[11330] Use ObjectGuid to store Totem guids instead of uint64 and fix related rare crash.

Signed-off-by: Ambal <pogrebniak@gala.net>
This commit is contained in:
rsa 2011-04-11 22:45:25 +03:00 committed by Ambal
parent 735f086992
commit cd32dd9bfc
5 changed files with 9 additions and 15 deletions

View file

@ -102,9 +102,6 @@ class MANGOS_DLL_SPEC ObjectGuid
void Set(uint64 const& guid) { m_guid = guid; }
void Clear() { m_guid = 0; }
// Possible removed in future for more strict control type conversions
void operator= (uint64 const& guid) { m_guid = guid; }
PackedGuid WriteAsPacked() const;
public: // accessors
uint64 const& GetRawValue() const { return m_guid; }

View file

@ -5012,7 +5012,7 @@ SpellCastResult Spell::CheckCast(bool strict)
if (m_spellInfo->SpellFamilyName == SPELLFAMILY_SHAMAN && m_spellInfo->SpellIconID == 33)
{
// fire totems slot
if (!m_caster->GetTotemGUID(TOTEM_SLOT_FIRE))
if (m_caster->GetTotemGuid(TOTEM_SLOT_FIRE).IsEmpty())
return SPELL_FAILED_TOTEMS;
}
break;

View file

@ -207,9 +207,6 @@ Unit::Unit()
m_addDmgOnce = 0;
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;
//m_Aura = NULL;
//m_AurasCheck = 2000;
@ -6005,7 +6002,7 @@ Unit* Unit::_GetTotem(TotemSlot slot) const
Totem* Unit::GetTotem(TotemSlot slot ) const
{
if(slot >= MAX_TOTEM_SLOT || !IsInWorld())
if(slot >= MAX_TOTEM_SLOT || !IsInWorld() || m_TotemSlot[slot].IsEmpty())
return NULL;
Creature *totem = GetMap()->GetCreature(m_TotemSlot[slot]);
@ -6015,23 +6012,23 @@ Totem* Unit::GetTotem(TotemSlot slot ) const
bool Unit::IsAllTotemSlotsUsed() const
{
for (int i = 0; i < MAX_TOTEM_SLOT; ++i)
if (!m_TotemSlot[i])
if (m_TotemSlot[i].IsEmpty())
return false;
return true;
}
void Unit::_AddTotem(TotemSlot slot, Totem* totem)
{
m_TotemSlot[slot] = totem->GetGUID();
m_TotemSlot[slot] = totem->GetObjectGuid();
}
void Unit::_RemoveTotem(Totem* totem)
{
for(int i = 0; i < MAX_TOTEM_SLOT; ++i)
{
if (m_TotemSlot[i] == totem->GetGUID())
if (m_TotemSlot[i] == totem->GetObjectGuid())
{
m_TotemSlot[i] = 0;
m_TotemSlot[i].Clear();
break;
}
}

View file

@ -1552,7 +1552,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject
CharmInfo* GetCharmInfo() { return m_charmInfo; }
CharmInfo* InitCharmInfo(Unit* charm);
uint64 const& GetTotemGUID(TotemSlot slot) const { return m_TotemSlot[slot]; }
ObjectGuid const& GetTotemGuid(TotemSlot slot) const { return m_TotemSlot[slot]; }
Totem* GetTotem(TotemSlot slot) const;
bool IsAllTotemSlotsUsed() const;
@ -2041,7 +2041,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject
GuardianPetList m_guardianPets;
uint64 m_TotemSlot[MAX_TOTEM_SLOT];
ObjectGuid m_TotemSlot[MAX_TOTEM_SLOT];
private: // Error traps for some wrong args using
// this will catch and prevent build for any cases when all optional args skipped and instead triggered used non boolean type

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "11329"
#define REVISION_NR "11330"
#endif // __REVISION_NR_H__