Fix crash caused by queuing multiple pick up orders for a single unit.
This commit is contained in:
@@ -33,6 +33,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
|
|
||||||
enum PickupState { Intercept, LockCarryable, Pickup }
|
enum PickupState { Intercept, LockCarryable, Pickup }
|
||||||
PickupState state = PickupState.Intercept;
|
PickupState state = PickupState.Intercept;
|
||||||
|
bool reserveFailed;
|
||||||
|
|
||||||
public PickupUnit(Actor self, Actor cargo, int delay, Color? targetLineColor)
|
public PickupUnit(Actor self, Actor cargo, int delay, Color? targetLineColor)
|
||||||
{
|
{
|
||||||
@@ -52,7 +53,10 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
{
|
{
|
||||||
// The cargo might have become invalid while we were moving towards it.
|
// The cargo might have become invalid while we were moving towards it.
|
||||||
if (cargo.IsDead || carryable.IsTraitDisabled || carryall.IsTraitDisabled || !cargo.AppearsFriendlyTo(self))
|
if (cargo.IsDead || carryable.IsTraitDisabled || carryall.IsTraitDisabled || !cargo.AppearsFriendlyTo(self))
|
||||||
|
{
|
||||||
|
reserveFailed = true;
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (carryall.ReserveCarryable(self, cargo))
|
if (carryall.ReserveCarryable(self, cargo))
|
||||||
{
|
{
|
||||||
@@ -61,11 +65,13 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
QueueChild(new Fly(self, Target.FromActor(cargo)));
|
QueueChild(new Fly(self, Target.FromActor(cargo)));
|
||||||
QueueChild(new FlyIdle(self, idleTurn: false));
|
QueueChild(new FlyIdle(self, idleTurn: false));
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
reserveFailed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Tick(Actor self)
|
public override bool Tick(Actor self)
|
||||||
{
|
{
|
||||||
if (IsCanceling)
|
if (IsCanceling || reserveFailed)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (cargo.IsDead || carryable.IsTraitDisabled || carryall.IsTraitDisabled || !cargo.AppearsFriendlyTo(self) || cargo != carryall.Carryable)
|
if (cargo.IsDead || carryable.IsTraitDisabled || carryall.IsTraitDisabled || !cargo.AppearsFriendlyTo(self) || cargo != carryall.Carryable)
|
||||||
|
|||||||
Reference in New Issue
Block a user