Fix an invalid target crash

target.CenterPosition is referenced in warhead orientation later
This commit is contained in:
Matthias Mailänder
2020-08-01 18:27:57 +02:00
committed by Paul Chote
parent 7746dc55f0
commit 4d46464bc6

View File

@@ -66,19 +66,14 @@ namespace OpenRA.Mods.Common.Projectiles
public void Tick(World world) public void Tick(World world)
{ {
// Check for blocking actors // If GuidedTarget has become invalid due to getting killed the same tick,
if (info.Blockable) // we need to set target to args.PassiveTarget to prevent target.CenterPosition below from crashing.
{ if (target.Type == TargetType.Invalid)
// If GuidedTarget has become invalid due to getting killed the same tick, target = Target.FromPos(args.PassiveTarget);
// 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 (BlocksProjectiles.AnyBlockingActorsBetween(world, args.Source, target.CenterPosition, // Check for blocking actors
info.Width, out var blockedPos)) if (info.Blockable && BlocksProjectiles.AnyBlockingActorsBetween(world, args.Source, target.CenterPosition, info.Width, out var blockedPos))
target = Target.FromPos(blockedPos); target = Target.FromPos(blockedPos);
}
var warheadArgs = new WarheadArgs(args) var warheadArgs = new WarheadArgs(args)
{ {