diff --git a/src/mod_server_idler.cpp b/src/mod_server_idler.cpp index 58d234a..493a7e9 100644 --- a/src/mod_server_idler.cpp +++ b/src/mod_server_idler.cpp @@ -3,12 +3,15 @@ #include "World.h" #include "Player.h" #include "WorldSessionMgr.h" +#include "Log.h" namespace { bool sEnabled = true; uint32 sIntervalIdle = 200u; uint32 sIntervalActive = 10u; + uint32 sCurrentInterval = 0u; + uint32 sPrintTimer = 0u; void ApplyInterval() { @@ -17,14 +20,20 @@ namespace bool hasRealPlayer = sWorldSessionMgr->GetActiveAndQueuedSessionCount() > 0; uint32 newInterval = hasRealPlayer ? sIntervalActive : sIntervalIdle; - sWorld->setIntConfig(CONFIG_INTERVAL_MAPUPDATE, newInterval); + + if (newInterval != sCurrentInterval) + { + sCurrentInterval = newInterval; + sWorld->setIntConfig(CONFIG_INTERVAL_MAPUPDATE, newInterval); + LOG_INFO("server.idler", "ServerIdler: MapUpdateInterval changed to {}", newInterval); + } } } class ServerIdler_WorldScript : public WorldScript { public: - ServerIdler_WorldScript() : WorldScript("ServerIdler_WorldScript") {} + ServerIdler_WorldScript() : WorldScript("ServerIdler_WorldScript") { } void OnAfterConfigLoad(bool) override { @@ -39,12 +48,26 @@ public: ApplyInterval(); } + + void OnUpdate(uint32 diff) override + { + if (!sEnabled) + return; + + sPrintTimer += diff; + if (sPrintTimer >= 30000u) + { + sPrintTimer = 0u; + uint32 current = sWorld->getIntConfig(CONFIG_INTERVAL_MAPUPDATE); + LOG_INFO("server.idler", "ServerIdler: MapUpdateInterval current value {}", current); + } + } }; class ServerIdler_PlayerScript : public PlayerScript { public: - ServerIdler_PlayerScript() : PlayerScript("ServerIdler_PlayerScript") {} + ServerIdler_PlayerScript() : PlayerScript("ServerIdler_PlayerScript") { } void OnPlayerLogin(Player*) override {