aboutsummaryrefslogtreecommitdiff
path: root/src/server/worldserver/Main.cpp
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2022-04-16 23:14:42 +0200
committerShauren <shauren.trinity@gmail.com>2022-04-16 23:14:42 +0200
commit29a4153f0038526ee6df690ec3499d66630e5071 (patch)
tree5af0e2aa858de3b48226689ca83142050df0bcee /src/server/worldserver/Main.cpp
parent4747515872775553de35cc3267e1ccd5e0076ca4 (diff)
Core/World: Allow specifying minimum world updates diff in config
Diffstat (limited to 'src/server/worldserver/Main.cpp')
-rw-r--r--src/server/worldserver/Main.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/server/worldserver/Main.cpp b/src/server/worldserver/Main.cpp
index 888b0ad65d4..f370881001e 100644
--- a/src/server/worldserver/Main.cpp
+++ b/src/server/worldserver/Main.cpp
@@ -67,8 +67,6 @@ namespace fs = boost::filesystem;
#define _TRINITY_CORE_CONFIG "worldserver.conf"
#endif
-#define WORLD_SLEEP_CONST 1
-
#ifdef _WIN32
#include "ServiceWin32.h"
char serviceName[] = "worldserver";
@@ -472,6 +470,7 @@ void ShutdownCLIThread(std::thread* cliThread)
void WorldUpdateLoop()
{
+ uint32 minUpdateDiff = uint32(sConfigMgr->GetIntDefault("MinWorldUpdateTime", 1));
uint32 realCurrTime = 0;
uint32 realPrevTime = getMSTime();
@@ -486,10 +485,10 @@ void WorldUpdateLoop()
realCurrTime = getMSTime();
uint32 diff = getMSTimeDiff(realPrevTime, realCurrTime);
- if (!diff)
+ if (diff < minUpdateDiff)
{
// sleep until enough time passes that we can update all timers
- std::this_thread::sleep_for(std::chrono::milliseconds(1));
+ std::this_thread::sleep_for(Milliseconds(minUpdateDiff - diff));
continue;
}