mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-22 10:05:32 +01:00
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:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user