Core/ObjectMgr: Refactor sCreatureDataAddonStorage
This commit is contained in:
@@ -2025,11 +2025,11 @@ bool Creature::canCreatureAttack(Unit const *pVictim, bool force) const
|
||||
return pVictim->IsInDist(&m_homePosition, dist);
|
||||
}
|
||||
|
||||
CreatureDataAddon const* Creature::GetCreatureAddon() const
|
||||
CreatureAddon const* Creature::GetCreatureAddon() const
|
||||
{
|
||||
if (m_DBTableGuid)
|
||||
{
|
||||
if (CreatureDataAddon const* addon = ObjectMgr::GetCreatureAddon(m_DBTableGuid))
|
||||
if (CreatureAddon const* addon = sObjectMgr->GetCreatureAddon(m_DBTableGuid))
|
||||
return addon;
|
||||
}
|
||||
|
||||
@@ -2040,7 +2040,7 @@ CreatureDataAddon const* Creature::GetCreatureAddon() const
|
||||
//creature_addon table
|
||||
bool Creature::LoadCreaturesAddon(bool reload)
|
||||
{
|
||||
CreatureDataAddon const *cainfo = GetCreatureAddon();
|
||||
CreatureAddon const *cainfo = GetCreatureAddon();
|
||||
if (!cainfo)
|
||||
return false;
|
||||
|
||||
@@ -2083,28 +2083,28 @@ bool Creature::LoadCreaturesAddon(bool reload)
|
||||
if (cainfo->path_id != 0)
|
||||
m_path_id = cainfo->path_id;
|
||||
|
||||
if (cainfo->auras)
|
||||
if (!cainfo->auras.empty())
|
||||
{
|
||||
for (CreatureDataAddonAura const* cAura = cainfo->auras; cAura->spell_id; ++cAura)
|
||||
for (std::vector<uint32>::const_iterator itr = cainfo->auras.begin(); itr != cainfo->auras.end(); ++itr)
|
||||
{
|
||||
SpellEntry const *AdditionalSpellInfo = sSpellStore.LookupEntry(cAura->spell_id);
|
||||
SpellEntry const *AdditionalSpellInfo = sSpellStore.LookupEntry(*itr);
|
||||
if (!AdditionalSpellInfo)
|
||||
{
|
||||
sLog->outErrorDb("Creature (GUID: %u Entry: %u) has wrong spell %u defined in `auras` field.",GetGUIDLow(),GetEntry(),cAura->spell_id);
|
||||
sLog->outErrorDb("Creature (GUID: %u Entry: %u) has wrong spell %u defined in `auras` field.", GetGUIDLow(), GetEntry(), *itr);
|
||||
continue;
|
||||
}
|
||||
|
||||
// skip already applied aura
|
||||
if (HasAura(cAura->spell_id))
|
||||
if (HasAura(*itr))
|
||||
{
|
||||
if (!reload)
|
||||
sLog->outErrorDb("Creature (GUID: %u Entry: %u) has duplicate aura (spell %u) in `auras` field.",GetGUIDLow(),GetEntry(),cAura->spell_id);
|
||||
sLog->outErrorDb("Creature (GUID: %u Entry: %u) has duplicate aura (spell %u) in `auras` field.", GetGUIDLow(), GetEntry(), *itr);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
AddAura(AdditionalSpellInfo, cAura->effectMask, this);
|
||||
sLog->outDebug(LOG_FILTER_UNITS, "Spell: %u with AuraEffectMask %u added to creature (GUID: %u Entry: %u)", cAura->spell_id, cAura->effectMask,GetGUIDLow(),GetEntry());
|
||||
AddAura(*itr, this);
|
||||
sLog->outDebug(LOG_FILTER_UNITS, "Spell: %u added to creature (GUID: %u Entry: %u)", *itr, GetGUIDLow(), GetEntry());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -263,14 +263,8 @@ struct CreatureData
|
||||
bool dbData;
|
||||
};
|
||||
|
||||
struct CreatureDataAddonAura
|
||||
{
|
||||
uint32 spell_id;
|
||||
uint8 effectMask;
|
||||
};
|
||||
|
||||
// from `creature_addon` table
|
||||
struct CreatureDataAddon
|
||||
// `creature_addon` table
|
||||
struct CreatureAddon
|
||||
{
|
||||
uint32 guidOrEntry;
|
||||
uint32 path_id;
|
||||
@@ -278,9 +272,11 @@ struct CreatureDataAddon
|
||||
uint32 bytes1;
|
||||
uint32 bytes2;
|
||||
uint32 emote;
|
||||
CreatureDataAddonAura const* auras; // loaded as char* "spell1 eff1 spell2 eff2 ... "
|
||||
std::vector<uint32> auras;
|
||||
};
|
||||
|
||||
typedef UNORDERED_MAP<uint32, CreatureAddon> CreatureAddonContainer;
|
||||
|
||||
struct CreatureModelInfo
|
||||
{
|
||||
float bounding_radius;
|
||||
@@ -533,7 +529,7 @@ class Creature : public Unit, public GridObject<Creature>
|
||||
|
||||
CreatureInfo const *GetCreatureInfo() const { return m_creatureInfo; }
|
||||
CreatureData const *GetCreatureData() const { return m_creatureData; }
|
||||
CreatureDataAddon const* GetCreatureAddon() const;
|
||||
CreatureAddon const* GetCreatureAddon() const;
|
||||
|
||||
std::string GetAIName() const;
|
||||
std::string GetScriptName() const;
|
||||
|
||||
Reference in New Issue
Block a user