Core/Movement: Port Ascent r1637 http://sourceforge.net/p/ascentemubackup/code/1637/ to TrinityCore
Port some movement packet fixes, taking into account client/server connection lag. Credits to original author, check http://sourceforge.net/p/ascentemubackup/code/1637/ for more details. MOVEMENT_PACKET_TIME_DELAY default value is currently set to 0, feel free to set it to different values and report feedback.
This commit is contained in:
@@ -31,6 +31,8 @@
|
||||
#include "InstanceSaveMgr.h"
|
||||
#include "ObjectMgr.h"
|
||||
|
||||
#define MOVEMENT_PACKET_TIME_DELAY 0
|
||||
|
||||
void WorldSession::HandleMoveWorldportAckOpcode(WorldPacket & /*recvData*/)
|
||||
{
|
||||
TC_LOG_DEBUG(LOG_FILTER_NETWORKIO, "WORLD: got MSG_MOVE_WORLDPORT_ACK.");
|
||||
@@ -359,11 +361,15 @@ void WorldSession::HandleMovementOpcodes(WorldPacket& recvData)
|
||||
plrMover->SetInWater(!plrMover->IsInWater() || plrMover->GetBaseMap()->IsUnderWater(movementInfo.pos.GetPositionX(), movementInfo.pos.GetPositionY(), movementInfo.pos.GetPositionZ()));
|
||||
}
|
||||
|
||||
uint32 mstime = getMSTime();
|
||||
/*----------------------*/
|
||||
if(m_clientTimeDelay == 0)
|
||||
m_clientTimeDelay = mstime - movementInfo.time;
|
||||
|
||||
/* process position-change */
|
||||
WorldPacket data(opcode, recvData.size());
|
||||
movementInfo.time = getMSTime();
|
||||
movementInfo.time = movementInfo.time + m_clientTimeDelay + MOVEMENT_PACKET_TIME_DELAY;
|
||||
|
||||
movementInfo.guid = mover->GetGUID();
|
||||
WriteMovementInfo(&data, &movementInfo);
|
||||
mover->SendMessageToSet(&data, _player);
|
||||
|
||||
@@ -115,6 +115,7 @@ WorldSession::WorldSession(uint32 id, WorldSocket* sock, AccountTypes sec, uint8
|
||||
m_sessionDbcLocale(sWorld->GetAvailableDbcLocale(locale)),
|
||||
m_sessionDbLocaleIndex(locale),
|
||||
m_latency(0),
|
||||
m_clientTimeDelay(0),
|
||||
m_TutorialsChanged(false),
|
||||
recruiterId(recruiter),
|
||||
isRecruiter(isARecruiter),
|
||||
|
||||
@@ -352,6 +352,7 @@ class WorldSession
|
||||
|
||||
uint32 GetLatency() const { return m_latency; }
|
||||
void SetLatency(uint32 latency) { m_latency = latency; }
|
||||
void ResetClientTimeDelay() { m_clientTimeDelay = 0; }
|
||||
uint32 getDialogStatus(Player* player, Object* questgiver, uint32 defstatus);
|
||||
|
||||
time_t m_timeOutTime;
|
||||
@@ -987,6 +988,7 @@ class WorldSession
|
||||
LocaleConstant m_sessionDbcLocale;
|
||||
LocaleConstant m_sessionDbLocaleIndex;
|
||||
uint32 m_latency;
|
||||
uint32 m_clientTimeDelay;
|
||||
AccountData m_accountData[NUM_ACCOUNT_DATA_TYPES];
|
||||
uint32 m_Tutorials[MAX_ACCOUNT_TUTORIAL_VALUES];
|
||||
bool m_TutorialsChanged;
|
||||
|
||||
@@ -1004,7 +1004,10 @@ int WorldSocket::HandlePing (WorldPacket& recvPacket)
|
||||
ACE_GUARD_RETURN (LockType, Guard, m_SessionLock, -1);
|
||||
|
||||
if (m_Session)
|
||||
{
|
||||
m_Session->SetLatency (latency);
|
||||
m_Session->ResetClientTimeDelay();
|
||||
}
|
||||
else
|
||||
{
|
||||
TC_LOG_ERROR(LOG_FILTER_NETWORKIO, "WorldSocket::HandlePing: peer sent CMSG_PING, "
|
||||
|
||||
Reference in New Issue
Block a user