mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-02-10 03:59:05 +01:00
Entities/Unit: Cleanup all the direct accesses to m_unitMovedByMe. Refactor the field to be protected. Add assertions to catch dangling pointers.
This commit is contained in:
@@ -216,7 +216,7 @@ void WorldSession::HandleMoveTeleportAck(WorldPacket& recvData)
|
||||
uint32 sequenceIndex, time;
|
||||
recvData >> sequenceIndex >> time;
|
||||
|
||||
Player* plMover = _player->m_unitMovedByMe->ToPlayer();
|
||||
Player* plMover = _player->GetUnitBeingMoved()->ToPlayer();
|
||||
|
||||
if (!plMover || !plMover->IsBeingTeleportedNear())
|
||||
return;
|
||||
@@ -260,7 +260,7 @@ void WorldSession::HandleMovementOpcodes(WorldPacket& recvData)
|
||||
{
|
||||
uint16 opcode = recvData.GetOpcode();
|
||||
|
||||
Unit* mover = _player->m_unitMovedByMe;
|
||||
Unit* mover = _player->GetUnitBeingMoved();
|
||||
|
||||
ASSERT(mover != nullptr); // there must always be a mover
|
||||
|
||||
@@ -521,8 +521,8 @@ void WorldSession::HandleSetActiveMoverOpcode(WorldPacket &recvData)
|
||||
recvData >> guid;
|
||||
|
||||
if (GetPlayer()->IsInWorld())
|
||||
if (_player->m_unitMovedByMe->GetGUID() != guid)
|
||||
TC_LOG_DEBUG("network", "HandleSetActiveMoverOpcode: incorrect mover guid: mover is %s and should be %s" , guid.ToString().c_str(), _player->m_unitMovedByMe->GetGUID().ToString().c_str());
|
||||
if (_player->GetUnitBeingMoved()->GetGUID() != guid)
|
||||
TC_LOG_DEBUG("network", "HandleSetActiveMoverOpcode: incorrect mover guid: mover is %s and should be %s" , guid.ToString().c_str(), _player->GetUnitBeingMoved()->GetGUID().ToString().c_str());
|
||||
}
|
||||
|
||||
void WorldSession::HandleMoveNotActiveMover(WorldPacket &recvData)
|
||||
@@ -555,7 +555,7 @@ void WorldSession::HandleMoveKnockBackAck(WorldPacket& recvData)
|
||||
ObjectGuid guid;
|
||||
recvData >> guid.ReadAsPacked();
|
||||
|
||||
if (_player->m_unitMovedByMe->GetGUID() != guid)
|
||||
if (_player->GetUnitBeingMoved()->GetGUID() != guid)
|
||||
return;
|
||||
|
||||
recvData.read_skip<uint32>(); // unk
|
||||
|
||||
Reference in New Issue
Block a user