Skip to content

Fix aerospace returning after told not to, and MekHQ POW capture bug#7958

Open
HammerGS wants to merge 1 commit intomainfrom
fix/7906-aero-flyoff-return
Open

Fix aerospace returning after told not to, and MekHQ POW capture bug#7958
HammerGS wants to merge 1 commit intomainfrom
fix/7906-aero-flyoff-return

Conversation

@HammerGS
Copy link
Member

@HammerGS HammerGS commented Feb 5, 2026

Fixes #7906

Also fixes MegaMek/mekhq#8702

Root cause: In processLeaveMap(), when an aerospace unit flew off with returnable == -1 (no return), the code still took the early return path meant for returning units. This caused two bugs:

  1. Non-returning aero stayed in game.getEntitiesVector() with deployed=false and deployRound=0, making them eligible to redeploy (MegaMek [Issue] Aerospace returning to battlefield after being told to leave #7906)

  2. At game end, these units appeared in victoryEvent.getEntities() instead of getRetreatedEntities(), causing MekHQ to treat them as salvageable enemy units and capture their pilots as POWs (MekHQ #8702)

Fix: Only take the early return path for returning aero (returnable > -1). Non-returning aero now fall through to the normal flee logic which properly removes them from the game with REMOVE_IN_RETREAT status.

Tested and the fled units show up in MekHQ

Fixes #7906

Root cause: In processLeaveMap(), when an aerospace unit flew off with
returnable == -1 (no return), the code still took the early return path
meant for returning units. This caused two bugs:

1. Non-returning aero stayed in game.getEntitiesVector() with deployed=false
   and deployRound=0, making them eligible to redeploy (MegaMek #7906)

2. At game end, these units appeared in victoryEvent.getEntities() instead
   of getRetreatedEntities(), causing MekHQ to treat them as salvageable
   enemy units and capture their pilots as POWs (MekHQ #8702)

Fix: Only take the early return path for returning aero (returnable > -1).
Non-returning aero now fall through to the normal flee logic which properly
removes them from the game with REMOVE_IN_RETREAT status.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@HammerGS HammerGS requested a review from a team as a code owner February 5, 2026 04:21
Copilot AI review requested due to automatic review settings February 5, 2026 04:21
@HammerGS HammerGS added Aerospace Any issue concerning aerospace units AI Generated Fix AI-generated fix. Requires human testing and review before merging. labels Feb 5, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes two related bugs caused by aerospace units with returnable == -1 (no return) incorrectly taking the early return path in processLeaveMap(). The fix ensures non-returning aerospace units fall through to the normal flee logic and are properly removed from the game.

Changes:

  • Added condition && (returnable > -1) to gate the early return path for returning aerospace units only
  • Updated comments to clarify that non-returning aero should fall through to normal flee logic
  • Updated copyright year to 2026

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@HammerGS HammerGS added the AI ready for Review Indicates that is has been in game tested and is ready for review as it can be label Feb 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Aerospace Any issue concerning aerospace units AI Generated Fix AI-generated fix. Requires human testing and review before merging. AI ready for Review Indicates that is has been in game tested and is ready for review as it can be

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Issue] Captured hostiles do not correspond to destroyed units [Issue] Aerospace returning to battlefield after being told to leave

1 participant