File tree Expand file tree Collapse file tree 7 files changed +14
-14
lines changed
Expand file tree Collapse file tree 7 files changed +14
-14
lines changed Original file line number Diff line number Diff line change @@ -212,31 +212,31 @@ class ChangeTimeTracker final
212212public:
213213 ChangeTimeTracker () :
214214 val (),
215- timeLastChange (std::time( nullptr ))
215+ timeLastChange (GetTickCount( ))
216216 {}
217217 ChangeTimeTracker (T defaultVal) :
218218 val (std::move(defaultVal)),
219- timeLastChange (std::time( nullptr ))
219+ timeLastChange (GetTickCount( ))
220220 {}
221221
222222 inline const T& Get () const { return val; }
223223 inline operator const T&() const { return val; }
224224
225- inline std:: time_t GetTimeLastChange () const { return timeLastChange; }
226- inline std:: time_t GetSecondsSinceLastChange () const { return std::time ( nullptr ) - timeLastChange; }
225+ inline DWORD GetTimeLastChange () const { return timeLastChange; }
226+ inline DWORD GetTimePassedMS () const { return GetTickCount ( ) - timeLastChange; }
227227
228228 void operator =(const T& otherVal)
229229 {
230230 if (val == otherVal)
231231 return ;
232232
233233 val = otherVal;
234- timeLastChange = std::time ( nullptr );
234+ timeLastChange = GetTickCount ( );
235235 }
236236
237237private:
238238 T val;
239- std:: time_t timeLastChange;
239+ DWORD timeLastChange;
240240};
241241
242242/* * Struct padding */
Original file line number Diff line number Diff line change @@ -232,9 +232,9 @@ Match::Update()
232232 if (m_endTime == 0 )
233233 {
234234 SessionLog () << " [MATCH] " << m_guid << " : Game over, match will automatically close in 60 seconds!" << std::endl;
235- m_endTime = std::time ( nullptr );
235+ m_endTime = GetTickCount ( );
236236 }
237- else if (std::time ( nullptr ) - m_endTime >= 60 ) // A minute has passed since the match ended
237+ else if (GetTickCount ( ) - m_endTime >= 60000 ) // A minute has passed since the match ended
238238 {
239239 SessionLog () << " [MATCH] " << m_guid << " : Match ended a minute ago, closing!" << std::endl;
240240 m_state = STATE_ENDED;
Original file line number Diff line number Diff line change @@ -101,7 +101,7 @@ class Match : public ::Match<PlayerSocket>
101101 // Mutex to prevent simultaneous match processes, like adding/removing players and processing events and removal of the match
102102 HANDLE m_mutex;
103103
104- std:: time_t m_endTime;
104+ DWORD m_endTime;
105105
106106private:
107107 Match (const Match&) = delete ;
Original file line number Diff line number Diff line change @@ -72,7 +72,7 @@ PlayerSocket::ProcessMessages()
7272 // Time out the client in states not involving participation in a match
7373 if (m_state != STATE_WAITINGFOROPPONENTS &&
7474 m_state != STATE_PLAYING &&
75- m_state.GetSecondsSinceLastChange () >= 60 )
75+ m_state.GetTimePassedMS () >= 60000 )
7676 {
7777 throw std::runtime_error (" Win7::PlayerSocket::ProcessMessages(): Timeout: Client has not switched from state "
7878 + std::to_string (m_state) + " for 60 seconds or more!" );
Original file line number Diff line number Diff line change @@ -261,9 +261,9 @@ Match::Update()
261261 if (m_endTime == 0 )
262262 {
263263 SessionLog () << " [MATCH] " << m_guid << " : Game over, match will automatically close in 60 seconds!" << std::endl;
264- m_endTime = std::time ( nullptr );
264+ m_endTime = GetTickCount ( );
265265 }
266- else if (std::time ( nullptr ) - m_endTime >= 60 ) // A minute has passed since the match ended
266+ else if (GetTickCount ( ) - m_endTime >= 60000 ) // A minute has passed since the match ended
267267 {
268268 SessionLog () << " [MATCH] " << m_guid << " : Match ended a minute ago, closing!" << std::endl;
269269 m_state = STATE_ENDED;
Original file line number Diff line number Diff line change @@ -114,7 +114,7 @@ class Match : public ::Match<PlayerSocket>
114114
115115 std::array<uint32, MATCH_MAX_PLAYERS> m_playerComputerIDs; // IDs of computer players by seat.
116116
117- std:: time_t m_endTime;
117+ DWORD m_endTime;
118118
119119private:
120120 Match (const Match&) = delete ;
Original file line number Diff line number Diff line change @@ -175,7 +175,7 @@ PlayerSocket::ProcessMessages()
175175 // Time out the client in states not involving participation in a match
176176 if (m_state != STATE_WAITINGFOROPPONENTS &&
177177 m_state != STATE_PLAYING &&
178- m_state.GetSecondsSinceLastChange () >= 60 )
178+ m_state.GetTimePassedMS () >= 60000 )
179179 {
180180 throw std::runtime_error (" WinXP::PlayerSocket::ProcessMessages(): Timeout: Client has not switched from state \" "
181181 + StateToString (m_state) + " \" for 60 seconds or more!" );
You can’t perform that action at this time.
0 commit comments