[performance] initialize server and bots fase

This commit is contained in:
bash
2024-10-29 10:57:26 +00:00
parent 3cd68c6dec
commit 8a9c25c72c
5 changed files with 38 additions and 34 deletions

View File

@@ -40,6 +40,7 @@
#include "Unit.h"
#include "UpdateTime.h"
#include "World.h"
#include "GameTime.h"
void PrintStatsThread() { sRandomPlayerbotMgr->PrintStats(); }
@@ -309,12 +310,17 @@ void RandomPlayerbotMgr::UpdateAIInternal(uint32 elapsed, bool /*minimal*/)
uint32 onlineBotFocus = 75;
if (onlineBotCount < (uint32)(sPlayerbotAIConfig->minRandomBots * 90 / 100))
{
onlineBotFocus = 25;
}
setBotInitializing(
onlineBotCount < maxAllowedBotCount &&
GameTime::GetUptime().count() < sPlayerbotAIConfig->maxRandomBots * 0.15);
// when server is balancing bots then boost (decrease value of) the nextCheckDelay till
// onlineBotCount reached the AllowedBotCount.
setIsBotInitCompleted(onlineBotCount < maxAllowedBotCount);
uint32 updateIntervalTurboBoost = onlineBotCount < maxAllowedBotCount ? 1 : sPlayerbotAIConfig->randomBotUpdateInterval;
uint32 updateIntervalTurboBoost = isBotInitializing() ? 1 : sPlayerbotAIConfig->randomBotUpdateInterval;
SetNextCheckDelay(updateIntervalTurboBoost * (onlineBotFocus + 25) * 10);
PerformanceMonitorOperation* pmo = sPerformanceMonitor->start(
@@ -987,35 +993,34 @@ bool RandomPlayerbotMgr::ProcessBot(uint32 bot)
if (isLogginIn)
return false;
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);
randomTime = urand(
std::max(5, static_cast<int>(sPlayerbotAIConfig->randomBotUpdateInterval * 0.5)),
std::max(12, static_cast<int>(sPlayerbotAIConfig->randomBotUpdateInterval * 2)));
SetEventValue(bot, "update", 1, randomTime);
uint32 updateIntervalTurboBoost = isBotInitializing() ? 1 : sPlayerbotAIConfig->randomBotUpdateInterval;
randomTime = urand(std::max(5, static_cast<int>(updateIntervalTurboBoost * 0.5)),
std::max(10, static_cast<int>(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<int>(sPlayerbotAIConfig->randomBotUpdateInterval * 0.4)));
ScheduleRandomize(bot, randomTime);
}
if (!GetEventValue(bot, "teleport"))
{
randomTime = urand(
std::max(7, static_cast<int>(sPlayerbotAIConfig->randomBotUpdateInterval * 0.7)),
std::max(14, static_cast<int>(sPlayerbotAIConfig->randomBotUpdateInterval * 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<int>(updateIntervalTurboBoost * 0.4)));
ScheduleRandomize(bot, randomTime);
}
if (!GetEventValue(bot, "teleport"))
{
randomTime = urand(std::max(7, static_cast<int>(updateIntervalTurboBoost * 0.7)),
std::max(14, static_cast<int>(updateIntervalTurboBoost * 1.4)));
ScheduleTeleport(bot, randomTime);
}
return true;
}
return true;
}
SetEventValue(bot, "login", 0, 0);