Fix reservable crashing when unreserving and attack moving

This commit is contained in:
abcdefg30
2020-11-03 18:20:42 +01:00
committed by Matthias Mailänder
parent 2c62f747d9
commit e3929d7ded

View File

@@ -84,9 +84,11 @@ namespace OpenRA.Mods.Common.Traits
{
if (reservedForAircraft.GetActorBelow() == self)
{
// HACK: Cache this in a local var, such that the inner activity of AttackMoveActivity can access the trait easily after reservedForAircraft was nulled
var aircraft = reservedForAircraft;
if (rallyPoint != null && rallyPoint.Path.Count > 0)
foreach (var cell in rallyPoint.Path)
reservedFor.QueueActivity(new AttackMoveActivity(reservedFor, () => reservedForAircraft.MoveTo(cell, 1, targetLineColor: Color.OrangeRed)));
reservedFor.QueueActivity(new AttackMoveActivity(reservedFor, () => aircraft.MoveTo(cell, 1, targetLineColor: Color.OrangeRed)));
else
reservedFor.QueueActivity(new TakeOff(reservedFor));
}