adjusting GetPlayerCount to GetActiveAndQueuedSessionCount

This commit is contained in:
Flerp 2025-11-15 18:21:24 -08:00
parent a37d449977
commit 8177d4a310

View File

@ -2,20 +2,21 @@
#include "Config.h" #include "Config.h"
#include "World.h" #include "World.h"
#include "Player.h" #include "Player.h"
#include "WorldSessionMgr.h"
namespace namespace
{ {
bool sEnabled = true; bool sEnabled = true;
uint32 sIntervalIdle = 200u; uint32 sIntervalIdle = 200u;
uint32 sIntervalActive = 10u; uint32 sIntervalActive = 10u;
uint32 sPlayersOnline = 0u;
void ApplyInterval() void ApplyInterval()
{ {
if (!sEnabled) if (!sEnabled)
return; return;
uint32 newInterval = (sPlayersOnline > 0) ? sIntervalActive : sIntervalIdle; bool hasRealPlayer = sWorldSessionMgr->GetActiveAndQueuedSessionCount() > 0;
uint32 newInterval = hasRealPlayer ? sIntervalActive : sIntervalIdle;
sWorld->setIntConfig(CONFIG_INTERVAL_MAPUPDATE, newInterval); sWorld->setIntConfig(CONFIG_INTERVAL_MAPUPDATE, newInterval);
} }
} }
@ -36,7 +37,6 @@ public:
if (sIntervalActive == 0u) if (sIntervalActive == 0u)
sIntervalActive = 1u; sIntervalActive = 1u;
sPlayersOnline = sWorld->GetPlayerCount();
ApplyInterval(); ApplyInterval();
} }
}; };
@ -48,21 +48,11 @@ public:
void OnLogin(Player*) override void OnLogin(Player*) override
{ {
if (!sEnabled)
return;
++sPlayersOnline;
ApplyInterval(); ApplyInterval();
} }
void OnLogout(Player*) override void OnLogout(Player*) override
{ {
if (!sEnabled)
return;
if (sPlayersOnline > 0)
--sPlayersOnline;
ApplyInterval(); ApplyInterval();
} }
}; };