Skip to content

Commit 70f1278

Browse files
committed
Core/Movement: Reduce differences between branches (move movement timestamp adjustment into separate function)
1 parent 0f8a33c commit 70f1278

3 files changed

Lines changed: 17 additions & 14 deletions

File tree

src/server/game/Handlers/MovementHandler.cpp

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -363,24 +363,14 @@ void WorldSession::HandleMovementOpcodes(WorldPacket& recvPacket)
363363
mover->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_LANDING); // Parachutes
364364

365365
/* process position-change */
366-
WorldPacket data(opcode, recvPacket.size());
367-
int64 movementTime = (int64) movementInfo.time + _timeSyncClockDelta;
368-
if (_timeSyncClockDelta == 0 || movementTime < 0 || movementTime > 0xFFFFFFFF)
369-
{
370-
TC_LOG_WARN("misc", "The computed movement time using clockDelta is erronous. Using fallback instead");
371-
movementInfo.time = GameTime::GetGameTimeMS();
372-
}
373-
else
374-
{
375-
movementInfo.time = (uint32)movementTime;
376-
}
377-
378366
movementInfo.guid = mover->GetGUID();
367+
movementInfo.time = AdjustClientMovementTime(movementInfo.time);
368+
mover->m_movementInfo = movementInfo;
369+
370+
WorldPacket data(opcode, recvPacket.size());
379371
WriteMovementInfo(&data, &movementInfo);
380372
mover->SendMessageToSet(&data, _player);
381373

382-
mover->m_movementInfo = movementInfo;
383-
384374
// Some vehicles allow the passenger to turn by himself
385375
if (Vehicle* vehicle = mover->GetVehicle())
386376
{

src/server/game/Server/WorldSession.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1749,6 +1749,18 @@ void WorldSession::SendTimeSync()
17491749
_timeSyncNextCounter++;
17501750
}
17511751

1752+
uint32 WorldSession::AdjustClientMovementTime(uint32 time) const
1753+
{
1754+
int64 movementTime = int64(time) + _timeSyncClockDelta;
1755+
if (_timeSyncClockDelta == 0 || movementTime < 0 || movementTime > 0xFFFFFFFF)
1756+
{
1757+
TC_LOG_WARN("misc", "The computed movement time using clockDelta is erronous. Using fallback instead");
1758+
return GameTime::GetGameTimeMS();
1759+
}
1760+
else
1761+
return uint32(movementTime);
1762+
}
1763+
17521764
bool WorldSession::IsRightUnitBeingMoved(ObjectGuid guid)
17531765
{
17541766
GameClient* client = GetGameClient();

src/server/game/Server/WorldSession.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,7 @@ class TC_GAME_API WorldSession
662662
// Time Synchronisation
663663
void ResetTimeSync();
664664
void SendTimeSync();
665+
uint32 AdjustClientMovementTime(uint32 time) const;
665666

666667
// Packets cooldown
667668
time_t GetCalendarEventCreationCooldown() const { return _calendarEventCreationCooldown; }

0 commit comments

Comments
 (0)