From 4d46464bc602c6daaa706d690531e4a6cc9b6a09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Sat, 1 Aug 2020 18:27:57 +0200 Subject: [PATCH] Fix an invalid target crash target.CenterPosition is referenced in warhead orientation later --- OpenRA.Mods.Common/Projectiles/InstantHit.cs | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/OpenRA.Mods.Common/Projectiles/InstantHit.cs b/OpenRA.Mods.Common/Projectiles/InstantHit.cs index 59ff825f4c..a949766620 100644 --- a/OpenRA.Mods.Common/Projectiles/InstantHit.cs +++ b/OpenRA.Mods.Common/Projectiles/InstantHit.cs @@ -66,19 +66,14 @@ namespace OpenRA.Mods.Common.Projectiles public void Tick(World world) { - // Check for blocking actors - if (info.Blockable) - { - // If GuidedTarget has become invalid due to getting killed the same tick, - // we need to set target to args.PassiveTarget to prevent target.CenterPosition below from crashing. - // The warheads have target validity checks themselves so they don't need this, but AnyBlockingActorsBetween does. - if (target.Type == TargetType.Invalid) - target = Target.FromPos(args.PassiveTarget); + // If GuidedTarget has become invalid due to getting killed the same tick, + // we need to set target to args.PassiveTarget to prevent target.CenterPosition below from crashing. + if (target.Type == TargetType.Invalid) + target = Target.FromPos(args.PassiveTarget); - if (BlocksProjectiles.AnyBlockingActorsBetween(world, args.Source, target.CenterPosition, - info.Width, out var blockedPos)) - target = Target.FromPos(blockedPos); - } + // Check for blocking actors + if (info.Blockable && BlocksProjectiles.AnyBlockingActorsBetween(world, args.Source, target.CenterPosition, info.Width, out var blockedPos)) + target = Target.FromPos(blockedPos); var warheadArgs = new WarheadArgs(args) {