mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-27 00:34:46 +01:00
Merge pull request #5 from duncanspumpkin/set_ride_setting
Added game_command_set_ride_setting.
This commit is contained in:
@@ -880,7 +880,7 @@ static uint32 game_do_command_table[58] = {
|
||||
0,
|
||||
0x006B52D4,
|
||||
0, // 10
|
||||
0x006B5559,
|
||||
0,
|
||||
0x006660A8,
|
||||
0x0066640B,
|
||||
0x006E0E01,
|
||||
@@ -943,7 +943,7 @@ static GAME_COMMAND_POINTER* new_game_command_table[58] = {
|
||||
game_command_set_ride_status,
|
||||
game_command_emptysub,
|
||||
game_command_set_ride_name, // 10
|
||||
game_command_emptysub,
|
||||
game_command_set_ride_setting,
|
||||
game_command_emptysub,
|
||||
game_command_emptysub,
|
||||
game_command_emptysub,
|
||||
|
||||
@@ -35,7 +35,7 @@ enum GAME_COMMAND {
|
||||
GAME_COMMAND_SET_RIDE_STATUS, // 8
|
||||
GAME_COMMAND_9,
|
||||
GAME_COMMAND_SET_RIDE_NAME,
|
||||
GAME_COMMAND_11,
|
||||
GAME_COMMAND_SET_RIDE_SETTING,
|
||||
GAME_COMMAND_12,
|
||||
GAME_COMMAND_13,
|
||||
GAME_COMMAND_REMOVE_SCENERY,
|
||||
|
||||
133
src/ride/ride.c
133
src/ride/ride.c
@@ -937,7 +937,7 @@ int ride_modify(rct_xy_element *input)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (ride->lifecycle_flags & RIDE_LIFECYCLE_19) {
|
||||
if (ride->lifecycle_flags & RIDE_LIFECYCLE_SIX_FLAGS) {
|
||||
RCT2_GLOBAL(0x013CE952 + 6, uint16) = ride->name;
|
||||
RCT2_GLOBAL(0x013CE952 + 8, uint32) = ride->name_arguments;
|
||||
window_error_open(STR_CANT_START_CONSTRUCTION_ON, STR_THIS_RIDE_CANNOT_BE_MODIFIED);
|
||||
@@ -1445,7 +1445,7 @@ static int ride_get_new_breakdown_problem(rct_ride *ride)
|
||||
|
||||
// Again the probability is lower, this time if young or two other unknown reasons...
|
||||
monthsOld = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, uint8) - ride->build_date;
|
||||
if (monthsOld < 16 || ride->var_196 > 12800 || ride->lifecycle_flags & RIDE_LIFECYCLE_19)
|
||||
if (monthsOld < 16 || ride->var_196 > 12800 || ride->lifecycle_flags & RIDE_LIFECYCLE_SIX_FLAGS)
|
||||
return -1;
|
||||
|
||||
return BREAKDOWN_BRAKES_FAILURE;
|
||||
@@ -2760,6 +2760,135 @@ void ride_music_update_final()
|
||||
|
||||
#pragma endregion
|
||||
|
||||
/* rct2: 0x006B5559 */
|
||||
void game_command_set_ride_setting(int *eax, int *ebx, int *ecx, int *edx, int *esi, int *edi, int *ebp)
|
||||
{
|
||||
RCT2_GLOBAL(0x141F56C, uint8) = 4;
|
||||
|
||||
uint8 ride_id = *edx & 0xFF;
|
||||
rct_ride* ride = GET_RIDE(ride_id);
|
||||
|
||||
uint8 flags = *ebx & 0xFF;
|
||||
uint8 new_value = (*ebx >> 8) & 0xFF;
|
||||
|
||||
uint8 setting = (*edx >> 8) & 0xFF;
|
||||
|
||||
if (setting == 0){
|
||||
if (ride->lifecycle_flags & RIDE_LIFECYCLE_BROKEN_DOWN){
|
||||
RCT2_GLOBAL(0x141E9AC, uint16) = 1796;
|
||||
*ebx = 0x80000000;
|
||||
return;
|
||||
}
|
||||
|
||||
if (ride->status != RIDE_STATUS_CLOSED){
|
||||
RCT2_GLOBAL(0x141E9AC, uint16) = 1006;
|
||||
*ebx = 0x80000000;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (ride->lifecycle_flags & RIDE_LIFECYCLE_SIX_FLAGS){
|
||||
if (setting == 0 || setting == 4 || setting == 8 || setting == 9)
|
||||
{
|
||||
RCT2_GLOBAL(0x141E9AC, uint16) = 1797;
|
||||
*ebx = 0x80000000;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (setting == 9 &&
|
||||
ride->lifecycle_flags & RIDE_LIFECYCLE_CABLE_LIFT &&
|
||||
new_value > 1){
|
||||
RCT2_GLOBAL(0x141E9AC, uint16) = 3141;
|
||||
*ebx = 0x80000000;
|
||||
return;
|
||||
}
|
||||
|
||||
if (flags == 0){
|
||||
*ebx = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
switch (setting){
|
||||
case 0:
|
||||
RCT2_CALLPROC_X(0x006B59C6, 0, 0, 0, ride_id, 0, 0, 0);
|
||||
ride_clear_for_construction(ride_id);
|
||||
ride_remove_peeps(ride_id);
|
||||
|
||||
rct_ride_type* ride_entry = GET_RIDE_ENTRY(ride->subtype);
|
||||
const uint8* available_modes = RideAvailableModes;
|
||||
|
||||
for (int i = 0; i < ride->type; i++) {
|
||||
while (*(available_modes++) != 255) {}
|
||||
}
|
||||
if (ride_entry->var_008 & (1 << 17)){
|
||||
available_modes += 2;
|
||||
}
|
||||
|
||||
uint8 default_mode = available_modes[0];
|
||||
for (; *available_modes != 0xFF; available_modes++){
|
||||
if (*available_modes == new_value)
|
||||
break;
|
||||
}
|
||||
|
||||
if (*available_modes == 0xFF) new_value = default_mode;
|
||||
|
||||
if (available_modes[1] == 0xFF){
|
||||
if (ride_entry->var_008 & (1 << 15))
|
||||
new_value = default_mode;
|
||||
}
|
||||
|
||||
ride->mode = new_value;
|
||||
RCT2_CALLPROC_X(0x6DD57D, 0, 0, 0, ride_id, 0, 0, 0);
|
||||
break;
|
||||
case 1:
|
||||
ride->depart_flags = new_value;
|
||||
break;
|
||||
case 2:
|
||||
ride->min_waiting_time = new_value;
|
||||
ride->max_waiting_time = max(new_value, ride->max_waiting_time);
|
||||
break;
|
||||
case 3:
|
||||
ride->max_waiting_time = new_value;
|
||||
ride->min_waiting_time = min(new_value, ride->min_waiting_time);
|
||||
break;
|
||||
case 4:
|
||||
RCT2_CALLPROC_X(0x006B59C6, 0, 0, 0, ride_id, 0, 0, 0);
|
||||
ride->time_limit = new_value;
|
||||
break;
|
||||
case 5:
|
||||
ride->inspection_interval = new_value;
|
||||
break;
|
||||
case 6:
|
||||
ride->lifecycle_flags &= ~RIDE_LIFECYCLE_MUSIC;
|
||||
if (new_value){
|
||||
ride->lifecycle_flags |= RIDE_LIFECYCLE_MUSIC;
|
||||
}
|
||||
break;
|
||||
case 7:
|
||||
if (new_value != ride->music){
|
||||
ride->music = new_value;
|
||||
ride->music_tune_id = 0xFF;
|
||||
}
|
||||
break;
|
||||
case 8:
|
||||
if (new_value != ride->lift_hill_speed){
|
||||
ride->lift_hill_speed = new_value;
|
||||
RCT2_CALLPROC_X(0x006B59C6, 0, 0, 0, ride_id, 0, 0, 0);
|
||||
}
|
||||
break;
|
||||
case 9:
|
||||
if (new_value != ride->num_circuits){
|
||||
ride->num_circuits = new_value;
|
||||
RCT2_CALLPROC_X(0x006B59C6, 0, 0, 0, ride_id, 0, 0, 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
window_invalidate_by_number(WC_RIDE, ride_id);
|
||||
*ebx = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006B4CC1
|
||||
|
||||
@@ -343,7 +343,7 @@ enum {
|
||||
RIDE_LIFECYCLE_16 = 1 << 16,
|
||||
RIDE_LIFECYCLE_CABLE_LIFT = 1 << 17,
|
||||
RIDE_LIFECYCLE_18 = 1 << 18,
|
||||
RIDE_LIFECYCLE_19 = 1 << 19
|
||||
RIDE_LIFECYCLE_SIX_FLAGS = 1 << 19
|
||||
};
|
||||
|
||||
enum {
|
||||
@@ -726,6 +726,7 @@ void ride_set_status(int rideIndex, int status);
|
||||
void game_command_set_ride_status(int *eax, int *ebx, int *ecx, int *edx, int *esi, int *edi, int *ebp);
|
||||
void ride_set_name(int rideIndex, const char *name);
|
||||
void game_command_set_ride_name(int *eax, int *ebx, int *ecx, int *edx, int *esi, int *edi, int *ebp);
|
||||
void game_command_set_ride_setting(int *eax, int *ebx, int *ecx, int *edx, int *esi, int *edi, int *ebp);
|
||||
|
||||
bool ride_type_has_flag(int rideType, int flag);
|
||||
|
||||
|
||||
@@ -678,6 +678,7 @@ const rct_ride_name_convention RideNameConvention[96] = {
|
||||
{ 1229, 1243, 1257, 0 }
|
||||
};
|
||||
|
||||
/* rct2: 0x0097C8AC */
|
||||
const uint8 RideAvailableModes[] = {
|
||||
RIDE_MODE_CONTINUOUS_CIRCUIT, RIDE_MODE_CONTINUOUS_CIRCUIT_BLOCK_SECTIONED, 0xFF, // 00 Spiral Roller coaster
|
||||
RIDE_MODE_CONTINUOUS_CIRCUIT, RIDE_MODE_CONTINUOUS_CIRCUIT_BLOCK_SECTIONED, 0xFF, // 01 Stand Up Coaster
|
||||
|
||||
@@ -1983,7 +1983,7 @@ static void window_ride_main_invalidate()
|
||||
w->disabled_widgets &= ~((1 << 22) | (1 << 19));
|
||||
if (ride->lifecycle_flags & (RIDE_LIFECYCLE_INDESTRUCTIBLE | RIDE_LIFECYCLE_INDESTRUCTIBLE_TRACK))
|
||||
w->disabled_widgets |= (1 << 22);
|
||||
if (ride->lifecycle_flags & RIDE_LIFECYCLE_19)
|
||||
if (ride->lifecycle_flags & RIDE_LIFECYCLE_SIX_FLAGS)
|
||||
w->disabled_widgets |= (1 << 19);
|
||||
|
||||
RCT2_GLOBAL(0x013CE952 + 0, uint16) = ride->name;
|
||||
@@ -2647,7 +2647,7 @@ static void window_ride_vehicle_scrollpaint()
|
||||
static void set_operating_setting(int rideNumber, uint8 setting, uint8 value)
|
||||
{
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TITLE, uint16) = STR_CANT_CHANGE_OPERATING_MODE;
|
||||
game_do_command(0, (value << 8) | 1, 0, (setting << 8) | rideNumber, GAME_COMMAND_11, 0, 0);
|
||||
game_do_command(0, (value << 8) | 1, 0, (setting << 8) | rideNumber, GAME_COMMAND_SET_RIDE_SETTING, 0, 0);
|
||||
}
|
||||
|
||||
static void window_ride_mode_tweak_set(rct_window *w, uint8 value)
|
||||
@@ -2674,7 +2674,7 @@ static void window_ride_mode_tweak_set(rct_window *w, uint8 value)
|
||||
)
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TITLE, uint16) = 1868;
|
||||
|
||||
game_do_command(0, (value << 8) | 1, 0, (4 << 8) | w->number, GAME_COMMAND_11, 0, 0);
|
||||
game_do_command(0, (value << 8) | 1, 0, (4 << 8) | w->number, GAME_COMMAND_SET_RIDE_SETTING, 0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3344,7 +3344,7 @@ static void window_ride_maintenance_dropdown()
|
||||
ride = GET_RIDE(w->number);
|
||||
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TITLE, uint16) = STR_CANT_CHANGE_OPERATING_MODE;
|
||||
game_do_command(0, (dropdownIndex << 8) | 1, 0, (5 << 8) | w->number, GAME_COMMAND_11, 0, 0);
|
||||
game_do_command(0, (dropdownIndex << 8) | 1, 0, (5 << 8) | w->number, GAME_COMMAND_SET_RIDE_SETTING, 0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -4245,7 +4245,7 @@ static void window_ride_toggle_music(rct_window *w)
|
||||
int activateMusic = (ride->lifecycle_flags & RIDE_LIFECYCLE_MUSIC) ? 0 : 1;
|
||||
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TITLE, uint16) = STR_CANT_CHANGE_OPERATING_MODE;
|
||||
game_do_command(0, (activateMusic << 8) | 1, 0, (6 << 8) | w->number, GAME_COMMAND_11, 0, 0);
|
||||
game_do_command(0, (activateMusic << 8) | 1, 0, (6 << 8) | w->number, GAME_COMMAND_SET_RIDE_SETTING, 0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -4360,7 +4360,7 @@ static void window_ride_music_dropdown()
|
||||
ride = GET_RIDE(w->number);
|
||||
musicStyle = window_ride_current_music_style_order[dropdownIndex];
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TITLE, uint16) = STR_CANT_CHANGE_OPERATING_MODE;
|
||||
game_do_command(0, (musicStyle << 8) | 1, 0, (7 << 8) | w->number, GAME_COMMAND_11, 0, 0);
|
||||
game_do_command(0, (musicStyle << 8) | 1, 0, (7 << 8) | w->number, GAME_COMMAND_SET_RIDE_SETTING, 0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -4702,7 +4702,7 @@ static void window_ride_measurements_invalidate()
|
||||
window_ride_measurements_widgets[WIDX_RESET_SELECTION].type = WWT_EMPTY;
|
||||
window_ride_measurements_widgets[WIDX_SAVE_DESIGN].type = WWT_EMPTY;
|
||||
window_ride_measurements_widgets[WIDX_CANCEL_DESIGN].type = WWT_EMPTY;
|
||||
if (!(ride->lifecycle_flags & RIDE_LIFECYCLE_19)) {
|
||||
if (!(ride->lifecycle_flags & RIDE_LIFECYCLE_SIX_FLAGS)) {
|
||||
if (ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_HAS_TRACK)) {
|
||||
window_ride_measurements_widgets[WIDX_SAVE_TRACK_DESIGN].type = WWT_FLATBTN;
|
||||
w->disabled_widgets |= (1 << WIDX_SAVE_TRACK_DESIGN);
|
||||
@@ -4753,7 +4753,7 @@ static void window_ride_measurements_paint()
|
||||
} else {
|
||||
ride = GET_RIDE(w->number);
|
||||
|
||||
if (ride->lifecycle_flags & RIDE_LIFECYCLE_19)
|
||||
if (ride->lifecycle_flags & RIDE_LIFECYCLE_SIX_FLAGS)
|
||||
gfx_draw_sprite(dpi, 23225, w->x + w->width - 53, w->y + w->height - 73, 0);
|
||||
|
||||
x = w->x + window_ride_measurements_widgets[WIDX_PAGE_BACKGROUND].left + 4;
|
||||
|
||||
Reference in New Issue
Block a user