aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Entities
diff options
context:
space:
mode:
authorleak <leakzx@googlemail.com>2011-04-28 22:46:40 +0200
committerleak <leakzx@googlemail.com>2011-04-28 22:46:40 +0200
commitc8413a7f27cdb0de2f93d2437decdbc1628cb69e (patch)
treeb160ee8df25d3246f54de52abebc473bb0991295 /src/server/game/Entities
parenta82654debd8fd00fec3f2024290876ab0d6dd175 (diff)
Core/ObjectMgr: Refactor sCreatureDataAddonStorage
Diffstat (limited to 'src/server/game/Entities')
-rwxr-xr-xsrc/server/game/Entities/Creature/Creature.cpp22
-rwxr-xr-xsrc/server/game/Entities/Creature/Creature.h16
2 files changed, 17 insertions, 21 deletions
diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp
index a8ed317f7d5..f8e0c6224ce 100755
--- a/src/server/game/Entities/Creature/Creature.cpp
+++ b/src/server/game/Entities/Creature/Creature.cpp
@@ -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;
diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h
index 9dc3b00791a..d3f26590f07 100755
--- a/src/server/game/Entities/Creature/Creature.h
+++ b/src/server/game/Entities/Creature/Creature.h
@@ -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;