diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 916a697ae..d33fa88c4 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -8442,6 +8442,20 @@ Pet* Unit::FindGuardianWithEntry(uint32 entry) return NULL; } +Unit* Unit::_GetTotem(uint8 slot) const +{ + return GetTotem(slot); +} + +Totem* Unit::GetTotem( uint8 slot ) const +{ + if(slot >= MAX_TOTEM) + return NULL; + + Creature *totem = GetMap()->GetCreature(m_TotemSlot[slot]); + return totem->isTotem() ? (Totem*)totem : NULL; +} + void Unit::UnsummonAllTotems() { for (int8 i = 0; i < MAX_TOTEM; ++i) diff --git a/src/game/Unit.h b/src/game/Unit.h index d919286cf..f5c915479 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -299,6 +299,7 @@ class Item; class Pet; class Path; class PetAura; +class Totem; struct SpellImmune { @@ -1242,6 +1243,8 @@ class MANGOS_DLL_SPEC Unit : public WorldObject Pet* CreateTamedPetFrom(Creature* creatureTarget,uint32 spell_id = 0); + Totem* GetTotem(uint8 slot) const; + template void CallForAllControlledUnits(Func const& func, bool withTotems, bool withGuardians, bool withCharms); template @@ -1645,6 +1648,8 @@ class MANGOS_DLL_SPEC Unit : public WorldObject float GetCombatRatingReduction(CombatRating cr) const; uint32 GetCombatRatingDamageReduction(CombatRating cr, float rate, float cap, uint32 damage) const; + Unit* _GetTotem(uint8 slot) const; // for templated function without include need + uint32 m_state; // Even derived shouldn't modify uint32 m_CombatTimer; @@ -1681,9 +1686,8 @@ void Unit::CallForAllControlledUnits(Func const& func, bool withTotems, bool wit if (withTotems) { for (int8 i = 0; i < MAX_TOTEM; ++i) - if(m_TotemSlot[i]) - if(Creature *totem = GetMap()->GetCreature(m_TotemSlot[i])) - func(totem); + if (Unit *totem = _GetTotem(i)) + func(totem); } if (withCharms) @@ -1711,10 +1715,9 @@ bool Unit::CheckAllControlledUnits(Func const& func, bool withTotems, bool withG if (withTotems) { for (int8 i = 0; i < MAX_TOTEM; ++i) - if (m_TotemSlot[i]) - if (Creature *totem = GetMap()->GetCreature(m_TotemSlot[i])) - if (func(totem)) - return true; + if (Unit *totem = _GetTotem(i)) + if (func(totem)) + return true; } if (withCharms) diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index f6c1d0a29..11dcf5f55 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "9188" + #define REVISION_NR "9189" #endif // __REVISION_NR_H__