bugfix(gui): Fix preferred starting cash not showing in combo box#2585
bugfix(gui): Fix preferred starting cash not showing in combo box#2585afc-afc0 wants to merge 1 commit intoTheSuperHackers:mainfrom
Conversation
* Fixes #2583 Re-populate the starting cash combo box after applying user preferences from INI files in Skirmish, LAN and WOL game setup menus. Previously, the combo box was populated before preferences were applied, so non-standard starting cash values would not appear in the dropdown. Also fix undefined behavior in PopulateStartingCashComboBox where a past-the-end iterator was dereferenced when the starting cash value was not found in the standard list.
|
| Filename | Overview |
|---|---|
| GeneralsMD/Code/GameNetwork/GUIUtil.cpp | Fixes UB in PopulateStartingCashComboBox: replaces past-the-end iterator dereference (it->countMoney()) with myGame->getStartingCash().countMoney(), which is semantically identical and safe. |
| GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/SkirmishGameOptionsMenu.cpp | Adds second PopulateStartingCashComboBox call after setStartingCash from prefs, ensuring the custom cash value is reflected in the UI. |
| GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/LanGameOptionsMenu.cpp | Adds second PopulateStartingCashComboBox call after setStartingCash from prefs, mirroring the Skirmish fix. |
| GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLGameSetupMenu.cpp | Adds second PopulateStartingCashComboBox call after setStartingCash (accounting for the isUsingStats conditional), completing the fix across all three multiplayer menus. |
Sequence Diagram
sequenceDiagram
participant Init as *MenuInit()
participant Combo as ComboBox (UI)
participant Prefs as UserPreferences
participant Util as PopulateStartingCashComboBox
Init->>Combo: Attach comboBoxStartingCash
Init->>Util: PopulateStartingCashComboBox(combo, game) [default cash, before prefs]
Init->>Prefs: pref.getStartingCash()
Init->>Init: game->setStartingCash(prefCash)
Note over Init,Util: FIX: re-populate after applying prefs
Init->>Util: PopulateStartingCashComboBox(combo, game) [preferred cash, correct selection]
Util->>Combo: GadgetComboBoxReset
Util->>Combo: Add standard entries
alt cash not in standard list (UB fix)
Util->>Combo: Add custom entry using myGame->getStartingCash().countMoney()
end
Util->>Combo: GadgetComboBoxSetSelectedPos
Reviews (1): Last reviewed commit: "bugfix(gui): Fix preferred starting cash..." | Re-trigger Greptile
Re-populate the starting cash combo box after applying user preferences from INI files in Skirmish, LAN and WOL game setup menus. Previously, the combo box was populated before preferences were applied, so non-standard starting cash values would not appear in the dropdown.
Also fix undefined behavior in PopulateStartingCashComboBox where a past-the-end iterator was dereferenced when the starting cash value was not found in the standard list.