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

@@ -24,8 +24,8 @@ bool ReviveFromCorpseAction::Execute(Event event)
WorldPacket& p = event.getPacket();
if (!p.empty() && p.GetOpcode() == CMSG_RECLAIM_CORPSE && groupLeader && !corpse && bot->IsAlive())
{
if (sServerFacade->IsDistanceLessThan(AI_VALUE2(float, "distance", "group leader"),
sPlayerbotAIConfig->farDistance))
if (ServerFacade::instance().IsDistanceLessThan(AI_VALUE2(float, "distance", "group leader"),
sPlayerbotAIConfig.farDistance))
{
if (!botAI->HasStrategy("follow", BOT_STATE_NON_COMBAT))
{
@@ -46,8 +46,8 @@ bool ReviveFromCorpseAction::Execute(Event event)
if (groupLeader)
{
if (!GET_PLAYERBOT_AI(groupLeader) && groupLeader->isDead() && groupLeader->GetCorpse() &&
sServerFacade->IsDistanceLessThan(AI_VALUE2(float, "distance", "group leader"),
sPlayerbotAIConfig->farDistance))
ServerFacade::instance().IsDistanceLessThan(AI_VALUE2(float, "distance", "group leader"),
sPlayerbotAIConfig.farDistance))
return false;
}
@@ -87,8 +87,8 @@ bool FindCorpseAction::Execute(Event event)
// if (groupLeader)
// {
// if (!GET_PLAYERBOT_AI(groupLeader) &&
// sServerFacade->IsDistanceLessThan(AI_VALUE2(float, "distance", "group leader"),
// sPlayerbotAIConfig->farDistance)) return false;
// ServerFacade::instance().IsDistanceLessThan(AI_VALUE2(float, "distance", "group leader"),
// sPlayerbotAIConfig.farDistance)) return false;
// }
uint32 dCount = AI_VALUE(uint32, "death count");
@@ -101,8 +101,8 @@ bool FindCorpseAction::Execute(Event event)
// bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(),
// bot->GetName().c_str());
context->GetValue<uint32>("death count")->Set(0);
// sRandomPlayerbotMgr->RandomTeleportForLevel(bot);
sRandomPlayerbotMgr->Revive(bot);
// sRandomPlayerbotMgr.RandomTeleportForLevel(bot);
sRandomPlayerbotMgr.Revive(bot);
return true;
}
}
@@ -123,7 +123,7 @@ bool FindCorpseAction::Execute(Event event)
{
if (moveToLeader) // We are near group leader.
{
if (botPos.fDist(leaderPos) < sPlayerbotAIConfig->spellDistance)
if (botPos.fDist(leaderPos) < sPlayerbotAIConfig.spellDistance)
return false;
}
else if (deadTime > 8 * MINUTE) // We have walked too long already.
@@ -138,7 +138,7 @@ bool FindCorpseAction::Execute(Event event)
}
// If we are getting close move to a save ressurrection spot instead of just the corpse.
if (corpseDist < sPlayerbotAIConfig->reactDistance)
if (corpseDist < sPlayerbotAIConfig.reactDistance)
{
if (moveToLeader)
moveToPos = leaderPos;
@@ -162,7 +162,7 @@ bool FindCorpseAction::Execute(Event event)
if (!botAI->AllowActivity(ALL_ACTIVITY))
{
uint32 delay = sServerFacade->GetDistance2d(bot, corpse) /
uint32 delay = ServerFacade::instance().GetDistance2d(bot, corpse) /
bot->GetSpeed(MOVE_RUN); // Time a bot would take to travel to it's corpse.
delay = std::min(delay, uint32(10 * MINUTE)); // Cap time to get to corpse at 10 minutes.
@@ -308,7 +308,7 @@ bool SpiritHealerAction::Execute(Event event)
GraveyardStruct const* ClosestGrave =
GetGrave(dCount > 10 || deadTime > 15 * MINUTE || AI_VALUE(uint8, "durability") < 10);
if (bot->GetDistance2d(ClosestGrave->x, ClosestGrave->y) < sPlayerbotAIConfig->sightDistance)
if (bot->GetDistance2d(ClosestGrave->x, ClosestGrave->y) < sPlayerbotAIConfig.sightDistance)
{
GuidVector npcs = AI_VALUE(GuidVector, "nearest npcs");
for (GuidVector::iterator i = npcs.begin(); i != npcs.end(); i++)