diff --git a/src/game.h b/src/game.h index 1f87d944c0..b3d4f15adb 100644 --- a/src/game.h +++ b/src/game.h @@ -25,7 +25,7 @@ enum GAME_COMMAND { GAME_COMMAND_0, GAME_COMMAND_1, GAME_COMMAND_TOGGLE_PAUSE, // 2 - GAME_COMMAND_3, + GAME_COMMAND_3, //Has something to do with ride construction GAME_COMMAND_4, GAME_COMMAND_LOAD_OR_QUIT, // 5 GAME_COMMAND_6, diff --git a/src/ride.c b/src/ride.c index 546817e186..43798a15db 100644 --- a/src/ride.c +++ b/src/ride.c @@ -20,6 +20,7 @@ #include #include "addresses.h" +#include "game.h" #include "map.h" #include "news_item.h" #include "sprite.h" @@ -422,6 +423,48 @@ rct_map_element *ride_find_track_gap(rct_map_element *startTrackElement, int *ou return (rct_map_element*)esi; } +/** + * + * rct2: 0x006B4800 + */ +void ride_construct_new(int list_item) +{ + int eax, ebx, ecx, edx, esi, edi, ebp; + edx = list_item; + eax = 0; + ecx = 0; + ebx = 1; + edi = 0; + esi = 0; + + RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TITLE, uint16) = 0x3DC; + + esi = GAME_COMMAND_6; + game_do_command_p(esi, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); + if (ebx == 0x80000000) { + return; + } + + //Looks like edi became the ride index after the command. + eax = edi; + rct_window *w; + short widgetIndex; + + //TODO: replace with window_ride_main_open(eax) + // window_ride_main_open(eax); + RCT2_CALLFUNC_X(0x006ACC28, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); + window_get_register(w); + + ecx = w->classification; + edx = 0x13; + ebp = (int)w; + //TODO: replace with window_ride_main_mouseup() after ride-window_merge + // window_ride_main_mouseup(); + RCT2_CALLFUNC_X(0x006AF17E, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); + rct_window *ride_window = window_find_by_id(w->classification, w->number); //class here + window_close(ride_window); +} + /** * * rct2: 0x006CC056 @@ -431,4 +474,4 @@ int ride_try_construct(rct_map_element *trackMapElement) // Success stored in carry flag which can't be accessed after call using is macro RCT2_CALLPROC_X(0x006CC056, 0, 0, 0, (int)trackMapElement, 0, 0, 0); return 1; -} \ No newline at end of file +} diff --git a/src/ride.h b/src/ride.h index dca498d637..0c452f956d 100644 --- a/src/ride.h +++ b/src/ride.h @@ -384,6 +384,7 @@ void ride_update_favourited_stat(); void ride_check_all_reachable(); rct_map_element *sub_6CAF80(int rideIndex, int *outX, int *outY); rct_map_element *ride_find_track_gap(rct_map_element *startTrackElement, int *outX, int *outY); +void ride_construct_new(int list_item); int ride_try_construct(rct_map_element *trackMapElement); #endif diff --git a/src/window_new_ride.c b/src/window_new_ride.c index 9b061810f0..d63c5ef2c8 100644 --- a/src/window_new_ride.c +++ b/src/window_new_ride.c @@ -989,5 +989,6 @@ static void window_new_ride_select(rct_window *w) } // Show ride construction window - RCT2_CALLPROC_X(0x006B4800, *((sint16*)&item), 0, 0, 0, 0, 0, 0); -} \ No newline at end of file + //RCT2_CALLPROC_X(0x006B4800, *((sint16*)&item), 0, 0, 0, 0, 0, 0); + ride_construct_new(*((sint16*)&item)); +}