Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix InstantHit crashing if blockable and target is dead #16756

Merged
merged 1 commit into from Jul 12, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 10 additions & 3 deletions OpenRA.Mods.Common/Projectiles/InstantHit.cs
Expand Up @@ -65,10 +65,17 @@ public void Tick(World world)
{
// Check for blocking actors
WPos blockedPos;
if (info.Blockable && BlocksProjectiles.AnyBlockingActorsBetween(world, args.Source, target.CenterPosition,
info.Width, out blockedPos))
if (info.Blockable)
{
target = Target.FromPos(blockedPos);
// 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 (BlocksProjectiles.AnyBlockingActorsBetween(world, args.Source, target.CenterPosition,
info.Width, out blockedPos))
target = Target.FromPos(blockedPos);
}

args.Weapon.Impact(target, args.SourceActor, args.DamageModifiers);
Expand Down