Skip to content

Fix a crash caused by invalid target in FlyAttack#21479

Merged
Mailaender merged 1 commit intoOpenRA:bleedfrom
cameo-mod:flyattack
Jul 21, 2024
Merged

Fix a crash caused by invalid target in FlyAttack#21479
Mailaender merged 1 commit intoOpenRA:bleedfrom
cameo-mod:flyattack

Conversation

@tjk-ws
Copy link
Copy Markdown
Contributor

@tjk-ws tjk-ws commented Jul 6, 2024

By moving to checkTarget's position this makes FlyAttack's MoveWithinRange consistent with its counterpart in AttackFollow as has been the approach in #21455.

// Move into range of the target.
if (!target.IsInRange(pos, lastVisibleMaximumRange) || target.IsInRange(pos, minimumRange))
QueueChild(aircraft.MoveWithinRange(target, minimumRange, lastVisibleMaximumRange, target.CenterPosition, Color.Red));
QueueChild(aircraft.MoveWithinRange(target, minimumRange, lastVisibleMaximumRange, checkTarget.CenterPosition, Color.Red));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So should we be checking for checkTarget.IsInRange... in the condition above? It seems odd to check whether we're in range of one thing, and then move towards a different thing.

(If the condition should change, then there might be other changes since we're already doing some such checks earlier on, but to start with just understanding if the condition should be altered too would be good)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see you adjusted the code.

As written now, this seems odd as on line 144 above we have

if (checkTarget.IsInRange(pos, lastVisibleMaximumRange) && !checkTarget.IsInRange(pos, minimumRange) && useLastVisibleTarget)
    return true;

which is bailing out if it is specifically having to use the last target. If later on we're moving into range of checkTarget per this PR's suggestion, then that feels.... weird? Why can we bail early in the useLastVisibleTarget = true case, but need to keep going for the useLastVisibleTarget = false case?

It might be that this logic is all fine and I just need an explanation as to why this all makes sense in both the useLastVisibleTarget = true and useLastVisibleTarget = false scenarios - or maybe there is something off about this that I can't quite put into words. If you can do anything to clear up my confusion, that would be very helpful.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The duplicate range check and move order was always present (see FlyAttack before the last relevant commit) and I aimed to preserve the existing order of checks. The check for useLastVisibleTarget could be moved to the final if block, I could experiment to see if the now unskipped takeoff order causes any regressions

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

@tjk-ws tjk-ws force-pushed the flyattack branch 2 times, most recently from 8463236 to 5d09b2d Compare July 7, 2024 21:04
@PunkPun PunkPun added this to the Next Release milestone Jul 18, 2024
@dnqbob
Copy link
Copy Markdown
Contributor

dnqbob commented Jul 20, 2024

So could I ask how to reproduce this crash?

@tjk-ws
Copy link
Copy Markdown
Contributor Author

tjk-ws commented Jul 20, 2024

So could I ask how to reproduce this crash?

Any appreciable amount of air combat should trigger it (see #17688 (comment))

Copy link
Copy Markdown
Member

@RoosterDragon RoosterDragon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm struggling to come up with a reproduction case, but based on the stack trace from OpenHV/OpenHV#1060 I'm happy this would resolve the issue by using checkTarget which has a fallback if the target has become invalid, as opposed to moving towards the invalidated target.

@Mailaender Mailaender merged commit bdc142a into OpenRA:bleed Jul 21, 2024
@Mailaender
Copy link
Copy Markdown
Member

Changelog

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants