From 55ba164deea6ce34a19893b96b7d29a98e69cd90 Mon Sep 17 00:00:00 2001 From: Duncan Date: Sun, 16 Aug 2020 18:48:21 +0100 Subject: [PATCH] Fix crash when switching ride types with construct window open (#12694) --- distribution/changelog.txt | 1 + src/openrct2-ui/windows/Ride.cpp | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/distribution/changelog.txt b/distribution/changelog.txt index 9d2fb8ec19..8c6357c9c5 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -1,6 +1,7 @@ 0.3.0+ (in development) ------------------------------------------------------------------------ - Fix: [#12691] Ride graph tooltip incorrectly used count instead of number string. +- Fix: [#12694] Crash when switching ride types with construction window open. 0.3.0 (2020-08-15) ------------------------------------------------------------------------ diff --git a/src/openrct2-ui/windows/Ride.cpp b/src/openrct2-ui/windows/Ride.cpp index 267998f374..6bc0e3dd57 100644 --- a/src/openrct2-ui/windows/Ride.cpp +++ b/src/openrct2-ui/windows/Ride.cpp @@ -2428,7 +2428,15 @@ static void window_ride_main_dropdown(rct_window* w, rct_widgetindex widgetIndex uint8_t rideType = RideDropdownData[rideLabelId].ride_type_id; if (rideType < RIDE_TYPE_COUNT) { - set_operating_setting(w->number, RideSetSetting::RideType, rideType); + auto rideSetSetting = RideSetSettingAction(w->number, RideSetSetting::RideType, rideType); + rideSetSetting.SetCallback([](const GameAction* ga, const GameActionResult* result) { + // Reset ghost track if ride construction window is open, prevents a crash + // Will get set to the correct Alternative variable during set_default_next_piece. + // TODO: Rework construction window to prevent the need for this. + _currentTrackAlternative = RIDE_TYPE_NO_ALTERNATIVES; + ride_construction_set_default_next_piece(); + }); + GameActions::Execute(&rideSetSetting); } } }