Fix track designs ignoring ghost/preview flags.

This commit is contained in:
Matt 2018-12-15 11:28:33 +01:00
parent 14695e9b41
commit d3a20df682
6 changed files with 21 additions and 32 deletions

View File

@ -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);
}
/**

View File

@ -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;

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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(

View File

@ -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;