mirror of
https://github.com/mod-playerbots/mod-playerbots.git
synced 2026-02-04 03:13:48 +00:00
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:
@@ -61,7 +61,7 @@ bool GoAction::Execute(Event event)
|
||||
else
|
||||
{
|
||||
botAI->TellMasterNoFacing("Clearing travel target");
|
||||
target->setTarget(sTravelMgr->nullTravelDestination, sTravelMgr->nullWorldPosition);
|
||||
target->setTarget(TravelMgr::instance().nullTravelDestination, TravelMgr::instance().nullWorldPosition);
|
||||
target->setForced(false);
|
||||
return true;
|
||||
}
|
||||
@@ -75,8 +75,8 @@ bool GoAction::Execute(Event event)
|
||||
if (GameObject* go = botAI->GetGameObject(guid))
|
||||
if (go->isSpawned())
|
||||
{
|
||||
if (sServerFacade->IsDistanceGreaterThan(sServerFacade->GetDistance2d(bot, go),
|
||||
sPlayerbotAIConfig->reactDistance))
|
||||
if (ServerFacade::instance().IsDistanceGreaterThan(ServerFacade::instance().GetDistance2d(bot, go),
|
||||
sPlayerbotAIConfig.reactDistance))
|
||||
{
|
||||
botAI->TellError("It is too far away");
|
||||
return false;
|
||||
@@ -86,7 +86,7 @@ bool GoAction::Execute(Event event)
|
||||
out << "Moving to " << ChatHelper::FormatGameobject(go);
|
||||
botAI->TellMasterNoFacing(out.str());
|
||||
return MoveNear(bot->GetMapId(), go->GetPositionX(), go->GetPositionY(), go->GetPositionZ() + 0.5f,
|
||||
sPlayerbotAIConfig->followDistance);
|
||||
sPlayerbotAIConfig.followDistance);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@@ -106,7 +106,7 @@ bool GoAction::Execute(Event event)
|
||||
out << "Moving to " << unit->GetName();
|
||||
botAI->TellMasterNoFacing(out.str());
|
||||
return MoveNear(bot->GetMapId(), unit->GetPositionX(), unit->GetPositionY(),
|
||||
unit->GetPositionZ() + 0.5f, sPlayerbotAIConfig->followDistance);
|
||||
unit->GetPositionZ() + 0.5f, sPlayerbotAIConfig.followDistance);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -176,8 +176,8 @@ bool GoAction::Execute(Event event)
|
||||
float z = bot->GetPositionZ();
|
||||
bot->UpdateAllowedPositionZ(x, y, z);
|
||||
|
||||
if (sServerFacade->IsDistanceGreaterThan(sServerFacade->GetDistance2d(bot, x, y),
|
||||
sPlayerbotAIConfig->reactDistance))
|
||||
if (ServerFacade::instance().IsDistanceGreaterThan(ServerFacade::instance().GetDistance2d(bot, x, y),
|
||||
sPlayerbotAIConfig.reactDistance))
|
||||
{
|
||||
botAI->TellMaster("It is too far away");
|
||||
return false;
|
||||
@@ -203,14 +203,14 @@ bool GoAction::Execute(Event event)
|
||||
out << "Moving to " << x1 << "," << y1;
|
||||
botAI->TellMasterNoFacing(out.str());
|
||||
|
||||
return MoveNear(bot->GetMapId(), x, y, z + 0.5f, sPlayerbotAIConfig->followDistance);
|
||||
return MoveNear(bot->GetMapId(), x, y, z + 0.5f, sPlayerbotAIConfig.followDistance);
|
||||
}
|
||||
|
||||
PositionInfo pos = context->GetValue<PositionMap&>("position")->Get()[param];
|
||||
if (pos.isSet())
|
||||
{
|
||||
if (sServerFacade->IsDistanceGreaterThan(sServerFacade->GetDistance2d(bot, pos.x, pos.y),
|
||||
sPlayerbotAIConfig->reactDistance))
|
||||
if (ServerFacade::instance().IsDistanceGreaterThan(ServerFacade::instance().GetDistance2d(bot, pos.x, pos.y),
|
||||
sPlayerbotAIConfig.reactDistance))
|
||||
{
|
||||
botAI->TellError("It is too far away");
|
||||
return false;
|
||||
@@ -219,7 +219,7 @@ bool GoAction::Execute(Event event)
|
||||
std::ostringstream out;
|
||||
out << "Moving to position " << param;
|
||||
botAI->TellMasterNoFacing(out.str());
|
||||
return MoveNear(bot->GetMapId(), pos.x, pos.y, pos.z + 0.5f, sPlayerbotAIConfig->followDistance);
|
||||
return MoveNear(bot->GetMapId(), pos.x, pos.y, pos.z + 0.5f, sPlayerbotAIConfig.followDistance);
|
||||
}
|
||||
|
||||
botAI->TellMaster("Whisper 'go x,y', 'go [game object]', 'go unit' or 'go position' and I will go there");
|
||||
|
||||
Reference in New Issue
Block a user