speed up InitEquipment

This commit is contained in:
Yunfan Li
2023-08-10 13:44:46 +08:00
parent 8fc864aa04
commit 3b85e3e4b9
4 changed files with 384 additions and 271 deletions

View File

@@ -166,10 +166,12 @@ class RandomItemMgr
std::vector<uint32> GetQuestIdsForItem(uint32 itemId);
static bool IsUsedBySkill(ItemTemplate const* proto, uint32 skillId);
bool IsTestItem(uint32 itemId) { return itemForTest.find(itemId) != itemForTest.end(); }
std::vector<uint32> GetCachedEquipments(uint32 requiredLevel, uint32 inventoryType);
private:
void BuildRandomItemCache();
void BuildEquipCache();
void BuildEquipCacheNew();
void BuildItemInfoCache();
void BuildAmmoCache();
void BuildFoodCache();
@@ -180,7 +182,6 @@ class RandomItemMgr
bool CanEquipItemNew(ItemTemplate const* proto);
void AddItemStats(uint32 mod, uint8& sp, uint8& ap, uint8& tank);
bool CheckItemStats(uint8 clazz, uint8 sp, uint8 ap, uint8 tank);
private:
std::map<uint32, RandomItemCache> randomItemCache;
std::map<RandomItemType, RandomItemPredicate*> predicates;
@@ -197,6 +198,8 @@ class RandomItemMgr
std::map<uint32, ItemInfoEntry> itemInfoCache;
std::set<uint32> itemForTest;
static std::set<uint32> itemCache;
// equipCacheNew[RequiredLevel][InventoryType]
std::map<uint32, std::map<uint32, std::vector<uint32>>> equipCacheNew;
};
#define sRandomItemMgr RandomItemMgr::instance()