From ae2f2c6d04de9b786a127d30abc5f1fdb149bb4c Mon Sep 17 00:00:00 2001 From: bash <31279994+hermensbas@users.noreply.github.com> Date: Tue, 29 Oct 2024 13:08:46 +0100 Subject: [PATCH] [performance] server_and_bot_init_phase_patch1 (#652) --- conf/playerbots.conf.dist | 2 +- src/PlayerbotAIConfig.cpp | 2 +- src/RandomPlayerbotMgr.cpp | 46 +++++++++++++++++++------------------- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/conf/playerbots.conf.dist b/conf/playerbots.conf.dist index a8273767..8d7bf12e 100644 --- a/conf/playerbots.conf.dist +++ b/conf/playerbots.conf.dist @@ -728,7 +728,7 @@ AiPlayerbot.FastReactInBG = 1 # # All In seconds -AiPlayerbot.RandomBotUpdateInterval = 5 +AiPlayerbot.RandomBotUpdateInterval = 1 AiPlayerbot.RandomBotCountChangeMinInterval = 1800 AiPlayerbot.RandomBotCountChangeMaxInterval = 7200 AiPlayerbot.MinRandomBotInWorldTime = 3600 diff --git a/src/PlayerbotAIConfig.cpp b/src/PlayerbotAIConfig.cpp index 9d9bdd44..7bf16079 100644 --- a/src/PlayerbotAIConfig.cpp +++ b/src/PlayerbotAIConfig.cpp @@ -156,7 +156,7 @@ bool PlayerbotAIConfig::Initialize() randomBotAutologin = sConfigMgr->GetOption("AiPlayerbot.RandomBotAutologin", true); minRandomBots = sConfigMgr->GetOption("AiPlayerbot.MinRandomBots", 50); maxRandomBots = sConfigMgr->GetOption("AiPlayerbot.MaxRandomBots", 200); - randomBotUpdateInterval = sConfigMgr->GetOption("AiPlayerbot.RandomBotUpdateInterval", 5); + randomBotUpdateInterval = sConfigMgr->GetOption("AiPlayerbot.RandomBotUpdateInterval", 1); randomBotCountChangeMinInterval = sConfigMgr->GetOption("AiPlayerbot.RandomBotCountChangeMinInterval", 30 * MINUTE); randomBotCountChangeMaxInterval = diff --git a/src/RandomPlayerbotMgr.cpp b/src/RandomPlayerbotMgr.cpp index 669d9cea..4fa098be 100644 --- a/src/RandomPlayerbotMgr.cpp +++ b/src/RandomPlayerbotMgr.cpp @@ -995,32 +995,32 @@ bool RandomPlayerbotMgr::ProcessBot(uint32 bot) uint32 randomTime; - if (!player) - { - AddPlayerBot(botGUID, 0); - randomTime = urand(1, 2); - SetEventValue(bot, "login", 1, randomTime); + if (!player) + { + AddPlayerBot(botGUID, 0); + randomTime = urand(1, 2); + SetEventValue(bot, "login", 1, randomTime); - uint32 updateIntervalTurboBoost = isBotInitializing() ? 1 : sPlayerbotAIConfig->randomBotUpdateInterval; - randomTime = urand(std::max(5, static_cast(updateIntervalTurboBoost * 0.5)), - std::max(10, static_cast(updateIntervalTurboBoost * 2))); - SetEventValue(bot, "update", 1, randomTime); + uint32 updateIntervalTurboBoost = isBotInitializing() ? 1 : sPlayerbotAIConfig->randomBotUpdateInterval; + randomTime = urand(std::max(5, static_cast(updateIntervalTurboBoost * 0.5)), + std::max(12, static_cast(updateIntervalTurboBoost * 2))); + SetEventValue(bot, "update", 1, randomTime); - // do not randomize or teleport immediately after server start (prevent lagging) - if (!GetEventValue(bot, "randomize")) - { - randomTime = urand(3, std::max(4, static_cast(updateIntervalTurboBoost * 0.4))); - ScheduleRandomize(bot, randomTime); - } - if (!GetEventValue(bot, "teleport")) - { - randomTime = urand(std::max(7, static_cast(updateIntervalTurboBoost * 0.7)), - std::max(14, static_cast(updateIntervalTurboBoost * 1.4))); - ScheduleTeleport(bot, randomTime); - } + // do not randomize or teleport immediately after server start (prevent lagging) + if (!GetEventValue(bot, "randomize")) + { + randomTime = urand(3, std::max(4, static_cast(updateIntervalTurboBoost * 0.4))); + ScheduleRandomize(bot, randomTime); + } + if (!GetEventValue(bot, "teleport")) + { + randomTime = urand(std::max(7, static_cast(updateIntervalTurboBoost * 0.7)), + std::max(14, static_cast(updateIntervalTurboBoost * 1.4))); + ScheduleTeleport(bot, randomTime); + } - return true; - } + return true; + } SetEventValue(bot, "login", 0, 0);