[9475] Add and use TotemSlot enum type

This commit is contained in:
VladimirMangos 2010-02-28 07:18:43 +03:00
parent 7e2d7d8324
commit ded1e3c263
10 changed files with 85 additions and 82 deletions

View file

@ -213,7 +213,7 @@ Unit::Unit()
m_addDmgOnce = 0;
for(int i = 0; i < MAX_TOTEM; ++i)
for(int i = 0; i < MAX_TOTEM_SLOT; ++i)
m_TotemSlot[i] = 0;
m_ObjectSlot[0] = m_ObjectSlot[1] = m_ObjectSlot[2] = m_ObjectSlot[3] = 0;
@ -8666,31 +8666,52 @@ Pet* Unit::FindGuardianWithEntry(uint32 entry)
return NULL;
}
Unit* Unit::_GetTotem(uint8 slot) const
Unit* Unit::_GetTotem(TotemSlot slot) const
{
return GetTotem(slot);
}
Totem* Unit::GetTotem( uint8 slot ) const
Totem* Unit::GetTotem(TotemSlot slot ) const
{
if(slot >= MAX_TOTEM || !IsInWorld())
if(slot >= MAX_TOTEM_SLOT || !IsInWorld())
return NULL;
Creature *totem = GetMap()->GetCreature(m_TotemSlot[slot]);
return totem && totem->isTotem() ? (Totem*)totem : NULL;
}
bool Unit::IsAllTotemSlotsUsed() const
{
for (int i = 0; i < MAX_TOTEM_SLOT; ++i)
if (!m_TotemSlot[i])
return false;
return true;
}
void Unit::_AddTotem(TotemSlot slot, Totem* totem)
{
m_TotemSlot[slot] = totem->GetGUID();
}
void Unit::_RemoveTotem(Totem* totem)
{
for(int i = 0; i < MAX_TOTEM_SLOT; ++i)
{
if (m_TotemSlot[i] == totem->GetGUID())
{
m_TotemSlot[i] = 0;
break;
}
}
}
void Unit::UnsummonAllTotems()
{
for (int8 i = 0; i < MAX_TOTEM; ++i)
{
if(!m_TotemSlot[i])
continue;
Creature *OldTotem = GetMap()->GetCreature(m_TotemSlot[i]);
if (OldTotem && OldTotem->isTotem())
((Totem*)OldTotem)->UnSummon();
}
for (int i = 0; i < MAX_TOTEM_SLOT; ++i)
if (Totem* totem = GetTotem(TotemSlot(i)))
totem->UnSummon();
}
int32 Unit::DealHeal(Unit *pVictim, uint32 addhealth, SpellEntry const *spellProto, bool critical)