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

(cherry picked from commit 29a4153f00)
This commit is contained in:
Shauren
2022-04-16 23:14:42 +02:00
parent 8501fb572a
commit 833ddfad11
2 changed files with 10 additions and 4 deletions

View File

@@ -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;
}

View File

@@ -361,6 +361,13 @@ SessionAddDelay = 10000
GridCleanUpDelay = 300000
#
# MinWorldUpdateTime
# Description: Minimum time (milliseconds) between world update ticks (for mostly idle servers).
# Default: 1 - (0.001 second)
MinWorldUpdateTime = 1
#
# MapUpdateInterval
# Description: Time (milliseconds) for map update interval.