This commit is contained in:
aozhiwei 2022-12-25 16:10:13 +08:00
parent 2260009fc2
commit f330657fbd
2 changed files with 18 additions and 2 deletions

View File

@ -4,6 +4,7 @@
#include "mt/Buff.h"
IMPL_TABLE(mt::Equip)
std::map<int, const mt::Equip*> mt::Equip::slot_hash_;
namespace mt
{
@ -187,6 +188,14 @@ namespace mt
#endif
}
}
if (inventory_slot().empty()) {
_inventory_slot_ = -1;
} else {
_inventory_slot_ = a8::XValue(inventory_slot());
}
if (_inventory_slot() > -1) {
slot_hash_[_inventory_slot()] = this;
}
}
int Equip::GetWeaponIdx() const
@ -232,5 +241,10 @@ namespace mt
}
}
const Equip* Equip::GetByIdBySlotId(int slot_id)
{
auto itr = slot_hash_.find(slot_id);
return itr != slot_hash_.end() ? itr->second : nullptr;
}
}

View File

@ -34,8 +34,10 @@ namespace mt
void Init2();
int GetWeaponIdx() const;
bool Match(CondAddBuff_e cond, int val, int val2) const;
static const Equip* GetByIdBySlotId(int slot_id) {};
static const Equip* GetByIdBySlotId(int slot_id);
private:
static std::map<int, const mt::Equip*> slot_hash_;
};
}