diff --git a/OpenRA.Mods.RA/Chronoshiftable.cs b/OpenRA.Mods.RA/Chronoshiftable.cs index 7883d98f8c..b90378775a 100755 --- a/OpenRA.Mods.RA/Chronoshiftable.cs +++ b/OpenRA.Mods.RA/Chronoshiftable.cs @@ -40,14 +40,14 @@ namespace OpenRA.Mods.RA } } - // Can't be used in synced code - public virtual bool CanChronoshiftTo(Actor self, int2 targetLocation) - { - // Todo: Allow enemy units to be chronoshifted into bad terrain to kill them - return self.HasTrait() && - self.Trait().CanEnterCell(targetLocation) && - (self.World.LocalShroud.IsExplored(targetLocation)); - } + // Can't be used in synced code, except with ignoreVis. + public virtual bool CanChronoshiftTo(Actor self, int2 targetLocation, bool ignoreVis) + { + // Todo: Allow enemy units to be chronoshifted into bad terrain to kill them + return self.HasTrait() && + self.Trait().CanEnterCell(targetLocation) && + (ignoreVis || self.World.LocalShroud.IsExplored(targetLocation)); + } public virtual bool Teleport(Actor self, int2 targetLocation, int duration, bool killCargo, Actor chronosphere) { diff --git a/OpenRA.Mods.RA/Scripting/RASpecialPowers.cs b/OpenRA.Mods.RA/Scripting/RASpecialPowers.cs index 4c46d5f92e..038fa10885 100644 --- a/OpenRA.Mods.RA/Scripting/RASpecialPowers.cs +++ b/OpenRA.Mods.RA/Scripting/RASpecialPowers.cs @@ -34,7 +34,7 @@ namespace OpenRA.Scripting var target = kv.First; var targetCell = kv.Second; var cs = target.Trait(); - if (cs.CanChronoshiftTo(target, targetCell)) + if (cs.CanChronoshiftTo(target, targetCell, true)) target.Trait().Teleport(target, targetCell, duration, diff --git a/OpenRA.Mods.RA/SupportPowers/ChronoshiftPower.cs b/OpenRA.Mods.RA/SupportPowers/ChronoshiftPower.cs index bb17efa383..c841c42802 100755 --- a/OpenRA.Mods.RA/SupportPowers/ChronoshiftPower.cs +++ b/OpenRA.Mods.RA/SupportPowers/ChronoshiftPower.cs @@ -51,13 +51,11 @@ namespace OpenRA.Mods.RA { var cs = target.Trait(); var targetCell = target.Location + order.TargetLocation - order.ExtraLocation; - // TODO: CanChronoshiftTo() can't be used in synced code, but not checking this here - // leaves it open to exploitation. - // if (cs.CanChronoshiftTo(target, targetCell)) ... - var cpi = Info as ChronoshiftPowerInfo; - cs.Teleport(target, targetCell, - cpi.Duration * 25, cpi.KillCargo, self); + + if (cs.CanChronoshiftTo(target, targetCell, true)) + cs.Teleport(target, targetCell, + cpi.Duration * 25, cpi.KillCargo, self); } } @@ -217,7 +215,7 @@ namespace OpenRA.Mods.RA foreach (var unit in power.UnitsInRange(sourceLocation)) { var targetCell = unit.Location + xy - sourceLocation; - var canEnter = unit.Trait().CanChronoshiftTo(unit,targetCell); + var canEnter = unit.Trait().CanChronoshiftTo(unit,targetCell, false); var tile = canEnter ? validTile : invalidTile; tile.DrawAt( wr, Game.CellSize * targetCell, "terrain" ); } @@ -229,7 +227,7 @@ namespace OpenRA.Mods.RA foreach (var unit in power.UnitsInRange(sourceLocation)) { var targetCell = unit.Location + xy - sourceLocation; - if (unit.Trait().CanChronoshiftTo(unit,targetCell)) + if (unit.Trait().CanChronoshiftTo(unit,targetCell, false)) { canTeleport = true; break;