mirror of
https://github.com/mod-playerbots/mod-playerbots
synced 2025-11-29 15:58:20 +08:00
speed up InitEquipment
This commit is contained in:
@@ -154,6 +154,7 @@ void RandomItemMgr::Init()
|
||||
{
|
||||
BuildItemInfoCache();
|
||||
// BuildEquipCache();
|
||||
BuildEquipCacheNew();
|
||||
BuildAmmoCache();
|
||||
BuildPotionCache();
|
||||
BuildFoodCache();
|
||||
@@ -441,6 +442,11 @@ bool RandomItemMgr::CheckItemStats(uint8 clazz, uint8 sp, uint8 ap, uint8 tank)
|
||||
return sp || ap || tank;
|
||||
}
|
||||
|
||||
std::vector<uint32> RandomItemMgr::GetCachedEquipments(uint32 requiredLevel, uint32 inventoryType)
|
||||
{
|
||||
return equipCacheNew[requiredLevel][inventoryType];
|
||||
}
|
||||
|
||||
bool RandomItemMgr::ShouldEquipArmorForSpec(uint8 playerclass, uint8 spec, ItemTemplate const* proto)
|
||||
{
|
||||
if (proto->InventoryType == INVTYPE_TABARD)
|
||||
@@ -2139,6 +2145,23 @@ void RandomItemMgr::BuildEquipCache()
|
||||
}
|
||||
}
|
||||
|
||||
void RandomItemMgr::BuildEquipCacheNew()
|
||||
{
|
||||
LOG_INFO("playerbots", "Loading equipments cache...");
|
||||
ItemTemplateContainer const* itemTemplates = sObjectMgr->GetItemTemplateStore();
|
||||
for (auto const& itr : *itemTemplates)
|
||||
{
|
||||
ItemTemplate const* proto = &itr.second;
|
||||
if (!proto)
|
||||
continue;
|
||||
uint32 itemId = proto->ItemId;
|
||||
if (IsTestItem(itemId)) {
|
||||
continue;
|
||||
}
|
||||
equipCacheNew[proto->RequiredLevel][proto->InventoryType].push_back(itemId);
|
||||
}
|
||||
}
|
||||
|
||||
RandomItemList RandomItemMgr::Query(uint32 level, uint8 clazz, uint8 slot, uint32 quality)
|
||||
{
|
||||
// return equipCache[key];
|
||||
|
||||
Reference in New Issue
Block a user