Core/World: Allow specifying minimum world updates diff in config

Port From (https://github.com/TrinityCore/TrinityCore/commit/833ddfad11fdb6af37bb70296dbc11613f4d0f5f)
This commit is contained in:
hondacrx
2022-06-15 18:15:15 -04:00
parent ed85b3ae55
commit 6a00ece6d4
2 changed files with 10 additions and 2 deletions
+3 -2
View File
@@ -180,6 +180,7 @@ namespace WorldServer
static void WorldUpdateLoop() static void WorldUpdateLoop()
{ {
int minUpdateDiff = ConfigMgr.GetDefaultValue("MinWorldUpdateTime", 1);
uint realPrevTime = Time.GetMSTime(); uint realPrevTime = Time.GetMSTime();
while (!Global.WorldMgr.IsStopped) while (!Global.WorldMgr.IsStopped)
@@ -187,10 +188,10 @@ namespace WorldServer
var realCurrTime = Time.GetMSTime(); var realCurrTime = Time.GetMSTime();
uint diff = Time.GetMSTimeDiff(realPrevTime, realCurrTime); uint diff = Time.GetMSTimeDiff(realPrevTime, realCurrTime);
if (diff == 0) if (diff < minUpdateDiff)
{ {
// sleep until enough time passes that we can update all timers // sleep until enough time passes that we can update all timers
Thread.Sleep(1); Thread.Sleep(TimeSpan.FromMilliseconds(minUpdateDiff - diff));
continue; continue;
} }
+7
View File
@@ -331,6 +331,13 @@ SessionAddDelay = 10000
GridCleanUpDelay = 300000 GridCleanUpDelay = 300000
#
# MinWorldUpdateTime
# Description: Minimum time (milliseconds) between world update ticks (for mostly idle servers).
# Default: 1 - (0.001 second)
MinWorldUpdateTime = 1
# #
# MapUpdateInterval # MapUpdateInterval
# Description: Time (milliseconds) for map update interval. # Description: Time (milliseconds) for map update interval.