diff --git a/src/game.h b/src/game.h index 3b00c7ea43..b5df70cc6b 100644 --- a/src/game.h +++ b/src/game.h @@ -31,7 +31,7 @@ enum GAME_COMMAND { GAME_COMMAND_REMOVE_TRACK, GAME_COMMAND_LOAD_OR_QUIT, // 5 GAME_COMMAND_6, - GAME_COMMAND_7, + GAME_COMMAND_DEMOLISH_RIDE, GAME_COMMAND_SET_RIDE_STATUS, // 8 GAME_COMMAND_9, GAME_COMMAND_SET_RIDE_NAME, diff --git a/src/peep/peep.c b/src/peep/peep.c index adb41accf4..64eb9fc49e 100644 --- a/src/peep/peep.c +++ b/src/peep/peep.c @@ -163,7 +163,7 @@ void sub_693B58(rct_peep* peep){ } /* 0x00693BE5 */ -static void sub_693BE5(rct_peep* peep, uint8 al){ +void sub_693BE5(rct_peep* peep, uint8 al){ if (al == peep->var_6D)return; peep->var_6D = al; diff --git a/src/peep/peep.h b/src/peep/peep.h index 704914342e..28875d2bfd 100644 --- a/src/peep/peep.h +++ b/src/peep/peep.h @@ -591,4 +591,6 @@ void sub_693B58(rct_peep* peep); void remove_peep_from_ride(rct_peep* peep); void remove_peep_from_queue(rct_peep* peep); +void sub_693BE5(rct_peep* peep, uint8 al); + #endif diff --git a/src/ride/ride.c b/src/ride/ride.c index 6d557a5082..e2f68f63e7 100644 --- a/src/ride/ride.c +++ b/src/ride/ride.c @@ -37,6 +37,7 @@ #include "../util/util.h" #include "../windows/error.h" #include "../world/banner.h" +#include "../world/footpath.h" #include "../world/map.h" #include "../world/sprite.h" #include "ride.h" @@ -138,6 +139,7 @@ void ride_prepare_breakdown(int rideIndex, int breakdownReason); static void ride_shop_connected(rct_ride* ride, int ride_idx); static void ride_spiral_slide_update(rct_ride *ride); static void ride_update(int rideIndex); +static void sub_6B59C6(int rideIndex); rct_ride_type *ride_get_entry(rct_ride *ride) { @@ -784,7 +786,7 @@ void ride_remove_peeps(int rideIndex) invalidate_sprite((rct_sprite*)peep); peep->state = PEEP_STATE_FALLING; - RCT2_CALLPROC_X(0x00693BE5, 0, 0, 0, 0, (int)peep, 0, 0); + sub_693BE5(peep, 0); peep->happiness = min(peep->happiness, peep->happiness_growth_rate) / 2; peep->happiness_growth_rate = peep->happiness; @@ -998,8 +1000,6 @@ bool sub_6C63D6(int inX, int inY, int inZ, int inDirection, track_begin_end *out */ void sub_6C96C0() { - // RCT2_CALLPROC_X(0x006C96C0, 0, 0, 0, 0, 0, 0, 0); return; - rct_ride *ride; rct_map_element *trackElement; int rideIndex, x, y, z, direction; @@ -3334,7 +3334,7 @@ void game_command_set_ride_setting(int *eax, int *ebx, int *ecx, int *edx, int * switch (setting){ case 0: - RCT2_CALLPROC_X(0x006B59C6, 0, 0, 0, ride_id, 0, 0, 0); + sub_6B59C6(ride_id); ride_clear_for_construction(ride_id); ride_remove_peeps(ride_id); @@ -3376,7 +3376,7 @@ void game_command_set_ride_setting(int *eax, int *ebx, int *ecx, int *edx, int * 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); + sub_6B59C6(ride_id); ride->time_limit = new_value; break; case 5: @@ -3397,13 +3397,13 @@ void game_command_set_ride_setting(int *eax, int *ebx, int *ecx, int *edx, int * 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); + sub_6B59C6(ride_id); } 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); + sub_6B59C6(ride_id); } break; } @@ -3526,7 +3526,28 @@ int ride_check_for_entrance_exit(int rideIndex) */ void sub_6B5952(int rideIndex) { - RCT2_CALLPROC_X(0x006B5952, 0, 0, 0, rideIndex, 0, 0, 0); + rct_ride *ride = GET_RIDE(rideIndex); + + for (int i = 0; i < 4; i++) { + uint16 xy = ride->entrances[i]; + if (xy == 0xFFFF) + continue; + + int x = xy & 0xFF; + int y = xy >> 8; + int z = ride->station_heights[i]; + + rct_map_element *mapElement = map_get_first_element_at(x, y); + do { + if (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_ENTRANCE) + continue; + if (mapElement->base_height != z) + continue; + + int direction = mapElement->type & MAP_ELEMENT_DIRECTION_MASK; + sub_6A742F(rideIndex, i, x, y, mapElement, direction ^ 2); + } while (map_element_is_last_for_tile(mapElement++)); + } } /** @@ -4308,6 +4329,30 @@ int ride_get_refund_price(int ride_id) return RCT2_GLOBAL(0x00F4413A, int); } +/** + * + * rct2: 0x00696707 + */ +static void ride_stop_peeps_queuing(int rideIndex) +{ + uint16 spriteIndex; + rct_peep *peep; + + FOR_ALL_PEEPS(spriteIndex, peep) { + if (peep->state != PEEP_STATE_QUEUING) + continue; + if (peep->current_ride != rideIndex) + continue; + + remove_peep_from_queue(peep); + peep_decrement_num_riders(peep); + + peep->state = PEEP_STATE_FALLING; + + peep_window_state_update(peep); + } +} + /** * * rct2: 0x006B49D9 @@ -4349,7 +4394,7 @@ void game_command_demolish_ride(int *eax, int *ebx, int *ecx, int *edx, int *esi } ride_clear_for_construction(ride_id); ride_remove_peeps(ride_id); - RCT2_CALLPROC_X(0x00696707, 0, 0, 0, ride_id, 0, 0, 0); + ride_stop_peeps_queuing(ride_id); *ebx = ride_get_refund_price(ride_id); RCT2_CALLPROC_X(0x006CB945, 0, 0, 0, ride_id, 0, 0, 0); @@ -4904,4 +4949,28 @@ bool ride_are_all_possible_entrances_and_exits_built(rct_ride *ride) } } return true; -} \ No newline at end of file +} + +/** + * + * rct2: 0x006B59C6 + */ +static void sub_6B59C6(int rideIndex) +{ + rct_ride *ride = GET_RIDE(rideIndex); + + ride_measurement_clear(ride); + ride->excitement = 0xFFFF; + ride->lifecycle_flags &= ~RIDE_LIFECYCLE_TESTED; + ride->lifecycle_flags &= ~RIDE_LIFECYCLE_TEST_IN_PROGRESS; + if (ride->lifecycle_flags & RIDE_LIFECYCLE_ON_TRACK) { + for (int i = 0; i < ride->num_vehicles; i++) { + uint16 spriteIndex = ride->vehicles[i]; + if (spriteIndex != SPRITE_INDEX_NULL) { + rct_vehicle *vehicle = &(g_sprite_list[spriteIndex].vehicle); + vehicle->var_48 &= ~(1 << 5); + } + } + } + window_invalidate_by_number(WC_RIDE, rideIndex); +} diff --git a/src/ride/track.c b/src/ride/track.c index 8ff1fd2e03..2129d4b0dc 100644 --- a/src/ride/track.c +++ b/src/ride/track.c @@ -1491,7 +1491,7 @@ int track_place_maze(sint16 x, sint16 y, sint16 z, uint8 rideIndex, uint8** trac } if (RCT2_GLOBAL(0x00F440D4, uint8) == 6){ - game_do_command(0, 0x69, 0, rideIndex, GAME_COMMAND_7, 0, 0); + game_do_command(0, 0x69, 0, rideIndex, GAME_COMMAND_DEMOLISH_RIDE, 0, 0); } RCT2_GLOBAL(0x00F44142, sint16) = x; @@ -3242,7 +3242,7 @@ void game_command_place_track_design(int* eax, int* ebx, int* ecx, int* edx, int if (cost == MONEY32_UNDEFINED || !(flags & GAME_COMMAND_FLAG_APPLY)){ rct_string_id error_reason = RCT2_GLOBAL(0x00141E9AC, rct_string_id); - game_do_command(0, GAME_COMMAND_FLAG_APPLY, 0, rideIndex, GAME_COMMAND_7, 0, 0); + game_do_command(0, GAME_COMMAND_FLAG_APPLY, 0, rideIndex, GAME_COMMAND_DEMOLISH_RIDE, 0, 0); *ebx = cost; RCT2_GLOBAL(0x00141E9AC, rct_string_id) = error_reason; RCT2_GLOBAL(RCT2_ADDRESS_NEXT_EXPENDITURE_TYPE, uint8) = 0; diff --git a/src/windows/demolish_ride_prompt.c b/src/windows/demolish_ride_prompt.c index ba62515caf..3ad481bc28 100644 --- a/src/windows/demolish_ride_prompt.c +++ b/src/windows/demolish_ride_prompt.c @@ -116,7 +116,7 @@ static void window_ride_demolish_mouseup(){ switch (widgetIndex){ case WIDX_DEMOLISH: RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_STRING_ID, rct_string_id) = STR_CANT_DEMOLISH_RIDE; - game_do_command(0, 1, 0, w->number, GAME_COMMAND_7, 0, 0); + game_do_command(0, 1, 0, w->number, GAME_COMMAND_DEMOLISH_RIDE, 0, 0); break; case WIDX_CANCEL: case WIDX_CLOSE: diff --git a/src/windows/maze_construction.c b/src/windows/maze_construction.c index ee801a53bc..0a659f63b2 100644 --- a/src/windows/maze_construction.c +++ b/src/windows/maze_construction.c @@ -176,7 +176,7 @@ static void window_maze_construction_close() if (ride->overall_view == 0xFFFF) { int savedPausedState = RCT2_GLOBAL(RCT2_ADDRESS_GAME_PAUSED, uint8); RCT2_GLOBAL(RCT2_ADDRESS_GAME_PAUSED, uint8) = 0; - game_do_command(0, 9, 0, rideIndex, GAME_COMMAND_7, 0, 0); + game_do_command(0, 9, 0, rideIndex, GAME_COMMAND_DEMOLISH_RIDE, 0, 0); RCT2_GLOBAL(RCT2_ADDRESS_GAME_PAUSED, uint8) = savedPausedState; } else { window_ride_main_open(rideIndex); diff --git a/src/windows/ride_construction.c b/src/windows/ride_construction.c index ac1c424f12..c06a25e1df 100644 --- a/src/windows/ride_construction.c +++ b/src/windows/ride_construction.c @@ -586,7 +586,7 @@ static void window_ride_construction_close() int eax = RCT2_GLOBAL(RCT2_ADDRESS_GAME_PAUSED, uint8); RCT2_GLOBAL(RCT2_ADDRESS_GAME_PAUSED, uint8) = 0; - game_do_command(0, 9, 0, rideIndex, GAME_COMMAND_7, 0, 0); + game_do_command(0, 9, 0, rideIndex, GAME_COMMAND_DEMOLISH_RIDE, 0, 0); RCT2_GLOBAL(RCT2_ADDRESS_GAME_PAUSED, uint8) = eax; } diff --git a/src/world/footpath.h b/src/world/footpath.h index 047773a653..2f943e8084 100644 --- a/src/world/footpath.h +++ b/src/world/footpath.h @@ -51,5 +51,6 @@ void footpath_bridge_get_info_from_pos(int screenX, int screenY, int *x, int *y, void footpath_remove_litter(int x, int y, int z); void sub_6A6C66(int x, int y, rct_map_element *mapElement, int flags); void sub_6A759F(); +void sub_6A742F(int rideIndex, int entranceIndex, int x, int y, rct_map_element *mapElement, int direction); #endif