From: Akiko Date: Mon, 1 Jun 2015 10:40:21 +0000 (+0200) Subject: - switched to new time functions X-Git-Url: http://community.linux-addicted.net/gitweb/?a=commitdiff_plain;h=d75340ce318e8728af499e3bb04a05214b7e2b39;p=tinns.git - switched to new time functions --- diff --git a/TinNS/Source/Common/Netcode.cxx b/TinNS/Source/Common/Netcode.cxx index e1cdec8..5216c41 100644 --- a/TinNS/Source/Common/Netcode.cxx +++ b/TinNS/Source/Common/Netcode.cxx @@ -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; diff --git a/TinNS/Source/Common/Time.cxx b/TinNS/Source/Common/Time.cxx index 8c81a9d..c2d9e5d 100644 --- a/TinNS/Source/Common/Time.cxx +++ b/TinNS/Source/Common/Time.cxx @@ -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); diff --git a/TinNS/Source/Common/Time.hxx b/TinNS/Source/Common/Time.hxx index 63b14cd..2f1fd6b 100644 --- a/TinNS/Source/Common/Time.hxx +++ b/TinNS/Source/Common/Time.hxx @@ -18,6 +18,7 @@ namespace Time //--- functions --- Timepoint now(); + time_t nowTimeT(); time_t toTimeT(const Timepoint &timepoint); Timepoint toTimepoint(const time_t timet); diff --git a/TinNS/Source/GameServer/VehicleAccessRequest.cxx b/TinNS/Source/GameServer/VehicleAccessRequest.cxx index 38a97b4..cdec035 100644 --- a/TinNS/Source/GameServer/VehicleAccessRequest.cxx +++ b/TinNS/Source/GameServer/VehicleAccessRequest.cxx @@ -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 ); - } } }