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:
Treeston
2019-06-23 16:44:37 +02:00
parent b3ee407707
commit 396f87c30d
8 changed files with 36 additions and 50 deletions

View File

@@ -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