Merge pull request #30 from DustinHendrickson/Dustin/NewModuleControlConf

Adding new config varaible to control if the module should run
This commit is contained in:
Dustin Hendrickson
2025-02-28 13:10:30 -08:00
committed by GitHub
2 changed files with 191 additions and 85 deletions

View File

@@ -4,11 +4,23 @@
# mod-player-bot-level-brackets configuration # mod-player-bot-level-brackets configuration
############################################## ##############################################
# #
# BotLevelBrackets.DebugMode # BotLevelBrackets.Enabled
# Description: Enables debug logging for the Bot Level Brackets module. # Description: Enables the module.
# Default: 1 (enabled)
# Valid values: 0 (off) / 1 (on)
BotLevelBrackets.Enabled = 1
# BotLevelBrackets.FullDebugMode
# Description: Enables full debug logging for the Bot Level Brackets module.
# Default: 0 (disabled) # Default: 0 (disabled)
# Valid values: 0 (off) / 1 (on) # Valid values: 0 (off) / 1 (on)
BotLevelBrackets.DebugMode = 0 BotLevelBrackets.FullDebugMode = 0
# BotLevelBrackets.LiteDebugMode
# Description: Enables lite debug logging for the Bot Level Brackets module.
# Default: 0 (disabled)
# Valid values: 0 (off) / 1 (on)
BotLevelBrackets.LiteDebugMode = 0
# BotLevelBrackets.CheckFrequency # BotLevelBrackets.CheckFrequency
# Description: The frequency (in seconds) at which the bot level distribution check is performed. # Description: The frequency (in seconds) at which the bot level distribution check is performed.

View File

