From 20dbf76e8184ead524884ab6ca814b6d9111aa24 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sun, 12 Aug 2018 22:06:22 +0100 Subject: [PATCH] Fix the Chronoshift-return cancellation bug. --- OpenRA.Mods.Cnc/Traits/Chronoshiftable.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/OpenRA.Mods.Cnc/Traits/Chronoshiftable.cs b/OpenRA.Mods.Cnc/Traits/Chronoshiftable.cs index 1e7e306f34..2ba4f2ae53 100644 --- a/OpenRA.Mods.Cnc/Traits/Chronoshiftable.cs +++ b/OpenRA.Mods.Cnc/Traits/Chronoshiftable.cs @@ -81,6 +81,18 @@ namespace OpenRA.Mods.Cnc.Traits { self.CancelActivity(); + // The Move activity is not immediately cancelled, which, combined + // with Activity.Cancel discarding NextActivity without checking the + // IsInterruptable flag, means that a well timed order can cancel the + // Teleport activity queued below - an exploit / cheat of the return mechanic. + // The Teleport activity queued below is guaranteed to either complete + // (force-resetting the actor to the middle of the target cell) or kill + // the actor. It is therefore safe to force-erase the Move activity to + // work around the cancellation bug. + // HACK: this is manipulating private internal actor state + if (self.CurrentActivity is Move) + typeof(Actor).GetProperty("CurrentActivity").SetValue(self, null); + // The actor is killed using Info.DamageTypes if the teleport fails self.QueueActivity(new Teleport(chronosphere, Origin, null, true, killCargo, Info.ChronoshiftSound, false, true, Info.DamageTypes));