Fix aerospace returning after told not to, and MekHQ POW capture bug#7958
Open
Fix aerospace returning after told not to, and MekHQ POW capture bug#7958
Conversation
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>
Contributor
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
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)
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