@@ -37,6 +37,8 @@ static const uint8 NUM_RANGES = 9;
static uint8 g_RandomBotMinLevel = 1; static uint8 g_RandomBotMinLevel = 1;
static uint8 g_RandomBotMaxLevel = 80; static uint8 g_RandomBotMaxLevel = 80;
// New configuration option to enable/disable the mod. Default is true.
static bool g_BotLevelBracketsEnabled = true;
// Separate arrays for Alliance and Horde. // Separate arrays for Alliance and Horde.
static LevelRangeConfig g_BaseLevelRanges[NUM_RANGES]; static LevelRangeConfig g_BaseLevelRanges[NUM_RANGES];
@@ -45,7 +47,8 @@ static LevelRangeConfig g_HordeLevelRanges[NUM_RANGES];
static uint32 g_BotDistCheckFrequency = 300; // in seconds static uint32 g_BotDistCheckFrequency = 300; // in seconds
static uint32 g_BotDistFlaggedCheckFrequency = 15; // in seconds static uint32 g_BotDistFlaggedCheckFrequency = 15; // in seconds
static bool g_BotDistDebugMode = false; static bool g_BotDistFullDebugMode = false;
static bool g_BotDistLiteDebugMode = false;
static bool g_UseDynamicDistribution = false; static bool g_UseDynamicDistribution = false;
// Real player weight to boost bracket contributions. // Real player weight to boost bracket contributions.
@@ -54,7 +57,10 @@ static float g_RealPlayerWeight = 1.0f;
// Loads the configuration from the config file. // Loads the configuration from the config file.
static void LoadBotLevelBracketsConfig() static void LoadBotLevelBracketsConfig()
{ {
g_BotDistDebugMode = sConfigMgr->GetOption<bool>("BotLevelBrackets.DebugMode", false); g_BotLevelBracketsEnabled = sConfigMgr->GetOption<bool>("BotLevelBrackets.Enabled", true);
g_BotDistFullDebugMode = sConfigMgr->GetOption<bool>("BotLevelBrackets.FullDebugMode", false);
g_BotDistLiteDebugMode = sConfigMgr->GetOption<bool>("BotLevelBrackets.LiteDebugMode", false);
g_BotDistCheckFrequency = sConfigMgr->GetOption<uint32>("BotLevelBrackets.CheckFrequency", 300); g_BotDistCheckFrequency = sConfigMgr->GetOption<uint32>("BotLevelBrackets.CheckFrequency", 300);
g_BotDistFlaggedCheckFrequency = sConfigMgr->GetOption<uint32>("BotLevelBrackets.CheckFlaggedFrequency", 15); g_BotDistFlaggedCheckFrequency = sConfigMgr->GetOption<uint32>("BotLevelBrackets.CheckFlaggedFrequency", 15);
g_UseDynamicDistribution = sConfigMgr->GetOption<bool>("BotLevelBrackets.UseDynamicDistribution", false); g_UseDynamicDistribution = sConfigMgr->GetOption<bool>("BotLevelBrackets.UseDynamicDistribution", false);
@@ -145,7 +151,7 @@ static void AdjustBotToRange(Player* bot, int targetRangeIndex, const LevelRange
uint8 upperBound = factionRanges[targetRangeIndex].upper; uint8 upperBound = factionRanges[targetRangeIndex].upper;
if (upperBound < 55) if (upperBound < 55)
{ {
if (g_BotDistDebugMode) if (g_BotDistFullDebugMode)
{ {
std::string playerFaction = IsAlliancePlayerBot(bot) ? "Alliance" : "Horde"; std::string playerFaction = IsAlliancePlayerBot(bot) ? "Alliance" : "Horde";
LOG_INFO("server.loading", LOG_INFO("server.loading",
@@ -167,7 +173,7 @@ static void AdjustBotToRange(Player* bot, int targetRangeIndex, const LevelRange
newFactory.Randomize(false); newFactory.Randomize(false);
if (g_BotDistDebugMode) if (g_BotDistFullDebugMode)
{ {
PlayerbotAI* botAI = sPlayerbotsMgr->GetPlayerbotAI(bot); PlayerbotAI* botAI = sPlayerbotsMgr->GetPlayerbotAI(bot);
std::string playerClassName = botAI ? botAI->GetChatHelper()->FormatClass(bot->getClass()) : "Unknown"; std::string playerClassName = botAI ? botAI->GetChatHelper()->FormatClass(bot->getClass()) : "Unknown";
@@ -214,20 +220,23 @@ static bool IsHordePlayerBot(Player* bot)
static void LogAllBotLevels() static void LogAllBotLevels()
{ {
std::map<uint8, uint32> botLevelCount; if (g_BotDistFullDebugMode)
for (auto const& itr : ObjectAccessor::GetPlayers())
{ {
Player* player = itr.second; std::map<uint8, uint32> botLevelCount;
if (!player || !player->IsInWorld()) for (auto const& itr : ObjectAccessor::GetPlayers())
continue; {
if (!IsPlayerBot(player)) Player* player = itr.second;
continue; if (!player || !player->IsInWorld())
uint8 level = player->GetLevel(); continue;
botLevelCount[level]++; if (!IsPlayerBot(player))
} continue;
for (const auto& entry : botLevelCount) uint8 level = player->GetLevel();
{ botLevelCount[level]++;
LOG_INFO("server.loading", "[BotLevelBrackets] Level {}: {} bots", entry.first, entry.second); }
for (const auto& entry : botLevelCount)
{
LOG_INFO("server.loading", "[BotLevelBrackets] Level {}: {} bots", entry.first, entry.second);
}
} }
} }
@@ -266,8 +275,11 @@ static void ClampAndBalanceBrackets()
if(totalAlliance != 100 && totalAlliance > 0) if(totalAlliance != 100 && totalAlliance > 0)
{ {
LOG_INFO("server.loading", "[BotLevelBrackets] Alliance: Sum of percentages is {} (expected 100). Auto adjusting.", totalAlliance); if (g_BotDistFullDebugMode)
{
LOG_INFO("server.loading", "[BotLevelBrackets] Alliance: Sum of percentages is {} (expected 100). Auto adjusting.", totalAlliance);
}
int missing = 100 - totalAlliance; int missing = 100 - totalAlliance;
while(missing > 0) while(missing > 0)
{ {
@@ -284,9 +296,11 @@ static void ClampAndBalanceBrackets()
} }
if(totalHorde != 100 && totalHorde > 0) if(totalHorde != 100 && totalHorde > 0)
{ {
if (g_BotDistFullDebugMode)
LOG_INFO("server.loading", "[BotLevelBrackets] Horde: Sum of percentages is {} (expected 100). Auto adjusting.", totalHorde); {
LOG_INFO("server.loading", "[BotLevelBrackets] Horde: Sum of percentages is {} (expected 100). Auto adjusting.", totalHorde);
}
int missing = 100 - totalHorde; int missing = 100 - totalHorde;
while(missing > 0) while(missing > 0)
{ {
@@ -310,32 +324,50 @@ static bool IsBotSafeForLevelReset(Player* bot)
{ {
if (!bot) if (!bot)
{ {
LOG_INFO("server.loading", "[BotLevelBrackets] Null bot pointer provided."); if (g_BotDistFullDebugMode)
{
LOG_INFO("server.loading", "[BotLevelBrackets] Null bot pointer provided.");
}
return false; return false;
} }
if (!bot->IsInWorld()) if (!bot->IsInWorld())
{ {
LOG_INFO("server.loading", "[BotLevelBrackets] Bot {} (Level {}) is not in world.", bot->GetName(), bot->GetLevel()); if (g_BotDistFullDebugMode)
{
LOG_INFO("server.loading", "[BotLevelBrackets] Bot {} (Level {}) is not in world.", bot->GetName(), bot->GetLevel());
}
return false; return false;
} }
if (!bot->IsAlive()) if (!bot->IsAlive())
{ {
LOG_INFO("server.loading", "[BotLevelBrackets] Bot {} (Level {}) is not alive.", bot->GetName(), bot->GetLevel()); if (g_BotDistFullDebugMode)
{
LOG_INFO("server.loading", "[BotLevelBrackets] Bot {} (Level {}) is not alive.", bot->GetName(), bot->GetLevel());
}
return false; return false;
} }
if (bot->IsInCombat()) if (bot->IsInCombat())
{ {
LOG_INFO("server.loading", "[BotLevelBrackets] Bot {} (Level {}) is in combat.", bot->GetName(), bot->GetLevel()); if (g_BotDistFullDebugMode)
{
LOG_INFO("server.loading", "[BotLevelBrackets] Bot {} (Level {}) is in combat.", bot->GetName(), bot->GetLevel());
}
return false; return false;
} }
if (bot->InBattleground() || bot->InArena() || bot->inRandomLfgDungeon() || bot->InBattlegroundQueue()) if (bot->InBattleground() || bot->InArena() || bot->inRandomLfgDungeon() || bot->InBattlegroundQueue())
{ {
LOG_INFO("server.loading", "[BotLevelBrackets] Bot {} (Level {}) is in battleground, arena, random dungeon, or battleground queue.", bot->GetName(), bot->GetLevel()); if (g_BotDistFullDebugMode)
{
LOG_INFO("server.loading", "[BotLevelBrackets] Bot {} (Level {}) is in battleground, arena, random dungeon, or battleground queue.", bot->GetName(), bot->GetLevel());
}
return false; return false;
} }
if (bot->IsInFlight()) if (bot->IsInFlight())
{ {
LOG_INFO("server.loading", "[BotLevelBrackets] Bot {} (Level {}) is in flight.", bot->GetName(), bot->GetLevel()); if (g_BotDistFullDebugMode)
{
LOG_INFO("server.loading", "[BotLevelBrackets] Bot {} (Level {}) is in flight.", bot->GetName(), bot->GetLevel());
}
return false; return false;
} }
if (Group* group = bot->GetGroup()) if (Group* group = bot->GetGroup())
@@ -345,7 +377,10 @@ static bool IsBotSafeForLevelReset(Player* bot)
Player* member = ref->GetSource(); Player* member = ref->GetSource();
if (member && !IsPlayerBot(member)) if (member && !IsPlayerBot(member))
{ {
LOG_INFO("server.loading", "[BotLevelBrackets] Bot {} (Level {}) has non-bot group member {} (Level {}).", bot->GetName(), bot->GetLevel(), member->GetName(), member->GetLevel()); if (g_BotDistFullDebugMode)
{
LOG_INFO("server.loading", "[BotLevelBrackets] Bot {} (Level {}) has non-bot group member {} (Level {}).", bot->GetName(), bot->GetLevel(), member->GetName(), member->GetLevel());
}
return false; return false;
} }
} }
@@ -366,7 +401,10 @@ static std::vector<PendingResetEntry> g_PendingLevelResets;
static void ProcessPendingLevelResets() static void ProcessPendingLevelResets()
{ {
LOG_INFO("server.loading", "[BotLevelBrackets] Processing {} pending resets...", g_PendingLevelResets.size()); if (g_BotDistFullDebugMode)
{
LOG_INFO("server.loading", "[BotLevelBrackets] Processing {} pending resets...", g_PendingLevelResets.size());
}
if (g_PendingLevelResets.empty()) if (g_PendingLevelResets.empty())
return; return;
@@ -379,8 +417,10 @@ static void ProcessPendingLevelResets()
if (bot && bot->IsInWorld() && IsBotSafeForLevelReset(bot)) if (bot && bot->IsInWorld() && IsBotSafeForLevelReset(bot))
{ {
AdjustBotToRange(bot, targetRange, it->factionRanges); AdjustBotToRange(bot, targetRange, it->factionRanges);
LOG_INFO("server.loading", "[BotLevelBrackets] Bot '{}' successfully reset to level range {}-{}.", if (g_BotDistFullDebugMode)
bot->GetName(), it->factionRanges[targetRange].lower, it->factionRanges[targetRange].upper); {
LOG_INFO("server.loading", "[BotLevelBrackets] Bot '{}' successfully reset to level range {}-{}.", bot->GetName(), it->factionRanges[targetRange].lower, it->factionRanges[targetRange].upper);
}
it = g_PendingLevelResets.erase(it); it = g_PendingLevelResets.erase(it);
} }
else else
@@ -460,7 +500,12 @@ public:
void OnStartup() override void OnStartup() override
{ {
LoadBotLevelBracketsConfig(); LoadBotLevelBracketsConfig();
if (g_BotDistDebugMode) if (!g_BotLevelBracketsEnabled)
{
LOG_INFO("server.loading", "[BotLevelBrackets] Module disabled via configuration.");
return;
}
if (g_BotDistFullDebugMode || g_BotDistLiteDebugMode)
{ {
LOG_INFO("server.loading", "[BotLevelBrackets] Module loaded. Check frequency: {} seconds, Check flagged frequency: {}.", g_BotDistCheckFrequency, g_BotDistFlaggedCheckFrequency); LOG_INFO("server.loading", "[BotLevelBrackets] Module loaded. Check frequency: {} seconds, Check flagged frequency: {}.", g_BotDistCheckFrequency, g_BotDistFlaggedCheckFrequency);
for (uint8 i = 0; i < NUM_RANGES; ++i) for (uint8 i = 0; i < NUM_RANGES; ++i)
@@ -478,13 +523,19 @@ public:
void OnUpdate(uint32 diff) override void OnUpdate(uint32 diff) override
{ {
if (!g_BotLevelBracketsEnabled)
return;
m_timer += diff; m_timer += diff;
m_flaggedTimer += diff; m_flaggedTimer += diff;
// Process pending level resets. // Process pending level resets.
if (m_flaggedTimer >= g_BotDistFlaggedCheckFrequency * 1000) if (m_flaggedTimer >= g_BotDistFlaggedCheckFrequency * 1000)
{ {
LOG_INFO("server.loading", "[BotLevelBrackets] Pending Level Resets Triggering."); if (g_BotDistFullDebugMode)
{
LOG_INFO("server.loading", "[BotLevelBrackets] Pending Level Resets Triggering.");
}
ProcessPendingLevelResets(); ProcessPendingLevelResets();
m_flaggedTimer = 0; m_flaggedTimer = 0;
} }
@@ -553,7 +604,7 @@ public:
for (int i = 0; i < NUM_RANGES; ++i) for (int i = 0; i < NUM_RANGES; ++i)
{ {
g_AllianceLevelRanges[i].desiredPercent = static_cast<uint8>(round((allianceWeights[i] / allianceTotalWeight) * 100)); g_AllianceLevelRanges[i].desiredPercent = static_cast<uint8>(round((allianceWeights[i] / allianceTotalWeight) * 100));
if (g_BotDistDebugMode) if (g_BotDistFullDebugMode || g_BotDistLiteDebugMode)
{ {
LOG_INFO("server.loading", "[BotLevelBrackets] Dynamic Distribution - Alliance Range {}: {}-{}, Real Players: {} (weight: {:.2f}), New Desired: {}%", LOG_INFO("server.loading", "[BotLevelBrackets] Dynamic Distribution - Alliance Range {}: {}-{}, Real Players: {} (weight: {:.2f}), New Desired: {}%",
i + 1, g_AllianceLevelRanges[i].lower, g_AllianceLevelRanges[i].upper, allianceRealCounts[i], allianceWeights[i], g_AllianceLevelRanges[i].desiredPercent); i + 1, g_AllianceLevelRanges[i].lower, g_AllianceLevelRanges[i].upper, allianceRealCounts[i], allianceWeights[i], g_AllianceLevelRanges[i].desiredPercent);
@@ -566,7 +617,7 @@ public:
if (sumAlliance < 100 && allianceTotalWeight > 0) if (sumAlliance < 100 && allianceTotalWeight > 0)
{ {
uint8 missing = 100 - sumAlliance; uint8 missing = 100 - sumAlliance;
if (g_BotDistDebugMode) if (g_BotDistFullDebugMode || g_BotDistLiteDebugMode)
{ {
LOG_INFO("server.loading", "[BotLevelBrackets] Alliance normalization: current sum = {}, missing = {}", sumAlliance, missing); LOG_INFO("server.loading", "[BotLevelBrackets] Alliance normalization: current sum = {}, missing = {}", sumAlliance, missing);
} }
@@ -582,7 +633,7 @@ public:
} }
} }
} }
if (g_BotDistDebugMode) if (g_BotDistFullDebugMode || g_BotDistLiteDebugMode)
{ {
LOG_INFO("server.loading", "[BotLevelBrackets] Alliance normalized percentages:"); LOG_INFO("server.loading", "[BotLevelBrackets] Alliance normalized percentages:");
for (int i = 0; i < NUM_RANGES; ++i) for (int i = 0; i < NUM_RANGES; ++i)
@@ -599,7 +650,7 @@ public:
for (int i = 0; i < NUM_RANGES; ++i) for (int i = 0; i < NUM_RANGES; ++i)
{ {
g_HordeLevelRanges[i].desiredPercent = static_cast<uint8>(round((hordeWeights[i] / hordeTotalWeight) * 100)); g_HordeLevelRanges[i].desiredPercent = static_cast<uint8>(round((hordeWeights[i] / hordeTotalWeight) * 100));
if (g_BotDistDebugMode) if (g_BotDistFullDebugMode || g_BotDistLiteDebugMode)
{ {
LOG_INFO("server.loading", "[BotLevelBrackets] Dynamic Distribution - Horde Range {}: {}-{}, Real Players: {} (weight: {:.2f}), New Desired: {}%", LOG_INFO("server.loading", "[BotLevelBrackets] Dynamic Distribution - Horde Range {}: {}-{}, Real Players: {} (weight: {:.2f}), New Desired: {}%",
i + 1, g_HordeLevelRanges[i].lower, g_HordeLevelRanges[i].upper, hordeRealCounts[i], hordeWeights[i], g_HordeLevelRanges[i].desiredPercent); i + 1, g_HordeLevelRanges[i].lower, g_HordeLevelRanges[i].upper, hordeRealCounts[i], hordeWeights[i], g_HordeLevelRanges[i].desiredPercent);
@@ -612,7 +663,7 @@ public:
if (sumHorde < 100 && hordeTotalWeight > 0) if (sumHorde < 100 && hordeTotalWeight > 0)
{ {
uint8 missing = 100 - sumHorde; uint8 missing = 100 - sumHorde;
if (g_BotDistDebugMode) if (g_BotDistFullDebugMode || g_BotDistLiteDebugMode)
{ {
LOG_INFO("server.loading", "[BotLevelBrackets] Horde normalization: current sum = {}, missing = {}", sumHorde, missing); LOG_INFO("server.loading", "[BotLevelBrackets] Horde normalization: current sum = {}, missing = {}", sumHorde, missing);
} }
@@ -628,7 +679,7 @@ public:
} }
} }
} }
if (g_BotDistDebugMode) if (g_BotDistFullDebugMode || g_BotDistLiteDebugMode)
{ {
LOG_INFO("server.loading", "[BotLevelBrackets] Horde normalized percentages:"); LOG_INFO("server.loading", "[BotLevelBrackets] Horde normalized percentages:");
for (int i = 0; i < NUM_RANGES; ++i) for (int i = 0; i < NUM_RANGES; ++i)
@@ -655,7 +706,7 @@ public:
// Iterate only over player bots. // Iterate only over player bots.
auto const& allPlayers = ObjectAccessor::GetPlayers(); auto const& allPlayers = ObjectAccessor::GetPlayers();
if (g_BotDistDebugMode) if (g_BotDistFullDebugMode)
LOG_INFO("server.loading", "[BotLevelBrackets] Starting processing of {} players.", allPlayers.size()); LOG_INFO("server.loading", "[BotLevelBrackets] Starting processing of {} players.", allPlayers.size());
for (auto const& itr : allPlayers) for (auto const& itr : allPlayers)
@@ -663,19 +714,19 @@ public:
Player* player = itr.second; Player* player = itr.second;
if (!player) if (!player)
{ {
if (g_BotDistDebugMode) if (g_BotDistFullDebugMode)
LOG_INFO("server.loading", "[BotLevelBrackets] Skipping null player."); LOG_INFO("server.loading", "[BotLevelBrackets] Skipping null player.");
continue; continue;
} }
if (!player->IsInWorld()) if (!player->IsInWorld())
{ {
if (g_BotDistDebugMode) if (g_BotDistFullDebugMode)
LOG_INFO("server.loading", "[BotLevelBrackets] Skipping player '{}' as they are not in world.", player->GetName()); LOG_INFO("server.loading", "[BotLevelBrackets] Skipping player '{}' as they are not in world.", player->GetName());
continue; continue;
} }
if (!IsPlayerBot(player) || !IsPlayerRandomBot(player)) if (!IsPlayerBot(player) || !IsPlayerRandomBot(player))
{ {
if (g_BotDistDebugMode) if (g_BotDistFullDebugMode)
LOG_INFO("server.loading", "[BotLevelBrackets] Skipping player '{}' as they are not a random bot.", player->GetName()); LOG_INFO("server.loading", "[BotLevelBrackets] Skipping player '{}' as they are not a random bot.", player->GetName());
continue; continue;
} }
@@ -688,11 +739,11 @@ public:
{ {
allianceActualCounts[rangeIndex]++; allianceActualCounts[rangeIndex]++;
allianceBotsByRange[rangeIndex].push_back(player); allianceBotsByRange[rangeIndex].push_back(player);
if (g_BotDistDebugMode) if (g_BotDistFullDebugMode)
LOG_INFO("server.loading", "[BotLevelBrackets] Alliance bot '{}' with level {} added to range {}.", LOG_INFO("server.loading", "[BotLevelBrackets] Alliance bot '{}' with level {} added to range {}.",
player->GetName(), player->GetLevel(), rangeIndex + 1); player->GetName(), player->GetLevel(), rangeIndex + 1);
} }
else if (g_BotDistDebugMode) else if (g_BotDistFullDebugMode)
{ {
LOG_INFO("server.loading", "[BotLevelBrackets] Alliance bot '{}' with level {} does not fall into any defined range.", LOG_INFO("server.loading", "[BotLevelBrackets] Alliance bot '{}' with level {} does not fall into any defined range.",
player->GetName(), player->GetLevel()); player->GetName(), player->GetLevel());
@@ -706,11 +757,11 @@ public:
{ {
hordeActualCounts[rangeIndex]++; hordeActualCounts[rangeIndex]++;
hordeBotsByRange[rangeIndex].push_back(player); hordeBotsByRange[rangeIndex].push_back(player);
if (g_BotDistDebugMode) if (g_BotDistFullDebugMode)
LOG_INFO("server.loading", "[BotLevelBrackets] Horde bot '{}' with level {} added to range {}.", LOG_INFO("server.loading", "[BotLevelBrackets] Horde bot '{}' with level {} added to range {}.",
player->GetName(), player->GetLevel(), rangeIndex + 1); player->GetName(), player->GetLevel(), rangeIndex + 1);
} }
else if (g_BotDistDebugMode) else if (g_BotDistFullDebugMode)
{ {
LOG_INFO("server.loading", "[BotLevelBrackets] Horde bot '{}' with level {} does not fall into any defined range.", LOG_INFO("server.loading", "[BotLevelBrackets] Horde bot '{}' with level {} does not fall into any defined range.",
player->GetName(), player->GetLevel()); player->GetName(), player->GetLevel());
@@ -718,7 +769,7 @@ public:
} }
} }
if (g_BotDistDebugMode) if (g_BotDistFullDebugMode || g_BotDistLiteDebugMode)
{ {
LOG_INFO("server.loading", "[BotLevelBrackets] ========================================="); LOG_INFO("server.loading", "[BotLevelBrackets] =========================================");
LOG_INFO("server.loading", "[BotLevelBrackets] Total Alliance Bots: {}.", totalAllianceBots); LOG_INFO("server.loading", "[BotLevelBrackets] Total Alliance Bots: {}.", totalAllianceBots);
@@ -729,23 +780,29 @@ public:
// Process Alliance bots. // Process Alliance bots.
if (totalAllianceBots > 0) if (totalAllianceBots > 0)
{ {
LOG_INFO("server.loading", "[BotLevelBrackets] ========================================="); if (g_BotDistFullDebugMode || g_BotDistLiteDebugMode)
{
LOG_INFO("server.loading", "[BotLevelBrackets] =========================================");
}
int allianceDesiredCounts[NUM_RANGES] = {0}; int allianceDesiredCounts[NUM_RANGES] = {0};
for (int i = 0; i < NUM_RANGES; ++i) for (int i = 0; i < NUM_RANGES; ++i)
{ {
allianceDesiredCounts[i] = static_cast<int>(round((g_AllianceLevelRanges[i].desiredPercent / 100.0) * totalAllianceBots)); allianceDesiredCounts[i] = static_cast<int>(round((g_AllianceLevelRanges[i].desiredPercent / 100.0) * totalAllianceBots));
if (g_BotDistDebugMode) if (g_BotDistFullDebugMode || g_BotDistLiteDebugMode)
{ {
LOG_INFO("server.loading", "[BotLevelBrackets] Alliance Range {} ({}-{}): Desired = {}, Actual = {}.", LOG_INFO("server.loading", "[BotLevelBrackets] Alliance Range {} ({}-{}): Desired = {}, Actual = {}.",
i + 1, g_AllianceLevelRanges[i].lower, g_AllianceLevelRanges[i].upper, i + 1, g_AllianceLevelRanges[i].lower, g_AllianceLevelRanges[i].upper,
allianceDesiredCounts[i], allianceActualCounts[i]); allianceDesiredCounts[i], allianceActualCounts[i]);
} }
} }
LOG_INFO("server.loading", "[BotLevelBrackets] ========================================="); if (g_BotDistFullDebugMode || g_BotDistLiteDebugMode)
{
LOG_INFO("server.loading", "[BotLevelBrackets] =========================================");
}
// Adjust overpopulated ranges. // Adjust overpopulated ranges.
for (int i = 0; i < NUM_RANGES; ++i) for (int i = 0; i < NUM_RANGES; ++i)
{ {
if (g_BotDistDebugMode) if (g_BotDistFullDebugMode)
LOG_INFO("server.loading", "[BotLevelBrackets] >>> Processing Alliance bots in range {}.", i + 1); LOG_INFO("server.loading", "[BotLevelBrackets] >>> Processing Alliance bots in range {}.", i + 1);
std::vector<Player*> safeBots; std::vector<Player*> safeBots;
@@ -755,7 +812,7 @@ public:
if (IsBotSafeForLevelReset(bot)) if (IsBotSafeForLevelReset(bot))
{ {
safeBots.push_back(bot); safeBots.push_back(bot);
if (g_BotDistDebugMode) if (g_BotDistFullDebugMode)
{ {
//LOG_INFO("server.loading", "[BotLevelBrackets] Alliance bot '{}' is safe for level reset in range {}.", bot->GetName(), i + 1); //LOG_INFO("server.loading", "[BotLevelBrackets] Alliance bot '{}' is safe for level reset in range {}.", bot->GetName(), i + 1);
} }
@@ -763,7 +820,7 @@ public:
else else
{ {
flaggedBots.push_back(bot); flaggedBots.push_back(bot);
if (g_BotDistDebugMode) if (g_BotDistFullDebugMode)
LOG_INFO("server.loading", "[BotLevelBrackets] Alliance bot '{}' is NOT safe for level reset in range {}.", LOG_INFO("server.loading", "[BotLevelBrackets] Alliance bot '{}' is NOT safe for level reset in range {}.",
bot->GetName(), i + 1); bot->GetName(), i + 1);
} }
@@ -772,8 +829,10 @@ public:
{ {
Player* bot = safeBots.back(); Player* bot = safeBots.back();
safeBots.pop_back(); safeBots.pop_back();
LOG_INFO("server.loading", "[BotLevelBrackets] Alliance safe bot '{}' from range {} will be moved.", if (g_BotDistFullDebugMode)
bot->GetName(), i + 1); {
LOG_INFO("server.loading", "[BotLevelBrackets] Alliance safe bot '{}' from range {} will be moved.", bot->GetName(), i + 1);
}
int targetRange = -1; int targetRange = -1;
if (bot->getClass() == CLASS_DEATH_KNIGHT) if (bot->getClass() == CLASS_DEATH_KNIGHT)
{ {
@@ -799,11 +858,16 @@ public:
} }
if (targetRange == -1) if (targetRange == -1)
{ {
LOG_INFO("server.loading", "[BotLevelBrackets] No valid target range found for alliance safe bot '{}'.", bot->GetName()); if (g_BotDistFullDebugMode)
{
LOG_INFO("server.loading", "[BotLevelBrackets] No valid target range found for alliance safe bot '{}'.", bot->GetName());
}
break; break;
} }
LOG_INFO("server.loading", "[BotLevelBrackets] !!!! Adjusting alliance bot '{}' from range {} to range {} ({}-{}).", if (g_BotDistFullDebugMode)
bot->GetName(), i + 1, targetRange + 1, g_AllianceLevelRanges[targetRange].lower, g_AllianceLevelRanges[targetRange].upper); {
LOG_INFO("server.loading", "[BotLevelBrackets] !!!! Adjusting alliance bot '{}' from range {} to range {} ({}-{}).", bot->GetName(), i + 1, targetRange + 1, g_AllianceLevelRanges[targetRange].lower, g_AllianceLevelRanges[targetRange].upper);
}
AdjustBotToRange(bot, targetRange, g_AllianceLevelRanges); AdjustBotToRange(bot, targetRange, g_AllianceLevelRanges);
allianceActualCounts[i]--; allianceActualCounts[i]--;
allianceActualCounts[targetRange]++; allianceActualCounts[targetRange]++;
@@ -812,8 +876,11 @@ public:
{ {
Player* bot = flaggedBots.back(); Player* bot = flaggedBots.back();
flaggedBots.pop_back(); flaggedBots.pop_back();
LOG_INFO("server.loading", "[BotLevelBrackets] Alliance flagged bot '{}' from range {} will be processed for pending reset.",
bot->GetName(), i + 1); if (g_BotDistFullDebugMode)
{
LOG_INFO("server.loading", "[BotLevelBrackets] Alliance flagged bot '{}' from range {} will be processed for pending reset.", bot->GetName(), i + 1);
}
int targetRange = -1; int targetRange = -1;
if (bot->getClass() == CLASS_DEATH_KNIGHT) if (bot->getClass() == CLASS_DEATH_KNIGHT)
{ {
@@ -839,7 +906,10 @@ public:
} }
if (targetRange == -1) if (targetRange == -1)
{ {
LOG_INFO("server.loading", "[BotLevelBrackets] No valid target range found for flagged alliance bot '{}' for pending reset.", bot->GetName()); if (g_BotDistFullDebugMode)
{
LOG_INFO("server.loading", "[BotLevelBrackets] No valid target range found for flagged alliance bot '{}' for pending reset.", bot->GetName());
}
break; break;
} }
bool alreadyFlagged = false; bool alreadyFlagged = false;
@@ -854,8 +924,10 @@ public:
if (!alreadyFlagged) if (!alreadyFlagged)
{ {
g_PendingLevelResets.push_back({bot, targetRange, g_AllianceLevelRanges}); g_PendingLevelResets.push_back({bot, targetRange, g_AllianceLevelRanges});
LOG_INFO("server.loading", "[BotLevelBrackets] Alliance bot '{}' flagged for pending level reset to range {}-{}.", if (g_BotDistFullDebugMode)
bot->GetName(), g_AllianceLevelRanges[targetRange].lower, g_AllianceLevelRanges[targetRange].upper); {
LOG_INFO("server.loading", "[BotLevelBrackets] Alliance bot '{}' flagged for pending level reset to range {}-{}.", bot->GetName(), g_AllianceLevelRanges[targetRange].lower, g_AllianceLevelRanges[targetRange].upper);
}
} }
} }
} }
@@ -864,22 +936,28 @@ public:
// Process Horde bots. // Process Horde bots.
if (totalHordeBots > 0) if (totalHordeBots > 0)
{ {
LOG_INFO("server.loading", "[BotLevelBrackets] ========================================="); if (g_BotDistFullDebugMode || g_BotDistLiteDebugMode)
{
LOG_INFO("server.loading", "[BotLevelBrackets] =========================================");
}
int hordeDesiredCounts[NUM_RANGES] = {0}; int hordeDesiredCounts[NUM_RANGES] = {0};
for (int i = 0; i < NUM_RANGES; ++i) for (int i = 0; i < NUM_RANGES; ++i)
{ {
hordeDesiredCounts[i] = static_cast<int>(round((g_HordeLevelRanges[i].desiredPercent / 100.0) * totalHordeBots)); hordeDesiredCounts[i] = static_cast<int>(round((g_HordeLevelRanges[i].desiredPercent / 100.0) * totalHordeBots));
if (g_BotDistDebugMode) if (g_BotDistFullDebugMode || g_BotDistLiteDebugMode)
{ {
LOG_INFO("server.loading", "[BotLevelBrackets] Horde Range {} ({}-{}): Desired = {}, Actual = {}.", LOG_INFO("server.loading", "[BotLevelBrackets] Horde Range {} ({}-{}): Desired = {}, Actual = {}.",
i + 1, g_HordeLevelRanges[i].lower, g_HordeLevelRanges[i].upper, i + 1, g_HordeLevelRanges[i].lower, g_HordeLevelRanges[i].upper,
hordeDesiredCounts[i], hordeActualCounts[i]); hordeDesiredCounts[i], hordeActualCounts[i]);
} }
} }
LOG_INFO("server.loading", "[BotLevelBrackets] ========================================="); if (g_BotDistFullDebugMode || g_BotDistLiteDebugMode)
{
LOG_INFO("server.loading", "[BotLevelBrackets] =========================================");
}
for (int i = 0; i < NUM_RANGES; ++i) for (int i = 0; i < NUM_RANGES; ++i)
{ {
if (g_BotDistDebugMode) if (g_BotDistFullDebugMode)
LOG_INFO("server.loading", "[BotLevelBrackets] Processing Horde bots in range {}.", i + 1); LOG_INFO("server.loading", "[BotLevelBrackets] Processing Horde bots in range {}.", i + 1);
std::vector<Player*> safeBots; std::vector<Player*> safeBots;
@@ -889,7 +967,7 @@ public:
if (IsBotSafeForLevelReset(bot)) if (IsBotSafeForLevelReset(bot))
{ {
safeBots.push_back(bot); safeBots.push_back(bot);
if (g_BotDistDebugMode) if (g_BotDistFullDebugMode)
{ {
//LOG_INFO("server.loading", "[BotLevelBrackets] Horde bot '{}' is safe for level reset in range {}.", bot->GetName(), i + 1); //LOG_INFO("server.loading", "[BotLevelBrackets] Horde bot '{}' is safe for level reset in range {}.", bot->GetName(), i + 1);
} }
@@ -897,7 +975,7 @@ public:
else else
{ {
flaggedBots.push_back(bot); flaggedBots.push_back(bot);
if (g_BotDistDebugMode) if (g_BotDistFullDebugMode)
LOG_INFO("server.loading", "[BotLevelBrackets] Horde bot '{}' is NOT safe for level reset in range {}.", LOG_INFO("server.loading", "[BotLevelBrackets] Horde bot '{}' is NOT safe for level reset in range {}.",
bot->GetName(), i + 1); bot->GetName(), i + 1);
} }
@@ -906,8 +984,12 @@ public:
{ {
Player* bot = safeBots.back(); Player* bot = safeBots.back();
safeBots.pop_back(); safeBots.pop_back();
LOG_INFO("server.loading", "[BotLevelBrackets] Horde safe bot '{}' from range {} will be moved.",
bot->GetName(), i + 1); if (g_BotDistFullDebugMode)
{
LOG_INFO("server.loading", "[BotLevelBrackets] Horde safe bot '{}' from range {} will be moved.", bot->GetName(), i + 1);
}
int targetRange = -1; int targetRange = -1;
if (bot->getClass() == CLASS_DEATH_KNIGHT) if (bot->getClass() == CLASS_DEATH_KNIGHT)
{ {
@@ -933,11 +1015,16 @@ public:
} }
if (targetRange == -1) if (targetRange == -1)
{ {
LOG_INFO("server.loading", "[BotLevelBrackets] No valid target range found for safe horde bot '{}'.", bot->GetName()); if (g_BotDistFullDebugMode)
{
LOG_INFO("server.loading", "[BotLevelBrackets] No valid target range found for safe horde bot '{}'.", bot->GetName());
}
break; break;
} }
LOG_INFO("server.loading", "[BotLevelBrackets] !!!! Adjusting horde bot '{}' from range {} to range {} ({}-{}).", if (g_BotDistFullDebugMode)
bot->GetName(), i + 1, targetRange + 1, g_HordeLevelRanges[targetRange].lower, g_HordeLevelRanges[targetRange].upper); {
LOG_INFO("server.loading", "[BotLevelBrackets] !!!! Adjusting horde bot '{}' from range {} to range {} ({}-{}).", bot->GetName(), i + 1, targetRange + 1, g_HordeLevelRanges[targetRange].lower, g_HordeLevelRanges[targetRange].upper);
}
AdjustBotToRange(bot, targetRange, g_HordeLevelRanges); AdjustBotToRange(bot, targetRange, g_HordeLevelRanges);
hordeActualCounts[i]--; hordeActualCounts[i]--;
hordeActualCounts[targetRange]++; hordeActualCounts[targetRange]++;
@@ -946,8 +1033,10 @@ public:
{ {
Player* bot = flaggedBots.back(); Player* bot = flaggedBots.back();
flaggedBots.pop_back(); flaggedBots.pop_back();
LOG_INFO("server.loading", "[BotLevelBrackets] Horde flagged bot '{}' from range {} will be processed for pending reset.", if (g_BotDistFullDebugMode)
bot->GetName(), i + 1); {
LOG_INFO("server.loading", "[BotLevelBrackets] Horde flagged bot '{}' from range {} will be processed for pending reset.", bot->GetName(), i + 1);
}
int targetRange = -1; int targetRange = -1;
if (bot->getClass() == CLASS_DEATH_KNIGHT) if (bot->getClass() == CLASS_DEATH_KNIGHT)
{ {
@@ -973,7 +1062,10 @@ public:
} }
if (targetRange == -1) if (targetRange == -1)
{ {
LOG_INFO("server.loading", "[BotLevelBrackets] No valid target range found for flagged horde bot '{}' for pending reset.", bot->GetName()); if (g_BotDistFullDebugMode)
{
LOG_INFO("server.loading", "[BotLevelBrackets] No valid target range found for flagged horde bot '{}' for pending reset.", bot->GetName());
}
break; break;
} }
bool alreadyFlagged = false; bool alreadyFlagged = false;
@@ -988,15 +1080,17 @@ public:
if (!alreadyFlagged) if (!alreadyFlagged)
{ {
g_PendingLevelResets.push_back({bot, targetRange, g_HordeLevelRanges}); g_PendingLevelResets.push_back({bot, targetRange, g_HordeLevelRanges});
LOG_INFO("server.loading", "[BotLevelBrackets] Horde bot '{}' flagged for pending level reset to range {}-{}.", if (g_BotDistFullDebugMode)
bot->GetName(), g_HordeLevelRanges[targetRange].lower, g_HordeLevelRanges[targetRange].upper); {
LOG_INFO("server.loading", "[BotLevelBrackets] Horde bot '{}' flagged for pending level reset to range {}-{}.", bot->GetName(), g_HordeLevelRanges[targetRange].lower, g_HordeLevelRanges[targetRange].upper);
}
} }
} }
} }
} }
if (g_BotDistDebugMode) if (g_BotDistFullDebugMode || g_BotDistLiteDebugMode)
{ {
LOG_INFO("server.loading", "[BotLevelBrackets] ========================================= COMPLETE"); LOG_INFO("server.loading", "[BotLevelBrackets] ========================================= COMPLETE");
LOG_INFO("server.loading", "[BotLevelBrackets] Distribution adjustment complete. Alliance bots: {}, Horde bots: {}.", LOG_INFO("server.loading", "[BotLevelBrackets] Distribution adjustment complete. Alliance bots: {}, Horde bots: {}.",