Core/ObjectMgr: Refactor sCreatureInfoAddonStorage
This commit is contained in:
@@ -2034,7 +2034,7 @@ CreatureAddon const* Creature::GetCreatureAddon() const
|
||||
}
|
||||
|
||||
// dependent from difficulty mode entry
|
||||
return ObjectMgr::GetCreatureTemplateAddon(GetCreatureInfo()->Entry);
|
||||
return sObjectMgr->GetCreatureTemplateAddon(GetCreatureInfo()->Entry);
|
||||
}
|
||||
|
||||
//creature_addon table
|
||||
|
||||
@@ -561,6 +561,77 @@ void ObjectMgr::LoadCreatureTemplates()
|
||||
sLog->outString();
|
||||
}
|
||||
|
||||
void ObjectMgr::LoadCreatureTemplateAddons()
|
||||
{
|
||||
uint32 oldMSTime = getMSTime();
|
||||
|
||||
// 0 1 2 3 4 5 6
|
||||
QueryResult result = WorldDatabase.Query("SELECT entry, path_id, mount, bytes1, bytes2, emote, auras FROM creature_template_addon");
|
||||
|
||||
if (!result)
|
||||
{
|
||||
sLog->outString(">> Loaded 0 creature template addon definitions. DB table `creature_addon` is empty.");
|
||||
sLog->outString();
|
||||
return;
|
||||
}
|
||||
|
||||
uint32 count = 0;
|
||||
do
|
||||
{
|
||||
Field *fields = result->Fetch();
|
||||
|
||||
uint32 entry = fields[0].GetUInt32();
|
||||
|
||||
if (!sCreatureStorage.LookupEntry<CreatureInfo>(entry))
|
||||
{
|
||||
sLog->outErrorDb("Creature template (Entry: %u) does not exist but has a record in `creature_template_addon`", entry);
|
||||
continue;
|
||||
}
|
||||
|
||||
CreatureAddon creatureAddon;
|
||||
|
||||
creatureAddon.path_id = fields[1].GetUInt32();
|
||||
creatureAddon.mount = fields[2].GetUInt32();
|
||||
creatureAddon.bytes1 = fields[3].GetUInt32();
|
||||
creatureAddon.bytes2 = fields[4].GetUInt32();
|
||||
creatureAddon.emote = fields[5].GetUInt32();
|
||||
|
||||
Tokens tokens(fields[6].GetString(), ' ');
|
||||
uint8 i = 0;
|
||||
creatureAddon.auras.resize(tokens.size());
|
||||
for (Tokens::iterator itr = tokens.begin(); itr != tokens.end(); ++itr)
|
||||
{
|
||||
SpellEntry const *AdditionalSpellInfo = sSpellStore.LookupEntry(uint32(atol(*itr)));
|
||||
if (!AdditionalSpellInfo)
|
||||
{
|
||||
sLog->outErrorDb("Creature (GUID: %u) has wrong spell %u defined in `auras` field in `creature_addon`.", entry, uint32(atol(*itr)));
|
||||
continue;
|
||||
}
|
||||
creatureAddon.auras[i++] = uint32(atol(*itr));
|
||||
}
|
||||
|
||||
if (creatureAddon.mount)
|
||||
{
|
||||
if (!sCreatureDisplayInfoStore.LookupEntry(creatureAddon.mount))
|
||||
{
|
||||
sLog->outErrorDb("Creature (GUID: %u) has invalid displayInfoId (%u) for mount defined in `creature_addon`", entry, creatureAddon.mount);
|
||||
creatureAddon.mount = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (!sEmotesStore.LookupEntry(creatureAddon.emote))
|
||||
sLog->outErrorDb("Creature (GUID: %u) has invalid emote (%u) defined in `creature_addon`.", entry, creatureAddon.emote);
|
||||
|
||||
CreatureTemplateAddonStore[entry] = creatureAddon;
|
||||
|
||||
++count;
|
||||
}
|
||||
while (result->NextRow());
|
||||
|
||||
sLog->outString(">> Loaded %u creature template addons in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
|
||||
sLog->outString();
|
||||
}
|
||||
|
||||
void ObjectMgr::CheckCreatureTemplate(CreatureInfo const* cInfo)
|
||||
{
|
||||
if (!cInfo)
|
||||
@@ -940,6 +1011,15 @@ CreatureAddon const * ObjectMgr::GetCreatureAddon(uint32 lowguid)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CreatureAddon const * ObjectMgr::GetCreatureTemplateAddon(uint32 entry)
|
||||
{
|
||||
CreatureAddonContainer::const_iterator itr = CreatureTemplateAddonStore.find(entry);
|
||||
if (itr != CreatureTemplateAddonStore.end())
|
||||
return &(itr->second);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
EquipmentInfo const* ObjectMgr::GetEquipmentInfo(uint32 entry)
|
||||
{
|
||||
EquipmentInfoContainer::const_iterator itr = EquipmentInfoStore.find(entry);
|
||||
|
||||
@@ -45,7 +45,6 @@
|
||||
#include <functional>
|
||||
|
||||
extern SQLStorage sCreatureStorage;
|
||||
extern SQLStorage sCreatureInfoAddonStorage;
|
||||
extern SQLStorage sGOStorage;
|
||||
|
||||
class Group;
|
||||
@@ -679,12 +678,7 @@ class ObjectMgr
|
||||
static void ChooseCreatureFlags(const CreatureInfo *cinfo, uint32& npcflag, uint32& unit_flags, uint32& dynamicflags, const CreatureData *data = NULL);
|
||||
EquipmentInfo const *GetEquipmentInfo(uint32 entry);
|
||||
CreatureAddon const *GetCreatureAddon(uint32 lowguid);
|
||||
|
||||
static CreatureAddon const *GetCreatureTemplateAddon(uint32 entry)
|
||||
{
|
||||
return sCreatureInfoAddonStorage.LookupEntry<CreatureAddon>(entry);
|
||||
}
|
||||
|
||||
CreatureAddon const *GetCreatureTemplateAddon(uint32 entry);
|
||||
ItemTemplate const* GetItemTemplate(uint32 entry);
|
||||
ItemTemplateContainer const* GetItemTemplateStore() { return &ItemTemplateStore; }
|
||||
|
||||
@@ -923,6 +917,7 @@ class ObjectMgr
|
||||
void LoadCreatureClassLevelStats();
|
||||
void LoadCreatureLocales();
|
||||
void LoadCreatureTemplates();
|
||||
void LoadCreatureTemplateAddons();
|
||||
void CheckCreatureTemplate(CreatureInfo const* cInfo);
|
||||
void LoadCreatures();
|
||||
void LoadLinkedRespawn();
|
||||
@@ -1404,6 +1399,7 @@ class ObjectMgr
|
||||
CreatureDataMap mCreatureDataMap;
|
||||
CreatureModelContainer CreatureModelStore;
|
||||
CreatureAddonContainer CreatureAddonStore;
|
||||
CreatureAddonContainer CreatureTemplateAddonStore;
|
||||
EquipmentInfoContainer EquipmentInfoStore;
|
||||
LinkedRespawnMap mLinkedRespawnMap;
|
||||
CreatureLocaleMap mCreatureLocaleMap;
|
||||
|
||||
@@ -1340,6 +1340,9 @@ void World::SetInitialWorldSettings()
|
||||
sLog->outString("Loading Creature templates...");
|
||||
sObjectMgr->LoadCreatureTemplates();
|
||||
|
||||
sLog->outString("Loading Creature template addons...");
|
||||
sObjectMgr->LoadCreatureTemplateAddons();
|
||||
|
||||
sLog->outString("Loading Vehicle scaling information...");
|
||||
sObjectMgr->LoadVehicleScaling();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user