diff --git a/src/interface/window.c b/src/interface/window.c index e798358e10..c7b573f09c 100644 --- a/src/interface/window.c +++ b/src/interface/window.c @@ -470,10 +470,15 @@ void window_close(rct_window* window) if (window == NULL) return; + // Make a copy of the window class and number incase + // the window order is changed by the close event. + rct_windowclass cls = window->classification; + rct_windownumber number = window->number; + // Call close event of window RCT2_CALLPROC_X(window->event_handlers[WE_CLOSE], 0, 0, 0, 0, (int)window, 0, 0); - window = window_find_by_number(window->classification, window->number); + window = window_find_by_number(cls, number); // Remove viewport if (window->viewport != NULL) { diff --git a/src/ride/ride.c b/src/ride/ride.c index 9765daf053..951ad6e659 100644 --- a/src/ride/ride.c +++ b/src/ride/ride.c @@ -481,7 +481,7 @@ static rct_window *ride_create_or_find_construction_window(int rideIndex) RCT2_GLOBAL(0x00F440A7, uint8) = rideIndex; w = window_construction_open(rideIndex); } else { - RCT2_CALLPROC_X(0x006C9627, 0, 0, 0, 0, 0, 0, 0); + sub_6C9627(); RCT2_GLOBAL(0x00F440A7, uint8) = rideIndex; } @@ -712,7 +712,7 @@ void sub_6C96C0() RCT2_CALLPROC_X(0x006C96C0, 0, 0, 0, 0, 0, 0, 0); } -static void sub_6C9627() +void sub_6C9627() { switch (RCT2_GLOBAL(0x00F440A6, uint8)) { case 3: diff --git a/src/ride/ride.h b/src/ride/ride.h index c6241ae1f3..3394f1b5bd 100644 --- a/src/ride/ride.h +++ b/src/ride/ride.h @@ -628,6 +628,8 @@ rct_ride_measurement *ride_get_measurement(int rideIndex, rct_string_id *message void ride_breakdown_add_news_item(int rideIndex); rct_peep *ride_find_closest_mechanic(rct_ride *ride, int forInspection); int sub_6CC3FB(int rideIndex); +void sub_6C9627(); +int sub_6C683D(int x, int y, int z, int direction, int type, int esi, int edi, int ebp); void ride_set_map_tooltip(rct_map_element *mapElement); int ride_music_params_update(sint16 x, sint16 y, sint16 z, uint8 rideIndex, uint16 sampleRate, uint32 position, uint8 *tuneId); void ride_music_update_final(); diff --git a/src/windows/ride_construction.c b/src/windows/ride_construction.c index 58edbf38b9..64907bd61b 100644 --- a/src/windows/ride_construction.c +++ b/src/windows/ride_construction.c @@ -203,7 +203,7 @@ void window_construction_close(){ window_get_register(w); - RCT2_CALLPROC_X(0x006C9627, 0, 0, 0, 0, 0, 0, 0); + sub_6C9627(); viewport_set_visibility(0); map_invalidate_map_selection_tiles(); @@ -234,7 +234,7 @@ void window_construction_maze_close(){ window_get_register(w); - RCT2_CALLPROC_X(0x006C9627, 0, 0, 0, 0, 0, 0, 0); + sub_6C9627(); viewport_set_visibility(0); map_invalidate_map_selection_tiles(); @@ -304,7 +304,7 @@ void window_construction_mouseup_demolish(rct_window* w){ return; RCT2_GLOBAL(0xF44070, uint32) = 0x80000000; - RCT2_CALLPROC_X(0x006C9627, 0, 0, 0, 0, 0, 0, 0); + sub_6C9627(); RCT2_GLOBAL(0xF440B8, uint8) = 3; if (RCT2_GLOBAL(0xF440A6, uint8) == 1){ @@ -313,7 +313,12 @@ void window_construction_mouseup_demolish(rct_window* w){ if (RCT2_GLOBAL(0xF440A6, uint8) != 2){ //6c9cc4 - //do this + int eax = RCT2_GLOBAL(0xF440A8, uint16), + ebx = RCT2_GLOBAL(0xF440AF, uint8) || (RCT2_GLOBAL(0xF440AE, uint8) << 8), + ecx = RCT2_GLOBAL(0xF440AA, uint16), + edx = RCT2_GLOBAL(0xF440AC, uint16); + + sub_6C683D(eax, ecx, edx, RCT2_GLOBAL(0xF440AE, uint8), RCT2_GLOBAL(0xF440AF, uint8) & 0x3FF, 0, 0, 0); } int ride_id = RCT2_GLOBAL(0xF440A7, uint8);