aboutsummaryrefslogtreecommitdiff
path: root/src/game/GameObject.cpp
diff options
context:
space:
mode:
authorraczman <none@none>2010-03-07 15:20:19 +0100
committerraczman <none@none>2010-03-07 15:20:19 +0100
commit91b8ee104eac7446f9b8cbea7ed9dce641740c8e (patch)
tree2866b76745089d8066dad65b63e5aff07e92f4f6 /src/game/GameObject.cpp
parentaeebe57dc08d8b2d90972f50f00c4a28dd3947ba (diff)
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
Diffstat (limited to 'src/game/GameObject.cpp')
-rw-r--r--src/game/GameObject.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/game/GameObject.cpp b/src/game/GameObject.cpp
index 8239b2cccad..8f47aa83a2a 100644
--- a/src/game/GameObject.cpp
+++ b/src/game/GameObject.cpp
@@ -253,9 +253,9 @@ void GameObject::Update(uint32 /*p_time*/)
UpdateData udata;
WorldPacket packet;
- BuildValuesUpdateBlockForPlayer(&udata,((Player*)caster));
+ BuildValuesUpdateBlockForPlayer(&udata,caster->ToPlayer());
udata.BuildPacket(&packet);
- ((Player*)caster)->GetSession()->SendPacket(&packet);
+ caster->ToPlayer()->GetSession()->SendPacket(&packet);
SendCustomAnim();
}
@@ -290,7 +290,7 @@ void GameObject::Update(uint32 /*p_time*/)
caster->FinishSpell(CURRENT_CHANNELED_SPELL);
WorldPacket data(SMSG_FISH_ESCAPED,0);
- ((Player*)caster)->GetSession()->SendPacket(&data);
+ caster->ToPlayer()->GetSession()->SendPacket(&data);
}
// can be delete
m_lootState = GO_JUST_DEACTIVATED;
@@ -396,8 +396,8 @@ void GameObject::Update(uint32 /*p_time*/)
if(IsBattleGroundTrap && ok->GetTypeId() == TYPEID_PLAYER)
{
//BattleGround gameobjects case
- if(((Player*)ok)->InBattleGround())
- if(BattleGround *bg = ((Player*)ok)->GetBattleGround())
+ if(ok->ToPlayer()->InBattleGround())
+ if(BattleGround *bg = ok->ToPlayer()->GetBattleGround())
bg->HandleTriggerBuff(GetGUID());
}
}
@@ -1271,7 +1271,7 @@ void GameObject::Use(Unit* user)
return;
// accept only use by player from same group for caster except caster itself
- if(((Player*)caster)==player || !((Player*)caster)->IsInSameRaidWith(player))
+ if(caster->ToPlayer()==player || !caster->ToPlayer()->IsInSameRaidWith(player))
return;
AddUniqueUse(player);
@@ -1318,7 +1318,7 @@ void GameObject::Use(Unit* user)
if( !caster || caster->GetTypeId() != TYPEID_PLAYER )
return;
- if(user->GetTypeId() != TYPEID_PLAYER || !((Player*)user)->IsInSameRaidWith((Player*)caster))
+ if(user->GetTypeId() != TYPEID_PLAYER || !user->ToPlayer()->IsInSameRaidWith(caster->ToPlayer()))
return;
}