mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
Core/World: Allow specifying minimum world updates diff in config
(cherry picked from commit 29a4153f00)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user