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

@@ -440,4 +440,4 @@ bool NewRpgTravelFlightAction::Execute(Event event)
botAI->rpgInfo.ChangeToIdle();
}
return true;
}
}

View File

@@ -103,4 +103,4 @@ public:
bool Execute(Event event) override;
};
#endif
#endif

View File

@@ -866,7 +866,7 @@ bool NewRpgBaseAction::GetQuestPOIPosAndObjectiveIdx(uint32 questId, std::vector
WorldPosition NewRpgBaseAction::SelectRandomGrindPos(Player* bot)
{
const std::vector<WorldLocation>& locs = sRandomPlayerbotMgr->locsPerLevelCache[bot->GetLevel()];
const std::vector<WorldLocation>& locs = sRandomPlayerbotMgr.locsPerLevelCache[bot->GetLevel()];
float hiRange = 500.0f;
float loRange = 2500.0f;
if (bot->GetLevel() < 5)
@@ -925,8 +925,8 @@ WorldPosition NewRpgBaseAction::SelectRandomGrindPos(Player* bot)
WorldPosition NewRpgBaseAction::SelectRandomCampPos(Player* bot)
{
const std::vector<WorldLocation>& locs = IsAlliance(bot->getRace())
? sRandomPlayerbotMgr->allianceStarterPerLevelCache[bot->GetLevel()]
: sRandomPlayerbotMgr->hordeStarterPerLevelCache[bot->GetLevel()];
? sRandomPlayerbotMgr.allianceStarterPerLevelCache[bot->GetLevel()]
: sRandomPlayerbotMgr.hordeStarterPerLevelCache[bot->GetLevel()];
bool inCity = false;
@@ -969,7 +969,7 @@ WorldPosition NewRpgBaseAction::SelectRandomCampPos(Player* bot)
bool NewRpgBaseAction::SelectRandomFlightTaxiNode(ObjectGuid& flightMaster, uint32& fromNode, uint32& toNode)
{
Creature* nearestFlightMaster = sFlightMasterCache->GetNearestFlightMaster(bot);
Creature* nearestFlightMaster = FlightMasterCache::Instance().GetNearestFlightMaster(bot);
if (!nearestFlightMaster || bot->GetDistance(nearestFlightMaster) > 500.0f)
return false;
@@ -1015,8 +1015,8 @@ bool NewRpgBaseAction::SelectRandomFlightTaxiNode(ObjectGuid& flightMaster, uint
capital = zone->flags & AREA_FLAG_CAPITAL;
}
auto itr = sRandomPlayerbotMgr->zone2LevelBracket.find(nodeZoneId);
if (!capital && itr == sRandomPlayerbotMgr->zone2LevelBracket.end())
auto itr = sRandomPlayerbotMgr.zone2LevelBracket.find(nodeZoneId);
if (!capital && itr == sRandomPlayerbotMgr.zone2LevelBracket.end())
continue;
if (!capital && (bot->GetLevel() < itr->second.low || bot->GetLevel() > itr->second.high))
@@ -1040,13 +1040,13 @@ bool NewRpgBaseAction::RandomChangeStatus(std::vector<NewRpgStatus> candidateSta
uint32 probSum = 0;
for (NewRpgStatus status : candidateStatus)
{
if (sPlayerbotAIConfig->RpgStatusProbWeight[status] == 0)
if (sPlayerbotAIConfig.RpgStatusProbWeight[status] == 0)
continue;
if (CheckRpgStatusAvailable(status))
{
availableStatus.push_back(status);
probSum += sPlayerbotAIConfig->RpgStatusProbWeight[status];
probSum += sPlayerbotAIConfig.RpgStatusProbWeight[status];
}
}
// Safety check. Default to "rest" if all RPG weights = 0
@@ -1061,7 +1061,7 @@ bool NewRpgBaseAction::RandomChangeStatus(std::vector<NewRpgStatus> candidateSta
NewRpgStatus chosenStatus = RPG_STATUS_END;
for (NewRpgStatus status : availableStatus)
{
accumulate += sPlayerbotAIConfig->RpgStatusProbWeight[status];
accumulate += sPlayerbotAIConfig.RpgStatusProbWeight[status];
if (accumulate >= rand)
{
chosenStatus = status;

View File

@@ -64,4 +64,4 @@ protected:
const uint32 stuckTime = 5 * 60 * 1000;
};
#endif
#endif

View File

@@ -136,4 +136,4 @@ std::string NewRpgInfo::ToString()
out << "UNKNOWN";
}
return out.str();
}
}

View File

@@ -130,4 +130,4 @@ struct NewRpgStatistic
// not sure is it necessary but keep it for now
#define RPG_INFO(x, y) botAI->rpgInfo.x.y
#endif
#endif

View File

@@ -1,4 +1,4 @@
#include "NewRpgTriggers.h"
#include "PlayerbotAI.h"
bool NewRpgStatusTrigger::IsActive() { return status == botAI->rpgInfo.status; }
bool NewRpgStatusTrigger::IsActive() { return status == botAI->rpgInfo.status; }