Skip to content

Fix wrong launch location after switching editors#2645

Merged
siimav merged 6 commits intoKSP-RO:masterfrom
Clayell:switch-editors
Sep 30, 2025
Merged

Fix wrong launch location after switching editors#2645
siimav merged 6 commits intoKSP-RO:masterfrom
Clayell:switch-editors

Conversation

@Clayell
Copy link
Contributor

@Clayell Clayell commented Sep 28, 2025

Fix #2572

This was surprisingly complex to deal with. There seems to be some sort of stock bug where if a vessel is loaded automatically in one editor after entering it (which can be done by loading a vehicle, exiting the editor, then re-entering that editor), then the user switches to the other editor, EditorLogic.fetch.launchSiteName (which actually originates from EditorDriver.selectedlaunchSiteName) will not update. (although I did a small test in stock and wasn't able to reproduce the bug, so I won't be reporting this to KSPCF)

We can check it against EditorDriver.ValidLaunchSite() to make sure this doesn't occur. If this occurs in the SPH, we don't actually know what launch site to switch it to, but luckily there isn't any way to set a different default launch site for either editor in stock*, so we can just set it to the default which is Runway. This will need to be updated if we add a way to set a different launch site for the SPH outside of the editor (in a similar way we do for LCs)

*There's some strange methods regarding this in the stock code. EditorDriver.setLaunchSite(launchSite) sets EditorLogic.fetch.launchSiteName and EditorDriver.selectedlaunchSiteName to launchSite, EditorDriver.saveselectedLaunchSite() sets HighLogic.CurrentGame.defaultVABLaunchSite (or SPH) to EditorDriver.selectedlaunchSiteName, and setDefaultLaunchSite() sets EditorLogic.fetch.launchSiteName and EditorDriver.selectedlaunchSiteName to "LaunchPad" (or "Runway"). How strange.

@Clayell
Copy link
Contributor Author

Clayell commented Sep 28, 2025

Examples of stock(?) bug:

Switching from SPH to VAB: (notice how EditorLogic.fetch.launchSiteName is set to Runway)
image

Switching from VAB to SPH: (notice how EditorLogic.fetch.launchSiteName is set to LaunchPad)
image

To note, this only occurs when the vessel is loaded in that editor automatically. If one enters an editor without a vessel loaded, then the bug won't appear. Although strangely, if a vessel is loaded in that vessel automatically, then one switches to a different vessel while staying in that same editor, the bug will still appear.

@sonarqubecloud
Copy link

@siimav siimav merged commit 5dc80e9 into KSP-RO:master Sep 30, 2025
4 checks passed
@Clayell Clayell deleted the switch-editors branch September 30, 2025 21:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Creating a simulation ignores if the editor was switched via the "Switch editor" button

2 participants