mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-30 05:43:12 +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:
@@ -284,7 +284,7 @@ void WorldSession::HandlePetActionHelper(Unit *pet, uint64 guid1, uint16 spellid
|
||||
}
|
||||
if (Unit* powner = pet->GetCharmerOrOwner())
|
||||
if(powner->GetTypeId() == TYPEID_PLAYER)
|
||||
pet->SendUpdateToPlayer((Player*)powner);
|
||||
pet->SendUpdateToPlayer(powner->ToPlayer());
|
||||
result = SPELL_CAST_OK;
|
||||
}
|
||||
|
||||
@@ -535,8 +535,8 @@ void WorldSession::HandlePetRename( WorldPacket & recv_data )
|
||||
pet->SetName(name);
|
||||
|
||||
Unit *owner = pet->GetOwner();
|
||||
if(owner && (owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup())
|
||||
((Player*)owner)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_NAME);
|
||||
if(owner && (owner->GetTypeId() == TYPEID_PLAYER) && owner->ToPlayer()->GetGroup())
|
||||
owner->ToPlayer()->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_NAME);
|
||||
|
||||
pet->RemoveByteFlag(UNIT_FIELD_BYTES_2, 2, UNIT_CAN_BE_RENAMED);
|
||||
|
||||
@@ -753,7 +753,7 @@ void WorldSession::HandlePetCastSpellOpcode( WorldPacket& recvPacket )
|
||||
caster->SendPetCastFail(spellid, result);
|
||||
if(caster->GetTypeId() == TYPEID_PLAYER)
|
||||
{
|
||||
if(!((Player*)caster)->HasSpellCooldown(spellid))
|
||||
if(!caster->ToPlayer()->HasSpellCooldown(spellid))
|
||||
GetPlayer()->SendClearCooldown(spellid, caster);
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user