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-06-10 16:50:29 +0200
commit833ddfad11fdb6af37bb70296dbc11613f4d0f5f (patch)
treed995ce07eea8c844d2032cf953897645239bf25e /src/server/worldserver/Main.cpp
parent8501fb572a38b7d278c6e37d7b32164c63771550 (diff)
Core/World: Allow specifying minimum world updates diff in config
(cherry picked from commit 29a4153f0038526ee6df690ec3499d66630e5071)
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 e08e9610965..bad72919f6a 100644
--- a/src/server/worldserver/Main.cpp
+++ b/src/server/worldserver/Main.cpp
@@ -70,8 +70,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";
@@ -489,6 +487,7 @@ void ShutdownCLIThread(std::thread* cliThread)
void WorldUpdateLoop()
{
+ uint32 minUpdateDiff = uint32(sConfigMgr->GetIntDefault("MinWorldUpdateTime", 1));
uint32 realCurrTime = 0;
uint32 realPrevTime = getMSTime();
@@ -504,10 +503,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;
}