Skip to content

Commit

Permalink
Merge pull request liyunfan1223#286 from fuzzdeveloper/master
Browse files Browse the repository at this point in the history
Fixed AiPlayerbot.PerfMonEnabled crashing server (and printing formatting strings directly to screen) + a few other minor fixes
  • Loading branch information
liyunfan1223 authored Jun 26, 2024
2 parents 7513b52 + 6dddab7 commit 15d4b7a
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 32 deletions.
10 changes: 4 additions & 6 deletions src/PerformanceMonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void PerformanceMonitor::PrintStats(bool perTick, bool fullStack)
total += map.second->totalTime;

LOG_INFO("playerbots", "--------------------------------------[TOTAL BOT]------------------------------------------------------");
LOG_INFO("playerbots", "percentage time | min .. max ( avg of count ) - type : name ");
LOG_INFO("playerbots", "percentage time | min .. max ( avg of count) - type : name");

for (std::map<PerformanceMetric, std::map<std::string, PerformanceData*>>::iterator i = data.begin(); i != data.end(); ++i)
{
Expand Down Expand Up @@ -115,7 +115,7 @@ void PerformanceMonitor::PrintStats(bool perTick, bool fullStack)

if (avg >= 0.5f || pd->maxTime > 10)
{
LOG_INFO("playerbots", "%7.3f%% %10.3fs | %6u .. %6u (%9.4f of %10u) - {} : {}"
LOG_INFO("playerbots", "{:7.3f}% {:10.3f}s | {:6d} .. {:6d} ({:10.3f} of {:10d}) - {:6} : {}"
, perc
, secs
, pd->minTime
Expand All @@ -134,10 +134,8 @@ void PerformanceMonitor::PrintStats(bool perTick, bool fullStack)
float totalCount = data[PERF_MON_TOTAL]["RandomPlayerbotMgr::FullTick"]->count;
total = data[PERF_MON_TOTAL]["RandomPlayerbotMgr::FullTick"]->totalTime;

LOG_INFO("playerbots", " ");
LOG_INFO("playerbots", " ");
LOG_INFO("playerbots", "---------------------------------------[PER TICK]------------------------------------------------------");
LOG_INFO("playerbots", "percentage time | min .. max ( avg of count ) - type : name ");
LOG_INFO("playerbots", "percentage time | min .. max ( avg of count) - type : name");

for (std::map<PerformanceMetric, std::map<std::string, PerformanceData*>>::iterator i = data.begin(); i != data.end(); ++i)
{
Expand Down Expand Up @@ -190,7 +188,7 @@ void PerformanceMonitor::PrintStats(bool perTick, bool fullStack)

if (avg >= 0.5f || pd->maxTime > 10)
{
LOG_INFO("playerbots", "%7.3f%% %9ums | %6u .. %6u (%9.4f of %10.3f) - {} : {}"
LOG_INFO("playerbots", "{:7.3f}% {:9d}ms | {:6d} .. {:6d} ({:10.3f} of {:10.3f}) - {:6} : {}"
, perc
, secs
, pd->minTime
Expand Down
6 changes: 4 additions & 2 deletions src/PlayerbotAI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2174,8 +2174,10 @@ bool PlayerbotAI::CanCastSpell(uint32 spellid, Unit* target, bool checkHasSpell,
}

if (bot->GetCurrentSpell(CURRENT_CHANNELED_SPELL) != nullptr) {
LOG_DEBUG("playerbots", "CanCastSpell() target name: {}, spellid: {}, bot name: {}, failed because has current channeled spell",
target->GetName(), spellid, bot->GetName());
if (!sPlayerbotAIConfig->logInGroupOnly || (bot->GetGroup() && HasRealPlayerMaster())) {
LOG_DEBUG("playerbots", "CanCastSpell() target name: {}, spellid: {}, bot name: {}, failed because has current channeled spell",
target->GetName(), spellid, bot->GetName());
}
return false;
}

Expand Down
4 changes: 2 additions & 2 deletions src/PlayerbotFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -357,8 +357,8 @@ void PlayerbotFactory::Randomize(bool incremental)
// bot->SaveToDB(false, false);
// InitGuild();
// bot->SaveToDB(false, false);
if (pmo)
pmo->finish();
//if (pmo)
// pmo->finish();

// if (bot->getLevel() >= 70)
// {
Expand Down
2 changes: 1 addition & 1 deletion src/strategy/StrategyContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class StrategyContext : public NamedObjectContext<Strategy>
creators["map full"] = &StrategyContext::map_full;
creators["sit"] = &StrategyContext::sit;
creators["mark rti"] = &StrategyContext::mark_rti;
creators["ads"] = &StrategyContext::possible_adds;
creators["adds"] = &StrategyContext::possible_adds;
creators["close"] = &StrategyContext::close;
creators["ranged"] = &StrategyContext::ranged;
creators["behind"] = &StrategyContext::behind;
Expand Down
24 changes: 3 additions & 21 deletions src/strategy/actions/BattleGroundJoinAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,30 +250,13 @@ bool BGJoinAction::shouldJoinBg(BattlegroundQueueTypeId queueTypeId, Battlegroun
bool hasBots = (sRandomPlayerbotMgr->BgBots[queueTypeId][bracketId][TEAM_ALLIANCE] + sRandomPlayerbotMgr->BgBots[queueTypeId][bracketId][TEAM_HORDE]) >= bg->GetMinPlayersPerTeam();

if (!sPlayerbotAIConfig->randomBotAutoJoinBG && !hasPlayers)
{
return false;

if (sPlayerbotAIConfig->enablePrototypePerformanceDiff)
{
if (!noLag)
{
return false;
}
}
}

if (!hasPlayers && !(isArena))
{
if (!(hasPlayers || hasBots))
return false;

if (sPlayerbotAIConfig->enablePrototypePerformanceDiff)
{
if (!noLag)
{
return false;
}
}
}
if (sPlayerbotAIConfig->enablePrototypePerformanceDiff && !hasPlayers && !noLag)
return false;

uint32 BracketSize = bg->GetMaxPlayersPerTeam() * 2;
uint32 TeamSize = bg->GetMaxPlayersPerTeam();
Expand Down Expand Up @@ -607,7 +590,6 @@ bool FreeBGJoinAction::shouldJoinBg(BattlegroundQueueTypeId queueTypeId, Battleg

bool isArena = false;
bool isRated = false;
bool noLag = sWorldUpdateTime.GetAverageUpdateTime() < (sRandomPlayerbotMgr->GetPlayers().empty() ? sPlayerbotAIConfig->diffEmpty : sPlayerbotAIConfig->diffWithPlayer) * 1.1;

ArenaType type = ArenaType(BattlegroundMgr::BGArenaType(queueTypeId));
if (type != ARENA_TYPE_NONE)
Expand Down

0 comments on commit 15d4b7a

Please sign in to comment.