Move game command calls to a single call site

This commit is contained in:
duncanspumpkin 2019-02-22 09:32:23 +00:00
parent 5b0367ea0e
commit d5ad6b7b0f
5 changed files with 21 additions and 25 deletions

View File

@ -3189,8 +3189,7 @@ static void window_ride_vehicle_scrollpaint(rct_window* w, rct_drawpixelinfo* dp
static void set_operating_setting(int32_t rideNumber, uint8_t setting, uint8_t value)
{
gGameCommandErrorTitle = STR_CANT_CHANGE_OPERATING_MODE;
game_do_command(0, (value << 8) | 1, 0, (setting << 8) | rideNumber, GAME_COMMAND_SET_RIDE_SETTING, 0, 0);
set_operating_setting(rideNumber, setting, value, GAME_COMMAND_FLAG_APPLY);
}
static void window_ride_mode_tweak_set(rct_window* w, uint8_t value)
@ -3987,8 +3986,7 @@ static void window_ride_maintenance_dropdown(rct_window* w, rct_widgetindex widg
switch (widgetIndex)
{
case WIDX_INSPECTION_INTERVAL_DROPDOWN:
gGameCommandErrorTitle = STR_CANT_CHANGE_OPERATING_MODE;
game_do_command(0, (dropdownIndex << 8) | 1, 0, (5 << 8) | w->number, GAME_COMMAND_SET_RIDE_SETTING, 0, 0);
set_operating_setting(w->number, RIDE_SETTING_INSPECTION_INTERVAL, dropdownIndex, GAME_COMMAND_FLAG_APPLY);
break;
case WIDX_FORCE_BREAKDOWN:
@ -5036,9 +5034,7 @@ static void window_ride_toggle_music(rct_window* w)
Ride* ride = get_ride(w->number);
int32_t activateMusic = (ride->lifecycle_flags & RIDE_LIFECYCLE_MUSIC) ? 0 : 1;
gGameCommandErrorTitle = STR_CANT_CHANGE_OPERATING_MODE;
game_do_command(0, (activateMusic << 8) | 1, 0, (6 << 8) | w->number, GAME_COMMAND_SET_RIDE_SETTING, 0, 0);
set_operating_setting(w->number, RIDE_SETTING_MUSIC, activateMusic, GAME_COMMAND_FLAG_APPLY);
}
/**
@ -5142,8 +5138,7 @@ static void window_ride_music_dropdown(rct_window* w, rct_widgetindex widgetInde
return;
musicStyle = window_ride_current_music_style_order[dropdownIndex];
gGameCommandErrorTitle = STR_CANT_CHANGE_OPERATING_MODE;
game_do_command(0, (musicStyle << 8) | 1, 0, (7 << 8) | w->number, GAME_COMMAND_SET_RIDE_SETTING, 0, 0);
set_operating_setting(w->number, RIDE_SETTING_MUSIC_TYPE, musicStyle, GAME_COMMAND_FLAG_APPLY);
}
/**

View File

@ -186,9 +186,7 @@ static int32_t cc_rides(InteractiveConsole& console, const arguments_t& argv)
}
else
{
gGameCommandErrorTitle = STR_CANT_CHANGE_OPERATING_MODE;
int32_t res = game_do_command(
0, (type << 8) | 1, 0, (RIDE_SETTING_RIDE_TYPE << 8) | ride_index, GAME_COMMAND_SET_RIDE_SETTING, 0, 0);
int32_t res = set_operating_setting(ride_index, RIDE_SETTING_RIDE_TYPE, type, GAME_COMMAND_FLAG_APPLY);
if (res == MONEY32_UNDEFINED)
{
console.WriteFormatLine("That didn't work");

View File

@ -4260,6 +4260,12 @@ void game_command_set_ride_setting(
*ebx = ride_set_setting(rideIndex, setting, newValue, flags);
}
money32 set_operating_setting(int32_t rideId, uint8_t setting, uint8_t value, uint8_t flags)
{
gGameCommandErrorTitle = STR_CANT_CHANGE_OPERATING_MODE;
return game_do_command(0, (value << 8) | flags, 0, (setting << 8) | rideId, GAME_COMMAND_SET_RIDE_SETTING, 0, 0);
}
/**
*
* rct2: 0x006B4CC1
@ -7618,9 +7624,8 @@ void ride_set_to_default_inspection_interval(Ride* ride)
{
if (defaultInspectionInterval <= RIDE_INSPECTION_NEVER)
{
gGameCommandErrorTitle = STR_CANT_CHANGE_OPERATING_MODE;
game_do_command(
0, (defaultInspectionInterval << 8) | 1, 0, (5 << 8) | ride->id, GAME_COMMAND_SET_RIDE_SETTING, 0, 0);
set_operating_setting(
ride->id, RIDE_SETTING_INSPECTION_INTERVAL, defaultInspectionInterval, GAME_COMMAND_FLAG_APPLY);
}
}
}

View File

@ -1136,6 +1136,7 @@ uint64_t ride_entry_get_supported_track_pieces(const rct_ride_entry* rideEntry);
void ride_set_ride_entry(Ride* ride, int32_t rideEntry);
void ride_set_num_vehicles(Ride* ride, int32_t numVehicles);
void ride_set_num_cars_per_vehicle(Ride* ride, int32_t numCarsPerVehicle);
money32 set_operating_setting(int32_t rideId, uint8_t setting, uint8_t value, uint8_t flags);
void game_command_set_ride_vehicles(
int32_t* eax, int32_t* ebx, int32_t* ecx, int32_t* edx, int32_t* esi, int32_t* edi, int32_t* ebp);

View File

@ -1967,7 +1967,7 @@ static money32 place_track_design(int16_t x, int16_t y, int16_t z, uint8_t flags
: GameActions::QueryNested(&rideSetVehicleAction);
}
game_do_command(0, flags | (td6->ride_mode << 8), 0, ride->id | (0 << 8), GAME_COMMAND_SET_RIDE_SETTING, 0, 0);
set_operating_setting(ride->id, RIDE_SETTING_MODE, td6->ride_mode, flags);
auto rideSetVehicleAction2 = RideSetVehicleAction(ride->id, RideSetVehicleType::NumTrains, td6->number_of_trains);
flags& GAME_COMMAND_FLAG_APPLY ? GameActions::ExecuteNested(&rideSetVehicleAction2)
: GameActions::QueryNested(&rideSetVehicleAction2);
@ -1975,21 +1975,18 @@ static money32 place_track_design(int16_t x, int16_t y, int16_t z, uint8_t flags
ride->id, RideSetVehicleType::NumCarsPerTrain, td6->number_of_cars_per_train);
flags& GAME_COMMAND_FLAG_APPLY ? GameActions::ExecuteNested(&rideSetVehicleAction3)
: GameActions::QueryNested(&rideSetVehicleAction3);
game_do_command(0, flags | (td6->depart_flags << 8), 0, ride->id | (1 << 8), GAME_COMMAND_SET_RIDE_SETTING, 0, 0);
game_do_command(0, flags | (td6->min_waiting_time << 8), 0, ride->id | (2 << 8), GAME_COMMAND_SET_RIDE_SETTING, 0, 0);
game_do_command(0, flags | (td6->max_waiting_time << 8), 0, ride->id | (3 << 8), GAME_COMMAND_SET_RIDE_SETTING, 0, 0);
game_do_command(0, flags | (td6->operation_setting << 8), 0, ride->id | (4 << 8), GAME_COMMAND_SET_RIDE_SETTING, 0, 0);
game_do_command(
0, flags | ((td6->lift_hill_speed_num_circuits & 0x1F) << 8), 0, ride->id | (8 << 8), GAME_COMMAND_SET_RIDE_SETTING, 0,
0);
set_operating_setting(ride->id, RIDE_SETTING_DEPARTURE, td6->depart_flags, flags);
set_operating_setting(ride->id, RIDE_SETTING_MIN_WAITING_TIME, td6->min_waiting_time, flags);
set_operating_setting(ride->id, RIDE_SETTING_MAX_WAITING_TIME, td6->max_waiting_time, flags);
set_operating_setting(ride->id, RIDE_SETTING_OPERATION_OPTION, td6->operation_setting, flags);
set_operating_setting(ride->id, RIDE_SETTING_LIFT_HILL_SPEED, td6->lift_hill_speed_num_circuits & 0x1F, flags);
uint8_t num_circuits = td6->lift_hill_speed_num_circuits >> 5;
if (num_circuits == 0)
{
num_circuits = 1;
}
game_do_command(0, flags | (num_circuits << 8), 0, ride->id | (9 << 8), GAME_COMMAND_SET_RIDE_SETTING, 0, 0);
set_operating_setting(ride->id, RIDE_SETTING_NUM_CIRCUITS, num_circuits, flags);
ride_set_to_default_inspection_interval(ride);
ride->lifecycle_flags |= RIDE_LIFECYCLE_NOT_CUSTOM_DESIGN;
ride->colour_scheme_type = td6->version_and_colour_scheme & 3;