Browse Source

Merge pull request #173 from Hoikas/time

Time Fixes
Branan Purvine-Riley 13 years ago
parent
commit
9137df7763
  1. 8
      Sources/Plasma/Apps/plClient/winmain.cpp
  2. 10
      Sources/Plasma/FeatureLib/pfPython/cyMisc.cpp
  3. 3
      Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.cpp
  4. 2
      Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.h

8
Sources/Plasma/Apps/plClient/winmain.cpp

@ -367,6 +367,14 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
// Handle messages // 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_KEYDOWN :
case WM_LBUTTONDOWN : case WM_LBUTTONDOWN :
case WM_RBUTTONDOWN : case WM_RBUTTONDOWN :

10
Sources/Plasma/FeatureLib/pfPython/cyMisc.cpp

@ -648,19 +648,19 @@ time_t cyMisc::ConvertGMTtoDni(time_t gtime)
plUnifiedTime utime = plUnifiedTime(); plUnifiedTime utime = plUnifiedTime();
utime.SetSecs(dtime); utime.SetSecs(dtime);
// check for daylight savings time in New Mexico and adjust // check for daylight savings time in New Mexico and adjust
if ( utime.GetMonth() >= 4 && utime.GetMonth() < 11 ) if ( utime.GetMonth() >= 3 && utime.GetMonth() < 11 )
{ {
plUnifiedTime dstStart = plUnifiedTime(); plUnifiedTime dstStart = plUnifiedTime();
dstStart.SetGMTime(utime.GetYear(),4,1,2,0,0); dstStart.SetGMTime(utime.GetYear(),3,7,2,0,0);
// find first Sunday after 4/1 (first sunday of April) // find first Sunday after 3/7 (second Sunday of March)
int days_to_go = 7 - dstStart.GetDayOfWeek(); int days_to_go = 7 - dstStart.GetDayOfWeek();
if (days_to_go == 7) if (days_to_go == 7)
days_to_go = 0; days_to_go = 0;
time_t dstStartSecs = dstStart.GetSecs() + days_to_go * kOneDay; time_t dstStartSecs = dstStart.GetSecs() + days_to_go * kOneDay;
plUnifiedTime dstEnd = plUnifiedTime(); plUnifiedTime dstEnd = plUnifiedTime();
dstEnd.SetGMTime(utime.GetYear(),10,25,1,0,0); dstEnd.SetGMTime(utime.GetYear(),11,1,1,0,0);
// find first sunday after 10/25 (last sunday of Oct.) // find first sunday after 11/1 (first Sunday of November)
days_to_go = 7 - dstEnd.GetDayOfWeek(); days_to_go = 7 - dstEnd.GetDayOfWeek();
if (days_to_go == 7) if (days_to_go == 7)
days_to_go = 0; days_to_go = 0;

3
Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.cpp

@ -506,8 +506,9 @@ void plNetClientMgr::UpdateServerTimeOffset(plNetMessage* msg)
} }
} }
void plNetClientMgr::ResetServerTimeOffset() void plNetClientMgr::ResetServerTimeOffset(bool delayed)
{ {
if (!delayed)
fServerTimeOffset = 0; fServerTimeOffset = 0;
fTimeSamples = 0; fTimeSamples = 0;
fLastTimeUpdate = 0; fLastTimeUpdate = 0;

2
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 StoreSDLState(const plStateDataRecord* sdRec, const plUoid& uoid, uint32_t sendFlags, uint32_t writeOptions);
void UpdateServerTimeOffset(plNetMessage* msg); void UpdateServerTimeOffset(plNetMessage* msg);
void ResetServerTimeOffset(); void ResetServerTimeOffset(bool delayed=false);
private: private:
plNetClientComm fNetClientComm; plNetClientComm fNetClientComm;

Loading…
Cancel
Save