Fix infinite loop in HeliReturnToBase

This can happen if HeliAttack tells the heli to return to base when the player doesn't have any of the RearmBuildings available, because the activity queues itself after the HRTB, and the latter will, after a forced land, then queue back HeliAttack, which then immediately queues back HRTB and so on.

Instead, we now assume that if there is no base to return to, going to NextActivity is pointless and don't queue NextActivity.
RTB was likely ordered by HeliAttack due to lack of ammo, so resuming the attack would be pointless.
This commit is contained in:
reaperrr
2018-03-19 01:52:08 +01:00
committed by abcdefg30
parent d79d4479c7
commit 3069bbfa7d

View File

@@ -59,8 +59,17 @@ namespace OpenRA.Mods.Common.Activities
{ {
var nearestHpad = ChooseHelipad(self, false); var nearestHpad = ChooseHelipad(self, false);
if (nearestHpad == null) // If a heli was told to return and there's no (available) RearmBuilding, going to the probable next queued activity (HeliAttack)
return ActivityUtils.SequenceActivities(new Turn(self, initialFacing), new HeliLand(self, true), NextActivity); // would be pointless (due to lack of ammo), and possibly even lead to an infinite loop due to HeliAttack.cs:L79.
if (nearestHpad == null && heli.Info.LandWhenIdle)
{
if (heli.Info.TurnToLand)
return ActivityUtils.SequenceActivities(new Turn(self, initialFacing), new HeliLand(self, true));
return new HeliLand(self, true);
}
else if (nearestHpad == null && !heli.Info.LandWhenIdle)
return null;
else else
{ {
var distanceFromHelipad = (nearestHpad.CenterPosition - self.CenterPosition).HorizontalLength; var distanceFromHelipad = (nearestHpad.CenterPosition - self.CenterPosition).HorizontalLength;