diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2007-01-06 18:46:17 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2007-01-06 18:46:17 +0000 |
commit | 383339dedf6f1a52b8d6b0196068232daec83526 (patch) | |
tree | fe8bca4bc6b45e83d5c8e70a2ff1e1af4d1b99ae /src/account-server | |
parent | 593e65eef0d43f2ff61dc1b4f3160c0a16b5f015 (diff) | |
download | manaserv-383339dedf6f1a52b8d6b0196068232daec83526.tar.gz manaserv-383339dedf6f1a52b8d6b0196068232daec83526.tar.bz2 manaserv-383339dedf6f1a52b8d6b0196068232daec83526.tar.xz manaserv-383339dedf6f1a52b8d6b0196068232daec83526.zip |
Removed world timer usage from account server, instead letting ENet wait during
each host service to reduce CPU usage. Modified timer code to gracefully handle
jumps back in time.
Diffstat (limited to 'src/account-server')
-rw-r--r-- | src/account-server/main-account.cpp | 36 |
1 files changed, 3 insertions, 33 deletions
diff --git a/src/account-server/main-account.cpp b/src/account-server/main-account.cpp index 195071d3..0bb550a1 100644 --- a/src/account-server/main-account.cpp +++ b/src/account-server/main-account.cpp @@ -43,15 +43,12 @@ #include "net/messageout.hpp" #include "utils/logger.h" #include "utils/stringfilter.h" -#include "utils/timer.h" // Default options that automake should be able to override. #define DEFAULT_LOG_FILE "tmwserv.log" #define DEFAULT_CONFIG_FILE "tmwserv.xml" #define DEFAULT_ITEMSDB_FILE "items.xml" -utils::Timer worldTimer(100, false); /**< Timer for world tics set to 100 ms */ -int worldTime = 0; /**< Current world time in 100ms ticks */ bool running = true; /**< Determines if server keeps running */ Skill skillTree("base"); /**< Skill tree */ @@ -178,9 +175,6 @@ void deinitialize() // Write configuration file config.write(); - // Stop world timer - worldTimer.stop(); - // Quit ENet enet_deinitialize(); @@ -263,8 +257,6 @@ void parseOptions(int argc, char *argv[]) */ int main(int argc, char *argv[]) { - int elapsedWorldTicks; - LOG_INFO("The Mana World Account+Chat Server v" << PACKAGE_VERSION); // Parse Command Line Options @@ -288,32 +280,10 @@ int main(int argc, char *argv[]) store.close(); store.open(); - // Initialize world timer - worldTimer.start(); - while (running) { - elapsedWorldTicks = worldTimer.poll(); - if (elapsedWorldTicks > 0) { - worldTime += elapsedWorldTicks; - - if (elapsedWorldTicks > 1) - { - LOG_WARN(elapsedWorldTicks - 1 << " World Tick(s) skipped " - "because of insufficient time. please buy a faster " - "machine ;-)"); - }; - - // Print world time at 10 second intervals to show we're alive - if (worldTime % 100 == 0) { - LOG_INFO("World time: " << worldTime); - } - - // Handle all messages that are in the message queues - accountHandler->process(); - chatHandler->process(); - serverHandler->process(); - } - worldTimer.sleep(); + accountHandler->process(50); + chatHandler->process(50); + serverHandler->process(50); } LOG_INFO("Received: Quit signal, closing down..."); |