- switched to new time functions
authorAkiko <akiko@linux-addicted.net>
Mon, 1 Jun 2015 10:40:21 +0000 (12:40 +0200)
committerAkiko <akiko@linux-addicted.net>
Mon, 1 Jun 2015 10:40:21 +0000 (12:40 +0200)
TinNS/Source/Common/Netcode.cxx
TinNS/Source/Common/Time.cxx
TinNS/Source/Common/Time.hxx
TinNS/Source/GameServer/VehicleAccessRequest.cxx

index e1cdec8..5216c41 100644 (file)
@@ -58,8 +58,7 @@ char* ConnectionTCP::getRemoteAddress()
 
 bool ConnectionTCP::timeOut() const
 {
-    time_t now = std::time(nullptr);
-    if((now-mLastActive) >= mTimeOutValue)
+    if ((Time::nowTimeT() - mLastActive) >= mTimeOutValue)
         return true;
 
     return false;
@@ -562,8 +561,7 @@ void ConnectionUDP::ReSendUDPMessage(uint16_t nUDP_ID)
 
 bool ConnectionUDP::timeOut() const
 {
-    time_t now = std::time(nullptr);
-    if((now-mLastActive) >= mTimeOutValue)
+    if ((Time::nowTimeT() - mLastActive) >= mTimeOutValue)
         return true;
 
     return false;
index 8c81a9d..c2d9e5d 100644 (file)
@@ -11,6 +11,11 @@ namespace Time
         return Clock::now();
     }
 
+    time_t nowTimeT()
+    {
+        return toTimeT(now());
+    }
+
     time_t toTimeT(const Timepoint &timepoint)
     {
         return Clock::to_time_t(timepoint);
index 63b14cd..2f1fd6b 100644 (file)
@@ -18,6 +18,7 @@ namespace Time
 
     //--- functions ---
     Timepoint now();
+    time_t nowTimeT();
 
     time_t toTimeT(const Timepoint &timepoint);
     Timepoint toTimepoint(const time_t timet);
index 38a97b4..cdec035 100644 (file)
@@ -1,4 +1,5 @@
 #include "GameServer/Includes.hxx"
+#include "Common/Includes.hxx"
 
 PVhcAccessRequest::PVhcAccessRequest()
 {
@@ -27,8 +28,7 @@ std::time_t mReuseWaitTime; // How long do we allow user to re-use the autorizat
 */
 void PVhcAccessRequestList::DropTimedOut()
 {
-  std::time_t now = std::time( NULL );
-  std::time_t timeout;
+  time_t timeout;
 
   for ( PVhcAccessRequestMap::iterator it = mActiveRequests.begin(); it != mActiveRequests.end(); it++ )
   {
@@ -47,10 +47,8 @@ void PVhcAccessRequestList::DropTimedOut()
         timeout = 0;
         break;
     }
-    if ( it->second.mTimestamp > ( now + timeout ) )
-    {
+    if (it->second.mTimestamp > (Time::nowTimeT() + timeout))
       mActiveRequests.erase( it );
-    }
   }
 }