From 1b077af90e39cd05ba382b59d2053cbdeb9567b7 Mon Sep 17 00:00:00 2001 From: hexdec Date: Thu, 28 Aug 2014 01:48:49 +0200 Subject: [PATCH 01/28] Implemented window_staff_peep_fire. Added new window class WC_FIRE_PROMPT. --- src/window.h | 1 + src/window_staff_peep.c | 23 ++++++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/window.h b/src/window.h index eda9d5e0e1..1098eba380 100644 --- a/src/window.h +++ b/src/window.h @@ -340,6 +340,7 @@ enum { WC_PEEP = 23, WC_GUEST_LIST = 24, WC_STAFF_LIST = 25, + WC_FIRE_PROMPT = 26, WC_PARK_INFORMATION = 27, WC_FINANCES = 28, WC_TITLE_MENU = 29, diff --git a/src/window_staff_peep.c b/src/window_staff_peep.c index 8131d8bab9..74c74c9642 100644 --- a/src/window_staff_peep.c +++ b/src/window_staff_peep.c @@ -264,7 +264,28 @@ void window_staff_peep_close() /** rct2: 0x6C0A77 */ void window_staff_peep_fire(rct_window* w) { - RCT2_CALLPROC_X(0x6C0A77, 0, 0, 0, 0, (int)w, 0, 0); + // Check if the confirm window already exists. + if (window_bring_to_front_by_id(0x1A, w->number)) { + return; + } + + // Find center of the screen. + int screen_height = RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, sint16); + int screen_width = RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, sint16); + int x = screen_width/2 - 100; + int y = screen_height/2 - 50; + + rct_window* window_prompt = window_create(x, y, 200, 100, (uint32*)0x992C3C, 0x1A, 0); + window_prompt->widgets = (rct_widget*)0x9AFB4C; + window_prompt->enabled_widgets |= 0x4; + window_prompt->enabled_widgets |= 0x8; + window_prompt->enabled_widgets |= 0x10; + + window_init_scroll_widgets(window_prompt); + + window_prompt->flags |= 0x10; + window_prompt->number = w->number; + window_prompt->colours[0] = 0x9A; } /** From 4b8fbcfd28ac2a5048ebe2ca2e2473253435ed62 Mon Sep 17 00:00:00 2001 From: hexdec Date: Thu, 28 Aug 2014 16:28:19 +0200 Subject: [PATCH 02/28] Added order and stats events for window_staff_peep. --- src/window_staff_peep.c | 70 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 67 insertions(+), 3 deletions(-) diff --git a/src/window_staff_peep.c b/src/window_staff_peep.c index 74c74c9642..17c58beba9 100644 --- a/src/window_staff_peep.c +++ b/src/window_staff_peep.c @@ -115,13 +115,77 @@ static void* window_staff_peep_overview_events[] = { window_staff_peep_emptysub, (void*)0x6BDD91, //Invalidate (void*)0x6BDEAF, //Paint - (void*)0x6BE62A + window_staff_peep_emptysub +}; + +// 0x992B5C +static void* window_staff_peep_orders_events[] = { + window_staff_peep_emptysub, + (void*)0x6BE7DB, + (void*)0x6BE975, + (void*)0x6BE802, + (void*)0x6BE809, + (void*)0x6BE9DA, + (void*)0x6BE960, + window_staff_peep_emptysub, + window_staff_peep_emptysub, + window_staff_peep_emptysub, + window_staff_peep_emptysub, + window_staff_peep_emptysub, + window_staff_peep_emptysub, + window_staff_peep_emptysub, + window_staff_peep_emptysub, + window_staff_peep_emptysub, + window_staff_peep_emptysub, + window_staff_peep_emptysub, + window_staff_peep_emptysub, + window_staff_peep_emptysub, + window_staff_peep_emptysub, + window_staff_peep_emptysub, + window_staff_peep_emptysub, + window_staff_peep_emptysub, + window_staff_peep_emptysub, + (void*)0x6BE62B, //Invalidate + (void*)0x6BE7C6, //Paint + window_staff_peep_emptysub +}; + +// 0x992BCC +static void* window_staff_peep_stats_events[] = { + window_staff_peep_emptysub, + (void*)0x6BEBCF, + (void*)0x6BEC1B, + window_staff_peep_emptysub, + window_staff_peep_emptysub, + (void*)0x6BEC80, + (void*)0x6BEBEA, + window_staff_peep_emptysub, + window_staff_peep_emptysub, + window_staff_peep_emptysub, + window_staff_peep_emptysub, + window_staff_peep_emptysub, + window_staff_peep_emptysub, + window_staff_peep_emptysub, + window_staff_peep_emptysub, + window_staff_peep_emptysub, + window_staff_peep_emptysub, + window_staff_peep_emptysub, + window_staff_peep_emptysub, + window_staff_peep_emptysub, + window_staff_peep_emptysub, + window_staff_peep_emptysub, + window_staff_peep_emptysub, + window_staff_peep_emptysub, + window_staff_peep_emptysub, + (void*)0x6BE9E9, //Invalidate + (void*)0x6BEA86, //Paint + window_staff_peep_emptysub }; void* window_staff_peep_page_events[] = { window_staff_peep_overview_events, - (void*)0x992B5C, - (void*)0x992BCC + window_staff_peep_orders_events, + window_staff_peep_stats_events }; uint32 window_staff_peep_page_enabled_widgets[] = { From 5fdc66d446fa16788e05679bac0a3e95ac7bcdca Mon Sep 17 00:00:00 2001 From: hexdec Date: Thu, 28 Aug 2014 16:30:42 +0200 Subject: [PATCH 03/28] Renamed window_staff_peep_mouse_up to window_staff_peep_mouseup. --- src/window_staff_peep.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/window_staff_peep.c b/src/window_staff_peep.c index 17c58beba9..014692acf2 100644 --- a/src/window_staff_peep.c +++ b/src/window_staff_peep.c @@ -84,12 +84,12 @@ void window_staff_peep_set_page(rct_window* w, int page); void window_staff_peep_disable_widgets(rct_window* w); void window_staff_peep_close(); -void window_staff_peep_mouse_up(); +void window_staff_peep_mouseup(); // 0x992AEC static void* window_staff_peep_overview_events[] = { window_staff_peep_close, - window_staff_peep_mouse_up, + window_staff_peep_mouseup, (void*)0x6BE558, (void*)0x6BDF98, (void*)0x6BDFA3, @@ -401,7 +401,7 @@ void window_staff_peep_set_page(rct_window* w, int page) } /** rct2: 0x006BDF55 */ -void window_staff_peep_mouse_up() +void window_staff_peep_mouseup() { short widgetIndex; rct_window* w; From 77384e45faa6095165d0d917268b3f2a7fc03391 Mon Sep 17 00:00:00 2001 From: hexdec Date: Fri, 29 Aug 2014 00:58:09 +0200 Subject: [PATCH 04/28] Implemented mouseup for window_staff_peep. --- src/game.h | 2 +- src/window_staff_peep.c | 67 +++++++++++++++++++++++++++++++++++++++-- 2 files changed, 65 insertions(+), 4 deletions(-) diff --git a/src/game.h b/src/game.h index 0e1a95035b..1f87d944c0 100644 --- a/src/game.h +++ b/src/game.h @@ -54,7 +54,7 @@ enum GAME_COMMAND { GAME_COMMAND_HIRE_NEW_STAFF_MEMBER, // 29 GAME_COMMAND_30, GAME_COMMAND_31, - GAME_COMMAND_32, + GAME_COMMAND_SET_STAFF_ORDER, GAME_COMMAND_33, GAME_COMMAND_SET_PARK_OPEN, // 34 GAME_COMMAND_35, diff --git a/src/window_staff_peep.c b/src/window_staff_peep.c index 014692acf2..ffbad2eace 100644 --- a/src/window_staff_peep.c +++ b/src/window_staff_peep.c @@ -86,6 +86,10 @@ void window_staff_peep_disable_widgets(rct_window* w); void window_staff_peep_close(); void window_staff_peep_mouseup(); +void window_staff_peep_orders_mouseup(); + +void window_staff_peep_stats_mouseup(); + // 0x992AEC static void* window_staff_peep_overview_events[] = { window_staff_peep_close, @@ -121,7 +125,7 @@ static void* window_staff_peep_overview_events[] = { // 0x992B5C static void* window_staff_peep_orders_events[] = { window_staff_peep_emptysub, - (void*)0x6BE7DB, + window_staff_peep_orders_mouseup, (void*)0x6BE975, (void*)0x6BE802, (void*)0x6BE809, @@ -153,7 +157,7 @@ static void* window_staff_peep_orders_events[] = { // 0x992BCC static void* window_staff_peep_stats_events[] = { window_staff_peep_emptysub, - (void*)0x6BEBCF, + window_staff_peep_stats_mouseup, (void*)0x6BEC1B, window_staff_peep_emptysub, window_staff_peep_emptysub, @@ -409,7 +413,6 @@ void window_staff_peep_mouseup() rct_peep* peep = GET_PEEP(w->number); switch (widgetIndex) { - case WIDX_CLOSE: window_close(w); break; @@ -445,4 +448,62 @@ void window_staff_peep_mouseup() window_show_textinput(w, (int)widgetIndex, 0xBA1, 0xBA2, peep->name_string_idx); break; } +} + +/** rct2: 0x006BE814 */ +void window_staff_peep_set_order(rct_window* w, int order_id) +{ + int eax = 1 << order_id; + + rct_peep* peep = GET_PEEP(w->number); + + int ax = peep->var_C6 ^ eax; + int flags = (ax << 8) | 1; + + game_do_command(peep->x, flags, peep->y, w->number, GAME_COMMAND_SET_STAFF_ORDER, (int)peep, 0); +} + +/** rct2: 0x006BE7DB */ +void window_staff_peep_orders_mouseup() +{ + short widgetIndex; + rct_window* w; + window_widget_get_registers(w, widgetIndex); + + switch (widgetIndex) { + case WIDX_CLOSE: + window_close(w); + break; + case WIDX_TAB_1: + case WIDX_TAB_2: + case WIDX_TAB_3: + window_staff_peep_set_page(w, widgetIndex - WIDX_TAB_1); + break; + case WIDX_VIEWPORT: + case WIDX_BTM_LABEL: + case WIDX_PICKUP: + case WIDX_PATROL: + case WIDX_RENAME: + window_staff_peep_set_order(w, widgetIndex - 8); + break; + } +} + +/** rct2: 0x0006BEBCF */ +void window_staff_peep_stats_mouseup() +{ + short widgetIndex; + rct_window* w; + window_widget_get_registers(w, widgetIndex); + + switch (widgetIndex) { + case WIDX_CLOSE: + window_close(w); + break; + case WIDX_TAB_1: + case WIDX_TAB_2: + case WIDX_TAB_3: + window_staff_peep_set_page(w, widgetIndex - WIDX_TAB_1); + break; + } } \ No newline at end of file From a2324a278dc5eeef81d70d0ea9984dabf08a00be Mon Sep 17 00:00:00 2001 From: Jackson Davis Date: Thu, 28 Aug 2014 15:11:28 +0100 Subject: [PATCH 05/28] First pass at 0x407074 (mouse read) --- src/input.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/input.c b/src/input.c index 1d10cc4e05..55cf373728 100644 --- a/src/input.c +++ b/src/input.c @@ -43,6 +43,7 @@ static void input_mouseover_widget_flatbutton_invalidate(); void process_mouse_over(int x, int y); void sub_6ED801(int x, int y); void invalidate_scroll(); +static void* sub_407074(); #pragma region Scroll bar input @@ -1557,9 +1558,8 @@ void game_handle_input() */ static void game_get_next_input(int *x, int *y, int *state) { - int eax, ebx, ecx, edx, esi, edi, ebp; - RCT2_CALLFUNC_X(0x00407074, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); - if (eax == 0) { + void* eax = sub_407074(); //RCT2_CALLFUNC_X(0x00407074, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); + if (eax == NULL) { *x = gCursorState.x; *y = gCursorState.y; *state = 0; @@ -1762,4 +1762,19 @@ void invalidate_scroll() wind->scrolls[scroll_id / sizeof(rct_scroll)].flags &= 0xFF11; window_invalidate_by_id(RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWCLASS, uint8), RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWNUMBER, uint16)); -} \ No newline at end of file +} + +static void* sub_407074() +{ + int ecx = RCT2_GLOBAL(0x009E2DE8, uint32); + if (ecx != RCT2_GLOBAL(0x009E2DE4, uint32)) { + int eax = ecx + ecx*2; + ecx++; + ecx &= 0x3F; + eax = 0x1424340 + eax*4; + RCT2_GLOBAL(0x009E2DE8, uint32) = ecx; + return (void*)eax; + } else { + return NULL; + } +} From 57a2bc02febdc58055792cc7c415c08e8d65026f Mon Sep 17 00:00:00 2001 From: Jackson Davis Date: Fri, 29 Aug 2014 08:45:10 +0100 Subject: [PATCH 06/28] Add structs/addresses for mouse buffer functions --- src/addresses.h | 3 ++- src/input.c | 27 +++++++++++++-------------- src/osinterface.c | 39 ++++++++++++++++++--------------------- src/osinterface.h | 6 ++++++ 4 files changed, 39 insertions(+), 36 deletions(-) diff --git a/src/addresses.h b/src/addresses.h index 80ef4cbe20..589dc5e69e 100644 --- a/src/addresses.h +++ b/src/addresses.h @@ -169,7 +169,8 @@ #define RCT2_ADDRESS_DSOUND_DEVICES_COUNTER 0x009E2BAC #define RCT2_ADDRESS_CMDLINE 0x009E2D98 - +#define RCT2_ADDRESS_MOUSE_READ_INDEX 0x009E2DE8 +#define RCT2_ADDRESS_MOUSE_WRITE_INDEX 0x009E2DE4 #define RCT2_ADDRESS_LAND_RAISE_COST 0x009E2E1C #define RCT2_ADDRESS_LAND_LOWER_COST 0x009E2E20 #define RCT2_ADDRESS_SELECTED_TERRAIN_EDGE 0x009E2E24 diff --git a/src/input.c b/src/input.c index 55cf373728..85e1102131 100644 --- a/src/input.c +++ b/src/input.c @@ -43,7 +43,7 @@ static void input_mouseover_widget_flatbutton_invalidate(); void process_mouse_over(int x, int y); void sub_6ED801(int x, int y); void invalidate_scroll(); -static void* sub_407074(); +static openrct2_mouse_data* get_mouse_input(); #pragma region Scroll bar input @@ -1558,7 +1558,7 @@ void game_handle_input() */ static void game_get_next_input(int *x, int *y, int *state) { - void* eax = sub_407074(); //RCT2_CALLFUNC_X(0x00407074, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); + openrct2_mouse_data* eax = get_mouse_input(); if (eax == NULL) { *x = gCursorState.x; *y = gCursorState.y; @@ -1566,9 +1566,9 @@ static void game_get_next_input(int *x, int *y, int *state) return; } - *x = RCT2_GLOBAL(eax + 0, sint32); - *y = RCT2_GLOBAL(eax + 4, sint32); - *state = RCT2_GLOBAL(eax + 8, sint32); + *x = eax->x; + *y = eax->y; + *state = eax->state; //int eax, ebx, ecx, edx, esi, edi, ebp; //RCT2_CALLFUNC_X(0x006E83C7, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); @@ -1764,16 +1764,15 @@ void invalidate_scroll() window_invalidate_by_id(RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWCLASS, uint8), RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWNUMBER, uint16)); } -static void* sub_407074() +/** + * rct2: 0x00407074 + */ +static openrct2_mouse_data* get_mouse_input() { - int ecx = RCT2_GLOBAL(0x009E2DE8, uint32); - if (ecx != RCT2_GLOBAL(0x009E2DE4, uint32)) { - int eax = ecx + ecx*2; - ecx++; - ecx &= 0x3F; - eax = 0x1424340 + eax*4; - RCT2_GLOBAL(0x009E2DE8, uint32) = ecx; - return (void*)eax; + int read_index = RCT2_GLOBAL(RCT2_ADDRESS_MOUSE_READ_INDEX, uint32); + if (read_index != RCT2_GLOBAL(RCT2_ADDRESS_MOUSE_WRITE_INDEX, uint32)) { + RCT2_GLOBAL(RCT2_ADDRESS_MOUSE_READ_INDEX, uint32) = (read_index + 1) & 0x3F; + return &mouse_buffer[read_index]; } else { return NULL; } diff --git a/src/osinterface.c b/src/osinterface.c index 9213603e7d..73a7b25e6b 100644 --- a/src/osinterface.c +++ b/src/osinterface.c @@ -40,11 +40,12 @@ openrct2_cursor gCursorState; const unsigned char *gKeysState; unsigned char *gKeysPressed; unsigned int gLastKeyPressed; +openrct2_mouse_data* mouse_buffer = (openrct2_mouse_data*)0x1424340; static void osinterface_create_window(); static void osinterface_close_window(); static void osinterface_resize(int width, int height); -static void sub_406C96(int actionType); +static void store_mouse_input(int state); static SDL_Window *_window; static SDL_Surface *_surface; @@ -350,7 +351,7 @@ void osinterface_process_messages() RCT2_GLOBAL(0x0142431C, int) = e.button.y; switch (e.button.button) { case SDL_BUTTON_LEFT: - sub_406C96(1); //RCT2_CALLPROC_1(0x00406C96, int, 1); + store_mouse_input(1); gCursorState.left = CURSOR_PRESSED; gCursorState.old = 1; break; @@ -358,7 +359,7 @@ void osinterface_process_messages() gCursorState.middle = CURSOR_PRESSED; break; case SDL_BUTTON_RIGHT: - sub_406C96(3); //RCT2_CALLPROC_1(0x00406C96, int, 3); + store_mouse_input(3); gCursorState.right = CURSOR_PRESSED; gCursorState.old = 2; break; @@ -369,7 +370,7 @@ void osinterface_process_messages() RCT2_GLOBAL(0x0142431C, int) = e.button.y; switch (e.button.button) { case SDL_BUTTON_LEFT: - sub_406C96(2); //RCT2_CALLPROC_1(0x00406C96, int, 2); + store_mouse_input(2); gCursorState.left = CURSOR_RELEASED; gCursorState.old = 3; break; @@ -377,7 +378,7 @@ void osinterface_process_messages() gCursorState.middle = CURSOR_RELEASED; break; case SDL_BUTTON_RIGHT: - sub_406C96(4); //RCT2_CALLPROC_1(0x00406C96, int, 4); + store_mouse_input(4); gCursorState.right = CURSOR_RELEASED; gCursorState.old = 4; break; @@ -599,22 +600,18 @@ char osinterface_get_path_separator() return '\\'; } -void sub_406C96(int actionType) +/** + * rct2: 0x00406C96 + */ +static void store_mouse_input(int state) { - int eax = RCT2_GLOBAL(0x009E2DE4, uint32); - int ecx = eax + 1; - ecx &= 0x3F; //Array of 64 point structs, loop around buffer? - if (ecx != RCT2_GLOBAL(0x009E2DE8, uint32)) { - int edx = RCT2_GLOBAL(0x01424318, uint32); // X - //eax is a struct index here. Mutliplied by then and then 4 for the struct with 3 4 byte fields - //Struct is {int x, int y, int actionType} - eax = eax + eax*2; - eax = 0x01424340 + eax * 4; //get base of struct, address is base of array - *((uint32*)eax) = edx; - edx = RCT2_GLOBAL(0x0142431C, uint32); // Y - *((uint32*)eax + 1) = edx; - edx = actionType; - *((uint32*)eax + 2) = edx; - RCT2_GLOBAL(0x009E2DE4, uint32) = ecx; + int write_index = RCT2_GLOBAL(RCT2_ADDRESS_MOUSE_WRITE_INDEX, uint32); + int next_write_index = (write_index + 1) & 0x3F; //64 length buffer + + if (next_write_index != RCT2_GLOBAL(RCT2_ADDRESS_MOUSE_READ_INDEX, uint32)) { + mouse_buffer[write_index].x = RCT2_GLOBAL(0x01424318, uint32); + mouse_buffer[write_index].y = RCT2_GLOBAL(0x0142431C, uint32); + mouse_buffer[write_index].state = state; + RCT2_GLOBAL(RCT2_ADDRESS_MOUSE_WRITE_INDEX, uint32) = next_write_index; } } diff --git a/src/osinterface.h b/src/osinterface.h index 6d2cade7aa..75fc3b19f1 100644 --- a/src/osinterface.h +++ b/src/osinterface.h @@ -66,6 +66,12 @@ typedef struct { int old; } openrct2_cursor; +typedef struct { + int x, y; + int state; //0 = ? 1 = LeftDown 2 = LeftUp 3 = RightDown 4 = RightUp +} openrct2_mouse_data; + +extern openrct2_mouse_data* mouse_buffer; extern openrct2_cursor gCursorState; extern const unsigned char *gKeysState; extern unsigned char *gKeysPressed; From f5841c24f4a02e22eb89aa91a2117713edc60c30 Mon Sep 17 00:00:00 2001 From: adrian17 Date: Fri, 29 Aug 2014 10:23:57 +0200 Subject: [PATCH 07/28] Move input functions and add an address --- src/addresses.h | 8 ++++++-- src/input.c | 47 ++++++++++++++++++++++++++++++++++++++--------- src/input.h | 2 ++ src/osinterface.c | 21 ++------------------- src/osinterface.h | 6 ------ 5 files changed, 48 insertions(+), 36 deletions(-) diff --git a/src/addresses.h b/src/addresses.h index 589dc5e69e..d46574cc45 100644 --- a/src/addresses.h +++ b/src/addresses.h @@ -169,8 +169,10 @@ #define RCT2_ADDRESS_DSOUND_DEVICES_COUNTER 0x009E2BAC #define RCT2_ADDRESS_CMDLINE 0x009E2D98 -#define RCT2_ADDRESS_MOUSE_READ_INDEX 0x009E2DE8 -#define RCT2_ADDRESS_MOUSE_WRITE_INDEX 0x009E2DE4 + +#define RCT2_ADDRESS_MOUSE_READ_INDEX 0x009E2DE8 +#define RCT2_ADDRESS_MOUSE_WRITE_INDEX 0x009E2DE4 + #define RCT2_ADDRESS_LAND_RAISE_COST 0x009E2E1C #define RCT2_ADDRESS_LAND_LOWER_COST 0x009E2E20 #define RCT2_ADDRESS_SELECTED_TERRAIN_EDGE 0x009E2E24 @@ -406,6 +408,8 @@ #define RCT2_ADDRESS_SCREEN_CAP_BPP 0x01423C10 #define RCT2_ADDRESS_SCREEN_CAP_RASTER_STRETCH 0x01423C14 +#define RCT2_ADDRESS_INPUT_QUEUE 0x01424340 + static void RCT2_CALLPROC_EBPSAFE(int address) { #ifdef _MSC_VER diff --git a/src/input.c b/src/input.c index 85e1102131..38d75468f8 100644 --- a/src/input.c +++ b/src/input.c @@ -36,6 +36,13 @@ POINT _dragPosition; +typedef struct { + uint32 x, y; + uint32 state; //1 = LeftDown 2 = LeftUp 3 = RightDown 4 = RightUp +} rct_mouse_data; + +rct_mouse_data* mouse_buffer = RCT2_ADDRESS(RCT2_ADDRESS_INPUT_QUEUE, rct_mouse_data); + static void game_get_next_input(int *x, int *y, int *state); static void input_mouseover(int x, int y, rct_window *w, int widgetIndex); static void input_mouseover_widget_check(rct_windowclass windowClass, rct_windownumber windowNumber, int widgetIndex); @@ -43,7 +50,7 @@ static void input_mouseover_widget_flatbutton_invalidate(); void process_mouse_over(int x, int y); void sub_6ED801(int x, int y); void invalidate_scroll(); -static openrct2_mouse_data* get_mouse_input(); +static rct_mouse_data* get_mouse_input(); #pragma region Scroll bar input @@ -1558,7 +1565,7 @@ void game_handle_input() */ static void game_get_next_input(int *x, int *y, int *state) { - openrct2_mouse_data* eax = get_mouse_input(); + rct_mouse_data* eax = get_mouse_input(); if (eax == NULL) { *x = gCursorState.x; *y = gCursorState.y; @@ -1764,16 +1771,38 @@ void invalidate_scroll() window_invalidate_by_id(RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWCLASS, uint8), RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWNUMBER, uint16)); } +/** +* rct2: 0x00406C96 +*/ +void store_mouse_input(int state) +{ + uint32 write_index = RCT2_GLOBAL(RCT2_ADDRESS_MOUSE_WRITE_INDEX, uint32); + uint32 next_write_index = (write_index + 1) % 64; + + // check if the queue is full + if (next_write_index == RCT2_GLOBAL(RCT2_ADDRESS_MOUSE_READ_INDEX, uint32)) + return; + + rct_mouse_data* item = &mouse_buffer[write_index]; + item->x = RCT2_GLOBAL(0x01424318, uint32); + item->y = RCT2_GLOBAL(0x0142431C, uint32); + item->state = state; + + RCT2_GLOBAL(RCT2_ADDRESS_MOUSE_WRITE_INDEX, uint32) = next_write_index; +} + + /** * rct2: 0x00407074 */ -static openrct2_mouse_data* get_mouse_input() +static rct_mouse_data* get_mouse_input() { - int read_index = RCT2_GLOBAL(RCT2_ADDRESS_MOUSE_READ_INDEX, uint32); - if (read_index != RCT2_GLOBAL(RCT2_ADDRESS_MOUSE_WRITE_INDEX, uint32)) { - RCT2_GLOBAL(RCT2_ADDRESS_MOUSE_READ_INDEX, uint32) = (read_index + 1) & 0x3F; - return &mouse_buffer[read_index]; - } else { + uint32 read_index = RCT2_GLOBAL(RCT2_ADDRESS_MOUSE_READ_INDEX, uint32); + + // check if that location has been written to yet + if (read_index == RCT2_GLOBAL(RCT2_ADDRESS_MOUSE_WRITE_INDEX, uint32)) return NULL; - } + + RCT2_GLOBAL(RCT2_ADDRESS_MOUSE_READ_INDEX, uint32) = (read_index + 1) % 64; + return &mouse_buffer[read_index]; } diff --git a/src/input.h b/src/input.h index a7a1d8ebb6..dd1cc5b3fb 100644 --- a/src/input.h +++ b/src/input.h @@ -24,4 +24,6 @@ void game_handle_input(); void game_handle_keyboard_input(); +void store_mouse_input(int state); + #endif \ No newline at end of file diff --git a/src/osinterface.c b/src/osinterface.c index 73a7b25e6b..fd6aef4b17 100644 --- a/src/osinterface.c +++ b/src/osinterface.c @@ -28,6 +28,7 @@ #include "addresses.h" #include "config.h" #include "gfx.h" +#include "input.h" #include "osinterface.h" #include "screenshot.h" #include "window.h" @@ -40,12 +41,10 @@ openrct2_cursor gCursorState; const unsigned char *gKeysState; unsigned char *gKeysPressed; unsigned int gLastKeyPressed; -openrct2_mouse_data* mouse_buffer = (openrct2_mouse_data*)0x1424340; static void osinterface_create_window(); static void osinterface_close_window(); static void osinterface_resize(int width, int height); -static void store_mouse_input(int state); static SDL_Window *_window; static SDL_Surface *_surface; @@ -598,20 +597,4 @@ int osinterface_ensure_directory_exists(const char *path) char osinterface_get_path_separator() { return '\\'; -} - -/** - * rct2: 0x00406C96 - */ -static void store_mouse_input(int state) -{ - int write_index = RCT2_GLOBAL(RCT2_ADDRESS_MOUSE_WRITE_INDEX, uint32); - int next_write_index = (write_index + 1) & 0x3F; //64 length buffer - - if (next_write_index != RCT2_GLOBAL(RCT2_ADDRESS_MOUSE_READ_INDEX, uint32)) { - mouse_buffer[write_index].x = RCT2_GLOBAL(0x01424318, uint32); - mouse_buffer[write_index].y = RCT2_GLOBAL(0x0142431C, uint32); - mouse_buffer[write_index].state = state; - RCT2_GLOBAL(RCT2_ADDRESS_MOUSE_WRITE_INDEX, uint32) = next_write_index; - } -} +} \ No newline at end of file diff --git a/src/osinterface.h b/src/osinterface.h index 75fc3b19f1..6d2cade7aa 100644 --- a/src/osinterface.h +++ b/src/osinterface.h @@ -66,12 +66,6 @@ typedef struct { int old; } openrct2_cursor; -typedef struct { - int x, y; - int state; //0 = ? 1 = LeftDown 2 = LeftUp 3 = RightDown 4 = RightUp -} openrct2_mouse_data; - -extern openrct2_mouse_data* mouse_buffer; extern openrct2_cursor gCursorState; extern const unsigned char *gKeysState; extern unsigned char *gKeysPressed; From 6473da43b27ea0c87c3a2d0fb45855ddeb9a8c6f Mon Sep 17 00:00:00 2001 From: adrian17 Date: Fri, 29 Aug 2014 11:37:32 +0200 Subject: [PATCH 08/28] Decompiled game_command_set_park_entrance_fee --- src/game.c | 3 ++- src/park.c | 36 ++++++++++++++++++++++++++++++++++++ src/park.h | 2 ++ 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/src/game.c b/src/game.c index f67b6f9279..30f4df92b1 100644 --- a/src/game.c +++ b/src/game.c @@ -29,6 +29,7 @@ #include "news_item.h" #include "object.h" #include "osinterface.h" +#include "park.h" #include "peep.h" #include "sawyercoding.h" #include "scenario.h" @@ -942,7 +943,7 @@ static uint32 game_do_command_table[58] = { 0x006666E7, 0x00666A63, 0x006CD8CE, - 0x00669E30, + (uint32)game_command_set_park_entrance_fee, (uint32)game_command_update_staff_colour, // 40 0x006E519A, 0x006E5597, diff --git a/src/park.c b/src/park.c index 159017c392..da3731efc9 100644 --- a/src/park.c +++ b/src/park.c @@ -581,4 +581,40 @@ uint8 calculate_guest_initial_happiness(uint8 percentage) { void park_update_histories() { RCT2_CALLPROC_EBPSAFE(0x0066A231); +} + +/** +* +* rct2: 0x00669E30 +*/ +void game_command_set_park_entrance_fee() +{ + uint8 _bl; + uint16 new_fee; + + #ifdef _MSC_VER + __asm mov _bl, bl + #else + __asm__("mov %[_bl], bl " : [_bl] "+m" (_bl)); + #endif + + #ifdef _MSC_VER + __asm mov new_fee, di + #else + __asm__("mov %[new_fee], di " : [new_fee] "+m" (new_fee)); + #endif + + RCT2_GLOBAL(0x0141F56C, uint8) = 0x10; + + if (_bl & 1){ + RCT2_GLOBAL(RCT2_ADDRESS_PARK_ENTRANCE_FEE, uint16) = new_fee; + + window_invalidate_by_id(WC_PARK_INFORMATION, 0); + } + + #ifdef _MSC_VER + __asm mov ebx, 0 + #else + __asm__("mov ebx, 0 "); + #endif } \ No newline at end of file diff --git a/src/park.h b/src/park.h index bb7d823e86..5c9a85171a 100644 --- a/src/park.h +++ b/src/park.h @@ -59,4 +59,6 @@ void park_update_histories(); uint8 calculate_guest_initial_happiness(uint8 percentage); +void game_command_set_park_entrance_fee(); + #endif From 199946d6821296bea6ca07026d30117d0a582e9a Mon Sep 17 00:00:00 2001 From: hexdec Date: Fri, 29 Aug 2014 02:03:20 +0200 Subject: [PATCH 09/28] Added window_staff_peep_stats_resize. --- src/window_staff_peep.c | 43 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 38 insertions(+), 5 deletions(-) diff --git a/src/window_staff_peep.c b/src/window_staff_peep.c index ffbad2eace..4ab380d324 100644 --- a/src/window_staff_peep.c +++ b/src/window_staff_peep.c @@ -89,6 +89,7 @@ void window_staff_peep_mouseup(); void window_staff_peep_orders_mouseup(); void window_staff_peep_stats_mouseup(); +void window_staff_peep_stats_resize(); // 0x992AEC static void* window_staff_peep_overview_events[] = { @@ -126,11 +127,11 @@ static void* window_staff_peep_overview_events[] = { static void* window_staff_peep_orders_events[] = { window_staff_peep_emptysub, window_staff_peep_orders_mouseup, - (void*)0x6BE975, + window_staff_peep_stats_resize, (void*)0x6BE802, (void*)0x6BE809, (void*)0x6BE9DA, - (void*)0x6BE960, + (void*)0x6BE960, // update window_staff_peep_emptysub, window_staff_peep_emptysub, window_staff_peep_emptysub, @@ -158,11 +159,11 @@ static void* window_staff_peep_orders_events[] = { static void* window_staff_peep_stats_events[] = { window_staff_peep_emptysub, window_staff_peep_stats_mouseup, - (void*)0x6BEC1B, + window_staff_peep_stats_resize, window_staff_peep_emptysub, window_staff_peep_emptysub, (void*)0x6BEC80, - (void*)0x6BEBEA, + (void*)0x6BEBEA, // update window_staff_peep_emptysub, window_staff_peep_emptysub, window_staff_peep_emptysub, @@ -489,7 +490,7 @@ void window_staff_peep_orders_mouseup() } } -/** rct2: 0x0006BEBCF */ +/** rct2: 0x006BEBCF */ void window_staff_peep_stats_mouseup() { short widgetIndex; @@ -506,4 +507,36 @@ void window_staff_peep_stats_mouseup() window_staff_peep_set_page(w, widgetIndex - WIDX_TAB_1); break; } +} + +/** rct2: 0x006BEC1B and rct2: 0x006BE975 */ +void window_staff_peep_stats_resize() +{ + rct_window* w; + window_get_register(w); + + w->min_width = 190; + w->max_width = 190; + w->min_height = 119; + w->max_height = 119; + + if (w->width < w->min_width) { + w->width = w->min_width; + window_invalidate(w); + } + + if (w->width > w->max_width) { + window_invalidate(w); + w->width = w->max_width; + } + + if (w->height < w->min_height) { + w->height = w->min_height; + window_invalidate(w); + } + + if (w->height > w->max_height) { + window_invalidate(w); + w->height = w->max_height; + } } \ No newline at end of file From 5bd35057712431a01a6244e66a0a7859d843b941 Mon Sep 17 00:00:00 2001 From: hexdec Date: Fri, 29 Aug 2014 15:51:47 +0200 Subject: [PATCH 10/28] Implemented window_staff_peep_overview_resize. --- src/window_staff_peep.c | 66 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 59 insertions(+), 7 deletions(-) diff --git a/src/window_staff_peep.c b/src/window_staff_peep.c index 4ab380d324..9b8c3b3594 100644 --- a/src/window_staff_peep.c +++ b/src/window_staff_peep.c @@ -83,8 +83,9 @@ rct_widget *window_staff_peep_page_widgets[] = { void window_staff_peep_set_page(rct_window* w, int page); void window_staff_peep_disable_widgets(rct_window* w); -void window_staff_peep_close(); -void window_staff_peep_mouseup(); +void window_staff_peep_overview_close(); +void window_staff_peep_overview_mouseup(); +void window_staff_peep_overview_resize(); void window_staff_peep_orders_mouseup(); @@ -93,9 +94,9 @@ void window_staff_peep_stats_resize(); // 0x992AEC static void* window_staff_peep_overview_events[] = { - window_staff_peep_close, - window_staff_peep_mouseup, - (void*)0x6BE558, + window_staff_peep_overview_close, + window_staff_peep_overview_mouseup, + window_staff_peep_overview_resize, (void*)0x6BDF98, (void*)0x6BDFA3, window_staff_peep_emptysub, @@ -317,7 +318,7 @@ void window_staff_peep_disable_widgets(rct_window* w) * Same as window_peep_close. * rct2: 0x006BDFF8 */ -void window_staff_peep_close() +void window_staff_peep_overview_close() { rct_window* w; @@ -406,7 +407,7 @@ void window_staff_peep_set_page(rct_window* w, int page) } /** rct2: 0x006BDF55 */ -void window_staff_peep_mouseup() +void window_staff_peep_overview_mouseup() { short widgetIndex; rct_window* w; @@ -451,6 +452,57 @@ void window_staff_peep_mouseup() } } +/** rct2: 0x006BE558 */ +void window_staff_peep_overview_resize() +{ + rct_window* w; + window_get_register(w); + + window_staff_peep_disable_widgets(w); + + w->min_width = 190; + w->max_width = 500; + w->min_height = 180; + w->max_height = 450; + + if (w->width < w->min_width) { + w->width = w->min_width; + window_invalidate(w); + } + + if (w->width > w->max_width) { + window_invalidate(w); + w->width = w->max_width; + } + + if (w->height < w->min_height) { + w->height = w->min_height; + window_invalidate(w); + } + + if (w->height > w->max_height) { + window_invalidate(w); + w->height = w->max_height; + } + + rct_viewport* viewport = w->viewport; + + if (viewport) { + int new_width = w->width - 30; + int new_height = w->height - 62; + + // Update the viewport size + if (viewport->width != new_width || viewport->height != new_height) { + viewport->width = new_width; + viewport->height = new_height; + viewport->view_width = new_width << viewport->zoom; + viewport->view_height = new_height << viewport->zoom; + } + } + + RCT2_CALLPROC_X(0x006BEDA3, 0, 0, 0, 0, (int)w, 0, 0); +} + /** rct2: 0x006BE814 */ void window_staff_peep_set_order(rct_window* w, int order_id) { From ced3c20bb1d2648808361f0c3d5d8b84284ac6cd Mon Sep 17 00:00:00 2001 From: hexdec Date: Fri, 29 Aug 2014 18:13:17 +0200 Subject: [PATCH 11/28] Implemented overview_mousedown. --- src/window_staff_peep.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/src/window_staff_peep.c b/src/window_staff_peep.c index 9b8c3b3594..1c24249faa 100644 --- a/src/window_staff_peep.c +++ b/src/window_staff_peep.c @@ -86,6 +86,7 @@ void window_staff_peep_disable_widgets(rct_window* w); void window_staff_peep_overview_close(); void window_staff_peep_overview_mouseup(); void window_staff_peep_overview_resize(); +void window_staff_peep_overview_mousedown(int widgetIndex, rct_window*w, rct_widget* widget); void window_staff_peep_orders_mouseup(); @@ -97,7 +98,7 @@ static void* window_staff_peep_overview_events[] = { window_staff_peep_overview_close, window_staff_peep_overview_mouseup, window_staff_peep_overview_resize, - (void*)0x6BDF98, + window_staff_peep_overview_mousedown, (void*)0x6BDFA3, window_staff_peep_emptysub, (void*)0x6BE602, @@ -503,6 +504,34 @@ void window_staff_peep_overview_resize() RCT2_CALLPROC_X(0x006BEDA3, 0, 0, 0, 0, (int)w, 0, 0); } +/** + * Handle the dropdown of patrol button. + * rct2: 0x006BDF98 + */ +void window_staff_peep_overview_mousedown(int widgetIndex, rct_window* w, rct_widget* widget) +{ + if (widgetIndex != WIDX_PATROL) { + return; + } + + // Dropdown names + gDropdownItemsFormat[0] = 0xD75; + gDropdownItemsFormat[1] = 0xD76; + + int x = widget->left + w->x; + int y = widget->top + w->y;; + int extray = widget->bottom - widget->top + 1; + window_dropdown_show_text(x, y, extray, w->colours[1], 0, 2); + RCT2_GLOBAL(0x009DEBA2, sint16) = 0; + + rct_peep* peep = GET_PEEP(w->number); + + // Disable clear patrol area if no area is set. + if (!(RCT2_ADDRESS(0x013CA672, uint8)[peep->var_C5] & 2)) { + RCT2_GLOBAL(0x009DED34, sint32) |= 1 << 1; + } +} + /** rct2: 0x006BE814 */ void window_staff_peep_set_order(rct_window* w, int order_id) { From 87171772899afae8c0ab2f25a334593a76eca86d Mon Sep 17 00:00:00 2001 From: hexdec Date: Fri, 29 Aug 2014 18:13:32 +0200 Subject: [PATCH 12/28] Implemented overview_dropdown. --- src/window_staff_peep.c | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/src/window_staff_peep.c b/src/window_staff_peep.c index 1c24249faa..d19be616f9 100644 --- a/src/window_staff_peep.c +++ b/src/window_staff_peep.c @@ -87,6 +87,7 @@ void window_staff_peep_overview_close(); void window_staff_peep_overview_mouseup(); void window_staff_peep_overview_resize(); void window_staff_peep_overview_mousedown(int widgetIndex, rct_window*w, rct_widget* widget); +void window_staff_peep_overview_dropdown(); void window_staff_peep_orders_mouseup(); @@ -99,7 +100,7 @@ static void* window_staff_peep_overview_events[] = { window_staff_peep_overview_mouseup, window_staff_peep_overview_resize, window_staff_peep_overview_mousedown, - (void*)0x6BDFA3, + window_staff_peep_overview_dropdown, window_staff_peep_emptysub, (void*)0x6BE602, window_staff_peep_emptysub, @@ -532,6 +533,42 @@ void window_staff_peep_overview_mousedown(int widgetIndex, rct_window* w, rct_wi } } +/** rct2: 0x006BDFA3 */ +void window_staff_peep_overview_dropdown() +{ + short widgetIndex, dropdownIndex; + rct_window* w; + + window_dropdown_get_registers(w, widgetIndex, dropdownIndex); + + if (widgetIndex != WIDX_PATROL) { + return; + } + + // Clear patrol + if (dropdownIndex == 1) { + rct_peep* peep = GET_PEEP(w->number); + int edi = peep->var_C5; + int ebx = edi << 9; + + for (int i = 0; i < 128; i++) + { + RCT2_GLOBAL(0x13B0E72 + ebx + i * 4, uint32) = 0; + } + RCT2_GLOBAL(0x13CA672 + edi, uint16) &= 0xFD; // bug?? + + window_invalidate(w); + RCT2_CALLPROC_EBPSAFE(0x006C0C3F); + } + else { + if (!tool_set(w, widgetIndex, 22)) { + show_gridlines(); + RCT2_GLOBAL(0x009DEA50, sint16) = w->number; + window_invalidate(w); + } + } +} + /** rct2: 0x006BE814 */ void window_staff_peep_set_order(rct_window* w, int order_id) { From 9039c196399153f483adb724f6e7ae5281bb1fdd Mon Sep 17 00:00:00 2001 From: hexdec Date: Fri, 29 Aug 2014 18:32:06 +0200 Subject: [PATCH 13/28] Implemented overview_update. --- src/window_staff_peep.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/window_staff_peep.c b/src/window_staff_peep.c index d19be616f9..7a6d76b283 100644 --- a/src/window_staff_peep.c +++ b/src/window_staff_peep.c @@ -88,6 +88,7 @@ void window_staff_peep_overview_mouseup(); void window_staff_peep_overview_resize(); void window_staff_peep_overview_mousedown(int widgetIndex, rct_window*w, rct_widget* widget); void window_staff_peep_overview_dropdown(); +void window_staff_peep_overview_update(rct_window *w); void window_staff_peep_orders_mouseup(); @@ -102,7 +103,7 @@ static void* window_staff_peep_overview_events[] = { window_staff_peep_overview_mousedown, window_staff_peep_overview_dropdown, window_staff_peep_emptysub, - (void*)0x6BE602, + window_staff_peep_overview_update, window_staff_peep_emptysub, window_staff_peep_emptysub, (void*)0x6BDFD8, @@ -569,6 +570,21 @@ void window_staff_peep_overview_dropdown() } } +/** + * Update the animation frame of the tab icon. + * rct2: 0x6BE602 + */ +void window_staff_peep_overview_update(rct_window* w) +{ + int var_496 = RCT2_GLOBAL((int)w + 0x496, uint16); + var_496++; + if (var_496 >= 24) { + var_496 = 0; + } + RCT2_GLOBAL((int)w + 0x496, uint16) = var_496; + window_invalidate_by_id(0x497, w->number); +} + /** rct2: 0x006BE814 */ void window_staff_peep_set_order(rct_window* w, int order_id) { From c50b9d12149bc36799dd56215a8372ed055e57ca Mon Sep 17 00:00:00 2001 From: hexdec Date: Fri, 29 Aug 2014 20:08:48 +0200 Subject: [PATCH 14/28] Implemented stats_update and orders_update. --- src/window_staff_peep.c | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/src/window_staff_peep.c b/src/window_staff_peep.c index 7a6d76b283..c531f8d1e6 100644 --- a/src/window_staff_peep.c +++ b/src/window_staff_peep.c @@ -86,14 +86,16 @@ void window_staff_peep_disable_widgets(rct_window* w); void window_staff_peep_overview_close(); void window_staff_peep_overview_mouseup(); void window_staff_peep_overview_resize(); -void window_staff_peep_overview_mousedown(int widgetIndex, rct_window*w, rct_widget* widget); +void window_staff_peep_overview_mousedown(int widgetIndex, rct_window* w, rct_widget* widget); void window_staff_peep_overview_dropdown(); -void window_staff_peep_overview_update(rct_window *w); +void window_staff_peep_overview_update(rct_window* w); void window_staff_peep_orders_mouseup(); +void window_staff_peep_orders_update(rct_window* w); void window_staff_peep_stats_mouseup(); void window_staff_peep_stats_resize(); +void window_staff_peep_stats_update(rct_window* w); // 0x992AEC static void* window_staff_peep_overview_events[] = { @@ -135,7 +137,7 @@ static void* window_staff_peep_orders_events[] = { (void*)0x6BE802, (void*)0x6BE809, (void*)0x6BE9DA, - (void*)0x6BE960, // update + window_staff_peep_orders_update, window_staff_peep_emptysub, window_staff_peep_emptysub, window_staff_peep_emptysub, @@ -167,7 +169,7 @@ static void* window_staff_peep_stats_events[] = { window_staff_peep_emptysub, window_staff_peep_emptysub, (void*)0x6BEC80, - (void*)0x6BEBEA, // update + window_staff_peep_stats_update, window_staff_peep_emptysub, window_staff_peep_emptysub, window_staff_peep_emptysub, @@ -624,6 +626,13 @@ void window_staff_peep_orders_mouseup() } } +/** rct2: 0x006BE960 */ +void window_staff_peep_orders_update(rct_window* w) +{ + w->frame_no++; + window_invalidate_by_id(0x597, w->number); +} + /** rct2: 0x006BEBCF */ void window_staff_peep_stats_mouseup() { @@ -673,4 +682,17 @@ void window_staff_peep_stats_resize() window_invalidate(w); w->height = w->max_height; } +} + +/** rct2: 0x006BEBEA */ +void window_staff_peep_stats_update(rct_window* w) +{ + w->frame_no++; + window_invalidate_by_id(0x697, w->number); + + rct_peep* peep = GET_PEEP(w->number); + if (peep->var_45 && 10) { + peep->var_45 &= 0xEF; + window_invalidate(w); + } } \ No newline at end of file From 24331b781d350d80f7224f7441599052497f94bb Mon Sep 17 00:00:00 2001 From: wolfreak99 Date: Sat, 30 Aug 2014 00:17:01 -0400 Subject: [PATCH 15/28] Corrected about window's credits. Switched the callproc values in the credits to open the proper music/publisher credits. --- src/window_about.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/window_about.c b/src/window_about.c index 6f968ada89..8cf3418380 100644 --- a/src/window_about.c +++ b/src/window_about.c @@ -125,10 +125,10 @@ static void window_about_mouseup() window_close(w); break; case WIDX_MUSIC_CREDITS: - RCT2_CALLPROC_EBPSAFE(0x0066D4EC); + RCT2_CALLPROC_EBPSAFE(0x0066D55B); break; case WIDX_PUBLISHER_CREDITS: - RCT2_CALLPROC_EBPSAFE(0x0066D55B); + RCT2_CALLPROC_EBPSAFE(0x0066D4EC); break; } } @@ -193,4 +193,4 @@ static void window_about_paint() // Licence gfx_draw_string_left(dpi, STR_LICENSED_TO_INFOGRAMES_INTERACTIVE_INC, 0, 0, w->x + 157, w->y + 257); -} \ No newline at end of file +} From 4d29aaa6bd41495cdf09a078478183e421fde721 Mon Sep 17 00:00:00 2001 From: adrian17 Date: Sat, 30 Aug 2014 14:31:36 +0200 Subject: [PATCH 16/28] Fix #385, made widget_is_enabled return 1 if true --- src/input.c | 7 ++----- src/widget.c | 4 ++-- src/window.c | 4 ++-- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/input.c b/src/input.c index 38d75468f8..437a791c92 100644 --- a/src/input.c +++ b/src/input.c @@ -530,11 +530,8 @@ static void input_leftmousedown(int x, int y, rct_window *w, int widgetIndex) } break; default: - // comment check as it disables the rotate station/building button in construction window -// if (!widget_is_enabled(w, widgetIndex)) -// break; - if (widget_is_disabled(w, widgetIndex)) - break; + if (!widget_is_enabled(w, widgetIndex)) + break; sound_play_panned(SOUND_CLICK_1, w->x + (widget->left + widget->right) / 2); diff --git a/src/widget.c b/src/widget.c index 1006ca3f13..22226cd78f 100644 --- a/src/widget.c +++ b/src/widget.c @@ -946,12 +946,12 @@ static void widget_draw_image(rct_drawpixelinfo *dpi, rct_window *w, int widgetI int widget_is_enabled(rct_window *w, int widgetIndex) { - return w->enabled_widgets & (1LL << widgetIndex); + return (w->enabled_widgets & (1LL << widgetIndex)) ? 1 : 0; } int widget_is_disabled(rct_window *w, int widgetIndex) { - return w->disabled_widgets & (1LL << widgetIndex); + return (w->disabled_widgets & (1LL << widgetIndex)) ? 1 : 0; } int widget_is_pressed(rct_window *w, int widgetIndex) diff --git a/src/window.c b/src/window.c index 27429674d7..355d5770bf 100644 --- a/src/window.c +++ b/src/window.c @@ -1150,7 +1150,7 @@ void window_draw_widgets(rct_window *w, rct_drawpixelinfo *dpi) if ((w->flags & WF_TRANSPARENT) && !(w->flags & WF_5)) gfx_fill_rect(dpi, w->x, w->y, w->x + w->width - 1, w->y + w->height - 1, 0x2000000 | 51); - //some code missing here? Between 006EB18C and 006EB260 + //todo: some code missing here? Between 006EB18C and 006EB260 widgetIndex = 0; for (widget = w->widgets; widget->type != WWT_LAST; widget++) { @@ -1162,7 +1162,7 @@ void window_draw_widgets(rct_window *w, rct_drawpixelinfo *dpi) widgetIndex++; } - //something missing here too? Between 006EC32B and 006EC369 + //todo: something missing here too? Between 006EC32B and 006EC369 if (w->flags & WF_WHITE_BORDER_MASK) { gfx_fill_rect_inset(dpi, w->x, w->y, w->x + w->width - 1, w->y + w->height - 1, 2, 0x10); From 5e96da663407ca1e081483baa521d44811769be7 Mon Sep 17 00:00:00 2001 From: Patrick Wijnings Date: Sat, 30 Aug 2014 15:11:19 +0200 Subject: [PATCH 17/28] Fix definition of PARK_FLAGS_NO_MONEY flag and clean up related code. --- src/award.c | 4 ++-- src/finance.c | 33 ++++++++++++++++++++++++++++---- src/finance.h | 1 + src/game.c | 2 +- src/park.c | 4 ++-- src/park.h | 4 ++-- src/scenario.c | 4 ++-- src/window_game_bottom_toolbar.c | 6 +++--- src/window_park.c | 15 +++++++++++++-- src/window_staff.c | 2 +- 10 files changed, 56 insertions(+), 19 deletions(-) diff --git a/src/award.c b/src/award.c index 397af63a45..d338ca27c1 100644 --- a/src/award.c +++ b/src/award.c @@ -155,7 +155,7 @@ static int award_is_deserved_best_value(int awardType, int activeAwardTypes) return 0; if (activeAwardTypes & (1 << PARK_AWARD_MOST_DISAPPOINTING)) return 0; - if (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & (PARK_FLAGS_11 | PARK_FLAGS_PARK_FREE_ENTRY)) + if (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & (PARK_FLAGS_NO_MONEY | PARK_FLAGS_PARK_FREE_ENTRY)) return 0; if (RCT2_GLOBAL(RCT2_TOTAL_RIDE_VALUE, money16) < MONEY(10, 00)) return 0; @@ -205,7 +205,7 @@ static int award_is_deserved_worse_value(int awardType, int activeAwardTypes) { if (activeAwardTypes & (1 << PARK_AWARD_BEST_VALUE)) return 0; - if (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_11) + if (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY) return 0; if (RCT2_GLOBAL(RCT2_ADDRESS_PARK_ENTRANCE_FEE, money16) == MONEY(0, 00)) return 0; diff --git a/src/finance.c b/src/finance.c index 601af718f8..7c2e842b0c 100644 --- a/src/finance.c +++ b/src/finance.c @@ -74,7 +74,7 @@ void finance_pay_wages() rct_peep* peep; uint16 spriteIndex; - if (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_11) + if (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY) return; FOR_ALL_STAFF(spriteIndex, peep) @@ -89,7 +89,7 @@ void finance_pay_research() { uint8 level; - if (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & 0x800) + if (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY) return; level = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_RESEARCH_LEVEL, uint8); @@ -106,7 +106,7 @@ void finance_pay_interest() sint16 current_interest = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_INTEREST_RATE, sint16); money32 tempcost = (current_loan * 5 * current_interest) >> 14; // (5 * interest) / 2^14 is pretty close to - if (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & 0x800) + if (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY) return; finance_payment(tempcost, RCT_EXPENDITURE_TYPE_INTEREST); @@ -127,7 +127,7 @@ void finance_pay_ride_upkeep() ride->var_196 = 25855; // durability? } - if (ride->status != RIDE_STATUS_CLOSED && !(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & 0x800)) { + if (ride->status != RIDE_STATUS_CLOSED && !(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY)) { sint16 upkeep = ride->upkeep_cost; if (upkeep != -1) { ride->var_158 -= upkeep; @@ -185,6 +185,31 @@ void finance_init() { sub_69E869(); } +/** +* +* rct2: 0x0069E79A +*/ +void finance_update_daily_profit() +{ + // 0x0135832C is related to savegames + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PROFIT, money32) = 7 * RCT2_GLOBAL(0x0135832C, money32); + RCT2_GLOBAL(0x0135832C, money32) = 0; + + int32 eax = 0; + + if (!(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY)) + { + + } + + eax /= 4; + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PROFIT, money32) += eax; + RCT2_GLOBAL(0x1358334, money32) += eax; + RCT2_GLOBAL(0x1358338, money32) += 1; + + //invalidate_window(al = 1C, bx = 0) +} + void sub_69E869() { // This subroutine is loan related and is used for cheat detection diff --git a/src/finance.h b/src/finance.h index 02e0dc6aab..e839dd3914 100644 --- a/src/finance.h +++ b/src/finance.h @@ -41,6 +41,7 @@ void finance_pay_interest(); void finance_pay_ride_upkeep(); void finance_reset_history(); void finance_init(); +void finance_update_daily_profit(); void sub_69E869(); #endif \ No newline at end of file diff --git a/src/game.c b/src/game.c index 51923944ee..a7abc48603 100644 --- a/src/game.c +++ b/src/game.c @@ -1860,7 +1860,7 @@ void handle_shortcut_command(int shortcutIndex) break; case SHORTCUT_SHOW_FINANCIAL_INFORMATION: if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0C)) - if (!(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & 0x800)) + if (!(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY)) window_finances_open(); break; case SHORTCUT_SHOW_RESEARCH_INFORMATION: diff --git a/src/park.c b/src/park.c index ba0457c3fc..94b2371f69 100644 --- a/src/park.c +++ b/src/park.c @@ -103,7 +103,7 @@ void park_init() RCT2_GLOBAL(RCT2_ADDRESS_LAND_COST, uint16) = MONEY(90, 00); RCT2_GLOBAL(RCT2_ADDRESS_CONSTRUCTION_RIGHTS_COST, uint16) = MONEY(40,00); RCT2_GLOBAL(0x01358774, uint16) = 0; - RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) = PARK_FLAGS_11 | PARK_FLAGS_SHOW_REAL_GUEST_NAMES; + RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) = PARK_FLAGS_NO_MONEY | PARK_FLAGS_SHOW_REAL_GUEST_NAMES; park_reset_history(); finance_reset_history(); award_reset(); @@ -427,7 +427,7 @@ static int park_calculate_guest_generation_probability() probability /= 4; // Check if money is enabled - if (!(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_11)) { + if (!(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY)) { // Penalty for overpriced entrance fee relative to total ride value money16 entranceFee = RCT2_GLOBAL(RCT2_ADDRESS_PARK_ENTRANCE_FEE, money16); if (entranceFee > totalRideValue) { diff --git a/src/park.h b/src/park.h index b12fcbad51..8f71122a88 100644 --- a/src/park.h +++ b/src/park.h @@ -35,11 +35,11 @@ enum { PARK_FLAGS_PREF_LESS_INTENSE_RIDES = (1 << 6), PARK_FLAGS_FORBID_MARKETING_CAMPAIGN = (1 << 7), PARK_FLAGS_PREF_MORE_INTENSE_RIDES = (1 << 8), - PARK_FLAGS_11 = (1 << 11), + PARK_FLAGS_NO_MONEY = (1 << 11), PARK_FLAGS_DIFFICULT_GUEST_GENERATION = (1 << 12), PARK_FLAGS_PARK_FREE_ENTRY = (1 << 13), PARK_FLAGS_DIFFICULT_PARK_RATING = (1 << 14), - PARK_FLAGS_NO_MONEY = (1 << 17), + PARK_FLAGS_NO_MONEY_SCENARIO = (1 << 17), // equivalent to PARK_FLAGS_NO_MONEY, but used in scenario editor PARK_FLAGS_18 = (1 << 18) }; diff --git a/src/scenario.c b/src/scenario.c index 441d23f3e0..76c6b9aaeb 100644 --- a/src/scenario.c +++ b/src/scenario.c @@ -223,8 +223,8 @@ void scenario_load_and_play(const rct_scenario_basic *scenario) RCT2_GLOBAL(0x009DEB7C, sint16) = 0; RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, sint32) &= 0xFFFFF7FF; - if (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, sint32) & 0x20000) - RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, sint32) |= 0x800; + if (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, sint32) & PARK_FLAGS_NO_MONEY_SCENARIO) + RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, sint32) |= PARK_FLAGS_NO_MONEY; RCT2_CALLPROC_EBPSAFE(0x00684AC3); RCT2_CALLPROC_EBPSAFE(0x006DFEE4); news_item_init_queue(); diff --git a/src/window_game_bottom_toolbar.c b/src/window_game_bottom_toolbar.c index dac63397f1..d724ff3f54 100644 --- a/src/window_game_bottom_toolbar.c +++ b/src/window_game_bottom_toolbar.c @@ -171,7 +171,7 @@ static void window_game_bottom_toolbar_mouseup() switch (widgetIndex) { case WIDX_LEFT_OUTSET: case WIDX_MONEY: - if (!(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & 0x800)) + if (!(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY)) window_finances_open(); break; case WIDX_GUESTS: @@ -332,7 +332,7 @@ static void window_game_bottom_toolbar_invalidate() } // Hide money if there is no money - if (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & 0x800) { + if (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY) { window_game_bottom_toolbar_widgets[WIDX_MONEY].type = WWT_EMPTY; window_game_bottom_toolbar_widgets[WIDX_GUESTS].top = 1; window_game_bottom_toolbar_widgets[WIDX_GUESTS].bottom = 17; @@ -426,7 +426,7 @@ static void window_game_bottom_toolbar_draw_left_panel(rct_drawpixelinfo *dpi, r y = window_game_bottom_toolbar_widgets[WIDX_LEFT_OUTSET].top + w->y + 4; // Draw money - if (!(RCT2_GLOBAL(0x0013573E4, uint32) & 0x800)) { + if (!(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY)) { RCT2_GLOBAL(0x013CE952, int) = DECRYPT_MONEY(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONEY_ENCRYPTED, sint32)); gfx_draw_string_centred( dpi, diff --git a/src/window_park.c b/src/window_park.c index 98caf43f0e..ac7b207403 100644 --- a/src/window_park.c +++ b/src/window_park.c @@ -580,6 +580,7 @@ static void window_park_anchor_border_widgets(rct_window *w); static void window_park_align_tabs(rct_window *w); static void window_park_set_pressed_tab(rct_window *w); static void window_park_draw_tab_images(rct_drawpixelinfo *dpi, rct_window *w); +static void window_park_set_disabled_tabs(rct_window *w); /** * @@ -599,7 +600,7 @@ rct_window *window_park_open() w->list_information_type = -1; w->var_48C = -1; w->var_492 = 0; - RCT2_CALLPROC_X(0x00667F8B, 0, 0, 0, 0, (int)w, 0, 0); + window_park_set_disabled_tabs(w); w->colours[0] = 1; w->colours[1] = 19; w->colours[2] = 19; @@ -607,6 +608,16 @@ rct_window *window_park_open() return w; } +/** + * + * rct2: 0x00667F8B + */ +void window_park_set_disabled_tabs(rct_window *w) +{ + // Disable price tab if money is disabled + w->disabled_widgets = (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY) ? (1 << WIDX_TAB_4) : 0; +} + #pragma region Entrance page /** @@ -2267,7 +2278,7 @@ static void window_park_set_page(rct_window *w, int page) w->var_020 = RCT2_GLOBAL(0x0097BAE0 + (page * 4), uint32); w->event_handlers = window_park_page_events[page]; w->widgets = window_park_page_widgets[page]; - RCT2_CALLPROC_X(0x00667F8B, 0, 0, 0, 0, (int)w, 0, 0); + window_park_set_disabled_tabs(w); window_invalidate(w); RCT2_CALLPROC_X(w->event_handlers[WE_RESIZE], 0, 0, 0, 0, (int)w, 0, 0); diff --git a/src/window_staff.c b/src/window_staff.c index d23545d8f9..7d852e638b 100644 --- a/src/window_staff.c +++ b/src/window_staff.c @@ -663,7 +663,7 @@ void window_staff_paint() { rct2_free(sprite_dpi); } - if (!(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_11)) { + if (!(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY)) { RCT2_GLOBAL(0x013CE952, uint32) = RCT2_ADDRESS(0x00992A00, uint16)[selectedTab]; gfx_draw_string_left(dpi, 1858, (void*)0x013CE952, 0, w->x + 0xA5, w->y + 0x20); } From 4cce2e38836abec452aea546969ccbfd8380f60a Mon Sep 17 00:00:00 2001 From: adrian17 Date: Sat, 30 Aug 2014 15:29:14 +0200 Subject: [PATCH 18/28] Fixed some buttons not working after last commit --- src/window_game_top_toolbar.c | 1 + src/window_options.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/window_game_top_toolbar.c b/src/window_game_top_toolbar.c index b7f624a598..4825f55128 100644 --- a/src/window_game_top_toolbar.c +++ b/src/window_game_top_toolbar.c @@ -170,6 +170,7 @@ void window_game_top_toolbar_open() (1 << WIDX_RIDES) | (1 << WIDX_PARK) | (1 << WIDX_STAFF) | + (1 << WIDX_GUESTS) | (1 << WIDX_CLEAR_SCENERY) | (1ULL << WIDX_FASTFORWARD) | (1ULL << WIDX_RESEARCH); diff --git a/src/window_options.c b/src/window_options.c index 8190d761ed..926b298c5b 100644 --- a/src/window_options.c +++ b/src/window_options.c @@ -230,6 +230,8 @@ void window_options_open() (1ULL << WIDX_MUSIC_DROPDOWN) | (1ULL << WIDX_SOUND_QUALITY) | (1ULL << WIDX_SOUND_QUALITY_DROPDOWN) | + (1ULL << WIDX_LANGUAGE) | + (1ULL << WIDX_LANGUAGE_DROPDOWN) | (1ULL << WIDX_CURRENCY) | (1ULL << WIDX_CURRENCY_DROPDOWN) | (1ULL << WIDX_DISTANCE) | From b253ad56cee021ffc185349cbb763a3b55f80726 Mon Sep 17 00:00:00 2001 From: hexdec Date: Sat, 30 Aug 2014 15:31:44 +0200 Subject: [PATCH 19/28] Fixed typo in window_staff_peep_stats_update. --- src/window_staff_peep.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/window_staff_peep.c b/src/window_staff_peep.c index c531f8d1e6..1195812b4b 100644 --- a/src/window_staff_peep.c +++ b/src/window_staff_peep.c @@ -691,7 +691,7 @@ void window_staff_peep_stats_update(rct_window* w) window_invalidate_by_id(0x697, w->number); rct_peep* peep = GET_PEEP(w->number); - if (peep->var_45 && 10) { + if (peep->var_45 & 0x10) { peep->var_45 &= 0xEF; window_invalidate(w); } From 858be90222d25a625c06dfaad1c8f4aede109ab9 Mon Sep 17 00:00:00 2001 From: hexdec Date: Sun, 31 Aug 2014 00:06:11 +0200 Subject: [PATCH 20/28] Added the missing enabled_widgets for window_staff_peep. --- src/window_staff_peep.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/window_staff_peep.c b/src/window_staff_peep.c index 1195812b4b..19a5d8076d 100644 --- a/src/window_staff_peep.c +++ b/src/window_staff_peep.c @@ -213,7 +213,12 @@ uint32 window_staff_peep_page_enabled_widgets[] = { (1 << WIDX_CLOSE) | (1 << WIDX_TAB_1) | (1 << WIDX_TAB_2) | - (1 << WIDX_TAB_3), + (1 << WIDX_TAB_3) | + (1 << WIDX_VIEWPORT) | // Sweep footpaths & Inspect rides + (1 << WIDX_BTM_LABEL) | // Water gardens & Fix rides + (1 << WIDX_PICKUP) | // Empty litter bins + (1 << WIDX_PATROL) | // Mow grass + (1 << WIDX_LOCATE), // Entertainer costume dropdown (1 << WIDX_CLOSE) | (1 << WIDX_TAB_1) | @@ -620,7 +625,6 @@ void window_staff_peep_orders_mouseup() case WIDX_BTM_LABEL: case WIDX_PICKUP: case WIDX_PATROL: - case WIDX_RENAME: window_staff_peep_set_order(w, widgetIndex - 8); break; } From d2e27c042809a1475dc3367ae98790ca0bcb8f38 Mon Sep 17 00:00:00 2001 From: hexdec Date: Sun, 31 Aug 2014 00:16:35 +0200 Subject: [PATCH 21/28] Added Widget enums for window_staff_peep. --- src/window_staff_peep.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/src/window_staff_peep.c b/src/window_staff_peep.c index 19a5d8076d..555818c920 100644 --- a/src/window_staff_peep.c +++ b/src/window_staff_peep.c @@ -50,7 +50,14 @@ enum WINDOW_STAFF_PEEP_WIDGET_IDX { WIDX_PATROL, WIDX_RENAME, WIDX_LOCATE, - WIDX_FIRE + WIDX_FIRE, + + WIDX_CHECKBOX_1 = 0x8, + WIDX_CHECKBOX_2, + WIDX_CHECKBOX_3, + WIDX_CHECKBOX_4, + + WIDX_COSTUME = 0xD, }; void window_staff_peep_emptysub(){}; @@ -214,11 +221,11 @@ uint32 window_staff_peep_page_enabled_widgets[] = { (1 << WIDX_TAB_1) | (1 << WIDX_TAB_2) | (1 << WIDX_TAB_3) | - (1 << WIDX_VIEWPORT) | // Sweep footpaths & Inspect rides - (1 << WIDX_BTM_LABEL) | // Water gardens & Fix rides - (1 << WIDX_PICKUP) | // Empty litter bins - (1 << WIDX_PATROL) | // Mow grass - (1 << WIDX_LOCATE), // Entertainer costume dropdown + (1 << WIDX_CHECKBOX_1) | + (1 << WIDX_CHECKBOX_2) | + (1 << WIDX_CHECKBOX_3) | + (1 << WIDX_CHECKBOX_4) | + (1 << WIDX_COSTUME), (1 << WIDX_CLOSE) | (1 << WIDX_TAB_1) | @@ -621,11 +628,11 @@ void window_staff_peep_orders_mouseup() case WIDX_TAB_3: window_staff_peep_set_page(w, widgetIndex - WIDX_TAB_1); break; - case WIDX_VIEWPORT: - case WIDX_BTM_LABEL: - case WIDX_PICKUP: - case WIDX_PATROL: - window_staff_peep_set_order(w, widgetIndex - 8); + case WIDX_CHECKBOX_1: + case WIDX_CHECKBOX_2: + case WIDX_CHECKBOX_3: + case WIDX_CHECKBOX_4: + window_staff_peep_set_order(w, widgetIndex - WIDX_CHECKBOX_1); break; } } From b832a7235b00d57cb7e781ce6af096e48aa6fd64 Mon Sep 17 00:00:00 2001 From: Patrick Wijnings Date: Sun, 31 Aug 2014 13:01:50 +0200 Subject: [PATCH 22/28] More PARK_FLAGS_NO_MONEY updates. Implement finance_update_daily_profit(). --- src/addresses.h | 1 + src/finance.c | 50 ++++++++++++++++++++++++++++++++----------- src/park.h | 2 ++ src/scenario.c | 10 ++++----- src/scenario.h | 4 ++-- src/window_new_ride.c | 4 ++-- src/window_peep.c | 2 +- 7 files changed, 50 insertions(+), 23 deletions(-) diff --git a/src/addresses.h b/src/addresses.h index d46574cc45..7bef46848b 100644 --- a/src/addresses.h +++ b/src/addresses.h @@ -236,6 +236,7 @@ #define RCT2_ADDRESS_OBJECTIVE_CURRENCY 0x013580FC #define RCT2_ADDRESS_OBJECTIVE_NUM_GUESTS 0x01358100 #define RCT2_ADDRESS_BALANCE_HISTORY 0x0135812C +#define RCT2_ADDRESS_CURRENT_EXPENDITURE 0x0135832C #define RCT2_ADDRESS_CURRENT_PROFIT 0x01358330 #define RCT2_ADDRESS_WEEKLY_PROFIT_HISTORY 0x0135833C #define RCT2_ADDRESS_CURRENT_PARK_VALUE 0x0135853C diff --git a/src/finance.c b/src/finance.c index ffb4496cca..785628ae74 100644 --- a/src/finance.c +++ b/src/finance.c @@ -57,7 +57,7 @@ void finance_payment(money32 amount, rct_expenditure_type type) RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONEY_ENCRYPTED, sint32) = ENCRYPT_MONEY(new_money); RCT2_ADDRESS(RCT2_ADDRESS_EXPENDITURE_TABLE, money32)[type] -= amount; if (RCT2_ADDRESS(0x00988E60, uint32)[type] & 1) - RCT2_GLOBAL(0x0135832C, money32) -= amount; + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_EXPENDITURE, money32) -= amount; // Cumulative amount of money spent this day RCT2_GLOBAL(0x009A9804, uint32) |= 1; // money diry flag @@ -158,11 +158,10 @@ void finance_init() { RCT2_ADDRESS(RCT2_ADDRESS_EXPENDITURE_TABLE, money32)[i] = 0; } - RCT2_GLOBAL(0x0135832C, uint32) = 0; - + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_EXPENDITURE, uint32) = 0; RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PROFIT, money32) = 0; - RCT2_GLOBAL(0x01358334, uint32) = 0; + RCT2_GLOBAL(0x01358334, money32) = 0; RCT2_GLOBAL(0x01358338, uint16) = 0; RCT2_GLOBAL(0x013573DC, money32) = MONEY(10000,00); // Cheat detection @@ -191,23 +190,48 @@ void finance_init() { */ void finance_update_daily_profit() { - // 0x0135832C is related to savegames - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PROFIT, money32) = 7 * RCT2_GLOBAL(0x0135832C, money32); - RCT2_GLOBAL(0x0135832C, money32) = 0; + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PROFIT, money32) = 7 * RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_EXPENDITURE, money32); + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_EXPENDITURE, money32) = 0; // Reset daily expenditure - int32 eax = 0; + money32 current_profit = 0; if (!(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY)) { + // Staff costs + uint16 sprite_index; + rct_peep *peep; + FOR_ALL_STAFF(sprite_index, peep) { + uint8 staff_type = peep->staff_type; + current_profit -= wage_table[peep->staff_type]; + } + + // Research costs + uint8 level = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_RESEARCH_LEVEL, uint8); + current_profit -= research_cost_table[level]; + + // Loan costs + money32 current_loan = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_LOAN, money32); + current_profit -= current_loan / 600; + + // Ride costs + rct_ride *ride; + int i; + FOR_ALL_RIDES(i, ride) { + if (ride->status != RIDE_STATUS_CLOSED && ride->upkeep_cost != -1) { + current_profit -= 2 * ride->upkeep_cost; + } + } } - eax /= 4; - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PROFIT, money32) += eax; - RCT2_GLOBAL(0x1358334, money32) += eax; - RCT2_GLOBAL(0x1358338, money32) += 1; + // This is not equivalent to / 4 due to rounding of negative numbers + current_profit = current_profit >> 2; - //invalidate_window(al = 1C, bx = 0) + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PROFIT, money32) += current_profit; + RCT2_GLOBAL(0x1358334, money32) += RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PROFIT, money32); + RCT2_GLOBAL(0x1358338, uint16) += 1; + + window_invalidate_by_id(WC_FINANCES, 0); } void sub_69E869() diff --git a/src/park.h b/src/park.h index 8f71122a88..8a27dfdc8d 100644 --- a/src/park.h +++ b/src/park.h @@ -59,4 +59,6 @@ void park_update_histories(); uint8 calculate_guest_initial_happiness(uint8 percentage); +void game_command_set_park_entrance_fee(); + #endif diff --git a/src/scenario.c b/src/scenario.c index e88c4dfa09..9154ce9e81 100644 --- a/src/scenario.c +++ b/src/scenario.c @@ -142,7 +142,7 @@ void scenario_load(const char *path) sawyercoding_read_chunk(file, (uint8*)RCT2_ADDRESS_ACTIVE_RESEARCH_TYPES); // Read ? - sawyercoding_read_chunk(file, (uint8*)0x0135832C); + sawyercoding_read_chunk(file, (uint8*)RCT2_ADDRESS_CURRENT_EXPENDITURE); // Read ? sawyercoding_read_chunk(file, (uint8*)RCT2_ADDRESS_CURRENT_PARK_VALUE); @@ -279,9 +279,9 @@ void scenario_load_and_play(const rct_scenario_basic *scenario) strcat((char*)RCT2_ADDRESS_SAVED_GAMES_PATH_2, ".SV6"); memset((void*)0x001357848, 0, 56); - RCT2_GLOBAL(0x0135832C, uint32) = 0; - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PROFIT, sint32) = 0; - RCT2_GLOBAL(0x01358334, uint32) = 0; + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_EXPENDITURE, uint32) = 0; + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PROFIT, money32) = 0; + RCT2_GLOBAL(0x01358334, money32) = 0; RCT2_GLOBAL(0x01358338, uint16) = 0; RCT2_GLOBAL(RCT2_ADDRESS_COMPLETED_COMPANY_VALUE, uint32) = 0x80000000; RCT2_GLOBAL(RCT2_ADDRESS_TOTAL_ADMISSIONS, uint32) = 0; @@ -577,7 +577,7 @@ void scenario_update() if ((current_days_in_month * next_month_tick) >> 16 != (current_days_in_month * month_tick) >> 16) { // daily checks - RCT2_CALLPROC_EBPSAFE(0x0069E79A); // daily profit update + finance_update_daily_profit(); // daily profit update RCT2_CALLPROC_EBPSAFE(0x0069C35E); // some kind of peeps days_visited update loop get_local_time(); RCT2_CALLPROC_EBPSAFE(0x0066A13C); // objective 6 dragging diff --git a/src/scenario.h b/src/scenario.h index 4ab1e2d2b2..cbd5b5d764 100644 --- a/src/scenario.h +++ b/src/scenario.h @@ -204,8 +204,8 @@ typedef struct { money32 balance_history[128]; // SC6[11] - uint32 dword_0135832C; - uint32 current_profit; + money32 current_expenditure; + money32 current_profit; uint32 dword_01358334; uint16 word_01358338; uint8 pad_0135833A[2]; diff --git a/src/window_new_ride.c b/src/window_new_ride.c index f744a63c24..9b061810f0 100644 --- a/src/window_new_ride.c +++ b/src/window_new_ride.c @@ -468,7 +468,7 @@ static void window_new_ride_refresh_widget_sizing(rct_window *w) window_new_ride_widgets[WIDX_CURRENTLY_IN_DEVELOPMENT_GROUP].type = WWT_GROUPBOX; window_new_ride_widgets[WIDX_LAST_DEVELOPMENT_GROUP].type = WWT_GROUPBOX; window_new_ride_widgets[WIDX_LAST_DEVELOPMENT_BUTTON].type = WWT_FLATBTN; - if (!(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_11)) + if (!(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY)) window_new_ride_widgets[WIDX_RESEARCH_FUNDING_BUTTON].type = WWT_FLATBTN; width = 300; @@ -944,7 +944,7 @@ static void window_new_ride_paint_ride_information(rct_window *w, rct_drawpixeli } // Price - if (!(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_11)) { + if (!(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY)) { // Get price of ride int unk2 = RCT2_GLOBAL(0x0097CC68 + (item.type * 2), uint8); money32 price = RCT2_GLOBAL(0x0097DD78 + (item.type * 4), uint16); diff --git a/src/window_peep.c b/src/window_peep.c index 8d154f4e74..a85331101c 100644 --- a/src/window_peep.c +++ b/src/window_peep.c @@ -500,7 +500,7 @@ void window_peep_disable_widgets(rct_window* w){ if (!(w->disabled_widgets & (1 << WIDX_PICKUP))) window_invalidate(w); } - if (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_11){ + if (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY){ disabled_widgets |= (1 << WIDX_TAB_4); //Disable finance tab if no money } w->disabled_widgets = disabled_widgets; From 9a6537209db2f3bd838d4f0d98f07d5da9acc3e0 Mon Sep 17 00:00:00 2001 From: Patrick Wijnings Date: Sun, 31 Aug 2014 13:06:24 +0200 Subject: [PATCH 23/28] Add comment to finance_update_daily_profit(). --- src/finance.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/finance.c b/src/finance.c index 785628ae74..efedfdff63 100644 --- a/src/finance.c +++ b/src/finance.c @@ -228,6 +228,8 @@ void finance_update_daily_profit() current_profit = current_profit >> 2; RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PROFIT, money32) += current_profit; + + // These are related to weekly profit graph RCT2_GLOBAL(0x1358334, money32) += RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PROFIT, money32); RCT2_GLOBAL(0x1358338, uint16) += 1; From 2cfb2908dee1412726e2bd704f3e7c6e4fefe10e Mon Sep 17 00:00:00 2001 From: IntelOrca Date: Sun, 31 Aug 2014 15:40:08 +0100 Subject: [PATCH 24/28] add ride track functions, for window ride branch --- src/map.c | 3 -- src/map.h | 2 ++ src/ride.c | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/ride.h | 4 +++ 4 files changed, 94 insertions(+), 3 deletions(-) diff --git a/src/map.c b/src/map.c index c82fd6dc48..ac086487e4 100644 --- a/src/map.c +++ b/src/map.c @@ -23,9 +23,6 @@ #include "date.h" #include "map.h" -#define GET_MAP_ELEMENT(x) (&(RCT2_ADDRESS(RCT2_ADDRESS_MAP_ELEMENTS, rct_map_element)[x])) -#define TILE_MAP_ELEMENT_POINTER(x) (RCT2_ADDRESS(RCT2_ADDRESS_TILE_MAP_ELEMENT_POINTERS, rct_map_element*)[x]) - static void tiles_init(); void map_element_set_terrain(rct_map_element *element, int terrain) diff --git a/src/map.h b/src/map.h index 8aa4e171fd..6c2cbf8b32 100644 --- a/src/map.h +++ b/src/map.h @@ -199,5 +199,7 @@ int map_element_height(int x, int y); void sub_68B089(); int map_coord_is_connected(uint16 coordinate, uint8 height, uint8 face_direction); +#define GET_MAP_ELEMENT(x) (&(RCT2_ADDRESS(RCT2_ADDRESS_MAP_ELEMENTS, rct_map_element)[x])) +#define TILE_MAP_ELEMENT_POINTER(x) (RCT2_ADDRESS(RCT2_ADDRESS_TILE_MAP_ELEMENT_POINTERS, rct_map_element*)[x]) #endif diff --git a/src/ride.c b/src/ride.c index bc5ae32544..546817e186 100644 --- a/src/ride.c +++ b/src/ride.c @@ -344,3 +344,91 @@ void ride_check_all_reachable() } } +/** + * + * rct2: 0x006CAF80 + * ax result x + * bx result y + * dl ride index + * esi result map element + */ +rct_map_element *sub_6CAF80(int rideIndex, int *outX, int *outY) +{ + rct_map_element *resultMapElement, *mapElement; + int foundSpecialTrackPiece; + + resultMapElement = (rct_map_element*)-1; + foundSpecialTrackPiece = 0; + + uint16 x, y; + for (x = 0; x < 256; x++) { + for (y = 0; y < 256; y++) { + // Iterate through map elements on tile + int tileIndex = (y << 8) | x; + mapElement = TILE_MAP_ELEMENT_POINTER(tileIndex); + do { + if ((mapElement->type & MAP_ELEMENT_TYPE_MASK) != MAP_ELEMENT_TYPE_TRACK) + continue; + if (rideIndex != mapElement->properties.track.ride_index) + continue; + + // Found a track piece for target ride + + // Check if its a ??? + int specialTrackPiece = ( + (mapElement->properties.track.type != 2 && mapElement->properties.track.type != 3) && + (RCT2_ADDRESS(0x0099BA64, uint8)[mapElement->properties.track.type * 16] & 0x10) + ); + + // Set result tile to this track piece if first found track or a ??? + if (resultMapElement == (rct_map_element*)-1 || specialTrackPiece) { + resultMapElement = mapElement; + + if (outX != NULL) *outX = x * 32; + if (outY != NULL) *outY = y * 32; + } + + if (specialTrackPiece) { + foundSpecialTrackPiece = 1; + return resultMapElement; + } + } while (!(mapElement->flags & MAP_ELEMENT_FLAG_LAST_TILE) && mapElement++); + } + } + return resultMapElement; +} + +/** + * + * rct2: 0x006CB02F + * ax result x + * bx result y + * esi input / output map element + */ +rct_map_element *ride_find_track_gap(rct_map_element *startTrackElement, int *outX, int *outY) +{ + int eax, ebx, ecx, edx, esi, edi, ebp; + esi = (int)startTrackElement; + eax = *outX; + ebx = 0; + ecx = *outY; + edx = 0; + edi = 0; + ebp = 0; + RCT2_CALLFUNC_X(0x006CB02F, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); + + if (outX != NULL) *outX = eax & 0xFFFF; + if (outY != NULL) *outY = ecx & 0xFFFF; + return (rct_map_element*)esi; +} + +/** + * + * rct2: 0x006CC056 + */ +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 77f4013831..dca498d637 100644 --- a/src/ride.h +++ b/src/ride.h @@ -21,6 +21,7 @@ #ifndef _RIDE_H_ #define _RIDE_H_ +#include "map.h" #include "rct2.h" #include "string_ids.h" @@ -381,5 +382,8 @@ void ride_init_all(); void reset_all_ride_build_dates(); 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); +int ride_try_construct(rct_map_element *trackMapElement); #endif From ba6d0bee30fd1fcf57c99c7a6d93cfa4406f6519 Mon Sep 17 00:00:00 2001 From: Jackson Davis Date: Mon, 1 Sep 2014 16:55:51 +0100 Subject: [PATCH 25/28] First pass at 6EE65A --- src/window_footpath.c | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/src/window_footpath.c b/src/window_footpath.c index 451816cb38..db6146c5a8 100644 --- a/src/window_footpath.c +++ b/src/window_footpath.c @@ -120,6 +120,7 @@ static void window_footpath_tooldrag(); static void window_footpath_toolup(); static void window_footpath_invalidate(); static void window_footpath_paint(); +static void sub_6EE65A(rct_window* w); static void* window_footpath_events[] = { window_footpath_close, @@ -201,7 +202,7 @@ void window_footpath_open() (1 << WIDX_CONSTRUCT_BRIDGE_OR_TUNNEL); window_init_scroll_widgets(window); - RCT2_CALLPROC_EBPSAFE(0x006EE65A); + sub_6EE65A(window); //RCT2_CALLPROC_EBPSAFE(0x006EE65A); show_gridlines(); window->colours[0] = 24; window->colours[1] = 24; @@ -825,4 +826,38 @@ loc_6A78EF: loc_6A79B0: RCT2_CALLPROC_EBPSAFE(0x006A855C); -} \ No newline at end of file +} + +static void sub_6EE65A(rct_window* window) +{ + uint16 ax = window->x; + uint16 bx = window->y; + uint16 cx = window->width; + uint16 dx = window->height; + cx += ax; + dx += bx; + for (rct_window* w = g_window_list; w < RCT2_GLOBAL(RCT2_ADDRESS_NEW_WINDOW_PTR, rct_window*); w++) { + if (w == window) + continue; + if (w->flags & (WF_STICK_TO_BACK | WF_STICK_TO_FRONT)) + continue; + if (w->x >= cx) + continue; + if (w->x + w->width <= ax) + continue; + if (w->y >= dx) + continue; + if (w->y + w->height <= bx) + continue; + window_invalidate(w); + cx += 13; + if (cx >= RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, uint16)) + continue; + cx -= 10; + cx -= w->x; + w->x += cx; + window_invalidate(w); + if (w->viewport != NULL) + w->viewport->x += cx; + } +} From f0d42616598c60b792bf1fbfec58a526cd1a8997 Mon Sep 17 00:00:00 2001 From: Jackson Davis Date: Mon, 1 Sep 2014 17:10:15 +0100 Subject: [PATCH 26/28] Move 6EE65A to window.c + minor refactor --- src/window.c | 35 +++++++++++++++++++++++++++++++++++ src/window.h | 1 + src/window_footpath.c | 36 +----------------------------------- 3 files changed, 37 insertions(+), 35 deletions(-) diff --git a/src/window.c b/src/window.c index 355d5770bf..e81a530965 100644 --- a/src/window.c +++ b/src/window.c @@ -1511,3 +1511,38 @@ void window_align_tabs( rct_window *w, uint8 start_tab_id, uint8 end_tab_id ) } } } + +/** + * Finds overlapping windows and moves them if possible + * rct2: 0x006EE65A + */ +void window_move_overlapping(rct_window* window) +{ + uint16 cx = window->width + window->x; + uint16 dx = window->height + window->y; + + for (rct_window* w = g_window_list; w < RCT2_GLOBAL(RCT2_ADDRESS_NEW_WINDOW_PTR, rct_window*); w++) { + if (w == window) + continue; + if (w->flags & (WF_STICK_TO_BACK | WF_STICK_TO_FRONT)) + continue; + if (w->x >= cx) + continue; + if (w->x + w->width <= window->x) + continue; + if (w->y >= dx) + continue; + if (w->y + w->height <= window->y) + continue; + window_invalidate(w); + cx += 13; + if (cx >= RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, uint16)) + continue; + cx -= 10; + cx -= w->x; + w->x += cx; + window_invalidate(w); + if (w->viewport != NULL) + w->viewport->x += cx; + } +} diff --git a/src/window.h b/src/window.h index 1098eba380..440ed28b40 100644 --- a/src/window.h +++ b/src/window.h @@ -469,6 +469,7 @@ void window_staff_init_vars(); void window_event_helper(rct_window* w, short widgetIndex, WINDOW_EVENTS event); void RCT2_CALLPROC_WE_MOUSE_DOWN(int address, int widgetIndex, rct_window*w, rct_widget* widget); +void window_move_overlapping(rct_window* window); #ifdef _MSC_VER #define window_get_register(w) \ diff --git a/src/window_footpath.c b/src/window_footpath.c index db6146c5a8..f852be5ecc 100644 --- a/src/window_footpath.c +++ b/src/window_footpath.c @@ -120,7 +120,6 @@ static void window_footpath_tooldrag(); static void window_footpath_toolup(); static void window_footpath_invalidate(); static void window_footpath_paint(); -static void sub_6EE65A(rct_window* w); static void* window_footpath_events[] = { window_footpath_close, @@ -202,7 +201,7 @@ void window_footpath_open() (1 << WIDX_CONSTRUCT_BRIDGE_OR_TUNNEL); window_init_scroll_widgets(window); - sub_6EE65A(window); //RCT2_CALLPROC_EBPSAFE(0x006EE65A); + window_move_overlapping(window); show_gridlines(); window->colours[0] = 24; window->colours[1] = 24; @@ -828,36 +827,3 @@ loc_6A79B0: RCT2_CALLPROC_EBPSAFE(0x006A855C); } -static void sub_6EE65A(rct_window* window) -{ - uint16 ax = window->x; - uint16 bx = window->y; - uint16 cx = window->width; - uint16 dx = window->height; - cx += ax; - dx += bx; - for (rct_window* w = g_window_list; w < RCT2_GLOBAL(RCT2_ADDRESS_NEW_WINDOW_PTR, rct_window*); w++) { - if (w == window) - continue; - if (w->flags & (WF_STICK_TO_BACK | WF_STICK_TO_FRONT)) - continue; - if (w->x >= cx) - continue; - if (w->x + w->width <= ax) - continue; - if (w->y >= dx) - continue; - if (w->y + w->height <= bx) - continue; - window_invalidate(w); - cx += 13; - if (cx >= RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, uint16)) - continue; - cx -= 10; - cx -= w->x; - w->x += cx; - window_invalidate(w); - if (w->viewport != NULL) - w->viewport->x += cx; - } -} From fc2c3bdb51a1d3a9f925bc3d1ff2696f5c29f981 Mon Sep 17 00:00:00 2001 From: Jackson Davis Date: Mon, 1 Sep 2014 22:06:50 +0200 Subject: [PATCH 27/28] Rename 6EE65A to push_others_right + refactor --- src/window.c | 67 +++++++++++++++++++++---------------------- src/window.h | 2 +- src/window_footpath.c | 2 +- 3 files changed, 35 insertions(+), 36 deletions(-) diff --git a/src/window.c b/src/window.c index e81a530965..9e04d0982e 100644 --- a/src/window.c +++ b/src/window.c @@ -828,6 +828,38 @@ rct_window *window_bring_to_front(rct_window *w) return w; } +/** + * + * rct2: 0x006EE65A + */ +void window_push_others_right(rct_window* window) +{ + + for (rct_window* w = g_window_list; w < RCT2_GLOBAL(RCT2_ADDRESS_NEW_WINDOW_PTR, rct_window*); w++) { + if (w == window) + continue; + if (w->flags & (WF_STICK_TO_BACK | WF_STICK_TO_FRONT)) + continue; + if (w->x >= window->x + window->width) + continue; + if (w->x + w->width <= window->x) + continue; + if (w->y >= window->y + window->height) + continue; + if (w->y + w->height <= window->y) + continue; + + window_invalidate(w); + if (window->x + window->width + 13 >= RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, uint16)) + continue; + uint16 push_amount = window->x + window->height - w->x + 3; + w->x += push_amount; + window_invalidate(w); + if (w->viewport != NULL) + w->viewport->x += push_amount; + } +} + /** * * rct2: 0x006EE6EA @@ -871,6 +903,7 @@ void window_push_others_below(rct_window *w1) } } + /** * * rct2: 0x006EE2E4 @@ -1512,37 +1545,3 @@ void window_align_tabs( rct_window *w, uint8 start_tab_id, uint8 end_tab_id ) } } -/** - * Finds overlapping windows and moves them if possible - * rct2: 0x006EE65A - */ -void window_move_overlapping(rct_window* window) -{ - uint16 cx = window->width + window->x; - uint16 dx = window->height + window->y; - - for (rct_window* w = g_window_list; w < RCT2_GLOBAL(RCT2_ADDRESS_NEW_WINDOW_PTR, rct_window*); w++) { - if (w == window) - continue; - if (w->flags & (WF_STICK_TO_BACK | WF_STICK_TO_FRONT)) - continue; - if (w->x >= cx) - continue; - if (w->x + w->width <= window->x) - continue; - if (w->y >= dx) - continue; - if (w->y + w->height <= window->y) - continue; - window_invalidate(w); - cx += 13; - if (cx >= RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, uint16)) - continue; - cx -= 10; - cx -= w->x; - w->x += cx; - window_invalidate(w); - if (w->viewport != NULL) - w->viewport->x += cx; - } -} diff --git a/src/window.h b/src/window.h index 440ed28b40..86aa034349 100644 --- a/src/window.h +++ b/src/window.h @@ -396,6 +396,7 @@ int window_get_scroll_size(rct_window *w, int scrollIndex, int *width, int *heig rct_window *window_bring_to_front_by_id(rct_windowclass cls, rct_windownumber number); rct_window *window_bring_to_front(rct_window *w); +void window_push_others_right(rct_window *w); void window_push_others_below(rct_window *w1); rct_window *window_get_main(); @@ -469,7 +470,6 @@ void window_staff_init_vars(); void window_event_helper(rct_window* w, short widgetIndex, WINDOW_EVENTS event); void RCT2_CALLPROC_WE_MOUSE_DOWN(int address, int widgetIndex, rct_window*w, rct_widget* widget); -void window_move_overlapping(rct_window* window); #ifdef _MSC_VER #define window_get_register(w) \ diff --git a/src/window_footpath.c b/src/window_footpath.c index f852be5ecc..01e4db3cb5 100644 --- a/src/window_footpath.c +++ b/src/window_footpath.c @@ -201,7 +201,7 @@ void window_footpath_open() (1 << WIDX_CONSTRUCT_BRIDGE_OR_TUNNEL); window_init_scroll_widgets(window); - window_move_overlapping(window); + window_push_others_right(window); show_gridlines(); window->colours[0] = 24; window->colours[1] = 24; From 4b3150449aaf99de86dfe409408c3e6b1b1206b1 Mon Sep 17 00:00:00 2001 From: Jackson Davis Date: Mon, 1 Sep 2014 22:22:54 +0200 Subject: [PATCH 28/28] Fix typo --- src/window.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/window.c b/src/window.c index 9e04d0982e..4351d90d1a 100644 --- a/src/window.c +++ b/src/window.c @@ -852,7 +852,7 @@ void window_push_others_right(rct_window* window) window_invalidate(w); if (window->x + window->width + 13 >= RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, uint16)) continue; - uint16 push_amount = window->x + window->height - w->x + 3; + uint16 push_amount = window->x + window->width - w->x + 3; w->x += push_amount; window_invalidate(w); if (w->viewport != NULL)