From b3ea71c080b72abbbbd5e39a181da697462d84c3 Mon Sep 17 00:00:00 2001 From: ZedThree Date: Sun, 4 May 2014 12:56:35 +0200 Subject: [PATCH 01/44] Replace more addresses with their named constants Also named window.var_4B2/4 as saved_view_x/y --- src/addresses.h | 3 +++ src/game.c | 12 ++++++------ src/scenario.c | 8 ++++---- src/title.c | 8 ++++---- src/viewport.c | 2 +- src/window.h | 4 ++-- src/window_footpath.c | 6 +++--- src/window_park.c | 14 +++++++------- src/window_water.c | 8 ++++---- 9 files changed, 34 insertions(+), 31 deletions(-) diff --git a/src/addresses.h b/src/addresses.h index d9c7a46036..c6a9bd19a6 100644 --- a/src/addresses.h +++ b/src/addresses.h @@ -202,6 +202,9 @@ #define RCT2_ADDRESS_SCENARIO_NAME 0x0141F5B8 +#define RCT2_ADDRESS_WATER_RAISE_COST 0x0141F738 +#define RCT2_ADDRESS_WATER_LOWER_COST 0x0141F73C + #define RCT2_ADDRESS_WINDOW_LIST 0x01420078 #define RCT2_ADDRESS_NEW_WINDOW_PTR 0x014234B8 #define RCT2_ADDRESS_VIEWPORT_LIST 0x014234BC diff --git a/src/game.c b/src/game.c index e8bafaeb33..38243ce888 100644 --- a/src/game.c +++ b/src/game.c @@ -399,8 +399,8 @@ static void game_handle_input_mouse(int x, int y, int state) RCT2_GLOBAL(0x009DE540, sint16) = 1000; dx <<= viewport->zoom + 1; dy <<= viewport->zoom + 1; - w->var_4B2 += dx; - w->var_4B4 += dy; + w->saved_view_x += dx; + w->saved_view_y += dy; } } } else if (state == 4) { @@ -795,11 +795,11 @@ void game_handle_edge_scroll() // Scroll viewport if (scrollX != 0) { - mainWindow->var_4B2 += scrollX * (12 << mainWindow->viewport->zoom); + mainWindow->saved_view_x += scrollX * (12 << mainWindow->viewport->zoom); RCT2_GLOBAL(0x009DE518, uint32) |= (1 << 7); } if (scrollY != 0) { - mainWindow->var_4B4 += scrollY * (12 << mainWindow->viewport->zoom); + mainWindow->saved_view_y += scrollY * (12 << mainWindow->viewport->zoom); RCT2_GLOBAL(0x009DE518, uint32) |= (1 << 7); } } @@ -836,11 +836,11 @@ void game_handle_key_scroll() // Scroll viewport if (scrollX != 0) { - mainWindow->var_4B2 += scrollX * (12 << mainWindow->viewport->zoom); + mainWindow->saved_view_x += scrollX * (12 << mainWindow->viewport->zoom); RCT2_GLOBAL(0x009DE518, uint32) |= (1 << 7); } if (scrollY != 0) { - mainWindow->var_4B4 += scrollY * (12 << mainWindow->viewport->zoom); + mainWindow->saved_view_y += scrollY * (12 << mainWindow->viewport->zoom); RCT2_GLOBAL(0x009DE518, uint32) |= (1 << 7); } } diff --git a/src/scenario.c b/src/scenario.c index 800d364a0a..05871c5780 100644 --- a/src/scenario.c +++ b/src/scenario.c @@ -422,8 +422,8 @@ void scenario_load_and_play(rct_scenario_basic *scenario) mainWindow = window_get_main(); mainWindow->var_4B0 = -1; - mainWindow->var_4B2 = RCT2_GLOBAL(RCT2_ADDRESS_SAVED_VIEW_X, sint16); - mainWindow->var_4B4 = RCT2_GLOBAL(RCT2_ADDRESS_SAVED_VIEW_Y, sint16); + mainWindow->saved_view_x = RCT2_GLOBAL(RCT2_ADDRESS_SAVED_VIEW_X, sint16); + mainWindow->saved_view_y = RCT2_GLOBAL(RCT2_ADDRESS_SAVED_VIEW_Y, sint16); uint8 _cl = (RCT2_GLOBAL(0x0138869E, sint16) & 0xFF) - mainWindow->viewport->zoom; mainWindow->viewport->zoom = RCT2_GLOBAL(0x0138869E, sint16) & 0xFF; @@ -438,8 +438,8 @@ void scenario_load_and_play(rct_scenario_basic *scenario) mainWindow->viewport->view_height <<= _cl; } } - mainWindow->var_4B2 -= mainWindow->viewport->view_width >> 1; - mainWindow->var_4B4 -= mainWindow->viewport->view_height >> 1; + mainWindow->saved_view_x -= mainWindow->viewport->view_width >> 1; + mainWindow->saved_view_y -= mainWindow->viewport->view_height >> 1; window_invalidate(mainWindow); RCT2_CALLPROC_EBPSAFE(0x0069E9A7); diff --git a/src/title.c b/src/title.c index 6a85e4e6c0..17cc541e60 100644 --- a/src/title.c +++ b/src/title.c @@ -167,8 +167,8 @@ static void title_update_showcase() w = window_get_main(); w->var_4B0 = -1; - w->var_4B2 = RCT2_GLOBAL(0x0138869A, sint16); - w->var_4B4 = RCT2_GLOBAL(0x0138869C, sint16); + w->saved_view_x = RCT2_GLOBAL(RCT2_ADDRESS_SAVED_VIEW_X, sint16); + w->saved_view_y = RCT2_GLOBAL(RCT2_ADDRESS_SAVED_VIEW_Y, sint16); { char _cl = (RCT2_GLOBAL(0x0138869E, sint16) & 0xFF) - w->viewport->zoom; @@ -184,8 +184,8 @@ static void title_update_showcase() w->viewport->view_height <<= _cl; } } - w->var_4B2 -= w->viewport->view_width >> 1; - w->var_4B4 -= w->viewport->view_height >> 1; + w->saved_view_x -= w->viewport->view_width >> 1; + w->saved_view_y -= w->viewport->view_height >> 1; } window_invalidate(w); diff --git a/src/viewport.c b/src/viewport.c index 857072af39..a22af3cf24 100644 --- a/src/viewport.c +++ b/src/viewport.c @@ -63,7 +63,7 @@ void viewport_init_all() RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWCLASS, rct_windowclass) = -1; RCT2_GLOBAL(0x009DE550, sint32) = -1; RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_NOT_SHOWN_TICKS, sint16) = -1; - RCT2_GLOBAL(0x009DE58A, sint16) = 0; + RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, sint16) = 0; RCT2_GLOBAL(0x009DEA50, sint16) = -1; RCT2_CALLPROC_EBPSAFE(0x006EE3C3); format_string((char*)0x0141FA44, STR_CANCEL, NULL); diff --git a/src/window.h b/src/window.h index 9fab72b82c..a1a1305167 100644 --- a/src/window.h +++ b/src/window.h @@ -136,8 +136,8 @@ typedef struct rct_window { sint16 var_4AC; sint16 var_4AE; sint16 var_4B0; // viewport target sprite? - sint16 var_4B2; // viewport target x? - sint16 var_4B4; // viewport target y? + sint16 saved_view_x; // 0x4B2 + sint16 saved_view_y; // 0x4B4 rct_windowclass classification; // 0x4B6 uint8 pad_4B7; sint8 var_4B8; diff --git a/src/window_footpath.c b/src/window_footpath.c index de147ada3d..d88cf014a3 100644 --- a/src/window_footpath.c +++ b/src/window_footpath.c @@ -223,7 +223,7 @@ static void window_footpath_close() RCT2_CALLPROC_EBPSAFE(0x006A7831); RCT2_CALLPROC_X(0x006CB70A, 0, 0, 0, 0, 0, 0, 0); RCT2_CALLPROC_EBPSAFE(0x0068AB1B); - RCT2_GLOBAL(0x009DE58A, uint16) &= ~2; + RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) &= ~2; window_invalidate_by_id(WC_TOP_TOOLBAR, 0); hide_gridlines(); } @@ -258,7 +258,7 @@ static void window_footpath_mouseup() tool_cancel(); RCT2_CALLPROC_EBPSAFE(0x006A7831); RCT2_CALLPROC_EBPSAFE(0x0068AB1B); - RCT2_GLOBAL(0x009DE58A, uint16) &= ~2; + RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) &= ~2; RCT2_GLOBAL(0x00F3EF99, uint8) = PATH_CONSTRUCTION_MODE_LAND; tool_set(w, WIDX_CONSTRUCT_ON_LAND, 17); RCT2_GLOBAL(0x009DE518, uint32) |= (1 << 6); @@ -273,7 +273,7 @@ static void window_footpath_mouseup() RCT2_CALLPROC_EBPSAFE(0x006EE281); RCT2_CALLPROC_EBPSAFE(0x006A7831); RCT2_CALLPROC_EBPSAFE(0x0068AB1B); - RCT2_GLOBAL(0x009DE58A, uint16) &= ~2; + RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) &= ~2; RCT2_GLOBAL(0x00F3EF99, uint8) = PATH_CONSTRUCTION_MODE_BRIDGE_OR_TUNNEL; tool_set(w, WIDX_CONSTRUCT_BRIDGE_OR_TUNNEL, 12); RCT2_GLOBAL(0x009DE518, uint32) |= (1 << 6); diff --git a/src/window_park.c b/src/window_park.c index 8d2c3078f7..4700b6f479 100644 --- a/src/window_park.c +++ b/src/window_park.c @@ -800,15 +800,15 @@ static void window_park_entrance_toolupdate() if (widgetIndex == WIDX_BUY_LAND_RIGHTS) { RCT2_CALLPROC_X(0x0068AAE1, x, y, 0, 0, w, 0, 0); - RCT2_GLOBAL(0x009DE58A, uint16) &= 0xFFFE; + RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) &= 0xFFFE; screen_pos_to_map_pos(&x, &y); if (x != SPRITE_LOCATION_NULL) { - RCT2_GLOBAL(0x009DE58A, uint16) |= 1; - RCT2_GLOBAL(0x009DE594, uint16) = 4; - RCT2_GLOBAL(0x009DE58C, uint16) = x; - RCT2_GLOBAL(0x009DE58E, uint16) = x; - RCT2_GLOBAL(0x009DE590, uint16) = y; - RCT2_GLOBAL(0x009DE592, uint16) = y; + RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) |= 1; + RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_TYPE, uint16) = 4; + RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_X, uint16) = x; + RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_X, uint16) = x; + RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_Y, uint16) = y; + RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_Y, uint16) = y; RCT2_CALLPROC_X(0x0068AAE1, x, y, 0, 0, w, 0, 0); } } diff --git a/src/window_water.c b/src/window_water.c index 56be72a634..1e91cbf5b5 100644 --- a/src/window_water.c +++ b/src/window_water.c @@ -102,8 +102,8 @@ void window_water_open() window_init_scroll_widgets(window); window_push_others_below(window); - RCT2_GLOBAL(0x0141F738, uint32) = 0x80000000; - RCT2_GLOBAL(0x0141F73C, uint32) = 0x80000000; + RCT2_GLOBAL(RCT2_ADDRESS_WATER_RAISE_COST, uint32) = 0x80000000; + RCT2_GLOBAL(RCT2_ADDRESS_WATER_LOWER_COST, uint32) = 0x80000000; window->colours[0] = 24; window->colours[1] = 24; window->colours[2] = 24; @@ -215,12 +215,12 @@ static void window_water_paint() // Draw raise cost amount x = (window_water_widgets[WIDX_PREVIEW].left + window_water_widgets[WIDX_PREVIEW].right) / 2 + w->x; y = window_water_widgets[WIDX_PREVIEW].bottom + w->y + 5; - if (RCT2_GLOBAL(0x0141F738, uint32) != 0x80000000 && RCT2_GLOBAL(0x0141F738, uint32) != 0) + if (RCT2_GLOBAL(RCT2_ADDRESS_WATER_RAISE_COST, uint32) != 0x80000000 && RCT2_GLOBAL(RCT2_ADDRESS_WATER_RAISE_COST, uint32) != 0) gfx_draw_string_centred(dpi, 984, x, y, 0, (void*)0x0141F738); y += 10; // Draw lower cost amount - if (RCT2_GLOBAL(0x0141F73C, uint32) != 0x80000000 && RCT2_GLOBAL(0x0141F73C, uint32) != 0) + if (RCT2_GLOBAL(RCT2_ADDRESS_WATER_LOWER_COST, uint32) != 0x80000000 && RCT2_GLOBAL(RCT2_ADDRESS_WATER_LOWER_COST, uint32) != 0) gfx_draw_string_centred(dpi, 985, x, y, 0, (void*)0x0141F73C); } From 00cd9014419194127c49b0cccd7435fc96b0c81b Mon Sep 17 00:00:00 2001 From: IntelOrca Date: Sun, 4 May 2014 14:10:32 +0100 Subject: [PATCH 02/44] add news window --- projects/openrct2.vcxproj | 1 + projects/openrct2.vcxproj.filters | 3 + src/game.c | 5 +- src/strings.h | 1 + src/window.c | 28 ++- src/window.h | 2 + src/window_game_bottom_toolbar.c | 2 +- src/window_news.c | 387 ++++++++++++++++++++++++++++++ 8 files changed, 417 insertions(+), 12 deletions(-) create mode 100644 src/window_news.c diff --git a/projects/openrct2.vcxproj b/projects/openrct2.vcxproj index 65dc2c25c5..e9b9025b4f 100644 --- a/projects/openrct2.vcxproj +++ b/projects/openrct2.vcxproj @@ -88,6 +88,7 @@ + diff --git a/projects/openrct2.vcxproj.filters b/projects/openrct2.vcxproj.filters index 320e75abdf..4f7eea0b40 100644 --- a/projects/openrct2.vcxproj.filters +++ b/projects/openrct2.vcxproj.filters @@ -269,6 +269,9 @@ Source Files + + Windows + diff --git a/src/game.c b/src/game.c index e8bafaeb33..c108aaffad 100644 --- a/src/game.c +++ b/src/game.c @@ -875,6 +875,9 @@ void handle_shortcut(int key) break; } } + if (key == SDL_SCANCODE_M) { + key = key; + } } /** @@ -930,7 +933,7 @@ void game_handle_keyboard_input() // Handle key input while ((key = get_next_key()) != 0) { - if (key == 255 || key == 0x10 || key == 0x11) + if (key == 255) continue; key |= RCT2_GLOBAL(RCT2_ADDRESS_PLACE_OBJECT_MODIFIER, uint8) << 8; diff --git a/src/strings.h b/src/strings.h index a5432c8d99..f664887074 100644 --- a/src/strings.h +++ b/src/strings.h @@ -334,6 +334,7 @@ enum { SPR_BUY_CONSTRUCTION_RIGHTS_TIP = 2326, STR_PARK_INFORMATION_TIP = 2233, + STR_RECENT_MESSAGES = 2234, STR_MONTH_JANUARY = 2236, STR_MONTH_FEBRUARY = STR_MONTH_JANUARY + 1, diff --git a/src/window.c b/src/window.c index da21178b58..a1644e98c8 100644 --- a/src/window.c +++ b/src/window.c @@ -631,6 +631,7 @@ void window_init_scroll_widgets(rct_window *w) rct_widget* widget; rct_scroll* scroll; int widget_index, scroll_index; + int width, height; widget_index = 0; scroll_index = 0; @@ -641,16 +642,11 @@ void window_init_scroll_widgets(rct_window *w) } scroll = &w->scrolls[scroll_index]; - - { - int _eax = 0, _ebx = scroll_index * sizeof(rct_scroll), _ecx = 0, _edx = 0, _esi = w, _edi = widget_index * sizeof(rct_widget), _ebp = 0; - RCT2_CALLFUNC_X(w->event_handlers[WE_SCROLL_GETSIZE], & _eax, &_ebx, &_ecx, &_edx, &_esi, &_edi, &_ebp); - - scroll->h_left = 0; - scroll->h_right = _ecx + 1; - scroll->v_top = 0; - scroll->v_bottom = _edx + 1; - } + window_get_scroll_size(w, scroll_index, &width, &height); + scroll->h_left = 0; + scroll->h_right = width + 1; + scroll->v_top = 0; + scroll->v_bottom = height + 1; if (widget->image & 0x01) scroll->flags |= HSCROLLBAR_VISIBLE; @@ -675,6 +671,18 @@ void window_update_scroll_widgets(rct_window *w) RCT2_CALLPROC_X(0x006EAE4E, 0, 0, 0, 0, w, 0, 0); } +int window_get_scroll_size(rct_window *w, int scrollIndex, int *width, int *height) +{ + rct_widget *widget = window_get_scroll_widget(w, scrollIndex); + int widgetIndex = window_get_widget_index(w, widget); + + int eax = 0, ebx = scrollIndex * sizeof(rct_scroll), ecx = 0, edx = 0, esi = w, edi = widgetIndex * sizeof(rct_widget), ebp = 0; + RCT2_CALLFUNC_X(w->event_handlers[WE_SCROLL_GETSIZE], & eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); + *width = ecx; + *height = edx; + return 1; +} + int window_get_scroll_data_index(rct_window *w, int widget_index) { int i, result; diff --git a/src/window.h b/src/window.h index 9fab72b82c..2bc443c7f7 100644 --- a/src/window.h +++ b/src/window.h @@ -298,6 +298,7 @@ void widget_invalidate(rct_windowclass cls, rct_windownumber number, int widgetI void window_init_scroll_widgets(rct_window *w); void window_update_scroll_widgets(rct_window *w); int window_get_scroll_data_index(rct_window *w, int widget_index); +int window_get_scroll_size(rct_window *w, int scrollIndex, int *width, int *height); rct_window *window_bring_to_front_by_id(rct_windowclass cls, rct_windownumber number); rct_window *window_bring_to_front(rct_window *w); @@ -334,6 +335,7 @@ void window_save_prompt_open(); void window_title_menu_open(); void window_title_exit_open(); void window_title_logo_open(); +void window_news_open(); void window_scenarioselect_open(); void window_clear_scenery_open(); void window_land_open(); diff --git a/src/window_game_bottom_toolbar.c b/src/window_game_bottom_toolbar.c index 2ce92865ed..32b4a01251 100644 --- a/src/window_game_bottom_toolbar.c +++ b/src/window_game_bottom_toolbar.c @@ -195,7 +195,7 @@ static void window_game_bottom_toolbar_mouseup() break; case WIDX_RIGHT_OUTSET: case WIDX_DATE: - RCT2_CALLPROC_EBPSAFE(0x0066E464); + window_news_open(); break; } } diff --git a/src/window_news.c b/src/window_news.c new file mode 100644 index 0000000000..46888608ed --- /dev/null +++ b/src/window_news.c @@ -0,0 +1,387 @@ +/***************************************************************************** + * Copyright (c) 2014 Ted John + * OpenRCT2, an open source clone of Roller Coaster Tycoon 2. + * + * This file is part of OpenRCT2. + * + * OpenRCT2 is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + *****************************************************************************/ + +#include +#include "addresses.h" +#include "audio.h" +#include "news_item.h" +#include "strings.h" +#include "sprite.h" +#include "sprites.h" +#include "widget.h" +#include "window.h" + +static enum WINDOW_NEWS_WIDGET_IDX { + WIDX_BACKGROUND, + WIDX_TITLE, + WIDX_CLOSE, + WIDX_SCROLL +}; + +static rct_widget window_news_widgets[] = { + { WWT_FRAME, 0, 0, 399, 0, 299, 0x0FFFFFFFF, STR_NONE }, // panel / background + { WWT_CAPTION, 0, 1, 398, 1, 14, STR_RECENT_MESSAGES, STR_WINDOW_TITLE_TIP }, // title bar + { WWT_CLOSEBOX, 0, 387, 397, 2, 13, STR_CLOSE_X, STR_CLOSE_WINDOW_TIP }, // close x button + { WWT_SCROLL, 0, 4, 395, 18, 295, 2, STR_NONE }, // scroll + { WIDGETS_END }, +}; + +static void window_news_emptysub() { } +static void window_news_mouseup(); +static void window_news_update(); +static void window_news_scrollgetsize(); +static void window_news_scrollmousedown(); +static void window_news_tooltip(); +static void window_news_paint(); +static void window_news_scrollpaint(); + +static uint32 window_news_events[] = { + window_news_emptysub, + window_news_mouseup, + window_news_emptysub, + window_news_emptysub, + window_news_emptysub, + window_news_emptysub, + window_news_update, + window_news_emptysub, + window_news_emptysub, + window_news_emptysub, + window_news_emptysub, + window_news_emptysub, + window_news_emptysub, + window_news_emptysub, + window_news_emptysub, + window_news_scrollgetsize, + window_news_scrollmousedown, + window_news_emptysub, + window_news_emptysub, + window_news_emptysub, + window_news_emptysub, + window_news_emptysub, + window_news_tooltip, + window_news_emptysub, + window_news_emptysub, + window_news_emptysub, + window_news_paint, + window_news_scrollpaint +}; + +/** + * + * rct2: 0x0066E464 + */ +void window_news_open() +{ + int x, y; + rct_window* window; + + // Check if window is already open + window = window_bring_to_front_by_id(WC_RECENT_NEWS, 0); + if (window == NULL) { + window = window_create_auto_pos( + 400, + 300, + window_news_events, + WC_ABOUT, + 0 + ); + window->widgets = window_news_widgets; + window->enabled_widgets = (1 << WIDX_CLOSE); + window_init_scroll_widgets(window); + window->colours[0] = 1; + window->colours[1] = 1; + window->colours[2] = 0; + window->var_480 = -1; + } + +// sub_66E4BA: + int width, height; + rct_widget *widget; + + window_get_scroll_size(window, 0, &width, &height); + widget = &window_news_widgets[WIDX_SCROLL]; + window->scrolls[0].v_top = max(0, height - (widget->bottom - widget->top - 1)); + widget_scroll_update_thumbs(window, WIDX_SCROLL); +} + +/** + * + * rct2: 0x0066D4D5 + */ +static void window_news_mouseup() +{ + int i; + short widgetIndex; + rct_window *w; + + __asm mov widgetIndex, dx + __asm mov w, esi + + if (widgetIndex == WIDX_CLOSE) + window_close(w); +} + +/** + * + * rct2: 0x0066EAB8 + */ +static void window_news_update() +{ + int i, j, x, y, z; + rct_window *w; + rct_news_item *newsItems; + + __asm mov w, esi + + if (w->var_480 == -1) + return; + if (--w->var_484 != 0) + return; + + window_invalidate(w); + sound_play_panned(5, w->x + (w->width / 2)); + + newsItems = RCT2_ADDRESS(RCT2_ADDRESS_NEWS_ITEM_LIST, rct_news_item); + j = w->var_480; + w->var_480 = -1; + for (i = 11; i < 61; i++) { + if (newsItems[i].type == NEWS_ITEM_NULL) + return; + + if (j == 0) { + if (newsItems[i].flags & 1) + return; + if (w->var_482 == 1) { + RCT2_CALLPROC_X(0x0066EBE6, 0, newsItems[i].type, newsItems[i].assoc, 0, 0, 0, 0); + return; + } else if (w->var_482 > 1) { + news_item_get_subject_location(newsItems[i].type, newsItems[i].assoc, &x, &y, &z); + if (x != SPRITE_LOCATION_NULL) + if ((w = window_get_main()) != NULL) + window_scroll_to_location(w, x, y, z); + return; + } + } + j--; + } +} + +/** + * + * rct2: 0x0066EA3C + */ +static void window_news_scrollgetsize() +{ + int i, height; + rct_news_item *newsItems = RCT2_ADDRESS(RCT2_ADDRESS_NEWS_ITEM_LIST, rct_news_item); + + height = 0; + for (i = 11; i < 61; i++) { + if (newsItems[i].type == NEWS_ITEM_NULL) + break; + + height += 42; + } + + __asm mov edx, height +} + +/** + * + * rct2: 0x0066EA5C + */ +static void window_news_scrollmousedown() +{ + int i, buttonIndex; + short x, y; + rct_window *w; + rct_news_item *newsItems; + + __asm mov x, cx + __asm mov y, dx + __asm mov w, esi + + buttonIndex = 0; + newsItems = RCT2_ADDRESS(RCT2_ADDRESS_NEWS_ITEM_LIST, rct_news_item); + for (i = 11; i < 61; i++) { + if (newsItems[i].type == NEWS_ITEM_NULL) + break; + + if (y < 42) { + if (newsItems[i].flags & 1) { + buttonIndex = 0; + break; + } else if (y < 14) { + buttonIndex = 0; + break; + } else if (y >= 38) { + buttonIndex = 0; + break; + } else if (x < 328) { + buttonIndex = 0; + break; + } else if (x < 351) { + if (RCT2_ADDRESS(0x0097BE7C, uint8)[newsItems[i].type] & 2) { + buttonIndex = 1; + break; + } + } else if (x < 376) { + if (RCT2_ADDRESS(0x0097BE7C, uint8)[newsItems[i].type] & 1) { + buttonIndex = 2; + break; + } + } + } + y -= 42; + } + + if (buttonIndex != 0) { + w->var_480 = i - 11; + w->var_482 = buttonIndex; + w->var_484 = 4; + window_invalidate(w); + sound_play_panned(4, w->x + (w->width / 2)); + } +} + +/** + * + * rct2: 0x0066EAAE + */ +static void window_news_tooltip() +{ + RCT2_GLOBAL(0x013CE952, uint16) = 3159; +} + +/** + * + * rct2: 0x0066E4E8 + */ +static void window_news_paint() +{ + int x, y; + rct_window *w; + rct_drawpixelinfo *dpi; + + __asm mov w, esi + __asm mov dpi, edi + + window_draw_widgets(w, dpi); +} + +/** + * + * rct2: 0x0066E4EE + */ +static void window_news_scrollpaint() +{ + int i, x, y, yy, press; + rct_window *w; + rct_drawpixelinfo *dpi; + rct_news_item *newsItems, *newsItem, *newsItem2; + + __asm mov w, esi + __asm mov dpi, edi + + y = 0; + newsItems = RCT2_ADDRESS(RCT2_ADDRESS_NEWS_ITEM_LIST, rct_news_item); + for (i = 11; i < 61; i++) { + newsItem = &newsItems[i]; + if (newsItem->type == NEWS_ITEM_NULL) + break; + if (y >= dpi->y + dpi->height) + break; + if (y + 42 < dpi->y) { + y += 42; + continue; + } + + // Background + gfx_fill_rect_inset(dpi, -1, y, 383, y + 41, w->colours[1], 0x24); + + // Date text + RCT2_GLOBAL(0x013CE952, uint16) = STR_DATE_DAY_1 + newsItem->day - 1; + RCT2_GLOBAL(0x013CE952 + 2, uint16) = STR_MONTH_MARCH + (newsItem->month % 8); + gfx_draw_string_left(dpi, 2235, 0x013CE952, 2, 4, y); + + // Item text + RCT2_GLOBAL(0x009B5F2C, uint8) = newsItem->colour; + strcpy(0x009B5F2D, newsItem->text); + gfx_draw_string_left_wrapped(dpi, 0, 2, y + 10, 325, 1926, 14); + + // Subject button + if ((RCT2_ADDRESS(0x0097BE7C, uint8)[newsItem->type] & 2) && !(newsItem->flags & 1)) { + x = 328; + yy = y + 14; + + press = 0; + if (w->var_480 != -1) { + newsItem2 = &newsItems[11 + w->var_480]; + if (newsItem == newsItem2 && w->var_482 == 1) + press = 0x20; + } + gfx_fill_rect_inset(dpi, x, yy, x + 23, yy + 23, w->colours[2], press); + + switch (newsItem->type) { + case NEWS_ITEM_RIDE: + gfx_draw_sprite(dpi, SPR_RIDE, x, yy); + break; + case NEWS_ITEM_PEEP_ON_RIDE: + // TODO + break; + case NEWS_ITEM_PEEP: + // TODO + break; + case NEWS_ITEM_MONEY: + gfx_draw_sprite(dpi, SPR_FINANCE, x, yy); + break; + case NEWS_ITEM_SCENERY: + gfx_draw_sprite(dpi, newsItem->assoc < 0x10000 ? SPR_NEW_RIDE : SPR_SCENERY, x, yy); + break; + case NEWS_ITEM_PEEPS: + gfx_draw_sprite(dpi, SPR_GUESTS, x, yy); + break; + case NEWS_ITEM_AWARD: + gfx_draw_sprite(dpi, SPR_AWARD, x, yy); + break; + case NEWS_ITEM_GRAPH: + gfx_draw_sprite(dpi, SPR_GRAPH, x, yy); + break; + } + } + + // Location button + if ((RCT2_ADDRESS(0x0097BE7C, uint8)[newsItem->type] & 1) && !(newsItem->flags & 1)) { + x = 352; + yy = y + 14; + + press = 0; + if (w->var_480 != -1) { + newsItem2 = &newsItems[11 + w->var_480]; + if (newsItem == newsItem2 && w->var_482 == 2) + press = 0x20; + } + gfx_fill_rect_inset(dpi, x, yy, x + 23, yy + 23, w->colours[2], press); + gfx_draw_sprite(dpi, SPR_LOCATE, x, yy); + } + + y += 42; + } +} \ No newline at end of file From f2b8c4984e3611fd98cc0fbebbdc2082dbb08ff2 Mon Sep 17 00:00:00 2001 From: Maciek Baron Date: Sat, 3 May 2014 18:13:10 +0100 Subject: [PATCH 03/44] Adding more possible locations for config.c --- src/config.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/config.c b/src/config.c index abebb81887..b8d87fff98 100644 --- a/src/config.c +++ b/src/config.c @@ -192,6 +192,10 @@ static int config_find_rct2_path(char *resultPath) const char *searchLocations[] = { "C:\\Program Files\\Infogrames\\RollerCoaster Tycoon 2", "C:\\Program Files (x86)\\Infogrames\\RollerCoaster Tycoon 2", + "C:\\Program Files\\Infogrames Interactive\\RollerCoaster Tycoon 2", + "C:\\Program Files (x86)\\Infogrames Interactive\\RollerCoaster Tycoon 2", + "C:\\Program Files\\Atari\\RollerCoaster Tycoon 2", + "C:\\Program Files (x86)\\Atari\\RollerCoaster Tycoon 2", "C:\\GOG Games\\RollerCoaster Tycoon 2 Triple Thrill Pack" }; From 61238c70f35436bcb58d0b824950c98f0a6197e5 Mon Sep 17 00:00:00 2001 From: Maciek Baron Date: Sun, 4 May 2014 16:16:03 +0100 Subject: [PATCH 04/44] Removing dupe address, adding OS hour and minute --- src/addresses.h | 5 +++-- src/config.c | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/addresses.h b/src/addresses.h index c6a9bd19a6..1bda37ad07 100644 --- a/src/addresses.h +++ b/src/addresses.h @@ -210,9 +210,10 @@ #define RCT2_ADDRESS_VIEWPORT_LIST 0x014234BC #define RCT2_ADDRESS_NEW_VIEWPORT_PTR 0x01423570 -#define RCT2_ADDRESS_OS_TIME_MONTH 0x01423A04 -#define RCT2_ADDRESS_OS_TOTALPHYS 0x01423B5C +#define RCT2_ADDRESS_OS_TIME_MINUTE 0x01424654 +#define RCT2_ADDRESS_OS_TIME_HOUR 0x01424656 #define RCT2_ADDRESS_OS_TIME_DAY 0x01424304 +#define RCT2_ADDRESS_OS_TIME_MONTH 0x01423A04 #define RCT2_ADDRESS_OS_TIME_YEAR 0x01424320 #define RCT2_ADDRESS_OS_TIME_DAYOFWEEK 0x01423B20 diff --git a/src/config.c b/src/config.c index b8d87fff98..951630cb8d 100644 --- a/src/config.c +++ b/src/config.c @@ -109,9 +109,9 @@ void config_load() } RCT2_GLOBAL(0x009AAC77, sint8) = 0; - if (RCT2_GLOBAL(RCT2_ADDRESS_OS_TOTALPHYS, uint32) > 0x4000000) { + if (RCT2_GLOBAL(RCT2_ADDRESS_MEM_TOTAL_PHYSICAL, uint32) > 0x4000000) { RCT2_GLOBAL(0x009AAC77, sint8) = 1; - if (RCT2_GLOBAL(RCT2_ADDRESS_OS_TOTALPHYS, uint32) > 0x8000000) + if (RCT2_GLOBAL(RCT2_ADDRESS_MEM_TOTAL_PHYSICAL, uint32) > 0x8000000) RCT2_GLOBAL(0x009AAC77, sint8) = 2; } From a0976e2f407beec26267a7930de6285076873049 Mon Sep 17 00:00:00 2001 From: IntelOrca Date: Sun, 4 May 2014 16:21:15 +0100 Subject: [PATCH 05/44] add load saved game --- src/game.c | 104 ++++++++++++++++++++++++++++++++++++++++++++++++- src/game.h | 1 + src/rct2.c | 2 +- src/scenario.c | 3 +- src/strings.h | 1 + 5 files changed, 107 insertions(+), 4 deletions(-) diff --git a/src/game.c b/src/game.c index b502ab38cf..8f9666fef4 100644 --- a/src/game.c +++ b/src/game.c @@ -25,13 +25,16 @@ #include "rct2.h" #include "game.h" #include "news_item.h" +#include "object.h" #include "osinterface.h" #include "peep.h" +#include "sawyercoding.h" #include "scenario.h" #include "screenshot.h" #include "strings.h" #include "title.h" #include "tutorial.h" +#include "viewport.h" #include "widget.h" #include "window.h" #include "window_error.h" @@ -1201,6 +1204,104 @@ static void load_landscape() } } +/** + * + * rct2: 0x00675E1B + */ +int game_load_save() +{ + rct_window *mainWindow; + HANDLE hFile; + char *path; + int i, j; + + path = (char*)0x0141EF68; + hFile = CreateFile( + path, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_RANDOM_ACCESS | FILE_ATTRIBUTE_NORMAL, NULL + ); + if (hFile == NULL) { + RCT2_GLOBAL(0x009AC31B, uint8) = 255; + RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_STRING_ID, uint16) = STR_FILE_CONTAINS_INVALID_DATA; + return 0; + } + + RCT2_GLOBAL(0x009E382C, HANDLE) = hFile; + // RCT2_CALLPROC_EBPSAFE(0x00676FD2); // check file checksum + + rct_s6_header *s6Header = 0x009E34E4; + rct_s6_info *s6Info = 0x0141F570; + + // Read first chunk + sawyercoding_read_chunk(hFile, s6Header); + if (s6Header->type == S6_TYPE_SAVEDGAME) { + // Read packed objects + if (s6Header->num_packed_objects > 0) { + j = 0; + for (i = 0; i < s6Header->num_packed_objects; i++) + j += object_load_packed(); + if (j > 0) + object_load_list(); + } + } + + object_read_and_load_entries(hFile); + + // Read flags (16 bytes) + sawyercoding_read_chunk(hFile, RCT2_ADDRESS_CURRENT_MONTH_YEAR); + + // Read map elements + memset(RCT2_ADDRESS_MAP_ELEMENTS, 0, MAX_MAP_ELEMENTS * sizeof(rct_map_element)); + sawyercoding_read_chunk(hFile, RCT2_ADDRESS_MAP_ELEMENTS); + + // Read game data, including sprites + sawyercoding_read_chunk(hFile, 0x010E63B8); + + CloseHandle(hFile); + + // Check expansion pack + // RCT2_CALLPROC_EBPSAFE(0x006757E6); + + // The rest is the same as in scenario load and play + RCT2_CALLPROC_EBPSAFE(0x006A9FC0); + map_update_tile_pointers(); + RCT2_CALLPROC_EBPSAFE(0x0069EBE4); + RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) = SCREEN_FLAGS_PLAYING; + viewport_init_all(); + game_create_windows(); + mainWindow = window_get_main(); + + mainWindow->var_4B0 = -1; + mainWindow->saved_view_x = RCT2_GLOBAL(RCT2_ADDRESS_SAVED_VIEW_X, sint16); + mainWindow->saved_view_y = RCT2_GLOBAL(RCT2_ADDRESS_SAVED_VIEW_Y, sint16); + uint8 _cl = (RCT2_GLOBAL(0x0138869E, sint16) & 0xFF) - mainWindow->viewport->zoom; + mainWindow->viewport->zoom = RCT2_GLOBAL(0x0138869E, sint16) & 0xFF; + *((char*)(&RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, sint32))) = RCT2_GLOBAL(0x0138869E, sint16) >> 8; + if (_cl != 0) { + if (_cl < 0) { + _cl = -_cl; + mainWindow->viewport->view_width >>= _cl; + mainWindow->viewport->view_height >>= _cl; + } else { + mainWindow->viewport->view_width <<= _cl; + mainWindow->viewport->view_height <<= _cl; + } + } + mainWindow->saved_view_x -= mainWindow->viewport->view_width >> 1; + mainWindow->saved_view_y -= mainWindow->viewport->view_height >> 1; + window_invalidate(mainWindow); + + RCT2_CALLPROC_EBPSAFE(0x0069E9A7); + RCT2_CALLPROC_EBPSAFE(0x006DFEE4); + RCT2_CALLPROC_EBPSAFE(0x006ACA58); + RCT2_GLOBAL(0x009DEB7C, uint16) = 0; + if (RCT2_GLOBAL(0x0013587C4, uint32) == 0) // this check is not in scenario play + RCT2_CALLPROC_EBPSAFE(0x0069E869); + + RCT2_CALLPROC_EBPSAFE(0x006837E3); // (palette related) + gfx_invalidate_screen(); + return 1; +} + /** * * rct2: 0x0066DBB7 @@ -1223,8 +1324,7 @@ static void load_game() } strcpy(0x009ABB37, 0x0141EF68); - RCT2_CALLPROC_EBPSAFE(0x00675E1B); // game_load - if (1) { + if (game_load_save()) { gfx_invalidate_screen(); rct2_endupdate(); } else { diff --git a/src/game.h b/src/game.h index 23aaff9a33..8619d04526 100644 --- a/src/game.h +++ b/src/game.h @@ -28,5 +28,6 @@ void game_logic_update(); int game_do_command(int eax, int ebx, int ecx, int edx, int esi, int edi, int ebp); void game_load_or_quit_no_save_prompt(); +int game_load_save(); #endif diff --git a/src/rct2.c b/src/rct2.c index fa49f9d794..569a82a7a1 100644 --- a/src/rct2.c +++ b/src/rct2.c @@ -235,7 +235,7 @@ void check_cmdline_arg() if(!stricmp(processed_arg + last_period, "sv6")) { strcpy(0x00141EF68, processed_arg); - RCT2_CALLPROC_EBPSAFE(0x00675E1B); //load_saved_game + game_load_save(); } else if(!stricmp(processed_arg + last_period, "sc6")) { diff --git a/src/scenario.c b/src/scenario.c index 05871c5780..1364cddb6e 100644 --- a/src/scenario.c +++ b/src/scenario.c @@ -329,6 +329,7 @@ void scenario_load(char *path) ); if (hFile != INVALID_HANDLE_VALUE) { RCT2_GLOBAL(0x009E382C, HANDLE*) = hFile; + // RCT2_CALLPROC_EBPSAFE(0x00676FD2); // check file checksum // Read first chunk sawyercoding_read_chunk(hFile, s6Header); @@ -393,7 +394,7 @@ void scenario_load(char *path) } RCT2_GLOBAL(0x009AC31B, uint8) = 255; - RCT2_GLOBAL(0x009AC31C, uint16) = 3011; + RCT2_GLOBAL(0x009AC31C, uint16) = STR_FILE_CONTAINS_INVALID_DATA; } /** diff --git a/src/strings.h b/src/strings.h index f664887074..3afedf5f26 100644 --- a/src/strings.h +++ b/src/strings.h @@ -438,6 +438,7 @@ enum { STR_LICENCE_AGREEMENT_NOTICE_2 = 2970, STR_UNABLE_TO_LOAD_FILE = 3010, + STR_FILE_CONTAINS_INVALID_DATA = 3011, STR_BEGINNER_PARKS = 3064, STR_CHALLENGING_PARKS = STR_BEGINNER_PARKS + 1, From 0477e2803b45a5ac7eef0767767aa3dda5452314 Mon Sep 17 00:00:00 2001 From: Maciek Baron Date: Sun, 4 May 2014 16:31:32 +0100 Subject: [PATCH 06/44] Implementing get_local_time() --- src/rct2.c | 16 +++++++++++++++- src/rct2.h | 1 + 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/rct2.c b/src/rct2.c index fa49f9d794..63f36fc196 100644 --- a/src/rct2.c +++ b/src/rct2.c @@ -122,7 +122,8 @@ void rct2_init() RCT2_CALLPROC_EBPSAFE(0x006BA8E0); // init_audio(); viewport_init_all(); news_item_init_queue(); - RCT2_CALLPROC_EBPSAFE(0x006C45E7); // get local time + get_local_time(); + OutputDebugString(s); RCT2_CALLPROC_EBPSAFE(0x00667104); RCT2_CALLPROC_EBPSAFE(0x006C4209); RCT2_CALLPROC_EBPSAFE(0x0069EB13); @@ -376,6 +377,19 @@ void get_system_time() RCT2_GLOBAL(RCT2_ADDRESS_OS_TIME_DAYOFWEEK, sint16) = systime.wDayOfWeek; } +/** + * Obtains os local time (hour and minute) + * rct2: 0x006C45E7; + */ +void get_local_time() +{ + SYSTEMTIME systime; + GetLocalTime(&systime); + + RCT2_GLOBAL(RCT2_ADDRESS_OS_TIME_HOUR, sint16) = systime.wHour; + RCT2_GLOBAL(RCT2_ADDRESS_OS_TIME_MINUTE, sint16) = systime.wMinute; +} + /** * RCT2 and this DLL can not free each other's allocated memory blocks. Use this to allocate memory if RCT2 is still able to * free it. diff --git a/src/rct2.h b/src/rct2.h index 2d4d479daa..d0a75a23ed 100644 --- a/src/rct2.h +++ b/src/rct2.h @@ -126,6 +126,7 @@ void rct2_endupdate(); char *get_file_path(int pathId); void get_system_info(); void get_system_time(); +void get_local_time(); void *rct2_malloc(size_t numBytes); void *rct2_realloc(void *block, size_t numBytes); void rct2_free(void *block); From 3ac5447abeb2e264d383e92c6d2ed06ff6f5a384 Mon Sep 17 00:00:00 2001 From: IntelOrca Date: Sun, 4 May 2014 16:32:10 +0100 Subject: [PATCH 07/44] fix news window multiple copies bug --- src/window_news.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/window_news.c b/src/window_news.c index 46888608ed..daa4f53939 100644 --- a/src/window_news.c +++ b/src/window_news.c @@ -99,7 +99,7 @@ void window_news_open() 400, 300, window_news_events, - WC_ABOUT, + WC_RECENT_NEWS, 0 ); window->widgets = window_news_widgets; From 6819b787edbfee2e29ac34b4d0e022098800393c Mon Sep 17 00:00:00 2001 From: IntelOrca Date: Sun, 4 May 2014 16:32:48 +0100 Subject: [PATCH 08/44] remove key debug check --- src/game.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/game.c b/src/game.c index 8f9666fef4..5b9fce5088 100644 --- a/src/game.c +++ b/src/game.c @@ -878,9 +878,6 @@ void handle_shortcut(int key) break; } } - if (key == SDL_SCANCODE_M) { - key = key; - } } /** From cde954ba637db7b8f0b8a397780edf85da68a0ee Mon Sep 17 00:00:00 2001 From: Maciek Baron Date: Sun, 4 May 2014 16:34:35 +0100 Subject: [PATCH 09/44] Removing leftover debug code --- src/rct2.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/rct2.c b/src/rct2.c index 63f36fc196..7cffc413be 100644 --- a/src/rct2.c +++ b/src/rct2.c @@ -123,7 +123,6 @@ void rct2_init() viewport_init_all(); news_item_init_queue(); get_local_time(); - OutputDebugString(s); RCT2_CALLPROC_EBPSAFE(0x00667104); RCT2_CALLPROC_EBPSAFE(0x006C4209); RCT2_CALLPROC_EBPSAFE(0x0069EB13); From 9b6873f09e1184fb5b51dc37d706807f38e3ed9a Mon Sep 17 00:00:00 2001 From: IntelOrca Date: Sun, 4 May 2014 17:34:13 +0100 Subject: [PATCH 10/44] add checksum validation for load sc6 and sv6 --- src/game.c | 7 ++++++- src/sawyercoding.c | 42 ++++++++++++++++++++++++++++++++++++++++++ src/sawyercoding.h | 1 + src/scenario.c | 7 ++++++- 4 files changed, 55 insertions(+), 2 deletions(-) diff --git a/src/game.c b/src/game.c index 5b9fce5088..43e55f9e25 100644 --- a/src/game.c +++ b/src/game.c @@ -1223,7 +1223,12 @@ int game_load_save() } RCT2_GLOBAL(0x009E382C, HANDLE) = hFile; - // RCT2_CALLPROC_EBPSAFE(0x00676FD2); // check file checksum + if (!sawyercoding_validate_checksum(hFile)) { + CloseHandle(hFile); + RCT2_GLOBAL(0x009AC31B, uint8) = 255; + RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_STRING_ID, uint16) = STR_FILE_CONTAINS_INVALID_DATA; + return 0; + } rct_s6_header *s6Header = 0x009E34E4; rct_s6_info *s6Info = 0x0141F570; diff --git a/src/sawyercoding.c b/src/sawyercoding.c index a48f55d357..c5393e02d4 100644 --- a/src/sawyercoding.c +++ b/src/sawyercoding.c @@ -27,6 +27,48 @@ static int decode_chunk_rle(char *buffer, int length); static int decode_chunk_repeat(char *buffer, int length); static void decode_chunk_rotate(char *buffer, int length); +/** + * + * rct2: 0x00676FD2 + */ +int sawyercoding_validate_checksum(HFILE hFile) +{ + int i; + uint32 checksum, fileChecksum; + DWORD dataSize, bufferSize, numBytesRead; + uint8 buffer[1024]; + + // Get data size + if ((dataSize = SetFilePointer(hFile, 0, NULL, FILE_END)) < 8) + return; + dataSize -= 4; + + // Calculate checksum + SetFilePointer(hFile, 0, NULL, FILE_BEGIN); + checksum = 0; + do { + bufferSize = min(dataSize, 1024); + ReadFile(hFile, buffer, bufferSize, &numBytesRead, NULL); + if (numBytesRead != bufferSize) + return 0; + + for (i = 0; i < bufferSize; i++) + checksum += buffer[i]; + dataSize -= bufferSize; + } while (dataSize != 0); + + // Read file checksum + ReadFile(hFile, &fileChecksum, sizeof(fileChecksum), &numBytesRead, NULL); + if (numBytesRead != sizeof(fileChecksum)) + return 0; + + // Reset file position + SetFilePointer(hFile, 0, NULL, FILE_BEGIN); + + // Validate + return checksum == fileChecksum; +} + /** * * rct2: 0x0067685F diff --git a/src/sawyercoding.h b/src/sawyercoding.h index 08956192b7..7b30566703 100644 --- a/src/sawyercoding.h +++ b/src/sawyercoding.h @@ -36,6 +36,7 @@ enum { CHUNK_ENCODING_ROTATE }; +int sawyercoding_validate_checksum(HFILE hFile); int sawyercoding_read_chunk(HFILE hFile, uint8 *buffer); #endif diff --git a/src/scenario.c b/src/scenario.c index 1364cddb6e..cd0fb9b931 100644 --- a/src/scenario.c +++ b/src/scenario.c @@ -329,7 +329,12 @@ void scenario_load(char *path) ); if (hFile != INVALID_HANDLE_VALUE) { RCT2_GLOBAL(0x009E382C, HANDLE*) = hFile; - // RCT2_CALLPROC_EBPSAFE(0x00676FD2); // check file checksum + if (!sawyercoding_validate_checksum(hFile)) { + CloseHandle(hFile); + RCT2_GLOBAL(0x009AC31B, uint8) = 255; + RCT2_GLOBAL(0x009AC31C, uint16) = STR_FILE_CONTAINS_INVALID_DATA; + return; + } // Read first chunk sawyercoding_read_chunk(hFile, s6Header); From 160c3887398207dbcbb2e8d3dee5fa2a661ff5aa Mon Sep 17 00:00:00 2001 From: IntelOrca Date: Sun, 4 May 2014 18:02:28 +0100 Subject: [PATCH 11/44] name more functions in editor.c --- src/editor.c | 36 ++++++++++++++++++------------------ src/window.h | 1 + 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/src/editor.c b/src/editor.c index 109e947e36..0c53218ee2 100644 --- a/src/editor.c +++ b/src/editor.c @@ -40,25 +40,25 @@ void editor_load() { rct_window *mainWindow; - RCT2_CALLPROC_EBPSAFE(0x006BABB4); - RCT2_CALLPROC_EBPSAFE(0x006BABD8); + RCT2_CALLPROC_EBPSAFE(0x006BABB4); // pause_sounds + RCT2_CALLPROC_EBPSAFE(0x006BABD8); // unpause_sounds RCT2_CALLPROC_EBPSAFE(0x006A9CE8); map_init(); RCT2_CALLPROC_EBPSAFE(0x006B9CB0); - RCT2_CALLPROC_EBPSAFE(0x00667104); - RCT2_CALLPROC_EBPSAFE(0x006C4209); - RCT2_CALLPROC_EBPSAFE(0x0069EB13); + RCT2_CALLPROC_EBPSAFE(0x00667104); // reset_park_entrances + RCT2_CALLPROC_EBPSAFE(0x006C4209); // reset_saved_strings + RCT2_CALLPROC_EBPSAFE(0x0069EB13); // sprites_init ride_init_all(); RCT2_CALLPROC_EBPSAFE(0x0068F083); // window_guest_list_init_vars_a RCT2_CALLPROC_EBPSAFE(0x006BD3A4); park_init(); - RCT2_CALLPROC_EBPSAFE(0x0069DEFB); + RCT2_CALLPROC_EBPSAFE(0x0069DEFB); // finance_init date_reset(); RCT2_CALLPROC_EBPSAFE(0x0068F050); // window_guest_list_init_vars_b RCT2_CALLPROC_EBPSAFE(0x006BD39C); RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) = SCREEN_FLAGS_SCENARIO_EDITOR; RCT2_GLOBAL(0x0141F570, uint8) = 0; - RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) |= 16; + RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) |= PARK_FLAGS_SHOW_REAL_GUEST_NAMES; RCT2_CALLPROC_EBPSAFE(0x006ACA58); RCT2_GLOBAL(0x0141F571, uint8) = 4; viewport_init_all(); @@ -66,7 +66,7 @@ void editor_load() RCT2_CALLPROC_EBPSAFE(0x0066EF38); // window_main_editor_create mainWindow = window_get_main(); window_scroll_to_location(mainWindow, 2400, 2400, 112); - mainWindow->flags &= ~0x08; + mainWindow->flags &= ~WF_3; RCT2_CALLPROC_EBPSAFE(0x006837E3); gfx_invalidate_screen(); RCT2_GLOBAL(0x009DEA66, sint16) = 0; @@ -94,14 +94,14 @@ void trackdesigner_load() map_init(); set_all_land_owned(); RCT2_CALLPROC_EBPSAFE(0x006B9CB0); - RCT2_CALLPROC_EBPSAFE(0x00667104); - RCT2_CALLPROC_EBPSAFE(0x006C4209); - RCT2_CALLPROC_EBPSAFE(0x0069EB13); + RCT2_CALLPROC_EBPSAFE(0x00667104); // reset_park_entrances + RCT2_CALLPROC_EBPSAFE(0x006C4209); // reset_saved_strings + RCT2_CALLPROC_EBPSAFE(0x0069EB13); // reset_sprites ride_init_all(); RCT2_CALLPROC_EBPSAFE(0x0068F083); // window_guest_list_init_vars_a RCT2_CALLPROC_EBPSAFE(0x006BD3A4); park_init(); - RCT2_CALLPROC_EBPSAFE(0x0069DEFB); + RCT2_CALLPROC_EBPSAFE(0x0069DEFB); // finance_init date_reset(); RCT2_CALLPROC_EBPSAFE(0x0068F050); // window_guest_list_init_vars_b RCT2_CALLPROC_EBPSAFE(0x006BD39C); @@ -113,7 +113,7 @@ void trackdesigner_load() RCT2_CALLPROC_EBPSAFE(0x0066EF38); // window_main_editor_create mainWindow = window_get_main(); window_scroll_to_location(mainWindow, 2400, 2400, 112); - mainWindow->flags &= ~0x08; + mainWindow->flags &= ~WF_3; RCT2_CALLPROC_EBPSAFE(0x006837E3); gfx_invalidate_screen(); RCT2_GLOBAL(0x009DEA66, sint16) = 0; @@ -132,14 +132,14 @@ void trackmanager_load() map_init(); set_all_land_owned(); RCT2_CALLPROC_EBPSAFE(0x006B9CB0); - RCT2_CALLPROC_EBPSAFE(0x00667104); - RCT2_CALLPROC_EBPSAFE(0x006C4209); - RCT2_CALLPROC_EBPSAFE(0x0069EB13); + RCT2_CALLPROC_EBPSAFE(0x00667104); // reset_park_entrances + RCT2_CALLPROC_EBPSAFE(0x006C4209); // reset_saved_strings + RCT2_CALLPROC_EBPSAFE(0x0069EB13); // reset_sprites ride_init_all(); RCT2_CALLPROC_EBPSAFE(0x0068F083); // window_guest_list_init_vars_a RCT2_CALLPROC_EBPSAFE(0x006BD3A4); park_init(); - RCT2_CALLPROC_EBPSAFE(0x0069DEFB); + RCT2_CALLPROC_EBPSAFE(0x0069DEFB); // finance_init date_reset(); RCT2_CALLPROC_EBPSAFE(0x0068F050); // window_guest_list_init_vars_b RCT2_CALLPROC_EBPSAFE(0x006BD39C); @@ -151,7 +151,7 @@ void trackmanager_load() RCT2_CALLPROC_EBPSAFE(0x0066EF38); // window_main_editor_create mainWindow = window_get_main(); window_scroll_to_location(mainWindow, 2400, 2400, 112); - mainWindow->flags &= ~0x08; + mainWindow->flags &= ~WF_3; RCT2_CALLPROC_EBPSAFE(0x006837E3); gfx_invalidate_screen(); RCT2_GLOBAL(0x009DEA66, sint16) = 0; diff --git a/src/window.h b/src/window.h index ea3feefca1..6559e7c5c8 100644 --- a/src/window.h +++ b/src/window.h @@ -190,6 +190,7 @@ typedef enum { WF_STICK_TO_BACK = (1 << 0), WF_STICK_TO_FRONT = (1 << 1), WF_2 = (1 << 2), + WF_3 = (1 << 3), WF_TRANSPARENT = (1 << 4), WF_5 = (1 << 5), WF_RESIZABLE = (1 << 8), From d18ff2bb1b497ccba8d31e63fa67c941b9efa1db Mon Sep 17 00:00:00 2001 From: Maciek Baron Date: Sun, 4 May 2014 18:49:06 +0100 Subject: [PATCH 12/44] Adding peep thought types --- src/peep.h | 138 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 138 insertions(+) diff --git a/src/peep.h b/src/peep.h index 14d4051753..917d41324b 100644 --- a/src/peep.h +++ b/src/peep.h @@ -38,6 +38,144 @@ enum STAFF_TYPE { }; enum PEEP_THOUGHT_TYPE { + PEEP_THOUGHT_TYPE_SPENT_MONEY = 1, // "I've spent all my money" + PEEP_THOUGHT_TYPE_SICK = 2, // "I feel sick" + PEEP_THOUGHT_TYPE_VERY_SICK = 3, // "I feel very sick" + PEEP_THOUGHT_TYPE_MORE_THRILLING = 4, // "I want to go on something more thrilling than X" + PEEP_THOUGHT_TYPE_INTENSE = 5, // "X looks too intense for me" + PEEP_THOUGHT_TYPE_HAVENT_FINISHED = 6, // "I haven't finished my X yet" + PEEP_THOUGHT_TYPE_SICKENING = 7, // "Just looking at X makes me feel sick" + PEEP_THOUGHT_TYPE_BAD_VALUE = 8, // "I'm not paying that much to go on X" + PEEP_THOUGHT_TYPE_GO_HOME = 9, // "I want to go home" + PEEP_THOUGHT_TYPE_GOOD_VALUE = 10, // "X is really good value" + PEEP_THOUGHT_TYPE_ALREADY_GOT = 11, // "I've already got" + PEEP_THOUGHT_TYPE_CANT_AFFORD = 12, // "I can't afford" + PEEP_THOUGHT_TYPE_NOT_HUNGRY = 13, // "I'm not not hungry" + PEEP_THOUGHT_TYPE_NOT_THIRSTY = 14, // "I'm not not thirsty" + PEEP_THOUGHT_TYPE_DROWNING = 15, // "Help! I'm drowning!" + PEEP_THOUGHT_TYPE_LOST = 16, // "I'm lost!" + PEEP_THOUGHT_TYPE_WAS_GREAT = 17, // "X was great" + PEEP_THOUGHT_TYPE_QUEUING_AGES = 18, // "I've been queuing for X for ages" + PEEP_THOUGHT_TYPE_TIRED = 19, // "I'm tired" + PEEP_THOUGHT_TYPE_HUNGRY = 20, // "I'm hungry" + PEEP_THOUGHT_TYPE_THIRSTY = 21, // "I'm thirsty" + PEEP_THOUGHT_TYPE_BATHROOM = 22, // "I need to go to the bathroom" + PEEP_THOUGHT_TYPE_CANT_FIND = 23, // "I can't find X" + PEEP_THOUGHT_TYPE_NOT_PAYING = 24, // "I'm not paying that much to use X" + PEEP_THOUGHT_TYPE_NOT_WHILE_RAINING = 25, // "I'm not going on X while it's raining" + PEEP_THOUGHT_TYPE_BAD_LITTER = 26, // "The litter here is really bad" + PEEP_THOUGHT_TYPE_CANT_FIND_EXIT = 27, // "I can't find the exit" + PEEP_THOUGHT_TYPE_GET_OFF = 28, // "I want to get off X" + PEEP_THOUGHT_TYPE_GET_OUT = 29, // "I want to get out of X" + PEEP_THOUGHT_TYPE_NOT_SAFE = 30, // "I'm not going on X - it isn't safe" + PEEP_THOUGHT_TYPE_PATH_DISGUSTING = 31, // "This path is disgusting" + PEEP_THOUGHT_TYPE_CROWDED = 32, // "It's too crowded here" + PEEP_THOUGHT_TYPE_VANDALISM = 33, // "The vandalism here is really bad" + PEEP_THOUGHT_TYPE_SCENERY = 34, // "Great scenery!" + PEEP_THOUGHT_VERY_CLEAN = 35, // "This park is very clean and tidy" + PEEP_THOUGHT_TYPE_FOUNTAINS = 36, // "The jumping fountains are great" + PEEP_THOUGHT_TYPE_MUSIC = 37, // "The music is nice here" + PEEP_THOUGHT_TYPE_BALLOON = 38, // "This baloon from X is really good value" + PEEP_THOUGHT_TYPE_TOY = 39, // "This cuddly toy from X is really good value" + PEEP_THOUGHT_TYPE_MAP = 40, + PEEP_THOUGHT_TYPE_PHOTO = 41, // "This on ride photo from X is really good value" + PEEP_THOUGHT_TYPE_UMBRELLA = 42, + PEEP_THOUGHT_TYPE_DRINK = 43, + PEEP_THOUGHT_TYPE_BURGER = 44, + PEEP_THOUGHT_TYPE_FRIES = 45, + PEEP_THOUGHT_TYPE_ICE_CREAM = 46, + PEEP_THOUGHT_TYPE_COTTON_CANDY = 47, + + PEEP_THOUGHT_TYPE_PIZZA = 51, + + PEEP_THOUGHT_TYPE_POPCORN = 53, + PEEP_THOUGHT_TYPE_HOT_DOG = 54, + PEEP_THOUGHT_TYPE_TENTACLE = 55, + PEEP_THOUGHT_TYPE_HAT = 56, + PEEP_THOUGHT_TYPE_CANDY_APPLE = 57, + PEEP_THOUGHT_TYPE_TSHIRT = 58, + PEEP_THOUGHT_TYPE_DONUT = 59, + PEEP_THOUGHT_TYPE_COFFEE = 60, + + PEEP_THOUGHT_TYPE_CHICKEN = 62, + PEEP_THOUGHT_TYPE_LEMONADE = 63, + + PEEP_THOUGHT_TYPE_WOW = 67, // "Wow!" + + PEEP_THOUGHT_TYPE_WOW2 = 70,// "Wow!" + PEEP_THOUGHT_TYPE_WATCHED = 71, // "I have the strangest feeling someone is watching me" + PEEP_THOUGHT_TYPE_BALLOON_MUCH = 72, // "I'm not paying that much to get a balloon from X" + PEEP_THOUGHT_TYPE_TOY_MUCH = 73, + PEEP_THOUGHT_TYPE_MAP_MUCH = 74, + PEEP_THOUGHT_TYPE_PHOTO_MUCH = 75, + PEEP_THOUGHT_TYPE_UMBRELLA_MUCH = 76, + PEEP_THOUGHT_TYPE_DRINK_MUCH = 77, + PEEP_THOUGHT_TYPE_BURGER_MUCH = 78, + PEEP_THOUGHT_TYPE_FRIES_MUCH = 79, + PEEP_THOUGHT_TYPE_ICE_CREAM_MUCH = 80, + PEEP_THOUGHT_TYPE_COTTON_CANDY_MUCH = 81, + + PEEP_THOUGHT_TYPE_PIZZA_MUCH = 85, + + PEEP_THOUGHT_TYPE_POPCORN_MUCH = 87, + PEEP_THOUGHT_TYPE_HOT_DOG_MUCH = 88, + PEEP_THOUGHT_TYPE_TENTACLE_MUCH = 89, + PEEP_THOUGHT_TYPE_HAT_MUCH = 90, + PEEP_THOUGHT_TYPE_CANDY_APPLE_MUCH = 91, + PEEP_THOUGHT_TYPE_TSHIRT_MUCH = 92, + PEEP_THOUGHT_TYPE_DONUT_MUCH = 93, + PEEP_THOUGHT_TYPE_COFFEE_MUCH = 94, + + PEEP_THOUGHT_TYPE_CHICKEN_MUCH = 96, + PEEP_THOUGHT_TYPE_LEMONADE_MUCH = 97, + + PEEP_THOUGHT_TYPE_PHOTO2 = 104, // "This on-ride photo from X is really good value" + PEEP_THOUGHT_TYPE_PHOTO3 = 105, + PEEP_THOUGHT_TYPE_PHOTO4 = 106, + PEEP_THOUGHT_TYPE_PRETZEL = 107, + PEEP_THOUGHT_TYPE_HOT_CHOCOLATE = 108, + PEEP_THOUGHT_TYPE_ICED_TEA = 109, + PEEP_THOUGHT_TYPE_FUNNEL_CAKE = 110, + PEEP_THOUGHT_TYPE_SUNGLASSES = 111, + PEEP_THOUGHT_TYPE_BEEF_NOODLES = 112, + PEEP_THOUGHT_TYPE_FRIED_RICE_NOODLES = 113, + PEEP_THOUGHT_TYPE_WONTON_SOUP = 114, + PEEP_THOUGHT_TYPE_MEATBALL_SOUP = 115, + PEEP_THOUGHT_TYPE_FRUIT_JUICE = 116, + PEEP_THOUGHT_TYPE_SOYBEAN_MILK = 117, + PEEP_THOUGHT_TYPE_SU_JONGKWA = 118, + PEEP_THOUGHT_TYPE_SUB_SANDWICH = 119, + PEEP_THOUGHT_TYPE_COOKIE = 120, + + PEEP_THOUGH_ROAST_SAUSAGE = 124, + + PEEP_THOUGHT_TYPE_PHOTO2_MUCH = 136, + PEEP_THOUGHT_TYPE_PHOTO3_MUCH = 137, + PEEP_THOUGHT_TYPE_PHOTO4_MUCH = 138, + PEEP_THOUGHT_TYPE_PRETZEL_MUCH = 139, + PEEP_THOUGHT_TYPE_HOT_CHOCOLATE_MUCH = 140, + PEEP_THOUGHT_TYPE_ICED_TEA_MUCH = 141, + PEEP_THOUGHT_TYPE_FUNNEL_CAKE_MUCH = 142, + PEEP_THOUGHT_TYPE_SUNGLASSES_MUCH = 143, + PEEP_THOUGHT_TYPE_BEEF_NOODLES_MUCH = 144, + PEEP_THOUGHT_TYPE_FRIED_RICE_NOODLES_MUCH = 145, + PEEP_THOUGHT_TYPE_WONTON_SOUP_MUCH = 146, + PEEP_THOUGHT_TYPE_MEATBALL_SOUP_MUCH = 147, + PEEP_THOUGHT_TYPE_FRUIT_JUICE_MUCH = 148, + PEEP_THOUGHT_TYPE_SOYBEAN_MILK_MUCH = 149, + PEEP_THOUGHT_TYPE_SU_JONGKWA_MUCH = 150, + PEEP_THOUGHT_TYPE_SUB_SANDWICH_MUCH = 151, + PEEP_THOUGHT_TYPE_COOKIE_MUCH = 152, + + PEEP_THOUGH_ROAST_SAUSAGE_MUCH = 156, + + PEEP_THOUGH_HELP = 168, // "Help! Put me down!" + PEEP_THOUGH_RUNNING_OUT = 169, // I'm running out of cash!" + PEEP_THOUGH_NEW_RIDE = 170, // "Wow! A new ride being built!" + PEEP_THOUGH_NICE_RIDE = 171, // "Nice ride! But not as good as the Phoenix..." + PEEP_THOUGH_EXCITED = 172, // "I'm so excited - It's an Intamin ride!" + PEEP_THOUGH_HERE_WE_ARE = 173, // "...and here we are on X!" + PEEP_THOUGHT_TYPE_NONE = 255 }; From da7563c7c92dbf9bb7c35fb4dfe01067e8ab79a1 Mon Sep 17 00:00:00 2001 From: IntelOrca Date: Sun, 4 May 2014 18:51:36 +0100 Subject: [PATCH 13/44] add unknown map element function --- src/game.c | 2 +- src/map.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/map.h | 1 + 3 files changed, 52 insertions(+), 1 deletion(-) diff --git a/src/game.c b/src/game.c index 43e55f9e25..c20491046e 100644 --- a/src/game.c +++ b/src/game.c @@ -140,7 +140,7 @@ void game_logic_update() if (RCT2_GLOBAL(0x009DEA66, sint16) == 0) RCT2_GLOBAL(0x009DEA66, sint16)--; - RCT2_CALLPROC_EBPSAFE(0x0068B089); + sub_68B089(); scenario_update(); climate_update(); RCT2_CALLPROC_EBPSAFE(0x006646E1); diff --git a/src/map.c b/src/map.c index 3a62c79253..581eabdf30 100644 --- a/src/map.c +++ b/src/map.c @@ -280,3 +280,53 @@ int map_element_height(int x, int y) return height; } + +/** + * + * rct2: 0x0068B089 + */ +void sub_68B089() +{ + int i; + rct_map_element *mapElementFirst, *mapElement; + + if (RCT2_GLOBAL(0x009DEA6F, uint8) & 1) + return; + + i = RCT2_GLOBAL(0x0010E63B8, uint32); + do { + i++; + if (i >= MAX_TILE_MAP_ELEMENT_POINTERS) + i = 0; + } while (TILE_MAP_ELEMENT_POINTER(i) == 0xFFFFFFFF); + RCT2_GLOBAL(0x0010E63B8, uint32) = i; + + mapElementFirst = mapElement = TILE_MAP_ELEMENT_POINTER(i); + do { + mapElement--; + if (mapElement < RCT2_ADDRESS_MAP_ELEMENTS) + break; + } while (mapElement->base_height == 255); + mapElement++; + + if (mapElement == mapElementFirst) + return; + + // + TILE_MAP_ELEMENT_POINTER(i) = mapElement; + do { + *mapElement = *mapElementFirst; + mapElementFirst->base_height = 255; + + mapElement++; + mapElementFirst++; + } while (!((mapElement - 1)->flags & MAP_ELEMENT_FLAG_LAST_TILE)); + + // Update next free element? + mapElement = RCT2_GLOBAL(0x0140E9A4, rct_map_element*); + do { + mapElement--; + } while (mapElement->base_height == 255); + mapElement++; + RCT2_GLOBAL(0x0140E9A4, rct_map_element*) = mapElement; +} \ No newline at end of file diff --git a/src/map.h b/src/map.h index 5d0f1a655b..88e76d7e11 100644 --- a/src/map.h +++ b/src/map.h @@ -185,5 +185,6 @@ enum { void map_init(); void map_update_tile_pointers(); int map_element_height(int x, int y); +void sub_68B089(); #endif From c062992e78502e2ea39e7251d4ddf0edb1423240 Mon Sep 17 00:00:00 2001 From: IntelOrca Date: Sun, 4 May 2014 19:59:24 +0100 Subject: [PATCH 14/44] add play intro config setting --- src/config.c | 3 +++ src/config.h | 1 + src/rct2.c | 3 +-- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/config.c b/src/config.c index 951630cb8d..ff256fcfc0 100644 --- a/src/config.c +++ b/src/config.c @@ -228,6 +228,7 @@ static void config_create_default(char *path) fprintf(fp, "[general]\n"); fprintf(fp, "game_path = %s\n", gConfig.game_path); fprintf(fp, "screenshot_format = PNG\n"); + fprintf(fp, "play_intro = false\n"); fclose(fp); } @@ -256,6 +257,8 @@ static void config_parse_settings(FILE *fp) } else { gConfig.screenshot_format = SCREENSHOT_FORMAT_BMP; } + } else if (strcmp(setting, "play_intro") == 0) { + gConfig.play_intro = (strcmp(value, "true") == 0); } } } diff --git a/src/config.h b/src/config.h index e08966cf3c..2ed8b08dff 100644 --- a/src/config.h +++ b/src/config.h @@ -81,6 +81,7 @@ void config_save(); // New config format typedef struct configuration { + uint8 play_intro; uint8 screenshot_format; char game_path[MAX_PATH]; } configuration_t; diff --git a/src/rct2.c b/src/rct2.c index a381fe1928..25b51bc217 100644 --- a/src/rct2.c +++ b/src/rct2.c @@ -142,8 +142,7 @@ void rct2_init() title_load(); gfx_clear(RCT2_ADDRESS(RCT2_ADDRESS_SCREEN_DPI, rct_drawpixelinfo), 10); - // RCT2_GLOBAL(RCT2_ADDRESS_RUN_INTRO_TICK_PART, int) = 8; - RCT2_GLOBAL(RCT2_ADDRESS_RUN_INTRO_TICK_PART, int) = 0; + RCT2_GLOBAL(RCT2_ADDRESS_RUN_INTRO_TICK_PART, int) = gConfig.play_intro ? 8 : 0; } // rct2: 0x00683499 From bab27900273b9751d5ad088488a8bdf5bbb64a66 Mon Sep 17 00:00:00 2001 From: MakaHost Date: Sun, 4 May 2014 21:45:40 +0200 Subject: [PATCH 15/44] Fixed spelling in peep thought types --- src/peep.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/peep.h b/src/peep.h index 917d41324b..5700be6935 100644 --- a/src/peep.h +++ b/src/peep.h @@ -167,14 +167,14 @@ enum PEEP_THOUGHT_TYPE { PEEP_THOUGHT_TYPE_SUB_SANDWICH_MUCH = 151, PEEP_THOUGHT_TYPE_COOKIE_MUCH = 152, - PEEP_THOUGH_ROAST_SAUSAGE_MUCH = 156, + PEEP_THOUGHT_ROAST_SAUSAGE_MUCH = 156, - PEEP_THOUGH_HELP = 168, // "Help! Put me down!" - PEEP_THOUGH_RUNNING_OUT = 169, // I'm running out of cash!" - PEEP_THOUGH_NEW_RIDE = 170, // "Wow! A new ride being built!" - PEEP_THOUGH_NICE_RIDE = 171, // "Nice ride! But not as good as the Phoenix..." - PEEP_THOUGH_EXCITED = 172, // "I'm so excited - It's an Intamin ride!" - PEEP_THOUGH_HERE_WE_ARE = 173, // "...and here we are on X!" + PEEP_THOUGHT_HELP = 168, // "Help! Put me down!" + PEEP_THOUGHT_RUNNING_OUT = 169, // I'm running out of cash!" + PEEP_THOUGHT_NEW_RIDE = 170, // "Wow! A new ride being built!" + PEEP_THOUGHT_NICE_RIDE = 171, // "Nice ride! But not as good as the Phoenix..." + PEEP_THOUGHT_EXCITED = 172, // "I'm so excited - It's an Intamin ride!" + PEEP_THOUGHT_HERE_WE_ARE = 173, // "...and here we are on X!" PEEP_THOUGHT_TYPE_NONE = 255 }; From d0203aaeda467d7d19ede4daffb38f48ff4510d3 Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Sun, 4 May 2014 20:48:47 +0100 Subject: [PATCH 16/44] Labelled more peep offsets --- src/peep.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/peep.h b/src/peep.h index 917d41324b..df866b2af7 100644 --- a/src/peep.h +++ b/src/peep.h @@ -275,7 +275,12 @@ typedef struct { uint8 hunger; // 0x3E uint8 thirst; // 0x3F uint8 bathroom; // 0x40 - uint8 pad_041[0x27]; + uint8 pad_41[0x2]; + uint8 intensity; // 0x43 + uint8 nausea_tolerance; // 0x44 + uint8 pad_45; + uint16 paid_on_drink; // 0x46 + uint8 pad_48[0x20]; uint8 current_ride; // 0x68 uint8 pad_69; uint8 current_train; // 0x6A From c4b7dd8a5a8b235e7f6eeb6df27156701979c417 Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Sun, 4 May 2014 21:14:30 +0100 Subject: [PATCH 17/44] Added PEEP_NAUSEA_TOLERANCE enum --- src/peep.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/peep.h b/src/peep.h index df866b2af7..fccecd3862 100644 --- a/src/peep.h +++ b/src/peep.h @@ -230,6 +230,13 @@ enum PEEP_FLAGS { PEEP_FLAGS_ICE_CREAM = (1 << 25) // Unconfirmed }; +enum PEEP_NAUSEA_TOLERANCE{ + PEEP_NAUSEA_TOLERANCE_NONE, + PEEP_NAUSEA_TOLERANCE_LOW, + PEEP_NAUSEA_TOLERANCE_AVERAGE, + PEEP_NAUSEA_TOLERANCE_HIGH +}; + typedef struct { uint8 type; uint8 item; From a35a9f29a4ca4788d108e4560e8ff4f86cdeffb4 Mon Sep 17 00:00:00 2001 From: IntelOrca Date: Mon, 5 May 2014 03:27:17 +0100 Subject: [PATCH 18/44] add guest list window --- projects/openrct2.vcxproj | 1 + projects/openrct2.vcxproj.filters | 3 + src/addresses.h | 5 +- src/gfx.c | 27 ++ src/window.h | 3 +- src/window_game_top_toolbar.c | 2 +- src/window_guest_list.c | 780 ++++++++++++++++++++++++++++++ 7 files changed, 818 insertions(+), 3 deletions(-) create mode 100644 src/window_guest_list.c diff --git a/projects/openrct2.vcxproj b/projects/openrct2.vcxproj index e9b9025b4f..6ff3a72044 100644 --- a/projects/openrct2.vcxproj +++ b/projects/openrct2.vcxproj @@ -87,6 +87,7 @@ + diff --git a/projects/openrct2.vcxproj.filters b/projects/openrct2.vcxproj.filters index 4f7eea0b40..44896fdf76 100644 --- a/projects/openrct2.vcxproj.filters +++ b/projects/openrct2.vcxproj.filters @@ -272,6 +272,9 @@ Windows + + Windows + diff --git a/src/addresses.h b/src/addresses.h index 1bda37ad07..601d8aa95e 100644 --- a/src/addresses.h +++ b/src/addresses.h @@ -302,7 +302,10 @@ static void RCT2_CALLFUNC_X(int address, int *_eax, int *_ebx, int *_ecx, int *_ // Put output ebp into ebp parameter mov eax, [esp] - mov [_ebp], eax + push ebx + mov ebx, [_ebp] + mov [ebx], eax + pop ebx add esp, 4 // Get resulting ebx, ecx, edx, esi, edi registers diff --git a/src/gfx.c b/src/gfx.c index 1a313818c3..022b35e1a2 100644 --- a/src/gfx.c +++ b/src/gfx.c @@ -406,6 +406,33 @@ void gfx_draw_string_centred_clipped(rct_drawpixelinfo *dpi, int format, void *a //gfx_draw_string(dpi, buffer, colour, x, y); } + +/** + * Draws i formatted text string right aligned. + * rct2: 0x006C1BFC + * dpi (edi) + * format (bx) + * args (esi) + * colour (al) + * x (cx) + * y (dx) + */ +void gfx_draw_string_right(rct_drawpixelinfo* dpi, int format, void* args, int colour, int x, int y) +{ + char* buffer; + short text_width; + + buffer = (char*)0x0141ED68; + format_string(buffer, format, args); + + // Measure text width + text_width = gfx_get_string_width(buffer); + + // Draw the text right aligned + x -= text_width; + gfx_draw_string(dpi, buffer, colour, x, y); +} + /** * * rct2: 0x006C1E53 diff --git a/src/window.h b/src/window.h index 6559e7c5c8..c5d432e2ef 100644 --- a/src/window.h +++ b/src/window.h @@ -126,7 +126,7 @@ typedef struct rct_window { sint16 var_484; // viewport target y sint16 var_486; // viewport target z sint16 var_488; // viewport rotation << 8 - sint16 page; + sint16 page; // 0x49A sint16 var_48C; sint16 var_48E; sint16 var_490; @@ -341,6 +341,7 @@ void window_scenarioselect_open(); void window_clear_scenery_open(); void window_land_open(); void window_water_open(); +void window_guest_list_open(); void window_park_entrance_open(); void window_park_objective_open(); void window_ride_list_open(); diff --git a/src/window_game_top_toolbar.c b/src/window_game_top_toolbar.c index e1740b87b7..fa59d02950 100644 --- a/src/window_game_top_toolbar.c +++ b/src/window_game_top_toolbar.c @@ -233,7 +233,7 @@ static void window_game_top_toolbar_mouseup() RCT2_CALLPROC_EBPSAFE(0x006BD3CC); break; case WIDX_GUESTS: - RCT2_CALLPROC_EBPSAFE(0x006992E3); + window_guest_list_open(); break; } } diff --git a/src/window_guest_list.c b/src/window_guest_list.c new file mode 100644 index 0000000000..324527fc06 --- /dev/null +++ b/src/window_guest_list.c @@ -0,0 +1,780 @@ +/***************************************************************************** + * Copyright (c) 2014 Ted John + * OpenRCT2, an open source clone of Roller Coaster Tycoon 2. + * + * This file is part of OpenRCT2. + * + * OpenRCT2 is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + *****************************************************************************/ + +#include +#include "addresses.h" +#include "game.h" +#include "peep.h" +#include "strings.h" +#include "sprite.h" +#include "sprites.h" +#include "widget.h" +#include "window.h" +#include "window_dropdown.h" + +enum { + PAGE_INDIVIDUAL, + PAGE_SUMMARISED +}; + +enum WINDOW_GUEST_LIST_WIDGET_IDX { + WIDX_BACKGROUND, + WIDX_TITLE, + WIDX_CLOSE, + WIDX_TAB_CONTENT_PANEL, + WIDX_PAGE_DROPDOWN, + WIDX_PAGE_DROPDOWN_BUTTON, + WIDX_INFO_TYPE_DROPDOWN, + WIDX_INFO_TYPE_DROPDOWN_BUTTON, + WIDX_MAP, + WIDX_TAB_1, + WIDX_TAB_2, + WIDX_GUEST_LIST +}; + +enum { + VIEW_ACTIONS, + VIEW_THOUGHTS +}; + +static rct_widget window_guest_list_widgets[] = { + { WWT_FRAME, 0, 0, 349, 0, 329, 0x0FFFFFFFF, STR_NONE }, // panel / background + { WWT_CAPTION, 0, 1, 348, 1, 14, STR_GUESTS, STR_WINDOW_TITLE_TIP }, // title bar + { WWT_CLOSEBOX, 0, 337, 347, 2, 13, STR_CLOSE_X, STR_CLOSE_WINDOW_TIP }, // close x button + { WWT_RESIZE, 1, 0, 349, 43, 329, 0x0FFFFFFFF, STR_NONE }, // tab content panel + { WWT_DROPDOWN, 1, 5, 84, 59, 70, STR_PAGE_1, STR_NONE }, // page dropdown + { WWT_DROPDOWN_BUTTON, 1, 73, 83, 60, 69, 876, STR_NONE }, // page dropdown button + { WWT_DROPDOWN, 1, 126, 301, 59, 70, 0x0FFFFFFFF, STR_INFORMATION_TYPE_TIP }, // information type dropdown + { WWT_DROPDOWN_BUTTON, 1, 290, 300, 60, 69, 876, STR_INFORMATION_TYPE_TIP }, // information type dropdown button + { WWT_FLATBTN, 1, 321, 344, 46, 69, 5192, STR_SHOW_GUESTS_ON_MAP_TIP }, // map + { WWT_TAB, 1, 3, 33, 17, 43, 0x02000144E, STR_INDIVIDUAL_GUESTS_TIP }, // tab 1 + { WWT_TAB, 1, 34, 64, 17, 43, 0x02000144E, STR_SUMMARISED_GUESTS_TIP }, // tab 2 + { WWT_SCROLL, 1, 3, 346, 72, 326, 3, STR_NONE }, // guest list + { WIDGETS_END }, +}; + +static void window_guest_list_emptysub() { } +static void window_guest_list_mouseup(); +static void window_guest_list_resize(); +static void window_guest_list_mousedown(); +static void window_guest_list_dropdown(); +static void window_guest_list_update(); +static void window_guest_list_scrollgetsize(); +static void window_guest_list_scrollmousedown(); +static void window_guest_list_scrollmouseover(); +static void window_guest_list_tooltip(); +static void window_guest_list_invalidate(); +static void window_guest_list_paint(); +static void window_guest_list_scrollpaint(); + +static uint32 window_guest_list_events[] = { + window_guest_list_emptysub, + window_guest_list_mouseup, + window_guest_list_resize, + window_guest_list_mousedown, + window_guest_list_dropdown, + window_guest_list_emptysub, + window_guest_list_update, + window_guest_list_emptysub, + window_guest_list_emptysub, + window_guest_list_emptysub, + window_guest_list_emptysub, + window_guest_list_emptysub, + window_guest_list_emptysub, + window_guest_list_emptysub, + window_guest_list_emptysub, + window_guest_list_scrollgetsize, + window_guest_list_scrollmousedown, + window_guest_list_emptysub, + window_guest_list_scrollmouseover, + window_guest_list_emptysub, + window_guest_list_emptysub, + window_guest_list_emptysub, + window_guest_list_tooltip, + window_guest_list_emptysub, + window_guest_list_emptysub, + window_guest_list_invalidate, + window_guest_list_paint, + window_guest_list_scrollpaint +}; + +static int window_guest_list_highlighted_index; +static int window_guest_list_selected_tab; +static int window_guest_list_selected_filter; +static int window_guest_list_selected_page; +static int window_guest_list_selected_view; +static int window_guest_list_num_pages; +static int window_guest_list_num_groups; + +static uint16 window_guest_list_groups_num_guests[240]; +static uint8 window_guest_list_groups_guest_faces[13440]; + +static void window_guest_list_draw_tab_images(rct_drawpixelinfo *dpi, rct_window *w); +static void window_guest_list_refresh_list(rct_window *w); +static void window_guest_list_close_all(rct_window *w); +static void window_guest_list_open_all(rct_window *w); + +/** + * + * rct2: 0x006992E3 + */ +void window_guest_list_open() +{ + rct_window* window; + + RCT2_CALLPROC_EBPSAFE(0x006992E3); + return; + + // Check if window is already open + window = window_bring_to_front_by_id(WC_RIDE_LIST, 0); + if (window != NULL) + return; + + window = window_create_auto_pos(350, 330, window_guest_list_events, WC_GUEST_LIST, 0x0400); + window->widgets = window_guest_list_widgets; + window->enabled_widgets = + (1 << WIDX_CLOSE) | + (1 << WIDX_PAGE_DROPDOWN) | + (1 << WIDX_PAGE_DROPDOWN_BUTTON) | + (1 << WIDX_INFO_TYPE_DROPDOWN) | + (1 << WIDX_INFO_TYPE_DROPDOWN_BUTTON) | + (1 << WIDX_MAP) | + (1 << WIDX_TAB_1) | + (1 << WIDX_TAB_2); + + window_init_scroll_widgets(window); + window_guest_list_highlighted_index = -1; + window->var_490 = 0; + window_guest_list_selected_tab = 0; + window_guest_list_selected_filter = -1; + window_guest_list_selected_page = 0; + window_guest_list_num_pages = 1; + window_guest_list_widgets[WIDX_PAGE_DROPDOWN].type = WWT_EMPTY; + window_guest_list_widgets[WIDX_PAGE_DROPDOWN_BUTTON].type = WWT_EMPTY; + window->var_492 = 0; + window->min_width = 350; + window->min_height = 330; + window->max_width = 500; + window->max_height = 450; + window->flags = WF_RESIZABLE; + window->colours[0] = 1; + window->colours[1] = 15; + window->colours[2] = 15; +} + +/** + * + * rct2: 0x00699AAF + */ +static void window_guest_list_mouseup() +{ + int i; + short widgetIndex; + rct_window *w; + + __asm mov widgetIndex, dx + __asm mov w, esi + + switch (widgetIndex) { + case WIDX_CLOSE: + window_close(w); + break; + case WIDX_MAP: + RCT2_CALLPROC_EBPSAFE(0x0068C88A); + break; + } +} + +/** + * + * rct2: 0x00699EA3 + */ +static void window_guest_list_resize() +{ + rct_window *w; + + __asm mov w, esi + + w->min_width = 350; + w->min_height = 330; + if (w->width < w->min_width) { + window_invalidate(w); + w->width = w->min_width; + } + if (w->height < w->min_height) { + window_invalidate(w); + w->height = w->min_height; + } +} + +/** + * + * rct2: 0x00699AC4 + */ +static void window_guest_list_mousedown() +{ + int i; + short widgetIndex; + rct_window *w; + rct_widget *widget; + + __asm mov widgetIndex, dx + __asm mov w, esi + __asm mov widget, edi + + switch (widgetIndex) { + case WIDX_TAB_1: + case WIDX_TAB_2: + if (window_guest_list_selected_filter == -1) + if (window_guest_list_selected_tab == widgetIndex - WIDX_TAB_1) + break; + window_guest_list_selected_tab = widgetIndex - WIDX_TAB_1; + window_guest_list_selected_page = 0; + window_guest_list_num_pages = 1; + window_guest_list_widgets[WIDX_PAGE_DROPDOWN].type = WWT_EMPTY; + window_guest_list_widgets[WIDX_PAGE_DROPDOWN_BUTTON].type = WWT_EMPTY; + w->var_490 = 0; + window_guest_list_selected_filter = -1; + window_invalidate(w); + w->scrolls[0].v_top = 0; + break; + case WIDX_PAGE_DROPDOWN_BUTTON: + widget = &w->widgets[widgetIndex - 1]; + + window_dropdown_show_text_custom_width( + w->x + widget->left, + w->y + widget->top, + widget->bottom - widget->top + 1, + w->colours[1], + 0x80, + window_guest_list_num_pages, + widget->right - widget->left - 3 + ); + + for (i = 0; i < 2; i++) { + gDropdownItemsFormat[i] = 1142; + gDropdownItemsArgs[i] = STR_PAGE_1 + i; + } + RCT2_GLOBAL(0x009DED38, uint32) |= (1 << window_guest_list_selected_view); + break; + case WIDX_INFO_TYPE_DROPDOWN_BUTTON: + widget = &w->widgets[widgetIndex - 1]; + + window_dropdown_show_text_custom_width( + w->x + widget->left, + w->y + widget->top, + widget->bottom - widget->top + 1, + w->colours[1], + 0x80, + 2, + widget->right - widget->left - 3 + ); + + for (i = 0; i < 2; i++) { + gDropdownItemsFormat[i] = 1142; + gDropdownItemsArgs[i] = STR_ACTIONS + i; + } + RCT2_GLOBAL(0x009DED38, uint32) |= (1 << window_guest_list_selected_view); + break; + } +} + +/** + * + * rct2: 0x00699AE1 + */ +static void window_guest_list_dropdown() +{ + short dropdownIndex, widgetIndex; + rct_window *w; + + __asm mov dropdownIndex, ax + __asm mov widgetIndex, dx + __asm mov w, esi + + switch (widgetIndex) { + case WIDX_PAGE_DROPDOWN_BUTTON: + if (dropdownIndex == -1) + break; + window_guest_list_selected_page = dropdownIndex; + window_invalidate(w); + break; + case WIDX_INFO_TYPE_DROPDOWN_BUTTON: + if (dropdownIndex == -1) + break; + window_guest_list_selected_view = dropdownIndex; + window_invalidate(w); + break; + } +} + +/** + * + * rct2: 0x00699E54 + */ +static void window_guest_list_update() +{ + rct_window *w; + + __asm mov w, esi + + if (RCT2_GLOBAL(0x00F1AF20, uint16) != 0) + RCT2_GLOBAL(0x00F1AF20, uint16)--; + w->var_490++; + if (w->var_490 >= (window_guest_list_selected_tab == PAGE_INDIVIDUAL ? 24 : 32)) + w->var_490 = 0; + widget_invalidate(WC_GUEST_LIST, 0, WIDX_TAB_1 + window_guest_list_selected_tab); +} + +/** + * + * rct2: 0x0069B865 + */ +int window_guest_list_is_peep_in_filter(rct_peep* peep) +{ + int eax, ebx, ecx, edx, esi, edi, ebp; + char temp; + + temp = window_guest_list_selected_view; + window_guest_list_selected_view = window_guest_list_selected_filter; + + esi = peep; + RCT2_CALLFUNC_X(0x0069B7EA, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); + ebx &= 0xFFFF; + + window_guest_list_selected_view = temp; + eax = (RCT2_GLOBAL(0x013CE952, uint16) << 16) | ebx; + + if (((RCT2_GLOBAL(0x00F1EDF6, uint32) >> 16) & 0xFFFF) == 0xFFFF && window_guest_list_selected_filter == 1) + eax |= 0xFFFF; + + if (eax == RCT2_GLOBAL(0x00F1EDF6, uint32) && RCT2_GLOBAL(0x013CE954, uint32) == RCT2_GLOBAL(0x00F1EDFA, uint32)) + return 0; + return 1; +} + +/** + * + * rct2: 0x00699C55 + */ +static void window_guest_list_scrollgetsize() +{ + int i, y, numGuests, spriteIdx; + rct_window *w; + rct_peep *peep; + + __asm mov w, esi + + switch (window_guest_list_selected_tab) { + case PAGE_INDIVIDUAL: + // Count the number of guests + numGuests = 0; + + spriteIdx = RCT2_GLOBAL(RCT2_ADDRESS_SPRITES_START_PEEP, uint16); + while (spriteIdx != SPRITE_INDEX_NULL) { + peep = &(RCT2_ADDRESS(RCT2_ADDRESS_SPRITE_LIST, rct_sprite)[spriteIdx].peep); + spriteIdx = peep->next; + + if (peep->type != PEEP_TYPE_GUEST) + continue; + if (peep->var_2A != 0) + continue; + if (window_guest_list_selected_filter != -1) + if (window_guest_list_is_peep_in_filter(peep)) + continue; + numGuests++; + } + w->var_492 = numGuests; + y = numGuests * 10; + break; + case PAGE_SUMMARISED: + // Find the groups + RCT2_CALLPROC_EBPSAFE(0x0069B5AE); + w->var_492 = window_guest_list_num_groups; + y = window_guest_list_num_groups * 21; + break; + } + + RCT2_GLOBAL(0x00F1EE09, uint32) = numGuests; + i = window_guest_list_selected_page; + for (i = window_guest_list_selected_page - 1; i >= 0; i--) + y -= 0x7BF2; + if (y < 0) + y = 0; + if (y > 0x7BF2) + y = 0x7BF2; + if (window_guest_list_highlighted_index != -1) { + window_guest_list_highlighted_index = -1; + window_invalidate(w); + } + + i = y - window_guest_list_widgets[WIDX_GUEST_LIST].bottom + window_guest_list_widgets[WIDX_GUEST_LIST].top + 21; + if (i < 0) + i = 0; + if (i < w->scrolls[0].v_top) { + w->scrolls[0].v_top = i; + window_invalidate(w); + } + + __asm mov ecx, 447 + __asm mov edx, y +} + +/** + * + * rct2: 0x00699D7D + */ +static void window_guest_list_scrollmousedown() +{ + int i, spriteIdx; + short y; + rct_window *w; + rct_peep *peep; + + __asm mov y, dx + __asm mov w, esi + + switch (window_guest_list_selected_tab) { + case PAGE_INDIVIDUAL: + i = y / 10; + i += window_guest_list_selected_page * 3173; + spriteIdx = RCT2_GLOBAL(RCT2_ADDRESS_SPRITES_START_PEEP, uint16); + while (spriteIdx != SPRITE_INDEX_NULL) { + peep = &(RCT2_ADDRESS(RCT2_ADDRESS_SPRITE_LIST, rct_sprite)[spriteIdx].peep); + spriteIdx = peep->next; + + if (peep->type != PEEP_TYPE_GUEST) + continue; + if (peep->var_2A != 0) + continue; + if (window_guest_list_selected_filter != -1) + if (window_guest_list_is_peep_in_filter(peep)) + continue; + + if (i == 0) { + // Open guest window + RCT2_CALLPROC_X(0x006989E9, 0, 0, 0, peep, 0, 0, 0); + break; + } else { + i--; + } + } + break; + case PAGE_SUMMARISED: + i = y / 21; + if (i < window_guest_list_num_groups) { + RCT2_GLOBAL(0x00F1EDF6, uint32) = ((int*)0x00F1B016)[i * 2]; + RCT2_GLOBAL(0x00F1EDFA, uint32) = ((int*)0x00F1B01A)[i * 2]; + window_guest_list_selected_filter = window_guest_list_selected_view; + window_guest_list_selected_tab = PAGE_INDIVIDUAL; + window_invalidate(w); + w->scrolls[0].v_top = 0; + } + break; + } +} + +/** + * + * rct2: 0x00699D3B + */ +static void window_guest_list_scrollmouseover() +{ + int i; + short y; + rct_window *w; + + __asm mov y, dx + __asm mov w, esi + + i = y / (window_guest_list_selected_tab == PAGE_INDIVIDUAL ? 10 : 21); + i += window_guest_list_selected_page * 3173; + if (i != window_guest_list_highlighted_index) { + window_guest_list_highlighted_index = i; + window_invalidate(w); + } +} + +/** + * + * rct2: 0x00699E4A + */ +static void window_guest_list_tooltip() +{ + RCT2_GLOBAL(0x013CE952, uint16) = STR_LIST; +} + +/** + * + * rct2: 0x00699511 + */ +static void window_guest_list_invalidate() +{ + rct_window *w; + + __asm mov w, esi + + w->pressed_widgets &= ~(1 << WIDX_TAB_1); + w->pressed_widgets &= ~(1 << WIDX_TAB_2); + w->pressed_widgets |= (1 << (window_guest_list_selected_tab + WIDX_TAB_1)); + + window_guest_list_widgets[WIDX_INFO_TYPE_DROPDOWN].image = STR_ACTIONS + window_guest_list_selected_view; + window_guest_list_widgets[WIDX_MAP].type = WWT_EMPTY; + if (window_guest_list_selected_tab == PAGE_INDIVIDUAL && window_guest_list_selected_filter != -1) + window_guest_list_widgets[WIDX_MAP].type = WWT_FLATBTN; + + window_guest_list_widgets[WIDX_BACKGROUND].right = w->width - 1; + window_guest_list_widgets[WIDX_BACKGROUND].bottom = w->height - 1; + window_guest_list_widgets[WIDX_TAB_CONTENT_PANEL].right = w->width - 1; + window_guest_list_widgets[WIDX_TAB_CONTENT_PANEL].bottom = w->height - 1; + window_guest_list_widgets[WIDX_TITLE].right = w->width - 2; + window_guest_list_widgets[WIDX_CLOSE].left = w->width - 13; + window_guest_list_widgets[WIDX_CLOSE].right = w->width - 3; + + window_guest_list_widgets[WIDX_GUEST_LIST].right = w->width - 4; + window_guest_list_widgets[WIDX_GUEST_LIST].bottom = w->height - 15; + window_guest_list_widgets[WIDX_PAGE_DROPDOWN].image = window_guest_list_selected_page + 3440; +} + +/** + * + * rct2: 0x006995CC + */ +static void window_guest_list_paint() +{ + int i, x, y, format; + rct_window *w; + rct_drawpixelinfo *dpi; + + __asm mov w, esi + __asm mov dpi, edi + + // Widgets + window_draw_widgets(w, dpi); + + // Tab 1 image + i = (window_guest_list_selected_tab == 0 ? w->var_490 & 0x0FFFFFFFC : 0); + i += ((int*)*((int*)0x00982708))[0] + 1; + i |= 0xA1600000; + gfx_draw_sprite( + dpi, + i, + (window_guest_list_widgets[WIDX_TAB_1].left + window_guest_list_widgets[WIDX_TAB_1].right) / 2 + w->x, + window_guest_list_widgets[WIDX_TAB_1].bottom - 6 + w->y + ); + + // Tab 2 image + i = (window_guest_list_selected_tab == 1 ? w->var_490 / 4 : 0); + gfx_draw_sprite( + dpi, + 5568 + i, + window_guest_list_widgets[WIDX_TAB_2].left + w->x, + window_guest_list_widgets[WIDX_TAB_2].top + w->y + ); + + // Filter description + x = w->x + 6; + y = w->y + window_guest_list_widgets[WIDX_TAB_CONTENT_PANEL].top + 3; + if (window_guest_list_selected_tab == PAGE_INDIVIDUAL) { + if (window_guest_list_selected_filter != -1) { + if (RCT2_GLOBAL(0x00F1EDF6, sint16) != -1) + format = STR_GUESTS_FILTER + window_guest_list_selected_filter; + else + format = STR_GUESTS_FILTER_THINKING_ABOUT; + } else { + format = STR_ALL_GUESTS; + } + } else { + format = STR_ALL_GUESTS_SUMMARISED; + } + gfx_draw_string_left_clipped(dpi, format, 0x00F1EDF6, 0, x, y, 310); + + // Number of guests (list items) + if (window_guest_list_selected_tab == PAGE_INDIVIDUAL) { + x = w->x + 4; + y = w->y + window_guest_list_widgets[WIDX_GUEST_LIST].bottom + 2; + RCT2_GLOBAL(0x013CE952, sint16) = w->var_492; + gfx_draw_string_left(dpi, (w->var_492 == 1 ? 1755 : 1754), 0x013CE952, 0, x, y); + } +} + +/** + * + * rct2: 0x00698721 + */ +static int get_guest_face_sprite(rct_peep *peep) +{ + int eax, ebx, ecx, edx, esi, edi, ebp; + esi = peep; + ebp = 999; + RCT2_CALLFUNC_X(0x00698721, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); + return ebp; +} + +/** + * + * rct2: 0x00699701 + */ +static void window_guest_list_scrollpaint() +{ + int eax, ebx, ecx, edx, esi, edi, ebp; + int spriteIdx, format, numGuests, i, j, x, y; + rct_window *w; + rct_drawpixelinfo *dpi; + rct_peep *peep; + rct_peep_thought *thought; + + __asm mov w, esi + __asm mov dpi, edi + + // Background fill + gfx_fill_rect(dpi, dpi->x, dpi->y, dpi->x + dpi->width - 1, dpi->y + dpi->height - 1, ((char*)0x0141FC48)[w->colours[1] * 8]); + + switch (window_guest_list_selected_tab) { + case PAGE_INDIVIDUAL: + i = 0; + y = window_guest_list_selected_page * -0x7BF2; + + // For each guest + spriteIdx = RCT2_GLOBAL(RCT2_ADDRESS_SPRITES_START_PEEP, uint16); + while (spriteIdx != SPRITE_INDEX_NULL) { + peep = &(RCT2_ADDRESS(RCT2_ADDRESS_SPRITE_LIST, rct_sprite)[spriteIdx].peep); + spriteIdx = peep->next; + + if (peep->type != PEEP_TYPE_GUEST) + continue; + peep->var_0C &= ~0x200; + if (peep->var_2A != 0) + continue; + if (window_guest_list_selected_filter != -1) { + if (window_guest_list_is_peep_in_filter(peep)) + continue; + RCT2_GLOBAL(0x009AC861, uint16) |= 1; + peep->var_0C |= 0x200; + } + + // + if (y + 11 >= -0x7FFF && y + 11 > dpi->y && y < 0x7FFF) { + // Check if y is beyond the scroll control + if (y > dpi->y + dpi->height) + break; + + // Highlight backcolour and text colour (format) + format = 1191; + if (i == window_guest_list_highlighted_index) { + gfx_fill_rect(dpi, 0, y, 800, y + 9, 0x02000031); + format = 1193; + } + + // Guest name + RCT2_GLOBAL(0x013CE952, uint16) = peep->name_string_idx; + RCT2_GLOBAL(0x013CE954, uint32) = peep->id; + gfx_draw_string_left_clipped(dpi, format, 0x013CE952, 0, 0, y - 1, 113); + + switch (window_guest_list_selected_view) { + case VIEW_ACTIONS: + // Guest face + gfx_draw_sprite(dpi, get_guest_face_sprite(peep), 118, y); + + // Tracking icon + if (peep->flags & PEEP_FLAGS_TRACKING) + gfx_draw_sprite(dpi, 5129, 112, y); + + // Action + eax = peep->var_0A; + RCT2_CALLFUNC_X(0x00698B0D, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); + ebx &= 0xFFFF; + ecx &= 0xFFFF; + + RCT2_GLOBAL(0x013CE952, uint16) = ebx; + RCT2_GLOBAL(0x013CE952 + 2, uint16) = ecx; + RCT2_GLOBAL(0x013CE952 + 4, uint32) = edx; + gfx_draw_string_left_clipped(dpi, format, 0x013CE952, 0, 133, y - 1, 314); + break; + case VIEW_THOUGHTS: + // For each thought + for (j = 0; j < PEEP_MAX_THOUGHTS; j++) { + thought = &peep->thoughts[j]; + if (thought->type == PEEP_THOUGHT_TYPE_NONE) + break; + if (thought->pad_3 == 0) + continue; + if (thought->pad_3 > 5) + break; + + ebx = thought->type; + eax = thought->item; + RCT2_CALLFUNC_X(0x00698342, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); + ebx &= 0xFFFF; + + RCT2_GLOBAL(0x013CE952, uint16) = ebx; + RCT2_GLOBAL(0x013CE952 + 2, uint32) = *((uint32*)esi); + RCT2_GLOBAL(0x013CE952 + 6, uint16) = *((uint16*)(esi + 4)); + gfx_draw_string_left_clipped(dpi, format, 0x013CE952, 0, 118, y - 1, 329); + break; + } + break; + } + } + + // Increment list item index and y + i++; + y += 10; + } + break; + case PAGE_SUMMARISED: + y = 0; + + // For each group of guests + for (i = 0; i < window_guest_list_num_groups; i++) { + // Check if y is beyond the scroll control + if (y + 22 >= dpi->y) { + // Check if y is beyond the scroll control + if (y >= dpi->y + dpi->height) + break; + + // Highlight backcolour and text colour (format) + format = 1191; + if (i == window_guest_list_highlighted_index) { + gfx_fill_rect(dpi, 0, y, 800, y + 20, 0x02000031); + format = 1193; + } + + // Draw guest faces + numGuests = window_guest_list_groups_num_guests[i]; + for (j = 0; j < 56 && j < numGuests; j++) + gfx_draw_sprite(dpi, window_guest_list_groups_guest_faces[numGuests * 56 + j] + 5486, j * 8, y + 9); + + // Draw action + RCT2_GLOBAL(0x013CE952, uint16) = ((uint32*)0x00F1B016)[i * 2] & 0xFFFF; + RCT2_GLOBAL(0x013CE952 + 2, uint16) = ((uint32*)0x00F1B016)[i * 2] >> 16; + RCT2_GLOBAL(0x013CE952 + 4, uint32) = ((int*)0x00F1B01A)[i * 2]; + RCT2_GLOBAL(0x013CE952 + 10, uint32) = numGuests; + gfx_draw_string_left_clipped(dpi, format, 0x013CE952, 0, 0, y - 1, 414); + + // Draw guest count + RCT2_GLOBAL(0x013CE95A, uint16) = STR_GUESTS_COUNT_COMMA_SEP; + gfx_draw_string_right(dpi, format, 0x0013CE95A, 0, 326, y - 1); + } + y += 21; + } + break; + } +} \ No newline at end of file From 29459fb9bbc7f27c383c681d84f68e80bf37d371 Mon Sep 17 00:00:00 2001 From: Maciek Baron Date: Mon, 5 May 2014 16:38:49 +0100 Subject: [PATCH 19/44] Adding item flags, time in thought struct --- src/peep.h | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 63 insertions(+), 4 deletions(-) diff --git a/src/peep.h b/src/peep.h index 0b6b268caa..57bfa17489 100644 --- a/src/peep.h +++ b/src/peep.h @@ -230,18 +230,73 @@ enum PEEP_FLAGS { PEEP_FLAGS_ICE_CREAM = (1 << 25) // Unconfirmed }; -enum PEEP_NAUSEA_TOLERANCE{ +enum PEEP_NAUSEA_TOLERANCE { PEEP_NAUSEA_TOLERANCE_NONE, PEEP_NAUSEA_TOLERANCE_LOW, PEEP_NAUSEA_TOLERANCE_AVERAGE, PEEP_NAUSEA_TOLERANCE_HIGH }; +enum PEEP_ITEM { + // item_standard_flags + PEEP_ITEM_BALOON = (1 << 0), + PEEP_ITEM_TOY = (1 << 1), + PEEP_ITEM_MAP = (1 << 2), + PEEP_ITEM_PHOTO = (1 << 3), + PEEP_ITEM_UMBRELLA = (1 << 4), + PEEP_ITEM_DRINK = (1 << 5), + PEEP_ITEM_BURGER = (1 << 6), + PEEP_ITEM_FRIES = (1 << 7), + PEEP_ITEM_ICE_CREAM = (1 << 8), + PEEP_ITEM_COTTON_CANDY = (1 << 9), + PEEP_ITEM_EMPTY_CAN = (1 << 10), + PEEP_ITEM_RUBBISH = (1 << 11), + PEEP_ITEM_EMPTY_BURGER_BOX = (1 << 12), + PEEP_ITEM_PIZZA = (1 << 13), + PEEP_ITEM_VOUCHER = (1 << 14), + PEEP_ITEM_POPCORN = (1 << 15), + PEEP_ITEM_HOT_DOG = (1 << 16), + PEEP_ITEM_TENTACLE = (1 << 17), + PEEP_ITEM_HAT = (1 << 18), + PEEP_ITEM_CANDY_APPLE = (1 << 19), + PEEP_ITEM_TSHIRT = (1 << 20), + PEEP_ITEM_DONUT = (1 << 21), + PEEP_ITEM_COFFEE = (1 << 22), + PEEP_ITEM_EMPTY_CUP = (1 << 23), + PEEP_ITEM_CHICKEN = (1 << 24), + PEEP_ITEM_LEMONADE = (1 << 25), + PEEP_ITEM_EMPTY_BOX = (1 << 26), + PEEP_ITEM_EMPTY_BOTTLE = (1 << 27), + + // item_extra_flags + PEEP_ITEM_PHOTO2 = (1 << 0), + PEEP_ITEM_PHOTO3 = (1 << 1), + PEEP_ITEM_PHOTO4 = (1 << 2), + PEEP_ITEM_PRETZEL = (1 << 3), + PEEP_ITEM_CHOCOLATE = (1 << 4), + PEEP_ITEM_ICED_TEA = (1 << 5), + PEEP_ITEM_FUNNEL_CAKE = (1 << 6), + PEEP_ITEM_SUNGLASSES = (1 << 7), + PEEP_ITEM_BEEF_NOODLES = (1 << 8), + PEEP_ITEM_FRIED_RICE_NOODLES = (1 << 9), + PEEP_ITEM_WONTON_SOUP = (1 << 10), + PEEP_ITEM_MEATBALL_SOUP = (1 << 11), + PEEP_ITEM_FRUIT_JUICE = (1 << 12), + PEEP_ITEM_SOYBEAN_MILK = (1 << 13), + PEEP_ITEM_SU_JONGKWA = (1 << 14), + PEEP_ITEM_SUB_SANDWICH = (1 << 15), + PEEP_ITEM_COOKIE = (1 << 16), + PEEP_ITEM_EMPTY_BOWL_RED = (1 << 17), + PEEP_ITEM_EMPTY_DRINK_CARTON = (1 << 18), + PEEP_ITEM_EMPTY_JUICE_CUP = (1 << 19), + PEEP_ITEM_ROAST_SAUSAGE = (1 << 20), + PEEP_ITEM_EMPTY_BOWL_BLUE = (1 << 21) +}; + typedef struct { uint8 type; uint8 item; - uint8 pad_3; - uint8 pad_4; + uint16 time; } rct_peep_thought; typedef struct { @@ -287,7 +342,9 @@ typedef struct { uint8 nausea_tolerance; // 0x44 uint8 pad_45; uint16 paid_on_drink; // 0x46 - uint8 pad_48[0x20]; + uint8 pad_48[0x10]; + uint32 item_extra_flags; // 0x58 + uint8 pad_5C[0x0C]; // 0x5C uint8 current_ride; // 0x68 uint8 pad_69; uint8 current_train; // 0x6A @@ -318,6 +375,8 @@ typedef struct { uint8 umbrella_colour; // 0xF7 uint8 hat_colour; // 0xF8 uint8 favourite_ride; // 0xF9 + uint16 pad_FA; + uint32 item_standard_flags; // 0xFC } rct_peep; int peep_get_staff_count(); From 1c51c816229473420c800f3dd6eeee61fa24851b Mon Sep 17 00:00:00 2001 From: Maciek Baron Date: Mon, 5 May 2014 16:52:19 +0100 Subject: [PATCH 20/44] Reverting struct changes --- src/peep.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/peep.h b/src/peep.h index 57bfa17489..62ef6c9c67 100644 --- a/src/peep.h +++ b/src/peep.h @@ -296,7 +296,8 @@ enum PEEP_ITEM { typedef struct { uint8 type; uint8 item; - uint16 time; + uint8 pad_3; + uint8 pad_4; } rct_peep_thought; typedef struct { From f20311ec6cda2e71f71e468c5e931f9a95660aca Mon Sep 17 00:00:00 2001 From: Maciek Baron Date: Mon, 5 May 2014 18:26:55 +0100 Subject: [PATCH 21/44] Fixing typo --- src/peep.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/peep.h b/src/peep.h index 62ef6c9c67..cdf2599990 100644 --- a/src/peep.h +++ b/src/peep.h @@ -239,7 +239,7 @@ enum PEEP_NAUSEA_TOLERANCE { enum PEEP_ITEM { // item_standard_flags - PEEP_ITEM_BALOON = (1 << 0), + PEEP_ITEM_BALLOON = (1 << 0), PEEP_ITEM_TOY = (1 << 1), PEEP_ITEM_MAP = (1 << 2), PEEP_ITEM_PHOTO = (1 << 3), From d0d51e477b5d75187b01d77ef122485d0683333a Mon Sep 17 00:00:00 2001 From: ZedThree Date: Mon, 5 May 2014 19:34:24 +0200 Subject: [PATCH 22/44] Add ride mode enum and name some ride variables --- src/news_item.c | 6 ++--- src/ride.c | 4 +-- src/ride.h | 67 +++++++++++++++++++++++++++++++++++++++++++------ 3 files changed, 64 insertions(+), 13 deletions(-) diff --git a/src/news_item.c b/src/news_item.c index 624c1b3aeb..3bc978f7bb 100644 --- a/src/news_item.c +++ b/src/news_item.c @@ -182,12 +182,12 @@ void news_item_get_subject_location(int type, int subject, int *x, int *y, int * switch (type) { case NEWS_ITEM_RIDE: ride = &(RCT2_ADDRESS(RCT2_ADDRESS_RIDE_LIST, rct_ride)[subject]); - if (ride->var_050 == 0xFFFF) { + if (ride->overall_view == 0xFFFF) { *x = SPRITE_LOCATION_NULL; break; } - *x = (ride->var_050 & 0xFF) * 32 + 16; - *y = (ride->var_050 >> 8) * 32 + 16; + *x = (ride->overall_view & 0xFF) * 32 + 16; + *y = (ride->overall_view >> 8) * 32 + 16; *z = map_element_height(*x, *y); break; case NEWS_ITEM_PEEP_ON_RIDE: diff --git a/src/ride.c b/src/ride.c index c04019e7b5..cc6f543d7f 100644 --- a/src/ride.c +++ b/src/ride.c @@ -113,7 +113,7 @@ int ride_get_total_queue_length(rct_ride *ride) { int i, queueLength = 0; for (i = 0; i < 4; i++) - if (ride->var_06A[i] != 0xFFFF) + if (ride->entrances[i] != 0xFFFF) queueLength += ride->queue_length[i]; return queueLength; } @@ -122,7 +122,7 @@ int ride_get_max_queue_time(rct_ride *ride) { int i, queueTime = 0; for (i = 0; i < 4; i++) - if (ride->var_06A[i] != 0xFFFF) + if (ride->entrances[i] != 0xFFFF) queueTime = max(queueTime, ride->queue_time[i]); return queueTime; } diff --git a/src/ride.h b/src/ride.h index 2519125595..78574be103 100644 --- a/src/ride.h +++ b/src/ride.h @@ -31,16 +31,20 @@ typedef struct { uint8 type; // 0x000 uint8 subtype; // 0x001 uint16 pad_002; - uint8 var_004; - uint8 pad_005[0x44]; + uint8 mode; // 0x004 + uint8 colour_scheme_type; // 0x005 + uint16 car_colours[32]; // 0x006 + uint8 pad_046[0x03]; uint8 status; // 0x049 uint16 var_04A; uint32 var_04C; - uint16 var_050; // 0x050 - uint8 pad_052[0x18]; - uint16 var_06A[4]; // probably entrance map coordinates - uint8 pad_072[0x14]; - uint16 train_car_map[1]; // 0x86 Points to the first car in the train + uint16 overall_view; // 0x050 + uint16 station_starts[4]; // 0x052 + uint8 pad_05A[0x10]; + uint16 entrances[4]; // 0x06A + uint16 exits[4]; // 0x072 + uint8 pad_07A[0x0C]; + uint16 train_car_map[1]; // 0x086 Points to the first car in the train uint8 pad_088[0x68]; sint16 var_0F0; sint16 var_0F2; @@ -56,7 +60,8 @@ typedef struct { sint16 running_cost; // 0x132 sint16 var_134; sint16 var_136; - uint8 pad_138[0x08]; + sint16 price; // 0x138 + uint8 pad_13A[0x06]; sint16 excitement; // 0x140 sint16 intensity; // 0x142 uint16 nausea; // 0x144 @@ -197,6 +202,52 @@ enum { RIDE_STATUS_TESTING }; +enum { + RIDE_MODE_NORMAL = 0, + RIDE_MODE_CONTINUOUS_CIRCUIT, + RIDE_MODE_REVERSE_INCLINED_SHUTTLE, + RIDE_MODE_POWERED_LAUNCH, // RCT1 style? + RIDE_MODE_SHUTTLE, + RIDE_MODE_BOAT_HIRE, + RIDE_MODE_UPWARD_LAUNCH, + RIDE_MODE_ROTATING_LIFT, + RIDE_MODE_STATION_TO_STATION, + RIDE_MODE_SINGLE_RIDE_PER_ADMISSION, + RIDE_MODE_UNLIMITED_RIDES_PER_ADMISSION, + RIDE_MODE_MAZE, + RIDE_MODE_RACE, + RIDE_MODE_BUMPERCAR, + RIDE_MODE_SWING, + RIDE_MODE_SHOP_STALL, + RIDE_MODE_ROTATION, + RIDE_MODE_FORWARD_ROTATION, + RIDE_MODE_BACKWARD_ROTATION, + RIDE_MODE_FILM_AVENGING_AVIATORS, + RIDE_MODE_3D_FILM_MOUSE_TAILS, + RIDE_MODE_SPACE_RINGS, + RIDE_MODE_BEGINNERS, + RIDE_MODE_LIM_POWERED_LAUNCH, + RIDE_MODE_FILM_THRILL_RIDERS, + RIDE_MODE_3D_FILM_STORM_CHASERS, + RIDE_MODE_3D_FILM_SPACE_RAIDERS, + RIDE_MODE_INTENSE, + RIDE_MODE_BERSERK, + RIDE_MODE_HAUNTED_HOUSE, + RIDE_MODE_CIRCUS_SHOW, + RIDE_MODE_DOWNWARD_LAUNCH, + RIDE_MODE_CROOKED_HOUSE, + RIDE_MODE_FREEFALL_DROP, + RIDE_MODE_CONTINUOUS_CIRCUIT_BLOCK_SECTIONED, + RIDE_MODE_POWERED_LAUNCH2, // RCT2 style? + RIDE_MODE_POWERED_LAUNCH_BLOCK_SECTIONED +}; + +enum { + RIDE_COLOUR_SCHEME_ALL_SAME, + RIDE_COLOUR_SCHEME_DIFFERENT_PER_TRAIN, + RIDE_COLOUR_SCHEME_DIFFERENT_PER_CAR +}; + #define MAX_RIDES 255 #define MAX_RIDE_MEASUREMENTS 8 From ce14d72d16b9565ac58be3dd8aaea57556eaeeff Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Mon, 5 May 2014 19:35:47 +0100 Subject: [PATCH 23/44] Labeled ride photo 1-4 and time in park offsets. --- src/peep.h | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/peep.h b/src/peep.h index 0b6b268caa..218faeb68c 100644 --- a/src/peep.h +++ b/src/peep.h @@ -287,7 +287,12 @@ typedef struct { uint8 nausea_tolerance; // 0x44 uint8 pad_45; uint16 paid_on_drink; // 0x46 - uint8 pad_48[0x20]; + uint8 pad_48[0x10]; + uint32 item_extra_flags; // 0x58 + uint8 photo2_ride_ref; // 0x5C + uint8 photo3_ride_ref; // 0x5D + uint8 photo4_ride_ref; // 0x5E + uint8 pad_5F[0x09]; uint8 current_ride; // 0x68 uint8 pad_69; uint8 current_train; // 0x6A @@ -298,11 +303,13 @@ typedef struct { uint32 id; // 0x9C sint32 cash_in_pocket; // 0xA0 sint32 cash_spent; // 0xA4 - uint8 pad_A8[8]; + uint8 pad_A8; + sint32 time_in_park; // 0xA9 + uint8 pad_AD[0x3]; rct_peep_thought thoughts[PEEP_MAX_THOUGHTS]; // 0xB0 uint16 pad_C4; uint8 var_C6; - uint8 pad_C7; + uint8 photo1_ride_ref; // 0xC7 uint32 flags; // 0xC8 uint8 var_CC; uint8 pad_CD[0x17]; @@ -318,6 +325,8 @@ typedef struct { uint8 umbrella_colour; // 0xF7 uint8 hat_colour; // 0xF8 uint8 favourite_ride; // 0xF9 + uint16 pad_FA; + uint32 item_standard_flags; // 0xFC } rct_peep; int peep_get_staff_count(); From 290255a32d2e45afe7c90c41f12db1f8c2fbb3a7 Mon Sep 17 00:00:00 2001 From: ZedThree Date: Mon, 5 May 2014 20:55:25 +0200 Subject: [PATCH 24/44] Fix bug: rides not sorted correctly --- src/window_ride_list.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/window_ride_list.c b/src/window_ride_list.c index 92d08a7918..390261673b 100644 --- a/src/window_ride_list.c +++ b/src/window_ride_list.c @@ -497,14 +497,14 @@ static void window_ride_list_scrollpaint() formatSecondary = STR_POPULARITY_UNKNOWN_LABEL; if ((ride->var_158 & 0xFF) != 255) { formatSecondary = STR_POPULARITY_LABEL; - RCT2_GLOBAL(0x013CE952 + 2, uint16) = (ride->var_158 * 4) & 0xFF; - } + RCT2_GLOBAL(0x013CE952 + 2, uint16) = (ride->var_158 & 0xFF) * 4; + } break; case INFORMATION_TYPE_SATISFACTION: formatSecondary = STR_SATISFACTION_UNKNOWN_LABEL; if ((ride->var_14A & 0xFF) != 255) { formatSecondary = STR_SATISFACTION_LABEL; - RCT2_GLOBAL(0x013CE952 + 2, uint16) = (ride->var_14A * 5) & 0xFF; + RCT2_GLOBAL(0x013CE952 + 2, uint16) = (ride->var_14A & 0xFF) * 5; } break; case INFORMATION_TYPE_PROFIT: @@ -647,7 +647,7 @@ static void window_ride_list_refresh_list(rct_window *w) case INFORMATION_TYPE_POPULARITY: while (--k >= 0) { otherRide = &(RCT2_ADDRESS(RCT2_ADDRESS_RIDE_LIST, rct_ride)[w->var_076[k]]); - if ((ride->var_158 * 4) & 0xFF <= (otherRide->var_158 * 4) & 0xFF) + if ((ride->var_158 & 0xFF) * 4 <= (otherRide->var_158 & 0xFF) * 4) break; swapper = w->var_076[k]; @@ -658,7 +658,7 @@ static void window_ride_list_refresh_list(rct_window *w) case INFORMATION_TYPE_SATISFACTION: while (--k >= 0) { otherRide = &(RCT2_ADDRESS(RCT2_ADDRESS_RIDE_LIST, rct_ride)[w->var_076[k]]); - if ((ride->var_14A * 5) & 0xFF <= (otherRide->var_14A * 5) & 0xFF) + if ((ride->var_14A & 0xFF) * 5 <= (otherRide->var_14A & 0xFF) * 5) break; swapper = w->var_076[k]; From 3a177fbb454ca1cdd5a3576a2724deb27462e177 Mon Sep 17 00:00:00 2001 From: IntelOrca Date: Mon, 5 May 2014 20:04:17 +0100 Subject: [PATCH 25/44] add grouping to guest list window --- src/window_guest_list.c | 394 ++++++++++++++++++++++++++++------------ 1 file changed, 277 insertions(+), 117 deletions(-) diff --git a/src/window_guest_list.c b/src/window_guest_list.c index 324527fc06..d57a504ccf 100644 --- a/src/window_guest_list.c +++ b/src/window_guest_list.c @@ -115,21 +115,22 @@ static uint32 window_guest_list_events[] = { window_guest_list_scrollpaint }; -static int window_guest_list_highlighted_index; -static int window_guest_list_selected_tab; -static int window_guest_list_selected_filter; -static int window_guest_list_selected_page; -static int window_guest_list_selected_view; -static int window_guest_list_num_pages; -static int window_guest_list_num_groups; +static int _window_guest_list_highlighted_index; +static int _window_guest_list_selected_tab; +static int _window_guest_list_selected_filter; +static int _window_guest_list_selected_page; +static int _window_guest_list_selected_view; +static int _window_guest_list_num_pages; +static int _window_guest_list_num_groups; -static uint16 window_guest_list_groups_num_guests[240]; -static uint8 window_guest_list_groups_guest_faces[13440]; +static uint16 _window_guest_list_groups_num_guests[240]; +static uint32 _window_guest_list_groups_argument_1[240]; +static uint32 _window_guest_list_groups_argument_2[240]; +static uint8 _window_guest_list_groups_guest_faces[240 * 58]; -static void window_guest_list_draw_tab_images(rct_drawpixelinfo *dpi, rct_window *w); -static void window_guest_list_refresh_list(rct_window *w); -static void window_guest_list_close_all(rct_window *w); -static void window_guest_list_open_all(rct_window *w); +static int window_guest_list_is_peep_in_filter(rct_peep* peep); +static void window_guest_list_find_groups(); +static int get_guest_face_sprite(rct_peep *peep); /** * @@ -139,9 +140,6 @@ void window_guest_list_open() { rct_window* window; - RCT2_CALLPROC_EBPSAFE(0x006992E3); - return; - // Check if window is already open window = window_bring_to_front_by_id(WC_RIDE_LIST, 0); if (window != NULL) @@ -160,12 +158,12 @@ void window_guest_list_open() (1 << WIDX_TAB_2); window_init_scroll_widgets(window); - window_guest_list_highlighted_index = -1; + _window_guest_list_highlighted_index = -1; window->var_490 = 0; - window_guest_list_selected_tab = 0; - window_guest_list_selected_filter = -1; - window_guest_list_selected_page = 0; - window_guest_list_num_pages = 1; + _window_guest_list_selected_tab = 1; + _window_guest_list_selected_filter = -1; + _window_guest_list_selected_page = 0; + _window_guest_list_num_pages = 1; window_guest_list_widgets[WIDX_PAGE_DROPDOWN].type = WWT_EMPTY; window_guest_list_widgets[WIDX_PAGE_DROPDOWN_BUTTON].type = WWT_EMPTY; window->var_492 = 0; @@ -242,16 +240,16 @@ static void window_guest_list_mousedown() switch (widgetIndex) { case WIDX_TAB_1: case WIDX_TAB_2: - if (window_guest_list_selected_filter == -1) - if (window_guest_list_selected_tab == widgetIndex - WIDX_TAB_1) + if (_window_guest_list_selected_filter == -1) + if (_window_guest_list_selected_tab == widgetIndex - WIDX_TAB_1) break; - window_guest_list_selected_tab = widgetIndex - WIDX_TAB_1; - window_guest_list_selected_page = 0; - window_guest_list_num_pages = 1; + _window_guest_list_selected_tab = widgetIndex - WIDX_TAB_1; + _window_guest_list_selected_page = 0; + _window_guest_list_num_pages = 1; window_guest_list_widgets[WIDX_PAGE_DROPDOWN].type = WWT_EMPTY; window_guest_list_widgets[WIDX_PAGE_DROPDOWN_BUTTON].type = WWT_EMPTY; w->var_490 = 0; - window_guest_list_selected_filter = -1; + _window_guest_list_selected_filter = -1; window_invalidate(w); w->scrolls[0].v_top = 0; break; @@ -264,7 +262,7 @@ static void window_guest_list_mousedown() widget->bottom - widget->top + 1, w->colours[1], 0x80, - window_guest_list_num_pages, + _window_guest_list_num_pages, widget->right - widget->left - 3 ); @@ -272,7 +270,7 @@ static void window_guest_list_mousedown() gDropdownItemsFormat[i] = 1142; gDropdownItemsArgs[i] = STR_PAGE_1 + i; } - RCT2_GLOBAL(0x009DED38, uint32) |= (1 << window_guest_list_selected_view); + RCT2_GLOBAL(0x009DED38, uint32) |= (1 << _window_guest_list_selected_view); break; case WIDX_INFO_TYPE_DROPDOWN_BUTTON: widget = &w->widgets[widgetIndex - 1]; @@ -291,7 +289,7 @@ static void window_guest_list_mousedown() gDropdownItemsFormat[i] = 1142; gDropdownItemsArgs[i] = STR_ACTIONS + i; } - RCT2_GLOBAL(0x009DED38, uint32) |= (1 << window_guest_list_selected_view); + RCT2_GLOBAL(0x009DED38, uint32) |= (1 << _window_guest_list_selected_view); break; } } @@ -313,13 +311,13 @@ static void window_guest_list_dropdown() case WIDX_PAGE_DROPDOWN_BUTTON: if (dropdownIndex == -1) break; - window_guest_list_selected_page = dropdownIndex; + _window_guest_list_selected_page = dropdownIndex; window_invalidate(w); break; case WIDX_INFO_TYPE_DROPDOWN_BUTTON: if (dropdownIndex == -1) break; - window_guest_list_selected_view = dropdownIndex; + _window_guest_list_selected_view = dropdownIndex; window_invalidate(w); break; } @@ -338,36 +336,9 @@ static void window_guest_list_update() if (RCT2_GLOBAL(0x00F1AF20, uint16) != 0) RCT2_GLOBAL(0x00F1AF20, uint16)--; w->var_490++; - if (w->var_490 >= (window_guest_list_selected_tab == PAGE_INDIVIDUAL ? 24 : 32)) + if (w->var_490 >= (_window_guest_list_selected_tab == PAGE_INDIVIDUAL ? 24 : 32)) w->var_490 = 0; - widget_invalidate(WC_GUEST_LIST, 0, WIDX_TAB_1 + window_guest_list_selected_tab); -} - -/** - * - * rct2: 0x0069B865 - */ -int window_guest_list_is_peep_in_filter(rct_peep* peep) -{ - int eax, ebx, ecx, edx, esi, edi, ebp; - char temp; - - temp = window_guest_list_selected_view; - window_guest_list_selected_view = window_guest_list_selected_filter; - - esi = peep; - RCT2_CALLFUNC_X(0x0069B7EA, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); - ebx &= 0xFFFF; - - window_guest_list_selected_view = temp; - eax = (RCT2_GLOBAL(0x013CE952, uint16) << 16) | ebx; - - if (((RCT2_GLOBAL(0x00F1EDF6, uint32) >> 16) & 0xFFFF) == 0xFFFF && window_guest_list_selected_filter == 1) - eax |= 0xFFFF; - - if (eax == RCT2_GLOBAL(0x00F1EDF6, uint32) && RCT2_GLOBAL(0x013CE954, uint32) == RCT2_GLOBAL(0x00F1EDFA, uint32)) - return 0; - return 1; + widget_invalidate(WC_GUEST_LIST, 0, WIDX_TAB_1 + _window_guest_list_selected_tab); } /** @@ -382,7 +353,7 @@ static void window_guest_list_scrollgetsize() __asm mov w, esi - switch (window_guest_list_selected_tab) { + switch (_window_guest_list_selected_tab) { case PAGE_INDIVIDUAL: // Count the number of guests numGuests = 0; @@ -396,7 +367,7 @@ static void window_guest_list_scrollgetsize() continue; if (peep->var_2A != 0) continue; - if (window_guest_list_selected_filter != -1) + if (_window_guest_list_selected_filter != -1) if (window_guest_list_is_peep_in_filter(peep)) continue; numGuests++; @@ -406,22 +377,22 @@ static void window_guest_list_scrollgetsize() break; case PAGE_SUMMARISED: // Find the groups - RCT2_CALLPROC_EBPSAFE(0x0069B5AE); - w->var_492 = window_guest_list_num_groups; - y = window_guest_list_num_groups * 21; + window_guest_list_find_groups(); + w->var_492 = _window_guest_list_num_groups; + y = _window_guest_list_num_groups * 21; break; } RCT2_GLOBAL(0x00F1EE09, uint32) = numGuests; - i = window_guest_list_selected_page; - for (i = window_guest_list_selected_page - 1; i >= 0; i--) + i = _window_guest_list_selected_page; + for (i = _window_guest_list_selected_page - 1; i >= 0; i--) y -= 0x7BF2; if (y < 0) y = 0; if (y > 0x7BF2) y = 0x7BF2; - if (window_guest_list_highlighted_index != -1) { - window_guest_list_highlighted_index = -1; + if (_window_guest_list_highlighted_index != -1) { + _window_guest_list_highlighted_index = -1; window_invalidate(w); } @@ -451,10 +422,10 @@ static void window_guest_list_scrollmousedown() __asm mov y, dx __asm mov w, esi - switch (window_guest_list_selected_tab) { + switch (_window_guest_list_selected_tab) { case PAGE_INDIVIDUAL: i = y / 10; - i += window_guest_list_selected_page * 3173; + i += _window_guest_list_selected_page * 3173; spriteIdx = RCT2_GLOBAL(RCT2_ADDRESS_SPRITES_START_PEEP, uint16); while (spriteIdx != SPRITE_INDEX_NULL) { peep = &(RCT2_ADDRESS(RCT2_ADDRESS_SPRITE_LIST, rct_sprite)[spriteIdx].peep); @@ -464,7 +435,7 @@ static void window_guest_list_scrollmousedown() continue; if (peep->var_2A != 0) continue; - if (window_guest_list_selected_filter != -1) + if (_window_guest_list_selected_filter != -1) if (window_guest_list_is_peep_in_filter(peep)) continue; @@ -479,11 +450,11 @@ static void window_guest_list_scrollmousedown() break; case PAGE_SUMMARISED: i = y / 21; - if (i < window_guest_list_num_groups) { - RCT2_GLOBAL(0x00F1EDF6, uint32) = ((int*)0x00F1B016)[i * 2]; - RCT2_GLOBAL(0x00F1EDFA, uint32) = ((int*)0x00F1B01A)[i * 2]; - window_guest_list_selected_filter = window_guest_list_selected_view; - window_guest_list_selected_tab = PAGE_INDIVIDUAL; + if (i < _window_guest_list_num_groups) { + RCT2_GLOBAL(0x00F1EDF6, uint32) = _window_guest_list_groups_argument_1[i]; + RCT2_GLOBAL(0x00F1EDFA, uint32) = _window_guest_list_groups_argument_2[i]; + _window_guest_list_selected_filter = _window_guest_list_selected_view; + _window_guest_list_selected_tab = PAGE_INDIVIDUAL; window_invalidate(w); w->scrolls[0].v_top = 0; } @@ -504,10 +475,10 @@ static void window_guest_list_scrollmouseover() __asm mov y, dx __asm mov w, esi - i = y / (window_guest_list_selected_tab == PAGE_INDIVIDUAL ? 10 : 21); - i += window_guest_list_selected_page * 3173; - if (i != window_guest_list_highlighted_index) { - window_guest_list_highlighted_index = i; + i = y / (_window_guest_list_selected_tab == PAGE_INDIVIDUAL ? 10 : 21); + i += _window_guest_list_selected_page * 3173; + if (i != _window_guest_list_highlighted_index) { + _window_guest_list_highlighted_index = i; window_invalidate(w); } } @@ -533,11 +504,11 @@ static void window_guest_list_invalidate() w->pressed_widgets &= ~(1 << WIDX_TAB_1); w->pressed_widgets &= ~(1 << WIDX_TAB_2); - w->pressed_widgets |= (1 << (window_guest_list_selected_tab + WIDX_TAB_1)); + w->pressed_widgets |= (1 << (_window_guest_list_selected_tab + WIDX_TAB_1)); - window_guest_list_widgets[WIDX_INFO_TYPE_DROPDOWN].image = STR_ACTIONS + window_guest_list_selected_view; + window_guest_list_widgets[WIDX_INFO_TYPE_DROPDOWN].image = STR_ACTIONS + _window_guest_list_selected_view; window_guest_list_widgets[WIDX_MAP].type = WWT_EMPTY; - if (window_guest_list_selected_tab == PAGE_INDIVIDUAL && window_guest_list_selected_filter != -1) + if (_window_guest_list_selected_tab == PAGE_INDIVIDUAL && _window_guest_list_selected_filter != -1) window_guest_list_widgets[WIDX_MAP].type = WWT_FLATBTN; window_guest_list_widgets[WIDX_BACKGROUND].right = w->width - 1; @@ -550,7 +521,7 @@ static void window_guest_list_invalidate() window_guest_list_widgets[WIDX_GUEST_LIST].right = w->width - 4; window_guest_list_widgets[WIDX_GUEST_LIST].bottom = w->height - 15; - window_guest_list_widgets[WIDX_PAGE_DROPDOWN].image = window_guest_list_selected_page + 3440; + window_guest_list_widgets[WIDX_PAGE_DROPDOWN].image = _window_guest_list_selected_page + 3440; } /** @@ -570,7 +541,7 @@ static void window_guest_list_paint() window_draw_widgets(w, dpi); // Tab 1 image - i = (window_guest_list_selected_tab == 0 ? w->var_490 & 0x0FFFFFFFC : 0); + i = (_window_guest_list_selected_tab == 0 ? w->var_490 & 0x0FFFFFFFC : 0); i += ((int*)*((int*)0x00982708))[0] + 1; i |= 0xA1600000; gfx_draw_sprite( @@ -581,7 +552,7 @@ static void window_guest_list_paint() ); // Tab 2 image - i = (window_guest_list_selected_tab == 1 ? w->var_490 / 4 : 0); + i = (_window_guest_list_selected_tab == 1 ? w->var_490 / 4 : 0); gfx_draw_sprite( dpi, 5568 + i, @@ -592,10 +563,10 @@ static void window_guest_list_paint() // Filter description x = w->x + 6; y = w->y + window_guest_list_widgets[WIDX_TAB_CONTENT_PANEL].top + 3; - if (window_guest_list_selected_tab == PAGE_INDIVIDUAL) { - if (window_guest_list_selected_filter != -1) { + if (_window_guest_list_selected_tab == PAGE_INDIVIDUAL) { + if (_window_guest_list_selected_filter != -1) { if (RCT2_GLOBAL(0x00F1EDF6, sint16) != -1) - format = STR_GUESTS_FILTER + window_guest_list_selected_filter; + format = STR_GUESTS_FILTER + _window_guest_list_selected_filter; else format = STR_GUESTS_FILTER_THINKING_ABOUT; } else { @@ -607,7 +578,7 @@ static void window_guest_list_paint() gfx_draw_string_left_clipped(dpi, format, 0x00F1EDF6, 0, x, y, 310); // Number of guests (list items) - if (window_guest_list_selected_tab == PAGE_INDIVIDUAL) { + if (_window_guest_list_selected_tab == PAGE_INDIVIDUAL) { x = w->x + 4; y = w->y + window_guest_list_widgets[WIDX_GUEST_LIST].bottom + 2; RCT2_GLOBAL(0x013CE952, sint16) = w->var_492; @@ -615,19 +586,6 @@ static void window_guest_list_paint() } } -/** - * - * rct2: 0x00698721 - */ -static int get_guest_face_sprite(rct_peep *peep) -{ - int eax, ebx, ecx, edx, esi, edi, ebp; - esi = peep; - ebp = 999; - RCT2_CALLFUNC_X(0x00698721, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); - return ebp; -} - /** * * rct2: 0x00699701 @@ -647,10 +605,10 @@ static void window_guest_list_scrollpaint() // Background fill gfx_fill_rect(dpi, dpi->x, dpi->y, dpi->x + dpi->width - 1, dpi->y + dpi->height - 1, ((char*)0x0141FC48)[w->colours[1] * 8]); - switch (window_guest_list_selected_tab) { + switch (_window_guest_list_selected_tab) { case PAGE_INDIVIDUAL: i = 0; - y = window_guest_list_selected_page * -0x7BF2; + y = _window_guest_list_selected_page * -0x7BF2; // For each guest spriteIdx = RCT2_GLOBAL(RCT2_ADDRESS_SPRITES_START_PEEP, uint16); @@ -663,7 +621,7 @@ static void window_guest_list_scrollpaint() peep->var_0C &= ~0x200; if (peep->var_2A != 0) continue; - if (window_guest_list_selected_filter != -1) { + if (_window_guest_list_selected_filter != -1) { if (window_guest_list_is_peep_in_filter(peep)) continue; RCT2_GLOBAL(0x009AC861, uint16) |= 1; @@ -678,7 +636,7 @@ static void window_guest_list_scrollpaint() // Highlight backcolour and text colour (format) format = 1191; - if (i == window_guest_list_highlighted_index) { + if (i == _window_guest_list_highlighted_index) { gfx_fill_rect(dpi, 0, y, 800, y + 9, 0x02000031); format = 1193; } @@ -688,7 +646,7 @@ static void window_guest_list_scrollpaint() RCT2_GLOBAL(0x013CE954, uint32) = peep->id; gfx_draw_string_left_clipped(dpi, format, 0x013CE952, 0, 0, y - 1, 113); - switch (window_guest_list_selected_view) { + switch (_window_guest_list_selected_view) { case VIEW_ACTIONS: // Guest face gfx_draw_sprite(dpi, get_guest_face_sprite(peep), 118, y); @@ -743,7 +701,7 @@ static void window_guest_list_scrollpaint() y = 0; // For each group of guests - for (i = 0; i < window_guest_list_num_groups; i++) { + for (i = 0; i < _window_guest_list_num_groups; i++) { // Check if y is beyond the scroll control if (y + 22 >= dpi->y) { // Check if y is beyond the scroll control @@ -752,20 +710,20 @@ static void window_guest_list_scrollpaint() // Highlight backcolour and text colour (format) format = 1191; - if (i == window_guest_list_highlighted_index) { + if (i == _window_guest_list_highlighted_index) { gfx_fill_rect(dpi, 0, y, 800, y + 20, 0x02000031); format = 1193; } // Draw guest faces - numGuests = window_guest_list_groups_num_guests[i]; + numGuests = _window_guest_list_groups_num_guests[i]; for (j = 0; j < 56 && j < numGuests; j++) - gfx_draw_sprite(dpi, window_guest_list_groups_guest_faces[numGuests * 56 + j] + 5486, j * 8, y + 9); + gfx_draw_sprite(dpi, _window_guest_list_groups_guest_faces[numGuests * 56 + j] + 5486, j * 8, y + 9); // Draw action - RCT2_GLOBAL(0x013CE952, uint16) = ((uint32*)0x00F1B016)[i * 2] & 0xFFFF; - RCT2_GLOBAL(0x013CE952 + 2, uint16) = ((uint32*)0x00F1B016)[i * 2] >> 16; - RCT2_GLOBAL(0x013CE952 + 4, uint32) = ((int*)0x00F1B01A)[i * 2]; + RCT2_GLOBAL(0x013CE952, uint16) = _window_guest_list_groups_argument_1[i] & 0xFFFF; + RCT2_GLOBAL(0x013CE952 + 2, uint16) = _window_guest_list_groups_argument_1[i] >> 16; + RCT2_GLOBAL(0x013CE952 + 4, uint32) = _window_guest_list_groups_argument_2[i]; RCT2_GLOBAL(0x013CE952 + 10, uint32) = numGuests; gfx_draw_string_left_clipped(dpi, format, 0x013CE952, 0, 0, y - 1, 414); @@ -777,4 +735,206 @@ static void window_guest_list_scrollpaint() } break; } +} + +/** + * + * rct2: 0x0069B865 + */ +static int window_guest_list_is_peep_in_filter(rct_peep* peep) +{ + int eax, ebx, ecx, edx, esi, edi, ebp; + char temp; + + temp = _window_guest_list_selected_view; + _window_guest_list_selected_view = _window_guest_list_selected_filter; + + esi = peep; + RCT2_CALLFUNC_X(0x0069B7EA, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); + ebx &= 0xFFFF; + + _window_guest_list_selected_view = temp; + eax = (RCT2_GLOBAL(0x013CE952, uint16) << 16) | ebx; + + if (((RCT2_GLOBAL(0x00F1EDF6, uint32) >> 16) & 0xFFFF) == 0xFFFF && _window_guest_list_selected_filter == 1) + eax |= 0xFFFF; + + if (eax == RCT2_GLOBAL(0x00F1EDF6, uint32) && RCT2_GLOBAL(0x013CE954, uint32) == RCT2_GLOBAL(0x00F1EDFA, uint32)) + return 0; + return 1; +} + +static int sub_69B7EA(rct_peep *peep, int *outEAX) +{ + int eax, ebx, ecx, edx, esi, edi, ebp; + + switch (_window_guest_list_selected_view) { + case VIEW_ACTIONS: + eax = peep->var_0A; + RCT2_CALLFUNC_X(0x00698B0D, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); + RCT2_GLOBAL(0x013CE952, uint16) = ecx & 0xFFFF; + RCT2_GLOBAL(0x013CE952 + 2, uint32) = edx; + + *outEAX = eax; + return ebx & 0xFFFF; + case VIEW_THOUGHTS: + if (peep->thoughts[0].pad_3 <= 5) { + eax = peep->thoughts[0].item; + ebx = peep->thoughts[0].type; + if (peep->thoughts[0].type != PEEP_THOUGHT_TYPE_NONE) { + RCT2_CALLFUNC_X(0x00698342, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); + RCT2_GLOBAL(0x013CE952, uint16) = *((uint16*)esi); + RCT2_GLOBAL(0x013CE952 + 2, uint32) = *((uint32*)(esi + 2)); + + *outEAX = eax; + return ebx & 0xFFFF; + } + } + + RCT2_GLOBAL(0x013CE952, uint16) = 0; + RCT2_GLOBAL(0x013CE952 + 2, uint32) = 0; + + *outEAX = 0; + return 0; + } +} + +/** + * + * rct2: 0x0069B5AE + */ +static void window_guest_list_find_groups() +{ + int spriteIdx, spriteIdx2, groupIndex, faceIndex; + rct_peep *peep, *peep2; + + int eax = RCT2_GLOBAL(0x00F663AC, uint32) & 0xFFFFFF00; + if (_window_guest_list_selected_view == RCT2_GLOBAL(0x00F1EE02, uint32)) + if (RCT2_GLOBAL(0x00F1AF20, uint16) != 0 || eax == RCT2_GLOBAL(0x00F1AF1C, uint32)) + return; + + RCT2_GLOBAL(0x00F1AF1C, uint32) = eax; + RCT2_GLOBAL(0x00F1EE02, uint32) = _window_guest_list_selected_view; + RCT2_GLOBAL(0x00F1AF20, uint16) = 320; + _window_guest_list_num_groups = 0; + + // Set all guests to unassigned + spriteIdx = RCT2_GLOBAL(RCT2_ADDRESS_SPRITES_START_PEEP, uint16); + while (spriteIdx != SPRITE_INDEX_NULL) { + peep = &(RCT2_ADDRESS(RCT2_ADDRESS_SPRITE_LIST, rct_sprite)[spriteIdx].peep); + spriteIdx = peep->next; + + if (peep->type != PEEP_TYPE_GUEST || peep->var_2A != 0) + continue; + + peep->var_0C |= (1 << 8); + } + + // For each guest / group + spriteIdx = RCT2_GLOBAL(RCT2_ADDRESS_SPRITES_START_PEEP, uint16); + while (spriteIdx != SPRITE_INDEX_NULL) { + peep = &(RCT2_ADDRESS(RCT2_ADDRESS_SPRITE_LIST, rct_sprite)[spriteIdx].peep); + spriteIdx = peep->next; + + if (peep->type != PEEP_TYPE_GUEST || peep->var_2A != 0 || !(peep->var_0C & (1 << 8))) + continue; + + // New group, cap at 240 though + groupIndex = _window_guest_list_num_groups; + if (groupIndex >= 240) + break; + + int ax = peep->var_0A; + _window_guest_list_num_groups++; + _window_guest_list_groups_num_guests[groupIndex] = 1; + peep->var_0C &= ~(1 << 8); + int bx = sub_69B7EA(peep, &eax); + eax = (RCT2_GLOBAL(0x013CE952, uint16) << 16) | bx; + RCT2_GLOBAL(0x00F1EDF6, uint32) = eax; + _window_guest_list_groups_argument_1[groupIndex] = eax; + RCT2_GLOBAL(0x00F1EDFA, uint32) = RCT2_GLOBAL(0x013CE952 + 2, uint32); + _window_guest_list_groups_argument_2[groupIndex] = RCT2_GLOBAL(0x013CE952 + 2, uint32); + RCT2_ADDRESS(0x00F1AF26, uint8)[groupIndex] = groupIndex; + faceIndex = groupIndex * 56; + _window_guest_list_groups_guest_faces[faceIndex++] = get_guest_face_sprite(peep) - 5486; + + // Find more peeps that belong to same group + spriteIdx2 = peep->next; + while (spriteIdx2 != SPRITE_INDEX_NULL) { + peep2 = &(RCT2_ADDRESS(RCT2_ADDRESS_SPRITE_LIST, rct_sprite)[spriteIdx2].peep); + spriteIdx2 = peep2->next; + + if (peep2->type != PEEP_TYPE_GUEST || peep2->var_2A != 0 || !(peep2->var_0C & (1 << 8))) + continue; + + // Get and check if in same group + // BUG this doesn't work! + bx = sub_69B7EA(peep2, &eax); + if (bx != RCT2_GLOBAL(0x00F1EDF6, uint32) || (eax & 0xFFFF) != RCT2_GLOBAL(0x013CE952, uint16) || eax != RCT2_GLOBAL(0x013CE952 + 2, uint32)) + continue; + + // Assign guest + _window_guest_list_groups_num_guests[groupIndex]++; + peep2->var_0C &= ~(1 << 8); + + // Add face sprite, cap at 56 though + if (_window_guest_list_groups_num_guests[groupIndex] < 56) + continue; + _window_guest_list_groups_guest_faces[faceIndex++] = get_guest_face_sprite(peep2) - 5486; + } + + if (RCT2_GLOBAL(0x00F1EDF6, uint16) == 0) { + _window_guest_list_num_groups--; + continue; + } + + ax = _window_guest_list_groups_num_guests[groupIndex]; + int edi = 0; + + while (1) { + if (edi >= groupIndex) + goto nextPeep; + if (ax > _window_guest_list_groups_num_guests[edi]) + break; + edi++; + } + + int ecx = _window_guest_list_groups_argument_1[groupIndex]; + int edx = _window_guest_list_groups_argument_2[groupIndex]; + int bl = RCT2_ADDRESS(0x00F1AF26, uint8)[groupIndex]; + int temp; + + do { + temp = ax; + ax = _window_guest_list_groups_num_guests[edi]; + _window_guest_list_groups_num_guests[edi] = temp; + + temp = ecx; + ecx = _window_guest_list_groups_argument_1[edi]; + _window_guest_list_groups_argument_1[edi] = temp; + + temp = edx; + edx = _window_guest_list_groups_argument_2[edi]; + _window_guest_list_groups_argument_2[edi] = temp; + + RCT2_ADDRESS(0x00F1AF26, uint8)[edi] = bl; + bl = RCT2_ADDRESS(0x00F1AF26, uint8)[edi]; + } while (++edi <= groupIndex); + + nextPeep: + ; + } +} + +/** + * + * rct2: 0x00698721 + */ +static int get_guest_face_sprite(rct_peep *peep) +{ + int eax, ebx, ecx, edx, esi, edi, ebp; + esi = peep; + ebp = 999; + RCT2_CALLFUNC_X(0x00698721, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); + return ebp; } \ No newline at end of file From 726c1a2312bfdaa40c0e5fb4c2c15b8ebd4e8d71 Mon Sep 17 00:00:00 2001 From: IntelOrca Date: Mon, 5 May 2014 20:16:27 +0100 Subject: [PATCH 26/44] fix peep structure --- src/peep.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/peep.h b/src/peep.h index 1ec0c917f6..fb5b009194 100644 --- a/src/peep.h +++ b/src/peep.h @@ -348,10 +348,7 @@ typedef struct { uint8 photo2_ride_ref; // 0x5C uint8 photo3_ride_ref; // 0x5D uint8 photo4_ride_ref; // 0x5E - uint8 pad_5F[0x09]; - uint8 pad_48[0x10]; - uint32 item_extra_flags; // 0x58 - uint8 pad_5C[0x0C]; // 0x5C + uint8 pad_5F[0x09]; // 0x5C uint8 current_ride; // 0x68 uint8 pad_69; uint8 current_train; // 0x6A From 5ca2b1a7fd9863582115abbe7f117cda1c57e851 Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Mon, 5 May 2014 20:27:06 +0100 Subject: [PATCH 27/44] Added more strings --- src/strings.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/strings.h b/src/strings.h index 3afedf5f26..232d0b4068 100644 --- a/src/strings.h +++ b/src/strings.h @@ -354,6 +354,17 @@ enum { STR_CHANGE_BASE_LAND_TIP = 2294, STR_CHANGE_VERTICAL_LAND_TIP = 2295, + //STR_NONE = 2368, + STR_LOW = 2369, + STR_AVERAGE = 2370, + STR_HIGH = 2371, + //STR_LOW = 2372, + STR_MEDIUM = 2373, + //STR_HIGH = 2374, + STR_VERY_HIGH = 2375, + STR_EXTREME = 2376, + STR_ULTRA_EXTREME = 2377, + STR_ADJUST_SMALLER_LAND_TIP = 2378, STR_ADJUST_LARGER_LAND_TIP = 2379, STR_ADJUST_SMALLER_WATER_TIP = 2380, From 48caec8b5887e0185575988253bb076dab4d942d Mon Sep 17 00:00:00 2001 From: lnz Date: Sun, 4 May 2014 20:13:05 +0200 Subject: [PATCH 28/44] Label unimplemented functions in scenario_update --- src/scenario.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/scenario.c b/src/scenario.c index cd0fb9b931..33d8cd39a3 100644 --- a/src/scenario.c +++ b/src/scenario.c @@ -854,7 +854,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); // finance update + RCT2_CALLPROC_EBPSAFE(0x0069E79A); // daily profit update RCT2_CALLPROC_EBPSAFE(0x0069C35E); // some kind of peeps days_visited update loop RCT2_CALLPROC_EBPSAFE(0x006C45E7); // get local time RCT2_CALLPROC_EBPSAFE(0x0066A13C); // objective 6 dragging @@ -868,13 +868,13 @@ void scenario_update() //if ( (unsigned int)((4 * current_day) & 0xFFFF) >= 0xFFEFu) { if ( next_month_tick % 0x4000 == 0) { // weekly checks - RCT2_CALLPROC_EBPSAFE(0x006C18A9); - RCT2_CALLPROC_EBPSAFE(0x00684DA5); - RCT2_CALLPROC_EBPSAFE(0x0069E092); + RCT2_CALLPROC_EBPSAFE(0x006C18A9); // pay wages + RCT2_CALLPROC_EBPSAFE(0x00684DA5); // pay for research + RCT2_CALLPROC_EBPSAFE(0x0069E092); // pay loan interest scenario_marketing_update(); - RCT2_CALLPROC_EBPSAFE(0x0069BF41); - RCT2_CALLPROC_EBPSAFE(0x006B7A5E); - RCT2_CALLPROC_EBPSAFE(0x006AC916); + RCT2_CALLPROC_EBPSAFE(0x0069BF41); // peep needs update and warnings + RCT2_CALLPROC_EBPSAFE(0x006B7A5E); // check ride reachability + RCT2_CALLPROC_EBPSAFE(0x006AC916); // ride update favourited if (month <= 1 && RCT2_GLOBAL(0x009ADAE0, sint32) != -1 && RCT2_GLOBAL(0x009ADAE0 + 14, uint16) & 1) { for (int i = 0; i < 100; ++i) { @@ -886,8 +886,8 @@ void scenario_update() break; } } - RCT2_CALLPROC_EBPSAFE(0x0066A231); - RCT2_CALLPROC_EBPSAFE(0x0066A348); + RCT2_CALLPROC_EBPSAFE(0x0066A231); // update histories (finance, ratings, etc) + RCT2_CALLPROC_EBPSAFE(0x0066A348); // update parksize } //if ( (unsigned int)((2 * current_day) & 0xFFFF) >= 0xFFF8) { @@ -904,7 +904,7 @@ void scenario_update() RCT2_CALLPROC_EBPSAFE(0x0069DEAD); scenario_objectives_check(); scenario_entrance_fee_too_high_check(); - RCT2_CALLPROC_EBPSAFE(0x0066A86C); + RCT2_CALLPROC_EBPSAFE(0x0066A86C); // award checks } } From 589118d66dcb3856b293e9160c277b42210c3b79 Mon Sep 17 00:00:00 2001 From: lnz Date: Mon, 5 May 2014 21:59:59 +0200 Subject: [PATCH 29/44] Implement some finance functions and added a few addresses & tables --- projects/openrct2.vcxproj | 2 ++ projects/openrct2.vcxproj.filters | 6 ++++++ src/addresses.h | 4 ++++ src/park.c | 4 ++-- src/scenario.c | 11 ++++++----- 5 files changed, 20 insertions(+), 7 deletions(-) diff --git a/projects/openrct2.vcxproj b/projects/openrct2.vcxproj index 6ff3a72044..3c13ff3f2b 100644 --- a/projects/openrct2.vcxproj +++ b/projects/openrct2.vcxproj @@ -21,6 +21,7 @@ + @@ -58,6 +59,7 @@ + diff --git a/projects/openrct2.vcxproj.filters b/projects/openrct2.vcxproj.filters index 44896fdf76..00a17f947b 100644 --- a/projects/openrct2.vcxproj.filters +++ b/projects/openrct2.vcxproj.filters @@ -123,6 +123,9 @@ Header Files + + Header Files + @@ -275,6 +278,9 @@ Windows + + Source Files + diff --git a/src/addresses.h b/src/addresses.h index 601d8aa95e..80f3bfcacb 100644 --- a/src/addresses.h +++ b/src/addresses.h @@ -160,8 +160,12 @@ #define RCT2_ADDRESS_CURRENT_COMPANY_VALUE 0x0135874C #define RCT2_ADDRESS_AWARD_LIST 0x01358760 #define RCT2_ADDRESS_CURRENT_MONEY_ENCRYPTED 0x013587F8 +#define RCT2_ADDRESS_EXPENDITURE_TABLE 0x01357848 +#define RCT2_ADDRESS_CURRENT_RESEARCH_LEVEL 0x013573FF +#define RCT2_ADDRESS_CURRENT_INTEREST_RATE 0x0135934A #define RCT2_ADDRESS_MAP_SIZE 0x01358834 +#define RCT2_ADDRESS_PARK_SIZE 0x013580EA #define RCT2_ADDRESS_SCENARIO_NAME 0x0135920A #define RCT2_ADDRESS_SCENARIO_DETAILS 0x0135924A diff --git a/src/park.c b/src/park.c index 6beb551b6c..a8f5a90f37 100644 --- a/src/park.c +++ b/src/park.c @@ -62,8 +62,8 @@ int park_calculate_size() } } - if (tiles != RCT2_GLOBAL(0x013580EA, sint16)) { - RCT2_GLOBAL(0x013580EA, sint16) = tiles; + if (tiles != RCT2_GLOBAL(RCT2_ADDRESS_PARK_SIZE, sint16)) { + RCT2_GLOBAL(RCT2_ADDRESS_PARK_SIZE, sint16) = tiles; window_invalidate_by_id(WC_PARK_INFORMATION, 0); } diff --git a/src/scenario.c b/src/scenario.c index 33d8cd39a3..b283c9e767 100644 --- a/src/scenario.c +++ b/src/scenario.c @@ -23,6 +23,7 @@ #include #include "addresses.h" #include "date.h" +#include "finance.h" #include "game.h" #include "map.h" #include "news_item.h" @@ -856,7 +857,7 @@ void scenario_update() // daily checks RCT2_CALLPROC_EBPSAFE(0x0069E79A); // daily profit update RCT2_CALLPROC_EBPSAFE(0x0069C35E); // some kind of peeps days_visited update loop - RCT2_CALLPROC_EBPSAFE(0x006C45E7); // get local time + get_local_time(); RCT2_CALLPROC_EBPSAFE(0x0066A13C); // objective 6 dragging if (objective_type == 10 || objective_type == 9 || objective_type == 8 || objective_type == 6 || objective_type == 5) { @@ -868,9 +869,9 @@ void scenario_update() //if ( (unsigned int)((4 * current_day) & 0xFFFF) >= 0xFFEFu) { if ( next_month_tick % 0x4000 == 0) { // weekly checks - RCT2_CALLPROC_EBPSAFE(0x006C18A9); // pay wages - RCT2_CALLPROC_EBPSAFE(0x00684DA5); // pay for research - RCT2_CALLPROC_EBPSAFE(0x0069E092); // pay loan interest + finance_pay_wages(); + finance_pay_research(); + finance_pay_interest(); scenario_marketing_update(); RCT2_CALLPROC_EBPSAFE(0x0069BF41); // peep needs update and warnings RCT2_CALLPROC_EBPSAFE(0x006B7A5E); // check ride reachability @@ -887,7 +888,7 @@ void scenario_update() } } RCT2_CALLPROC_EBPSAFE(0x0066A231); // update histories (finance, ratings, etc) - RCT2_CALLPROC_EBPSAFE(0x0066A348); // update parksize + park_calculate_size(); } //if ( (unsigned int)((2 * current_day) & 0xFFFF) >= 0xFFF8) { From 9de233e34b0bfea02578d12c8db0eccadf047b65 Mon Sep 17 00:00:00 2001 From: lnz Date: Mon, 5 May 2014 22:16:34 +0200 Subject: [PATCH 30/44] Actually add finance code. --- src/finance.c | 103 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/finance.h | 40 ++++++++++++++++++++ 2 files changed, 143 insertions(+) create mode 100644 src/finance.c create mode 100644 src/finance.h diff --git a/src/finance.c b/src/finance.c new file mode 100644 index 0000000000..37c4a14d60 --- /dev/null +++ b/src/finance.c @@ -0,0 +1,103 @@ +/***************************************************************************** +* Copyright (c) 2014 Matthias Lanzinger +* OpenRCT2, an open source clone of Roller Coaster Tycoon 2. +* +* This file is part of OpenRCT2. +* +* OpenRCT2 is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. + +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. + +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*****************************************************************************/ + +#include "addresses.h" +#include "finance.h" +#include "sprite.h" +#include "park.h" +#include "peep.h" +#include "window.h" + + +const int wage_table[4] = { 500, 800, 600, 550 }; +const int research_cost_table[4] = { 0, 1000, 2000, 4000 }; // monthly cost + +/** + * + * rct2: 0x069C674 + * @param amount (eax) + * @param type passed via global var 0x0141F56C, our type is that var/4. + **/ +void finance_payment(int amount, rct_expenditure_type type) +{ + int test = RCT2_GLOBAL(0x13CA740, uint32); + sint32 cur_money = DECRYPT_MONEY(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONEY_ENCRYPTED, sint32)); + sint32 new_money = cur_money - amount; + + //overflow check + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONEY_ENCRYPTED, sint32) = ENCRYPT_MONEY(new_money); + RCT2_ADDRESS(RCT2_ADDRESS_EXPENDITURE_TABLE, sint32)[type] -= amount; + if (RCT2_ADDRESS(0x00988E60, uint32)[type] & 1) + RCT2_GLOBAL(0x0135832C, sint32) -= amount; + + + RCT2_GLOBAL(0x009A9804, uint32) |= 1; // money diry flag + window_invalidate_by_id(WC_FINANCES, 0); +} + +/** + * Pays the wages of all active staff members in the park. + * rct2: 0x006C18A9 + **/ +void finance_pay_wages() +{ + rct_peep* peep; + uint16 sprite_idx; + + if (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & 0x800) + return; + + for (sprite_idx = RCT2_GLOBAL(RCT2_ADDRESS_SPRITES_START_PEEP, uint16); sprite_idx != SPRITE_INDEX_NULL; sprite_idx = peep->next) { + peep = &(RCT2_ADDRESS(RCT2_ADDRESS_SPRITE_LIST, rct_sprite)[sprite_idx].peep); + if (peep->type == PEEP_TYPE_STAFF) + finance_payment(wage_table[peep->staff_type], RCT_EXPENDITURE_TYPE_WAGES); + } +} + +/** +* Pays the current research level's cost. +* rct2: 0x00684DA5 +**/ +void finance_pay_research() +{ + uint8 level; + + if (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & 0x800) + return; + + level = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_RESEARCH_LEVEL, uint8); + finance_payment(research_cost_table[level] / 4, RCT_EXPENDITURE_TYPE_RESEARCH); +} + +/** + * Pay interest on current loans. + * rct2: 0x0069E092 + **/ +void finance_pay_interest() +{ + sint32 current_loan = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_LOAN, sint32); + sint16 current_interest = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_INTEREST_RATE, sint16); + sint64 tempcost = (current_loan * 5 * current_interest) >> 14; // (5*interest)/2^14 is pretty close to + + if (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & 0x800) + return; + + finance_payment((sint32)tempcost, RCT_EXPENDITURE_TYPE_INTEREST); +} diff --git a/src/finance.h b/src/finance.h new file mode 100644 index 0000000000..6c8d75fdfa --- /dev/null +++ b/src/finance.h @@ -0,0 +1,40 @@ +/***************************************************************************** +* Copyright (c) 2014 Matthias Lanzinger +* OpenRCT2, an open source clone of Roller Coaster Tycoon 2. +* +* This file is part of OpenRCT2. +* +* OpenRCT2 is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. + +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. + +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*****************************************************************************/ + +#ifndef _FINANCE_H_ +#define _FINANCE_H_ + +#include "rct2.h" + +typedef int rct_expenditure_type; + +enum { + RCT_EXPENDITURE_TYPE_WAGES = 10, + RCT_EXPENDITURE_TYPE_RESEARCH = 12, + RCT_EXPENDITURE_TYPE_INTEREST = 13 +}; + + +void finance_payment(int amount, rct_expenditure_type type); +void finance_pay_wages(); +void finance_pay_research(); +void finance_pay_interest(); + +#endif \ No newline at end of file From 1f00ad9110b9e91f7f4ababae590d584aa618b28 Mon Sep 17 00:00:00 2001 From: Maciek Baron Date: Mon, 5 May 2014 23:10:28 +0100 Subject: [PATCH 31/44] Implemented a few functions in editor.c --- src/addresses.h | 2 + src/editor.c | 105 +++++++++++++++++++++++++++++++++++++++++++----- src/editor.h | 5 +++ 3 files changed, 101 insertions(+), 11 deletions(-) diff --git a/src/addresses.h b/src/addresses.h index 601d8aa95e..594aae6db0 100644 --- a/src/addresses.h +++ b/src/addresses.h @@ -141,6 +141,7 @@ #define RCT2_ADDRESS_SPRITES_START_LITTER 0x013573C4 #define RCT2_ADDRESS_CURRENT_LOAN 0x013573E0 +#define RCT2_ADDRESS_MAXIMUM_LOAN 0x013580F0 #define RCT2_ADDRESS_PARK_FLAGS 0x013573E4 #define RCT2_ADDRESS_PARK_ENTRANCE_FEE 0x013573E8 #define RCT2_ADDRESS_GUESTS_IN_PARK 0x01357844 @@ -160,6 +161,7 @@ #define RCT2_ADDRESS_CURRENT_COMPANY_VALUE 0x0135874C #define RCT2_ADDRESS_AWARD_LIST 0x01358760 #define RCT2_ADDRESS_CURRENT_MONEY_ENCRYPTED 0x013587F8 +#define RCT2_ADDRESS_CURRENT_INTEREST_RATE 0x0135934A #define RCT2_ADDRESS_MAP_SIZE 0x01358834 diff --git a/src/editor.c b/src/editor.c index 0c53218ee2..31e77b4229 100644 --- a/src/editor.c +++ b/src/editor.c @@ -40,19 +40,19 @@ void editor_load() { rct_window *mainWindow; - RCT2_CALLPROC_EBPSAFE(0x006BABB4); // pause_sounds - RCT2_CALLPROC_EBPSAFE(0x006BABD8); // unpause_sounds + pause_sounds(); + unpause_sounds(); RCT2_CALLPROC_EBPSAFE(0x006A9CE8); map_init(); RCT2_CALLPROC_EBPSAFE(0x006B9CB0); - RCT2_CALLPROC_EBPSAFE(0x00667104); // reset_park_entrances - RCT2_CALLPROC_EBPSAFE(0x006C4209); // reset_saved_strings + reset_park_entrances(); + reset_saved_strings(); RCT2_CALLPROC_EBPSAFE(0x0069EB13); // sprites_init ride_init_all(); RCT2_CALLPROC_EBPSAFE(0x0068F083); // window_guest_list_init_vars_a RCT2_CALLPROC_EBPSAFE(0x006BD3A4); park_init(); - RCT2_CALLPROC_EBPSAFE(0x0069DEFB); // finance_init + finance_init(); date_reset(); RCT2_CALLPROC_EBPSAFE(0x0068F050); // window_guest_list_init_vars_b RCT2_CALLPROC_EBPSAFE(0x006BD39C); @@ -94,14 +94,14 @@ void trackdesigner_load() map_init(); set_all_land_owned(); RCT2_CALLPROC_EBPSAFE(0x006B9CB0); - RCT2_CALLPROC_EBPSAFE(0x00667104); // reset_park_entrances - RCT2_CALLPROC_EBPSAFE(0x006C4209); // reset_saved_strings + reset_park_entrances(); + reset_saved_strings(); RCT2_CALLPROC_EBPSAFE(0x0069EB13); // reset_sprites ride_init_all(); RCT2_CALLPROC_EBPSAFE(0x0068F083); // window_guest_list_init_vars_a RCT2_CALLPROC_EBPSAFE(0x006BD3A4); park_init(); - RCT2_CALLPROC_EBPSAFE(0x0069DEFB); // finance_init + finance_init(); date_reset(); RCT2_CALLPROC_EBPSAFE(0x0068F050); // window_guest_list_init_vars_b RCT2_CALLPROC_EBPSAFE(0x006BD39C); @@ -132,14 +132,14 @@ void trackmanager_load() map_init(); set_all_land_owned(); RCT2_CALLPROC_EBPSAFE(0x006B9CB0); - RCT2_CALLPROC_EBPSAFE(0x00667104); // reset_park_entrances - RCT2_CALLPROC_EBPSAFE(0x006C4209); // reset_saved_strings + reset_park_entrances(); + reset_saved_strings(); RCT2_CALLPROC_EBPSAFE(0x0069EB13); // reset_sprites ride_init_all(); RCT2_CALLPROC_EBPSAFE(0x0068F083); // window_guest_list_init_vars_a RCT2_CALLPROC_EBPSAFE(0x006BD3A4); park_init(); - RCT2_CALLPROC_EBPSAFE(0x0069DEFB); // finance_init + finance_init(); date_reset(); RCT2_CALLPROC_EBPSAFE(0x0068F050); // window_guest_list_init_vars_b RCT2_CALLPROC_EBPSAFE(0x006BD39C); @@ -168,3 +168,86 @@ static void set_all_land_owned() game_do_command(64, 1, 64, 2, 56, (mapSize - 2) * 32, (mapSize - 2) * 32); } + +/** +* +* rct2: 0x00667104 +*/ +void reset_park_entrances() { + RCT2_GLOBAL(0x013573D4, uint16) = 0; + + for (short i = 0; i < 4; i++) { + RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_X, uint16)[i] = 0x8000; + } + + RCT2_GLOBAL(0x013573F2, uint16) = 0xFFFF; + RCT2_GLOBAL(0x013573F8, uint16) = 0xFFFF; +} + +/** +* +* rct2: 0x006C4209 +*/ +void reset_saved_strings() { + for (int i = 0; i < 1024; i++) { + RCT2_ADDRESS(0x135A8F4, uint8)[i * 32] = 0; + } +} + +/** +* +* rct2: 0x006BABB4 +*/ +void pause_sounds() { + if (++RCT2_GLOBAL(0x009AF59C, uint8) == 1) { + RCT2_CALLPROC_EBPSAFE(0x006BCAE5); + RCT2_CALLPROC_EBPSAFE(0x006BABDF); + RCT2_CALLPROC_EBPSAFE(0x006BCA9F); + RCT2_CALLPROC_EBPSAFE(0x006BD07F); + } +} + +/** +* +* rct2: 0x006BABD8 +*/ +void unpause_sounds() { + RCT2_GLOBAL(0x009AF59C, uint8)--; +} + +/** +* +* rct2: 0x0069DEFB +*/ +void finance_init() { + + for (short i = 0; i < 56; i++) { + RCT2_ADDRESS(0x01357848, uint32)[i] = 0; + } + + RCT2_GLOBAL(0x0135832C, uint32) = 0; + + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PROFIT, uint32) = 0; + + RCT2_GLOBAL(0x01358334, uint32) = 0; + RCT2_GLOBAL(0x01358338, uint16) = 0; + + RCT2_GLOBAL(0x013573DC, uint32) = 100000; + + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONEY_ENCRYPTED, sint32) = ENCRYPT_MONEY(100000); + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_LOAN, sint32) = 100000; + RCT2_GLOBAL(RCT2_ADDRESS_MAXIMUM_LOAN, uint32) = 200000; + + RCT2_GLOBAL(0x013587D0, uint32) = 0; + + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_INTEREST_RATE, uint8) = 10; + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PARK_VALUE, sint32) = 0; + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_COMPANY_VALUE, sint32) = 0; + RCT2_GLOBAL(RCT2_ADDRESS_COMPLETED_COMPANY_VALUE, sint32) = 0x80000000; + RCT2_GLOBAL(RCT2_ADDRESS_TOTAL_ADMISSIONS, uint32) = 0; + RCT2_GLOBAL(RCT2_ADDRESS_INCOME_FROM_ADMISSIONS, uint32) = 0; + + RCT2_GLOBAL(0x013587D8, uint16) = 0x3F; + + RCT2_CALLPROC_EBPSAFE(0x0069E869); +} \ No newline at end of file diff --git a/src/editor.h b/src/editor.h index 34a7ef5ab3..d350e8a24f 100644 --- a/src/editor.h +++ b/src/editor.h @@ -25,5 +25,10 @@ void editor_load(); void editor_convert_save_to_scenario(); void trackdesigner_load(); void trackmanager_load(); +void reset_park_entrances(); +void reset_saved_strings(); +void pause_sounds(); +void unpause_sounds(); +void finance_init(); #endif From da0236ef8443e8e80603415eb6b4ff76c89ff428 Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Tue, 6 May 2014 21:09:08 +0100 Subject: [PATCH 32/44] Labeled init values for Shearwood Forest --- src/park.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/park.c b/src/park.c index 6beb551b6c..f80ca4839b 100644 --- a/src/park.c +++ b/src/park.c @@ -98,6 +98,8 @@ int calculate_park_rating() // -150 to +3 based on a range of guests from 0 to 2000 result -= 150 - (min(2000, RCT2_GLOBAL(RCT2_ADDRESS_GUESTS_IN_PARK, uint16)) / 13); + return result; + //1016 good // Guests, happiness, ? num_happy_peeps = 0; @@ -126,6 +128,8 @@ int calculate_park_rating() if (_bp >= 0) result -= _bp * 7; } + return result; + //998 980 // Rides { @@ -166,6 +170,7 @@ int calculate_park_rating() _bx = min(1000, _bx); result -= 200 - ((_ax + _bx) / 10); } + //826 // Litter { @@ -183,6 +188,7 @@ int calculate_park_rating() } result -= 600 - (4 * (150 - min(150, num_litter))); } + //826 // Rides { @@ -222,10 +228,10 @@ int calculate_park_rating() result += 100 - _ax - _bx; } } - + //809 result -= RCT2_GLOBAL(0x0135882E, sint16); result = clamp(0, result, 999); - + //809 return result; } From c26b944b6e7d1a170c25b5a0dc127eae69b63375 Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Tue, 6 May 2014 21:13:38 +0100 Subject: [PATCH 33/44] Now uses string references --- src/window_cheats.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/window_cheats.c b/src/window_cheats.c index 47ae59c9cd..4e9b188f53 100644 --- a/src/window_cheats.c +++ b/src/window_cheats.c @@ -56,7 +56,7 @@ static rct_widget window_cheats_money_widgets[] = { { WWT_IMGBTN, 1, 0, WW - 1, 43, WH - 1, 0x0FFFFFFFF, 65535}, // tab content panel { WWT_TAB, 1, 3, 33, 17, 43, 0x2000144E, 2462}, // tab 1 { WWT_TAB, 1, 34, 64, 17, 43, 0x2000144E, 2462}, // tab 2 - { WWT_CLOSEBOX, 1, 4, 74, 47, 63, 2375, 2375 }, // high money + { WWT_CLOSEBOX, 1, 4, 74, 47, 63, STR_VERY_HIGH, STR_VERY_HIGH}, // high money { WIDGETS_END }, }; @@ -67,7 +67,7 @@ static rct_widget window_cheats_guests_widgets[] = { { WWT_IMGBTN, 1, 0, WW - 1, 43, WH - 1, 0x0FFFFFFFF, 65535 }, // tab content panel { WWT_TAB, 1, 3, 33, 17, 43, 0x2000144E, 2462 }, // tab 1 { WWT_TAB, 1, 34, 64, 17, 43, 0x2000144E, 2462 }, // tab 2 - { WWT_CLOSEBOX, 1, 4, 74, 47, 63, 2376, 2376 }, // happy guests + { WWT_CLOSEBOX, 1, 4, 74, 47, 63, STR_EXTREME, STR_EXTREME}, // happy guests { WIDGETS_END }, }; From b52c5c0b2dea65171dbe3a2a4a9537fc82c93955 Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Tue, 6 May 2014 21:54:42 +0100 Subject: [PATCH 34/44] Peeps part now working --- src/park.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/park.c b/src/park.c index 19d5adf40c..6fcc3bbbb7 100644 --- a/src/park.c +++ b/src/park.c @@ -78,8 +78,8 @@ int calculate_park_rating() { { int eax, ebx, ecx, edx, esi, edi, ebp; - RCT2_CALLFUNC_X(0x00669EAA, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); - return eax & 0xFFFF; + //RCT2_CALLFUNC_X(0x00669EAA, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); + //return eax & 0xFFFF; } @@ -98,7 +98,7 @@ int calculate_park_rating() // -150 to +3 based on a range of guests from 0 to 2000 result -= 150 - (min(2000, RCT2_GLOBAL(RCT2_ADDRESS_GUESTS_IN_PARK, uint16)) / 13); - return result; + //return result; //1016 good // Guests, happiness, ? @@ -117,19 +117,21 @@ int calculate_park_rating() if (peep->var_C6 <= 89) _bp++; } - + // Peep happiness -500 to +0 result -= 500; - if (num_happy_peeps > 0) - result += 2 * min(250, (RCT2_GLOBAL(RCT2_ADDRESS_GUESTS_IN_PARK, uint16) * 300) / num_happy_peeps); + //516 good + + if (RCT2_GLOBAL(RCT2_ADDRESS_GUESTS_IN_PARK, uint16) > 0) + result += 2 * min(250, (num_happy_peeps * 300) / RCT2_GLOBAL(RCT2_ADDRESS_GUESTS_IN_PARK, uint16)); // ? _bp -= 25; if (_bp >= 0) result -= _bp * 7; } - return result; - //998 980 + + //998 good // Rides { From aef83362bc8aeabee3f874118cf90a1bece02d1d Mon Sep 17 00:00:00 2001 From: Maciek Baron Date: Tue, 6 May 2014 22:04:09 +0100 Subject: [PATCH 35/44] Cleaning up small shared functions Cleaning up small shared functions and moving them to appropriate files --- src/addresses.h | 4 ++ src/audio.c | 22 +++++++++ src/audio.h | 2 + src/editor.c | 98 ++++------------------------------------ src/editor.h | 5 -- src/finance.c | 37 +++++++++++++++ src/finance.h | 1 + src/game.c | 12 ++--- src/park.c | 15 ++++++ src/park.h | 1 + src/rct2.c | 8 ++-- src/strings.c | 10 ++++ src/strings.h | 1 + src/title.c | 9 ++-- src/window.c | 24 ++++++++++ src/window.h | 3 ++ src/window_save_prompt.c | 5 +- 17 files changed, 147 insertions(+), 110 deletions(-) diff --git a/src/addresses.h b/src/addresses.h index a453f9c7bd..0182a37ad5 100644 --- a/src/addresses.h +++ b/src/addresses.h @@ -215,6 +215,10 @@ #define RCT2_ADDRESS_NEW_WINDOW_PTR 0x014234B8 #define RCT2_ADDRESS_VIEWPORT_LIST 0x014234BC #define RCT2_ADDRESS_NEW_VIEWPORT_PTR 0x01423570 +#define RCT2_ADDRESS_WINDOW_GUEST_LIST_SELECTED_FILTER 0x00F1EE06 +#define RCT2_ADDRESS_WINDOW_GUEST_LIST_SELECTED_TAB 0x00F1EE12 +#define RCT2_ADDRESS_WINDOW_GUEST_LIST_SELECTED_VIEW 0x00F1EE13 + #define RCT2_ADDRESS_OS_TIME_MINUTE 0x01424654 #define RCT2_ADDRESS_OS_TIME_HOUR 0x01424656 diff --git a/src/audio.c b/src/audio.c index 468ff26d08..20925d1a25 100644 --- a/src/audio.c +++ b/src/audio.c @@ -20,6 +20,7 @@ #include "audio.h" #include "addresses.h" +#include "rct2.h" void get_dsound_devices() { @@ -45,3 +46,24 @@ void sound_stop(rct_sound* sound) { RCT2_CALLPROC_1(0x00404DD8, rct_sound*, sound); } + +/** +* +* rct2: 0x006BABB4 +*/ +void pause_sounds() { + if (++RCT2_GLOBAL(0x009AF59C, uint8) == 1) { + RCT2_CALLPROC_EBPSAFE(0x006BCAE5); + RCT2_CALLPROC_EBPSAFE(0x006BABDF); + RCT2_CALLPROC_EBPSAFE(0x006BCA9F); + RCT2_CALLPROC_EBPSAFE(0x006BD07F); + } +} + +/** +* +* rct2: 0x006BABD8 +*/ +void unpause_sounds() { + RCT2_GLOBAL(0x009AF59C, uint8)--; +} \ No newline at end of file diff --git a/src/audio.h b/src/audio.h index bb82236c96..2f5f9981ae 100644 --- a/src/audio.h +++ b/src/audio.h @@ -48,6 +48,8 @@ int sound_prepare(int sound_id, rct_sound *sound, int var_8, int var_c); void sound_play_panned(int sound_id, int x); int sound_play(rct_sound* sound, int looping, int volume, int pan, int frequency); void sound_stop(rct_sound *sound); +void pause_sounds(); +void unpause_sounds(); typedef enum { RCT2_SOUND_SCREAM = 11, diff --git a/src/editor.c b/src/editor.c index 31e77b4229..766bb8da6f 100644 --- a/src/editor.c +++ b/src/editor.c @@ -29,6 +29,9 @@ #include "ride.h" #include "window.h" #include "viewport.h" +#include "finance.h" +#include "audio.h" +#include "strings.h" static void set_all_land_owned(); @@ -49,12 +52,12 @@ void editor_load() reset_saved_strings(); RCT2_CALLPROC_EBPSAFE(0x0069EB13); // sprites_init ride_init_all(); - RCT2_CALLPROC_EBPSAFE(0x0068F083); // window_guest_list_init_vars_a + window_guest_list_init_vars_a(); RCT2_CALLPROC_EBPSAFE(0x006BD3A4); park_init(); finance_init(); date_reset(); - RCT2_CALLPROC_EBPSAFE(0x0068F050); // window_guest_list_init_vars_b + window_guest_list_init_vars_b(); RCT2_CALLPROC_EBPSAFE(0x006BD39C); RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) = SCREEN_FLAGS_SCENARIO_EDITOR; RCT2_GLOBAL(0x0141F570, uint8) = 0; @@ -98,12 +101,12 @@ void trackdesigner_load() reset_saved_strings(); RCT2_CALLPROC_EBPSAFE(0x0069EB13); // reset_sprites ride_init_all(); - RCT2_CALLPROC_EBPSAFE(0x0068F083); // window_guest_list_init_vars_a + window_guest_list_init_vars_a(); RCT2_CALLPROC_EBPSAFE(0x006BD3A4); park_init(); finance_init(); date_reset(); - RCT2_CALLPROC_EBPSAFE(0x0068F050); // window_guest_list_init_vars_b + window_guest_list_init_vars_b(); RCT2_CALLPROC_EBPSAFE(0x006BD39C); RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) = SCREEN_FLAGS_TRACK_DESIGNER; RCT2_GLOBAL(0x0141F570, uint8) = 0; @@ -136,12 +139,12 @@ void trackmanager_load() reset_saved_strings(); RCT2_CALLPROC_EBPSAFE(0x0069EB13); // reset_sprites ride_init_all(); - RCT2_CALLPROC_EBPSAFE(0x0068F083); // window_guest_list_init_vars_a + window_guest_list_init_vars_a(); RCT2_CALLPROC_EBPSAFE(0x006BD3A4); park_init(); finance_init(); date_reset(); - RCT2_CALLPROC_EBPSAFE(0x0068F050); // window_guest_list_init_vars_b + window_guest_list_init_vars_b(); RCT2_CALLPROC_EBPSAFE(0x006BD39C); RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) = SCREEN_FLAGS_TRACK_MANAGER; RCT2_GLOBAL(0x0141F570, uint8) = 0; @@ -167,87 +170,4 @@ static void set_all_land_owned() int mapSize = RCT2_GLOBAL(RCT2_ADDRESS_MAP_SIZE, sint16); game_do_command(64, 1, 64, 2, 56, (mapSize - 2) * 32, (mapSize - 2) * 32); -} - -/** -* -* rct2: 0x00667104 -*/ -void reset_park_entrances() { - RCT2_GLOBAL(0x013573D4, uint16) = 0; - - for (short i = 0; i < 4; i++) { - RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_X, uint16)[i] = 0x8000; - } - - RCT2_GLOBAL(0x013573F2, uint16) = 0xFFFF; - RCT2_GLOBAL(0x013573F8, uint16) = 0xFFFF; -} - -/** -* -* rct2: 0x006C4209 -*/ -void reset_saved_strings() { - for (int i = 0; i < 1024; i++) { - RCT2_ADDRESS(0x135A8F4, uint8)[i * 32] = 0; - } -} - -/** -* -* rct2: 0x006BABB4 -*/ -void pause_sounds() { - if (++RCT2_GLOBAL(0x009AF59C, uint8) == 1) { - RCT2_CALLPROC_EBPSAFE(0x006BCAE5); - RCT2_CALLPROC_EBPSAFE(0x006BABDF); - RCT2_CALLPROC_EBPSAFE(0x006BCA9F); - RCT2_CALLPROC_EBPSAFE(0x006BD07F); - } -} - -/** -* -* rct2: 0x006BABD8 -*/ -void unpause_sounds() { - RCT2_GLOBAL(0x009AF59C, uint8)--; -} - -/** -* -* rct2: 0x0069DEFB -*/ -void finance_init() { - - for (short i = 0; i < 56; i++) { - RCT2_ADDRESS(0x01357848, uint32)[i] = 0; - } - - RCT2_GLOBAL(0x0135832C, uint32) = 0; - - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PROFIT, uint32) = 0; - - RCT2_GLOBAL(0x01358334, uint32) = 0; - RCT2_GLOBAL(0x01358338, uint16) = 0; - - RCT2_GLOBAL(0x013573DC, uint32) = 100000; - - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONEY_ENCRYPTED, sint32) = ENCRYPT_MONEY(100000); - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_LOAN, sint32) = 100000; - RCT2_GLOBAL(RCT2_ADDRESS_MAXIMUM_LOAN, uint32) = 200000; - - RCT2_GLOBAL(0x013587D0, uint32) = 0; - - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_INTEREST_RATE, uint8) = 10; - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PARK_VALUE, sint32) = 0; - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_COMPANY_VALUE, sint32) = 0; - RCT2_GLOBAL(RCT2_ADDRESS_COMPLETED_COMPANY_VALUE, sint32) = 0x80000000; - RCT2_GLOBAL(RCT2_ADDRESS_TOTAL_ADMISSIONS, uint32) = 0; - RCT2_GLOBAL(RCT2_ADDRESS_INCOME_FROM_ADMISSIONS, uint32) = 0; - - RCT2_GLOBAL(0x013587D8, uint16) = 0x3F; - - RCT2_CALLPROC_EBPSAFE(0x0069E869); } \ No newline at end of file diff --git a/src/editor.h b/src/editor.h index d350e8a24f..34a7ef5ab3 100644 --- a/src/editor.h +++ b/src/editor.h @@ -25,10 +25,5 @@ void editor_load(); void editor_convert_save_to_scenario(); void trackdesigner_load(); void trackmanager_load(); -void reset_park_entrances(); -void reset_saved_strings(); -void pause_sounds(); -void unpause_sounds(); -void finance_init(); #endif diff --git a/src/finance.c b/src/finance.c index 37c4a14d60..b011b4ccec 100644 --- a/src/finance.c +++ b/src/finance.c @@ -101,3 +101,40 @@ void finance_pay_interest() finance_payment((sint32)tempcost, RCT_EXPENDITURE_TYPE_INTEREST); } + +/** +* +* rct2: 0x0069DEFB +*/ +void finance_init() { + + for (short i = 0; i < 56; i++) { + RCT2_ADDRESS(0x01357848, uint32)[i] = 0; + } + + RCT2_GLOBAL(0x0135832C, uint32) = 0; + + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PROFIT, uint32) = 0; + + RCT2_GLOBAL(0x01358334, uint32) = 0; + RCT2_GLOBAL(0x01358338, uint16) = 0; + + RCT2_GLOBAL(0x013573DC, uint32) = 100000; + + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONEY_ENCRYPTED, sint32) = ENCRYPT_MONEY(100000); + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_LOAN, sint32) = 100000; + RCT2_GLOBAL(RCT2_ADDRESS_MAXIMUM_LOAN, uint32) = 200000; + + RCT2_GLOBAL(0x013587D0, uint32) = 0; + + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_INTEREST_RATE, uint8) = 10; + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PARK_VALUE, sint32) = 0; + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_COMPANY_VALUE, sint32) = 0; + RCT2_GLOBAL(RCT2_ADDRESS_COMPLETED_COMPANY_VALUE, sint32) = 0x80000000; + RCT2_GLOBAL(RCT2_ADDRESS_TOTAL_ADMISSIONS, uint32) = 0; + RCT2_GLOBAL(RCT2_ADDRESS_INCOME_FROM_ADMISSIONS, uint32) = 0; + + RCT2_GLOBAL(0x013587D8, uint16) = 0x3F; + + RCT2_CALLPROC_EBPSAFE(0x0069E869); +} \ No newline at end of file diff --git a/src/finance.h b/src/finance.h index 6c8d75fdfa..4a81abe34f 100644 --- a/src/finance.h +++ b/src/finance.h @@ -36,5 +36,6 @@ void finance_payment(int amount, rct_expenditure_type type); void finance_pay_wages(); void finance_pay_research(); void finance_pay_interest(); +void finance_init(); #endif \ No newline at end of file diff --git a/src/game.c b/src/game.c index c20491046e..a68cd91245 100644 --- a/src/game.c +++ b/src/game.c @@ -1097,9 +1097,9 @@ static void game_pause_toggle() RCT2_GLOBAL(0x009DEA6E, uint32) ^= 1; window_invalidate_by_id(WC_TOP_TOOLBAR, 0); if (RCT2_GLOBAL(0x009DEA6E, uint32) & 1) - RCT2_CALLPROC_EBPSAFE(0x006BABB4); // pause_sounds + pause_sounds(); else - RCT2_CALLPROC_EBPSAFE(0x006BABD8); // unpause_sounds + unpause_sounds(); } __asm mov ebx, 0 @@ -1147,9 +1147,9 @@ static int open_landscape_file_dialog() format_string(0x0141ED68, STR_LOAD_LANDSCAPE_DIALOG_TITLE, 0); strcpy(0x0141EF68, RCT2_ADDRESS_LANDSCAPES_PATH); format_string(0x0141EE68, STR_RCT2_LANDSCAPE_FILE, 0); - RCT2_CALLPROC_EBPSAFE(0x006BABB4); // pause_sounds + pause_sounds(); osinterface_open_common_file_dialog(1, 0x0141ED68, 0x0141EF68, "*.SV6;*.SV4;*.SC6", 0x0141EE68); - RCT2_CALLPROC_EBPSAFE(0x006BABD8); // unpause_sounds + unpause_sounds(); // window_proc } @@ -1162,9 +1162,9 @@ static int open_load_game_dialog() format_string(0x0141ED68, STR_LOAD_GAME_DIALOG_TITLE, 0); strcpy(0x0141EF68, RCT2_ADDRESS_SAVED_GAMES_PATH); format_string(0x0141EE68, STR_RCT2_SAVED_GAME, 0); - RCT2_CALLPROC_EBPSAFE(0x006BABB4); // pause_sounds + pause_sounds(); osinterface_open_common_file_dialog(1, 0x0141ED68, 0x0141EF68, "*.SV6", 0x0141EE68); - RCT2_CALLPROC_EBPSAFE(0x006BABD8); // unpause_sounds + unpause_sounds(); // window_proc } diff --git a/src/park.c b/src/park.c index a8f5a90f37..7edfe1679b 100644 --- a/src/park.c +++ b/src/park.c @@ -273,3 +273,18 @@ int calculate_company_value() return result; } + +/** +* +* rct2: 0x00667104 +*/ +void reset_park_entrances() { + RCT2_GLOBAL(0x013573D4, uint16) = 0; + + for (short i = 0; i < 4; i++) { + RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_X, uint16)[i] = 0x8000; + } + + RCT2_GLOBAL(0x013573F2, uint16) = 0xFFFF; + RCT2_GLOBAL(0x013573F8, uint16) = 0xFFFF; +} diff --git a/src/park.h b/src/park.h index 287729ac6f..ee91fa5b46 100644 --- a/src/park.h +++ b/src/park.h @@ -74,5 +74,6 @@ int park_calculate_size(); int calculate_park_rating(); int calculate_park_value(); int calculate_company_value(); +void reset_park_entrances(); #endif diff --git a/src/rct2.c b/src/rct2.c index 25b51bc217..24ea502be0 100644 --- a/src/rct2.c +++ b/src/rct2.c @@ -123,11 +123,11 @@ void rct2_init() viewport_init_all(); news_item_init_queue(); get_local_time(); - RCT2_CALLPROC_EBPSAFE(0x00667104); - RCT2_CALLPROC_EBPSAFE(0x006C4209); + reset_park_entrances(); + reset_saved_strings(); RCT2_CALLPROC_EBPSAFE(0x0069EB13); ride_init_all(); - RCT2_CALLPROC_EBPSAFE(0x0068F083); // window guest list init vars a + window_guest_list_init_vars_a(); RCT2_CALLPROC_EBPSAFE(0x006BD3A4); map_init(); park_init(); @@ -136,7 +136,7 @@ void rct2_init() climate_reset(CLIMATE_COOL_AND_WET); RCT2_CALLPROC_EBPSAFE(0x006DFEE4); RCT2_CALLPROC_EBPSAFE(0x006ACA58); - RCT2_CALLPROC_EBPSAFE(0x0068F050); // window guest list init vars b + window_guest_list_init_vars_b(); RCT2_CALLPROC_EBPSAFE(0x006BD39C); title_load(); diff --git a/src/strings.c b/src/strings.c index c26db5a171..540e644252 100644 --- a/src/strings.c +++ b/src/strings.c @@ -124,3 +124,13 @@ void generate_string_file() fclose(f); } + +/** +* +* rct2: 0x006C4209 +*/ +void reset_saved_strings() { + for (int i = 0; i < 1024; i++) { + RCT2_ADDRESS(0x135A8F4, uint8)[i * 32] = 0; + } +} \ No newline at end of file diff --git a/src/strings.h b/src/strings.h index 3afedf5f26..1e9f80a450 100644 --- a/src/strings.h +++ b/src/strings.h @@ -25,6 +25,7 @@ typedef unsigned short rct_string_id; void format_string(char *dest, rct_string_id format, void *args); void generate_string_file(); +void reset_saved_strings(); enum { FORMAT_TINYFONT = 7, diff --git a/src/title.c b/src/title.c index 17cc541e60..db3b8e7baa 100644 --- a/src/title.c +++ b/src/title.c @@ -34,6 +34,7 @@ #include "scenario.h" #include "strings.h" #include "viewport.h" +#include "editor.h" static const int gOldMusic = 0; static const int gRandomShowcase = 0; @@ -91,11 +92,11 @@ void title_load() RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) = SCREEN_FLAGS_TITLE_DEMO; - RCT2_CALLPROC_EBPSAFE(0x00667104); - RCT2_CALLPROC_EBPSAFE(0x006C4209); + reset_park_entrances(); + reset_saved_strings(); RCT2_CALLPROC_EBPSAFE(0x0069EB13); ride_init_all(); - RCT2_CALLPROC_EBPSAFE(0x0068F083); // window_guest_list_init_vars_a + window_guest_list_init_vars_a(); RCT2_CALLPROC_EBPSAFE(0x006BD3A4); map_init(); park_init(); @@ -103,7 +104,7 @@ void title_load() RCT2_CALLPROC_X(0x006C45ED, 0, 0, 0, 0, 0, 0, 0); RCT2_CALLPROC_EBPSAFE(0x006DFEE4); RCT2_CALLPROC_EBPSAFE(0x006ACA58); - RCT2_CALLPROC_EBPSAFE(0x0068F050); // window_guest_list_init_vars_b + window_guest_list_init_vars_b(); RCT2_CALLPROC_EBPSAFE(0x006BD39C); RCT2_CALLPROC_EBPSAFE(0x0068AFFD); RCT2_CALLPROC_EBPSAFE(0x0069EBE4); diff --git a/src/window.c b/src/window.c index a1644e98c8..0a7f726040 100644 --- a/src/window.c +++ b/src/window.c @@ -1179,4 +1179,28 @@ void tool_cancel() RCT2_CALLPROC_X(w->event_handlers[WE_TOOL_ABORT], 0, 0, 0, RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WIDGETINDEX, uint16), w, 0, 0); } } +} + +/** +* +* rct2: 0x0068F083 +*/ +void window_guest_list_init_vars_a() { + RCT2_GLOBAL(0x013B0E6C, uint32) = 1; + RCT2_GLOBAL(0x00F1AF1C, uint32) = 0xFFFFFFFF; + RCT2_GLOBAL(0x00F1EE02, uint32) = 0xFFFFFFFF; + RCT2_GLOBAL(RCT2_ADDRESS_WINDOW_GUEST_LIST_SELECTED_FILTER, uint8) = 0xFF; +} + +/** +* +* rct2: 0x0068F050 +*/ +void window_guest_list_init_vars_b() { + RCT2_GLOBAL(RCT2_ADDRESS_WINDOW_GUEST_LIST_SELECTED_TAB, uint8) = 0; + RCT2_GLOBAL(RCT2_ADDRESS_WINDOW_GUEST_LIST_SELECTED_VIEW, uint8) = 0; + RCT2_GLOBAL(0x00F1AF1C, uint32) = 0xFFFFFFFF; + RCT2_GLOBAL(0x00F1EE02, uint32) = 0xFFFFFFFF; + RCT2_GLOBAL(RCT2_ADDRESS_WINDOW_GUEST_LIST_SELECTED_FILTER, uint8) = 0xFF; + RCT2_GLOBAL(0x00F1AF20, uint16) = 0; } \ No newline at end of file diff --git a/src/window.h b/src/window.h index c5d432e2ef..1aefaf65e4 100644 --- a/src/window.h +++ b/src/window.h @@ -347,4 +347,7 @@ void window_park_objective_open(); void window_ride_list_open(); void window_cheats_open(); +void window_guest_list_init_vars_a(); +void window_guest_list_init_vars_b(); + #endif diff --git a/src/window_save_prompt.c b/src/window_save_prompt.c index 35c95a7797..3978cc1154 100644 --- a/src/window_save_prompt.c +++ b/src/window_save_prompt.c @@ -26,6 +26,7 @@ #include "tutorial.h" #include "widget.h" #include "window.h" +#include "audio.h" static enum WINDOW_SAVE_PROMPT_WIDGET_IDX { WIDX_BACKGROUND, @@ -118,7 +119,7 @@ void window_save_prompt_open() // Pause the game RCT2_GLOBAL(0x009DEA6E, uint8) |= 2; - RCT2_CALLPROC_EBPSAFE(0x006BABB4); + pause_sounds(); window_invalidate_by_id(0x80 | WC_TOP_TOOLBAR, 0); } @@ -161,7 +162,7 @@ static void window_save_prompt_close() { // Unpause the game RCT2_GLOBAL(0x009DEA6E, uint8) &= ~2; - RCT2_CALLPROC_EBPSAFE(0x006BABD8); + unpause_sounds(); window_invalidate_by_id(0x80 | WC_TOP_TOOLBAR, 0); } From 169a3b6b72dd2368c1929377764921cba6340a10 Mon Sep 17 00:00:00 2001 From: lnz Date: Wed, 7 May 2014 16:24:36 +0200 Subject: [PATCH 36/44] Implement Peep problem warnings update. --- src/addresses.h | 2 + src/peep.c | 131 ++++++++++++++++++++++++++++++++++++++++++++++++ src/peep.h | 15 +++++- src/scenario.c | 2 +- src/strings.h | 8 +++ 5 files changed, 156 insertions(+), 2 deletions(-) diff --git a/src/addresses.h b/src/addresses.h index a453f9c7bd..571613eb3f 100644 --- a/src/addresses.h +++ b/src/addresses.h @@ -178,6 +178,8 @@ #define RCT2_ADDRESS_CURRENT_TICKS 0x013628F4 #define RCT2_ADDRESS_RIDE_LIST 0x013628F8 +#define RCT2_ADDRESS_RIDE_COUNT 0x013587C8 +#define RCT2_ADDRESS_RIDE_FLAGS 0x0097CF40 #define RCT2_ADDRESS_SAVED_VIEW_X 0x0138869A #define RCT2_ADDRESS_SAVED_VIEW_Y 0x0138869C #define RCT2_ADDRESS_RIDE_MEASUREMENTS 0x0138B60C diff --git a/src/peep.c b/src/peep.c index 0a16060ca2..194c255704 100644 --- a/src/peep.c +++ b/src/peep.c @@ -19,8 +19,10 @@ *****************************************************************************/ #include "addresses.h" +#include "news_item.h" #include "peep.h" #include "rct2.h" +#include "ride.h" #include "sprite.h" int peep_get_staff_count() @@ -71,3 +73,132 @@ void peep_update_all() i++; } } + + +/** + * + * rct2: 0x0069BF41 + **/ +void peep_problem_warnings_update() +{ + rct_peep* peep; + rct_ride* ride; + uint16 sprite_idx; + uint16 guests_in_park = RCT2_GLOBAL(RCT2_ADDRESS_GUESTS_IN_PARK, uint16); + int hunger_counter = 0, lost_counter = 0, noexit_counter = 0, thirst_counter = 0, + litter_counter = 0, disgust_counter = 0, bathroom_counter = 0 ,vandalism_counter = 0; + static int warning_throttle[6] = { 0, 0, 0, 0, 0, 0 }; + + RCT2_GLOBAL(RCT2_ADDRESS_RIDE_COUNT, sint16) = ride_get_count(); // refactor this to somewhere else + + + for (sprite_idx = RCT2_GLOBAL(RCT2_ADDRESS_SPRITES_START_PEEP, uint16); sprite_idx != SPRITE_INDEX_NULL; sprite_idx = peep->next) { + peep = &(RCT2_ADDRESS(RCT2_ADDRESS_SPRITE_LIST, rct_sprite)[sprite_idx].peep); + + if (peep->type != PEEP_TYPE_GUEST || peep->var_2A != 0 || peep->thoughts[0].pad_3 > 5) + continue; + + switch (peep->thoughts[0].type) { + case PEEP_THOUGHT_TYPE_LOST: //0x10 + lost_counter++; + break; + + case PEEP_THOUGHT_TYPE_HUNGRY: // 0x14 + if (peep->var_C5 == -1){ + hunger_counter++; + break; + } + ride = &RCT2_ADDRESS(RCT2_ADDRESS_RIDE_LIST, rct_ride)[peep->var_C5]; + if (!(RCT2_GLOBAL(RCT2_ADDRESS_RIDE_FLAGS + ride->type * 8, uint32) & 0x80000)) + hunger_counter++; + break; + + case PEEP_THOUGHT_TYPE_THIRSTY: + if (peep->var_C5 == -1){ + thirst_counter++; + break; + } + ride = &RCT2_ADDRESS(RCT2_ADDRESS_RIDE_LIST, rct_ride)[peep->var_C5]; + if (!(RCT2_GLOBAL(RCT2_ADDRESS_RIDE_FLAGS + ride->type * 8, uint32) & 0x1000000)) + thirst_counter++; + break; + + case PEEP_THOUGHT_TYPE_BATHROOM: + if (peep->var_C5 == -1){ + bathroom_counter++; + break; + } + ride = &RCT2_ADDRESS(RCT2_ADDRESS_RIDE_LIST, rct_ride)[peep->var_C5]; + if (!(RCT2_GLOBAL(RCT2_ADDRESS_RIDE_FLAGS + ride->type * 8, uint32) & 0x2000000)) + bathroom_counter++; + break; + + case PEEP_THOUGHT_TYPE_BAD_LITTER: // 0x1a + litter_counter++; + break; + case PEEP_THOUGHT_TYPE_CANT_FIND_EXIT: // 0x1b + noexit_counter++; + break; + case PEEP_THOUGHT_TYPE_PATH_DISGUSTING: // 0x1f + disgust_counter++; + break; + case PEEP_THOUGHT_TYPE_VANDALISM: //0x21 + vandalism_counter++; + break; + default: + break; + } + } + // could maybe be packed into a loop, would lose a lot of clarity though + if (warning_throttle[0]) + --warning_throttle[0]; + else if ( hunger_counter >= PEEP_HUNGER_WARNING_THRESHOLD && hunger_counter >= guests_in_park / 16) { + warning_throttle[0] = 4; + news_item_add_to_queue(NEWS_ITEM_PEEPS, STR_PEEPS_ARE_HUNGRY, 20); + } + + if (warning_throttle[1]) + --warning_throttle[1]; + else if (thirst_counter >= PEEP_THIRST_WARNING_THRESHOLD && thirst_counter >= guests_in_park / 16) { + warning_throttle[1] = 4; + news_item_add_to_queue(NEWS_ITEM_PEEPS, STR_PEEPS_ARE_THIRSTY, 21); + } + + if (warning_throttle[2]) + --warning_throttle[2]; + else if (bathroom_counter >= PEEP_BATHROOM_WARNING_THRESHOLD && bathroom_counter >= guests_in_park / 16) { + warning_throttle[2] = 4; + news_item_add_to_queue(NEWS_ITEM_PEEPS, STR_PEEPS_CANT_FIND_BATHROOM, 22); + } + + if (warning_throttle[3]) + --warning_throttle[3]; + else if (litter_counter >= PEEP_LITTER_WARNING_THRESHOLD && litter_counter >= guests_in_park / 32) { + warning_throttle[3] = 4; + news_item_add_to_queue(NEWS_ITEM_PEEPS, STR_PEEPS_DISLIKE_LITTER, 26); + } + + if (warning_throttle[4]) + --warning_throttle[4]; + else if (disgust_counter >= PEEP_DISGUST_WARNING_THRESHOLD && disgust_counter >= guests_in_park / 32) { + warning_throttle[4] = 4; + news_item_add_to_queue(NEWS_ITEM_PEEPS, STR_PEEPS_DISGUSTED_BY_PATHS, 31); + } + + if (warning_throttle[5]) + --warning_throttle[5]; + else if (vandalism_counter >= PEEP_VANDALISM_WARNING_THRESHOLD && vandalism_counter >= guests_in_park / 32) { + warning_throttle[5] = 4; + news_item_add_to_queue(NEWS_ITEM_PEEPS, STR_PEEPS_DISLIKE_VANDALISM, 33); + } + + if (warning_throttle[6]) + --warning_throttle[6]; + else if (noexit_counter >= PEEP_NOEXIT_WARNING_THRESHOLD) { + warning_throttle[6] = 4; + news_item_add_to_queue(NEWS_ITEM_PEEPS, STR_PEEPS_GETTING_LOST_OR_STUCK, 27); + } else if (lost_counter >= PEEP_LOST_WARNING_THRESHOLD) { + warning_throttle[6] = 4; + news_item_add_to_queue(NEWS_ITEM_PEEPS, STR_PEEPS_GETTING_LOST_OR_STUCK, 16); + } +} diff --git a/src/peep.h b/src/peep.h index fb5b009194..0b54db7988 100644 --- a/src/peep.h +++ b/src/peep.h @@ -25,6 +25,17 @@ #define PEEP_MAX_THOUGHTS 5 +#define PEEP_HUNGER_WARNING_THRESHOLD 25 +#define PEEP_THIRST_WARNING_THRESHOLD 25 +#define PEEP_BATHROOM_WARNING_THRESHOLD 28 +#define PEEP_LITTER_WARNING_THRESHOLD 23 +#define PEEP_DISGUST_WARNING_THRESHOLD 22 +#define PEEP_VANDALISM_WARNING_THRESHOLD 15 +#define PEEP_NOEXIT_WARNING_THRESHOLD 8 +#define PEEP_LOST_WARNING_THRESHOLD 8 + + + enum PEEP_TYPE { PEEP_TYPE_GUEST, PEEP_TYPE_STAFF @@ -363,7 +374,8 @@ typedef struct { sint32 time_in_park; // 0xA9 uint8 pad_AD[0x3]; rct_peep_thought thoughts[PEEP_MAX_THOUGHTS]; // 0xB0 - uint16 pad_C4; + uint8 pad_C4; + uint8 var_C5; uint8 var_C6; uint8 photo1_ride_ref; // 0xC7 uint32 flags; // 0xC8 @@ -387,5 +399,6 @@ typedef struct { int peep_get_staff_count(); void peep_update_all(); +void peep_problem_warnings_update(); #endif diff --git a/src/scenario.c b/src/scenario.c index b283c9e767..db4ee7bd54 100644 --- a/src/scenario.c +++ b/src/scenario.c @@ -873,7 +873,7 @@ void scenario_update() finance_pay_research(); finance_pay_interest(); scenario_marketing_update(); - RCT2_CALLPROC_EBPSAFE(0x0069BF41); // peep needs update and warnings + peep_problem_warnings_update(); RCT2_CALLPROC_EBPSAFE(0x006B7A5E); // check ride reachability RCT2_CALLPROC_EBPSAFE(0x006AC916); // ride update favourited diff --git a/src/strings.h b/src/strings.h index 232d0b4068..83bb0feae4 100644 --- a/src/strings.h +++ b/src/strings.h @@ -415,6 +415,14 @@ enum { STR_SHOW_GUESTS_ON_MAP_TIP = 2803, STR_SHOW_MAP_TIP = 2805, + STR_PEEPS_DISGUSTED_BY_PATHS = 2806, + STR_PEEPS_DISLIKE_LITTER = 2807, + STR_PEEPS_DISLIKE_VANDALISM = 2808, + STR_PEEPS_ARE_HUNGRY = 2809, + STR_PEEPS_ARE_THIRSTY = 2810, + STR_PEEPS_CANT_FIND_BATHROOM = 2811, + STR_PEEPS_GETTING_LOST_OR_STUCK = 2812, + STR_ENTRANCE_FEE_TOO_HI = 2813, STR_AWARD_MOST_UNTIDY = 2814, From 840c76b68e3c18923ecaa15b8382dfe011a4363b Mon Sep 17 00:00:00 2001 From: lnz Date: Wed, 7 May 2014 16:28:42 +0200 Subject: [PATCH 37/44] Fix month not changing bug and wage cost bug. --- src/finance.c | 6 +++--- src/scenario.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/finance.c b/src/finance.c index 37c4a14d60..2f6130d8be 100644 --- a/src/finance.c +++ b/src/finance.c @@ -25,9 +25,9 @@ #include "peep.h" #include "window.h" - +// monthly cost const int wage_table[4] = { 500, 800, 600, 550 }; -const int research_cost_table[4] = { 0, 1000, 2000, 4000 }; // monthly cost +const int research_cost_table[4] = { 0, 1000, 2000, 4000 }; /** * @@ -67,7 +67,7 @@ void finance_pay_wages() for (sprite_idx = RCT2_GLOBAL(RCT2_ADDRESS_SPRITES_START_PEEP, uint16); sprite_idx != SPRITE_INDEX_NULL; sprite_idx = peep->next) { peep = &(RCT2_ADDRESS(RCT2_ADDRESS_SPRITE_LIST, rct_sprite)[sprite_idx].peep); if (peep->type == PEEP_TYPE_STAFF) - finance_payment(wage_table[peep->staff_type], RCT_EXPENDITURE_TYPE_WAGES); + finance_payment(wage_table[peep->staff_type] / 4, RCT_EXPENDITURE_TYPE_WAGES); } } diff --git a/src/scenario.c b/src/scenario.c index db4ee7bd54..40733fac15 100644 --- a/src/scenario.c +++ b/src/scenario.c @@ -898,7 +898,7 @@ void scenario_update() } RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_TICKS, uint16) = next_month_tick; - if (next_month_tick > 0x10000) { + if (next_month_tick >= 0x10000) { // month ends actions RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, sint16)++; RCT2_GLOBAL(0x009A9804, uint32) |= 2; From 8ddfc136f6affc0e44220906def2790422791fa0 Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Wed, 7 May 2014 18:57:50 +0100 Subject: [PATCH 38/44] Fixed bug in second ride related equations --- src/park.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/park.c b/src/park.c index 6fcc3bbbb7..e10c0a06fb 100644 --- a/src/park.c +++ b/src/park.c @@ -98,7 +98,6 @@ int calculate_park_rating() // -150 to +3 based on a range of guests from 0 to 2000 result -= 150 - (min(2000, RCT2_GLOBAL(RCT2_ADDRESS_GUESTS_IN_PARK, uint16)) / 13); - //return result; //1016 good // Guests, happiness, ? @@ -173,7 +172,7 @@ int calculate_park_rating() result -= 200 - ((_ax + _bx) / 10); } //826 - + // Litter { rct_litter* litter; @@ -215,13 +214,15 @@ int calculate_park_rating() result -= 100; if (num_rides > 0) { + short temp_bx; + temp_bx = _bx; _bx = _ax / num_rides; - _ax = _bx / num_rides; + _ax = temp_bx / num_rides; _bx -= 46; - if (_bx >= 0) + if (_bx < 0) _bx = -_bx; _ax -= 65; - if (_ax >= 0) + if (_ax < 0) _ax = -_ax; _bx /= 2; _ax /= 2; From 4e4fa93e14b6f669950ce99c9bca36e4c2260291 Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Wed, 7 May 2014 19:44:13 +0100 Subject: [PATCH 39/44] Fixed litter bug. Removed debug notes. Made rides code more readable --- src/park.c | 108 +++++++++++++++++------------------------------------ 1 file changed, 34 insertions(+), 74 deletions(-) diff --git a/src/park.c b/src/park.c index e10c0a06fb..5b11ee4024 100644 --- a/src/park.c +++ b/src/park.c @@ -76,13 +76,6 @@ int park_calculate_size() */ int calculate_park_rating() { - { - int eax, ebx, ecx, edx, esi, edi, ebp; - //RCT2_CALLFUNC_X(0x00669EAA, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); - //return eax & 0xFFFF; - } - - int result; result = 1150; @@ -98,7 +91,6 @@ int calculate_park_rating() // -150 to +3 based on a range of guests from 0 to 2000 result -= 150 - (min(2000, RCT2_GLOBAL(RCT2_ADDRESS_GUESTS_IN_PARK, uint16)) / 13); - //1016 good // Guests, happiness, ? num_happy_peeps = 0; @@ -119,7 +111,6 @@ int calculate_park_rating() // Peep happiness -500 to +0 result -= 500; - //516 good if (RCT2_GLOBAL(RCT2_ADDRESS_GUESTS_IN_PARK, uint16) > 0) result += 2 * min(250, (num_happy_peeps * 300) / RCT2_GLOBAL(RCT2_ADDRESS_GUESTS_IN_PARK, uint16)); @@ -130,13 +121,11 @@ int calculate_park_rating() result -= _bp * 7; } - //998 good - // Rides { int i; - short _ax, _bx; - int num_rides; + short _ax, total_ride_intensity = 0, total_ride_excitement = 0, average_intensity, average_excitement; + int num_rides, num_exciting_rides = 0; rct_ride* ride; // @@ -148,31 +137,44 @@ int calculate_park_rating() if (ride->type == RIDE_TYPE_NULL) continue; _ax += 100 - ride->var_199; + + if (ride->excitement != -1){ + total_ride_excitement += ride->excitement / 8; + total_ride_intensity += ride->intensity / 8; + num_exciting_rides++; + } num_rides++; } result -= 200; if (num_rides > 0) result += (_ax / num_rides) * 2; - // - _ax = 0; - _bx = 0; - for (i = 0; i < 255; i++) { - ride = &(RCT2_ADDRESS(RCT2_ADDRESS_RIDE_LIST, rct_ride)[i]); + result -= 100; - if (ride->type == RIDE_TYPE_NULL) - continue; - if (ride->excitement == -1) - continue; - _ax += ride->excitement / 8; - _bx += ride->intensity / 8; + if (num_exciting_rides>0){ + average_excitement = total_ride_excitement / num_exciting_rides; + average_intensity = total_ride_intensity / num_exciting_rides; + + average_excitement -= 46; + if (average_excitement < 0){ + average_excitement = -average_excitement; + } + + average_intensity -= 65; + if (average_intensity < 0){ + average_intensity = -average_intensity; + } + + average_excitement = min(average_excitement / 2, 50); + average_intensity = min(average_intensity / 2, 50); + result += 100 - average_excitement - average_intensity; } - _ax = min(1000, _ax); - _bx = min(1000, _bx); - result -= 200 - ((_ax + _bx) / 10); + + total_ride_excitement = min(1000, total_ride_excitement); + total_ride_intensity = min(1000, total_ride_intensity); + result -= 200 - ((total_ride_excitement + total_ride_intensity) / 10); } - //826 - + // Litter { rct_litter* litter; @@ -184,57 +186,15 @@ int calculate_park_rating() litter = &(RCT2_ADDRESS(RCT2_ADDRESS_SPRITE_LIST, rct_sprite)[sprite_idx].litter); // Guessing this eliminates recently dropped litter - if (litter->var_24 - RCT2_GLOBAL(0x00F663AC, sint32) >= 7680) + if ((uint32)(litter->var_24 - RCT2_GLOBAL(0x00F663AC, sint32)) >= 7680) num_litter++; } result -= 600 - (4 * (150 - min(150, num_litter))); } - //826 - - // Rides - { - int i, num_rides; - short _ax, _bx; - rct_ride* ride; - - num_rides = 0; - _ax = 0; - _bx = 0; - for (i = 0; i < 255; i++) { - ride = &(RCT2_ADDRESS(RCT2_ADDRESS_RIDE_LIST, rct_ride)[i]); - - if (ride->type == RIDE_TYPE_NULL) - continue; - if (ride->excitement == -1) - continue; - _ax += ride->excitement / 8; - _bx += ride->intensity / 8; - num_rides++; - } - - result -= 100; - if (num_rides > 0) { - short temp_bx; - temp_bx = _bx; - _bx = _ax / num_rides; - _ax = temp_bx / num_rides; - _bx -= 46; - if (_bx < 0) - _bx = -_bx; - _ax -= 65; - if (_ax < 0) - _ax = -_ax; - _bx /= 2; - _ax /= 2; - _bx = min(50, _bx); - _ax = min(50, _ax); - result += 100 - _ax - _bx; - } - } - //809 + result -= RCT2_GLOBAL(0x0135882E, sint16); result = clamp(0, result, 999); - //809 + //934 return result; } From bfd4dbcbe9ba7e0896a2775af78499f5ed65bea2 Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Wed, 7 May 2014 19:46:30 +0100 Subject: [PATCH 40/44] Changed litter var_24 to unsigned --- src/park.c | 3 +-- src/sprite.h | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/park.c b/src/park.c index 5b11ee4024..54e49521e0 100644 --- a/src/park.c +++ b/src/park.c @@ -186,7 +186,7 @@ int calculate_park_rating() litter = &(RCT2_ADDRESS(RCT2_ADDRESS_SPRITE_LIST, rct_sprite)[sprite_idx].litter); // Guessing this eliminates recently dropped litter - if ((uint32)(litter->var_24 - RCT2_GLOBAL(0x00F663AC, sint32)) >= 7680) + if (litter->var_24 - RCT2_GLOBAL(0x00F663AC, uint32) >= 7680) num_litter++; } result -= 600 - (4 * (150 - min(150, num_litter))); @@ -194,7 +194,6 @@ int calculate_park_rating() result -= RCT2_GLOBAL(0x0135882E, sint16); result = clamp(0, result, 999); - //934 return result; } diff --git a/src/sprite.h b/src/sprite.h index 5a3a071ba0..a51e448c41 100644 --- a/src/sprite.h +++ b/src/sprite.h @@ -43,7 +43,7 @@ typedef struct { uint32 pad_00; uint16 next; // 0x04 uint8 pad_06[0x1E]; - sint32 var_24; + uint32 var_24; } rct_litter; typedef struct { From 15c1213fb5ca0db7198f0d1703daf0e6d182d585 Mon Sep 17 00:00:00 2001 From: ddevrien Date: Wed, 7 May 2014 20:53:33 +0200 Subject: [PATCH 41/44] Identified WWT_6, added some strings WWT_6 is used for signs, it's the color selection button --- src/strings.h | 6 ++++++ src/widget.c | 4 ++-- src/widget.h | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/strings.h b/src/strings.h index 8b10ec152c..1912fd5737 100644 --- a/src/strings.h +++ b/src/strings.h @@ -446,6 +446,12 @@ enum { STR_MUSIC_ACKNOWLEDGEMENTS_ELLIPSIS = 2862, STR_MUSIC_ACKNOWLEDGEMENTS = 2863, + STR_CHANGE_BANNER_TEXT_TIP = 2986, + STR_SET_AS_NO_ENTRY_BANNER_TIP = 2987, + STR_DEMOLISH_BANNER_TIP = 2988, + STR_SELECT_MAIN_COLOR_TIP = 2989, + STR_SELECT_TEXT_COLOR_TIP = 2990, + STR_LICENCE_AGREEMENT_NOTICE_1 = 2969, STR_LICENCE_AGREEMENT_NOTICE_2 = 2970, diff --git a/src/widget.c b/src/widget.c index fe5bcd96cd..c9de92adca 100644 --- a/src/widget.c +++ b/src/widget.c @@ -115,7 +115,7 @@ void widget_draw(rct_drawpixelinfo *dpi, rct_window *w, int widgetIndex) widget_button_draw(dpi, w, widgetIndex); break; case WWT_5: - case WWT_6: + case WWT_COLORBTN: case WWT_TRNBTN: case WWT_TAB: widget_tab_draw(dpi, w, widgetIndex); @@ -861,7 +861,7 @@ static void widget_draw_image(rct_drawpixelinfo *dpi, rct_window *w, int widgetI // Get the colour colour = w->colours[widget->colour]; - if (widget->type == WWT_4 || widget->type == WWT_6 || widget->type == WWT_TRNBTN || widget->type == WWT_TAB) + if (widget->type == WWT_4 || widget->type == WWT_COLORBTN || widget->type == WWT_TRNBTN || widget->type == WWT_TAB) if (widget_is_pressed(w, widgetIndex) || widget_is_active_tool(w, widgetIndex)) image++; diff --git a/src/widget.h b/src/widget.h index ea4eccbf11..477c124a6c 100644 --- a/src/widget.h +++ b/src/widget.h @@ -30,7 +30,7 @@ typedef enum { WWT_IMGBTN = 3, WWT_4 = 4, WWT_5 = 5, - WWT_6 = 6, + WWT_COLORBTN = 6, WWT_TRNBTN = 7, WWT_TAB = 8, WWT_FLATBTN = 9, From c70865457c1b839af250c318702462d069ea77b0 Mon Sep 17 00:00:00 2001 From: Maciek Baron Date: Wed, 7 May 2014 21:16:57 +0100 Subject: [PATCH 42/44] Adding window_ride_init_vars and various enums Adding window_ride_init_vars and various enums, also decompiled one unknown function. --- src/addresses.h | 10 ++++++++-- src/editor.c | 32 +++++++++++++++++++++++--------- src/editor.h | 2 ++ src/finance.c | 4 ++-- src/game.c | 2 +- src/rct2.c | 4 ++-- src/scenario.c | 2 +- src/title.c | 6 +++--- src/window.c | 24 ++++++++++++++++++++++++ src/window.h | 18 ++++++++++++++++++ 10 files changed, 84 insertions(+), 20 deletions(-) diff --git a/src/addresses.h b/src/addresses.h index 0182a37ad5..0a47b592ce 100644 --- a/src/addresses.h +++ b/src/addresses.h @@ -215,10 +215,16 @@ #define RCT2_ADDRESS_NEW_WINDOW_PTR 0x014234B8 #define RCT2_ADDRESS_VIEWPORT_LIST 0x014234BC #define RCT2_ADDRESS_NEW_VIEWPORT_PTR 0x01423570 -#define RCT2_ADDRESS_WINDOW_GUEST_LIST_SELECTED_FILTER 0x00F1EE06 -#define RCT2_ADDRESS_WINDOW_GUEST_LIST_SELECTED_TAB 0x00F1EE12 + +#define RCT2_ADDRESS_WINDOW_GUEST_LIST_SELECTED_FILTER 0x00F1EE06 +#define RCT2_ADDRESS_WINDOW_GUEST_LIST_SELECTED_TAB 0x00F1EE12 #define RCT2_ADDRESS_WINDOW_GUEST_LIST_SELECTED_VIEW 0x00F1EE13 +#define RCT2_ADDRESS_WINDOW_RIDE_LIST_INFORMATION_TYPE 0x00F43833 +#define RCT2_ADDRESS_WINDOW_RIDE_LIST_SELECTED_TAB 0x00F43824 +#define RCT2_ADDRESS_WINDOW_RIDE_LIST_HIGHLIGHTED_ITEM 0x00F43825 + +#define RCT2_ADDRESS_WINDOW_STAFF_LIST_SELECTED_TAB 0x00F4390A #define RCT2_ADDRESS_OS_TIME_MINUTE 0x01424654 #define RCT2_ADDRESS_OS_TIME_HOUR 0x01424656 diff --git a/src/editor.c b/src/editor.c index 766bb8da6f..9f07f326af 100644 --- a/src/editor.c +++ b/src/editor.c @@ -53,16 +53,16 @@ void editor_load() RCT2_CALLPROC_EBPSAFE(0x0069EB13); // sprites_init ride_init_all(); window_guest_list_init_vars_a(); - RCT2_CALLPROC_EBPSAFE(0x006BD3A4); + sub_6BD3A4(); park_init(); finance_init(); date_reset(); window_guest_list_init_vars_b(); - RCT2_CALLPROC_EBPSAFE(0x006BD39C); + RCT2_GLOBAL(RCT2_ADDRESS_WINDOW_STAFF_LIST_SELECTED_TAB, uint8) = WINDOW_STAFF_LIST_TAB_HANDYMEN; RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) = SCREEN_FLAGS_SCENARIO_EDITOR; RCT2_GLOBAL(0x0141F570, uint8) = 0; RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) |= PARK_FLAGS_SHOW_REAL_GUEST_NAMES; - RCT2_CALLPROC_EBPSAFE(0x006ACA58); + window_ride_list_init_vars(); RCT2_GLOBAL(0x0141F571, uint8) = 4; viewport_init_all(); news_item_init_queue(); @@ -102,15 +102,15 @@ void trackdesigner_load() RCT2_CALLPROC_EBPSAFE(0x0069EB13); // reset_sprites ride_init_all(); window_guest_list_init_vars_a(); - RCT2_CALLPROC_EBPSAFE(0x006BD3A4); + sub_6BD3A4(); park_init(); finance_init(); date_reset(); window_guest_list_init_vars_b(); - RCT2_CALLPROC_EBPSAFE(0x006BD39C); + RCT2_GLOBAL(RCT2_ADDRESS_WINDOW_STAFF_LIST_SELECTED_TAB, uint8) = WINDOW_STAFF_LIST_TAB_HANDYMEN; RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) = SCREEN_FLAGS_TRACK_DESIGNER; RCT2_GLOBAL(0x0141F570, uint8) = 0; - RCT2_CALLPROC_EBPSAFE(0x006ACA58); + window_ride_list_init_vars(); viewport_init_all(); news_item_init_queue(); RCT2_CALLPROC_EBPSAFE(0x0066EF38); // window_main_editor_create @@ -140,15 +140,15 @@ void trackmanager_load() RCT2_CALLPROC_EBPSAFE(0x0069EB13); // reset_sprites ride_init_all(); window_guest_list_init_vars_a(); - RCT2_CALLPROC_EBPSAFE(0x006BD3A4); + sub_6BD3A4(); park_init(); finance_init(); date_reset(); window_guest_list_init_vars_b(); - RCT2_CALLPROC_EBPSAFE(0x006BD39C); + RCT2_GLOBAL(RCT2_ADDRESS_WINDOW_STAFF_LIST_SELECTED_TAB, uint8) = WINDOW_STAFF_LIST_TAB_HANDYMEN; RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) = SCREEN_FLAGS_TRACK_MANAGER; RCT2_GLOBAL(0x0141F570, uint8) = 0; - RCT2_CALLPROC_EBPSAFE(0x006ACA58); + window_ride_list_init_vars(); viewport_init_all(); news_item_init_queue(); RCT2_CALLPROC_EBPSAFE(0x0066EF38); // window_main_editor_create @@ -170,4 +170,18 @@ static void set_all_land_owned() int mapSize = RCT2_GLOBAL(RCT2_ADDRESS_MAP_SIZE, sint16); game_do_command(64, 1, 64, 2, 56, (mapSize - 2) * 32, (mapSize - 2) * 32); +} + +/** +* +* rct2: 0x006BD3A4 +*/ +void sub_6BD3A4() { + for (short i = 0; i < 200; i++) { + RCT2_ADDRESS(0x013CA672, uint8)[i] = 0; + } + for (short i = 200; i < 204; i++) { + RCT2_ADDRESS(0x013CA672, uint8)[i] = 1; + } + RCT2_CALLPROC_EBPSAFE(0x006C0C3F); } \ No newline at end of file diff --git a/src/editor.h b/src/editor.h index 34a7ef5ab3..9022a6cd4d 100644 --- a/src/editor.h +++ b/src/editor.h @@ -26,4 +26,6 @@ void editor_convert_save_to_scenario(); void trackdesigner_load(); void trackmanager_load(); +void sub_6BD3A4(); + #endif diff --git a/src/finance.c b/src/finance.c index b011b4ccec..a24f64f51e 100644 --- a/src/finance.c +++ b/src/finance.c @@ -109,7 +109,7 @@ void finance_pay_interest() void finance_init() { for (short i = 0; i < 56; i++) { - RCT2_ADDRESS(0x01357848, uint32)[i] = 0; + RCT2_ADDRESS(RCT2_ADDRESS_EXPENDITURE_TABLE, uint32)[i] = 0; } RCT2_GLOBAL(0x0135832C, uint32) = 0; @@ -119,7 +119,7 @@ void finance_init() { RCT2_GLOBAL(0x01358334, uint32) = 0; RCT2_GLOBAL(0x01358338, uint16) = 0; - RCT2_GLOBAL(0x013573DC, uint32) = 100000; + RCT2_GLOBAL(0x013573DC, uint32) = 100000; // Cheat detection RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONEY_ENCRYPTED, sint32) = ENCRYPT_MONEY(100000); RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_LOAN, sint32) = 100000; diff --git a/src/game.c b/src/game.c index a68cd91245..0358864fa1 100644 --- a/src/game.c +++ b/src/game.c @@ -1294,7 +1294,7 @@ int game_load_save() RCT2_CALLPROC_EBPSAFE(0x0069E9A7); RCT2_CALLPROC_EBPSAFE(0x006DFEE4); - RCT2_CALLPROC_EBPSAFE(0x006ACA58); + window_ride_list_init_vars(); RCT2_GLOBAL(0x009DEB7C, uint16) = 0; if (RCT2_GLOBAL(0x0013587C4, uint32) == 0) // this check is not in scenario play RCT2_CALLPROC_EBPSAFE(0x0069E869); diff --git a/src/rct2.c b/src/rct2.c index 24ea502be0..be54cd7306 100644 --- a/src/rct2.c +++ b/src/rct2.c @@ -135,9 +135,9 @@ void rct2_init() date_reset(); climate_reset(CLIMATE_COOL_AND_WET); RCT2_CALLPROC_EBPSAFE(0x006DFEE4); - RCT2_CALLPROC_EBPSAFE(0x006ACA58); + window_ride_list_init_vars(); window_guest_list_init_vars_b(); - RCT2_CALLPROC_EBPSAFE(0x006BD39C); + RCT2_GLOBAL(RCT2_ADDRESS_WINDOW_STAFF_LIST_SELECTED_TAB, uint8) = WINDOW_STAFF_LIST_TAB_HANDYMEN; title_load(); diff --git a/src/scenario.c b/src/scenario.c index b283c9e767..d0031bd810 100644 --- a/src/scenario.c +++ b/src/scenario.c @@ -450,7 +450,7 @@ void scenario_load_and_play(rct_scenario_basic *scenario) window_invalidate(mainWindow); RCT2_CALLPROC_EBPSAFE(0x0069E9A7); - RCT2_CALLPROC_EBPSAFE(0x006ACA58); + window_ride_list_init_vars(); RCT2_GLOBAL(0x00F663B0, sint32) = RCT2_GLOBAL(0x009AA0F0, sint32); RCT2_GLOBAL(0x00F663B4, sint32) = RCT2_GLOBAL(0x009AA0F4, sint32); diff --git a/src/title.c b/src/title.c index db3b8e7baa..fc6ef67aa5 100644 --- a/src/title.c +++ b/src/title.c @@ -103,9 +103,9 @@ void title_load() date_reset(); RCT2_CALLPROC_X(0x006C45ED, 0, 0, 0, 0, 0, 0, 0); RCT2_CALLPROC_EBPSAFE(0x006DFEE4); - RCT2_CALLPROC_EBPSAFE(0x006ACA58); + window_ride_list_init_vars(); window_guest_list_init_vars_b(); - RCT2_CALLPROC_EBPSAFE(0x006BD39C); + RCT2_GLOBAL(RCT2_ADDRESS_WINDOW_STAFF_LIST_SELECTED_TAB, uint8) = WINDOW_STAFF_LIST_TAB_HANDYMEN; RCT2_CALLPROC_EBPSAFE(0x0068AFFD); RCT2_CALLPROC_EBPSAFE(0x0069EBE4); viewport_init_all(); @@ -191,7 +191,7 @@ static void title_update_showcase() window_invalidate(w); RCT2_CALLPROC_EBPSAFE(0x0069E9A7); - RCT2_CALLPROC_EBPSAFE(0x006ACA58); + window_ride_list_init_vars(); RCT2_CALLPROC_EBPSAFE(0x00684AC3); RCT2_CALLPROC_EBPSAFE(0x006DFEE4); news_item_init_queue(); diff --git a/src/window.c b/src/window.c index 0a7f726040..a35da16b81 100644 --- a/src/window.c +++ b/src/window.c @@ -1203,4 +1203,28 @@ void window_guest_list_init_vars_b() { RCT2_GLOBAL(0x00F1EE02, uint32) = 0xFFFFFFFF; RCT2_GLOBAL(RCT2_ADDRESS_WINDOW_GUEST_LIST_SELECTED_FILTER, uint8) = 0xFF; RCT2_GLOBAL(0x00F1AF20, uint16) = 0; +} + +/** +* +* rct2: 0x006ACA58 +*/ +void window_ride_list_init_vars() { + // If we are in the track designer, default to the Roller Coaster tab + if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_TRACK_DESIGNER) { + RCT2_GLOBAL(RCT2_ADDRESS_WINDOW_RIDE_LIST_SELECTED_TAB, uint8) = WINDOW_RIDE_LIST_TAB_ROLLER_COASTER; + } + else { + RCT2_GLOBAL(RCT2_ADDRESS_WINDOW_RIDE_LIST_SELECTED_TAB, uint8) = WINDOW_RIDE_LIST_TAB_TRANSPORT; + } + + for (short i = 0; i < 6; i++) { + /* + Reset what is highlighted in each tab. + Each 16bit number represents the item in its respective tab. + */ + RCT2_ADDRESS(RCT2_ADDRESS_WINDOW_RIDE_LIST_HIGHLIGHTED_ITEM, uint16)[i] = 0xFFFF; + } + + RCT2_GLOBAL(RCT2_ADDRESS_WINDOW_RIDE_LIST_INFORMATION_TYPE, uint8) = 0; } \ No newline at end of file diff --git a/src/window.h b/src/window.h index 1aefaf65e4..1f52eee128 100644 --- a/src/window.h +++ b/src/window.h @@ -284,6 +284,23 @@ enum { WC_CHEATS = 110, } WINDOW_CLASS; +enum { + WINDOW_RIDE_LIST_TAB_TRANSPORT, + WINDOW_RIDE_LIST_TAB_GENTLE, + WINDOW_RIDE_LIST_TAB_ROLLER_COASTER, + WINDOW_RIDE_LIST_TAB_THRILL, + WINDOW_RIDE_LIST_TAB_WATER, + WINDOW_RIDE_LIST_TAB_SHOP, + WINDOW_RIDE_LIST_TAB_RESEARCH +} WINDOW_RIDE_LIST_TAB; + +enum { + WINDOW_STAFF_LIST_TAB_HANDYMEN, + WINDOW_STAFF_LIST_TAB_MECHANICS, + WINDOW_STAFF_LIST_TAB_SECURITY, + WINDOW_STAFF_LIST_TAB_ENTERTAINERS +} WINDOW_STAFF_LIST_TAB; + void window_dispatch_update_all(); void window_update_all(); rct_window *window_create(int x, int y, int width, int height, uint32 *event_handlers, rct_windowclass cls, uint16 flags); @@ -349,5 +366,6 @@ void window_cheats_open(); void window_guest_list_init_vars_a(); void window_guest_list_init_vars_b(); +void window_ride_list_init_vars(); #endif From 76611d054a04080e024f591791f728a05c6f4b53 Mon Sep 17 00:00:00 2001 From: ZedThree Date: Wed, 7 May 2014 23:11:23 +0200 Subject: [PATCH 43/44] Fix bug in open_load_game_dialog() Should return the result of osinterface_open_common_file_dialog() --- src/game.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/game.c b/src/game.c index a68cd91245..f46623127f 100644 --- a/src/game.c +++ b/src/game.c @@ -1159,13 +1159,15 @@ static int open_landscape_file_dialog() */ static int open_load_game_dialog() { + int result; format_string(0x0141ED68, STR_LOAD_GAME_DIALOG_TITLE, 0); strcpy(0x0141EF68, RCT2_ADDRESS_SAVED_GAMES_PATH); format_string(0x0141EE68, STR_RCT2_SAVED_GAME, 0); pause_sounds(); - osinterface_open_common_file_dialog(1, 0x0141ED68, 0x0141EF68, "*.SV6", 0x0141EE68); + result = osinterface_open_common_file_dialog(1, 0x0141ED68, 0x0141EF68, "*.SV6", 0x0141EE68); unpause_sounds(); // window_proc + return result; } /** From d5927e415ff6da8a10a8463aa793fb84685846eb Mon Sep 17 00:00:00 2001 From: IntelOrca Date: Wed, 7 May 2014 23:45:16 +0100 Subject: [PATCH 44/44] use finance_payment in do_game_command --- src/game.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/game.c b/src/game.c index 6ff59b88db..c734617582 100644 --- a/src/game.c +++ b/src/game.c @@ -24,6 +24,7 @@ #include "config.h" #include "rct2.h" #include "game.h" +#include "finance.h" #include "news_item.h" #include "object.h" #include "osinterface.h" @@ -1057,6 +1058,7 @@ int game_do_command(int eax, int ebx, int ecx, int edx, int esi, int edi, int eb // if (!(flags & 0x20)) { // Update money balance + finance_payment(cost, RCT2_GLOBAL(0x0141F56C, uint8)); RCT2_CALLPROC_X(0x0069C674, 0, cost, 0, 0, 0, 0, 0); if (RCT2_GLOBAL(0x0141F568, uint8) == RCT2_GLOBAL(0x013CA740, uint8)) { // Create a +/- money text effect