Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix infinite loop in HeliAttack/HeliReturnToBase #14946

Merged
merged 1 commit into from Mar 22, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 11 additions & 2 deletions OpenRA.Mods.Common/Activities/Air/HeliReturnToBase.cs
Expand Up @@ -59,8 +59,17 @@ public override Activity Tick(Actor self)
{
var nearestHpad = ChooseHelipad(self, false);

if (nearestHpad == null)
return ActivityUtils.SequenceActivities(new Turn(self, initialFacing), new HeliLand(self, true), NextActivity);
// If a heli was told to return and there's no (available) RearmBuilding, going to the probable next queued activity (HeliAttack)
// 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
{
var distanceFromHelipad = (nearestHpad.CenterPosition - self.CenterPosition).HorizontalLength;
Expand Down