diff options
author | Philipp Sehmisch <crush@themanaworld.org> | 2009-12-28 02:27:21 +0100 |
---|---|---|
committer | Philipp Sehmisch <crush@themanaworld.org> | 2009-12-28 02:27:59 +0100 |
commit | d6eb729838a6dc494dc7a752599706a42ae9964e (patch) | |
tree | eb6aa2cecf0855e44c62da468f6b3dbd25078488 /src | |
parent | adad29344670a60ca06221be0e0a033a2f7b1c82 (diff) | |
download | manaserv-d6eb729838a6dc494dc7a752599706a42ae9964e.tar.gz manaserv-d6eb729838a6dc494dc7a752599706a42ae9964e.tar.bz2 manaserv-d6eb729838a6dc494dc7a752599706a42ae9964e.tar.xz manaserv-d6eb729838a6dc494dc7a752599706a42ae9964e.zip |
Made world tick skip detection more lax
Diffstat (limited to 'src')
-rw-r--r-- | src/game-server/main-game.cpp | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/game-server/main-game.cpp b/src/game-server/main-game.cpp index 5e132fc5..11c36509 100644 --- a/src/game-server/main-game.cpp +++ b/src/game-server/main-game.cpp @@ -66,6 +66,8 @@ using utils::Logger; #define DEFAULT_MONSTERSDB_FILE "monsters.xml" #define DEFAULT_STATUSDB_FILE "mana-status-effect.xml" +static int const WORLD_TICK_SKIP = 2; /** tolerance for lagging behind in world calculation) **/ + 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 */ @@ -342,16 +344,18 @@ int main(int argc, char *argv[]) while (running) { elapsedWorldTicks = worldTimer.poll(); - if (elapsedWorldTicks > 0) - { - worldTime += elapsedWorldTicks; + if (elapsedWorldTicks == 0) worldTimer.sleep(); - if (elapsedWorldTicks > 1) + while (elapsedWorldTicks > 0) + { + if (elapsedWorldTicks > WORLD_TICK_SKIP) { - LOG_WARN("Not enough time to calculate "<< elapsedWorldTicks -1 - << " World Tick(s) - skipping. Please buy a faster " - "machine ;-)"); - }; + LOG_WARN("Skipped "<< elapsedWorldTicks - WORLD_TICK_SKIP + << " world tick due to insufficient CPU time."); + elapsedWorldTicks = WORLD_TICK_SKIP; + } + worldTime++; + elapsedWorldTicks--; // Print world time at 10 second intervals to show we're alive if (worldTime % 100 == 0) { @@ -403,10 +407,6 @@ int main(int argc, char *argv[]) // Send potentially urgent outgoing messages gameHandler->flush(); } - else - { - worldTimer.sleep(); - } } LOG_INFO("Received: Quit signal, closing down..."); |