Fix Crashs Formation Arrow (#708)

* Fix crash in formations

* Crash fix: Arrow formation

* Crash fix: Arrow formation looking for member information in different maps/instances.

* Loop fix: arrow formation

* Crash fix: Arrow formation when group isn't all in 1 place.

* Fix Build
This commit is contained in:
EricksOliveira
2024-11-14 14:23:07 +00:00
committed by GitHub
parent ff5ad54f91
commit af0a6b73e1
2 changed files with 16 additions and 10 deletions

View File

@@ -22,10 +22,9 @@ WorldLocation ArrowFormation::GetLocationInternal()
float offset = 0.f;
Player* master = botAI->GetMaster();
if (!master)
{
if (!botAI->IsSafe(master))
return Formation::NullLocation;
}
float orientation = master->GetOrientation();
MultiLineUnitPlacer placer(orientation);
@@ -43,6 +42,9 @@ WorldLocation ArrowFormation::GetLocationInternal()
offset += rangedLines * sPlayerbotAIConfig->followDistance;
healers.PlaceUnits(&placer);
healers.Move(-cos(orientation) * offset, -sin(orientation) * offset);
if (!masterUnit || !botUnit)
return Formation::NullLocation;
float x = master->GetPositionX() - masterUnit->GetX() + botUnit->GetX();
float y = master->GetPositionY() - masterUnit->GetY() + botUnit->GetY();
@@ -89,14 +91,15 @@ void ArrowFormation::FillSlotsExceptMaster()
while (gref)
{
Player* member = gref->GetSource();
if (member == bot)
FindSlot(member)->AddLast(botUnit = new FormationUnit(index, false));
else if (member != botAI->GetMaster())
FindSlot(member)->AddLast(new FormationUnit(index, false));
if (botAI->IsSafe(member))
{
if (member == bot)
FindSlot(member)->AddLast(botUnit = new FormationUnit(index, false));
else if (member != botAI->GetMaster())
FindSlot(member)->AddLast(new FormationUnit(index, false));
++index;
}
gref = gref->next();
++index;
}
}