From d3a20df68260e75c3b711c20a6ccb6819282927a Mon Sep 17 00:00:00 2001 From: Matt Date: Sat, 15 Dec 2018 11:28:33 +0100 Subject: [PATCH] Fix track designs ignoring ghost/preview flags. --- src/openrct2-ui/windows/Ride.cpp | 2 +- src/openrct2-ui/windows/TrackDesignPlace.cpp | 3 +- src/openrct2/Game.cpp | 3 +- src/openrct2/actions/GameActionCompat.cpp | 3 +- src/openrct2/ride/Ride.h | 2 +- src/openrct2/ride/TrackDesign.cpp | 40 +++++++------------- 6 files changed, 21 insertions(+), 32 deletions(-) diff --git a/src/openrct2-ui/windows/Ride.cpp b/src/openrct2-ui/windows/Ride.cpp index 077cad7f94..05c611164f 100644 --- a/src/openrct2-ui/windows/Ride.cpp +++ b/src/openrct2-ui/windows/Ride.cpp @@ -2478,7 +2478,7 @@ static void window_ride_main_textinput(rct_window* w, rct_widgetindex widgetInde if (widgetIndex != WIDX_RENAME || text == nullptr) return; - ride_set_name(w->number, text); + ride_set_name(w->number, text, 0); } /** diff --git a/src/openrct2-ui/windows/TrackDesignPlace.cpp b/src/openrct2-ui/windows/TrackDesignPlace.cpp index 60739391c0..b93dd21b17 100644 --- a/src/openrct2-ui/windows/TrackDesignPlace.cpp +++ b/src/openrct2-ui/windows/TrackDesignPlace.cpp @@ -283,7 +283,8 @@ static void window_track_place_toolupdate(rct_window* w, rct_widgetindex widgetI for (int32_t i = 0; i < 7; i++) { uint8_t rideIndex; - window_track_place_attempt_placement(_trackDesign, mapX, mapY, mapZ, 105, &cost, &rideIndex); + uint16_t flags = GAME_COMMAND_FLAG_APPLY | GAME_COMMAND_FLAG_5 | GAME_COMMAND_FLAG_GHOST; + window_track_place_attempt_placement(_trackDesign, mapX, mapY, mapZ, flags, &cost, &rideIndex); if (cost != MONEY32_UNDEFINED) { _window_track_place_ride_index = rideIndex; diff --git a/src/openrct2/Game.cpp b/src/openrct2/Game.cpp index bd62d2bcea..8fdc1aff8e 100644 --- a/src/openrct2/Game.cpp +++ b/src/openrct2/Game.cpp @@ -566,7 +566,8 @@ int32_t game_do_command_p( // Show error window if (gGameCommandNestLevel == 0 && (flags & GAME_COMMAND_FLAG_APPLY) && gUnk141F568 == gUnk13CA740 - && !(flags & GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED) && !(flags & GAME_COMMAND_FLAG_NETWORKED)) + && !(flags & GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED) && !(flags & GAME_COMMAND_FLAG_NETWORKED) + && !(flags & GAME_COMMAND_FLAG_GHOST)) { context_show_error(gGameCommandErrorTitle, gGameCommandErrorText); } diff --git a/src/openrct2/actions/GameActionCompat.cpp b/src/openrct2/actions/GameActionCompat.cpp index 5e40fc3caa..b2f3b58068 100644 --- a/src/openrct2/actions/GameActionCompat.cpp +++ b/src/openrct2/actions/GameActionCompat.cpp @@ -169,9 +169,10 @@ void game_command_set_ride_status( #pragma endregion #pragma region RideSetNameAction -void ride_set_name(int32_t rideIndex, const char* name) +void ride_set_name(int32_t rideIndex, const char* name, uint32_t flags) { auto gameAction = RideSetNameAction(rideIndex, name); + gameAction.SetFlags(flags); GameActions::Execute(&gameAction); } diff --git a/src/openrct2/ride/Ride.h b/src/openrct2/ride/Ride.h index 3777ad446f..1b65570f46 100644 --- a/src/openrct2/ride/Ride.h +++ b/src/openrct2/ride/Ride.h @@ -1051,7 +1051,7 @@ TileElement* ride_get_station_exit_element(int32_t x, int32_t y, int32_t z); void ride_set_status(int32_t rideIndex, int32_t status); void game_command_set_ride_status( int32_t* eax, int32_t* ebx, int32_t* ecx, int32_t* edx, int32_t* esi, int32_t* edi, int32_t* ebp); -void ride_set_name(int32_t rideIndex, const char* name); +void ride_set_name(int32_t rideIndex, const char* name, uint32_t flags); void game_command_set_ride_name( int32_t* eax, int32_t* ebx, int32_t* ecx, int32_t* edx, int32_t* esi, int32_t* edi, int32_t* ebp); void game_command_set_ride_setting( diff --git a/src/openrct2/ride/TrackDesign.cpp b/src/openrct2/ride/TrackDesign.cpp index 8697878b17..0d0e4bd1d3 100644 --- a/src/openrct2/ride/TrackDesign.cpp +++ b/src/openrct2/ride/TrackDesign.cpp @@ -1881,8 +1881,7 @@ static money32 place_track_design(int16_t x, int16_t y, int16_t z, uint8_t flags uint8_t rideIndex; uint8_t rideColour; - money32 createRideResult = ride_create_command( - td6->type, entryIndex, GAME_COMMAND_FLAG_APPLY | flags, &rideIndex, &rideColour); + money32 createRideResult = ride_create_command(td6->type, entryIndex, flags, &rideIndex, &rideColour); if (createRideResult == MONEY32_UNDEFINED) { gGameCommandErrorTitle = STR_CANT_CREATE_NEW_RIDE_ATTRACTION; @@ -1926,7 +1925,7 @@ static money32 place_track_design(int16_t x, int16_t y, int16_t z, uint8_t flags if (cost == MONEY32_UNDEFINED || !(flags & GAME_COMMAND_FLAG_APPLY)) { rct_string_id error_reason = gGameCommandErrorText; - ride_action_modify(rideIndex, RIDE_MODIFY_DEMOLISH, GAME_COMMAND_FLAG_APPLY | flags); + ride_action_modify(rideIndex, RIDE_MODIFY_DEMOLISH, flags); gGameCommandErrorText = error_reason; gCommandExpenditureType = RCT_EXPENDITURE_TYPE_RIDE_CONSTRUCTION; *outRideIndex = rideIndex; @@ -1935,40 +1934,27 @@ static money32 place_track_design(int16_t x, int16_t y, int16_t z, uint8_t flags if (entryIndex != 0xFF) { - game_do_command( - 0, GAME_COMMAND_FLAG_APPLY | (2 << 8), 0, rideIndex | (entryIndex << 8), GAME_COMMAND_SET_RIDE_VEHICLES, 0, 0); + game_do_command(0, flags | (2 << 8), 0, rideIndex | (entryIndex << 8), GAME_COMMAND_SET_RIDE_VEHICLES, 0, 0); } + game_do_command(0, flags | (td6->ride_mode << 8), 0, rideIndex | (0 << 8), GAME_COMMAND_SET_RIDE_SETTING, 0, 0); + game_do_command(0, flags | (0 << 8), 0, rideIndex | (td6->number_of_trains << 8), GAME_COMMAND_SET_RIDE_VEHICLES, 0, 0); game_do_command( - 0, GAME_COMMAND_FLAG_APPLY | (td6->ride_mode << 8), 0, rideIndex | (0 << 8), GAME_COMMAND_SET_RIDE_SETTING, 0, 0); + 0, flags | (1 << 8), 0, rideIndex | (td6->number_of_cars_per_train << 8), GAME_COMMAND_SET_RIDE_VEHICLES, 0, 0); + game_do_command(0, flags | (td6->depart_flags << 8), 0, rideIndex | (1 << 8), GAME_COMMAND_SET_RIDE_SETTING, 0, 0); + game_do_command(0, flags | (td6->min_waiting_time << 8), 0, rideIndex | (2 << 8), GAME_COMMAND_SET_RIDE_SETTING, 0, 0); + game_do_command(0, flags | (td6->max_waiting_time << 8), 0, rideIndex | (3 << 8), GAME_COMMAND_SET_RIDE_SETTING, 0, 0); + game_do_command(0, flags | (td6->operation_setting << 8), 0, rideIndex | (4 << 8), GAME_COMMAND_SET_RIDE_SETTING, 0, 0); game_do_command( - 0, GAME_COMMAND_FLAG_APPLY | (0 << 8), 0, rideIndex | (td6->number_of_trains << 8), GAME_COMMAND_SET_RIDE_VEHICLES, 0, + 0, flags | ((td6->lift_hill_speed_num_circuits & 0x1F) << 8), 0, rideIndex | (8 << 8), GAME_COMMAND_SET_RIDE_SETTING, 0, 0); - game_do_command( - 0, GAME_COMMAND_FLAG_APPLY | (1 << 8), 0, rideIndex | (td6->number_of_cars_per_train << 8), - GAME_COMMAND_SET_RIDE_VEHICLES, 0, 0); - game_do_command( - 0, GAME_COMMAND_FLAG_APPLY | (td6->depart_flags << 8), 0, rideIndex | (1 << 8), GAME_COMMAND_SET_RIDE_SETTING, 0, 0); - game_do_command( - 0, GAME_COMMAND_FLAG_APPLY | (td6->min_waiting_time << 8), 0, rideIndex | (2 << 8), GAME_COMMAND_SET_RIDE_SETTING, 0, - 0); - game_do_command( - 0, GAME_COMMAND_FLAG_APPLY | (td6->max_waiting_time << 8), 0, rideIndex | (3 << 8), GAME_COMMAND_SET_RIDE_SETTING, 0, - 0); - game_do_command( - 0, GAME_COMMAND_FLAG_APPLY | (td6->operation_setting << 8), 0, rideIndex | (4 << 8), GAME_COMMAND_SET_RIDE_SETTING, 0, - 0); - game_do_command( - 0, GAME_COMMAND_FLAG_APPLY | ((td6->lift_hill_speed_num_circuits & 0x1F) << 8), 0, rideIndex | (8 << 8), - GAME_COMMAND_SET_RIDE_SETTING, 0, 0); uint8_t num_circuits = td6->lift_hill_speed_num_circuits >> 5; if (num_circuits == 0) { num_circuits = 1; } - game_do_command( - 0, GAME_COMMAND_FLAG_APPLY | (num_circuits << 8), 0, rideIndex | (9 << 8), GAME_COMMAND_SET_RIDE_SETTING, 0, 0); + game_do_command(0, flags | (num_circuits << 8), 0, rideIndex | (9 << 8), GAME_COMMAND_SET_RIDE_SETTING, 0, 0); ride_set_to_default_inspection_interval(rideIndex); ride->lifecycle_flags |= RIDE_LIFECYCLE_NOT_CUSTOM_DESIGN; @@ -1990,7 +1976,7 @@ static money32 place_track_design(int16_t x, int16_t y, int16_t z, uint8_t flags ride->vehicle_colours_extended[i] = td6->vehicle_additional_colour[i]; } - ride_set_name(rideIndex, td6->name); + ride_set_name(rideIndex, td6->name, flags); gCommandExpenditureType = RCT_EXPENDITURE_TYPE_RIDE_CONSTRUCTION; *outRideIndex = rideIndex;