Improper singletons migration to clean Meyer's singletons (cherry-pick) (#2082)

# Pull Request

- Applies the clean and corrected singletons, Meyer pattern. (cherry
picked from @SmashingQuasar )

Testing by just playing the game in various ways. Been tested by myself
@Celandriel and @SmashingQuasar
---

## Complexity & Impact

- Does this change add new decision branches?
    - [x] No
    - [ ] Yes (**explain below**)

- Does this change increase per-bot or per-tick processing?
    - [x] No
    - [ ] Yes (**describe and justify impact**)

- Could this logic scale poorly under load?
    - [x] No
    - [ ] Yes (**explain why**)

---

## Defaults & Configuration

- Does this change modify default bot behavior?
    - [x] No
    - [ ] Yes (**explain why**)

---

## AI Assistance

- Was AI assistance (e.g. ChatGPT or similar tools) used while working
on this change?
    - [x] No
    - [ ] Yes (**explain below**)
---

## Final Checklist

- [x] Stability is not compromised
- [x] Performance impact is understood, tested, and acceptable
- [x] Added logic complexity is justified and explained
- [x] Documentation updated if needed

---

## Notes for Reviewers

Anything that significantly improves realism at the cost of stability or
performance should be carefully discussed
before merging.

---------

Co-authored-by: Nicolas Lebacq <nicolas.cordier@outlook.com>
Co-authored-by: Keleborn <22352763+Celandriel@users.noreply.github.com>
This commit is contained in:
bashermens
2026-01-30 21:49:37 +01:00
committed by GitHub
parent a92886032c
commit 13fff46fa0
233 changed files with 2460 additions and 2354 deletions

View File

@@ -1276,7 +1276,7 @@ static std::pair<uint32, uint32> IC_AttackObjectives[] = {
// useful commands for fixing BG bugs and checking waypoints/paths
bool BGTactics::HandleConsoleCommand(ChatHandler* handler, char const* args)
{
if (!sPlayerbotAIConfig->enabled)
if (!sPlayerbotAIConfig.enabled)
{
handler->PSendSysMessage("|cffff0000Playerbot system is currently disabled!");
return true;
@@ -2219,7 +2219,7 @@ bool BGTactics::selectObjective(bool reset)
if (urand(0, 99) < 20 && teamFC)
{
target.Relocate(teamFC->GetPositionX(), teamFC->GetPositionY(), teamFC->GetPositionZ());
if (sServerFacade->GetDistance2d(bot, teamFC) < 33.0f)
if (ServerFacade::instance().GetDistance2d(bot, teamFC) < 33.0f)
Follow(teamFC);
}
else
@@ -2263,7 +2263,7 @@ bool BGTactics::selectObjective(bool reset)
if (urand(0, 99) < 70)
{
target.Relocate(teamFC->GetPositionX(), teamFC->GetPositionY(), teamFC->GetPositionZ());
if (sServerFacade->GetDistance2d(bot, teamFC) < 33.0f)
if (ServerFacade::instance().GetDistance2d(bot, teamFC) < 33.0f)
Follow(teamFC);
}
}
@@ -2284,7 +2284,7 @@ bool BGTactics::selectObjective(bool reset)
{
// Assist own FC if not pursuing enemy FC
target.Relocate(teamFC->GetPositionX(), teamFC->GetPositionY(), teamFC->GetPositionZ());
if (sServerFacade->GetDistance2d(bot, teamFC) < 33.0f)
if (ServerFacade::instance().GetDistance2d(bot, teamFC) < 33.0f)
Follow(teamFC);
}
else if (urand(0, 99) < 5)
@@ -3197,11 +3197,11 @@ bool BGTactics::moveToObjective(bool ignoreDist)
return true;
}
if (!ignoreDist && sServerFacade->IsDistanceGreaterThan(sServerFacade->GetDistance2d(bot, pos.x, pos.y), 100.0f))
if (!ignoreDist && ServerFacade::instance().IsDistanceGreaterThan(ServerFacade::instance().GetDistance2d(bot, pos.x, pos.y), 100.0f))
{
// std::ostringstream out;
// out << "It is too far away! " << pos.x << ", " << pos.y << ", Distance: " <<
// sServerFacade->GetDistance2d(bot, pos.x, pos.y); bot->Say(out.str(), LANG_UNIVERSAL);
// ServerFacade::instance().GetDistance2d(bot, pos.x, pos.y); bot->Say(out.str(), LANG_UNIVERSAL);
return false;
}
@@ -3213,7 +3213,7 @@ bool BGTactics::moveToObjective(bool ignoreDist)
}
// std::ostringstream out; out << "Moving to objective " << pos.x << ", " << pos.y << ", Distance: " <<
// sServerFacade->GetDistance2d(bot, pos.x, pos.y); bot->Say(out.str(), LANG_UNIVERSAL);
// ServerFacade::instance().GetDistance2d(bot, pos.x, pos.y); bot->Say(out.str(), LANG_UNIVERSAL);
// dont increase from 1.5 will cause bugs with horde capping AV towers
return MoveNear(bot->GetMapId(), pos.x, pos.y, pos.z, 1.5f);
@@ -3433,7 +3433,7 @@ bool BGTactics::moveToObjectiveWp(BattleBotPath* const& currentPath, uint32 curr
// out << "WP: ";
// reverse ? out << currPoint << " <<< -> " << nPoint : out << currPoint << ">>> ->" << nPoint;
// out << ", " << nextPoint.x << ", " << nextPoint.y << " Path Size: " << currentPath->size() << ", Dist: " <<
// sServerFacade->GetDistance2d(bot, nextPoint.x, nextPoint.y); bot->Say(out.str(), LANG_UNIVERSAL);
// ServerFacade::instance().GetDistance2d(bot, nextPoint.x, nextPoint.y); bot->Say(out.str(), LANG_UNIVERSAL);
return MoveTo(bot->GetMapId(), nextPoint.x + frand(-2, 2), nextPoint.y + frand(-2, 2), nextPoint.z);
}
@@ -4039,9 +4039,9 @@ bool BGTactics::useBuff()
if (closeObjects.empty())
return false;
bool needRegen = bot->GetHealthPct() < sPlayerbotAIConfig->mediumHealth ||
bool needRegen = bot->GetHealthPct() < sPlayerbotAIConfig.mediumHealth ||
(AI_VALUE2(bool, "has mana", "self target") &&
AI_VALUE2(uint8, "mana", "self target") < sPlayerbotAIConfig->mediumMana);
AI_VALUE2(uint8, "mana", "self target") < sPlayerbotAIConfig.mediumMana);
bool needSpeed = (bgType != BATTLEGROUND_WS || bot->HasAura(BG_WS_SPELL_WARSONG_FLAG) ||
bot->HasAura(BG_WS_SPELL_SILVERWING_FLAG) || bot->HasAura(BG_EY_NETHERSTORM_FLAG_SPELL)) ||
!(teamFlagTaken() || flagTaken());
@@ -4057,7 +4057,7 @@ bool BGTactics::useBuff()
continue;
// use speed buff only if close
if (sServerFacade->IsDistanceGreaterThan(sServerFacade->GetDistance2d(bot, go),
if (ServerFacade::instance().IsDistanceGreaterThan(ServerFacade::instance().GetDistance2d(bot, go),
go->GetEntry() == Buff_Entries[0] ? 20.0f : 50.0f))
continue;
@@ -4107,7 +4107,7 @@ uint32 BGTactics::getPlayersInArea(TeamId teamId, Position point, float range, b
if (!combat && player->IsInCombat())
continue;
if (sServerFacade->GetDistance2d(player, point.GetPositionX(), point.GetPositionY()) < range)
if (ServerFacade::instance().GetDistance2d(player, point.GetPositionX(), point.GetPositionY()) < range)
++defCount;
}
}
@@ -4191,9 +4191,9 @@ bool BGTactics::IsLockedInsideKeep()
// get closest portal
if (bot->GetTeamId() == TEAM_ALLIANCE && go->GetEntry() == GO_TELEPORTER_4)
{
float tempDist = sServerFacade->GetDistance2d(bot, go->GetPositionX(), go->GetPositionY());
float tempDist = ServerFacade::instance().GetDistance2d(bot, go->GetPositionX(), go->GetPositionY());
if (sServerFacade->IsDistanceLessThan(tempDist, closestDistance))
if (ServerFacade::instance().IsDistanceLessThan(tempDist, closestDistance))
{
closestDistance = tempDist;
closestPortal = go;
@@ -4204,9 +4204,9 @@ bool BGTactics::IsLockedInsideKeep()
// get closest portal
if (bot->GetTeamId() == TEAM_HORDE && go->GetEntry() == GO_TELEPORTER_2)
{
float tempDist = sServerFacade->GetDistance2d(bot, go->GetPositionX(), go->GetPositionY());
float tempDist = ServerFacade::instance().GetDistance2d(bot, go->GetPositionX(), go->GetPositionY());
if (sServerFacade->IsDistanceLessThan(tempDist, closestDistance))
if (ServerFacade::instance().IsDistanceLessThan(tempDist, closestDistance))
{
closestDistance = tempDist;
closestPortal = go;
@@ -4253,7 +4253,7 @@ bool ArenaTactics::Execute(Event event)
{
if (!bot->InBattleground())
{
bool IsRandomBot = sRandomPlayerbotMgr->IsRandomBot(bot->GetGUID().GetCounter());
bool IsRandomBot = sRandomPlayerbotMgr.IsRandomBot(bot->GetGUID().GetCounter());
botAI->ChangeStrategy("-arena", BOT_STATE_COMBAT);
botAI->ChangeStrategy("-arena", BOT_STATE_NON_COMBAT);
botAI->ResetStrategies(!IsRandomBot);