Fix NRE in Guard when the target actor is dead.

This commit is contained in:
Paul Chote
2018-05-06 16:26:02 +01:00
committed by reaperrr
parent ff8f147955
commit b8fd4abc4a

View File

@@ -41,7 +41,7 @@ namespace OpenRA.Mods.Common.Traits
public void ResolveOrder(Actor self, Order order) public void ResolveOrder(Actor self, Order order)
{ {
if (order.OrderString == "Guard") if (order.OrderString == "Guard")
GuardTarget(self, Target.FromActor(order.TargetActor), order.Queued); GuardTarget(self, order.Target, order.Queued);
} }
public void GuardTarget(Actor self, Target target, bool queued = false) public void GuardTarget(Actor self, Target target, bool queued = false)
@@ -49,6 +49,9 @@ namespace OpenRA.Mods.Common.Traits
if (!queued) if (!queued)
self.CancelActivity(); self.CancelActivity();
if (target.Type != TargetType.Actor)
return;
self.SetTargetLine(target, Color.Yellow); self.SetTargetLine(target, Color.Yellow);
var range = target.Actor.Info.TraitInfo<GuardableInfo>().Range; var range = target.Actor.Info.TraitInfo<GuardableInfo>().Range;