diff --git a/OpenRA.Game/Actor.cs b/OpenRA.Game/Actor.cs index 08fbaf0a17..00105153eb 100755 --- a/OpenRA.Game/Actor.cs +++ b/OpenRA.Game/Actor.cs @@ -72,6 +72,7 @@ namespace OpenRA Activity currentActivity; public Group Group; + public int Generation; internal Actor(World world, string name, TypeDictionary initDict ) { diff --git a/OpenRA.Game/Traits/Target.cs b/OpenRA.Game/Traits/Target.cs index 068e859e3c..4af8de64bb 100644 --- a/OpenRA.Game/Traits/Target.cs +++ b/OpenRA.Game/Traits/Target.cs @@ -18,6 +18,7 @@ namespace OpenRA.Traits Player owner; PPos pos; bool valid; + int generation; public static Target FromActor(Actor a) { @@ -25,7 +26,8 @@ namespace OpenRA.Traits { actor = a, valid = (a != null), - owner = (a != null) ? a.Owner : null + owner = (a != null) ? a.Owner : null, + generation = a.Generation, }; } public static Target FromPos(PPos p) { return new Target { pos = p, valid = true }; } @@ -39,7 +41,7 @@ namespace OpenRA.Traits public static readonly Target None = new Target(); - public bool IsValid { get { return valid && (actor == null || (actor.IsInWorld && !actor.IsDead() && actor.Owner == owner)); } } + public bool IsValid { get { return valid && (actor == null || (actor.IsInWorld && !actor.IsDead() && actor.Owner == owner && actor.Generation == generation)); } } public PPos PxPosition { get { return IsActor ? actor.Trait().PxPosition : pos; } } public PPos CenterLocation { get { return PxPosition; } }