Added new type-safe cast functions.

This, when properly used, should get rid of most memory corruption issues,
currently, casting types C-style with no checks leads to some abstract crashing.
Functionality is same as with dynamic_cast<>, but with no RTTI check - so when
casting into invalid type you will receive NULL, and most probably crash.
At the same time, i took the liberty to convert most Player* casts to ToPlayer().
Still needs crapload of casts being moved to new facility.

--HG--
branch : trunk
This commit is contained in:
raczman
2010-03-07 15:20:19 +01:00
parent aeebe57dc0
commit 91b8ee104e
30 changed files with 674 additions and 663 deletions
+3 -3
View File
@@ -209,10 +209,10 @@ void PetAI::UpdateAI(const uint32 diff)
{
m_creature->SetInFront(target);
if(target && target->GetTypeId() == TYPEID_PLAYER)
m_creature->SendUpdateToPlayer((Player*)target);
m_creature->SendUpdateToPlayer(target->ToPlayer());
if(owner && owner->GetTypeId() == TYPEID_PLAYER)
m_creature->SendUpdateToPlayer((Player*)owner);
m_creature->SendUpdateToPlayer(owner->ToPlayer());
}
m_creature->AddCreatureSpellCooldown(spell->m_spellInfo->Id);
@@ -236,7 +236,7 @@ void PetAI::UpdateAllies()
if(!owner)
return;
else if(owner->GetTypeId() == TYPEID_PLAYER)
pGroup = ((Player*)owner)->GetGroup();
pGroup = owner->ToPlayer()->GetGroup();
//only pet and owner/not in group->ok
if(m_AllySet.size() == 2 && !pGroup)