mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
Entities/Unit: Cleanup all the direct accesses to m_unitMovedByMe. Refactor the field to be protected. Add assertions to catch dangling pointers.
(cherry picked from commit 396f87c30d)
This commit is contained in:
@@ -43,7 +43,7 @@ void WorldSession::HandleUseItemOpcode(WorldPackets::Spells::UseItem& packet)
|
||||
Player* user = _player;
|
||||
|
||||
// ignore for remote control state
|
||||
if (user->m_unitMovedByMe != user)
|
||||
if (user->GetUnitBeingMoved() != user)
|
||||
return;
|
||||
|
||||
Item* item = user->GetUseableItemByPos(packet.PackSlot, packet.Slot);
|
||||
@@ -137,7 +137,7 @@ void WorldSession::HandleOpenItemOpcode(WorldPackets::Spells::OpenItem& packet)
|
||||
Player* player = GetPlayer();
|
||||
|
||||
// ignore for remote control state
|
||||
if (player->m_unitMovedByMe != player)
|
||||
if (player->GetUnitBeingMoved() != player)
|
||||
return;
|
||||
TC_LOG_INFO("network", "bagIndex: %u, slot: %u", packet.Slot, packet.PackSlot);
|
||||
|
||||
@@ -248,8 +248,8 @@ void WorldSession::HandleGameObjectUseOpcode(WorldPackets::GameObject::GameObjUs
|
||||
if (GameObject* obj = GetPlayer()->GetGameObjectIfCanInteractWith(packet.Guid))
|
||||
{
|
||||
// ignore for remote control state
|
||||
if (GetPlayer()->m_unitMovedByMe != GetPlayer())
|
||||
if (!(GetPlayer()->IsOnVehicle(GetPlayer()->m_unitMovedByMe) || GetPlayer()->IsMounted()) && !obj->GetGOInfo()->IsUsableMounted())
|
||||
if (GetPlayer()->GetUnitBeingMoved() != GetPlayer())
|
||||
if (!(GetPlayer()->IsOnVehicle(GetPlayer()->GetUnitBeingMoved()) || GetPlayer()->IsMounted()) && !obj->GetGOInfo()->IsUsableMounted())
|
||||
return;
|
||||
|
||||
obj->Use(GetPlayer());
|
||||
@@ -259,7 +259,7 @@ void WorldSession::HandleGameObjectUseOpcode(WorldPackets::GameObject::GameObjUs
|
||||
void WorldSession::HandleGameobjectReportUse(WorldPackets::GameObject::GameObjReportUse& packet)
|
||||
{
|
||||
// ignore for remote control state
|
||||
if (_player->m_unitMovedByMe != _player)
|
||||
if (_player->GetUnitBeingMoved() != _player)
|
||||
return;
|
||||
|
||||
if (GameObject* go = GetPlayer()->GetGameObjectIfCanInteractWith(packet.Guid))
|
||||
@@ -274,7 +274,7 @@ void WorldSession::HandleGameobjectReportUse(WorldPackets::GameObject::GameObjRe
|
||||
void WorldSession::HandleCastSpellOpcode(WorldPackets::Spells::CastSpell& cast)
|
||||
{
|
||||
// ignore for remote control state (for player case)
|
||||
Unit* mover = _player->m_unitMovedByMe;
|
||||
Unit* mover = _player->GetUnitBeingMoved();
|
||||
if (mover != _player && mover->GetTypeId() == TYPEID_PLAYER)
|
||||
return;
|
||||
|
||||
@@ -482,7 +482,7 @@ void WorldSession::HandleCancelAutoRepeatSpellOpcode(WorldPackets::Spells::Cance
|
||||
void WorldSession::HandleCancelChanneling(WorldPackets::Spells::CancelChannelling& /*cancelChanneling*/)
|
||||
{
|
||||
// ignore for remote control state (for player case)
|
||||
Unit* mover = _player->m_unitMovedByMe;
|
||||
Unit* mover = _player->GetUnitBeingMoved();
|
||||
if (mover != _player && mover->GetTypeId() == TYPEID_PLAYER)
|
||||
return;
|
||||
|
||||
@@ -492,7 +492,7 @@ void WorldSession::HandleCancelChanneling(WorldPackets::Spells::CancelChannellin
|
||||
void WorldSession::HandleTotemDestroyed(WorldPackets::Totem::TotemDestroyed& totemDestroyed)
|
||||
{
|
||||
// ignore for remote control state
|
||||
if (_player->m_unitMovedByMe != _player)
|
||||
if (_player->GetUnitBeingMoved() != _player)
|
||||
return;
|
||||
|
||||
uint8 slotId = totemDestroyed.Slot;
|
||||
|
||||
Reference in New Issue
Block a user