diff --git a/Sources/Plasma/Apps/plClient/winmain.cpp b/Sources/Plasma/Apps/plClient/winmain.cpp index e003f674..94bcdd5b 100644 --- a/Sources/Plasma/Apps/plClient/winmain.cpp +++ b/Sources/Plasma/Apps/plClient/winmain.cpp @@ -366,7 +366,15 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) static uint32_t keyState=0; // Handle messages - switch (message) { + switch (message) { + case WM_TIMECHANGE: + // To prevent cheating and keep things better synchronized, + // we will completely re-eval the offsets on the next NetMsg we + // get from the server + if (plNetClientMgr* nc = plNetClientMgr::GetInstance()) + nc->ResetServerTimeOffset(true); + break; + case WM_KEYDOWN : case WM_LBUTTONDOWN : case WM_RBUTTONDOWN : diff --git a/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.cpp b/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.cpp index b3a9c693..f563a2c6 100644 --- a/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.cpp +++ b/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.cpp @@ -506,9 +506,10 @@ void plNetClientMgr::UpdateServerTimeOffset(plNetMessage* msg) } } -void plNetClientMgr::ResetServerTimeOffset() +void plNetClientMgr::ResetServerTimeOffset(bool delayed) { - fServerTimeOffset = 0; + if (!delayed) + fServerTimeOffset = 0; fTimeSamples = 0; fLastTimeUpdate = 0; } diff --git a/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.h b/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.h index b2ac3af3..5d435364 100644 --- a/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.h +++ b/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.h @@ -383,7 +383,7 @@ public: void StoreSDLState(const plStateDataRecord* sdRec, const plUoid& uoid, uint32_t sendFlags, uint32_t writeOptions); void UpdateServerTimeOffset(plNetMessage* msg); - void ResetServerTimeOffset(); + void ResetServerTimeOffset(bool delayed=false); private: plNetClientComm fNetClientComm;