diff --git a/OpenRA.Game/Actor.cs b/OpenRA.Game/Actor.cs index 08fbaf0a17..47bfa08aca 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 ) { @@ -272,6 +273,7 @@ namespace OpenRA // momentarily remove from world so the ownership queries don't get confused w.Remove(this); Owner = newOwner; + Generation++; w.Add(this); foreach (var t in this.TraitsImplementing()) diff --git a/OpenRA.Game/Traits/Target.cs b/OpenRA.Game/Traits/Target.cs index 068e859e3c..33456afd5c 100644 --- a/OpenRA.Game/Traits/Target.cs +++ b/OpenRA.Game/Traits/Target.cs @@ -15,9 +15,9 @@ namespace OpenRA.Traits public static Target[] NoTargets = {}; Actor actor; - Player owner; PPos pos; bool valid; + int generation; public static Target FromActor(Actor a) { @@ -25,7 +25,7 @@ namespace OpenRA.Traits { actor = a, valid = (a != 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 +39,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.Generation == generation)); } } public PPos PxPosition { get { return IsActor ? actor.Trait().PxPosition : pos; } } public PPos CenterLocation { get { return PxPosition; } } diff --git a/OpenRA.Mods.RA/Activities/Teleport.cs b/OpenRA.Mods.RA/Activities/Teleport.cs index ede8cbed78..f9809d9f83 100755 --- a/OpenRA.Mods.RA/Activities/Teleport.cs +++ b/OpenRA.Mods.RA/Activities/Teleport.cs @@ -33,6 +33,7 @@ namespace OpenRA.Mods.RA.Activities Sound.Play("chrono2.aud", destination.ToPPos()); self.Trait().SetPosition(self, destination); + self.Generation++; if (killCargo && self.HasTrait()) { @@ -66,6 +67,7 @@ namespace OpenRA.Mods.RA.Activities public override Activity Tick(Actor self) { self.Trait().SetPosition(self, destination); + self.Generation++; return NextActivity; } }