Repository navigation
Fix nav deselection with unselect-nav - #8080
Open
AdmiralTolwyn wants to merge 1 commit into
Open
AdmiralTolwyn wants to merge 1 commit into
AdmiralTolwyn wants to merge 1 commit into
Conversation
The slot-0 assignment dates to the 2012 addition of the SEXP. Make unselect-nav leave no nav selected. End engaged autopilot, including cinematic autopilot, before clearing the selection because autopilot shutdown indexes the selected nav.
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.
unselect-navis documented as "Deselects any navpoint selected.", but since it was added in 2012DeselectNav()has setCurrentNavto 0 instead of -1, the no-selection value everything else checks. So the SEXP selects the first nav point: the HUD nav marker jumps to it and autopilot targets it.This sets -1. Clearing the selection while autopilot is engaged would leave the autopilot code indexing
Navs[-1], so if autopilot is engaged it is ended first, throughEndAutoPilot(), while the selected nav is still valid. The SEXP help now says so.What mission designers could notice:
unselect-navno nav is selected: the HUD nav marker disappears, and the autopilot key reports that no nav is selected until the mission callsselect-navor the player cycles to a nav.unselect-navnow ends it, including cinematic autopilot and whenautopilot.tblsets+No_Autopilot_Interrupt. Before, autopilot kept flying with the selection pointing at the first nav.Not changed here: when the nav of a destroyed ship is removed while autopilot is engaged (
autopilot.cpp:1106-1108), the selection is also cleared without ending autopilot. That is a separate, pre-existing path.Testing
New tests in
test/src/autopilot/test_nav_deselect.cpp: deselecting clears each selection,CanAutopilot()stays false with nothing selected, and deselecting while engaged ends autopilot and returns control to the player. Against master'sDeselectNav()all three fail.macOS arm64, Release: 375 passed, 1 skipped (
OptionsManagerOverride.ShadowRenderMethodDefaultFollowsTheGlobal, unrelated).Retail FS2 data, a test mission with two nav points that selects the second and runs
unselect-nav, once with autopilot off and once engaged; the engine state was read back after each call:unselect-navBoth games kept running and exited cleanly.