diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/account-server/main-account.cpp | 3 | ||||
-rw-r--r-- | src/game-server/main-game.cpp | 2 | ||||
-rw-r--r-- | src/utils/timer.cpp | 27 | ||||
-rw-r--r-- | src/utils/timer.h | 10 |
4 files changed, 21 insertions, 21 deletions
diff --git a/src/account-server/main-account.cpp b/src/account-server/main-account.cpp index 19ffb23f..b0373db9 100644 --- a/src/account-server/main-account.cpp +++ b/src/account-server/main-account.cpp @@ -359,6 +359,9 @@ int main(int argc, char *argv[]) // Check for expired bans every 30 seconds utils::Timer banTimer(30000); + statTimer.start(); + banTimer.start(); + // ------------------------------------------------------------------------- // FIXME: for testing purposes only... // writing accountserver startup time and svn revision to database as global diff --git a/src/game-server/main-game.cpp b/src/game-server/main-game.cpp index e7a06c84..62da4f9c 100644 --- a/src/game-server/main-game.cpp +++ b/src/game-server/main-game.cpp @@ -78,7 +78,7 @@ using utils::Logger; static int const WORLD_TICK_SKIP = 2; /** tolerance for lagging behind in world calculation) **/ /** Timer for world ticks */ -utils::Timer worldTimer(WORLD_TICK_MS, false); +utils::Timer worldTimer(WORLD_TICK_MS); int worldTime = 0; /**< Current world time in ticks */ bool running = true; /**< Determines if server keeps running */ diff --git a/src/utils/timer.cpp b/src/utils/timer.cpp index a79a546f..aea10add 100644 --- a/src/utils/timer.cpp +++ b/src/utils/timer.cpp @@ -27,12 +27,25 @@ #include <windows.h> #endif +/** + * Calls gettimeofday() and converts it into milliseconds. + */ +static uint64_t getTimeInMillisec() +{ + uint64_t timeInMillisec; + timeval time; + + gettimeofday(&time, 0); + timeInMillisec = (uint64_t)time.tv_sec * 1000 + time.tv_usec / 1000; + return timeInMillisec; +} + namespace utils { -Timer::Timer(unsigned int ms, bool createActive) +Timer::Timer(unsigned int ms) { - active = createActive; + active = false; interval = ms; lastpulse = getTimeInMillisec(); } @@ -89,14 +102,4 @@ void Timer::changeInterval(unsigned int newinterval) interval = newinterval; } -uint64_t Timer::getTimeInMillisec() -{ - uint64_t timeInMillisec; - timeval time; - - gettimeofday(&time, 0); - timeInMillisec = (uint64_t)time.tv_sec * 1000 + time.tv_usec / 1000; - return timeInMillisec; -} - } // ::utils diff --git a/src/utils/timer.h b/src/utils/timer.h index 87c94a28..2c6ca891 100644 --- a/src/utils/timer.h +++ b/src/utils/timer.h @@ -41,9 +41,8 @@ class Timer * Constructor. * * @param ms the interval in milliseconds - * @param createActive whether the timer should be implicitly started */ - Timer(unsigned int ms, bool createActive = true); + Timer(unsigned int ms); /** * Returns the number of elapsed ticks since last call. @@ -68,15 +67,10 @@ class Timer /** * Changes the interval between two pulses. */ - void changeInterval (unsigned int newinterval); + void changeInterval(unsigned int newinterval); private: /** - * Calls gettimeofday() and converts it into milliseconds. - */ - uint64_t getTimeInMillisec(); - - /** * Interval between two pulses. */ unsigned int interval; |