From b04b25d01332a079e00473f2d627596e97ccb3a4 Mon Sep 17 00:00:00 2001 From: "Miso Zmiric (Mike Squinter)" Date: Thu, 8 May 2014 07:10:26 +0100 Subject: [PATCH 01/41] Add directory_browser to config_create_default partially resolves #42 [https://github.com/IntelOrca/OpenRCT2/issues/42] --- projects/openrct2.sln | 12 +++++++++- src/config.c | 55 +++++++++++++++++++++++++++++++++++++++++-- src/config.h | 1 + src/rct2.c | 2 +- 4 files changed, 66 insertions(+), 4 deletions(-) diff --git a/projects/openrct2.sln b/projects/openrct2.sln index f176b7813f..4bdb4ac96e 100644 --- a/projects/openrct2.sln +++ b/projects/openrct2.sln @@ -1,18 +1,28 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 2013 -VisualStudioVersion = 12.0.30110.0 +VisualStudioVersion = 12.0.21005.1 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "openrct2", "openrct2.vcxproj", "{D24D94F6-2A74-480C-B512-629C306CE92F}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|Mixed Platforms = Debug|Mixed Platforms Debug|Win32 = Debug|Win32 + Release|Any CPU = Release|Any CPU + Release|Mixed Platforms = Release|Mixed Platforms Release|Win32 = Release|Win32 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D24D94F6-2A74-480C-B512-629C306CE92F}.Debug|Any CPU.ActiveCfg = Debug|Win32 + {D24D94F6-2A74-480C-B512-629C306CE92F}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 + {D24D94F6-2A74-480C-B512-629C306CE92F}.Debug|Mixed Platforms.Build.0 = Debug|Win32 {D24D94F6-2A74-480C-B512-629C306CE92F}.Debug|Win32.ActiveCfg = Debug|Win32 {D24D94F6-2A74-480C-B512-629C306CE92F}.Debug|Win32.Build.0 = Debug|Win32 + {D24D94F6-2A74-480C-B512-629C306CE92F}.Release|Any CPU.ActiveCfg = Release|Win32 + {D24D94F6-2A74-480C-B512-629C306CE92F}.Release|Mixed Platforms.ActiveCfg = Release|Win32 + {D24D94F6-2A74-480C-B512-629C306CE92F}.Release|Mixed Platforms.Build.0 = Release|Win32 {D24D94F6-2A74-480C-B512-629C306CE92F}.Release|Win32.ActiveCfg = Release|Win32 {D24D94F6-2A74-480C-B512-629C306CE92F}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection diff --git a/src/config.c b/src/config.c index ff256fcfc0..b907cfd77b 100644 --- a/src/config.c +++ b/src/config.c @@ -25,6 +25,7 @@ #include "addresses.h" #include "config.h" #include "rct2.h" +#include // Current keyboard shortcuts uint16 gShortcutKeys[SHORTCUT_COUNT]; @@ -220,8 +221,9 @@ static void config_create_default(char *path) FILE* fp; if (!config_find_rct2_path(gConfig.game_path)) { - MessageBox(NULL, "Unable to find RCT2 installation directory. Please correct in config.ini.", "OpenRCT2", MB_OK); - strcpy(gConfig.game_path, "C:\\"); + MessageBox(NULL, "Unable to find RCT2 installation directory. Please select the directoy where you installed RTC2!", "OpenRCT2", MB_OK); + char *res = directory_browser(); + strcpy(gConfig.game_path, res); } fp = fopen(path, "w"); @@ -232,6 +234,55 @@ static void config_create_default(char *path) fclose(fp); } +//A directory browser allowing for semi-automatic config.ini for non standard installs +char* directory_browser() +{ + BROWSEINFO bi; + char pszBuffer[MAX_PATH]; + LPITEMIDLIST pidl; + LPMALLOC lpMalloc; + + // Initialize COM + if (CoInitializeEx(0, COINIT_APARTMENTTHREADED) != S_OK) + { + MessageBox(NULL, _T("Error opening browse window"), _T("ERROR"), MB_OK); + CoUninitialize(); + return 0; + } + + // Get a pointer to the shell memory allocator + if (SHGetMalloc(&lpMalloc) != S_OK) + { + MessageBox(NULL, _T("Error opening browse window"), _T("ERROR"), MB_OK); + CoUninitialize(); + return 0; + } + + bi.hwndOwner = NULL; + bi.pidlRoot = NULL; + bi.pszDisplayName = pszBuffer; + bi.lpszTitle = _T("Select your RCT2 installation directory"); + bi.ulFlags = BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS; + bi.lpfn = NULL; + bi.lParam = 0; + + char *outPath = "C:\\"; + + if (pidl = SHBrowseForFolder(&bi)) + { + // Copy the path directory to the buffer + if (SHGetPathFromIDList(pidl, pszBuffer)) + { + // store pszBuffer (and the path) in the outPath + outPath = strcat("", pszBuffer); + + } + + } + CoUninitialize(); + return outPath; +} + /** * Parse settings and set the game veriables * @param fp file pointer to the settings file diff --git a/src/config.h b/src/config.h index 2ed8b08dff..4d00474a91 100644 --- a/src/config.h +++ b/src/config.h @@ -76,6 +76,7 @@ extern uint16 gShortcutKeys[SHORTCUT_COUNT]; void config_reset_shortcut_keys(); void config_load(); void config_save(); +char* directory_browser(); // New config format diff --git a/src/rct2.c b/src/rct2.c index be54cd7306..696769cc63 100644 --- a/src/rct2.c +++ b/src/rct2.c @@ -151,7 +151,7 @@ void rct2_init_directories() // check install directory DWORD dwAttrib = GetFileAttributes(gConfig.game_path); if (dwAttrib == INVALID_FILE_ATTRIBUTES || !(dwAttrib & FILE_ATTRIBUTE_DIRECTORY)) { - MessageBox(NULL, "Invalid RCT2 installation path. Please correct in config.ini.", "OpenRCT2", MB_OK); + MessageBox(NULL, "Invalid RCT2 installation path. Please delete config.ini and run OpenRTC2 again.", "OpenRCT2", MB_OK); exit(-1); } From b1017a839f0ec50dfb6fef801bd146630b76311d Mon Sep 17 00:00:00 2001 From: "Miso Zmiric (Mike Squinter)" Date: Thu, 8 May 2014 13:06:36 +0100 Subject: [PATCH 02/41] fix late night typo --- src/config.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config.c b/src/config.c index b907cfd77b..125aa5123e 100644 --- a/src/config.c +++ b/src/config.c @@ -221,7 +221,7 @@ static void config_create_default(char *path) FILE* fp; if (!config_find_rct2_path(gConfig.game_path)) { - MessageBox(NULL, "Unable to find RCT2 installation directory. Please select the directoy where you installed RTC2!", "OpenRCT2", MB_OK); + MessageBox(NULL, "Unable to find RCT2 installation directory. Please select the directoy where you installed RCT2!", "OpenRCT2", MB_OK); char *res = directory_browser(); strcpy(gConfig.game_path, res); } From 231777d1317d375329436fd901e64222b76d4480 Mon Sep 17 00:00:00 2001 From: IntelOrca Date: Thu, 8 May 2014 16:07:57 +0100 Subject: [PATCH 03/41] clean up config --- projects/openrct2.sln | 12 +----------- src/config.c | 27 ++++++++++++--------------- src/config.h | 1 - src/rct2.c | 2 +- 4 files changed, 14 insertions(+), 28 deletions(-) diff --git a/projects/openrct2.sln b/projects/openrct2.sln index 4bdb4ac96e..f176b7813f 100644 --- a/projects/openrct2.sln +++ b/projects/openrct2.sln @@ -1,28 +1,18 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 2013 -VisualStudioVersion = 12.0.21005.1 +VisualStudioVersion = 12.0.30110.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "openrct2", "openrct2.vcxproj", "{D24D94F6-2A74-480C-B512-629C306CE92F}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Debug|Mixed Platforms = Debug|Mixed Platforms Debug|Win32 = Debug|Win32 - Release|Any CPU = Release|Any CPU - Release|Mixed Platforms = Release|Mixed Platforms Release|Win32 = Release|Win32 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {D24D94F6-2A74-480C-B512-629C306CE92F}.Debug|Any CPU.ActiveCfg = Debug|Win32 - {D24D94F6-2A74-480C-B512-629C306CE92F}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 - {D24D94F6-2A74-480C-B512-629C306CE92F}.Debug|Mixed Platforms.Build.0 = Debug|Win32 {D24D94F6-2A74-480C-B512-629C306CE92F}.Debug|Win32.ActiveCfg = Debug|Win32 {D24D94F6-2A74-480C-B512-629C306CE92F}.Debug|Win32.Build.0 = Debug|Win32 - {D24D94F6-2A74-480C-B512-629C306CE92F}.Release|Any CPU.ActiveCfg = Release|Win32 - {D24D94F6-2A74-480C-B512-629C306CE92F}.Release|Mixed Platforms.ActiveCfg = Release|Win32 - {D24D94F6-2A74-480C-B512-629C306CE92F}.Release|Mixed Platforms.Build.0 = Release|Win32 {D24D94F6-2A74-480C-B512-629C306CE92F}.Release|Win32.ActiveCfg = Release|Win32 {D24D94F6-2A74-480C-B512-629C306CE92F}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection diff --git a/src/config.c b/src/config.c index beef6f6dc9..af8ac6ca44 100644 --- a/src/config.c +++ b/src/config.c @@ -147,6 +147,7 @@ void config_save() configuration_t gConfig; +static char *config_show_directory_browser(); static void config_parse_settings(FILE *fp); static int config_get_line(FILE *fp, char *setting, char *value); static int config_parse_setting(FILE *fp, char *setting); @@ -170,7 +171,7 @@ void config_init() DWORD dwAttrib = GetFileAttributes(path); if (dwAttrib == INVALID_FILE_ATTRIBUTES || !(dwAttrib & FILE_ATTRIBUTE_DIRECTORY)) { // folder does not exist if (!CreateDirectory(path, NULL)) { - config_error("Could not create config file (do you have write acces to you documents folder?)"); + config_error("Could not create config file (do you have write access to your documents folder?)"); } } strcat(path, "\\config.ini"); @@ -230,7 +231,7 @@ static void config_create_default(char *path) if (!config_find_rct2_path(gConfig.game_path)) { MessageBox(NULL, "Unable to find RCT2 installation directory. Please select the directoy where you installed RCT2!", "OpenRCT2", MB_OK); - char *res = directory_browser(); + char *res = config_show_directory_browser(); strcpy(gConfig.game_path, res); } @@ -242,8 +243,10 @@ static void config_create_default(char *path) fclose(fp); } -//A directory browser allowing for semi-automatic config.ini for non standard installs -char* directory_browser() +/** + * A directory browser allowing for semi-automatic config.ini for non standard installs. + */ +static char *config_show_directory_browser() { BROWSEINFO bi; char pszBuffer[MAX_PATH]; @@ -251,16 +254,14 @@ char* directory_browser() LPMALLOC lpMalloc; // Initialize COM - if (CoInitializeEx(0, COINIT_APARTMENTTHREADED) != S_OK) - { + if (CoInitializeEx(0, COINIT_APARTMENTTHREADED) != S_OK) { MessageBox(NULL, _T("Error opening browse window"), _T("ERROR"), MB_OK); CoUninitialize(); return 0; } // Get a pointer to the shell memory allocator - if (SHGetMalloc(&lpMalloc) != S_OK) - { + if (SHGetMalloc(&lpMalloc) != S_OK) { MessageBox(NULL, _T("Error opening browse window"), _T("ERROR"), MB_OK); CoUninitialize(); return 0; @@ -276,16 +277,12 @@ char* directory_browser() char *outPath = "C:\\"; - if (pidl = SHBrowseForFolder(&bi)) - { + if (pidl = SHBrowseForFolder(&bi)) { // Copy the path directory to the buffer - if (SHGetPathFromIDList(pidl, pszBuffer)) - { - // store pszBuffer (and the path) in the outPath + if (SHGetPathFromIDList(pidl, pszBuffer)) { + // Store pszBuffer (and the path) in the outPath outPath = strcat("", pszBuffer); - } - } CoUninitialize(); return outPath; diff --git a/src/config.h b/src/config.h index a071aba390..65ee7b4752 100644 --- a/src/config.h +++ b/src/config.h @@ -81,7 +81,6 @@ extern uint16 gShortcutKeys[SHORTCUT_COUNT]; void config_reset_shortcut_keys(); void config_load(); void config_save(); -char* directory_browser(); // New config format diff --git a/src/rct2.c b/src/rct2.c index 696769cc63..be54cd7306 100644 --- a/src/rct2.c +++ b/src/rct2.c @@ -151,7 +151,7 @@ void rct2_init_directories() // check install directory DWORD dwAttrib = GetFileAttributes(gConfig.game_path); if (dwAttrib == INVALID_FILE_ATTRIBUTES || !(dwAttrib & FILE_ATTRIBUTE_DIRECTORY)) { - MessageBox(NULL, "Invalid RCT2 installation path. Please delete config.ini and run OpenRTC2 again.", "OpenRCT2", MB_OK); + MessageBox(NULL, "Invalid RCT2 installation path. Please correct in config.ini.", "OpenRCT2", MB_OK); exit(-1); } From a35289fc9fce8530f62ed5546db32d9c1a6b2aa0 Mon Sep 17 00:00:00 2001 From: ZedThree Date: Thu, 8 May 2014 17:08:52 +0200 Subject: [PATCH 04/41] Add functions to open park window to awards/rating Also update replace some address that have constants/functions --- src/window.h | 2 + src/window_footpath.c | 2 +- src/window_game_bottom_toolbar.c | 2 +- src/window_park.c | 66 ++++++++++++++++++++++++++++++-- 4 files changed, 66 insertions(+), 6 deletions(-) diff --git a/src/window.h b/src/window.h index 1f52eee128..dff987d918 100644 --- a/src/window.h +++ b/src/window.h @@ -359,8 +359,10 @@ void window_clear_scenery_open(); void window_land_open(); void window_water_open(); void window_guest_list_open(); +void window_park_awards_open(); void window_park_entrance_open(); void window_park_objective_open(); +void window_park_rating_open(); void window_ride_list_open(); void window_cheats_open(); diff --git a/src/window_footpath.c b/src/window_footpath.c index d88cf014a3..44ab834559 100644 --- a/src/window_footpath.c +++ b/src/window_footpath.c @@ -270,7 +270,7 @@ static void window_footpath_mouseup() break; _window_footpath_cost = 0x80000000; - RCT2_CALLPROC_EBPSAFE(0x006EE281); + tool_cancel(); RCT2_CALLPROC_EBPSAFE(0x006A7831); RCT2_CALLPROC_EBPSAFE(0x0068AB1B); RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) &= ~2; diff --git a/src/window_game_bottom_toolbar.c b/src/window_game_bottom_toolbar.c index 32b4a01251..6be78ee35b 100644 --- a/src/window_game_bottom_toolbar.c +++ b/src/window_game_bottom_toolbar.c @@ -166,7 +166,7 @@ static void window_game_bottom_toolbar_mouseup() RCT2_CALLPROC_EBPSAFE(0x00667D35); break; case WIDX_PARK_RATING: - RCT2_CALLPROC_EBPSAFE(0x00667CA4); + window_park_rating_open(); break; case WIDX_MIDDLE_INSET: news_item_close_current(); diff --git a/src/window_park.c b/src/window_park.c index 4700b6f479..3ed83cd0e0 100644 --- a/src/window_park.c +++ b/src/window_park.c @@ -646,7 +646,7 @@ static void window_park_entrance_close() if (RCT2_GLOBAL(0x009DE518, uint32) & (1 << 3)) if (w->classification == RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWCLASS, rct_windowclass) && w->number == RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWNUMBER, rct_windownumber)) - RCT2_CALLPROC_EBPSAFE(0x006EE281); + tool_cancel(); } /** @@ -1083,6 +1083,35 @@ static void window_park_scroll_to_viewport(rct_window *w) #pragma region Rating page +/** +* +* rct2: 0x00667CA4 +*/ +void window_park_rating_open() +{ + rct_window* window; + + window = window_bring_to_front_by_id(WC_PARK_INFORMATION, 0); + if (window == NULL) { + window = window_park_open(); + window->var_482 = -1; + window->var_484 = -1; + } + + if (RCT2_GLOBAL(0x009DE518, uint32) & (1 << 3)) + if (window->classification == RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWCLASS, rct_windowclass) && window->number == RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWNUMBER, rct_windownumber)) + tool_cancel(); + + window->viewport = NULL; + window->page = WINDOW_PARK_PAGE_RATING; + window_invalidate(window); + window->widgets = window_park_rating_widgets; + window->enabled_widgets = window_park_page_enabled_widgets[WINDOW_PARK_PAGE_RATING]; + window->var_020 = 0; + window->event_handlers = window_park_rating_events; + window_init_scroll_widgets(window); +} + /** * * rct2: 0x00668A06 @@ -1570,7 +1599,7 @@ static void window_park_stats_paint() y = w->y + window_park_awards_widgets[WIDX_PAGE_BACKGROUND].top + 4; // Draw park size - parkSize = RCT2_GLOBAL(0x013580EA, sint16) * 10; + parkSize = RCT2_GLOBAL(RCT2_ADDRESS_PARK_SIZE, sint16) * 10; stringIndex = STR_PARK_SIZE_METRIC_LABEL; if (!RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_METRIC, uint8)) { stringIndex = STR_PARK_SIZE_IMPERIAL_LABEL; @@ -1619,7 +1648,7 @@ void window_park_objective_open() if (RCT2_GLOBAL(0x009DE518, uint32) & (1 << 3)) if (window->classification == RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWCLASS, rct_windowclass) && window->number == RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWNUMBER, rct_windownumber)) - RCT2_CALLPROC_EBPSAFE(0x006EE281); + tool_cancel(); window->viewport = NULL; window->page = WINDOW_PARK_PAGE_OBJECTIVE; @@ -1773,6 +1802,35 @@ static void window_park_objective_paint() #pragma region Awards page +/** +* +* rct2: 0x00667DC6 +*/ +void window_park_awards_open() +{ + rct_window* window; + + window = window_bring_to_front_by_id(WC_PARK_INFORMATION, 0); + if (window == NULL) { + window = window_park_open(); + window->var_482 = -1; + window->var_484 = -1; + } + + if (RCT2_GLOBAL(0x009DE518, uint32) & (1 << 3)) + if (window->classification == RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWCLASS, rct_windowclass) && window->number == RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWNUMBER, rct_windownumber)) + tool_cancel(); + + window->viewport = NULL; + window->page = WINDOW_PARK_PAGE_AWARDS; + window_invalidate(window); + window->widgets = window_park_awards_widgets; + window->enabled_widgets = window_park_page_enabled_widgets[WINDOW_PARK_PAGE_AWARDS]; + window->var_020 = 0; + window->event_handlers = window_park_awards_events; + window_init_scroll_widgets(window); +} + /** * * rct2: 0x00669851 @@ -1896,7 +1954,7 @@ static void window_park_set_page(rct_window *w, int page) if (RCT2_GLOBAL(0x009DE518, uint32) & (1 << 3)) if (w->classification == RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWCLASS, rct_windowclass) && w->number == RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWNUMBER, rct_windownumber)) - RCT2_CALLPROC_EBPSAFE(0x006EE281); + tool_cancel(); // Set listen only to viewport listen = 0; From c94fd530229171617cf69d42989ae1620c3213b6 Mon Sep 17 00:00:00 2001 From: ZedThree Date: Thu, 8 May 2014 17:14:08 +0200 Subject: [PATCH 05/41] Add news_item_open_subject() --- src/news_item.c | 68 ++++++++++++++++++++++++++++++++ src/news_item.h | 1 + src/window_game_bottom_toolbar.c | 2 +- src/window_news.c | 2 +- 4 files changed, 71 insertions(+), 2 deletions(-) diff --git a/src/news_item.c b/src/news_item.c index 3bc978f7bb..7e4aa2cd4a 100644 --- a/src/news_item.c +++ b/src/news_item.c @@ -276,3 +276,71 @@ void news_item_add_to_queue(uint8 type, rct_string_id string_id, uint32 assoc) newsItem++; newsItem->type = 0; } + +/** + * Opens the window/tab for the subject of the news item + * + * rct2: 0x0066EBE6 + * + **/ +void news_item_open_subject(int type, int subject) { + + int eax; + rct_peep* peep; + rct_window* window; + + switch (type) { + case NEWS_ITEM_RIDE: + RCT2_CALLPROC_X(0x006ACC28, subject, 0, 0, 0, 0, 0, 0); + break; + case NEWS_ITEM_PEEP_ON_RIDE: + case NEWS_ITEM_PEEP: + peep = &(RCT2_ADDRESS(RCT2_ADDRESS_SPRITE_LIST, rct_sprite)[subject]); + RCT2_CALLPROC_X(0x006989E9, 0, 0, 0, peep, 0, 0, 0); + break; + case NEWS_ITEM_MONEY: + // Open finances window + RCT2_CALLPROC_EBPSAFE(0x0069DDF1); + break; + case NEWS_ITEM_SCENERY: + + if (subject >= 0x10000) { + // Open ride list window + RCT2_CALLPROC_EBPSAFE(0x006B3CFF); + eax = (subject & 0xFF00) >> 8; + eax += (subject & 0xFF) << 8; + // Switch to right tab and scroll to ride location + RCT2_CALLPROC_X(0x006B3EBA, eax, 0, subject, 0, 0, 0, 0); + break; + } + + // Check if window is already open + window = window_bring_to_front_by_id(WC_SCENERY, 0); + if (window == NULL) { + window = window_find_by_id(WC_TOP_TOOLBAR, 0); + if (window != NULL) { + window_invalidate(window); + if (tool_set(window, 9, 0)){ + RCT2_CALLPROC_X(0x006E1172, (subject & 0xFFFF), 0, subject, 0, 0, 0, 0); + } + RCT2_GLOBAL(0x009DE518, uint32) |= (1 << 6); + // Open scenery window + RCT2_CALLPROC_EBPSAFE(0x006E0FEF); + } + } + // Switch to new scenery tab + RCT2_CALLPROC_X(0x006E1172, (subject & 0xFFFF), 0, subject, 0, 0, 0, 0); + + break; + case NEWS_ITEM_PEEPS: + // Open guest list to right tab + RCT2_CALLPROC_X(0x006993BA, 3, subject, 0, 0, 0, 0, 0); + break; + case NEWS_ITEM_AWARD: + window_park_awards_open(); + break; + case NEWS_ITEM_GRAPH: + window_park_rating_open(); + break; + } +} diff --git a/src/news_item.h b/src/news_item.h index 3de7ada5a5..8775fa1581 100644 --- a/src/news_item.h +++ b/src/news_item.h @@ -61,5 +61,6 @@ void news_item_update_current(); void news_item_close_current(); void news_item_get_subject_location(int type, int subject, int *x, int *y, int *z); void news_item_add_to_queue(uint8 type, rct_string_id string_id, uint32 assoc); +void news_item_open_subject(int type, int subject); #endif diff --git a/src/window_game_bottom_toolbar.c b/src/window_game_bottom_toolbar.c index 6be78ee35b..4169876f68 100644 --- a/src/window_game_bottom_toolbar.c +++ b/src/window_game_bottom_toolbar.c @@ -173,7 +173,7 @@ static void window_game_bottom_toolbar_mouseup() break; case WIDX_NEWS_SUBJECT: newsItem = &(RCT2_ADDRESS(RCT2_ADDRESS_NEWS_ITEM_LIST, rct_news_item)[0]); - RCT2_CALLPROC_X(0x0066EBE6, 0, newsItem->type, newsItem->assoc, 0, 0, 0, 0); + news_item_open_subject(newsItem->type, newsItem->assoc); break; case WIDX_NEWS_LOCATE: newsItem = &(RCT2_ADDRESS(RCT2_ADDRESS_NEWS_ITEM_LIST, rct_news_item)[0]); diff --git a/src/window_news.c b/src/window_news.c index daa4f53939..cdfb22104c 100644 --- a/src/window_news.c +++ b/src/window_news.c @@ -169,7 +169,7 @@ static void window_news_update() 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); + news_item_open_subject(newsItems[i].type, newsItems[i].assoc); return; } else if (w->var_482 > 1) { news_item_get_subject_location(newsItems[i].type, newsItems[i].assoc, &x, &y, &z); From c1ac6edb96bd516bb41abda9deaef5c18bed9299 Mon Sep 17 00:00:00 2001 From: ZedThree Date: Thu, 8 May 2014 17:35:32 +0200 Subject: [PATCH 06/41] Add function to open park window to guests tab --- src/window.h | 1 + src/window_game_bottom_toolbar.c | 2 +- src/window_park.c | 29 +++++++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/window.h b/src/window.h index dff987d918..3b80f58142 100644 --- a/src/window.h +++ b/src/window.h @@ -361,6 +361,7 @@ void window_water_open(); void window_guest_list_open(); void window_park_awards_open(); void window_park_entrance_open(); +void window_park_guests_open(); void window_park_objective_open(); void window_park_rating_open(); void window_ride_list_open(); diff --git a/src/window_game_bottom_toolbar.c b/src/window_game_bottom_toolbar.c index 4169876f68..a5914cf9ef 100644 --- a/src/window_game_bottom_toolbar.c +++ b/src/window_game_bottom_toolbar.c @@ -163,7 +163,7 @@ static void window_game_bottom_toolbar_mouseup() RCT2_CALLPROC_EBPSAFE(0x0069DDF1); break; case WIDX_GUESTS: - RCT2_CALLPROC_EBPSAFE(0x00667D35); + window_park_guests_open(); break; case WIDX_PARK_RATING: window_park_rating_open(); diff --git a/src/window_park.c b/src/window_park.c index 3ed83cd0e0..e01ca4550a 100644 --- a/src/window_park.c +++ b/src/window_park.c @@ -1226,6 +1226,35 @@ static void window_park_rating_paint() #pragma region Guests page +/** +* +* rct2: 0x00667D35 +*/ +void window_park_guests_open() +{ + rct_window* window; + + window = window_bring_to_front_by_id(WC_PARK_INFORMATION, 0); + if (window == NULL) { + window = window_park_open(); + window->var_482 = -1; + window->var_484 = -1; + } + + if (RCT2_GLOBAL(0x009DE518, uint32) & (1 << 3)) + if (window->classification == RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWCLASS, rct_windowclass) && window->number == RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWNUMBER, rct_windownumber)) + tool_cancel(); + + window->viewport = NULL; + window->page = WINDOW_PARK_PAGE_GUESTS; + window_invalidate(window); + window->widgets = window_park_guests_widgets; + window->enabled_widgets = window_park_page_enabled_widgets[WINDOW_PARK_PAGE_GUESTS]; + window->var_020 = 0; + window->event_handlers = window_park_guests_events; + window_init_scroll_widgets(window); +} + /** * * rct2: 0x00668DEB From 85b102c5b0408cb8c4172070930f4824f4846c40 Mon Sep 17 00:00:00 2001 From: ZedThree Date: Thu, 8 May 2014 17:53:57 +0200 Subject: [PATCH 07/41] Change NEWS_ITEM_SCENERY to NEWS_ITEM_RESEARCH --- src/news_item.c | 2 +- src/news_item.h | 2 +- src/window_game_bottom_toolbar.c | 2 +- src/window_news.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/news_item.c b/src/news_item.c index 7e4aa2cd4a..70c0f1f01e 100644 --- a/src/news_item.c +++ b/src/news_item.c @@ -302,7 +302,7 @@ void news_item_open_subject(int type, int subject) { // Open finances window RCT2_CALLPROC_EBPSAFE(0x0069DDF1); break; - case NEWS_ITEM_SCENERY: + case NEWS_ITEM_RESEARCH: if (subject >= 0x10000) { // Open ride list window diff --git a/src/news_item.h b/src/news_item.h index 8775fa1581..f7e5333af1 100644 --- a/src/news_item.h +++ b/src/news_item.h @@ -33,7 +33,7 @@ enum { NEWS_ITEM_PEEP, NEWS_ITEM_MONEY, NEWS_ITEM_BLANK, - NEWS_ITEM_SCENERY, + NEWS_ITEM_RESEARCH, NEWS_ITEM_PEEPS, NEWS_ITEM_AWARD, NEWS_ITEM_GRAPH diff --git a/src/window_game_bottom_toolbar.c b/src/window_game_bottom_toolbar.c index a5914cf9ef..00eacc24e3 100644 --- a/src/window_game_bottom_toolbar.c +++ b/src/window_game_bottom_toolbar.c @@ -615,7 +615,7 @@ static void window_game_bottom_toolbar_draw_news_item(rct_drawpixelinfo *dpi, rc break; case NEWS_ITEM_MONEY: gfx_draw_sprite(dpi, SPR_FINANCE, x, y); - case NEWS_ITEM_SCENERY: + case NEWS_ITEM_RESEARCH: gfx_draw_sprite(dpi, (newsItem->assoc < 0x10000 ? SPR_NEW_RIDE : SPR_SCENERY), x, y); break; case NEWS_ITEM_PEEPS: diff --git a/src/window_news.c b/src/window_news.c index cdfb22104c..1e849ce080 100644 --- a/src/window_news.c +++ b/src/window_news.c @@ -352,7 +352,7 @@ static void window_news_scrollpaint() case NEWS_ITEM_MONEY: gfx_draw_sprite(dpi, SPR_FINANCE, x, yy); break; - case NEWS_ITEM_SCENERY: + case NEWS_ITEM_RESEARCH: gfx_draw_sprite(dpi, newsItem->assoc < 0x10000 ? SPR_NEW_RIDE : SPR_SCENERY, x, yy); break; case NEWS_ITEM_PEEPS: From d3be99cc98591f3a2a5109d8da7390af83f18a5f Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Thu, 8 May 2014 19:15:31 +0100 Subject: [PATCH 08/41] Added get_guest_face_sprite small and large functions. --- src/peep.h | 4 ++- src/window_guest_list.c | 79 +++++++++++++++++++++++++++++++++++------ 2 files changed, 71 insertions(+), 12 deletions(-) diff --git a/src/peep.h b/src/peep.h index 0b54db7988..529eef7d16 100644 --- a/src/peep.h +++ b/src/peep.h @@ -388,7 +388,9 @@ typedef struct { uint8 no_of_food; // 0xEC uint8 no_of_drinks; // 0xED uint8 no_of_souvenirs; // 0xEE - uint8 pad_EF[0x07]; + uint8 pad_EF[0x04]; + uint8 var_F3; + uint8 pad_F4[0x02]; uint8 balloon_colour; // 0xF6 uint8 umbrella_colour; // 0xF7 uint8 hat_colour; // 0xF8 diff --git a/src/window_guest_list.c b/src/window_guest_list.c index d57a504ccf..4af11e4dd4 100644 --- a/src/window_guest_list.c +++ b/src/window_guest_list.c @@ -130,7 +130,8 @@ static uint8 _window_guest_list_groups_guest_faces[240 * 58]; 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); +static int get_guest_face_sprite_small(rct_peep *peep); +static int get_guest_face_sprite_large(rct_peep *peep); /** * @@ -649,7 +650,7 @@ static void window_guest_list_scrollpaint() switch (_window_guest_list_selected_view) { case VIEW_ACTIONS: // Guest face - gfx_draw_sprite(dpi, get_guest_face_sprite(peep), 118, y); + gfx_draw_sprite(dpi, get_guest_face_sprite_small(peep), 118, y); // Tracking icon if (peep->flags & PEEP_FLAGS_TRACKING) @@ -856,7 +857,7 @@ static void window_guest_list_find_groups() _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; + _window_guest_list_groups_guest_faces[faceIndex++] = get_guest_face_sprite_small(peep) - 5486; // Find more peeps that belong to same group spriteIdx2 = peep->next; @@ -880,7 +881,7 @@ static void window_guest_list_find_groups() // 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; + _window_guest_list_groups_guest_faces[faceIndex++] = get_guest_face_sprite_small(peep2) - 5486; } if (RCT2_GLOBAL(0x00F1EDF6, uint16) == 0) { @@ -927,14 +928,70 @@ static void window_guest_list_find_groups() } /** - * + * Function split into large and small sprite * rct2: 0x00698721 */ -static int get_guest_face_sprite(rct_peep *peep) +static int get_guest_face_sprite_small(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; + int sprite; + sprite = 0x157A; + + if (peep->var_F3) return sprite; + + sprite = 0x1579; + if (peep->nausea > 200) return sprite; + sprite--; + + if (peep->nausea > 170) return sprite; + sprite--; + + if (peep->nausea > 140) return sprite; + sprite = 0x1576; + + if (peep->energy < 46) return sprite; + sprite--; + + if (peep->energy < 70) return sprite; + sprite = 0x156E; + + for (int i = 37; peep->happiness >= i; i += 37) + { + sprite++; + } + + return sprite; +} + +/** +* Function split into large and small sprite +* rct2: 0x00698721 +*/ +static int get_guest_face_sprite_large(rct_peep* peep){ + int sprite; + sprite = 5314; + + if (peep->var_F3) return sprite; + + sprite = 5298; + if (peep->nausea > 200) return sprite; + sprite = 0x14AE; + + if (peep->nausea > 170) return sprite; + sprite = 0x14AD; + + if (peep->nausea > 140) return sprite; + sprite = 0x14AC; + + if (peep->energy < 46) return sprite; + sprite--; + + if (peep->energy < 70) return sprite; + sprite = 0x14A4; + + for (int i = 37; peep->happiness >= i; i += 37) + { + sprite++; + } + + return sprite; } \ No newline at end of file From 240662ee39f70e6a004d96e1dcc23854f5f05638 Mon Sep 17 00:00:00 2001 From: "Miso Zmiric (Mike Squinter)" Date: Thu, 8 May 2014 19:55:35 +0100 Subject: [PATCH 09/41] another typo fixed :) --- src/config.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config.c b/src/config.c index 125aa5123e..fbff88735c 100644 --- a/src/config.c +++ b/src/config.c @@ -221,7 +221,7 @@ static void config_create_default(char *path) FILE* fp; if (!config_find_rct2_path(gConfig.game_path)) { - MessageBox(NULL, "Unable to find RCT2 installation directory. Please select the directoy where you installed RCT2!", "OpenRCT2", MB_OK); + MessageBox(NULL, "Unable to find RCT2 installation directory. Please select the directory where you installed RCT2!", "OpenRCT2", MB_OK); char *res = directory_browser(); strcpy(gConfig.game_path, res); } From 0c34c3791c1fd9ad69a5034a92ff684a16dedb5c Mon Sep 17 00:00:00 2001 From: Maciek Baron Date: Thu, 8 May 2014 21:48:31 +0100 Subject: [PATCH 10/41] Cleaning up files and code related to windows --- projects/openrct2.vcxproj | 3 ++ projects/openrct2.vcxproj.filters | 9 +++++ src/addresses.h | 2 ++ src/editor.c | 12 +++---- src/game.c | 2 +- src/rct2.c | 4 +-- src/scenario.c | 2 +- src/title.c | 6 ++-- src/window.c | 24 ------------- src/window.h | 21 +++-------- src/window_finances.c | 33 ++++++++++++++++++ src/window_ride_construction.c | 58 +++++++++++++++++++++++++++++++ src/window_staff.c | 39 +++++++++++++++++++++ 13 files changed, 161 insertions(+), 54 deletions(-) create mode 100644 src/window_finances.c create mode 100644 src/window_ride_construction.c create mode 100644 src/window_staff.c diff --git a/projects/openrct2.vcxproj b/projects/openrct2.vcxproj index 3c13ff3f2b..8438e163f6 100644 --- a/projects/openrct2.vcxproj +++ b/projects/openrct2.vcxproj @@ -93,9 +93,12 @@ + + + diff --git a/projects/openrct2.vcxproj.filters b/projects/openrct2.vcxproj.filters index 00a17f947b..c11377bf77 100644 --- a/projects/openrct2.vcxproj.filters +++ b/projects/openrct2.vcxproj.filters @@ -281,6 +281,15 @@ Source Files + + Windows + + + Windows + + + Windows + diff --git a/src/addresses.h b/src/addresses.h index 2ec02b5edd..0917bbfe59 100644 --- a/src/addresses.h +++ b/src/addresses.h @@ -228,6 +228,8 @@ #define RCT2_ADDRESS_WINDOW_STAFF_LIST_SELECTED_TAB 0x00F4390A +#define RCT2_ADDRESS_WINDOW_MAP_SELECTED_TAB 0x014209E4 + #define RCT2_ADDRESS_OS_TIME_MINUTE 0x01424654 #define RCT2_ADDRESS_OS_TIME_HOUR 0x01424656 #define RCT2_ADDRESS_OS_TIME_DAY 0x01424304 diff --git a/src/editor.c b/src/editor.c index 9f07f326af..57ec041be7 100644 --- a/src/editor.c +++ b/src/editor.c @@ -58,11 +58,11 @@ void editor_load() finance_init(); date_reset(); window_guest_list_init_vars_b(); - RCT2_GLOBAL(RCT2_ADDRESS_WINDOW_STAFF_LIST_SELECTED_TAB, uint8) = WINDOW_STAFF_LIST_TAB_HANDYMEN; + window_staff_init_vars(); 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; - window_ride_list_init_vars(); + window_ride_construction_init_vars(); RCT2_GLOBAL(0x0141F571, uint8) = 4; viewport_init_all(); news_item_init_queue(); @@ -107,10 +107,10 @@ void trackdesigner_load() finance_init(); date_reset(); window_guest_list_init_vars_b(); - RCT2_GLOBAL(RCT2_ADDRESS_WINDOW_STAFF_LIST_SELECTED_TAB, uint8) = WINDOW_STAFF_LIST_TAB_HANDYMEN; + window_staff_init_vars(); RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) = SCREEN_FLAGS_TRACK_DESIGNER; RCT2_GLOBAL(0x0141F570, uint8) = 0; - window_ride_list_init_vars(); + window_ride_construction_init_vars(); viewport_init_all(); news_item_init_queue(); RCT2_CALLPROC_EBPSAFE(0x0066EF38); // window_main_editor_create @@ -145,10 +145,10 @@ void trackmanager_load() finance_init(); date_reset(); window_guest_list_init_vars_b(); - RCT2_GLOBAL(RCT2_ADDRESS_WINDOW_STAFF_LIST_SELECTED_TAB, uint8) = WINDOW_STAFF_LIST_TAB_HANDYMEN; + window_staff_init_vars(); RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) = SCREEN_FLAGS_TRACK_MANAGER; RCT2_GLOBAL(0x0141F570, uint8) = 0; - window_ride_list_init_vars(); + window_ride_construction_init_vars(); viewport_init_all(); news_item_init_queue(); RCT2_CALLPROC_EBPSAFE(0x0066EF38); // window_main_editor_create diff --git a/src/game.c b/src/game.c index c734617582..9d7611bbc3 100644 --- a/src/game.c +++ b/src/game.c @@ -1298,7 +1298,7 @@ int game_load_save() RCT2_CALLPROC_EBPSAFE(0x0069E9A7); RCT2_CALLPROC_EBPSAFE(0x006DFEE4); - window_ride_list_init_vars(); + window_ride_construction_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 be54cd7306..a16180c282 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); - window_ride_list_init_vars(); + window_ride_construction_init_vars(); window_guest_list_init_vars_b(); - RCT2_GLOBAL(RCT2_ADDRESS_WINDOW_STAFF_LIST_SELECTED_TAB, uint8) = WINDOW_STAFF_LIST_TAB_HANDYMEN; + window_staff_init_vars(); title_load(); diff --git a/src/scenario.c b/src/scenario.c index 4d2b409bdb..0752ea39df 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); - window_ride_list_init_vars(); + window_ride_construction_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 fc6ef67aa5..e32641a20b 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); - window_ride_list_init_vars(); + window_ride_construction_init_vars(); window_guest_list_init_vars_b(); - RCT2_GLOBAL(RCT2_ADDRESS_WINDOW_STAFF_LIST_SELECTED_TAB, uint8) = WINDOW_STAFF_LIST_TAB_HANDYMEN; + window_staff_init_vars(); 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); - window_ride_list_init_vars(); + window_ride_construction_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 a35da16b81..0a7f726040 100644 --- a/src/window.c +++ b/src/window.c @@ -1203,28 +1203,4 @@ 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 3b80f58142..956507fa1e 100644 --- a/src/window.h +++ b/src/window.h @@ -284,22 +284,6 @@ 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(); @@ -369,6 +353,9 @@ void window_cheats_open(); void window_guest_list_init_vars_a(); void window_guest_list_init_vars_b(); -void window_ride_list_init_vars(); + +void window_ride_construction_init_vars(); + +void window_staff_init_vars(); #endif diff --git a/src/window_finances.c b/src/window_finances.c new file mode 100644 index 0000000000..a2244518dd --- /dev/null +++ b/src/window_finances.c @@ -0,0 +1,33 @@ +/***************************************************************************** +* Copyright (c) 2014 Maciek Baron +* 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 "window.h" + +enum { + WINDOW_FINANCES_TAB_SUMMARY, + WINDOW_FINANCES_TAB_FINANCIAL_GRAPH, + WINDOW_FINANCES_TAB_VALUE_GRAPH, + WINDOW_FINANCES_TAB_PROFIT_GRAPH, + WINDOW_FINANCES_TAB_MARKETING, + WINDOW_FINANCES_TAB_RESEARCH +} WINDOW_FINANCIAL_TAB; \ No newline at end of file diff --git a/src/window_ride_construction.c b/src/window_ride_construction.c new file mode 100644 index 0000000000..35b813ac78 --- /dev/null +++ b/src/window_ride_construction.c @@ -0,0 +1,58 @@ +/***************************************************************************** +* Copyright (c) 2014 Maciek Baron +* 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 "window.h" + +enum { + WINDOW_RIDE_CONSTRUCTION_TAB_TRANSPORT, + WINDOW_RIDE_CONSTRUCTION_TAB_GENTLE, + WINDOW_RIDE_CONSTRUCTION_TAB_ROLLER_COASTER, + WINDOW_RIDE_CONSTRUCTION_TAB_THRILL, + WINDOW_RIDE_CONSTRUCTION_TAB_WATER, + WINDOW_RIDE_CONSTRUCTION_TAB_SHOP, + WINDOW_RIDE_CONSTRUCTION_TAB_RESEARCH +} WINDOW_RIDE_CONSTRUCTION_TAB; + +/** +* +* rct2: 0x006ACA58 +*/ +void window_ride_construction_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_CONSTRUCTION_TAB_ROLLER_COASTER; + } + else { + RCT2_GLOBAL(RCT2_ADDRESS_WINDOW_RIDE_LIST_SELECTED_TAB, uint8) = WINDOW_RIDE_CONSTRUCTION_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_staff.c b/src/window_staff.c new file mode 100644 index 0000000000..3652084e9d --- /dev/null +++ b/src/window_staff.c @@ -0,0 +1,39 @@ +/***************************************************************************** +* Copyright (c) 2014 Maciek Baron +* 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 "window.h" + +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; + + +/* +* rct2: 0x006BD39C +**/ +void window_staff_init_vars() { + RCT2_GLOBAL(RCT2_ADDRESS_WINDOW_STAFF_LIST_SELECTED_TAB, uint8) = WINDOW_STAFF_LIST_TAB_HANDYMEN; +} \ No newline at end of file From 1eda151c704278e17de7b0ee88849342706b2bbc Mon Sep 17 00:00:00 2001 From: ddevrien Date: Fri, 9 May 2014 10:04:40 +0200 Subject: [PATCH 11/41] Added basic code for banner window --- projects/openrct2.vcxproj | 1 + projects/openrct2.vcxproj.filters | 3 + src/window.h | 2 + src/window_banner.c | 211 ++++++++++++++++++++++++++++++ src/window_cheats.c | 4 +- 5 files changed, 220 insertions(+), 1 deletion(-) create mode 100644 src/window_banner.c diff --git a/projects/openrct2.vcxproj b/projects/openrct2.vcxproj index 3c13ff3f2b..ba0b2c85a4 100644 --- a/projects/openrct2.vcxproj +++ b/projects/openrct2.vcxproj @@ -96,6 +96,7 @@ + diff --git a/projects/openrct2.vcxproj.filters b/projects/openrct2.vcxproj.filters index 00a17f947b..e542a6e094 100644 --- a/projects/openrct2.vcxproj.filters +++ b/projects/openrct2.vcxproj.filters @@ -281,6 +281,9 @@ Source Files + + Windows + diff --git a/src/window.h b/src/window.h index 1aefaf65e4..21d7321eb4 100644 --- a/src/window.h +++ b/src/window.h @@ -275,6 +275,7 @@ enum { WC_CHANGE_KEYBOARD_SHORTCUT = 37, WC_MAP = 38, WC_TITLE_LOGO = 39, + WC_BANNER = 40, WC_EDITOR_OBJECT_SELECTION = 42, WC_EDITOR_INVENTION_LIST = 43, WC_EDITOR_SCENARIO_OPTIONS = 45, @@ -345,6 +346,7 @@ void window_guest_list_open(); void window_park_entrance_open(); void window_park_objective_open(); void window_ride_list_open(); +void window_banner_open(); void window_cheats_open(); void window_guest_list_init_vars_a(); diff --git a/src/window_banner.c b/src/window_banner.c new file mode 100644 index 0000000000..d8fc973a20 --- /dev/null +++ b/src/window_banner.c @@ -0,0 +1,211 @@ +/***************************************************************************** + * Copyright (c) 2014 Ted John, Dennis Devriendt + * 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 "strings.h" +#include "widget.h" +#include "window.h" + +static enum WINDOW_CLEAR_SCENERY_WIDGET_IDX { + WIDX_BACKGROUND, + WIDX_TITLE, + WIDX_CLOSE, + WIDX_VIEWPORT, + WIDX_BANNER_TEXT, + WIDX_BANNER_NO_ENTRY, + WIDX_BANNER_DEMOLISH, + WIDX_MAIN_COLOR, + WIDX_TEXT_COLOR_DROPDOWN, + WIDX_TEXT_COLOR_DROPDOWN_BUTTON +}; + +static rct_widget window_banner_widgets[] = { + { WWT_FRAME, 0, 0, 112, 0, 95, 0x0FFFFFFFF, 65535}, // panel / background + { WWT_CAPTION, 0, 1, 111, 1, 14, 0xBA9, STR_WINDOW_TITLE_TIP}, // title bar + { WWT_CLOSEBOX, 0, 100, 110, 2, 13, 0x338, STR_CLOSE_WINDOW_TIP}, // close x button + { WWT_VIEWPORT, 1, 3, 87, 17, 76, 0x0FFFFFFFE, 65535}, // tab content panel + { WWT_FLATBTN, 1, 88, 111, 19, 42, 0x1430, STR_CHANGE_BANNER_TEXT_TIP}, // change banner button + { WWT_FLATBTN, 1, 88, 111, 43, 66, 0x143A, STR_SET_AS_NO_ENTRY_BANNER_TIP}, // no entry button + { WWT_FLATBTN, 1, 88, 111, 67, 90, 0x142D, STR_DEMOLISH_BANNER_TIP}, // demolish button + { WWT_COLORBTN, 1, 5, 16, 80, 91, 0x0FFFFFFFF, STR_SELECT_MAIN_COLOR_TIP}, // high money + { WWT_DROPDOWN, 1, 43, 81, 80, 91, 0x0FFFFFFFF, 65535}, // high money + { WWT_DROPDOWN_BUTTON, 1, 70, 80, 81, 90, 0x36C, STR_SELECT_TEXT_COLOR_TIP}, // high money + { WIDGETS_END }, +}; + +static void window_banner_emptysub() { } +static void window_banner_mouseup(); +static void window_banner_mousedown(); +static void window_banner_dropdown(); +static void window_banner_textinput(); +static void window_banner_invalidate(); +static void window_banner_paint(); + +static uint32 window_banner_events[] = { + window_banner_emptysub, + window_banner_mouseup, + window_banner_emptysub, + window_banner_mousedown, + window_banner_dropdown, + window_banner_emptysub, + window_banner_emptysub, + window_banner_emptysub, + window_banner_emptysub, + window_banner_emptysub, + window_banner_emptysub, + window_banner_emptysub, + window_banner_emptysub, + window_banner_emptysub, + window_banner_emptysub, + window_banner_emptysub, + window_banner_emptysub, + window_banner_emptysub, + window_banner_emptysub, + window_banner_textinput, + 0x006BA7B5, //sub_6BA7B5 + window_banner_emptysub, + window_banner_emptysub, + window_banner_emptysub, + window_banner_emptysub, + window_banner_invalidate, + window_banner_paint, + window_banner_emptysub +}; + +/** +* +* rct2: 0x006BA305 +*/ +void window_banner_open() +{ + rct_window* w; + + // Check if window is already open + w = window_bring_to_front_by_id(WC_BANNER, 0); + if (w != NULL) + return; + + w = window_create_auto_pos(113, 96, window_banner_events, WC_BANNER, 0); + w->widgets = window_banner_widgets; + w->enabled_widgets = + (1 << WIDX_CLOSE) | + (1 << WIDX_BANNER_TEXT) | + (1 << WIDX_BANNER_NO_ENTRY) | + (1 << WIDX_BANNER_DEMOLISH) | + (1 << WIDX_MAIN_COLOR) | + (1 << WIDX_TEXT_COLOR_DROPDOWN) | + (1 << WIDX_TEXT_COLOR_DROPDOWN_BUTTON); + + window_init_scroll_widgets(w); + w->colours[0] = 24; + w->colours[1] = 24; + w->colours[2] = 24; + + // loc_6BA43E + w->flags |= WF_TRANSPARENT; + window_invalidate(w); +} + +static void window_banner_mouseup() +{ + short widgetIndex; + rct_window *w; + + __asm mov widgetIndex, dx + __asm mov w, esi + + switch (widgetIndex) { + case WIDX_CLOSE: + window_close(w); + break; + case WIDX_BANNER_DEMOLISH: + RCT2_CALLPROC_EBPSAFE(0x006BA739); + break; + case WIDX_BANNER_TEXT: + RCT2_CALLPROC_EBPSAFE(0x006BA6BC); + break; + case WIDX_BANNER_NO_ENTRY: + RCT2_CALLPROC_EBPSAFE(0x006BA64D); + break; + } +} + +static void window_banner_mousedown() +{ + short widgetIndex; + rct_window *w; + + __asm mov widgetIndex, dx + __asm mov w, esi + + switch (widgetIndex) { + case WIDX_MAIN_COLOR: + RCT2_CALLPROC_EBPSAFE(0x006BA528); + break; + case WIDX_TEXT_COLOR_DROPDOWN_BUTTON: + RCT2_CALLPROC_EBPSAFE(0x006BA563); + break; + } +} + +static void window_banner_dropdown() +{ + short widgetIndex; + + __asm mov widgetIndex, dx; + + if (widgetIndex == WIDX_MAIN_COLOR) + RCT2_CALLPROC_EBPSAFE(0x006BA548); + else if (widgetIndex == WIDX_TEXT_COLOR_DROPDOWN_BUTTON) + RCT2_CALLPROC_EBPSAFE(0x006BA5D0); +} + +static void window_banner_textinput() +{ + short widgetIndex; + + __asm mov widgetIndex, dx; + + if (widgetIndex == WIDX_BANNER_TEXT) { + RCT2_CALLPROC_EBPSAFE(0x006BA6D8); + } +} + +static void window_banner_invalidate() +{ + RCT2_CALLPROC_EBPSAFE(0x006BA44D); +} + +static void window_banner_paint() +{ + rct_window *w; + rct_drawpixelinfo *dpi; + + __asm mov w, esi + __asm mov dpi, edi + + window_draw_widgets(w, dpi); + + // Draw viewport + if (w->viewport != NULL) { + window_draw_viewport(dpi, w); + } +} diff --git a/src/window_cheats.c b/src/window_cheats.c index 4e9b188f53..50385e2ad3 100644 --- a/src/window_cheats.c +++ b/src/window_cheats.c @@ -28,7 +28,6 @@ #include "widget.h" #include "window.h" - #define WW 200 #define WH 128 #define CHEATS_MONEY_INCREMENT 10000 @@ -207,6 +206,9 @@ static void window_cheats_money_mouseup() window_invalidate_by_id(0x40 | WC_BOTTOM_TOOLBAR, 0); break; } + + window_park_entrance_open(); + window_banner_open(); } static void window_cheats_guests_mouseup() From 3eff5ebf6f005a3f9ebd0e4434f8ecbf0b30a1cb Mon Sep 17 00:00:00 2001 From: ddevrien Date: Fri, 9 May 2014 10:04:40 +0200 Subject: [PATCH 12/41] Added basic code for banner window --- src/window.h | 2 + src/window_banner.c | 211 ++++++++++++++++++++++++++++++++++++++++++++ src/window_cheats.c | 4 +- 3 files changed, 216 insertions(+), 1 deletion(-) create mode 100644 src/window_banner.c diff --git a/src/window.h b/src/window.h index 956507fa1e..01ce98f35c 100644 --- a/src/window.h +++ b/src/window.h @@ -275,6 +275,7 @@ enum { WC_CHANGE_KEYBOARD_SHORTCUT = 37, WC_MAP = 38, WC_TITLE_LOGO = 39, + WC_BANNER = 40, WC_EDITOR_OBJECT_SELECTION = 42, WC_EDITOR_INVENTION_LIST = 43, WC_EDITOR_SCENARIO_OPTIONS = 45, @@ -349,6 +350,7 @@ void window_park_guests_open(); void window_park_objective_open(); void window_park_rating_open(); void window_ride_list_open(); +void window_banner_open(); void window_cheats_open(); void window_guest_list_init_vars_a(); diff --git a/src/window_banner.c b/src/window_banner.c new file mode 100644 index 0000000000..d8fc973a20 --- /dev/null +++ b/src/window_banner.c @@ -0,0 +1,211 @@ +/***************************************************************************** + * Copyright (c) 2014 Ted John, Dennis Devriendt + * 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 "strings.h" +#include "widget.h" +#include "window.h" + +static enum WINDOW_CLEAR_SCENERY_WIDGET_IDX { + WIDX_BACKGROUND, + WIDX_TITLE, + WIDX_CLOSE, + WIDX_VIEWPORT, + WIDX_BANNER_TEXT, + WIDX_BANNER_NO_ENTRY, + WIDX_BANNER_DEMOLISH, + WIDX_MAIN_COLOR, + WIDX_TEXT_COLOR_DROPDOWN, + WIDX_TEXT_COLOR_DROPDOWN_BUTTON +}; + +static rct_widget window_banner_widgets[] = { + { WWT_FRAME, 0, 0, 112, 0, 95, 0x0FFFFFFFF, 65535}, // panel / background + { WWT_CAPTION, 0, 1, 111, 1, 14, 0xBA9, STR_WINDOW_TITLE_TIP}, // title bar + { WWT_CLOSEBOX, 0, 100, 110, 2, 13, 0x338, STR_CLOSE_WINDOW_TIP}, // close x button + { WWT_VIEWPORT, 1, 3, 87, 17, 76, 0x0FFFFFFFE, 65535}, // tab content panel + { WWT_FLATBTN, 1, 88, 111, 19, 42, 0x1430, STR_CHANGE_BANNER_TEXT_TIP}, // change banner button + { WWT_FLATBTN, 1, 88, 111, 43, 66, 0x143A, STR_SET_AS_NO_ENTRY_BANNER_TIP}, // no entry button + { WWT_FLATBTN, 1, 88, 111, 67, 90, 0x142D, STR_DEMOLISH_BANNER_TIP}, // demolish button + { WWT_COLORBTN, 1, 5, 16, 80, 91, 0x0FFFFFFFF, STR_SELECT_MAIN_COLOR_TIP}, // high money + { WWT_DROPDOWN, 1, 43, 81, 80, 91, 0x0FFFFFFFF, 65535}, // high money + { WWT_DROPDOWN_BUTTON, 1, 70, 80, 81, 90, 0x36C, STR_SELECT_TEXT_COLOR_TIP}, // high money + { WIDGETS_END }, +}; + +static void window_banner_emptysub() { } +static void window_banner_mouseup(); +static void window_banner_mousedown(); +static void window_banner_dropdown(); +static void window_banner_textinput(); +static void window_banner_invalidate(); +static void window_banner_paint(); + +static uint32 window_banner_events[] = { + window_banner_emptysub, + window_banner_mouseup, + window_banner_emptysub, + window_banner_mousedown, + window_banner_dropdown, + window_banner_emptysub, + window_banner_emptysub, + window_banner_emptysub, + window_banner_emptysub, + window_banner_emptysub, + window_banner_emptysub, + window_banner_emptysub, + window_banner_emptysub, + window_banner_emptysub, + window_banner_emptysub, + window_banner_emptysub, + window_banner_emptysub, + window_banner_emptysub, + window_banner_emptysub, + window_banner_textinput, + 0x006BA7B5, //sub_6BA7B5 + window_banner_emptysub, + window_banner_emptysub, + window_banner_emptysub, + window_banner_emptysub, + window_banner_invalidate, + window_banner_paint, + window_banner_emptysub +}; + +/** +* +* rct2: 0x006BA305 +*/ +void window_banner_open() +{ + rct_window* w; + + // Check if window is already open + w = window_bring_to_front_by_id(WC_BANNER, 0); + if (w != NULL) + return; + + w = window_create_auto_pos(113, 96, window_banner_events, WC_BANNER, 0); + w->widgets = window_banner_widgets; + w->enabled_widgets = + (1 << WIDX_CLOSE) | + (1 << WIDX_BANNER_TEXT) | + (1 << WIDX_BANNER_NO_ENTRY) | + (1 << WIDX_BANNER_DEMOLISH) | + (1 << WIDX_MAIN_COLOR) | + (1 << WIDX_TEXT_COLOR_DROPDOWN) | + (1 << WIDX_TEXT_COLOR_DROPDOWN_BUTTON); + + window_init_scroll_widgets(w); + w->colours[0] = 24; + w->colours[1] = 24; + w->colours[2] = 24; + + // loc_6BA43E + w->flags |= WF_TRANSPARENT; + window_invalidate(w); +} + +static void window_banner_mouseup() +{ + short widgetIndex; + rct_window *w; + + __asm mov widgetIndex, dx + __asm mov w, esi + + switch (widgetIndex) { + case WIDX_CLOSE: + window_close(w); + break; + case WIDX_BANNER_DEMOLISH: + RCT2_CALLPROC_EBPSAFE(0x006BA739); + break; + case WIDX_BANNER_TEXT: + RCT2_CALLPROC_EBPSAFE(0x006BA6BC); + break; + case WIDX_BANNER_NO_ENTRY: + RCT2_CALLPROC_EBPSAFE(0x006BA64D); + break; + } +} + +static void window_banner_mousedown() +{ + short widgetIndex; + rct_window *w; + + __asm mov widgetIndex, dx + __asm mov w, esi + + switch (widgetIndex) { + case WIDX_MAIN_COLOR: + RCT2_CALLPROC_EBPSAFE(0x006BA528); + break; + case WIDX_TEXT_COLOR_DROPDOWN_BUTTON: + RCT2_CALLPROC_EBPSAFE(0x006BA563); + break; + } +} + +static void window_banner_dropdown() +{ + short widgetIndex; + + __asm mov widgetIndex, dx; + + if (widgetIndex == WIDX_MAIN_COLOR) + RCT2_CALLPROC_EBPSAFE(0x006BA548); + else if (widgetIndex == WIDX_TEXT_COLOR_DROPDOWN_BUTTON) + RCT2_CALLPROC_EBPSAFE(0x006BA5D0); +} + +static void window_banner_textinput() +{ + short widgetIndex; + + __asm mov widgetIndex, dx; + + if (widgetIndex == WIDX_BANNER_TEXT) { + RCT2_CALLPROC_EBPSAFE(0x006BA6D8); + } +} + +static void window_banner_invalidate() +{ + RCT2_CALLPROC_EBPSAFE(0x006BA44D); +} + +static void window_banner_paint() +{ + rct_window *w; + rct_drawpixelinfo *dpi; + + __asm mov w, esi + __asm mov dpi, edi + + window_draw_widgets(w, dpi); + + // Draw viewport + if (w->viewport != NULL) { + window_draw_viewport(dpi, w); + } +} diff --git a/src/window_cheats.c b/src/window_cheats.c index 4e9b188f53..50385e2ad3 100644 --- a/src/window_cheats.c +++ b/src/window_cheats.c @@ -28,7 +28,6 @@ #include "widget.h" #include "window.h" - #define WW 200 #define WH 128 #define CHEATS_MONEY_INCREMENT 10000 @@ -207,6 +206,9 @@ static void window_cheats_money_mouseup() window_invalidate_by_id(0x40 | WC_BOTTOM_TOOLBAR, 0); break; } + + window_park_entrance_open(); + window_banner_open(); } static void window_cheats_guests_mouseup() From 6eb635fd2b7592281b79b796cf5d1fd276cec8ea Mon Sep 17 00:00:00 2001 From: ddevrien Date: Fri, 9 May 2014 10:15:10 +0200 Subject: [PATCH 13/41] master project files --- projects/openrct2.vcxproj | 4 ---- projects/openrct2.vcxproj.filters | 4 ---- 2 files changed, 8 deletions(-) diff --git a/projects/openrct2.vcxproj b/projects/openrct2.vcxproj index 094b40be3e..8438e163f6 100644 --- a/projects/openrct2.vcxproj +++ b/projects/openrct2.vcxproj @@ -98,11 +98,7 @@ -<<<<<<< HEAD -======= - ->>>>>>> 1eda151c704278e17de7b0ee88849342706b2bbc diff --git a/projects/openrct2.vcxproj.filters b/projects/openrct2.vcxproj.filters index c505b74ce7..c11377bf77 100644 --- a/projects/openrct2.vcxproj.filters +++ b/projects/openrct2.vcxproj.filters @@ -281,7 +281,6 @@ Source Files -<<<<<<< HEAD Windows @@ -289,9 +288,6 @@ Windows -======= - ->>>>>>> 1eda151c704278e17de7b0ee88849342706b2bbc Windows From 45f78eded4bef89acba56eaf5f0ab5698d7c2936 Mon Sep 17 00:00:00 2001 From: atmaxinger Date: Fri, 9 May 2014 11:40:06 +0200 Subject: [PATCH 14/41] Moved platform specific UI code (MessageBox, DirectoryChooser) into osinterface.c --- src/config.c | 52 +++++------------------------------------------ src/osinterface.c | 49 +++++++++++++++++++++++++++++++++++++++++++- src/osinterface.h | 2 ++ src/rct2.c | 2 +- 4 files changed, 56 insertions(+), 49 deletions(-) diff --git a/src/config.c b/src/config.c index af8ac6ca44..c29c7ff622 100644 --- a/src/config.c +++ b/src/config.c @@ -27,6 +27,8 @@ #include "rct2.h" #include +#include "osinterface.h" + // Current keyboard shortcuts uint16 gShortcutKeys[SHORTCUT_COUNT]; @@ -230,8 +232,8 @@ static void config_create_default(char *path) FILE* fp; if (!config_find_rct2_path(gConfig.game_path)) { - MessageBox(NULL, "Unable to find RCT2 installation directory. Please select the directoy where you installed RCT2!", "OpenRCT2", MB_OK); - char *res = config_show_directory_browser(); + osinterface_show_messagebox("Unable to find RCT2 installation directory. Please select the directoy where you installed RCT2!"); + char *res = osinterface_open_directory_browser("Please select your RCT2 directory"); strcpy(gConfig.game_path, res); } @@ -243,50 +245,6 @@ static void config_create_default(char *path) fclose(fp); } -/** - * A directory browser allowing for semi-automatic config.ini for non standard installs. - */ -static char *config_show_directory_browser() -{ - BROWSEINFO bi; - char pszBuffer[MAX_PATH]; - LPITEMIDLIST pidl; - LPMALLOC lpMalloc; - - // Initialize COM - if (CoInitializeEx(0, COINIT_APARTMENTTHREADED) != S_OK) { - MessageBox(NULL, _T("Error opening browse window"), _T("ERROR"), MB_OK); - CoUninitialize(); - return 0; - } - - // Get a pointer to the shell memory allocator - if (SHGetMalloc(&lpMalloc) != S_OK) { - MessageBox(NULL, _T("Error opening browse window"), _T("ERROR"), MB_OK); - CoUninitialize(); - return 0; - } - - bi.hwndOwner = NULL; - bi.pidlRoot = NULL; - bi.pszDisplayName = pszBuffer; - bi.lpszTitle = _T("Select your RCT2 installation directory"); - bi.ulFlags = BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS; - bi.lpfn = NULL; - bi.lParam = 0; - - char *outPath = "C:\\"; - - if (pidl = SHBrowseForFolder(&bi)) { - // Copy the path directory to the buffer - if (SHGetPathFromIDList(pidl, pszBuffer)) { - // Store pszBuffer (and the path) in the outPath - outPath = strcat("", pszBuffer); - } - } - CoUninitialize(); - return outPath; -} /** * Parse settings and set the game veriables @@ -505,7 +463,7 @@ static int config_parse_section(FILE *fp, char *setting, char *value){ * @param msg Message to print in message box */ static void config_error(char *msg){ - MessageBox(NULL, msg, "OpenRCT2", MB_OK); + osinterface_show_messagebox(msg); //TODO:SHUT DOWN EVERYTHING! } diff --git a/src/osinterface.c b/src/osinterface.c index 3e97491e5b..760f73bf63 100644 --- a/src/osinterface.c +++ b/src/osinterface.c @@ -19,6 +19,8 @@ *****************************************************************************/ #include +#include +#include #include #include #include @@ -348,4 +350,49 @@ int osinterface_open_common_file_dialog(int type, char *title, char *filename, c RCT2_GLOBAL(0x009E2C74, uint32) = tmp; return result; -} \ No newline at end of file +} + +void osinterface_show_messagebox(char* message){ + MessageBox(NULL, message, "OpenRCT2", MB_OK); +} + +char* osinterface_open_directory_browser(char *title) { + BROWSEINFO bi; + char pszBuffer[MAX_PATH]; + LPITEMIDLIST pidl; + LPMALLOC lpMalloc; + + // Initialize COM + if (CoInitializeEx(0, COINIT_APARTMENTTHREADED) != S_OK) { + MessageBox(NULL, _T("Error opening browse window"), _T("ERROR"), MB_OK); + CoUninitialize(); + return 0; + } + + // Get a pointer to the shell memory allocator + if (SHGetMalloc(&lpMalloc) != S_OK) { + MessageBox(NULL, _T("Error opening browse window"), _T("ERROR"), MB_OK); + CoUninitialize(); + return 0; + } + + bi.hwndOwner = NULL; + bi.pidlRoot = NULL; + bi.pszDisplayName = pszBuffer; + bi.lpszTitle = _T(title); + bi.ulFlags = BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS; + bi.lpfn = NULL; + bi.lParam = 0; + + char *outPath = "C:\\"; + + if (pidl = SHBrowseForFolder(&bi)) { + // Copy the path directory to the buffer + if (SHGetPathFromIDList(pidl, pszBuffer)) { + // Store pszBuffer (and the path) in the outPath + outPath = strcat("", pszBuffer); + } + } + CoUninitialize(); + return outPath; +} diff --git a/src/osinterface.h b/src/osinterface.h index 9ec682fea2..a42da3c6d3 100644 --- a/src/osinterface.h +++ b/src/osinterface.h @@ -47,5 +47,7 @@ void osinterface_draw(); void osinterface_free(); int osinterface_open_common_file_dialog(int type, char *title, char *filename, char *filterPattern, char *filterName); +void osinterface_show_messagebox(char* message); +char* osinterface_open_directory_browser(char *title); #endif diff --git a/src/rct2.c b/src/rct2.c index a16180c282..f586b16230 100644 --- a/src/rct2.c +++ b/src/rct2.c @@ -151,7 +151,7 @@ void rct2_init_directories() // check install directory DWORD dwAttrib = GetFileAttributes(gConfig.game_path); if (dwAttrib == INVALID_FILE_ATTRIBUTES || !(dwAttrib & FILE_ATTRIBUTE_DIRECTORY)) { - MessageBox(NULL, "Invalid RCT2 installation path. Please correct in config.ini.", "OpenRCT2", MB_OK); + osinterface_show_messagebox("Invalid RCT2 installation path. Please correct in config.ini."); exit(-1); } From 6ddeb610f0dadf403eeedf1e60183c5f2ab8f4e1 Mon Sep 17 00:00:00 2001 From: ddevrien Date: Fri, 9 May 2014 20:59:41 +0200 Subject: [PATCH 15/41] Some additions to window_banner --- projects/openrct2.vcxproj | 1 + projects/openrct2.vcxproj.filters | 3 +++ src/window_banner.c | 35 +++++++++++++++++++++++++------ 3 files changed, 33 insertions(+), 6 deletions(-) diff --git a/projects/openrct2.vcxproj b/projects/openrct2.vcxproj index 8438e163f6..0bb32ba58a 100644 --- a/projects/openrct2.vcxproj +++ b/projects/openrct2.vcxproj @@ -84,6 +84,7 @@ + diff --git a/projects/openrct2.vcxproj.filters b/projects/openrct2.vcxproj.filters index c11377bf77..973add4e53 100644 --- a/projects/openrct2.vcxproj.filters +++ b/projects/openrct2.vcxproj.filters @@ -290,6 +290,9 @@ Windows + + Windows + diff --git a/src/window_banner.c b/src/window_banner.c index d8fc973a20..e3766a829d 100644 --- a/src/window_banner.c +++ b/src/window_banner.c @@ -20,7 +20,9 @@ #include #include "addresses.h" +#include "config.h" #include "strings.h" +#include "viewport.h" #include "widget.h" #include "window.h" @@ -80,7 +82,7 @@ static uint32 window_banner_events[] = { window_banner_emptysub, window_banner_emptysub, window_banner_textinput, - 0x006BA7B5, //sub_6BA7B5 + 0x006BA7B5, window_banner_emptysub, window_banner_emptysub, window_banner_emptysub, @@ -96,10 +98,16 @@ static uint32 window_banner_events[] = { */ void window_banner_open() { + rct_windownumber windownumber; rct_window* w; + rct_viewport *viewport; + rct_widget *viewportWidget; + + //__asm mov windownumber, ax // not quite right I think + windownumber = 0; // Check if window is already open - w = window_bring_to_front_by_id(WC_BANNER, 0); + w = window_bring_to_front_by_id(WC_BANNER, windownumber); if (w != NULL) return; @@ -114,13 +122,30 @@ void window_banner_open() (1 << WIDX_TEXT_COLOR_DROPDOWN) | (1 << WIDX_TEXT_COLOR_DROPDOWN_BUTTON); + w->number = windownumber; window_init_scroll_widgets(w); w->colours[0] = 24; w->colours[1] = 24; w->colours[2] = 24; - // loc_6BA43E - w->flags |= WF_TRANSPARENT; + /* + TODO: MISSING CODE 006BA377 -> 006BA3F6, need the banner map element + */ + + // Create viewport + viewportWidget = &window_banner_widgets[WIDX_VIEWPORT]; + viewport_create( + w, + w->x + viewportWidget->left + 1, + w->y + viewportWidget->top + 1, + (viewportWidget->right - viewportWidget->left) - 2, + (viewportWidget->bottom - viewportWidget->top) - 2, + 100, // TODO: needs banner map position + 100 // TODO: needs banner map position + ); + + w->viewport->flags = (RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_FLAGS, uint8) & CONFIG_FLAG_ALWAYS_SHOW_GRIDLINES) ? VIEWPORT_FLAG_GRIDLINES : 0; + w->flags |= WF_2 | WF_TRANSPARENT; window_invalidate(w); } @@ -151,10 +176,8 @@ static void window_banner_mouseup() static void window_banner_mousedown() { short widgetIndex; - rct_window *w; __asm mov widgetIndex, dx - __asm mov w, esi switch (widgetIndex) { case WIDX_MAIN_COLOR: From b280675ab57a6a549292cb250ff4f5f4230c56ce Mon Sep 17 00:00:00 2001 From: ddevrien Date: Fri, 9 May 2014 21:03:00 +0200 Subject: [PATCH 16/41] cleanup --- src/window_cheats.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/window_cheats.c b/src/window_cheats.c index 50385e2ad3..4e9b188f53 100644 --- a/src/window_cheats.c +++ b/src/window_cheats.c @@ -28,6 +28,7 @@ #include "widget.h" #include "window.h" + #define WW 200 #define WH 128 #define CHEATS_MONEY_INCREMENT 10000 @@ -206,9 +207,6 @@ static void window_cheats_money_mouseup() window_invalidate_by_id(0x40 | WC_BOTTOM_TOOLBAR, 0); break; } - - window_park_entrance_open(); - window_banner_open(); } static void window_cheats_guests_mouseup() From b2d1f0dfd6a9b9a00d85f36e9e3231e506cc630d Mon Sep 17 00:00:00 2001 From: ZedThree Date: Fri, 9 May 2014 12:54:11 +0200 Subject: [PATCH 17/41] Add functions for closing top/all window(s) --- src/window.c | 45 +++++++++++++++++++++++++++++++++++++++++++-- src/window.h | 2 ++ 2 files changed, 45 insertions(+), 2 deletions(-) diff --git a/src/window.c b/src/window.c index 0a7f726040..9ce9708cdf 100644 --- a/src/window.c +++ b/src/window.c @@ -1,5 +1,5 @@ /***************************************************************************** -* Copyright (c) 2014 Ted John +* Copyright (c) 2014 Ted John, Peter Hill * OpenRCT2, an open source clone of Roller Coaster Tycoon 2. * * This file is part of OpenRCT2. @@ -493,6 +493,47 @@ rct_window *window_find_by_id(rct_windowclass cls, rct_windownumber number) return NULL; } +/** + * Closes the top-most window + * + * rct2: 0x006E403C + */ +void window_close_top() { + rct_window* w; + + window_close_by_id(WC_DROPDOWN, 0); + + if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) { + if (RCT2_ADDRESS(0x0141F570, uint8) != 1) { + return; + } + } + for (w = RCT2_FIRST_WINDOW; w < RCT2_LAST_WINDOW; w++){ + if (!(w->flags & (WF_STICK_TO_BACK | WF_STICK_TO_FRONT))) { + window_close(w); + return; + } + } +} + +/** + * Closes all open windows + * + * rct2: 0x006EE927 + */ +void window_close_all() { + rct_window* w; + + window_close_by_id(WC_DROPDOWN, 0); + + for (w = RCT2_FIRST_WINDOW; w < RCT2_LAST_WINDOW; w++){ + if (!(w->flags & (WF_STICK_TO_BACK | WF_STICK_TO_FRONT))) { + window_close(w); + w = RCT2_FIRST_WINDOW; + } + } +} + /** * * rct2: 0x006EA845 @@ -1203,4 +1244,4 @@ 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; -} \ No newline at end of file +} diff --git a/src/window.h b/src/window.h index 956507fa1e..a9dad108d6 100644 --- a/src/window.h +++ b/src/window.h @@ -291,6 +291,8 @@ rct_window *window_create(int x, int y, int width, int height, uint32 *event_han rct_window *window_create_auto_pos(int width, int height, uint32 *event_handlers, rct_windowclass cls, uint16 flags); void window_close(rct_window *window); void window_close_by_id(rct_windowclass cls, rct_windownumber number); +void window_close_top(); +void window_close_all(); rct_window *window_find_by_id(rct_windowclass cls, rct_windownumber number); rct_window *window_find_from_point(int x, int y); int window_find_widget_from_point(rct_window *w, int x, int y); From bc413fede97db2354944913b34e6f9ac4078f847 Mon Sep 17 00:00:00 2001 From: ZedThree Date: Fri, 9 May 2014 18:27:59 +0200 Subject: [PATCH 18/41] Add helper function for calling widget events Add window_event_helper --- src/window.c | 9 +++++++++ src/window.h | 2 ++ 2 files changed, 11 insertions(+) diff --git a/src/window.c b/src/window.c index 9ce9708cdf..f41a874ff6 100644 --- a/src/window.c +++ b/src/window.c @@ -1245,3 +1245,12 @@ void window_guest_list_init_vars_b() { RCT2_GLOBAL(RCT2_ADDRESS_WINDOW_GUEST_LIST_SELECTED_FILTER, uint8) = 0xFF; RCT2_GLOBAL(0x00F1AF20, uint16) = 0; } + +/** + * Wrapper for window events so C functions can call them + */ +void window_event_helper(rct_window* w, short widgetIndex, WINDOW_EVENTS event) { + + RCT2_CALLPROC_X(w->event_handlers[event], 0, 0, 0, widgetIndex, w, 0, 0); + +} diff --git a/src/window.h b/src/window.h index a9dad108d6..faa40a5878 100644 --- a/src/window.h +++ b/src/window.h @@ -360,4 +360,6 @@ void window_ride_construction_init_vars(); void window_staff_init_vars(); +void window_event_helper(rct_window* w, short widgetIndex, WINDOW_EVENTS event); + #endif From 93d062704d0a2b64570e484408b878e526f1980f Mon Sep 17 00:00:00 2001 From: ZedThree Date: Fri, 9 May 2014 09:47:20 +0200 Subject: [PATCH 19/41] Add code to handle shortcuts --- src/game.c | 265 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 257 insertions(+), 8 deletions(-) diff --git a/src/game.c b/src/game.c index 9d7611bbc3..14b0627211 100644 --- a/src/game.c +++ b/src/game.c @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2014 Ted John + * Copyright (c) 2014 Ted John, Peter Hill * OpenRCT2, an open source clone of Roller Coaster Tycoon 2. * * This file is part of OpenRCT2. @@ -870,15 +870,264 @@ int get_next_key() * * rct2: 0x006E3E68 */ -void handle_shortcut(int key) -{ - int i; - for (i = 0; i < 32; i++) { - if (key == gShortcutKeys[i]) { - RCT2_CALLPROC_EBPSAFE(RCT2_ADDRESS(0x006E3FB4, uint32)[i]); - break; +void handle_shortcut(int key) { + + rct_window* window; + + if (key == gShortcutKeys[0]) { + // Close top most window + window_close_top(); + + } else if (key == gShortcutKeys[1]) { + // Close all windows + if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2)) { + window_close_all(); + return; } + if (RCT2_ADDRESS(0x0141F570, uint8) == 1) { + window_close_top(); + } + } else if (key == gShortcutKeys[2]) { + // Cancel construction mode + window = window_find_by_id(WC_ERROR, 0); + if (window != NULL) { + window_close(window); + return; + } + if (RCT2_GLOBAL(0x009DE518, uint32) & (1 << 3)) { + tool_cancel(); + } + } else if (key == gShortcutKeys[3]) { + // Pause + if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 10)) { + window = window_find_by_id(WC_TOP_TOOLBAR, 0); + if (window != NULL) { + window_invalidate(window); + window_event_helper(window, 0, WE_MOUSE_UP); + } + } + } else if (key == gShortcutKeys[4]) { + // Zoom out + if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) { + if (RCT2_ADDRESS(0x0141F570, uint8) != 1) { + return; + } + } + if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 8)) { + window = window_find_by_id(WC_TOP_TOOLBAR, 0); + if (window != NULL) { + window_invalidate(window); + window_event_helper(window, 2, WE_MOUSE_UP); + } + } + } else if (key == gShortcutKeys[5]) { + // Zoom in + if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) { + if (RCT2_ADDRESS(0x0141F570, uint8) != 1) { + return; + } + } + if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 8)) { + window = window_find_by_id(WC_TOP_TOOLBAR, 0); + if (window != NULL) { + window_invalidate(window); + window_event_helper(window, 3, WE_MOUSE_UP); + } + } + } else if (key == gShortcutKeys[6]) { + // Rotate view + if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) { + if (RCT2_ADDRESS(0x0141F570, uint8) != 1) { + return; + } + } + if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 8)) { + window = window_find_by_id(WC_TOP_TOOLBAR, 0); + if (window != NULL) { + window_invalidate(window); + window_event_helper(window, 4, WE_MOUSE_UP); + } + } + } else if (key == gShortcutKeys[7]) { + // Rotate object + RCT2_CALLPROC_EBPSAFE(0x006E4182); + } else if (key == gShortcutKeys[8]) { + // Underground view toggle + RCT2_CALLPROC_X(0x0066CF8A, 0, 0, 0, 0, 0, 0, 0); + } else if (key == gShortcutKeys[9]) { + // Remove base land toggle + RCT2_CALLPROC_X(0x0066CF8A, 1, 0, 0, 0, 0, 0, 0); + } else if (key == gShortcutKeys[10]) { + // Remove vertical land toggle + RCT2_CALLPROC_X(0x0066CF8A, 2, 0, 0, 0, 0, 0, 0); + } else if (key == gShortcutKeys[11]) { + // See through rides toggle + RCT2_CALLPROC_X(0x0066CF8A, 4, 0, 0, 0, 0, 0, 0); + } else if (key == gShortcutKeys[12]) { + // See through scenery toggle + RCT2_CALLPROC_X(0x0066CF8A, 5, 0, 0, 0, 0, 0, 0); + } else if (key == gShortcutKeys[13]) { + // Invisible supports toggle + RCT2_CALLPROC_X(0x0066CF8A, 6, 0, 0, 0, 0, 0, 0); + } else if (key == gShortcutKeys[14]) { + // Invisible people toggle + RCT2_CALLPROC_X(0x0066CF8A, 7, 0, 0, 0, 0, 0, 0); + } else if (key == gShortcutKeys[15]) { + // Height marks on land toggle + RCT2_CALLPROC_X(0x0066CF8A, 9, 0, 0, 0, 0, 0, 0); + } else if (key == gShortcutKeys[16]) { + // Height marks on ride tracks toggle + RCT2_CALLPROC_X(0x0066CF8A, 10, 0, 0, 0, 0, 0, 0); + } else if (key == gShortcutKeys[17]) { + // Height marks on paths toggle + RCT2_CALLPROC_X(0x0066CF8A, 11, 0, 0, 0, 0, 0, 0); + } else if (key == gShortcutKeys[18]) { + // Adjust land + if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) { + if (RCT2_ADDRESS(0x0141F570, uint8) != 1) { + return; + } + } + if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0C)) { + window = window_find_by_id(WC_TOP_TOOLBAR, 0); + if (window != NULL) { + window_invalidate(window); + window_event_helper(window, 7, WE_MOUSE_UP); + } + } + } else if (key == gShortcutKeys[19]) { + // Adjust water + if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) { + if (RCT2_ADDRESS(0x0141F570, uint8) != 1) { + return; + } + } + if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0C)) { + window = window_find_by_id(WC_TOP_TOOLBAR, 0); + if (window != NULL) { + window_invalidate(window); + window_event_helper(window, 8, WE_MOUSE_UP); + } + } + } else if (key == gShortcutKeys[20]) { + // Build scenery + if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) { + if (RCT2_ADDRESS(0x0141F570, uint8) != 1) { + return; + } + } + if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0C)) { + window = window_find_by_id(WC_TOP_TOOLBAR, 0); + if (window != NULL) { + window_invalidate(window); + window_event_helper(window, 9, WE_MOUSE_UP); + } + } + } else if (key == gShortcutKeys[21]) { + // Build paths + if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) { + if (RCT2_ADDRESS(0x0141F570, uint8) != 1) { + return; + } + } + if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0C)) { + window = window_find_by_id(WC_TOP_TOOLBAR, 0); + if (window != NULL) { + window_invalidate(window); + window_event_helper(window, 10, WE_MOUSE_UP); + } + } + } else if (key == gShortcutKeys[22]) { + // Build new ride + if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) { + if (RCT2_ADDRESS(0x0141F570, uint8) != 1) { + return; + } + } + if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0C)) { + window = window_find_by_id(WC_TOP_TOOLBAR, 0); + if (window != NULL) { + window_invalidate(window); + window_event_helper(window, 11, WE_MOUSE_UP); + } + } + } else if (key == gShortcutKeys[23]) { + // Show financial information + if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0C)) { + if (!(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & 0x800)) { + RCT2_CALLPROC_EBPSAFE(0x0069DDF1); + } + } + } else if (key == gShortcutKeys[24]) { + // Show research information + if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0E)) { + // Open new ride window + RCT2_CALLPROC_EBPSAFE(0x006B3CFF); + window = window_find_by_id(WC_CONSTRUCT_RIDE, 0); + if (window != NULL) { + window_event_helper(window, 10, WE_MOUSE_DOWN); + } + } + } else if (key == gShortcutKeys[25]) { + // Show rides list + if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0E)) { + window = window_find_by_id(WC_TOP_TOOLBAR, 0); + if (window != NULL) { + window_invalidate(window); + window_event_helper(window, 12, WE_MOUSE_UP); + } + } + } else if (key == gShortcutKeys[26]) { + // Show park information + if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0E)) { + window = window_find_by_id(WC_TOP_TOOLBAR, 0); + if (window != NULL) { + window_invalidate(window); + window_event_helper(window, 13, WE_MOUSE_UP); + } + } + } else if (key == gShortcutKeys[27]) { + // Show guest list + if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0E)) { + window = window_find_by_id(WC_TOP_TOOLBAR, 0); + if (window != NULL) { + window_invalidate(window); + window_event_helper(window, 15, WE_MOUSE_UP); + } + } + } else if (key == gShortcutKeys[28]) { + // Show staff information + if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0E)) { + window = window_find_by_id(WC_TOP_TOOLBAR, 0); + if (window != NULL) { + window_invalidate(window); + window_event_helper(window, 14, WE_MOUSE_UP); + } + } + } else if (key == gShortcutKeys[29]) { + // Show recent messages + if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0E)) { + window_news_open(); + } + } else if (key == gShortcutKeys[30]) { + // Show map + if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) { + if (RCT2_ADDRESS(0x0141F570, uint8) != 1) { + return; + } + } + if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0C)) { + window = window_find_by_id(WC_TOP_TOOLBAR, 0); + if (window != NULL) { + window_invalidate(window); + window_event_helper(window, 6, WE_MOUSE_UP); + } + } + } else if (key == gShortcutKeys[31]) { + // Screenshot + RCT2_CALLPROC_EBPSAFE(0x006E4034); } + } /** From 2523b1f328a0b56fa9d836362c41dc28bf0663b9 Mon Sep 17 00:00:00 2001 From: ZedThree Date: Fri, 9 May 2014 22:44:55 +0200 Subject: [PATCH 20/41] Fix a couple of window bugs --- src/window_game_top_toolbar.c | 7 ++++--- src/window_guest_list.c | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/window_game_top_toolbar.c b/src/window_game_top_toolbar.c index fa59d02950..afacce3cf1 100644 --- a/src/window_game_top_toolbar.c +++ b/src/window_game_top_toolbar.c @@ -208,9 +208,10 @@ static void window_game_top_toolbar_mouseup() } break; case WIDX_SCENERY: - tool_set(w, WIDX_SCENERY, 0); - RCT2_GLOBAL(0x009DE518, uint32) |= (1 << 6); - RCT2_CALLPROC_EBPSAFE(0x006E0FEF); + if (!tool_set(w, WIDX_SCENERY, 0)) { + RCT2_GLOBAL(0x009DE518, uint32) |= (1 << 6); + RCT2_CALLPROC_EBPSAFE(0x006E0FEF); + } break; case WIDX_PATH: if (window_find_by_id(WC_FOOTPATH, 0) == NULL) { diff --git a/src/window_guest_list.c b/src/window_guest_list.c index 4af11e4dd4..a3f2de1480 100644 --- a/src/window_guest_list.c +++ b/src/window_guest_list.c @@ -142,7 +142,7 @@ void window_guest_list_open() rct_window* window; // Check if window is already open - window = window_bring_to_front_by_id(WC_RIDE_LIST, 0); + window = window_bring_to_front_by_id(WC_GUEST_LIST, 0); if (window != NULL) return; @@ -994,4 +994,4 @@ static int get_guest_face_sprite_large(rct_peep* peep){ } return sprite; -} \ No newline at end of file +} From 3b8f0d685bc8c5a78ef64f795ce8b475e7288d2a Mon Sep 17 00:00:00 2001 From: IntelOrca Date: Fri, 9 May 2014 23:05:50 +0100 Subject: [PATCH 21/41] convert handling shortcut keys to switch --- src/game.c | 361 +++++++++++++++++++--------------------- src/window_guest_list.c | 2 +- 2 files changed, 168 insertions(+), 195 deletions(-) diff --git a/src/game.c b/src/game.c index 14b0627211..1a775dcf4c 100644 --- a/src/game.c +++ b/src/game.c @@ -866,39 +866,28 @@ int get_next_key() return 0; } -/** - * - * rct2: 0x006E3E68 - */ -void handle_shortcut(int key) { +void handle_shortcut_command(int shortcutIndex) +{ + rct_window *window; - rct_window* window; - - if (key == gShortcutKeys[0]) { - // Close top most window + switch (shortcutIndex) { + case SHORTCUT_CLOSE_TOP_MOST_WINDOW: window_close_top(); - - } else if (key == gShortcutKeys[1]) { - // Close all windows - if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2)) { + break; + case SHORTCUT_CLOSE_ALL_FLOATING_WINDOWS: + if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2)) window_close_all(); - return; - } - if (RCT2_ADDRESS(0x0141F570, uint8) == 1) { + else if (RCT2_ADDRESS(0x0141F570, uint8) == 1) window_close_top(); - } - } else if (key == gShortcutKeys[2]) { - // Cancel construction mode + break; + case SHORTCUT_CANCEL_CONSTRUCTION_MODE: window = window_find_by_id(WC_ERROR, 0); - if (window != NULL) { + if (window != NULL) window_close(window); - return; - } - if (RCT2_GLOBAL(0x009DE518, uint32) & (1 << 3)) { + else if (RCT2_GLOBAL(0x009DE518, uint32) & (1 << 3)) tool_cancel(); - } - } else if (key == gShortcutKeys[3]) { - // Pause + break; + case SHORTCUT_PAUSE_GAME: if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 10)) { window = window_find_by_id(WC_TOP_TOOLBAR, 0); if (window != NULL) { @@ -906,228 +895,212 @@ void handle_shortcut(int key) { window_event_helper(window, 0, WE_MOUSE_UP); } } - } else if (key == gShortcutKeys[4]) { - // Zoom out - if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) { - if (RCT2_ADDRESS(0x0141F570, uint8) != 1) { - return; + break; + case SHORTCUT_ZOOM_VIEW_OUT: + if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) || RCT2_ADDRESS(0x0141F570, uint8) == 1) { + if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 8)) { + window = window_find_by_id(WC_TOP_TOOLBAR, 0); + if (window != NULL) { + window_invalidate(window); + window_event_helper(window, 2, WE_MOUSE_UP); + } } } - if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 8)) { - window = window_find_by_id(WC_TOP_TOOLBAR, 0); - if (window != NULL) { - window_invalidate(window); - window_event_helper(window, 2, WE_MOUSE_UP); + break; + case SHORTCUT_ZOOM_VIEW_IN: + if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) || RCT2_ADDRESS(0x0141F570, uint8) == 1) { + if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 8)) { + window = window_find_by_id(WC_TOP_TOOLBAR, 0); + if (window != NULL) { + window_invalidate(window); + window_event_helper(window, 3, WE_MOUSE_UP); + } } } - } else if (key == gShortcutKeys[5]) { - // Zoom in - if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) { - if (RCT2_ADDRESS(0x0141F570, uint8) != 1) { - return; + break; + case SHORTCUT_ROTATE_VIEW: + if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) || RCT2_ADDRESS(0x0141F570, uint8) == 1) { + if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 8)) { + window = window_find_by_id(WC_TOP_TOOLBAR, 0); + if (window != NULL) { + window_invalidate(window); + window_event_helper(window, 4, WE_MOUSE_UP); + } } } - if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 8)) { - window = window_find_by_id(WC_TOP_TOOLBAR, 0); - if (window != NULL) { - window_invalidate(window); - window_event_helper(window, 3, WE_MOUSE_UP); - } - } - } else if (key == gShortcutKeys[6]) { - // Rotate view - if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) { - if (RCT2_ADDRESS(0x0141F570, uint8) != 1) { - return; - } - } - if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 8)) { - window = window_find_by_id(WC_TOP_TOOLBAR, 0); - if (window != NULL) { - window_invalidate(window); - window_event_helper(window, 4, WE_MOUSE_UP); - } - } - } else if (key == gShortcutKeys[7]) { - // Rotate object + break; + case SHORTCUT_ROTATE_CONSTRUCTION_OBJECT: RCT2_CALLPROC_EBPSAFE(0x006E4182); - } else if (key == gShortcutKeys[8]) { - // Underground view toggle + break; + case SHORTCUT_UNDERGROUND_VIEW_TOGGLE: RCT2_CALLPROC_X(0x0066CF8A, 0, 0, 0, 0, 0, 0, 0); - } else if (key == gShortcutKeys[9]) { - // Remove base land toggle + break; + case SHORTCUT_REMOVE_BASE_LAND_TOGGLE: RCT2_CALLPROC_X(0x0066CF8A, 1, 0, 0, 0, 0, 0, 0); - } else if (key == gShortcutKeys[10]) { - // Remove vertical land toggle + break; + case SHORTCUT_REMOVE_VERTICAL_LAND_TOGGLE: RCT2_CALLPROC_X(0x0066CF8A, 2, 0, 0, 0, 0, 0, 0); - } else if (key == gShortcutKeys[11]) { - // See through rides toggle + break; + case SHORTCUT_SEE_THROUGH_RIDES_TOGGLE: RCT2_CALLPROC_X(0x0066CF8A, 4, 0, 0, 0, 0, 0, 0); - } else if (key == gShortcutKeys[12]) { - // See through scenery toggle + break; + case SHORTCUT_SEE_THROUGH_SCENERY_TOGGLE: RCT2_CALLPROC_X(0x0066CF8A, 5, 0, 0, 0, 0, 0, 0); - } else if (key == gShortcutKeys[13]) { - // Invisible supports toggle + break; + case SHORTCUT_INVISIBLE_SUPPORTS_TOGGLE: RCT2_CALLPROC_X(0x0066CF8A, 6, 0, 0, 0, 0, 0, 0); - } else if (key == gShortcutKeys[14]) { - // Invisible people toggle + break; + case SHORTCUT_INVISIBLE_PEOPLE_TOGGLE: RCT2_CALLPROC_X(0x0066CF8A, 7, 0, 0, 0, 0, 0, 0); - } else if (key == gShortcutKeys[15]) { - // Height marks on land toggle + break; + case SHORTCUT_HEIGHT_MARKS_ON_LAND_TOGGLE: RCT2_CALLPROC_X(0x0066CF8A, 9, 0, 0, 0, 0, 0, 0); - } else if (key == gShortcutKeys[16]) { - // Height marks on ride tracks toggle + break; + case SHORTCUT_HEIGHT_MARKS_ON_RIDE_TRACKS_TOGGLE: RCT2_CALLPROC_X(0x0066CF8A, 10, 0, 0, 0, 0, 0, 0); - } else if (key == gShortcutKeys[17]) { - // Height marks on paths toggle + break; + case SHORTCUT_HEIGHT_MARKS_ON_PATHS_TOGGLE: RCT2_CALLPROC_X(0x0066CF8A, 11, 0, 0, 0, 0, 0, 0); - } else if (key == gShortcutKeys[18]) { - // Adjust land - if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) { - if (RCT2_ADDRESS(0x0141F570, uint8) != 1) { - return; + break; + case SHORTCUT_ADJUST_LAND: + if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) || RCT2_ADDRESS(0x0141F570, uint8) == 1) { + if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0C)) { + window = window_find_by_id(WC_TOP_TOOLBAR, 0); + if (window != NULL) { + window_invalidate(window); + window_event_helper(window, 7, WE_MOUSE_UP); + } } } - if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0C)) { - window = window_find_by_id(WC_TOP_TOOLBAR, 0); - if (window != NULL) { - window_invalidate(window); - window_event_helper(window, 7, WE_MOUSE_UP); + break; + case SHORTCUT_ADJUST_WATER: + if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) || RCT2_ADDRESS(0x0141F570, uint8) == 1) { + if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0C)) { + window = window_find_by_id(WC_TOP_TOOLBAR, 0); + if (window != NULL) { + window_invalidate(window); + window_event_helper(window, 8, WE_MOUSE_UP); + } } } - } else if (key == gShortcutKeys[19]) { - // Adjust water - if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) { - if (RCT2_ADDRESS(0x0141F570, uint8) != 1) { - return; + break; + case SHORTCUT_BUILD_SCENERY: + if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) || RCT2_ADDRESS(0x0141F570, uint8) == 1) { + if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0C)) { + window = window_find_by_id(WC_TOP_TOOLBAR, 0); + if (window != NULL) { + window_invalidate(window); + window_event_helper(window, 9, WE_MOUSE_UP); + } } } - if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0C)) { - window = window_find_by_id(WC_TOP_TOOLBAR, 0); - if (window != NULL) { - window_invalidate(window); - window_event_helper(window, 8, WE_MOUSE_UP); + break; + case SHORTCUT_BUILD_PATHS: + if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) || RCT2_ADDRESS(0x0141F570, uint8) == 1) { + if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0C)) { + window = window_find_by_id(WC_TOP_TOOLBAR, 0); + if (window != NULL) { + window_invalidate(window); + window_event_helper(window, 10, WE_MOUSE_UP); + } } } - } else if (key == gShortcutKeys[20]) { - // Build scenery - if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) { - if (RCT2_ADDRESS(0x0141F570, uint8) != 1) { - return; + break; + case SHORTCUT_BUILD_NEW_RIDE: + if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) || RCT2_ADDRESS(0x0141F570, uint8) == 1) { + if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0C)) { + window = window_find_by_id(WC_TOP_TOOLBAR, 0); + if (window != NULL) { + window_invalidate(window); + window_event_helper(window, 11, WE_MOUSE_UP); + } } } - if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0C)) { - window = window_find_by_id(WC_TOP_TOOLBAR, 0); - if (window != NULL) { - window_invalidate(window); - window_event_helper(window, 9, WE_MOUSE_UP); - } - } - } else if (key == gShortcutKeys[21]) { - // Build paths - if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) { - if (RCT2_ADDRESS(0x0141F570, uint8) != 1) { - return; - } - } - if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0C)) { - window = window_find_by_id(WC_TOP_TOOLBAR, 0); - if (window != NULL) { - window_invalidate(window); - window_event_helper(window, 10, WE_MOUSE_UP); - } - } - } else if (key == gShortcutKeys[22]) { - // Build new ride - if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) { - if (RCT2_ADDRESS(0x0141F570, uint8) != 1) { - return; - } - } - if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0C)) { - window = window_find_by_id(WC_TOP_TOOLBAR, 0); - if (window != NULL) { - window_invalidate(window); - window_event_helper(window, 11, WE_MOUSE_UP); - } - } - } else if (key == gShortcutKeys[23]) { - // Show financial information - if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0C)) { - if (!(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & 0x800)) { - RCT2_CALLPROC_EBPSAFE(0x0069DDF1); - } - } - } else if (key == gShortcutKeys[24]) { - // Show research information - if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0E)) { - // Open new ride window - RCT2_CALLPROC_EBPSAFE(0x006B3CFF); - window = window_find_by_id(WC_CONSTRUCT_RIDE, 0); - if (window != NULL) { + break; + case SHORTCUT_SHOW_FINANCIAL_INFORMATION: + if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0C)) + if (!(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & 0x800)) + RCT2_CALLPROC_EBPSAFE(0x0069DDF1); + break; + case SHORTCUT_SHOW_RESEARCH_INFORMATION: + if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0E)) { + // Open new ride window + RCT2_CALLPROC_EBPSAFE(0x006B3CFF); + window = window_find_by_id(WC_CONSTRUCT_RIDE, 0); + if (window != NULL) window_event_helper(window, 10, WE_MOUSE_DOWN); - } } - } else if (key == gShortcutKeys[25]) { - // Show rides list - if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0E)) { - window = window_find_by_id(WC_TOP_TOOLBAR, 0); + break; + case SHORTCUT_SHOW_RIDES_LIST: + if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0E)) { + window = window_find_by_id(WC_TOP_TOOLBAR, 0); if (window != NULL) { window_invalidate(window); window_event_helper(window, 12, WE_MOUSE_UP); } } - } else if (key == gShortcutKeys[26]) { - // Show park information - if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0E)) { - window = window_find_by_id(WC_TOP_TOOLBAR, 0); + break; + case SHORTCUT_SHOW_PARK_INFORMATION: + if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0E)) { + window = window_find_by_id(WC_TOP_TOOLBAR, 0); if (window != NULL) { window_invalidate(window); window_event_helper(window, 13, WE_MOUSE_UP); } } - } else if (key == gShortcutKeys[27]) { - // Show guest list - if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0E)) { - window = window_find_by_id(WC_TOP_TOOLBAR, 0); + break; + case SHORTCUT_SHOW_GUEST_LIST: + if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0E)) { + window = window_find_by_id(WC_TOP_TOOLBAR, 0); if (window != NULL) { window_invalidate(window); window_event_helper(window, 15, WE_MOUSE_UP); } } - } else if (key == gShortcutKeys[28]) { - // Show staff information - if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0E)) { + break; + case SHORTCUT_SHOW_STAFF_LIST: + if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0E)) { window = window_find_by_id(WC_TOP_TOOLBAR, 0); if (window != NULL) { window_invalidate(window); window_event_helper(window, 14, WE_MOUSE_UP); } } - } else if (key == gShortcutKeys[29]) { - // Show recent messages - if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0E)) { - window_news_open(); - } - } else if (key == gShortcutKeys[30]) { - // Show map - if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) { - if (RCT2_ADDRESS(0x0141F570, uint8) != 1) { - return; + break; + case SHORTCUT_SHOW_RECENT_MESSAGES: + if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0E)) + window_news_open(); + break; + case SHORTCUT_SHOW_MAP: + if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) || RCT2_ADDRESS(0x0141F570, uint8) == 1) { + if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0C)) { + window = window_find_by_id(WC_TOP_TOOLBAR, 0); + if (window != NULL) { + window_invalidate(window); + window_event_helper(window, 6, WE_MOUSE_UP); + } } } - if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0C)) { - window = window_find_by_id(WC_TOP_TOOLBAR, 0); - if (window != NULL) { - window_invalidate(window); - window_event_helper(window, 6, WE_MOUSE_UP); - } - } - } else if (key == gShortcutKeys[31]) { - // Screenshot - RCT2_CALLPROC_EBPSAFE(0x006E4034); + break; + case SHORTCUT_SCREENSHOT: + RCT2_CALLPROC_EBPSAFE(0x006E4034); // set screenshot countdown to 2 + break; } +} +/** + * + * rct2: 0x006E3E68 + */ +void handle_shortcut(int key) +{ + int i; + for (i = 0; i < SHORTCUT_COUNT; i++) { + if (key == gShortcutKeys[i]) { + handle_shortcut_command(i); + break; + } + } } /** diff --git a/src/window_guest_list.c b/src/window_guest_list.c index a3f2de1480..0dbd247bb3 100644 --- a/src/window_guest_list.c +++ b/src/window_guest_list.c @@ -161,7 +161,7 @@ void window_guest_list_open() window_init_scroll_widgets(window); _window_guest_list_highlighted_index = -1; window->var_490 = 0; - _window_guest_list_selected_tab = 1; + _window_guest_list_selected_tab = PAGE_INDIVIDUAL; _window_guest_list_selected_filter = -1; _window_guest_list_selected_page = 0; _window_guest_list_num_pages = 1; From 73d06418b62f0302614371b68990812276dba5e0 Mon Sep 17 00:00:00 2001 From: Maciek Baron Date: Fri, 9 May 2014 23:06:53 +0100 Subject: [PATCH 22/41] Adding ride build date, reset function --- src/ride.c | 17 +++++++++++++++++ src/ride.h | 5 ++++- src/scenario.c | 2 +- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/ride.c b/src/ride.c index cc6f543d7f..bb4d8e7164 100644 --- a/src/ride.c +++ b/src/ride.c @@ -150,3 +150,20 @@ void ride_init_all() ride_measurement->var_00 = 0xFF; } } + +/** +* +* rct2: 0x006B7A38 +*/ +void reset_all_ride_build_dates() { + int i; + rct_ride *ride; + for (i = 0; i < MAX_RIDES; i++) { + ride = GET_RIDE(i); + if (ride->type != RIDE_TYPE_NULL) { + //mov ax, current_month_year + //sub [esi + 180h], ax + ride->build_date -= RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, uint16); + } + } +} \ No newline at end of file diff --git a/src/ride.h b/src/ride.h index 78574be103..f7152bf3e5 100644 --- a/src/ride.h +++ b/src/ride.h @@ -72,7 +72,9 @@ typedef struct { uint8 var_14D; uint8 pad_14E[0x0A]; uint16 var_158; - uint8 pad_15A[0x3C]; + uint8 pad_15A[0x26]; + uint16 build_date; + uint8 pad_182[0x14]; uint16 var_196; uint8 pad_198; uint8 var_199; @@ -257,5 +259,6 @@ int ride_get_count(); int ride_get_total_queue_length(rct_ride *ride); int ride_get_max_queue_time(rct_ride *ride); void ride_init_all(); +void reset_all_ride_build_dates(); #endif diff --git a/src/scenario.c b/src/scenario.c index 0752ea39df..fbbb839e67 100644 --- a/src/scenario.c +++ b/src/scenario.c @@ -513,7 +513,7 @@ void scenario_load_and_play(rct_scenario_basic *scenario) RCT2_GLOBAL(0x013587D8, uint16) = 63; RCT2_CALLPROC_EBPSAFE(0x0069E869); // (loan related, called above already) RCT2_CALLPROC_EBPSAFE(0x0066729F); // reset history / finance / awards - RCT2_CALLPROC_EBPSAFE(0x006B7A38); // reset_all_ride_build_dates + reset_all_ride_build_dates(); date_reset(); RCT2_CALLPROC_EBPSAFE(0x00674576); park_calculate_size(); From d3382e3a3877ba5c15049bf56ae08486236206d1 Mon Sep 17 00:00:00 2001 From: Maciek Baron Date: Fri, 9 May 2014 23:11:51 +0100 Subject: [PATCH 23/41] Renaming ride construction content --- projects/openrct2.vcxproj | 2 +- projects/openrct2.vcxproj.filters | 6 +++--- src/editor.c | 6 +++--- src/game.c | 2 +- src/rct2.c | 2 +- src/scenario.c | 2 +- src/title.c | 4 ++-- src/window.h | 2 +- ..._ride_construction.c => window_new_ride.c} | 20 +++++++++---------- 9 files changed, 23 insertions(+), 23 deletions(-) rename src/{window_ride_construction.c => window_new_ride.c} (80%) diff --git a/projects/openrct2.vcxproj b/projects/openrct2.vcxproj index 0bb32ba58a..6f1ca98c26 100644 --- a/projects/openrct2.vcxproj +++ b/projects/openrct2.vcxproj @@ -96,7 +96,7 @@ - + diff --git a/projects/openrct2.vcxproj.filters b/projects/openrct2.vcxproj.filters index 973add4e53..f575f5e573 100644 --- a/projects/openrct2.vcxproj.filters +++ b/projects/openrct2.vcxproj.filters @@ -281,9 +281,6 @@ Source Files - - Windows - Windows @@ -293,6 +290,9 @@ Windows + + Windows + diff --git a/src/editor.c b/src/editor.c index 57ec041be7..e2d8e01f7b 100644 --- a/src/editor.c +++ b/src/editor.c @@ -62,7 +62,7 @@ void editor_load() 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; - window_ride_construction_init_vars(); + window_new_ride_init_vars(); RCT2_GLOBAL(0x0141F571, uint8) = 4; viewport_init_all(); news_item_init_queue(); @@ -110,7 +110,7 @@ void trackdesigner_load() window_staff_init_vars(); RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) = SCREEN_FLAGS_TRACK_DESIGNER; RCT2_GLOBAL(0x0141F570, uint8) = 0; - window_ride_construction_init_vars(); + window_new_ride_init_vars(); viewport_init_all(); news_item_init_queue(); RCT2_CALLPROC_EBPSAFE(0x0066EF38); // window_main_editor_create @@ -148,7 +148,7 @@ void trackmanager_load() window_staff_init_vars(); RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) = SCREEN_FLAGS_TRACK_MANAGER; RCT2_GLOBAL(0x0141F570, uint8) = 0; - window_ride_construction_init_vars(); + window_new_ride_init_vars(); viewport_init_all(); news_item_init_queue(); RCT2_CALLPROC_EBPSAFE(0x0066EF38); // window_main_editor_create diff --git a/src/game.c b/src/game.c index 1a775dcf4c..ad0852b179 100644 --- a/src/game.c +++ b/src/game.c @@ -1520,7 +1520,7 @@ int game_load_save() RCT2_CALLPROC_EBPSAFE(0x0069E9A7); RCT2_CALLPROC_EBPSAFE(0x006DFEE4); - window_ride_construction_init_vars(); + window_new_ride_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 f586b16230..d4cc2fe042 100644 --- a/src/rct2.c +++ b/src/rct2.c @@ -135,7 +135,7 @@ void rct2_init() date_reset(); climate_reset(CLIMATE_COOL_AND_WET); RCT2_CALLPROC_EBPSAFE(0x006DFEE4); - window_ride_construction_init_vars(); + window_new_ride_init_vars(); window_guest_list_init_vars_b(); window_staff_init_vars(); diff --git a/src/scenario.c b/src/scenario.c index fbbb839e67..a05cc25216 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); - window_ride_construction_init_vars(); + window_new_ride_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 e32641a20b..ec26fb9133 100644 --- a/src/title.c +++ b/src/title.c @@ -103,7 +103,7 @@ void title_load() date_reset(); RCT2_CALLPROC_X(0x006C45ED, 0, 0, 0, 0, 0, 0, 0); RCT2_CALLPROC_EBPSAFE(0x006DFEE4); - window_ride_construction_init_vars(); + window_new_ride_init_vars(); window_guest_list_init_vars_b(); window_staff_init_vars(); RCT2_CALLPROC_EBPSAFE(0x0068AFFD); @@ -191,7 +191,7 @@ static void title_update_showcase() window_invalidate(w); RCT2_CALLPROC_EBPSAFE(0x0069E9A7); - window_ride_construction_init_vars(); + window_new_ride_init_vars(); RCT2_CALLPROC_EBPSAFE(0x00684AC3); RCT2_CALLPROC_EBPSAFE(0x006DFEE4); news_item_init_queue(); diff --git a/src/window.h b/src/window.h index eb4abfa776..e163eb81e2 100644 --- a/src/window.h +++ b/src/window.h @@ -358,7 +358,7 @@ void window_cheats_open(); void window_guest_list_init_vars_a(); void window_guest_list_init_vars_b(); -void window_ride_construction_init_vars(); +void window_new_ride_init_vars(); void window_staff_init_vars(); diff --git a/src/window_ride_construction.c b/src/window_new_ride.c similarity index 80% rename from src/window_ride_construction.c rename to src/window_new_ride.c index 35b813ac78..edbb45d96e 100644 --- a/src/window_ride_construction.c +++ b/src/window_new_ride.c @@ -24,26 +24,26 @@ #include "window.h" enum { - WINDOW_RIDE_CONSTRUCTION_TAB_TRANSPORT, - WINDOW_RIDE_CONSTRUCTION_TAB_GENTLE, - WINDOW_RIDE_CONSTRUCTION_TAB_ROLLER_COASTER, - WINDOW_RIDE_CONSTRUCTION_TAB_THRILL, - WINDOW_RIDE_CONSTRUCTION_TAB_WATER, - WINDOW_RIDE_CONSTRUCTION_TAB_SHOP, - WINDOW_RIDE_CONSTRUCTION_TAB_RESEARCH + WINDOW_NEW_RIDE_TAB_TRANSPORT, + WINDOW_NEW_RIDE_TAB_GENTLE, + WINDOW_NEW_RIDE_TAB_ROLLER_COASTER, + WINDOW_NEW_RIDE_TAB_THRILL, + WINDOW_NEW_RIDE_TAB_WATER, + WINDOW_NEW_RIDE_TAB_SHOP, + WINDOW_NEW_RIDE_TAB_RESEARCH } WINDOW_RIDE_CONSTRUCTION_TAB; /** * * rct2: 0x006ACA58 */ -void window_ride_construction_init_vars() { +void window_new_ride_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_CONSTRUCTION_TAB_ROLLER_COASTER; + RCT2_GLOBAL(RCT2_ADDRESS_WINDOW_RIDE_LIST_SELECTED_TAB, uint8) = WINDOW_NEW_RIDE_TAB_ROLLER_COASTER; } else { - RCT2_GLOBAL(RCT2_ADDRESS_WINDOW_RIDE_LIST_SELECTED_TAB, uint8) = WINDOW_RIDE_CONSTRUCTION_TAB_TRANSPORT; + RCT2_GLOBAL(RCT2_ADDRESS_WINDOW_RIDE_LIST_SELECTED_TAB, uint8) = WINDOW_NEW_RIDE_TAB_TRANSPORT; } for (short i = 0; i < 6; i++) { From 61ceee26a7b9d31be2ce64a987d5694f26f18edb Mon Sep 17 00:00:00 2001 From: IntelOrca Date: Sat, 10 May 2014 00:40:47 +0100 Subject: [PATCH 24/41] remove extra scenario name address macro --- src/addresses.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/addresses.h b/src/addresses.h index 0917bbfe59..a23cc338b0 100644 --- a/src/addresses.h +++ b/src/addresses.h @@ -208,8 +208,6 @@ #define RCT2_ADDRESS_GAME_COMMAND_ERROR_STRING_ID 0x0141E9AE #define RCT2_ADDRESS_CURRENT_ROTATION 0x0141E9E0 -#define RCT2_ADDRESS_SCENARIO_NAME 0x0141F5B8 - #define RCT2_ADDRESS_WATER_RAISE_COST 0x0141F738 #define RCT2_ADDRESS_WATER_LOWER_COST 0x0141F73C From 5f690ac134e79ed23a3b24ad068648cd58d2b276 Mon Sep 17 00:00:00 2001 From: ddevrien Date: Fri, 9 May 2014 10:04:40 +0200 Subject: [PATCH 25/41] Added basic code for banner window --- src/window_cheats.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/window_cheats.c b/src/window_cheats.c index 4e9b188f53..50385e2ad3 100644 --- a/src/window_cheats.c +++ b/src/window_cheats.c @@ -28,7 +28,6 @@ #include "widget.h" #include "window.h" - #define WW 200 #define WH 128 #define CHEATS_MONEY_INCREMENT 10000 @@ -207,6 +206,9 @@ static void window_cheats_money_mouseup() window_invalidate_by_id(0x40 | WC_BOTTOM_TOOLBAR, 0); break; } + + window_park_entrance_open(); + window_banner_open(); } static void window_cheats_guests_mouseup() From f8363e098bd55fc7ed5f5ee2428ddfd2bf82643b Mon Sep 17 00:00:00 2001 From: IntelOrca Date: Sun, 11 May 2014 00:35:45 +0100 Subject: [PATCH 26/41] add park_init --- src/addresses.h | 5 +++++ src/finance.h | 2 ++ src/park.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++- src/park.h | 3 ++- src/strings.h | 2 ++ 5 files changed, 66 insertions(+), 2 deletions(-) diff --git a/src/addresses.h b/src/addresses.h index a23cc338b0..ace66af4e8 100644 --- a/src/addresses.h +++ b/src/addresses.h @@ -164,6 +164,11 @@ #define RCT2_ADDRESS_CURRENT_INTEREST_RATE 0x0135934A #define RCT2_ADDRESS_EXPENDITURE_TABLE 0x01357848 #define RCT2_ADDRESS_CURRENT_RESEARCH_LEVEL 0x013573FF + +#define RCT2_ADDRESS_HANDYMAN_COLOUR 0x01357BCD +#define RCT2_ADDRESS_MECHANIC_COLOUR 0x01357BCE +#define RCT2_ADDRESS_SECURITY_COLOUR 0x01357BCF + #define RCT2_ADDRESS_CURRENT_INTEREST_RATE 0x0135934A #define RCT2_ADDRESS_MAP_SIZE 0x01358834 diff --git a/src/finance.h b/src/finance.h index 4a81abe34f..3fc80726fb 100644 --- a/src/finance.h +++ b/src/finance.h @@ -23,6 +23,8 @@ #include "rct2.h" +#define CURRENCY(whole, fraction) ((whole) * 10 + ((fraction) / 10)) + typedef int rct_expenditure_type; enum { diff --git a/src/park.c b/src/park.c index aaa1685375..74961928ef 100644 --- a/src/park.c +++ b/src/park.c @@ -19,11 +19,14 @@ *****************************************************************************/ #include "addresses.h" +#include "finance.h" #include "map.h" #include "park.h" #include "peep.h" #include "ride.h" +#include "scenario.h" #include "sprite.h" +#include "strings.h" #include "window.h" int park_is_open() @@ -37,7 +40,58 @@ int park_is_open() */ void park_init() { - RCT2_CALLPROC_EBPSAFE(0x00667132); + int i; + + RCT2_GLOBAL(0x013CA740, uint8) = 0; + RCT2_GLOBAL(0x013573D4, uint16) = 777; + RCT2_GLOBAL(RCT2_ADDRESS_HANDYMAN_COLOUR, uint8) = 28; + RCT2_GLOBAL(RCT2_ADDRESS_MECHANIC_COLOUR, uint8) = 28; + RCT2_GLOBAL(RCT2_ADDRESS_SECURITY_COLOUR, uint8) = 28; + RCT2_GLOBAL(RCT2_ADDRESS_GUESTS_IN_PARK, uint16) = 0; + RCT2_GLOBAL(0x01357BC8, uint16) = 0; + RCT2_GLOBAL(0x01357846, uint16) = 0; + RCT2_GLOBAL(0x013573FE, uint16) = 0; + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PARK_RATING, uint16) = 0; + RCT2_GLOBAL(0x013580EC, uint16) = 0; + RCT2_GLOBAL(0x013580EE, uint16) = 0; + RCT2_GLOBAL(0x01357CF4, sint32) = -1; + + for (i = 0; i < 20; i++) + RCT2_ADDRESS(0x01358102, uint8)[i] = 0; + + RCT2_GLOBAL(0x01358844, uint32) = 0xFFFFFFFF; + RCT2_GLOBAL(0x01358849, uint32) = 0xFFFFFFFE; + RCT2_GLOBAL(0x0135884E, uint32) = 0xFFFFFFFD; + finance_init(); + + for (i = 0; i < 2; i++) + RCT2_ADDRESS(0x01357404, uint32)[i] = 0; + + for (i = 0; i < 56; i++) + RCT2_ADDRESS(0x01357BD0, sint32)[i] = -1; + + RCT2_GLOBAL(RCT2_ADDRESS_PARK_ENTRANCE_FEE, uint16) = CURRENCY(10, 00); + RCT2_GLOBAL(0x013573F2, sint16) = -1; + RCT2_GLOBAL(0x013573F8, sint16) = -1; + RCT2_GLOBAL(0x01357CF2, uint16) = 127; + RCT2_GLOBAL(0x013573FF, uint8) = 2; + + RCT2_GLOBAL(0x013580F4, uint16) = 500; + RCT2_GLOBAL(0x013580E9, uint8) = 128; + RCT2_GLOBAL(0x013580F6, uint8) = 200; + RCT2_GLOBAL(0x013580F7, uint8) = 200; + RCT2_GLOBAL(RCT2_ADDRESS_OBJECTIVE_TYPE, uint8) = 1; + RCT2_GLOBAL(RCT2_ADDRESS_OBJECTIVE_YEAR, uint8) = 4; + RCT2_GLOBAL(RCT2_ADDRESS_OBJECTIVE_NUM_GUESTS, uint16) = 1000; + RCT2_GLOBAL(0x01358770, uint16) = 900; + RCT2_GLOBAL(0x01358772, uint16) = 400; + RCT2_GLOBAL(0x01358774, uint16) = 0; + RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) = PARK_FLAGS_11 | PARK_FLAGS_SHOW_REAL_GUEST_NAMES; + RCT2_CALLPROC_EBPSAFE(0x0066729F); // reset history / finance / awards + + rct_s6_info *info = 0x0141F570; + info->name[0] = '\0'; + format_string(info->details, STR_NO_DETAILS_YET, NULL); } /** diff --git a/src/park.h b/src/park.h index ee91fa5b46..5b43d49e4d 100644 --- a/src/park.h +++ b/src/park.h @@ -59,7 +59,8 @@ enum { PARK_FLAGS_FORBID_HIGH_CONSTRUCTION = (1 << 5), // below tree height PARK_FLAGS_PREF_LESS_INTENSE_RIDES = (1 << 6), PARK_FLAGS_FORBID_MARKETING_CAMPAIGN = (1 << 7), - PARK_FLAGS_PREF_MORE_INTENSE_RIDES = (1 << 11), + PARK_FLAGS_PREF_MORE_INTENSE_RIDES = (1 << 8), + PARK_FLAGS_11 = (1 << 11), PARK_FLAGS_DIFFICULT_GUEST_GENERATION = (1 << 12), PARK_FLAGS_PARK_FREE_ENTRY = (1 << 13), PARK_FLAGS_DIFFICULT_PARK_RATING = (1 << 14), diff --git a/src/strings.h b/src/strings.h index 1e459333b6..a2fb5f1c38 100644 --- a/src/strings.h +++ b/src/strings.h @@ -490,6 +490,8 @@ enum { STR_LIST = 3159, + STR_NO_DETAILS_YET = 3317, + STR_OBJECTIVE = 3322, STR_GAME_TOOLS = 3341, From 70e7660d0b5617a6f7cf7fbbd147b6ddac6be3d5 Mon Sep 17 00:00:00 2001 From: IntelOrca Date: Sun, 11 May 2014 01:18:56 +0100 Subject: [PATCH 27/41] add park_reset_awards_and_history --- src/addresses.h | 3 +++ src/park.c | 28 +++++++++++++++++++++++++++- src/park.h | 1 + src/scenario.c | 2 +- 4 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/addresses.h b/src/addresses.h index ace66af4e8..18f012969f 100644 --- a/src/addresses.h +++ b/src/addresses.h @@ -153,8 +153,11 @@ #define RCT2_ADDRESS_OBJECTIVE_YEAR 0x013580F9 #define RCT2_ADDRESS_OBJECTIVE_CURRENCY 0x013580FC #define RCT2_ADDRESS_OBJECTIVE_NUM_GUESTS 0x01358100 +#define RCT2_ADDRESS_BALANCE_HISTORY 0x0135812C #define RCT2_ADDRESS_CURRENT_PROFIT 0x01358330 +#define RCT2_ADDRESS_WEEKLY_PROFIT_HISTORY 0x0135833C #define RCT2_ADDRESS_CURRENT_PARK_VALUE 0x0135853C +#define RCT2_ADDRESS_PARK_VALUE_HISTORY 0x01358540 #define RCT2_ADDRESS_COMPLETED_COMPANY_VALUE 0x01358740 #define RCT2_ADDRESS_TOTAL_ADMISSIONS 0x01358744 #define RCT2_ADDRESS_INCOME_FROM_ADMISSIONS 0x01358748 diff --git a/src/park.c b/src/park.c index 74961928ef..911d10997e 100644 --- a/src/park.c +++ b/src/park.c @@ -87,13 +87,39 @@ void park_init() RCT2_GLOBAL(0x01358772, uint16) = 400; RCT2_GLOBAL(0x01358774, uint16) = 0; RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) = PARK_FLAGS_11 | PARK_FLAGS_SHOW_REAL_GUEST_NAMES; - RCT2_CALLPROC_EBPSAFE(0x0066729F); // reset history / finance / awards + park_reset_awards_and_history(); rct_s6_info *info = 0x0141F570; info->name[0] = '\0'; format_string(info->details, STR_NO_DETAILS_YET, NULL); } +/** + * + * rct2: 0x0066729F + */ +void park_reset_awards_and_history() +{ + int i; + + // Reset park rating and guests in park history + for (i = 0; i < 32; i++) { + RCT2_ADDRESS(RCT2_ADDRESS_PARK_RATING_HISTORY, uint8)[i] = 255; + RCT2_ADDRESS(RCT2_ADDRESS_GUESTS_IN_PARK_HISTORY, uint8)[i] = 255; + } + + // Reset finance history + for (i = 0; i < 128; i++) { + RCT2_ADDRESS(RCT2_ADDRESS_BALANCE_HISTORY, uint32)[i] = 0x80000000; + RCT2_ADDRESS(RCT2_ADDRESS_WEEKLY_PROFIT_HISTORY, uint32)[i] = 0x80000000; + RCT2_ADDRESS(RCT2_ADDRESS_PARK_VALUE_HISTORY, uint32)[i] = 0x80000000; + } + + // Reset awards + for (i = 0; i < 4; i++) + RCT2_ADDRESS(RCT2_ADDRESS_AWARD_LIST, rct_award)[i].time = 0; +} + /** * * rct2: 0x0066A348 diff --git a/src/park.h b/src/park.h index 5b43d49e4d..177e4755a5 100644 --- a/src/park.h +++ b/src/park.h @@ -70,6 +70,7 @@ enum { int park_is_open(); void park_init(); +void park_reset_awards_and_history(); int park_calculate_size(); int calculate_park_rating(); diff --git a/src/scenario.c b/src/scenario.c index a05cc25216..954f2d489c 100644 --- a/src/scenario.c +++ b/src/scenario.c @@ -512,7 +512,7 @@ void scenario_load_and_play(rct_scenario_basic *scenario) RCT2_GLOBAL(RCT2_ADDRESS_INCOME_FROM_ADMISSIONS, uint32) = 0; RCT2_GLOBAL(0x013587D8, uint16) = 63; RCT2_CALLPROC_EBPSAFE(0x0069E869); // (loan related, called above already) - RCT2_CALLPROC_EBPSAFE(0x0066729F); // reset history / finance / awards + park_reset_awards_and_history(); reset_all_ride_build_dates(); date_reset(); RCT2_CALLPROC_EBPSAFE(0x00674576); From b39cf4d1af975e89042dd8507f7c6c556d807ccb Mon Sep 17 00:00:00 2001 From: ddevrien Date: Sun, 11 May 2014 09:01:01 +0200 Subject: [PATCH 28/41] Started work on options window --- projects/openrct2.vcxproj | 1 + projects/openrct2.vcxproj.filters | 3 + src/strings.h | 22 +++ src/widget.c | 2 +- src/widget.h | 2 +- src/window.h | 1 + src/window_banner.c | 2 +- src/window_game_top_toolbar.c | 1 + src/window_options.c | 248 ++++++++++++++++++++++++++++++ 9 files changed, 279 insertions(+), 3 deletions(-) create mode 100644 src/window_options.c diff --git a/projects/openrct2.vcxproj b/projects/openrct2.vcxproj index 6f1ca98c26..75fc4d2765 100644 --- a/projects/openrct2.vcxproj +++ b/projects/openrct2.vcxproj @@ -97,6 +97,7 @@ + diff --git a/projects/openrct2.vcxproj.filters b/projects/openrct2.vcxproj.filters index f575f5e573..7350319a76 100644 --- a/projects/openrct2.vcxproj.filters +++ b/projects/openrct2.vcxproj.filters @@ -293,6 +293,9 @@ Windows + + Windows + diff --git a/src/strings.h b/src/strings.h index 1e459333b6..945299c8c4 100644 --- a/src/strings.h +++ b/src/strings.h @@ -278,6 +278,8 @@ enum { STR_SUMMARISED_GUESTS_TIP = 1753, STR_ADMISSION_PRICE = 1756, + STR_MUSIC = 1777, + STR_ACTIONS = 1814, STR_THOUGHTS = STR_ACTIONS + 1, STR_INFORMATION_TYPE_TIP = 1816, @@ -355,6 +357,15 @@ enum { STR_CHANGE_BASE_LAND_TIP = 2294, STR_CHANGE_VERTICAL_LAND_TIP = 2295, + STR_SOUND_QUALITY = 2317, + STR_CURRENCY = 2328, + STR_DISTANCE_AND_SPEED = 2329, + STR_TEMPERATURE = 2330, + STR_HEIGHT_LABELS = 2331, + STR_DISPLAY_RESOLUTION = 2360, + STR_TILE_EDGE_SMOOTHING_TIP = 2362, + STR_TURN_GRIDLINES_ON_TIP = 2364, + //STR_NONE = 2368, STR_LOW = 2369, STR_AVERAGE = 2370, @@ -404,12 +415,17 @@ enum { STR_PROFIT_PER_WEEK_AND_PARK_VALUE_TIP = 2482, + STR_REAL_NAME_TOGGLE_TIP = 2488, + STR_ENTER_NAME_INTO_SCENARIO_CHART = 2790, STR_COMPLETED_BY_WITH_COMPANY_VALUE = 2794, STR_SORT = 2795, STR_RIDE_LIST_SORT_TIP = 2796, + STR_SCREEN_EDGE_SCROLL_TIP = 2798, + STR_CHANGE_HOTKEY_TIP = 2799, + STR_TOTAL_ADMISSIONS = 2800, STR_INCOME_FROM_ADMISSIONS = 2801, @@ -466,6 +482,8 @@ enum { STR_UNABLE_TO_LOAD_FILE = 3010, STR_FILE_CONTAINS_INVALID_DATA = 3011, + STR_CONSTRUCTION_MARKER = 3057, + STR_BEGINNER_PARKS = 3064, STR_CHALLENGING_PARKS = STR_BEGINNER_PARKS + 1, STR_EXPERT_PARKS = STR_BEGINNER_PARKS + 2, @@ -492,12 +510,16 @@ enum { STR_OBJECTIVE = 3322, + STR_SAVE_PLUGIN_DATA_TIP = 3334, + STR_GAME_TOOLS = 3341, STR_SCENARIO_EDITOR = 3342, STR_CONVERT_SAVED_GAME_TO_SCENARIO = 3343, STR_ROLLER_COASTER_DESIGNER = 3344, STR_TRACK_DESIGNS_MANAGER = 3345, + STR_SOUND_FORCED_SOFTWARE_BUFFER_MIXING_TIP = 3363, + STR_TUTORIAL_BEGINNERS = 3385, STR_TUTORIAL_CUSTOM_RIDES = 3386, STR_TUTORIAL_ROLLER_COASTER = 3387, diff --git a/src/widget.c b/src/widget.c index c9de92adca..0a0bf25188 100644 --- a/src/widget.c +++ b/src/widget.c @@ -153,7 +153,7 @@ void widget_draw(rct_drawpixelinfo *dpi, rct_window *w, int widgetIndex) case WWT_SCROLL: widget_scroll_draw(dpi, w, widgetIndex); break; - case WWT_23: + case WWT_CHECKBOX: case WWT_24: break; case WWT_25: diff --git a/src/widget.h b/src/widget.h index 477c124a6c..0f269bc724 100644 --- a/src/widget.h +++ b/src/widget.h @@ -47,7 +47,7 @@ typedef enum { WWT_CAPTION = 20, WWT_CLOSEBOX = 21, WWT_SCROLL = 22, - WWT_23, + WWT_CHECKBOX, WWT_24, WWT_25, WWT_LAST = 26, diff --git a/src/window.h b/src/window.h index e163eb81e2..3a21c90257 100644 --- a/src/window.h +++ b/src/window.h @@ -346,6 +346,7 @@ void window_clear_scenery_open(); void window_land_open(); void window_water_open(); void window_guest_list_open(); +void window_options_open(); void window_park_awards_open(); void window_park_entrance_open(); void window_park_guests_open(); diff --git a/src/window_banner.c b/src/window_banner.c index e3766a829d..89bf755a46 100644 --- a/src/window_banner.c +++ b/src/window_banner.c @@ -26,7 +26,7 @@ #include "widget.h" #include "window.h" -static enum WINDOW_CLEAR_SCENERY_WIDGET_IDX { +static enum WINDOW_BANNER_WIDGET_IDX { WIDX_BACKGROUND, WIDX_TITLE, WIDX_CLOSE, diff --git a/src/window_game_top_toolbar.c b/src/window_game_top_toolbar.c index afacce3cf1..f4c8b26890 100644 --- a/src/window_game_top_toolbar.c +++ b/src/window_game_top_toolbar.c @@ -377,6 +377,7 @@ static void window_game_top_toolbar_dropdown() window_about_open(); break; case 4: // options + //window_options_open(); RCT2_CALLPROC_EBPSAFE(0x006BAC5B); break; case 5: // screenshot diff --git a/src/window_options.c b/src/window_options.c new file mode 100644 index 0000000000..6899affa08 --- /dev/null +++ b/src/window_options.c @@ -0,0 +1,248 @@ +/***************************************************************************** + * Copyright (c) 2014 Ted John, Dennis Devriendt + * 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 "strings.h" +#include "widget.h" +#include "window.h" + +static enum WINDOW_OPTIONS_WIDGET_IDX { + WIDX_BACKGROUND, + WIDX_TITLE, + WIDX_CLOSE, + WIDX_SOUND_DROPDOWN = 5, + WIDX_MUSIC = 6, + WIDX_SOUND_QUALITY = 8, + WIDX_CURRENCY = 12, + WIDX_DISTANCE = 14, + WIDX_TEMPERATURE = 16, + WIDX_HEIGHT_LABELS = 18, + WIDX_RESOLUTION = 21, + WIDX_CONSTRUCTION_MARKER = 25 +}; + +static rct_widget window_options_widgets[] = { + { WWT_FRAME, 0, 0, 309, 0, 371, 0x0FFFFFFFF, STR_NONE }, + { WWT_CAPTION, 0, 1, 308, 1, 14, 0x490, STR_WINDOW_TITLE_TIP }, + { WWT_CLOSEBOX, 0, 297, 307, 2, 13, 0x338, STR_CLOSE_WINDOW_TIP }, + { WWT_GROUPBOX, 0, 3, 306, 17, 93, 0x91D, STR_NONE }, + { WWT_DROPDOWN, 0, 10, 299, 31, 42, 0x361, STR_NONE }, + { WWT_DROPDOWN_BUTTON, 0, 288, 298, 32, 41, 0x36C, STR_NONE }, + { WWT_DROPDOWN, 0, 155, 299, 46, 57, 0x365, STR_NONE }, + { WWT_DROPDOWN_BUTTON, 0, 288, 298, 47, 56, 0x36C, STR_NONE }, + { WWT_DROPDOWN, 0, 155, 299, 61, 72, 0x366, STR_NONE }, + { WWT_DROPDOWN_BUTTON, 0, 288, 298, 62, 71, 0x36C, STR_NONE }, + { WWT_CHECKBOX, 0, 10, 299, 76, 87, 0x0D22, STR_SOUND_FORCED_SOFTWARE_BUFFER_MIXING_TIP }, + { WWT_GROUPBOX, 0, 3, 306, 100, 176, 0x91C, STR_NONE }, + { WWT_DROPDOWN, 0, 155, 299, 114, 125, 0x367, STR_NONE }, + { WWT_DROPDOWN_BUTTON, 0, 288, 298, 115, 124, 0x36C, STR_NONE }, + { WWT_DROPDOWN, 0, 155, 299, 129, 140, 0x368, STR_NONE }, + { WWT_DROPDOWN_BUTTON, 0, 288, 298, 130, 139, 0x36C, STR_NONE }, + { WWT_DROPDOWN, 0, 155, 299, 144, 155, 0x36B, STR_NONE }, + { WWT_DROPDOWN_BUTTON, 0, 288, 298, 145, 154, 0x36C, STR_NONE }, + { WWT_DROPDOWN, 0, 155, 299, 159, 170, 0x364, STR_NONE }, + { WWT_DROPDOWN_BUTTON, 0, 288, 298, 160, 169, 0x36C, STR_NONE }, + { WWT_GROUPBOX, 0, 3, 306, 182, 258, 0x92A, STR_NONE }, + { WWT_DROPDOWN, 0, 155, 299, 196, 207, 0x348, STR_NONE }, + { WWT_DROPDOWN_BUTTON, 0, 288, 298, 197, 206, 0x36C, STR_NONE }, + { WWT_CHECKBOX, 0, 10, 299, 212, 223, 0x939, STR_TILE_EDGE_SMOOTHING_TIP }, + { WWT_CHECKBOX, 0, 10, 299, 227, 238, 0x93B, STR_TURN_GRIDLINES_ON_TIP }, + { WWT_DROPDOWN, 0, 155, 299, 241, 252, 0x0FFFFFFFF, STR_NONE }, + { WWT_DROPDOWN_BUTTON, 0, 288, 298, 242, 251, 0x36C, STR_NONE }, + { WWT_GROUPBOX, 0, 3, 306, 264, 310, 0x9B5, STR_NONE }, + { WWT_CHECKBOX, 2, 10, 299, 279, 290, 0x0AED, STR_SCREEN_EDGE_SCROLL_TIP }, + { WWT_DROPDOWN_BUTTON, 0, 26, 185, 293, 304, 0x9B9, STR_CHANGE_HOTKEY_TIP }, + { WWT_GROUPBOX, 0, 3, 306, 317, 365, 0x9B6, STR_NONE }, + { WWT_CHECKBOX, 2, 10, 299, 331, 342, 0x9B7, STR_REAL_NAME_TOGGLE_TIP }, + { WWT_CHECKBOX, 2, 10, 299, 346, 357, 0x0D05, STR_SAVE_PLUGIN_DATA_TIP }, + { WIDGETS_END }, +}; + +static void window_options_emptysub() { } +static void window_options_mouseup(); +static void window_options_mousedown(); +static void window_options_dropdown(); +static void window_options_textinput(); +static void window_options_update(); +static void window_options_paint(); + +static uint32 window_options_events[] = { + window_options_emptysub, + window_options_mouseup, + window_options_emptysub, + window_options_mousedown, + window_options_dropdown, + window_options_emptysub, + window_options_emptysub, + window_options_emptysub, + window_options_emptysub, + window_options_emptysub, + window_options_emptysub, + window_options_emptysub, + window_options_emptysub, + window_options_emptysub, + window_options_emptysub, + window_options_emptysub, + window_options_emptysub, + window_options_emptysub, + window_options_emptysub, + window_options_emptysub, + window_options_emptysub, + window_options_emptysub, + window_options_emptysub, + window_options_emptysub, + window_options_emptysub, + window_options_update, + window_options_paint, + window_options_emptysub +}; + +/** +* +* rct2: 0x006BAC5B +*/ +void window_options_open() +{ + rct_window* w; + + // Check if window is already open + w = window_bring_to_front_by_id(WC_OPTIONS, 0); + if (w != NULL) + return; + + w = window_create_auto_pos(310, 372, window_options_events, WC_OPTIONS, 0); + w->widgets = window_options_widgets; + w->enabled_widgets = + (1 << WIDX_CLOSE) | + 0x10 | + (1 << WIDX_SOUND_DROPDOWN) | + 0x40 | + 0x80 | + 0x100 | + 0x200 | + 0x1000 | + 0x2000 | + 0x4000 | + 0x8000 | + 0x200000 | + 0x400000 | + 0x10000 | + 0x20000 | + 0x20000000 | + 0x10000000 | + 0x80000000 | + 0x2000000 | + 0x4000000 | + 0x40000 | + 0x80000 | + 0x800000 | + 0x1000000 | + 0x400; + // TODO: missing .text:006BAD22 or dword ptr [esi+0Ch], 1 + + window_init_scroll_widgets(w); + w->colours[0] = 7; + w->colours[1] = 7; + w->colours[2] = 7; +} + +/** +* +* rct2: 0x006BAFCA +*/ +static void window_options_mouseup() +{ + RCT2_CALLPROC_EBPSAFE(0x006BAFCA); +} + +/** +* +* rct2: 0x006BB01B +*/ +static void window_options_mousedown() +{ + RCT2_CALLPROC_EBPSAFE(0x006BB01B); +} + +/** +* +* rct2: 0x006BB076 +*/ +static void window_options_dropdown() +{ + RCT2_CALLPROC_EBPSAFE(0x006BB076); + /*short widgetIndex; + rct_window *w; + + __asm mov widgetIndex, dx + __asm mov w, esi + + switch (widgetIndex) { + case WIDX_SOUND_DROPDOWN: + RCT2_CALLPROC_EBPSAFE(0x006BB757); + break; + }*/ +} + +/** +* +* rct2: 0x006BAD48 +*/ +static void window_options_update() +{ + RCT2_CALLPROC_EBPSAFE(0x006BAD48); +} + +/** +* +* rct2: 0x006BAEB4 +*/ +static void window_options_paint() +{ + rct_window *w; + rct_drawpixelinfo *dpi; + + __asm mov w, esi + __asm mov dpi, edi + + window_draw_widgets(w, dpi); + + // units + gfx_draw_string_left(dpi, STR_CURRENCY, w, 0, w->x + 10, + w->y + window_options_widgets[WIDX_CURRENCY].top + 1); + gfx_draw_string_left(dpi, STR_DISTANCE_AND_SPEED, w, 0, w->x + 10, + w->y + window_options_widgets[WIDX_DISTANCE].top + 1); + gfx_draw_string_left(dpi, STR_TEMPERATURE, w, 0, w->x + 10, + w->y + window_options_widgets[WIDX_TEMPERATURE].top + 1); + gfx_draw_string_left(dpi, STR_HEIGHT_LABELS, w, 0, w->x + 10, + w->y + window_options_widgets[WIDX_HEIGHT_LABELS].top + 1); + + // display + gfx_draw_string_left(dpi, STR_DISPLAY_RESOLUTION, w, 0, w->x + 10, + w->y + window_options_widgets[WIDX_RESOLUTION].top + 1); + gfx_draw_string_left(dpi, STR_CONSTRUCTION_MARKER, w, 0, w->x + 10, + w->y + window_options_widgets[WIDX_CONSTRUCTION_MARKER].top + 1); + + // sound + gfx_draw_string_left(dpi, STR_MUSIC, w, 0, w->x + 10, + w->y + window_options_widgets[WIDX_MUSIC].top + 1); + gfx_draw_string_left(dpi, STR_SOUND_QUALITY, w, 0, w->x + 10, + w->y + window_options_widgets[WIDX_SOUND_QUALITY].top + 1); +} From 977fe5f485bfbb97cc1021bf88937d6a6f32dacc Mon Sep 17 00:00:00 2001 From: ddevrien Date: Sun, 11 May 2014 09:04:25 +0200 Subject: [PATCH 29/41] forgot debug code --- src/window_cheats.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/window_cheats.c b/src/window_cheats.c index 50385e2ad3..4e9b188f53 100644 --- a/src/window_cheats.c +++ b/src/window_cheats.c @@ -28,6 +28,7 @@ #include "widget.h" #include "window.h" + #define WW 200 #define WH 128 #define CHEATS_MONEY_INCREMENT 10000 @@ -206,9 +207,6 @@ static void window_cheats_money_mouseup() window_invalidate_by_id(0x40 | WC_BOTTOM_TOOLBAR, 0); break; } - - window_park_entrance_open(); - window_banner_open(); } static void window_cheats_guests_mouseup() From 580035fdef8a9e8296c9872df97738b1f6e359db Mon Sep 17 00:00:00 2001 From: ddevrien Date: Sun, 11 May 2014 09:45:03 +0200 Subject: [PATCH 30/41] Fix groupbox widget draw issue (issue #91) --- src/widget.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/widget.c b/src/widget.c index 0a0bf25188..c476beed44 100644 --- a/src/widget.c +++ b/src/widget.c @@ -564,7 +564,7 @@ static void widget_groupbox_draw(rct_drawpixelinfo *dpi, rct_window *w, int widg // Text if (widget->image != (uint32)-1) { colour = w->colours[widget->colour] & 0x7F; - if (colour & 1) + if (widget_is_disabled(w, widgetIndex)) colour |= 0x40; gfx_draw_string_left(dpi, widget->image, 0x013CE952, colour, l, t); textRight = gLastDrawStringX + 1; From 5c5c5373cdf96b0a6d324e25abc1a89c2e850eed Mon Sep 17 00:00:00 2001 From: ddevrien Date: Sun, 11 May 2014 10:51:05 +0200 Subject: [PATCH 31/41] Implemented checkbox widget draw function --- src/widget.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/src/widget.c b/src/widget.c index c476beed44..c2d386e705 100644 --- a/src/widget.c +++ b/src/widget.c @@ -37,6 +37,7 @@ static void widget_text_inset(rct_drawpixelinfo *dpi, rct_window *w, int widgetI static void widget_text_draw(rct_drawpixelinfo *dpi, rct_window *w, int widgetIndex); static void widget_groupbox_draw(rct_drawpixelinfo *dpi, rct_window *w, int widgetIndex); static void widget_caption_draw(rct_drawpixelinfo *dpi, rct_window *w, int widgetIndex); +static void widget_checkbox_draw(rct_drawpixelinfo *dpi, rct_window *w, int widgetIndex); static void widget_closebox_draw(rct_drawpixelinfo *dpi, rct_window *w, int widgetIndex); static void widget_scroll_draw(rct_drawpixelinfo *dpi, rct_window *w, int widgetIndex); static void widget_hscrollbar_draw(rct_drawpixelinfo *dpi, rct_scroll *scroll, int l, int t, int r, int b, int colour); @@ -154,6 +155,8 @@ void widget_draw(rct_drawpixelinfo *dpi, rct_window *w, int widgetIndex) widget_scroll_draw(dpi, w, widgetIndex); break; case WWT_CHECKBOX: + widget_checkbox_draw(dpi, w, widgetIndex); + break; case WWT_24: break; case WWT_25: @@ -711,6 +714,46 @@ static void widget_closebox_draw(rct_drawpixelinfo *dpi, rct_window *w, int widg gfx_draw_string_centred_clipped(dpi, widget->image, (void*)0x013CE952, colour, l, t, widget->right - widget->left - 2); } +/** +* +* rct2: 0x006EBAD9 +*/ +static void widget_checkbox_draw(rct_drawpixelinfo *dpi, rct_window *w, int widgetIndex) +{ + rct_widget* widget; + int l, t, b; + uint8 colour; + + // Get the widget + widget = &w->widgets[widgetIndex]; + + // Resolve the absolute ltb + l = w->x + widget->left; + t = w->y + widget->top; + b = w->y + widget->bottom; + + // Get the colour + colour = w->colours[widget->colour]; + + // checkbox + gfx_fill_rect_inset(dpi, l, t, l + 9, b - 1, colour, 0x60); + + // fill it when checkbox is pressed + if (widget_is_pressed(w, widgetIndex)) { + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, uint16) = 224; + gfx_draw_string(dpi, (char*)0x009DED72, colour & 0x7F, l, t); + } + + // draw the text + if (widget->image == -1) + return; + + if (widget_is_disabled(w, widgetIndex)) { + colour |= 0x40; + } + gfx_draw_string_left(dpi, widget->image, (char*)0x013CE952, colour, l + 14, t); +} + /** * * rct2: 0x006EBD96 From 52c95e415417d96524261caaaa02610995cd4583 Mon Sep 17 00:00:00 2001 From: ddevrien Date: Sun, 11 May 2014 10:57:56 +0200 Subject: [PATCH 32/41] little addition to checkbox widget --- src/widget.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/widget.c b/src/widget.c index c2d386e705..5da914bf7e 100644 --- a/src/widget.c +++ b/src/widget.c @@ -736,12 +736,14 @@ static void widget_checkbox_draw(rct_drawpixelinfo *dpi, rct_window *w, int widg colour = w->colours[widget->colour]; // checkbox - gfx_fill_rect_inset(dpi, l, t, l + 9, b - 1, colour, 0x60); + if (widget->type != WWT_24) { + gfx_fill_rect_inset(dpi, l, t, l + 9, b - 1, colour, 0x60); - // fill it when checkbox is pressed - if (widget_is_pressed(w, widgetIndex)) { - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, uint16) = 224; - gfx_draw_string(dpi, (char*)0x009DED72, colour & 0x7F, l, t); + // fill it when checkbox is pressed + if (widget_is_pressed(w, widgetIndex)) { + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, uint16) = 224; + gfx_draw_string(dpi, (char*)0x009DED72, colour & 0x7F, l, t); + } } // draw the text From cd8587243ca353d579e8737d196fd36919d00503 Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Sun, 11 May 2014 13:14:43 +0100 Subject: [PATCH 33/41] Initial rewrite of gfx_draw_line --- src/gfx.c | 116 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 115 insertions(+), 1 deletion(-) diff --git a/src/gfx.c b/src/gfx.c index 022b35e1a2..41d464030a 100644 --- a/src/gfx.c +++ b/src/gfx.c @@ -98,6 +98,48 @@ void gfx_draw_pixel(rct_drawpixelinfo *dpi, int x, int y, int colour) gfx_fill_rect(dpi, x, y, x, y, colour); } +/* +* rct2: 0x68474C +*/ +void gfx_draw_line_on_buffer(int edi, int ebp, int esi) +{ + //edi ebp + //int edi, ebp, esi; + edi -= RCT2_GLOBAL(0x9ABDBE, sint16); + + if (edi < 0)return; + if (edi >= RCT2_GLOBAL(0x9ABDC2, sint16))return; + + if (!ebp) return; + + ebp++; + esi -= RCT2_GLOBAL(0x9ABDBC, sint16); + if (esi < 0){ + ebp += esi; + if (ebp <= 0)return; + esi = 0; + } + + int eax = esi; + eax += ebp; + eax -= RCT2_GLOBAL(0x9ABDC0, sint16); + if (eax > 0){ + ebp -= eax; + return; + } + eax = RCT2_GLOBAL(0x9ABDC4, sint16); + eax += RCT2_GLOBAL(0x9ABDC0, sint16); + edi *= eax; + edi += esi; + edi += RCT2_GLOBAL(0x9ABDB8, sint32); + eax = RCT2_GLOBAL(0xEDF84A,uint16); + for (int i = 0; i < ebp; ++i){ + *((uint8*)edi) = eax; + edi++; + } +} + + /** * * rct2: 0x00684466 @@ -110,7 +152,79 @@ void gfx_draw_pixel(rct_drawpixelinfo *dpi, int x, int y, int colour) */ void gfx_draw_line(rct_drawpixelinfo *dpi, int x1, int y1, int x2, int y2, int colour) { - RCT2_CALLPROC_X(0x00684466, x1, y1, x2, y2, 0, dpi, colour); + //RCT2_CALLPROC_X(0x00684466, x1, y1, x2, y2, 0, dpi, colour); + + if ((x1 < dpi->x) && (x2 < dpi->x)){ + return;//jump to 0x68474B + } + + if ((y1 < dpi->y) && (y2 < dpi->y)){ + return;//jump to 0x68474B + } + + if ((x1 <= (dpi->x + dpi->width)) && (x2 <= (dpi->x + dpi->width))){ + return;//jump to 0x68474B + } + + if ((y1 <= (dpi->y + dpi->height)) && (y2 <= (dpi->y + dpi->height))){ + return;//jump to 0x68474B + } + + RCT2_GLOBAL(0xEDF84A, uint16) = (uint16)(0xFFFF & colour); + + int bits_pointer; + bits_pointer = dpi->bits; + RCT2_GLOBAL(0x9ABDB8, uint32) = bits_pointer; + RCT2_GLOBAL(0x9ABDBC, uint16) = dpi->x; + RCT2_GLOBAL(0x9ABDBE, uint16) = dpi->y; + RCT2_GLOBAL(0x9ABDC0, uint16) = dpi->width; + RCT2_GLOBAL(0x9ABDC2, uint16) = dpi->height; + RCT2_GLOBAL(0x9ABDC4, uint16) = dpi->pitch; + + int edi = y1; + int esi = x1; + int ebp = colour & 0xFFFF; + int cx = x2 - x1; + if (cx < 0){ + //jump 0x684633 + } + int ax = cx; + int dx = y2 - y1; + if (dx < 0){ + //jump 0x6845AB + } + RCT2_GLOBAL(0xEDF846, uint16) = cx; + RCT2_GLOBAL(0xEDF848, uint16) = dx; + if (dx > cx){ + //jump 0x68456A + } + ax--; + if (ax < 0){ + return;//jump 0x684568 + } + cx /= 2; + cx = -cx; + ebp = 0; + + for (int i = ax; i >= 0; i--){ + ebp++; + cx += RCT2_GLOBAL(0xEDF848, sint16); + if (cx <= 0){ + i--; + if (i < 0){ + gfx_draw_line_on_buffer(edi, ebp, esi); + return; + } + continue; + } + cx -= RCT2_GLOBAL(0xEDF846, sint16); + gfx_draw_line_on_buffer(edi, ebp, esi); + esi += ebp; + edi++; + ebp = 0; + } + return; + } /** From 0ba23fe88633a02de5aa11c8da0e3d98c1f0434d Mon Sep 17 00:00:00 2001 From: ddevrien Date: Sun, 11 May 2014 17:24:52 +0200 Subject: [PATCH 34/41] Some work on options window --- src/addresses.h | 3 + src/strings.h | 24 +++- src/widget.c | 3 +- src/window_dropdown.c | 10 +- src/window_dropdown.h | 2 +- src/window_game_top_toolbar.c | 4 +- src/window_options.c | 206 ++++++++++++++++++++++++---------- 7 files changed, 176 insertions(+), 76 deletions(-) diff --git a/src/addresses.h b/src/addresses.h index a23cc338b0..fab898085c 100644 --- a/src/addresses.h +++ b/src/addresses.h @@ -119,6 +119,9 @@ #define RCT2_ADDRESS_WINDOW_DPI 0x009DEA74 +#define RCT2_ADDRESS_NUM_DSOUND_DEVICES 0x009E2B88 +#define RCT2_ADDRESS_DSOUND_DEVICES 0x009E2B8C + #define RCT2_ADDRESS_CMDLINE 0x009E2D98 #define RCT2_ADDRESS_LAND_RAISE_COST 0x009E2E1C diff --git a/src/strings.h b/src/strings.h index 945299c8c4..c2d2a5e520 100644 --- a/src/strings.h +++ b/src/strings.h @@ -217,6 +217,8 @@ enum { STR_PLACE_SCENERY_TIP = 1159, STR_ADJUST_WATER_TIP = 1160, + STR_OPTIONS = 1168, + STR_BUILD_FOOTPATH_TIP = 1173, STR_CANT_BUILD_FOOTPATH_HERE = 1176, STR_CANT_REMOVE_FOOTPATH_FROM_HERE = 1177, @@ -362,9 +364,14 @@ enum { STR_DISTANCE_AND_SPEED = 2329, STR_TEMPERATURE = 2330, STR_HEIGHT_LABELS = 2331, + STR_UNITS = 2332, + STR_SOUND = 2333, + STR_DISPLAY = 2346, STR_DISPLAY_RESOLUTION = 2360, - STR_TILE_EDGE_SMOOTHING_TIP = 2362, - STR_TURN_GRIDLINES_ON_TIP = 2364, + STR_TILE_SMOOTHING = 2361, + STR_TILE_SMOOTHING_TIP = 2362, + STR_GRIDLINES = 2363, + STR_GRIDLINES_TIP = 2364, //STR_NONE = 2368, STR_LOW = 2369, @@ -415,7 +422,11 @@ enum { STR_PROFIT_PER_WEEK_AND_PARK_VALUE_TIP = 2482, - STR_REAL_NAME_TOGGLE_TIP = 2488, + STR_CONTROLS = 2485, + STR_GENERAL = 2486, + STR_REAL_NAME = 2487, + STR_REAL_NAME_TIP = 2488, + STR_HOTKEY = 2489, STR_ENTER_NAME_INTO_SCENARIO_CHART = 2790, @@ -423,8 +434,9 @@ enum { STR_SORT = 2795, STR_RIDE_LIST_SORT_TIP = 2796, - STR_SCREEN_EDGE_SCROLL_TIP = 2798, - STR_CHANGE_HOTKEY_TIP = 2799, + STR_SCREEN_EDGE_SCROLLING = 2797, + STR_SCREEN_EDGE_SCROLLING_TIP = 2798, + STR_HOTKEY_TIP = 2799, STR_TOTAL_ADMISSIONS = 2800, STR_INCOME_FROM_ADMISSIONS = 2801, @@ -510,6 +522,7 @@ enum { STR_OBJECTIVE = 3322, + STR_SAVE_PLUGIN_DATA = 3333, STR_SAVE_PLUGIN_DATA_TIP = 3334, STR_GAME_TOOLS = 3341, @@ -518,6 +531,7 @@ enum { STR_ROLLER_COASTER_DESIGNER = 3344, STR_TRACK_DESIGNS_MANAGER = 3345, + STR_SOUND_FORCED_SOFTWARE_BUFFER_MIXING = 3362, STR_SOUND_FORCED_SOFTWARE_BUFFER_MIXING_TIP = 3363, STR_TUTORIAL_BEGINNERS = 3385, diff --git a/src/widget.c b/src/widget.c index 5da914bf7e..3aa909e355 100644 --- a/src/widget.c +++ b/src/widget.c @@ -155,9 +155,8 @@ void widget_draw(rct_drawpixelinfo *dpi, rct_window *w, int widgetIndex) widget_scroll_draw(dpi, w, widgetIndex); break; case WWT_CHECKBOX: - widget_checkbox_draw(dpi, w, widgetIndex); - break; case WWT_24: + widget_checkbox_draw(dpi, w, widgetIndex); break; case WWT_25: break; diff --git a/src/window_dropdown.c b/src/window_dropdown.c index 9050dd6c64..14c27202a2 100644 --- a/src/window_dropdown.c +++ b/src/window_dropdown.c @@ -51,7 +51,7 @@ int _dropdown_item_height; int _dropdown_highlighted_index; uint16 gDropdownItemsFormat[64]; -sint32 gDropdownItemsArgs[64]; +sint64 gDropdownItemsArgs[64]; uint32 gDropdownItemsChecked; static void window_dropdown_emptysub() { } @@ -134,8 +134,8 @@ void window_dropdown_show_text_custom_width(int x, int y, int extray, uint8 colo char buffer[256]; // Copy the formats and arguments until all use of it is decompiled - memcpy(0x009DEBA4, gDropdownItemsFormat, 37 * 2); - memcpy(0x009DEBF4, gDropdownItemsArgs, 80 * 4); + memcpy(0x009DEBA4, gDropdownItemsFormat, 40 * 2); + memcpy(0x009DEBF4, gDropdownItemsArgs, 40 * 8); RCT2_GLOBAL(0x009DE518, uint32) &= ~(0x04 | 0x02); if (flags & 0x80) @@ -203,8 +203,8 @@ void window_dropdown_show_image(int x, int y, int extray, uint8 colour, uint8 fl rct_window* w; // Copy the formats and arguments until all use of it is decompiled - memcpy(0x009DEBA4, gDropdownItemsFormat, 37 * 2); - memcpy(0x009DEBF4, gDropdownItemsArgs, 80 * 4); + memcpy(0x009DEBA4, gDropdownItemsFormat, 40 * 2); + memcpy(0x009DEBF4, gDropdownItemsArgs, 40 * 8); RCT2_GLOBAL(0x009DE518, uint32) &= ~(0x04 | 0x02); if (flags & 0x80) diff --git a/src/window_dropdown.h b/src/window_dropdown.h index 14d47a8920..b98598abac 100644 --- a/src/window_dropdown.h +++ b/src/window_dropdown.h @@ -28,7 +28,7 @@ extern int gAppropriateImageDropdownItemsPerRow[]; extern uint16 gDropdownItemsFormat[64]; -extern sint32 gDropdownItemsArgs[64]; +extern sint64 gDropdownItemsArgs[64]; extern uint32 gDropdownItemsChecked; void window_dropdown_show_text(int x, int y, int extray, uint8 colour, uint8 flags, int num_items); diff --git a/src/window_game_top_toolbar.c b/src/window_game_top_toolbar.c index f4c8b26890..d64bb1b862 100644 --- a/src/window_game_top_toolbar.c +++ b/src/window_game_top_toolbar.c @@ -377,8 +377,8 @@ static void window_game_top_toolbar_dropdown() window_about_open(); break; case 4: // options - //window_options_open(); - RCT2_CALLPROC_EBPSAFE(0x006BAC5B); + window_options_open(); + //RCT2_CALLPROC_EBPSAFE(0x006BAC5B); break; case 5: // screenshot RCT2_GLOBAL(RCT2_ADDRESS_SCREENSHOT_COUNTDOWN, sint8) = 10; diff --git a/src/window_options.c b/src/window_options.c index 6899affa08..a9f81e2eeb 100644 --- a/src/window_options.c +++ b/src/window_options.c @@ -22,56 +22,78 @@ #include "strings.h" #include "widget.h" #include "window.h" +#include "window_dropdown.h" static enum WINDOW_OPTIONS_WIDGET_IDX { WIDX_BACKGROUND, WIDX_TITLE, WIDX_CLOSE, - WIDX_SOUND_DROPDOWN = 5, - WIDX_MUSIC = 6, - WIDX_SOUND_QUALITY = 8, - WIDX_CURRENCY = 12, - WIDX_DISTANCE = 14, - WIDX_TEMPERATURE = 16, - WIDX_HEIGHT_LABELS = 18, - WIDX_RESOLUTION = 21, - WIDX_CONSTRUCTION_MARKER = 25 + WIDX_SOUND_GROUP, + WIDX_SOUND, + WIDX_SOUND_DROPDOWN, + WIDX_MUSIC, + WIDX_MUSIC_DROPDOWN, + WIDX_SOUND_QUALITY, + WIDX_SOUND_QUALITY_DROPDOWN, + WIDX_SOUND_SW_BUFFER_CHECKBOX, + WIDX_UNITS_GROUP, + WIDX_CURRENCY, + WIDX_CURRENCY_DROPDOWN, + WIDX_DISTANCE, + WIDX_DISTANCE_DROPDOWN, + WIDX_TEMPERATURE, + WIDX_TEMPERATURE_DROPDOWN, + WIDX_HEIGHT_LABELS, + WIDX_HEIGHT_LABELS_DROPDOWN, + WIDX_DISPLAY_GROUP, + WIDX_RESOLUTION, + WIDX_RESOLUTION_DROPDOWN, + WIDX_TILE_SMOOTHING_CHECKBOX, + WIDX_GRIDLINES_CHECKBOX, + WIDX_CONSTRUCTION_MARKER, + WIDX_CONSTRUCTION_MARKER_DROPDOWN, + WIDX_CONTROLS_GROUP, + WIDX_SCREEN_EDGE_SCROLLING, + WIDX_HOTKEY_DROPDOWN, + WIDX_GENERAL_GROUP, + WIDX_REAL_NAME_CHECKBOX, + WIDX_SAVE_PLUGIN_DATA_CHECKBOX }; static rct_widget window_options_widgets[] = { - { WWT_FRAME, 0, 0, 309, 0, 371, 0x0FFFFFFFF, STR_NONE }, - { WWT_CAPTION, 0, 1, 308, 1, 14, 0x490, STR_WINDOW_TITLE_TIP }, - { WWT_CLOSEBOX, 0, 297, 307, 2, 13, 0x338, STR_CLOSE_WINDOW_TIP }, - { WWT_GROUPBOX, 0, 3, 306, 17, 93, 0x91D, STR_NONE }, - { WWT_DROPDOWN, 0, 10, 299, 31, 42, 0x361, STR_NONE }, + { WWT_FRAME, 0, 0, 309, 0, 371, STR_NONE, STR_NONE }, + { WWT_CAPTION, 0, 1, 308, 1, 14, STR_OPTIONS, STR_WINDOW_TITLE_TIP }, + { WWT_CLOSEBOX, 0, 297, 307, 2, 13, STR_CLOSE_X, STR_CLOSE_WINDOW_TIP }, + { WWT_GROUPBOX, 0, 3, 306, 17, 93, STR_SOUND, STR_NONE }, + { WWT_DROPDOWN, 0, 10, 299, 31, 42, 0x361, STR_NONE }, // sound { WWT_DROPDOWN_BUTTON, 0, 288, 298, 32, 41, 0x36C, STR_NONE }, - { WWT_DROPDOWN, 0, 155, 299, 46, 57, 0x365, STR_NONE }, + { WWT_DROPDOWN, 0, 155, 299, 46, 57, 0x365, STR_NONE }, // music { WWT_DROPDOWN_BUTTON, 0, 288, 298, 47, 56, 0x36C, STR_NONE }, - { WWT_DROPDOWN, 0, 155, 299, 61, 72, 0x366, STR_NONE }, + { WWT_DROPDOWN, 0, 155, 299, 61, 72, 0x366, STR_NONE }, // sound quality { WWT_DROPDOWN_BUTTON, 0, 288, 298, 62, 71, 0x36C, STR_NONE }, - { WWT_CHECKBOX, 0, 10, 299, 76, 87, 0x0D22, STR_SOUND_FORCED_SOFTWARE_BUFFER_MIXING_TIP }, - { WWT_GROUPBOX, 0, 3, 306, 100, 176, 0x91C, STR_NONE }, - { WWT_DROPDOWN, 0, 155, 299, 114, 125, 0x367, STR_NONE }, + { WWT_CHECKBOX, 0, 10, 299, 76, 87, STR_SOUND_FORCED_SOFTWARE_BUFFER_MIXING, STR_SOUND_FORCED_SOFTWARE_BUFFER_MIXING_TIP }, + { WWT_GROUPBOX, 0, 3, 306, 100, 176, STR_UNITS, STR_NONE }, + { WWT_DROPDOWN, 0, 155, 299, 114, 125, 0x367, STR_NONE }, // currency { WWT_DROPDOWN_BUTTON, 0, 288, 298, 115, 124, 0x36C, STR_NONE }, - { WWT_DROPDOWN, 0, 155, 299, 129, 140, 0x368, STR_NONE }, + { WWT_DROPDOWN, 0, 155, 299, 129, 140, 0x368, STR_NONE }, // distance { WWT_DROPDOWN_BUTTON, 0, 288, 298, 130, 139, 0x36C, STR_NONE }, - { WWT_DROPDOWN, 0, 155, 299, 144, 155, 0x36B, STR_NONE }, + { WWT_DROPDOWN, 0, 155, 299, 144, 155, 0x36B, STR_NONE }, // temperature { WWT_DROPDOWN_BUTTON, 0, 288, 298, 145, 154, 0x36C, STR_NONE }, - { WWT_DROPDOWN, 0, 155, 299, 159, 170, 0x364, STR_NONE }, + { WWT_DROPDOWN, 0, 155, 299, 159, 170, 0x364, STR_NONE }, // height labels { WWT_DROPDOWN_BUTTON, 0, 288, 298, 160, 169, 0x36C, STR_NONE }, - { WWT_GROUPBOX, 0, 3, 306, 182, 258, 0x92A, STR_NONE }, - { WWT_DROPDOWN, 0, 155, 299, 196, 207, 0x348, STR_NONE }, + { WWT_GROUPBOX, 0, 3, 306, 182, 258, STR_DISPLAY, STR_NONE }, + { WWT_DROPDOWN, 0, 155, 299, 196, 207, 0x348, STR_NONE }, // resolution { WWT_DROPDOWN_BUTTON, 0, 288, 298, 197, 206, 0x36C, STR_NONE }, - { WWT_CHECKBOX, 0, 10, 299, 212, 223, 0x939, STR_TILE_EDGE_SMOOTHING_TIP }, - { WWT_CHECKBOX, 0, 10, 299, 227, 238, 0x93B, STR_TURN_GRIDLINES_ON_TIP }, - { WWT_DROPDOWN, 0, 155, 299, 241, 252, 0x0FFFFFFFF, STR_NONE }, + { WWT_CHECKBOX, 0, 10, 299, 212, 223, STR_TILE_SMOOTHING, STR_TILE_SMOOTHING_TIP }, + { WWT_CHECKBOX, 0, 10, 299, 227, 238, STR_GRIDLINES, STR_GRIDLINES_TIP }, + { WWT_DROPDOWN, 0, 155, 299, 241, 252, STR_NONE, STR_NONE }, // construction marker { WWT_DROPDOWN_BUTTON, 0, 288, 298, 242, 251, 0x36C, STR_NONE }, - { WWT_GROUPBOX, 0, 3, 306, 264, 310, 0x9B5, STR_NONE }, - { WWT_CHECKBOX, 2, 10, 299, 279, 290, 0x0AED, STR_SCREEN_EDGE_SCROLL_TIP }, - { WWT_DROPDOWN_BUTTON, 0, 26, 185, 293, 304, 0x9B9, STR_CHANGE_HOTKEY_TIP }, - { WWT_GROUPBOX, 0, 3, 306, 317, 365, 0x9B6, STR_NONE }, - { WWT_CHECKBOX, 2, 10, 299, 331, 342, 0x9B7, STR_REAL_NAME_TOGGLE_TIP }, - { WWT_CHECKBOX, 2, 10, 299, 346, 357, 0x0D05, STR_SAVE_PLUGIN_DATA_TIP }, + { WWT_GROUPBOX, 0, 3, 306, 264, 310, STR_CONTROLS, STR_NONE }, + { WWT_CHECKBOX, 2, 10, 299, 279, 290, STR_SCREEN_EDGE_SCROLLING, STR_SCREEN_EDGE_SCROLLING_TIP }, + { WWT_DROPDOWN_BUTTON, 0, 26, 185, 293, 304, STR_HOTKEY, STR_HOTKEY_TIP }, + { WWT_GROUPBOX, 0, 3, 306, 317, 365, STR_GENERAL, STR_NONE }, + { WWT_CHECKBOX, 2, 10, 299, 331, 342, STR_REAL_NAME, STR_REAL_NAME_TIP }, + { WWT_CHECKBOX, 2, 10, 299, 346, 357, STR_SAVE_PLUGIN_DATA, STR_SAVE_PLUGIN_DATA_TIP }, { WIDGETS_END }, }; @@ -79,7 +101,6 @@ static void window_options_emptysub() { } static void window_options_mouseup(); static void window_options_mousedown(); static void window_options_dropdown(); -static void window_options_textinput(); static void window_options_update(); static void window_options_paint(); @@ -129,32 +150,32 @@ void window_options_open() w = window_create_auto_pos(310, 372, window_options_events, WC_OPTIONS, 0); w->widgets = window_options_widgets; - w->enabled_widgets = - (1 << WIDX_CLOSE) | - 0x10 | + w->enabled_widgets = + (1 << WIDX_CLOSE) | + (1 << WIDX_SOUND) | (1 << WIDX_SOUND_DROPDOWN) | - 0x40 | - 0x80 | - 0x100 | - 0x200 | - 0x1000 | - 0x2000 | - 0x4000 | - 0x8000 | - 0x200000 | - 0x400000 | - 0x10000 | - 0x20000 | - 0x20000000 | - 0x10000000 | - 0x80000000 | - 0x2000000 | - 0x4000000 | - 0x40000 | - 0x80000 | - 0x800000 | - 0x1000000 | - 0x400; + (1 << WIDX_MUSIC) | + (1 << WIDX_MUSIC_DROPDOWN) | + (1 << WIDX_SOUND_QUALITY) | + (1 << WIDX_SOUND_QUALITY_DROPDOWN) | + (1 << WIDX_CURRENCY) | + (1 << WIDX_CURRENCY_DROPDOWN) | + (1 << WIDX_DISTANCE) | + (1 << WIDX_DISTANCE_DROPDOWN) | + (1 << WIDX_RESOLUTION) | + (1 << WIDX_RESOLUTION_DROPDOWN) | + (1 << WIDX_TEMPERATURE) | + (1 << WIDX_TEMPERATURE_DROPDOWN) | + (1 << WIDX_HOTKEY_DROPDOWN) | + (1 << WIDX_SCREEN_EDGE_SCROLLING) | + (1 << WIDX_REAL_NAME_CHECKBOX) | + (1 << WIDX_CONSTRUCTION_MARKER) | + (1 << WIDX_CONSTRUCTION_MARKER_DROPDOWN) | + (1 << WIDX_HEIGHT_LABELS) | + (1 << WIDX_HEIGHT_LABELS_DROPDOWN) | + (1 << WIDX_TILE_SMOOTHING_CHECKBOX) | + (1 << WIDX_GRIDLINES_CHECKBOX) | + (1 << WIDX_SOUND_SW_BUFFER_CHECKBOX); // TODO: missing .text:006BAD22 or dword ptr [esi+0Ch], 1 window_init_scroll_widgets(w); @@ -178,7 +199,70 @@ static void window_options_mouseup() */ static void window_options_mousedown() { - RCT2_CALLPROC_EBPSAFE(0x006BB01B); + //RCT2_CALLPROC_EBPSAFE(0x006BB01B); + int numItems, i; + sint64 device; + short widgetIndex; + rct_window *w; + rct_widget *widget; + + __asm mov widgetIndex, dx + __asm mov w, esi + + widget = &w->widgets[widgetIndex - 1]; + + switch (widgetIndex) { + case WIDX_SOUND_DROPDOWN: + numItems = RCT2_GLOBAL(RCT2_ADDRESS_NUM_DSOUND_DEVICES, uint32); + if (numItems == 0) + break; + + window_dropdown_show_text_custom_width( + w->x + widget->left, + w->y + widget->top, + widget->bottom - widget->top + 1, + w->colours[1], + 0x80, + numItems, + widget->right - widget->left - 3 + ); + + // populate the list with the sound devices + device = RCT2_GLOBAL(RCT2_ADDRESS_DSOUND_DEVICES, sint32) + 0x10; + + for (i = 0; i < numItems; i++) { + gDropdownItemsFormat[i] = 1142; + gDropdownItemsArgs[i] = 1170 | (device << 16); + device += 0x210; + } + gDropdownItemsChecked |= (1 << RCT2_GLOBAL(0x9AF280, uint32)); + + break; + case WIDX_HEIGHT_LABELS_DROPDOWN: + RCT2_CALLPROC_EBPSAFE(0x006BB517); + break; + case WIDX_MUSIC_DROPDOWN: + RCT2_CALLPROC_EBPSAFE(0x006BB5A8); + break; + case WIDX_SOUND_QUALITY_DROPDOWN: + RCT2_CALLPROC_EBPSAFE(0x006BB631); + break; + case WIDX_CURRENCY_DROPDOWN: + RCT2_CALLPROC_EBPSAFE(0x006BB494); + break; + case WIDX_DISTANCE_DROPDOWN: + RCT2_CALLPROC_EBPSAFE(0x006BB3E6); + break; + case WIDX_RESOLUTION_DROPDOWN: + RCT2_CALLPROC_EBPSAFE(0x006BB2AF); + break; + case WIDX_TEMPERATURE_DROPDOWN: + RCT2_CALLPROC_EBPSAFE(0x006BB21F); + break; + case WIDX_CONSTRUCTION_MARKER_DROPDOWN: + RCT2_CALLPROC_EBPSAFE(0x006BB18F); + break; + } } /** @@ -245,4 +329,4 @@ static void window_options_paint() w->y + window_options_widgets[WIDX_MUSIC].top + 1); gfx_draw_string_left(dpi, STR_SOUND_QUALITY, w, 0, w->x + 10, w->y + window_options_widgets[WIDX_SOUND_QUALITY].top + 1); -} +} \ No newline at end of file From bf8a032553152683ad56f9de1b9541f219ad379f Mon Sep 17 00:00:00 2001 From: IntelOrca Date: Sun, 11 May 2014 16:50:29 +0100 Subject: [PATCH 35/41] fix dropdown argument arrays --- src/window_dropdown.c | 10 +++++----- src/window_dropdown.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/window_dropdown.c b/src/window_dropdown.c index 9050dd6c64..14c27202a2 100644 --- a/src/window_dropdown.c +++ b/src/window_dropdown.c @@ -51,7 +51,7 @@ int _dropdown_item_height; int _dropdown_highlighted_index; uint16 gDropdownItemsFormat[64]; -sint32 gDropdownItemsArgs[64]; +sint64 gDropdownItemsArgs[64]; uint32 gDropdownItemsChecked; static void window_dropdown_emptysub() { } @@ -134,8 +134,8 @@ void window_dropdown_show_text_custom_width(int x, int y, int extray, uint8 colo char buffer[256]; // Copy the formats and arguments until all use of it is decompiled - memcpy(0x009DEBA4, gDropdownItemsFormat, 37 * 2); - memcpy(0x009DEBF4, gDropdownItemsArgs, 80 * 4); + memcpy(0x009DEBA4, gDropdownItemsFormat, 40 * 2); + memcpy(0x009DEBF4, gDropdownItemsArgs, 40 * 8); RCT2_GLOBAL(0x009DE518, uint32) &= ~(0x04 | 0x02); if (flags & 0x80) @@ -203,8 +203,8 @@ void window_dropdown_show_image(int x, int y, int extray, uint8 colour, uint8 fl rct_window* w; // Copy the formats and arguments until all use of it is decompiled - memcpy(0x009DEBA4, gDropdownItemsFormat, 37 * 2); - memcpy(0x009DEBF4, gDropdownItemsArgs, 80 * 4); + memcpy(0x009DEBA4, gDropdownItemsFormat, 40 * 2); + memcpy(0x009DEBF4, gDropdownItemsArgs, 40 * 8); RCT2_GLOBAL(0x009DE518, uint32) &= ~(0x04 | 0x02); if (flags & 0x80) diff --git a/src/window_dropdown.h b/src/window_dropdown.h index 14d47a8920..b98598abac 100644 --- a/src/window_dropdown.h +++ b/src/window_dropdown.h @@ -28,7 +28,7 @@ extern int gAppropriateImageDropdownItemsPerRow[]; extern uint16 gDropdownItemsFormat[64]; -extern sint32 gDropdownItemsArgs[64]; +extern sint64 gDropdownItemsArgs[64]; extern uint32 gDropdownItemsChecked; void window_dropdown_show_text(int x, int y, int extray, uint8 colour, uint8 flags, int num_items); From 45532da9c6bca80698190e6651cbae6895ffad3b Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Sun, 11 May 2014 20:10:32 +0100 Subject: [PATCH 36/41] Rewrote gfx_draw_line_on_buffer after realising how it works --- src/gfx.c | 126 ++++++++++++++++++++++++++++------------------ src/window_park.c | 1 - 2 files changed, 78 insertions(+), 49 deletions(-) diff --git a/src/gfx.c b/src/gfx.c index 41d464030a..7beb9bb6a7 100644 --- a/src/gfx.c +++ b/src/gfx.c @@ -99,43 +99,46 @@ void gfx_draw_pixel(rct_drawpixelinfo *dpi, int x, int y, int colour) } /* +* Draws a horizontal line of specified colour to a buffer. * rct2: 0x68474C */ -void gfx_draw_line_on_buffer(int edi, int ebp, int esi) +void gfx_draw_line_on_buffer(rct_drawpixelinfo *dpi, char colour, int y, int x, int no_pixels) { - //edi ebp - //int edi, ebp, esi; - edi -= RCT2_GLOBAL(0x9ABDBE, sint16); + y -= dpi->y; - if (edi < 0)return; - if (edi >= RCT2_GLOBAL(0x9ABDC2, sint16))return; + //Check to make sure point is in the y range + if (y < 0)return; + if (y >= dpi->height)return; + //Check to make sure we are drawing at least a pixel + if (!no_pixels) return; - if (!ebp) return; + no_pixels++; + x -= dpi->x; - ebp++; - esi -= RCT2_GLOBAL(0x9ABDBC, sint16); - if (esi < 0){ - ebp += esi; - if (ebp <= 0)return; - esi = 0; + //If x coord outside range leave + if (x < 0){ + //Unless the number of pixels is enough to be in range + no_pixels += x; + if (no_pixels <= 0)return; + //Resets starting point to 0 as we don't draw outside the range + x = 0; } - int eax = esi; - eax += ebp; - eax -= RCT2_GLOBAL(0x9ABDC0, sint16); - if (eax > 0){ - ebp -= eax; - return; + //Ensure that the end point of the line is within range + if (x + no_pixels - dpi->width > 0){ + //If the end point has any pixels outside range + //cut them off. If there are now no pixels return. + no_pixels -= x + no_pixels - dpi->width; + if (no_pixels <= 0)return; } - eax = RCT2_GLOBAL(0x9ABDC4, sint16); - eax += RCT2_GLOBAL(0x9ABDC0, sint16); - edi *= eax; - edi += esi; - edi += RCT2_GLOBAL(0x9ABDB8, sint32); - eax = RCT2_GLOBAL(0xEDF84A,uint16); - for (int i = 0; i < ebp; ++i){ - *((uint8*)edi) = eax; - edi++; + + char* bits_pointer; + //Get the buffer we are drawing to and move to the first coordinate. + bits_pointer = dpi->bits + y*(dpi->pitch + dpi->width) + x; + + //Draw the line to the specified colour + for (; no_pixels > 0; --no_pixels, ++bits_pointer){ + *((uint8*)bits_pointer) = colour; } } @@ -153,6 +156,7 @@ void gfx_draw_line_on_buffer(int edi, int ebp, int esi) void gfx_draw_line(rct_drawpixelinfo *dpi, int x1, int y1, int x2, int y2, int colour) { //RCT2_CALLPROC_X(0x00684466, x1, y1, x2, y2, 0, dpi, colour); + //return; if ((x1 < dpi->x) && (x2 < dpi->x)){ return;//jump to 0x68474B @@ -162,11 +166,11 @@ void gfx_draw_line(rct_drawpixelinfo *dpi, int x1, int y1, int x2, int y2, int c return;//jump to 0x68474B } - if ((x1 <= (dpi->x + dpi->width)) && (x2 <= (dpi->x + dpi->width))){ + if ((x1 > (dpi->x + dpi->width)) && (x2 > (dpi->x + dpi->width))){ return;//jump to 0x68474B } - if ((y1 <= (dpi->y + dpi->height)) && (y2 <= (dpi->y + dpi->height))){ + if ((y1 > (dpi->y + dpi->height)) && (y2 > (dpi->y + dpi->height))){ return;//jump to 0x68474B } @@ -184,41 +188,67 @@ void gfx_draw_line(rct_drawpixelinfo *dpi, int x1, int y1, int x2, int y2, int c int edi = y1; int esi = x1; int ebp = colour & 0xFFFF; - int cx = x2 - x1; - if (cx < 0){ - //jump 0x684633 + int x_diff, y_diff; + x_diff = x2 - x1; + + if (x1 > x2){ + x_diff = -x_diff; + int ax = x_diff; + int dx = y2 - y1; + if (dx < 0){ + RCT2_CALLPROC_X(0x6846C5, ax, x2, x_diff, dx, esi, edi, ebp); + return; + //jump 0x6846C5 + } + RCT2_GLOBAL(0xEDF846, uint16) = x_diff; + RCT2_GLOBAL(0xEDF848, uint16) = y2 - y1; + if (dx > x_diff){ + RCT2_CALLPROC_X(0x684691, ax, x2, x_diff, dx, esi, edi, ebp); + return; + //jump 0x684691 + } + ax--; + if (ax < 0)return; + x_diff /= 2; + x_diff = -x_diff; + ebp = 0; + return;//not finished } - int ax = cx; - int dx = y2 - y1; - if (dx < 0){ + int ax = x_diff; + y_diff = y2 - y1; + if (y1 > y2){ + RCT2_CALLPROC_X(0x6845AB, ax, x2, x_diff, y_diff, esi, edi, ebp); + return; //jump 0x6845AB } - RCT2_GLOBAL(0xEDF846, uint16) = cx; - RCT2_GLOBAL(0xEDF848, uint16) = dx; - if (dx > cx){ + RCT2_GLOBAL(0xEDF846, uint16) = x_diff; + RCT2_GLOBAL(0xEDF848, uint16) = y_diff; + if ((y2 - y1) > (x2 - x1)){ + RCT2_CALLPROC_X(0x68456A, ax, x2, x_diff, y_diff, esi, edi, ebp); + return; //jump 0x68456A } ax--; if (ax < 0){ + RCT2_CALLPROC_X(0x684568, ax, x2, x_diff, y_diff, esi, edi, ebp); return;//jump 0x684568 } - cx /= 2; - cx = -cx; + x_diff /= 2; + x_diff = -x_diff; ebp = 0; for (int i = ax; i >= 0; i--){ ebp++; - cx += RCT2_GLOBAL(0xEDF848, sint16); - if (cx <= 0){ - i--; - if (i < 0){ - gfx_draw_line_on_buffer(edi, ebp, esi); + x_diff += y_diff; + if (x_diff <= 0){ + if (i-1 < 0){ + gfx_draw_line_on_buffer(dpi, (uint16)(0xFFFF & colour), edi, ebp, esi); return; } continue; } - cx -= RCT2_GLOBAL(0xEDF846, sint16); - gfx_draw_line_on_buffer(edi, ebp, esi); + x_diff -= x2 - x1; + gfx_draw_line_on_buffer(dpi, (uint16)(0xFFFF & colour), edi, ebp, esi); esi += ebp; edi++; ebp = 0; diff --git a/src/window_park.c b/src/window_park.c index e01ca4550a..6e3911f424 100644 --- a/src/window_park.c +++ b/src/window_park.c @@ -2139,7 +2139,6 @@ static void window_park_graph_draw_months(rct_drawpixelinfo *dpi, uint8 *history static void window_park_graph_draw_line_a(rct_drawpixelinfo *dpi, uint8 *history, int baseX, int baseY) { int i, x, y, lastX, lastY; - lastX = -1; x = baseX; for (i = 31; i >= 0; i--) { From 84342b07d20354a94ea5597be29c864640077a79 Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Sun, 11 May 2014 21:25:18 +0100 Subject: [PATCH 37/41] Replaced decompiled code with bresenhams algorithm. Gfx_draw_line finished. --- src/gfx.c | 136 ++++++++++++++++++++++-------------------------------- 1 file changed, 54 insertions(+), 82 deletions(-) diff --git a/src/gfx.c b/src/gfx.c index 7beb9bb6a7..b2ba5158aa 100644 --- a/src/gfx.c +++ b/src/gfx.c @@ -144,7 +144,7 @@ void gfx_draw_line_on_buffer(rct_drawpixelinfo *dpi, char colour, int y, int x, /** - * + * Draws a line on dpi if within dpi boundaries * rct2: 0x00684466 * dpi (edi) * x1 (ax) @@ -155,106 +155,78 @@ void gfx_draw_line_on_buffer(rct_drawpixelinfo *dpi, char colour, int y, int x, */ void gfx_draw_line(rct_drawpixelinfo *dpi, int x1, int y1, int x2, int y2, int colour) { - //RCT2_CALLPROC_X(0x00684466, x1, y1, x2, y2, 0, dpi, colour); - //return; - + // Check to make sure the line is within the drawing area if ((x1 < dpi->x) && (x2 < dpi->x)){ - return;//jump to 0x68474B + return; } if ((y1 < dpi->y) && (y2 < dpi->y)){ - return;//jump to 0x68474B + return; } - if ((x1 > (dpi->x + dpi->width)) && (x2 > (dpi->x + dpi->width))){ - return;//jump to 0x68474B + if ((x1 >(dpi->x + dpi->width)) && (x2 >(dpi->x + dpi->width))){ + return; } if ((y1 > (dpi->y + dpi->height)) && (y2 > (dpi->y + dpi->height))){ - return;//jump to 0x68474B + return; } - RCT2_GLOBAL(0xEDF84A, uint16) = (uint16)(0xFFFF & colour); + //Bresenhams algorithm - int bits_pointer; - bits_pointer = dpi->bits; - RCT2_GLOBAL(0x9ABDB8, uint32) = bits_pointer; - RCT2_GLOBAL(0x9ABDBC, uint16) = dpi->x; - RCT2_GLOBAL(0x9ABDBE, uint16) = dpi->y; - RCT2_GLOBAL(0x9ABDC0, uint16) = dpi->width; - RCT2_GLOBAL(0x9ABDC2, uint16) = dpi->height; - RCT2_GLOBAL(0x9ABDC4, uint16) = dpi->pitch; - - int edi = y1; - int esi = x1; - int ebp = colour & 0xFFFF; - int x_diff, y_diff; - x_diff = x2 - x1; + //If vertical plot points upwards + int steep = abs(y2 - y1) > abs(x2 - x1); + if (steep){ + int temp_y2 = y2; + int temp_x2 = x2; + y2 = x1; + x2 = y1; + y1 = temp_x2; + x1 = temp_y2; + } + //If line is right to left swap direction if (x1 > x2){ - x_diff = -x_diff; - int ax = x_diff; - int dx = y2 - y1; - if (dx < 0){ - RCT2_CALLPROC_X(0x6846C5, ax, x2, x_diff, dx, esi, edi, ebp); - return; - //jump 0x6846C5 - } - RCT2_GLOBAL(0xEDF846, uint16) = x_diff; - RCT2_GLOBAL(0xEDF848, uint16) = y2 - y1; - if (dx > x_diff){ - RCT2_CALLPROC_X(0x684691, ax, x2, x_diff, dx, esi, edi, ebp); - return; - //jump 0x684691 - } - ax--; - if (ax < 0)return; - x_diff /= 2; - x_diff = -x_diff; - ebp = 0; - return;//not finished + int temp_y2 = y2; + int temp_x2 = x2; + y2 = y1; + x2 = x1; + y1 = temp_y2; + x1 = temp_x2; } - int ax = x_diff; - y_diff = y2 - y1; - if (y1 > y2){ - RCT2_CALLPROC_X(0x6845AB, ax, x2, x_diff, y_diff, esi, edi, ebp); - return; - //jump 0x6845AB - } - RCT2_GLOBAL(0xEDF846, uint16) = x_diff; - RCT2_GLOBAL(0xEDF848, uint16) = y_diff; - if ((y2 - y1) > (x2 - x1)){ - RCT2_CALLPROC_X(0x68456A, ax, x2, x_diff, y_diff, esi, edi, ebp); - return; - //jump 0x68456A - } - ax--; - if (ax < 0){ - RCT2_CALLPROC_X(0x684568, ax, x2, x_diff, y_diff, esi, edi, ebp); - return;//jump 0x684568 - } - x_diff /= 2; - x_diff = -x_diff; - ebp = 0; - for (int i = ax; i >= 0; i--){ - ebp++; - x_diff += y_diff; - if (x_diff <= 0){ - if (i-1 < 0){ - gfx_draw_line_on_buffer(dpi, (uint16)(0xFFFF & colour), edi, ebp, esi); - return; - } - continue; + int delta_x = x2 - x1; + int delta_y = abs(y2 - y1); + int error = delta_x / 2; + int y_step; + int y = y1; + + //Direction of step + if (y1 < y2)y_step = 1; + else y_step = -1; + + for (int x = x1, x_start = x1, no_pixels = 1; x < x2; ++x,++no_pixels){ + //Vertical lines are drawn 1 pixel at a time + if (steep)gfx_draw_line_on_buffer(dpi, colour, x, y, 1); + + error -= delta_y; + if (error < 0){ + //Non vertical lines are drawn with as many pixels in a horizontal line as possible + if (!steep)gfx_draw_line_on_buffer(dpi, colour, y, x_start, no_pixels); + + //Reset non vertical line vars + x_start = x + 1; + no_pixels = 1; + y += y_step; + error += delta_x; + } + + //Catch the case of the last line + if (x + 1 == x2 && !steep){ + gfx_draw_line_on_buffer(dpi, colour, y, x_start, no_pixels); } - x_diff -= x2 - x1; - gfx_draw_line_on_buffer(dpi, (uint16)(0xFFFF & colour), edi, ebp, esi); - esi += ebp; - edi++; - ebp = 0; } return; - } /** From 19a475f05ae76d282927d921d0f0c5e75bcfee18 Mon Sep 17 00:00:00 2001 From: lnz Date: Sun, 11 May 2014 23:17:20 +0200 Subject: [PATCH 38/41] Implement ride upkeep payments --- src/finance.c | 30 ++++++++++++++++++++++++++++++ src/finance.h | 2 ++ src/ride.h | 3 ++- src/scenario.c | 4 ++-- 4 files changed, 36 insertions(+), 3 deletions(-) diff --git a/src/finance.c b/src/finance.c index 86eb3d1508..35cd5f74e6 100644 --- a/src/finance.c +++ b/src/finance.c @@ -23,6 +23,7 @@ #include "sprite.h" #include "park.h" #include "peep.h" +#include "ride.h" #include "window.h" // monthly cost @@ -102,6 +103,35 @@ void finance_pay_interest() finance_payment((sint32)tempcost, RCT_EXPENDITURE_TYPE_INTEREST); } +/** + * + * rct2: 0x006AC885 + */ +void finance_pay_ride_upkeep() +{ + rct_ride* ride; + for (int i = 0; i < 255; i++) { + ride = &(RCT2_ADDRESS(RCT2_ADDRESS_RIDE_LIST, rct_ride)[i]); + if (ride->type == RIDE_TYPE_NULL) + continue; + + if (!(ride->var_1D0 & 0x1000)) { + ride->build_date = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, uint16); + ride->var_196 = 25855; // durability? + + } + if (ride->status != RIDE_STATUS_CLOSED && !(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & 0x800)) { + sint16 upkeep = ride->upkeep_cost; + if (upkeep != -1) { + ride->var_158 -= upkeep; + ride->var_14D |= 2; + finance_payment(upkeep, RCT2_EXPENDITURE_TYPE_RIDE_UPKEEP); + } + } + } +} + + /** * * rct2: 0x0069DEFB diff --git a/src/finance.h b/src/finance.h index 3fc80726fb..7bb126cc01 100644 --- a/src/finance.h +++ b/src/finance.h @@ -28,6 +28,7 @@ typedef int rct_expenditure_type; enum { + RCT2_EXPENDITURE_TYPE_RIDE_UPKEEP = 1, RCT_EXPENDITURE_TYPE_WAGES = 10, RCT_EXPENDITURE_TYPE_RESEARCH = 12, RCT_EXPENDITURE_TYPE_INTEREST = 13 @@ -38,6 +39,7 @@ void finance_payment(int amount, rct_expenditure_type type); void finance_pay_wages(); void finance_pay_research(); void finance_pay_interest(); +void finance_pay_ride_upkeep(); void finance_init(); #endif \ No newline at end of file diff --git a/src/ride.h b/src/ride.h index f7152bf3e5..bac885d930 100644 --- a/src/ride.h +++ b/src/ride.h @@ -74,7 +74,8 @@ typedef struct { uint16 var_158; uint8 pad_15A[0x26]; uint16 build_date; - uint8 pad_182[0x14]; + sint16 upkeep_cost; // 0x182 + uint8 pad_184[0x12]; uint16 var_196; uint8 pad_198; uint8 var_199; diff --git a/src/scenario.c b/src/scenario.c index 954f2d489c..22a37ddf01 100644 --- a/src/scenario.c +++ b/src/scenario.c @@ -893,8 +893,8 @@ void scenario_update() //if ( (unsigned int)((2 * current_day) & 0xFFFF) >= 0xFFF8) { if (next_month_tick % 0x8000 == 0) { - // biweekly checks - RCT2_CALLPROC_EBPSAFE(0x006AC885); + // fortnightly + finance_pay_ride_upkeep(); } RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_TICKS, uint16) = next_month_tick; From bb12fc1a427b3b1c0b4b24a2ffa5930bdf153bb4 Mon Sep 17 00:00:00 2001 From: lnz Date: Sun, 11 May 2014 23:21:26 +0200 Subject: [PATCH 39/41] Implement update for ride favourited numbers --- src/finance.c | 2 +- src/ride.c | 35 ++++++++++++++++++++++++++++++++++- src/ride.h | 1 + src/scenario.c | 8 ++++---- 4 files changed, 40 insertions(+), 6 deletions(-) diff --git a/src/finance.c b/src/finance.c index 35cd5f74e6..7db4b107b0 100644 --- a/src/finance.c +++ b/src/finance.c @@ -110,7 +110,7 @@ void finance_pay_interest() void finance_pay_ride_upkeep() { rct_ride* ride; - for (int i = 0; i < 255; i++) { + for (int i = 0; i < MAX_RIDES; i++) { ride = &(RCT2_ADDRESS(RCT2_ADDRESS_RIDE_LIST, rct_ride)[i]); if (ride->type == RIDE_TYPE_NULL) continue; diff --git a/src/ride.c b/src/ride.c index bb4d8e7164..42f32287ff 100644 --- a/src/ride.c +++ b/src/ride.c @@ -20,6 +20,9 @@ #include "addresses.h" #include "ride.h" +#include "sprite.h" +#include "peep.h" +#include "window.h" #define GET_RIDE(x) (&(RCT2_ADDRESS(RCT2_ADDRESS_RIDE_LIST, rct_ride)[x])) #define GET_RIDE_MEASUREMENT(x) (&(RCT2_ADDRESS(RCT2_ADDRESS_RIDE_MEASUREMENTS, rct_ride_measurement)[x])) @@ -166,4 +169,34 @@ void reset_all_ride_build_dates() { ride->build_date -= RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, uint16); } } -} \ No newline at end of file +} + +/** + * rct2: 0x006AC916 + */ +void ride_update_favourited_stat() +{ + rct_ride *ride; + rct_peep* peep; + + for (int i = 0; i < MAX_RIDES; i++) { + ride = GET_RIDE(i); + if (ride->type != RIDE_TYPE_NULL) + ride->guests_favourite = 0; + + } + for (int 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->var_08 != 4) + return; + if (peep->favourite_ride != 0xff) { + ride = GET_RIDE(peep->favourite_ride); + ride->guests_favourite++; + ride->var_14D |= 1; + + } + + } + window_invalidate_by_id(WC_RIDE_LIST, 0); +} + diff --git a/src/ride.h b/src/ride.h index bac885d930..84eb778120 100644 --- a/src/ride.h +++ b/src/ride.h @@ -261,5 +261,6 @@ int ride_get_total_queue_length(rct_ride *ride); int ride_get_max_queue_time(rct_ride *ride); void ride_init_all(); void reset_all_ride_build_dates(); +void ride_update_favourited_stat(); #endif diff --git a/src/scenario.c b/src/scenario.c index 22a37ddf01..81f97bbd08 100644 --- a/src/scenario.c +++ b/src/scenario.c @@ -604,7 +604,7 @@ void scenario_objective5_check() memset(type_already_counted, 0, 256); - for (int i = 0; i < 255; i++) { + for (int i = 0; i < MAX_RIDES; i++) { uint8 subtype_id; uint32 subtype_p; ride = &(RCT2_ADDRESS(RCT2_ADDRESS_RIDE_LIST, rct_ride)[i]); @@ -640,7 +640,7 @@ void scenario_objective8_check() memset(type_already_counted, 0, 256); - for (int i = 0; i < 255; i++) { + for (int i = 0; i < MAX_RIDES; i++) { uint8 subtype_id; uint32 subtype_p; ride = &(RCT2_ADDRESS(RCT2_ADDRESS_RIDE_LIST, rct_ride)[i]); @@ -741,7 +741,7 @@ void scenario_objectives_check() { rct_ride* ride; int rcs = 0; - for (int i = 0; i < 255; i++) { + for (int i = 0; i < MAX_RIDES; i++) { ride = &(RCT2_ADDRESS(RCT2_ADDRESS_RIDE_LIST, rct_ride)[i]); if (ride->status && ride->excitement > objective_currency) rcs++; @@ -875,7 +875,7 @@ void scenario_update() scenario_marketing_update(); peep_problem_warnings_update(); RCT2_CALLPROC_EBPSAFE(0x006B7A5E); // check ride reachability - RCT2_CALLPROC_EBPSAFE(0x006AC916); // ride update favourited + ride_update_favourited_stat(); if (month <= 1 && RCT2_GLOBAL(0x009ADAE0, sint32) != -1 && RCT2_GLOBAL(0x009ADAE0 + 14, uint16) & 1) { for (int i = 0; i < 100; ++i) { From 8dcca91092e4da8dbd6cf40388aeb7784421cd52 Mon Sep 17 00:00:00 2001 From: IntelOrca Date: Mon, 12 May 2014 01:45:45 +0100 Subject: [PATCH 40/41] mass clean up and reduce warnings --- projects/openrct2.vcxproj | 6 +- projects/openrct2.vcxproj.filters | 3 - src/config.c | 24 ++--- src/game.c | 143 ++++++++++++++---------------- src/gfx.c | 27 +++--- src/map.c | 5 +- src/map.h | 2 +- src/news_item.c | 22 ++--- src/news_item.h | 3 +- src/object.c | 2 +- src/object.h | 2 +- src/osinterface.c | 10 +-- src/osinterface.h | 4 +- src/park.c | 2 +- src/peep.c | 6 +- src/rct2.c | 19 ++-- src/sawyercoding.c | 11 ++- src/sawyercoding.h | 4 +- src/scenario.c | 79 ++++++++--------- src/screenshot.c | 8 +- src/settings.c | 28 ------ src/settings.h | 33 ------- src/strings.c | 2 +- src/title.c | 8 +- src/viewport.c | 6 +- src/widget.c | 32 ++++--- src/window.c | 88 +++++++++--------- src/window_news.c | 2 +- 28 files changed, 249 insertions(+), 332 deletions(-) delete mode 100644 src/settings.c delete mode 100644 src/settings.h diff --git a/projects/openrct2.vcxproj b/projects/openrct2.vcxproj index 75fc4d2765..1f0de53737 100644 --- a/projects/openrct2.vcxproj +++ b/projects/openrct2.vcxproj @@ -74,7 +74,6 @@ - @@ -160,6 +159,7 @@ Disabled true 1Byte + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) true @@ -172,13 +172,15 @@ Disabled true true - true + + MultiThreaded 1Byte 4013 false + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) true diff --git a/projects/openrct2.vcxproj.filters b/projects/openrct2.vcxproj.filters index 7350319a76..559453fe4d 100644 --- a/projects/openrct2.vcxproj.filters +++ b/projects/openrct2.vcxproj.filters @@ -269,9 +269,6 @@ Windows - - Source Files - Windows diff --git a/src/config.c b/src/config.c index f1b2ddd385..97263fb994 100644 --- a/src/config.c +++ b/src/config.c @@ -137,10 +137,10 @@ void config_save() HANDLE hFile; DWORD bytesWritten; - hFile = CreateFile(get_file_path(PATH_ID_GAMECFG), GENERIC_WRITE, NULL, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + hFile = CreateFile(get_file_path(PATH_ID_GAMECFG), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (hFile != INVALID_HANDLE_VALUE) { WriteFile(hFile, &MagicNumber, 4, &bytesWritten, NULL); - WriteFile(hFile, 0x009AAC5C, 2155, &bytesWritten, NULL); + WriteFile(hFile, (LPCVOID)0x009AAC5C, 2155, &bytesWritten, NULL); CloseHandle(hFile); } } @@ -252,7 +252,7 @@ static void config_create_default(char *path) */ static void config_parse_settings(FILE *fp) { - int c = NULL, pos = 0; + int pos = 0; char *setting; char *value; char *section; @@ -389,36 +389,36 @@ static int config_parse_setting(FILE *fp, char *setting){ * @param value a pointer to where to store the value * @return < 0 if EOF is reached */ -static int config_parse_value(FILE *fp, char *value){ +static int config_parse_value(FILE *fp, char *value) +{ long start, end; int size, c, pos = 0; start = ftell(fp); c = fgetc(fp); - while (isspace(c)){ + while (isspace(c)) { start = ftell(fp); c = fgetc(fp); - } - while (c != EOF && c != '\n'){ + while (c != EOF && c != '\n') { c = fgetc(fp); } + end = ftell(fp); size = end - start; - if (size > MAX_CONFIG_LENGTH){ + if (size > MAX_CONFIG_LENGTH) config_error("One of your settings is too long"); - } + fseek(fp, start, SEEK_SET); c = fgetc(fp); - while (c != EOF && c != '\n'){ - + while (c != EOF && c != '\n') { value[pos] = (char)c; c = fgetc(fp); pos++; } value[pos] = '\0'; - return; + return 0; } /** diff --git a/src/game.c b/src/game.c index ad0852b179..18f6c14414 100644 --- a/src/game.c +++ b/src/game.c @@ -195,7 +195,7 @@ void game_handle_input() if (RCT2_GLOBAL(0x009ABDF2, uint8) != 0) { for (w = RCT2_ADDRESS(RCT2_ADDRESS_WINDOW_LIST, rct_window); w < RCT2_GLOBAL(RCT2_ADDRESS_NEW_WINDOW_PTR, rct_window*); w++) - RCT2_CALLPROC_X(w->event_handlers[WE_UNKNOWN_07], 0, 0, 0, 0, w, 0, 0); + RCT2_CALLPROC_X(w->event_handlers[WE_UNKNOWN_07], 0, 0, 0, 0, (int)w, 0, 0); RCT2_CALLPROC_EBPSAFE(0x006EA73F); RCT2_CALLPROC_EBPSAFE(0x006E8346); // update_cursor_position @@ -228,7 +228,7 @@ void game_handle_input() } for (w = RCT2_ADDRESS(RCT2_ADDRESS_WINDOW_LIST, rct_window); w < RCT2_GLOBAL(RCT2_ADDRESS_NEW_WINDOW_PTR, rct_window*); w++) - RCT2_CALLPROC_X(w->event_handlers[WE_UNKNOWN_08], 0, 0, 0, 0, w, 0, 0); + RCT2_CALLPROC_X(w->event_handlers[WE_UNKNOWN_08], 0, 0, 0, 0, (int)w, 0, 0); } /** @@ -288,11 +288,9 @@ static void input_leftmousedown(int x, int y, rct_window *w, int widgetIndex); */ static void game_handle_input_mouse(int x, int y, int state) { - rct_window *w, *w2; + rct_window *w; rct_widget *widget; int widgetIndex; - rct_windowclass windowClass; - rct_windownumber windowNumber; // Get window and widget under cursor position w = window_find_from_point(x, y); @@ -347,7 +345,7 @@ static void game_handle_input_mouse(int x, int y, int state) break; case INPUT_STATE_WIDGET_PRESSED: - RCT2_CALLPROC_X(0x006E8DA7, x, y, state, widgetIndex, w, widget, 0); + RCT2_CALLPROC_X(0x006E8DA7, x, y, state, widgetIndex, (int)w, (int)widget, 0); break; case INPUT_STATE_DRAGGING: // RCT2_CALLPROC_X(0x006E8C5C, x, y, state, widgetIndex, w, widget, 0); @@ -370,7 +368,7 @@ static void game_handle_input_mouse(int x, int y, int state) } else if (state == 2) { RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) = INPUT_STATE_NORMAL; RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_TIMEOUT, uint8) = 0; - RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WIDGET_INDEX, uint8) = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WIDGETINDEX, sint16); + RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WIDGET_INDEX, uint16) = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WIDGETINDEX, sint16); RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WINDOW_CLASS, rct_windowclass) = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWCLASS, rct_windowclass); RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WINDOW_NUMBER, rct_windownumber) = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWNUMBER, rct_windownumber); y = clamp(29, y, RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, uint16) - 34); @@ -382,7 +380,7 @@ static void game_handle_input_mouse(int x, int y, int state) RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_X, sint16) = x; RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_Y, sint16) = y; - RCT2_CALLPROC_X(w->event_handlers[WE_UNKNOWN_18], 0, 0, x, y, w, 0, 0); + RCT2_CALLPROC_X(w->event_handlers[WE_UNKNOWN_18], 0, 0, x, y, (int)w, 0, 0); } break; case INPUT_STATE_VIEWPORT_DRAG: @@ -460,13 +458,13 @@ static void game_handle_input_mouse(int x, int y, int state) break; } case INPUT_STATE_DROPDOWN_ACTIVE: - RCT2_CALLPROC_X(0x006E8DA7, x, y, state, widgetIndex, w, widget, 0); + RCT2_CALLPROC_X(0x006E8DA7, x, y, state, widgetIndex, (int)w, (int)widget, 0); break; case INPUT_STATE_VIEWPORT_LEFT: - RCT2_CALLPROC_X(0x006E87B4, x, y, state, widgetIndex, w, widget, 0); + RCT2_CALLPROC_X(0x006E87B4, x, y, state, widgetIndex, (int)w, (int)widget, 0); break; case INPUT_STATE_SCROLL_LEFT: - RCT2_CALLPROC_X(0x006E8676, x, y, state, widgetIndex, w, widget, 0); + RCT2_CALLPROC_X(0x006E8676, x, y, state, widgetIndex, (int)w, (int)widget, 0); break; case INPUT_STATE_RESIZING: // RCT2_CALLPROC_X(0x006E8B46, x, y, state, widgetIndex, w, widget, 0); @@ -482,7 +480,7 @@ static void game_handle_input_mouse(int x, int y, int state) if (state == 2) { RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) = INPUT_STATE_NORMAL; RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_TIMEOUT, uint8) = 0; - RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WIDGET_INDEX, uint8) = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WIDGETINDEX, sint16); + RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WIDGET_INDEX, uint16) = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WIDGETINDEX, sint16); RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WINDOW_CLASS, rct_windowclass) = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWCLASS, rct_windowclass); RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WINDOW_NUMBER, rct_windownumber) = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWNUMBER, rct_windownumber); } @@ -498,7 +496,7 @@ static void game_handle_input_mouse(int x, int y, int state) RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_Y, sint16) = y; break; case 9: - RCT2_CALLPROC_X(0x006E8ACB, x, y, state, widgetIndex, w, widget, 0); + RCT2_CALLPROC_X(0x006E8ACB, x, y, state, widgetIndex, (int)w, (int)widget, 0); break; } } @@ -527,8 +525,8 @@ static void input_mouseover(int x, int y, rct_window *w, int widgetIndex) int eax, ebx, ecx, edx, esi, edi, ebp; eax = x; ebx = y; - esi = w; - edi = widget; + esi = (int)w; + edi = (int)widget; RCT2_CALLFUNC_X(0x006E9F92, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); // widget_scoll_get_part eax &= 0xFFFF; ebx &= 0xFFFF; @@ -537,7 +535,7 @@ static void input_mouseover(int x, int y, rct_window *w, int widgetIndex) if (ecx < 0) goto showTooltip; if (ecx == 0) { - RCT2_CALLPROC_X(w->event_handlers[WE_SCROLL_MOUSEOVER], edx, 0, eax, ebx, w, 0, 0); + RCT2_CALLPROC_X(w->event_handlers[WE_SCROLL_MOUSEOVER], edx, 0, eax, ebx, (int)w, 0, 0); goto showTooltip; } else { @@ -585,8 +583,6 @@ static void input_mouseover(int x, int y, rct_window *w, int widgetIndex) */ static void input_mouseover_widget_check(rct_windowclass windowClass, rct_windownumber windowNumber, int widgetIndex) { - rct_window *w; - // Check if widget cursor was over has changed if (windowClass != RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_OVER_WINDOWCLASS, rct_windowclass) || windowNumber != RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_OVER_WINDOWNUMBER, rct_windownumber) || @@ -597,8 +593,8 @@ static void input_mouseover_widget_check(rct_windowclass windowClass, rct_window // Set new cursor over widget RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_OVER_WINDOWCLASS, rct_windowclass) = windowClass; - RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_OVER_WINDOWNUMBER, rct_windowclass) = windowNumber; - RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_OVER_WIDGETINDEX, rct_windowclass) = widgetIndex; + RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_OVER_WINDOWNUMBER, rct_windownumber) = windowNumber; + RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_OVER_WIDGETINDEX, uint16) = widgetIndex; // Invalidate new widget cursor is on if widget is a flat button if (windowClass != 255) @@ -612,7 +608,7 @@ static void input_mouseover_widget_flatbutton_invalidate() if (w == NULL) return; - RCT2_CALLPROC_X(w->event_handlers[WE_INVALIDATE], 0, 0, 0, 0, w, 0, 0); + RCT2_CALLPROC_X(w->event_handlers[WE_INVALIDATE], 0, 0, 0, 0, (int)w, 0, 0); if (w->widgets[RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_OVER_WIDGETINDEX, rct_windownumber)].type == WWT_FLATBTN) widget_invalidate(RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_OVER_WINDOWCLASS, rct_windowclass), RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_OVER_WINDOWNUMBER, rct_windownumber), RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_OVER_WIDGETINDEX, rct_windownumber)); } @@ -676,7 +672,7 @@ static void input_leftmousedown(int x, int y, rct_window *w, int widgetIndex) if (w == NULL) break; - RCT2_CALLPROC_X(w->event_handlers[WE_TOOL_DOWN], x, y, 0, RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WIDGETINDEX, uint16), w, 0, 0); + RCT2_CALLPROC_X(w->event_handlers[WE_TOOL_DOWN], x, y, 0, RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WIDGETINDEX, uint16), (int)w, 0, 0); RCT2_GLOBAL(0x009DE518, uint32) |= (1 << 4); break; case WWT_CAPTION: @@ -698,8 +694,8 @@ static void input_leftmousedown(int x, int y, rct_window *w, int widgetIndex) int eax, ebx, ecx, edx, esi, edi, ebp; eax = x; ebx = y; - esi = w; - edi = widget; + esi = (int)w; + edi = (int)widget; RCT2_CALLFUNC_X(0x006E9F92, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); // widget_scoll_get_part eax &= 0xFFFF; ebx &= 0xFFFF; @@ -708,42 +704,42 @@ static void input_leftmousedown(int x, int y, rct_window *w, int widgetIndex) RCT2_GLOBAL(0x009DE548, uint16) = ecx; RCT2_GLOBAL(0x009DE54C, uint32) = edx; - RCT2_CALLPROC_X(w->event_handlers[WE_UNKNOWN_15], RCT2_GLOBAL(0x009DE54C, uint32), ebx, ecx, edx, w, widget, 0); + RCT2_CALLPROC_X(w->event_handlers[WE_UNKNOWN_15], RCT2_GLOBAL(0x009DE54C, uint32), ebx, ecx, edx, (int)w, (int)widget, 0); switch (ecx) { case SCROLL_PART_VIEW: - RCT2_CALLPROC_X(w->event_handlers[WE_SCROLL_MOUSEDOWN], edx / sizeof(rct_scroll), ebx, eax, ebx, w, widget, 0); + RCT2_CALLPROC_X(w->event_handlers[WE_SCROLL_MOUSEDOWN], edx / sizeof(rct_scroll), ebx, eax, ebx, (int)w, (int)widget, 0); break; case SCROLL_PART_HSCROLLBAR_LEFT: // 0x006E9A60 - RCT2_CALLPROC_X(0x006E9A60, 0, 0, 0, 0, w, 0, 0); + RCT2_CALLPROC_X(0x006E9A60, 0, 0, 0, 0, (int)w, 0, 0); break; case SCROLL_PART_HSCROLLBAR_RIGHT: // 0x006E9ABF - RCT2_CALLPROC_X(0x006E9ABF, 0, 0, 0, 0, w, 0, 0); + RCT2_CALLPROC_X(0x006E9ABF, 0, 0, 0, 0, (int)w, 0, 0); break; case SCROLL_PART_HSCROLLBAR_LEFT_TROUGH: // 0x006E9B47 - RCT2_CALLPROC_X(0x006E9B47, 0, 0, 0, 0, w, 0, 0); + RCT2_CALLPROC_X(0x006E9B47, 0, 0, 0, 0, (int)w, 0, 0); break; case SCROLL_PART_HSCROLLBAR_RIGHT_TROUGH: // 0x006E9BB7 - RCT2_CALLPROC_X(0x006E9BB7, 0, 0, 0, 0, w, 0, 0); + RCT2_CALLPROC_X(0x006E9BB7, 0, 0, 0, 0, (int)w, 0, 0); break; case SCROLL_PART_VSCROLLBAR_TOP: // 0x006E9C37 - RCT2_CALLPROC_X(0x006E9C37, 0, 0, 0, 0, w, 0, 0); + RCT2_CALLPROC_X(0x006E9C37, 0, 0, 0, 0, (int)w, 0, 0); break; case SCROLL_PART_VSCROLLBAR_BOTTOM: // 0x006E9C96 - RCT2_CALLPROC_X(0x006E9C96, 0, 0, 0, 0, w, 0, 0); + RCT2_CALLPROC_X(0x006E9C96, 0, 0, 0, 0, (int)w, 0, 0); break; case SCROLL_PART_VSCROLLBAR_TOP_TROUGH: // 0x006E9D1E - RCT2_CALLPROC_X(0x006E9D1E, 0, 0, 0, 0, w, 0, 0); + RCT2_CALLPROC_X(0x006E9D1E, 0, 0, 0, 0, (int)w, 0, 0); break; case SCROLL_PART_VSCROLLBAR_BOTTOM_TROUGH: // 0x006E9D8E - RCT2_CALLPROC_X(0x006E9D8E, 0, 0, 0, 0, w, 0, 0); + RCT2_CALLPROC_X(0x006E9D8E, 0, 0, 0, 0, (int)w, 0, 0); break; } break; @@ -757,14 +753,14 @@ static void input_leftmousedown(int x, int y, rct_window *w, int widgetIndex) // Set new cursor down widget RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWCLASS, rct_windowclass) = windowClass; - RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWNUMBER, rct_windowclass) = windowNumber; - RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WIDGETINDEX, rct_windowclass) = widgetIndex; + RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWNUMBER, rct_windownumber) = windowNumber; + RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WIDGETINDEX, uint16) = widgetIndex; RCT2_GLOBAL(0x009DE518, uint32) |= (1 << 0); RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) = INPUT_STATE_WIDGET_PRESSED; RCT2_GLOBAL(0x009DE528, uint16) = 1; widget_invalidate(windowClass, windowNumber, widgetIndex); - RCT2_CALLPROC_X(w->event_handlers[WE_MOUSE_DOWN], 0, 0, 0, widgetIndex, w, widget, 0); + RCT2_CALLPROC_X(w->event_handlers[WE_MOUSE_DOWN], 0, 0, 0, widgetIndex, (int)w, (int)widget, 0); break; } } @@ -877,7 +873,7 @@ void handle_shortcut_command(int shortcutIndex) case SHORTCUT_CLOSE_ALL_FLOATING_WINDOWS: if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2)) window_close_all(); - else if (RCT2_ADDRESS(0x0141F570, uint8) == 1) + else if (RCT2_GLOBAL(0x0141F570, uint8) == 1) window_close_top(); break; case SHORTCUT_CANCEL_CONSTRUCTION_MODE: @@ -897,7 +893,7 @@ void handle_shortcut_command(int shortcutIndex) } break; case SHORTCUT_ZOOM_VIEW_OUT: - if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) || RCT2_ADDRESS(0x0141F570, uint8) == 1) { + if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) || RCT2_GLOBAL(0x0141F570, uint8) == 1) { if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 8)) { window = window_find_by_id(WC_TOP_TOOLBAR, 0); if (window != NULL) { @@ -908,7 +904,7 @@ void handle_shortcut_command(int shortcutIndex) } break; case SHORTCUT_ZOOM_VIEW_IN: - if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) || RCT2_ADDRESS(0x0141F570, uint8) == 1) { + if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) || RCT2_GLOBAL(0x0141F570, uint8) == 1) { if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 8)) { window = window_find_by_id(WC_TOP_TOOLBAR, 0); if (window != NULL) { @@ -919,7 +915,7 @@ void handle_shortcut_command(int shortcutIndex) } break; case SHORTCUT_ROTATE_VIEW: - if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) || RCT2_ADDRESS(0x0141F570, uint8) == 1) { + if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) || RCT2_GLOBAL(0x0141F570, uint8) == 1) { if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 8)) { window = window_find_by_id(WC_TOP_TOOLBAR, 0); if (window != NULL) { @@ -963,7 +959,7 @@ void handle_shortcut_command(int shortcutIndex) RCT2_CALLPROC_X(0x0066CF8A, 11, 0, 0, 0, 0, 0, 0); break; case SHORTCUT_ADJUST_LAND: - if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) || RCT2_ADDRESS(0x0141F570, uint8) == 1) { + if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) || RCT2_GLOBAL(0x0141F570, uint8) == 1) { if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0C)) { window = window_find_by_id(WC_TOP_TOOLBAR, 0); if (window != NULL) { @@ -974,7 +970,7 @@ void handle_shortcut_command(int shortcutIndex) } break; case SHORTCUT_ADJUST_WATER: - if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) || RCT2_ADDRESS(0x0141F570, uint8) == 1) { + if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) || RCT2_GLOBAL(0x0141F570, uint8) == 1) { if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0C)) { window = window_find_by_id(WC_TOP_TOOLBAR, 0); if (window != NULL) { @@ -985,7 +981,7 @@ void handle_shortcut_command(int shortcutIndex) } break; case SHORTCUT_BUILD_SCENERY: - if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) || RCT2_ADDRESS(0x0141F570, uint8) == 1) { + if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) || RCT2_GLOBAL(0x0141F570, uint8) == 1) { if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0C)) { window = window_find_by_id(WC_TOP_TOOLBAR, 0); if (window != NULL) { @@ -996,7 +992,7 @@ void handle_shortcut_command(int shortcutIndex) } break; case SHORTCUT_BUILD_PATHS: - if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) || RCT2_ADDRESS(0x0141F570, uint8) == 1) { + if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) || RCT2_GLOBAL(0x0141F570, uint8) == 1) { if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0C)) { window = window_find_by_id(WC_TOP_TOOLBAR, 0); if (window != NULL) { @@ -1007,7 +1003,7 @@ void handle_shortcut_command(int shortcutIndex) } break; case SHORTCUT_BUILD_NEW_RIDE: - if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) || RCT2_ADDRESS(0x0141F570, uint8) == 1) { + if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) || RCT2_GLOBAL(0x0141F570, uint8) == 1) { if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0C)) { window = window_find_by_id(WC_TOP_TOOLBAR, 0); if (window != NULL) { @@ -1072,7 +1068,7 @@ void handle_shortcut_command(int shortcutIndex) window_news_open(); break; case SHORTCUT_SHOW_MAP: - if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) || RCT2_ADDRESS(0x0141F570, uint8) == 1) { + if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) || RCT2_GLOBAL(0x0141F570, uint8) == 1) { if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0C)) { window = window_find_by_id(WC_TOP_TOOLBAR, 0); if (window != NULL) { @@ -1133,7 +1129,7 @@ void set_shortcut(int key) void game_handle_keyboard_input() { rct_window *w; - int key, i; + int key; // Handle mouse scrolling if (RCT2_GLOBAL(RCT2_ADDRESS_ON_TUTORIAL, uint8) == 0) @@ -1182,7 +1178,7 @@ void game_handle_keyboard_input() if (RCT2_GLOBAL(RCT2_ADDRESS_PLACE_OBJECT_MODIFIER, uint8) & 4) { window_tooltip_close(); if ((w = window_get_main()) != NULL) { - RCT2_CALLPROC_X(0x006EA2AA, 0, 0, 0, 0, w, RCT2_GLOBAL(0x009DEA72, uint16), 0); + RCT2_CALLPROC_X(0x006EA2AA, 0, 0, 0, 0, (int)w, RCT2_GLOBAL(0x009DEA72, uint16), 0); RCT2_GLOBAL(0x009DEA72, uint16)++; } } @@ -1190,7 +1186,7 @@ void game_handle_keyboard_input() if (!(RCT2_GLOBAL(RCT2_ADDRESS_PLACE_OBJECT_MODIFIER, uint8) & 4)) { window_tooltip_close(); if ((w = window_get_main()) != NULL) { - RCT2_CALLPROC_X(0x006EA2AA, 0, 0, 0, 0, w, RCT2_GLOBAL(0x009DEA72, uint16), 0); + RCT2_CALLPROC_X(0x006EA2AA, 0, 0, 0, 0, (int)w, RCT2_GLOBAL(0x009DEA72, uint16), 0); RCT2_GLOBAL(0x009DEA72, uint16)++; } } @@ -1311,9 +1307,7 @@ int game_do_command(int eax, int ebx, int ecx, int edx, int esi, int edi, int eb */ static void game_pause_toggle() { - rct_window *w; - char input_bl, input_dl; - short input_di; + char input_bl; __asm mov input_bl, bl @@ -1335,7 +1329,6 @@ static void game_pause_toggle() */ static void game_load_or_quit() { - rct_window *w; char input_bl, input_dl; short input_di; @@ -1368,11 +1361,11 @@ static void game_load_or_quit() */ 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); + format_string((char*)0x0141ED68, STR_LOAD_LANDSCAPE_DIALOG_TITLE, 0); + strcpy((char*)0x0141EF68, (char*)RCT2_ADDRESS_LANDSCAPES_PATH); + format_string((char*)0x0141EE68, STR_RCT2_LANDSCAPE_FILE, 0); pause_sounds(); - osinterface_open_common_file_dialog(1, 0x0141ED68, 0x0141EF68, "*.SV6;*.SV4;*.SC6", 0x0141EE68); + osinterface_open_common_file_dialog(1, (char*)0x0141ED68, (char*)0x0141EF68, "*.SV6;*.SV4;*.SC6", (char*)0x0141EE68); unpause_sounds(); // window_proc } @@ -1384,11 +1377,11 @@ 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); + format_string((char*)0x0141ED68, STR_LOAD_GAME_DIALOG_TITLE, 0); + strcpy((char*)0x0141EF68, (char*)RCT2_ADDRESS_SAVED_GAMES_PATH); + format_string((char*)0x0141EE68, STR_RCT2_SAVED_GAME, 0); pause_sounds(); - result = osinterface_open_common_file_dialog(1, 0x0141ED68, 0x0141EF68, "*.SV6", 0x0141EE68); + result = osinterface_open_common_file_dialog(1, (char*)0x0141ED68, (char*)0x0141EF68, "*.SV6", (char*)0x0141EE68); unpause_sounds(); // window_proc return result; @@ -1404,7 +1397,7 @@ static void load_landscape() gfx_invalidate_screen(); } else { // Set default filename - char *esi = 0x0141EF67; + char *esi = (char*)0x0141EF67; while (1) { esi++; if (*esi == '.') @@ -1414,7 +1407,7 @@ static void load_landscape() strcpy(esi, ".SC6"); break; } - strcpy(0x009ABB37, 0x0141EF68); + strcpy((char*)0x009ABB37, (char*)0x0141EF68); RCT2_CALLPROC_EBPSAFE(0x006758C0); // landscape_load if (1) { @@ -1456,11 +1449,11 @@ int game_load_save() return 0; } - rct_s6_header *s6Header = 0x009E34E4; - rct_s6_info *s6Info = 0x0141F570; + rct_s6_header *s6Header = (rct_s6_header*)0x009E34E4; + rct_s6_info *s6Info = (rct_s6_info*)0x0141F570; // Read first chunk - sawyercoding_read_chunk(hFile, s6Header); + sawyercoding_read_chunk(hFile, (uint8*)s6Header); if (s6Header->type == S6_TYPE_SAVEDGAME) { // Read packed objects if (s6Header->num_packed_objects > 0) { @@ -1475,14 +1468,14 @@ int game_load_save() object_read_and_load_entries(hFile); // Read flags (16 bytes) - sawyercoding_read_chunk(hFile, RCT2_ADDRESS_CURRENT_MONTH_YEAR); + sawyercoding_read_chunk(hFile, (uint8*)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); + memset((void*)RCT2_ADDRESS_MAP_ELEMENTS, 0, MAX_MAP_ELEMENTS * sizeof(rct_map_element)); + sawyercoding_read_chunk(hFile, (uint8*)RCT2_ADDRESS_MAP_ELEMENTS); // Read game data, including sprites - sawyercoding_read_chunk(hFile, 0x010E63B8); + sawyercoding_read_chunk(hFile, (uint8*)0x010E63B8); CloseHandle(hFile); @@ -1540,7 +1533,7 @@ static void load_game() gfx_invalidate_screen(); } else { // Set default filename - char *esi = 0x0141EF67; + char *esi = (char*)0x0141EF67; while (1) { esi++; if (*esi == '.') @@ -1550,7 +1543,7 @@ static void load_game() strcpy(esi, ".SV6"); break; } - strcpy(0x009ABB37, 0x0141EF68); + strcpy((char*)0x009ABB37, (char*)0x0141EF68); if (game_load_save()) { gfx_invalidate_screen(); @@ -1602,10 +1595,10 @@ void game_load_or_quit_no_save_prompt() static uint32 game_do_command_table[58] = { 0x006B2FC5, 0x0066397F, - game_pause_toggle, + (uint32)game_pause_toggle, 0x006C511D, 0x006C5B69, - game_load_or_quit, + (uint32)game_load_or_quit, 0x006B3F0F, 0x006B49D9, 0x006B4EA6, diff --git a/src/gfx.c b/src/gfx.c index b2ba5158aa..b0f8a59487 100644 --- a/src/gfx.c +++ b/src/gfx.c @@ -241,7 +241,7 @@ void gfx_draw_line(rct_drawpixelinfo *dpi, int x1, int y1, int x2, int y2, int c */ void gfx_fill_rect(rct_drawpixelinfo *dpi, int left, int top, int right, int bottom, int colour) { - RCT2_CALLPROC_X(0x00678AD4, left, right, top, bottom, 0, dpi, colour); + RCT2_CALLPROC_X(0x00678AD4, left, right, top, bottom, 0, (int)dpi, colour); } /** @@ -257,7 +257,7 @@ void gfx_fill_rect(rct_drawpixelinfo *dpi, int left, int top, int right, int bot */ void gfx_fill_rect_inset(rct_drawpixelinfo* dpi, short left, short top, short right, short bottom, int colour, short _si) { - RCT2_CALLPROC_X(0x006E6F81, left, right, top, bottom, _si, dpi, colour); + RCT2_CALLPROC_X(0x006E6F81, left, right, top, bottom, _si, (int)dpi, colour); } /** @@ -269,7 +269,7 @@ void gfx_fill_rect_inset(rct_drawpixelinfo* dpi, short left, short top, short ri */ void gfx_draw_sprite(rct_drawpixelinfo *dpi, int image_id, int x, int y) { - RCT2_CALLPROC_X(0x0067A28E, 0, image_id, x, y, 0, dpi, 0); + RCT2_CALLPROC_X(0x0067A28E, 0, image_id, x, y, 0, (int)dpi, 0); } /** @@ -312,7 +312,7 @@ void gfx_transpose_palette(int pal, unsigned char product) */ void gfx_draw_string_centred(rct_drawpixelinfo *dpi, int format, int x, int y, int colour, void *args) { - RCT2_CALLPROC_X(0x006C1D6C, colour, format, x, y, args, dpi, 0); + RCT2_CALLPROC_X(0x006C1D6C, colour, format, x, y, (int)args, (int)dpi, 0); } /** @@ -369,7 +369,6 @@ void gfx_set_dirty_blocks(int left, int top, int right, int bottom) void gfx_draw_all_dirty_blocks() { int x, y, xx, yy, columns, rows; - short left, top, right, bottom; uint8 *screenDirtyBlocks = RCT2_ADDRESS(0x00EDE408, uint8); for (x = 0; x < RCT2_GLOBAL(RCT2_ADDRESS_DIRTY_BLOCK_COLUMNS, sint32); x++) { @@ -462,7 +461,7 @@ int gfx_get_string_width(char *buffer) { int eax, ebx, ecx, edx, esi, edi, ebp; - esi = buffer; + esi = (int)buffer; RCT2_CALLFUNC_X(0x006C2321, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); return ecx & 0xFFFF; @@ -482,7 +481,7 @@ int gfx_get_string_width(char *buffer) */ void gfx_draw_string_left_clipped(rct_drawpixelinfo* dpi, int format, void* args, int colour, int x, int y, int width) { - RCT2_CALLPROC_X(0x006C1B83, colour, format, x, y, args, dpi, width); + RCT2_CALLPROC_X(0x006C1B83, colour, format, x, y, (int)args, (int)dpi, width); //char* buffer; @@ -507,7 +506,7 @@ void gfx_draw_string_left_clipped(rct_drawpixelinfo* dpi, int format, void* args */ void gfx_draw_string_centred_clipped(rct_drawpixelinfo *dpi, int format, void *args, int colour, int x, int y, int width) { - RCT2_CALLPROC_X(0x006C1BBA, colour, format, x, y, args, dpi, width); + RCT2_CALLPROC_X(0x006C1BBA, colour, format, x, y, (int)args, (int)dpi, width); //char* buffer; //short text_width; @@ -568,8 +567,8 @@ int gfx_draw_string_centred_wrapped(rct_drawpixelinfo *dpi, void *args, int x, i ebx = format; ecx = x; edx = y; - esi = args; - edi = dpi; + esi = (int)args; + edi = (int)dpi; ebp = width; RCT2_CALLFUNC_X(0x006C1E53, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); @@ -595,8 +594,8 @@ int gfx_draw_string_left_wrapped(rct_drawpixelinfo *dpi, void *format, int x, in ebx = colour; ecx = x; edx = y; - esi = format; - edi = dpi; + esi = (int)format; + edi = (int)dpi; ebp = width; RCT2_CALLFUNC_X(0x006C2105, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); @@ -639,8 +638,8 @@ void gfx_draw_string(rct_drawpixelinfo *dpi, char *format, int colour, int x, in ebx = 0; ecx = x; edx = y; - esi = format; - edi = dpi; + esi = (int)format; + edi = (int)dpi; ebp = 0; RCT2_CALLFUNC_X(0x00682702, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); diff --git a/src/map.c b/src/map.c index 581eabdf30..935f059ee0 100644 --- a/src/map.c +++ b/src/map.c @@ -146,7 +146,6 @@ void map_update_tile_pointers() */ int map_element_height(int x, int y) { - int i; rct_map_element *mapElement; // Off the map @@ -298,13 +297,13 @@ void sub_68B089() i++; if (i >= MAX_TILE_MAP_ELEMENT_POINTERS) i = 0; - } while (TILE_MAP_ELEMENT_POINTER(i) == 0xFFFFFFFF); + } while (TILE_MAP_ELEMENT_POINTER(i) == TILE_UNDEFINED_MAP_ELEMENT); RCT2_GLOBAL(0x0010E63B8, uint32) = i; mapElementFirst = mapElement = TILE_MAP_ELEMENT_POINTER(i); do { mapElement--; - if (mapElement < RCT2_ADDRESS_MAP_ELEMENTS) + if (mapElement < (rct_map_element*)RCT2_ADDRESS_MAP_ELEMENTS) break; } while (mapElement->base_height == 255); mapElement++; diff --git a/src/map.h b/src/map.h index 88e76d7e11..108e339a82 100644 --- a/src/map.h +++ b/src/map.h @@ -180,7 +180,7 @@ enum { #define MAX_MAP_ELEMENTS 196608 #define MAX_TILE_MAP_ELEMENT_POINTERS (256 * 256) -#define TILE_UNDEFINED_MAP_ELEMENT -1 +#define TILE_UNDEFINED_MAP_ELEMENT (rct_map_element*)-1 void map_init(); void map_update_tile_pointers(); diff --git a/src/news_item.c b/src/news_item.c index 70c0f1f01e..4b5fa14e7c 100644 --- a/src/news_item.c +++ b/src/news_item.c @@ -191,7 +191,7 @@ void news_item_get_subject_location(int type, int subject, int *x, int *y, int * *z = map_element_height(*x, *y); break; case NEWS_ITEM_PEEP_ON_RIDE: - peep = &(RCT2_ADDRESS(RCT2_ADDRESS_SPRITE_LIST, rct_sprite)[subject]); + peep = &(RCT2_ADDRESS(RCT2_ADDRESS_SPRITE_LIST, rct_sprite)[subject]).peep; *x = peep->x; *y = peep->y; *z = peep->z; @@ -212,16 +212,16 @@ void news_item_get_subject_location(int type, int subject, int *x, int *y, int * } // Find the first car of the train peep is on - car = &(RCT2_ADDRESS(RCT2_ADDRESS_SPRITE_LIST, rct_sprite)[ride->train_car_map[peep->current_train]]); + car = &(RCT2_ADDRESS(RCT2_ADDRESS_SPRITE_LIST, rct_sprite)[ride->train_car_map[peep->current_train]]).car; // Find the actual car peep is on for (i = 0; i < peep->current_car; i++) - car = &(RCT2_ADDRESS(RCT2_ADDRESS_SPRITE_LIST, rct_sprite)[car->next_car]); + car = &(RCT2_ADDRESS(RCT2_ADDRESS_SPRITE_LIST, rct_sprite)[car->next_car]).car; *x = car->x; *y = car->y; *z = car->z; break; case NEWS_ITEM_PEEP: - peep = &(RCT2_ADDRESS(RCT2_ADDRESS_SPRITE_LIST, rct_sprite)[subject]); + peep = &(RCT2_ADDRESS(RCT2_ADDRESS_SPRITE_LIST, rct_sprite)[subject]).peep; *x = peep->x; *y = peep->y; *z = peep->z; @@ -252,7 +252,7 @@ void news_item_add_to_queue(uint8 type, rct_string_id string_id, uint32 assoc) // find first open slot while (newsItem->type != NEWS_ITEM_NULL) { - if (newsItem + sizeof(newsItem) >= 0x13CB1CC) + if (newsItem + sizeof(newsItem) >= (rct_news_item*)0x13CB1CC) news_item_close_current(); else newsItem++; @@ -263,12 +263,12 @@ void news_item_add_to_queue(uint8 type, rct_string_id string_id, uint32 assoc) newsItem->flags = 0; newsItem->assoc = assoc; newsItem->ticks = 0; - newsItem->month = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, uint16); - newsItem->day = (days_in_month[(newsItem->month & 7)] * RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_TICKS, uint16)) >> 16; + newsItem->month_year = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, uint16); + newsItem->day = (days_in_month[(newsItem->month_year & 7)] * RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_TICKS, uint16)) >> 16; - format_string(0x0141EF68, string_id, 0x013CE952); // overflows possible? + format_string((char*)0x0141EF68, string_id, (void*)0x013CE952); // overflows possible? newsItem->colour = ((char*)0x0141EF68)[0]; - strncpy(newsItem->text, 0x0141EF68, 255); + strncpy(newsItem->text, (char*)0x0141EF68, 255); newsItem->text[254] = 0; // blatant disregard for what happens on the last element. @@ -295,8 +295,8 @@ void news_item_open_subject(int type, int subject) { break; case NEWS_ITEM_PEEP_ON_RIDE: case NEWS_ITEM_PEEP: - peep = &(RCT2_ADDRESS(RCT2_ADDRESS_SPRITE_LIST, rct_sprite)[subject]); - RCT2_CALLPROC_X(0x006989E9, 0, 0, 0, peep, 0, 0, 0); + peep = &(RCT2_ADDRESS(RCT2_ADDRESS_SPRITE_LIST, rct_sprite)[subject]).peep; + RCT2_CALLPROC_X(0x006989E9, 0, 0, 0, (int)peep, 0, 0, 0); break; case NEWS_ITEM_MONEY: // Open finances window diff --git a/src/news_item.h b/src/news_item.h index f7e5333af1..a82aa29b0f 100644 --- a/src/news_item.h +++ b/src/news_item.h @@ -48,8 +48,7 @@ typedef struct { uint8 flags; // 0x01 uint32 assoc; // 0x02 uint16 ticks; // 0x06 - uint8 month; // 0x08 - uint8 pad_09; // 0x09 + uint16 month_year; // 0x08 uint8 day; // 0x0A uint8 pad_0B; // 0x0B uint8 colour; // 0x0C diff --git a/src/object.c b/src/object.c index ba642157c2..1a98a2a482 100644 --- a/src/object.c +++ b/src/object.c @@ -34,7 +34,7 @@ void object_load_list() * * rct2: 0x006AA0C6 */ -void object_read_and_load_entries(HFILE hFile) +void object_read_and_load_entries(HANDLE hFile) { RCT2_CALLPROC_EBPSAFE(0x006AA0C6); diff --git a/src/object.h b/src/object.h index 54c5f76220..3549548bab 100644 --- a/src/object.h +++ b/src/object.h @@ -35,7 +35,7 @@ typedef struct { } rct_object_entry; void object_load_list(); -void object_read_and_load_entries(HFILE hFile); +void object_read_and_load_entries(HANDLE hFile); int object_load_packed(); #endif diff --git a/src/osinterface.c b/src/osinterface.c index 760f73bf63..1c7afe06d6 100644 --- a/src/osinterface.c +++ b/src/osinterface.c @@ -33,8 +33,8 @@ typedef void(*update_palette_func)(char*, int, int); openrct2_cursor gCursorState; -unsigned char* gKeysState; -unsigned char* gKeysPressed; +const unsigned char *gKeysState; +unsigned char *gKeysPressed; unsigned int gLastKeyPressed; static void osinterface_create_window(); @@ -325,12 +325,12 @@ int osinterface_open_common_file_dialog(int type, char *title, char *filename, c openFileName.lpstrTitle = title; // Copy filter name - strcpy(0x01423800, filterName); + strcpy((char*)0x01423800, filterName); // Copy filter pattern - strcpy(0x01423800 + strlen(filterName) + 1, filterPattern); + strcpy((char*)0x01423800 + strlen(filterName) + 1, filterPattern); *((char*)(0x01423800 + strlen(filterName) + 1 + strlen(filterPattern) + 1)) = 0; - openFileName.lpstrFilter = 0x01423800; + openFileName.lpstrFilter = (char*)0x01423800; // tmp = RCT2_GLOBAL(0x009E2C74, uint32); diff --git a/src/osinterface.h b/src/osinterface.h index a42da3c6d3..8360d3f1c4 100644 --- a/src/osinterface.h +++ b/src/osinterface.h @@ -37,8 +37,8 @@ typedef struct { } openrct2_cursor; extern openrct2_cursor gCursorState; -extern unsigned char* gKeysState; -extern unsigned char* gKeysPressed; +extern const unsigned char *gKeysState; +extern unsigned char *gKeysPressed; extern unsigned int gLastKeyPressed; void osinterface_init(); diff --git a/src/park.c b/src/park.c index 911d10997e..bc39ff3d46 100644 --- a/src/park.c +++ b/src/park.c @@ -89,7 +89,7 @@ void park_init() RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) = PARK_FLAGS_11 | PARK_FLAGS_SHOW_REAL_GUEST_NAMES; park_reset_awards_and_history(); - rct_s6_info *info = 0x0141F570; + rct_s6_info *info = (rct_s6_info*)0x0141F570; info->name[0] = '\0'; format_string(info->details, STR_NO_DETAILS_YET, NULL); } diff --git a/src/peep.c b/src/peep.c index 194c255704..8a04b3e95d 100644 --- a/src/peep.c +++ b/src/peep.c @@ -63,11 +63,11 @@ void peep_update_all() sprite_index = peep->next; if ((i & 0x7F) != (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TICKS, uint32) & 0x7F)) { - RCT2_CALLPROC_X(0x0068FC1E, 0, 0, 0, 0, peep, 0, 0); + RCT2_CALLPROC_X(0x0068FC1E, 0, 0, 0, 0, (int)peep, 0, 0); } else { - RCT2_CALLPROC_X(0x0068F41A, 0, 0, 0, i, peep, 0, 0); + RCT2_CALLPROC_X(0x0068F41A, 0, 0, 0, i, (int)peep, 0, 0); if (peep->var_08 == 4) - RCT2_CALLPROC_X(0x0068FC1E, 0, 0, 0, 0, peep, 0, 0); + RCT2_CALLPROC_X(0x0068FC1E, 0, 0, 0, 0, (int)peep, 0, 0); } i++; diff --git a/src/rct2.c b/src/rct2.c index d4cc2fe042..a53a31bf22 100644 --- a/src/rct2.c +++ b/src/rct2.c @@ -17,8 +17,8 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . *****************************************************************************/ - -#define _CRT_SECURE_NO_WARNINGS + +#pragma warning(disable : 4996) // GetVersionExA deprecated #include #include @@ -43,7 +43,6 @@ #include "title.h" #include "track.h" #include "viewport.h" -#include "settings.h" void rct2_init_directories(); @@ -231,16 +230,16 @@ void check_cmdline_arg() } processed_arg[j ++] = 0; - if(!stricmp(processed_arg + last_period, "sv6")) + if (!_stricmp(processed_arg + last_period, "sv6")) { - strcpy(0x00141EF68, processed_arg); + strcpy((char*)0x00141EF68, processed_arg); game_load_save(); } - else if(!stricmp(processed_arg + last_period, "sc6")) + else if (!_stricmp(processed_arg + last_period, "sc6")) { //TODO: scenario install } - else if(!stricmp(processed_arg + last_period, "td6") || !stricmp(processed_arg + last_period, "td4")) + else if (!_stricmp(processed_arg + last_period, "td6") || !_stricmp(processed_arg + last_period, "td4")) { //TODO: track design install } @@ -321,7 +320,7 @@ void get_system_info() GetSystemInfo(&sysInfo); // RCT2 only has 2 bytes reserved for OEM_ID even though it should be a DWORD - RCT2_GLOBAL(RCT2_ADDRESS_SYS_OEM_ID, uint16) = sysInfo.dwOemId; + RCT2_GLOBAL(RCT2_ADDRESS_SYS_OEM_ID, uint16) = (uint16)sysInfo.dwOemId; RCT2_GLOBAL(RCT2_ADDRESS_SYS_CPU_LEVEL, uint16) = sysInfo.wProcessorLevel; RCT2_GLOBAL(RCT2_ADDRESS_SYS_CPU_REVISION, uint16) = sysInfo.wProcessorRevision; RCT2_GLOBAL(RCT2_ADDRESS_SYS_CPU_NUMBER, uint32) = sysInfo.dwNumberOfProcessors; @@ -332,9 +331,9 @@ void get_system_info() RCT2_GLOBAL(RCT2_ADDRESS_MEM_TOTAL_VIRTUAL, uint32) = memInfo.dwTotalVirtual; uint32 size = 80; - GetUserName(RCT2_ADDRESS_OS_USER_NAME, &size); + GetUserName((char*)RCT2_ADDRESS_OS_USER_NAME, &size); size = 80; - GetComputerName(RCT2_ADDRESS_OS_COMPUTER_NAME, &size); + GetComputerName((char*)RCT2_ADDRESS_OS_COMPUTER_NAME, &size); // Screen Display Width/Height but RCT_ADDRESS_SCREEN_HEIGHT/WIDTH already taken? RCT2_GLOBAL(0x01423C08, sint32) = GetSystemMetrics(SM_CXSCREEN); diff --git a/src/sawyercoding.c b/src/sawyercoding.c index c5393e02d4..7e7a59928b 100644 --- a/src/sawyercoding.c +++ b/src/sawyercoding.c @@ -31,16 +31,15 @@ static void decode_chunk_rotate(char *buffer, int length); * * rct2: 0x00676FD2 */ -int sawyercoding_validate_checksum(HFILE hFile) +int sawyercoding_validate_checksum(HANDLE hFile) { - int i; - uint32 checksum, fileChecksum; + uint32 i, checksum, fileChecksum; DWORD dataSize, bufferSize, numBytesRead; uint8 buffer[1024]; // Get data size if ((dataSize = SetFilePointer(hFile, 0, NULL, FILE_END)) < 8) - return; + return 0; dataSize -= 4; // Calculate checksum @@ -74,7 +73,7 @@ int sawyercoding_validate_checksum(HFILE hFile) * rct2: 0x0067685F * buffer (esi) */ -int sawyercoding_read_chunk(HFILE hFile, uint8 *buffer) +int sawyercoding_read_chunk(HANDLE hFile, uint8 *buffer) { DWORD numBytesRead; sawyercoding_chunk_header chunkHeader; @@ -145,7 +144,7 @@ static int decode_chunk_rle(char *buffer, int length) static int decode_chunk_repeat(char *buffer, int length) { int i, j, count; - uint8 *src, *dst, *copyOffset, rleCodeByte; + uint8 *src, *dst, *copyOffset; // Backup buffer src = malloc(length); diff --git a/src/sawyercoding.h b/src/sawyercoding.h index 7b30566703..02b63b6209 100644 --- a/src/sawyercoding.h +++ b/src/sawyercoding.h @@ -36,7 +36,7 @@ enum { CHUNK_ENCODING_ROTATE }; -int sawyercoding_validate_checksum(HFILE hFile); -int sawyercoding_read_chunk(HFILE hFile, uint8 *buffer); +int sawyercoding_validate_checksum(HANDLE hFile); +int sawyercoding_read_chunk(HANDLE hFile, uint8 *buffer); #endif diff --git a/src/scenario.c b/src/scenario.c index 81f97bbd08..a766c87c36 100644 --- a/src/scenario.c +++ b/src/scenario.c @@ -18,8 +18,6 @@ * along with this program. If not, see . *****************************************************************************/ -#define _CRT_SECURE_NO_WARNINGS - #include #include "addresses.h" #include "date.h" @@ -103,9 +101,8 @@ void scenario_load_list() static void scenario_list_add(char *path) { - int i; rct_scenario_basic *scenario; - rct_s6_info *s6Info = 0x0141F570; + rct_s6_info *s6Info = (rct_s6_info*)0x0141F570; // Check if scenario already exists in list, likely if in scores scenario = get_scenario_by_filename(path); @@ -138,7 +135,7 @@ static void scenario_list_add(char *path) } // Check if the scenario list buffer has room for another scenario - if ((RCT2_NUM_SCENARIOS + 1) * sizeof(rct_scenario_basic) > _scenarioListSize) { + if ((RCT2_NUM_SCENARIOS + 1) * (int)sizeof(rct_scenario_basic) > _scenarioListSize) { // Allocate more room _scenarioListSize += 16 * sizeof(rct_scenario_basic); RCT2_SCENARIO_LIST = (rct_scenario_basic*)rct2_realloc(RCT2_SCENARIO_LIST, _scenarioListSize); @@ -267,8 +264,8 @@ static int scenario_load_basic(char *path) { HANDLE hFile; int _eax; - rct_s6_header *s6Header = 0x009E34E4; - rct_s6_info *s6Info = 0x0141F570; + rct_s6_header *s6Header = (rct_s6_header*)0x009E34E4; + rct_s6_info *s6Info = (rct_s6_info*)0x0141F570; hFile = CreateFile( path, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_RANDOM_ACCESS | FILE_ATTRIBUTE_NORMAL, NULL @@ -277,10 +274,10 @@ static int scenario_load_basic(char *path) RCT2_GLOBAL(0x009E382C, HANDLE*) = hFile; // Read first chunk - sawyercoding_read_chunk(hFile, s6Header); + sawyercoding_read_chunk(hFile, (uint8*)s6Header); if (s6Header->type == S6_TYPE_SCENARIO) { // Read second chunk - sawyercoding_read_chunk(hFile, s6Info); + sawyercoding_read_chunk(hFile, (uint8*)s6Info); CloseHandle(hFile); RCT2_GLOBAL(0x009AA00C, uint8) = 0; if (s6Info->flags != 255) { @@ -322,8 +319,8 @@ void scenario_load(char *path) { HANDLE hFile; int i, j; - rct_s6_header *s6Header = 0x009E34E4; - rct_s6_info *s6Info = 0x0141F570; + rct_s6_header *s6Header = (rct_s6_header*)0x009E34E4; + rct_s6_info *s6Info = (rct_s6_info*)0x0141F570; hFile = CreateFile( path, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_RANDOM_ACCESS | FILE_ATTRIBUTE_NORMAL, NULL @@ -338,10 +335,10 @@ void scenario_load(char *path) } // Read first chunk - sawyercoding_read_chunk(hFile, s6Header); + sawyercoding_read_chunk(hFile, (uint8*)s6Header); if (s6Header->type == S6_TYPE_SCENARIO) { // Read second chunk - sawyercoding_read_chunk(hFile, s6Info); + sawyercoding_read_chunk(hFile, (uint8*)s6Info); // Read packed objects if (s6Header->num_packed_objects > 0) { @@ -355,35 +352,35 @@ void scenario_load(char *path) object_read_and_load_entries(hFile); // Read flags (16 bytes) - sawyercoding_read_chunk(hFile, RCT2_ADDRESS_CURRENT_MONTH_YEAR); + sawyercoding_read_chunk(hFile, (uint8*)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); + memset((void*)RCT2_ADDRESS_MAP_ELEMENTS, 0, MAX_MAP_ELEMENTS * sizeof(rct_map_element)); + sawyercoding_read_chunk(hFile, (uint8*)RCT2_ADDRESS_MAP_ELEMENTS); // Read game data, including sprites - sawyercoding_read_chunk(hFile, 0x010E63B8); + sawyercoding_read_chunk(hFile, (uint8*)0x010E63B8); // Read number of guests in park and something else - sawyercoding_read_chunk(hFile, RCT2_ADDRESS_GUESTS_IN_PARK); + sawyercoding_read_chunk(hFile, (uint8*)RCT2_ADDRESS_GUESTS_IN_PARK); // Read ? - sawyercoding_read_chunk(hFile, 0x01357BC8); + sawyercoding_read_chunk(hFile, (uint8*)0x01357BC8); // Read park rating - sawyercoding_read_chunk(hFile, RCT2_ADDRESS_CURRENT_PARK_RATING); + sawyercoding_read_chunk(hFile, (uint8*)RCT2_ADDRESS_CURRENT_PARK_RATING); // Read ? - sawyercoding_read_chunk(hFile, 0x01357CF2); + sawyercoding_read_chunk(hFile, (uint8*)0x01357CF2); // Read ? - sawyercoding_read_chunk(hFile, 0x0135832C); + sawyercoding_read_chunk(hFile, (uint8*)0x0135832C); // Read ? - sawyercoding_read_chunk(hFile, RCT2_ADDRESS_CURRENT_PARK_VALUE); + sawyercoding_read_chunk(hFile, (uint8*)RCT2_ADDRESS_CURRENT_PARK_VALUE); // Read more game data, including research items and rides - sawyercoding_read_chunk(hFile, 0x01358740); + sawyercoding_read_chunk(hFile, (uint8*)0x01358740); CloseHandle(hFile); @@ -411,7 +408,7 @@ void scenario_load(char *path) void scenario_load_and_play(rct_scenario_basic *scenario) { rct_window *mainWindow; - rct_s6_info *s6Info = 0x0141F570; + rct_s6_info *s6Info = (rct_s6_info*)0x0141F570; RCT2_GLOBAL(0x009AA0F0, uint32) = RCT2_GLOBAL(0x00F663B0, uint32) ^ timeGetTime(); RCT2_GLOBAL(0x009AA0F4, uint32) = RCT2_GLOBAL(0x00F663B4, uint32) ^ timeGetTime(); @@ -422,7 +419,7 @@ void scenario_load_and_play(rct_scenario_basic *scenario) RCT2_ADDRESS(RCT2_ADDRESS_SCENARIOS_PATH, char), scenario->path ); - scenario_load(0x0141EF68); + scenario_load((char*)0x0141EF68); RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) = SCREEN_FLAGS_PLAYING; viewport_init_all(); game_create_windows(); @@ -461,24 +458,24 @@ void scenario_load_and_play(rct_scenario_basic *scenario) RCT2_CALLPROC_EBPSAFE(0x00684AC3); RCT2_CALLPROC_EBPSAFE(0x006DFEE4); news_item_init_queue(); - if (RCT2_ADDRESS(RCT2_ADDRESS_OBJECTIVE_TYPE, uint8) != OBJECTIVE_NONE) + if (RCT2_GLOBAL(RCT2_ADDRESS_OBJECTIVE_TYPE, uint8) != OBJECTIVE_NONE) window_park_objective_open(); RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PARK_RATING, sint16) = calculate_park_rating(); RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PARK_VALUE, sint16) = calculate_park_value(); RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_COMPANY_VALUE, sint16) = calculate_company_value(); RCT2_GLOBAL(0x013587D0, sint16) = RCT2_GLOBAL(0x013573DC, sint16) - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_LOAN, sint16); - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONEY_ENCRYPTED, sint16) = ENCRYPT_MONEY(RCT2_GLOBAL(0x013573DC, sint32)); + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONEY_ENCRYPTED, sint32) = ENCRYPT_MONEY(RCT2_GLOBAL(0x013573DC, sint32)); RCT2_CALLPROC_EBPSAFE(0x0069E869); // (loan related) - strcpy(0x0135924A, s6Info->details); - strcpy(0x0135920A, s6Info->name); + strcpy((char*)0x0135924A, s6Info->details); + strcpy((char*)0x0135920A, s6Info->name); if (RCT2_GLOBAL(0x009ADAE4, sint32) != -1) { char *ebp = RCT2_GLOBAL(0x009ADAE4, char*); // - format_string(0x0141ED68, RCT2_GLOBAL(ebp + 2, uint16), 0); + format_string((char*)0x0141ED68, RCT2_GLOBAL(ebp + 2, uint16), 0); // Set park name RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TITLE, uint16) = STR_CANT_RENAME_PARK; @@ -487,22 +484,22 @@ void scenario_load_and_play(rct_scenario_basic *scenario) game_do_command(0, 1, 0, *((int*)(0x0141ED68 + 24)), 33, *((int*)(0x0141ED68 + 32)), *((int*)(0x0141ED68 + 28))); // - format_string(0x0141ED68, RCT2_GLOBAL(ebp + 0, uint16), 0); - strncpy(RCT2_ADDRESS_SCENARIO_NAME, 0x0141ED68, 31); + format_string((char*)0x0141ED68, RCT2_GLOBAL(ebp + 0, uint16), 0); + strncpy((char*)RCT2_ADDRESS_SCENARIO_NAME, (char*)0x0141ED68, 31); ((char*)RCT2_ADDRESS_SCENARIO_NAME)[31] = '\0'; // Set scenario details - format_string(0x0141ED68, RCT2_GLOBAL(ebp + 4, uint16), 0); - strncpy(RCT2_ADDRESS_SCENARIO_DETAILS, 0x0141ED68, 255); + format_string((char*)0x0141ED68, RCT2_GLOBAL(ebp + 4, uint16), 0); + strncpy((char*)RCT2_ADDRESS_SCENARIO_DETAILS, (char*)0x0141ED68, 255); ((char*)RCT2_ADDRESS_SCENARIO_DETAILS)[255] = '\0'; } // Set the last saved game path - strcpy(0x009ABB37, 0x009AB5DA); - format_string(0x009ABB37 + strlen(0x009ABB37), RCT2_GLOBAL(0x0013573D4, uint16), 0x0013573D8); - strcat(0x009ABB37, ".SV6"); + strcpy((char*)0x009ABB37, (char*)0x009AB5DA); + format_string((char*)0x009ABB37 + strlen((char*)0x009ABB37), RCT2_GLOBAL(0x0013573D4, uint16), (void*)0x0013573D8); + strcat((char*)0x009ABB37, ".SV6"); - memset(0x001357848, 0, 56); + memset((void*)0x001357848, 0, 56); RCT2_GLOBAL(0x0135832C, uint32) = 0; RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PROFIT, sint32) = 0; RCT2_GLOBAL(0x01358334, uint32) = 0; @@ -519,7 +516,7 @@ void scenario_load_and_play(rct_scenario_basic *scenario) park_calculate_size(); RCT2_CALLPROC_EBPSAFE(0x006C1955); RCT2_GLOBAL(0x01358840, uint8) = 0; - memset(0x001358102, 0, 20); + memset((void*)0x001358102, 0, 20); RCT2_GLOBAL(0x00135882E, uint16) = 0; // Open park with free entry when there is no money @@ -572,7 +569,7 @@ void scenario_success() RCT2_CALLPROC_EBPSAFE(0x0069BE9B); // celebration for (i = 0; i < RCT2_GLOBAL(RCT2_ADDRESS_NUM_SCENARIOS, sint32); i++) { - char* cur_scenario_name = RCT2_ADDRESS(0x135936C, char*); + char *cur_scenario_name = RCT2_ADDRESS(0x135936C, char); scenario = &(RCT2_GLOBAL(RCT2_ADDRESS_SCENARIO_LIST, rct_scenario_basic*)[i]); if (0 == strncmp(cur_scenario_name, scenario->path, 256)){ diff --git a/src/screenshot.c b/src/screenshot.c index af65bf976b..25595520b8 100644 --- a/src/screenshot.c +++ b/src/screenshot.c @@ -117,9 +117,9 @@ int screenshot_dump_bmp() BitmapFileHeader header; BitmapInfoHeader info; - int i, x, y, index, width, height, stride; - char *buffer, path[MAX_PATH], *row, *dst; - HFILE hFile; + int i, y, index, width, height, stride; + char *buffer, path[MAX_PATH], *row; + HANDLE hFile; DWORD bytesWritten; // Get a free screenshot path @@ -127,7 +127,7 @@ int screenshot_dump_bmp() return -1; // Open file for writing - hFile = CreateFile(path, GENERIC_WRITE, NULL, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + hFile = CreateFile(path, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (hFile == INVALID_HANDLE_VALUE) return -1; diff --git a/src/settings.c b/src/settings.c deleted file mode 100644 index 6e281aa97a..0000000000 --- a/src/settings.c +++ /dev/null @@ -1,28 +0,0 @@ -/***************************************************************************** -* 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 -#include -#include -#include -#include "settings.h" -#include "screenshot.h" - diff --git a/src/settings.h b/src/settings.h deleted file mode 100644 index d5e2452ac0..0000000000 --- a/src/settings.h +++ /dev/null @@ -1,33 +0,0 @@ -/***************************************************************************** -* Copyright (c) 2014 Ted John, Peter Hill -* 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 _SETTINGS_H_ -#define _SETTINGS_H_ - -#include -#include -#include "rct2.h" - - - - - - -#endif \ No newline at end of file diff --git a/src/strings.c b/src/strings.c index 540e644252..fc50c8f1b6 100644 --- a/src/strings.c +++ b/src/strings.c @@ -32,7 +32,7 @@ */ void format_string(char *dest, rct_string_id format, void *args) { - RCT2_CALLPROC_X(0x006C2555, format, 0, args, 0, 0, dest, 0); + RCT2_CALLPROC_X(0x006C2555, format, 0, (int)args, 0, 0, (int)dest, 0); } void generate_string_file() diff --git a/src/title.c b/src/title.c index ec26fb9133..1664250b60 100644 --- a/src/title.c +++ b/src/title.c @@ -154,7 +154,7 @@ static void title_update_showcase() rct_window* w; uint8 script_opcode, script_operand; short x, y, z; - int i, _edx; + int i; if (_scriptWaitCounter <= 0) { do { @@ -223,7 +223,7 @@ static void title_update_showcase() _currentScript = _magicMountainScript; if (gRandomShowcase) { if (_currentScript != NULL) - free(_currentScript); + free((uint8*)_currentScript); _currentScript = generate_random_script(); } break; @@ -322,7 +322,7 @@ static void title_play_music() strcat(musicPath, "\\data\\css50.dat"); } - if (RCT2_CALLFUNC_3(0x0040194E, int, int, int, int, 3, musicPath, 0)) // play music + if (RCT2_CALLFUNC_3(0x0040194E, int, int, char*, int, 3, musicPath, 0)) // play music RCT2_CALLPROC_5(0x00401999, int, int, int, int, int, 3, 1, 0, 0, 0); RCT2_GLOBAL(0x009AF600, uint8) = 1; @@ -333,7 +333,7 @@ static uint8 *generate_random_script() int i, j; const int views = 16; - srand(time(NULL)); + srand((unsigned int)time(NULL)); uint8 *script = malloc(views * 8 + 2); i = 0; diff --git a/src/viewport.c b/src/viewport.c index a22af3cf24..b005bafad2 100644 --- a/src/viewport.c +++ b/src/viewport.c @@ -78,7 +78,7 @@ void viewport_create(rct_window *w, int x, int y, int width, int height, int ecx { x &= 0xFFFF; y &= 0xFFFF; - RCT2_CALLPROC_X(0x006EB009, (y << 16) | x, (height << 16) | width, ecx, edx, w, 0, 0); + RCT2_CALLPROC_X(0x006EB009, (y << 16) | x, (height << 16) | width, ecx, edx, (int)w, 0, 0); } /** @@ -103,7 +103,7 @@ void viewport_update_pointers() */ void viewport_update_position(rct_window *window) { - RCT2_CALLPROC_X(0x006E7A3A, 0, 0, 0, 0, window, 0, 0); + RCT2_CALLPROC_X(0x006E7A3A, 0, 0, 0, 0, (int)window, 0, 0); } /** @@ -112,7 +112,7 @@ void viewport_update_position(rct_window *window) */ void viewport_render(rct_drawpixelinfo *dpi, rct_viewport *viewport, int left, int top, int right, int bottom) { - RCT2_CALLPROC_X(0x00685C02, left , top, 0, right, viewport, dpi, bottom); + RCT2_CALLPROC_X(0x00685C02, left , top, 0, right, (int)viewport, (int)dpi, bottom); } /** diff --git a/src/widget.c b/src/widget.c index 3aa909e355..f286139c41 100644 --- a/src/widget.c +++ b/src/widget.c @@ -248,7 +248,6 @@ static void widget_button_draw(rct_drawpixelinfo *dpi, rct_window *w, int widget { rct_widget* widget; int l, t, r, b, press; - uint32 image; uint8 colour; // Get the widget @@ -331,8 +330,7 @@ static void widget_tab_draw(rct_drawpixelinfo *dpi, rct_window *w, int widgetInd static void widget_flat_button_draw(rct_drawpixelinfo *dpi, rct_window *w, int widgetIndex) { rct_widget* widget; - int l, t, r, b, press; - uint32 image; + int l, t, r, b; uint8 colour; if (!widget_is_disabled(w, widgetIndex) && widget_is_highlighted(w, widgetIndex)) { @@ -375,7 +373,7 @@ static void widget_flat_button_draw(rct_drawpixelinfo *dpi, rct_window *w, int w static void widget_text_button(rct_drawpixelinfo *dpi, rct_window *w, int widgetIndex) { rct_widget* widget; - int l, t, r, b, width, press, stringId; + int l, t, r, b, press; uint8 colour; // Get the widget @@ -405,7 +403,7 @@ static void widget_text_button(rct_drawpixelinfo *dpi, rct_window *w, int widget static void widget_text_unknown(rct_drawpixelinfo *dpi, rct_window *w, int widgetIndex) { rct_widget* widget; - int l, t, r, b, width, press, stringId; + int l, t, r, b, stringId; uint8 colour; // Get the widget @@ -433,7 +431,7 @@ static void widget_text_unknown(rct_drawpixelinfo *dpi, rct_window *w, int widge gfx_draw_string_left_clipped( dpi, stringId, - 0x013CE952, + (void*)0x013CE952, colour, l + 1, t, @@ -445,7 +443,7 @@ static void widget_text_unknown(rct_drawpixelinfo *dpi, rct_window *w, int widge gfx_draw_string_centred_clipped( dpi, stringId, - 0x013CE952, + (void*)0x013CE952, colour, (w->x + w->x + widget->left + widget->right + 1) / 2 - 1, t, @@ -461,7 +459,7 @@ static void widget_text_unknown(rct_drawpixelinfo *dpi, rct_window *w, int widge static void widget_text(rct_drawpixelinfo *dpi, rct_window *w, int widgetIndex) { rct_widget* widget; - int l, t, r, b, width, press; + int l, t, r, b; uint8 colour; // Get the widget @@ -481,7 +479,7 @@ static void widget_text(rct_drawpixelinfo *dpi, rct_window *w, int widgetIndex) if (widget_is_disabled(w, widgetIndex)) colour |= 0x40; - gfx_draw_string_left(dpi, widget->image, 0x013CE952, colour, l + 1, t); + gfx_draw_string_left(dpi, widget->image, (void*)0x013CE952, colour, l + 1, t); } /** @@ -491,7 +489,7 @@ static void widget_text(rct_drawpixelinfo *dpi, rct_window *w, int widgetIndex) static void widget_text_inset(rct_drawpixelinfo *dpi, rct_window *w, int widgetIndex) { rct_widget* widget; - int l, t, r, b, width, press; + int l, t, r, b; uint8 colour; // Get the widget @@ -568,7 +566,7 @@ static void widget_groupbox_draw(rct_drawpixelinfo *dpi, rct_window *w, int widg colour = w->colours[widget->colour] & 0x7F; if (widget_is_disabled(w, widgetIndex)) colour |= 0x40; - gfx_draw_string_left(dpi, widget->image, 0x013CE952, colour, l, t); + gfx_draw_string_left(dpi, widget->image, (void*)0x013CE952, colour, l, t); textRight = gLastDrawStringX + 1; } @@ -764,7 +762,7 @@ static void widget_scroll_draw(rct_drawpixelinfo *dpi, rct_window *w, int widget rct_widget* widget; rct_scroll* scroll; int scrollIndex; - int l, t, r, b, press, ebp; + int l, t, r, b; int cl, ct, cr, cb; uint8 colour; rct_drawpixelinfo scroll_dpi; @@ -826,7 +824,7 @@ static void widget_scroll_draw(rct_drawpixelinfo *dpi, rct_window *w, int widget // Draw the scroll contents if (scroll_dpi.width > 0 && scroll_dpi.height > 0) - RCT2_CALLPROC_X(w->event_handlers[WE_SCROLL_PAINT], 0, 0, 0, 0, w, &scroll_dpi, 0); + RCT2_CALLPROC_X(w->event_handlers[WE_SCROLL_PAINT], 0, 0, 0, 0, (int)w, (int)&scroll_dpi, 0); } static void widget_hscrollbar_draw(rct_drawpixelinfo *dpi, rct_scroll *scroll, int l, int t, int r, int b, int colour) @@ -914,20 +912,20 @@ static void widget_draw_image(rct_drawpixelinfo *dpi, rct_window *w, int widgetI colour = w->colours[widget->colour]; colour = RCT2_ADDRESS(0x00141FC4A, uint8)[(colour & 0x7F) * 8] & 0xFF; RCT2_GLOBAL(0x009ABDA4, uint32) = 0x009DED74; - memset(0x009DED74, colour, 256); + memset((void*)0x009DED74, colour, 256); RCT2_GLOBAL(0x009DED74, uint8) = 0; RCT2_GLOBAL(0x00EDF81C, uint32) = 0x20000000; image &= 0x7FFFF; - RCT2_CALLPROC_X(0x0067A46E, 0, image, l + 1, t + 1, 0, dpi, 0); + RCT2_CALLPROC_X(0x0067A46E, 0, image, l + 1, t + 1, 0, (int)dpi, 0); // Draw greyed out (dark) colour = w->colours[widget->colour]; colour = RCT2_ADDRESS(0x00141FC48, uint8)[(colour & 0x7F) * 8] & 0xFF; RCT2_GLOBAL(0x009ABDA4, uint32) = 0x009DED74; - memset(0x009DED74, colour, 256); + memset((void*)0x009DED74, colour, 256); RCT2_GLOBAL(0x009DED74, uint8) = 0; RCT2_GLOBAL(0x00EDF81C, uint32) = 0x20000000; - RCT2_CALLPROC_X(0x0067A46E, 0, image, l, t, 0, dpi, 0); + RCT2_CALLPROC_X(0x0067A46E, 0, image, l, t, 0, (int)dpi, 0); } else { if (image & 0x80000000) { // ? diff --git a/src/window.c b/src/window.c index f41a874ff6..11a43c5567 100644 --- a/src/window.c +++ b/src/window.c @@ -111,7 +111,7 @@ void window_dispatch_update_all() RCT2_GLOBAL(0x01423604, sint32)++; RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_NOT_SHOWN_TICKS, sint16)++; for (w = RCT2_LAST_WINDOW; w >= RCT2_FIRST_WINDOW; w--) - RCT2_CALLPROC_X(w->event_handlers[WE_UPDATE], 0, 0, 0, 0, w, 0, 0); + RCT2_CALLPROC_X(w->event_handlers[WE_UPDATE], 0, 0, 0, 0, (int)w, 0, 0); RCT2_CALLPROC_EBPSAFE(0x006EE411); // handle_text_input } @@ -142,7 +142,7 @@ void window_update_all() if (RCT2_GLOBAL(0x009DEB7C, sint16) >= 1000) { RCT2_GLOBAL(0x009DEB7C, sint16) = 0; for (w = RCT2_LAST_WINDOW; w >= RCT2_FIRST_WINDOW; w--) - RCT2_CALLPROC_X(w->event_handlers[WE_UNKNOWN_07], 0, 0, 0, 0, w, 0, 0); + RCT2_CALLPROC_X(w->event_handlers[WE_UNKNOWN_07], 0, 0, 0, 0, (int)w, 0, 0); } // Border flash invalidation @@ -164,7 +164,7 @@ void window_update_all() */ static void window_scroll_wheel_input(rct_window *w, int scrollIndex, int wheel) { - int widgetIndex, newValue, size; + int widgetIndex, size; rct_scroll *scroll; rct_widget *widget; @@ -238,7 +238,7 @@ static void window_viewport_wheel_input(rct_window *w, int wheel) */ static void window_all_wheel_input() { - int i, raw, wheel, widgetIndex; + int raw, wheel, widgetIndex; rct_window *w; rct_widget *widget; rct_scroll *scroll; @@ -402,9 +402,9 @@ rct_window *window_create_auto_pos(int width, int height, uint32 *event_handlers ebx = (height << 16) | width; ecx = (flags << 8) | cls; - edx = event_handlers; + edx = (int)event_handlers; RCT2_CALLFUNC_X(0x006EA9B1, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); - return esi; + return (rct_window*)esi; } /** @@ -421,7 +421,7 @@ void window_close(rct_window* window) return; // Call close event of window - RCT2_CALLPROC_X(window->event_handlers[WE_CLOSE], 0, 0, 0, 0, window, 0, 0); + RCT2_CALLPROC_X(window->event_handlers[WE_CLOSE], 0, 0, 0, 0, (int)window, 0, 0); window = window_find_by_id(window->classification, window->number); @@ -498,22 +498,22 @@ rct_window *window_find_by_id(rct_windowclass cls, rct_windownumber number) * * rct2: 0x006E403C */ -void window_close_top() { - rct_window* w; +void window_close_top() +{ + rct_window* w; - window_close_by_id(WC_DROPDOWN, 0); + window_close_by_id(WC_DROPDOWN, 0); - if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) { - if (RCT2_ADDRESS(0x0141F570, uint8) != 1) { - return; - } - } - for (w = RCT2_FIRST_WINDOW; w < RCT2_LAST_WINDOW; w++){ - if (!(w->flags & (WF_STICK_TO_BACK | WF_STICK_TO_FRONT))) { - window_close(w); - return; - } - } + if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) + if (RCT2_GLOBAL(0x0141F570, uint8) != 1) + return; + + for (w = RCT2_FIRST_WINDOW; w < RCT2_LAST_WINDOW; w++) { + if (!(w->flags & (WF_STICK_TO_BACK | WF_STICK_TO_FRONT))) { + window_close(w); + return; + } + } } /** @@ -540,7 +540,7 @@ void window_close_all() { */ rct_window *window_find_from_point(int x, int y) { - rct_window *w, *w2; + rct_window *w; rct_widget *widget; int widget_index; @@ -576,7 +576,7 @@ int window_find_widget_from_point(rct_window *w, int x, int y) int i, widget_index; // Invalidate the window - RCT2_CALLPROC_X(w->event_handlers[WE_INVALIDATE], 0, 0, 0, 0, w, 0, 0); + RCT2_CALLPROC_X(w->event_handlers[WE_INVALIDATE], 0, 0, 0, 0, (int)w, 0, 0); // Find the widget at point x, y widget_index = -1; @@ -709,7 +709,7 @@ void window_init_scroll_widgets(rct_window *w) */ void window_update_scroll_widgets(rct_window *w) { - RCT2_CALLPROC_X(0x006EAE4E, 0, 0, 0, 0, w, 0, 0); + RCT2_CALLPROC_X(0x006EAE4E, 0, 0, 0, 0, (int)w, 0, 0); } int window_get_scroll_size(rct_window *w, int scrollIndex, int *width, int *height) @@ -717,7 +717,7 @@ int window_get_scroll_size(rct_window *w, int scrollIndex, int *width, int *heig 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; + int eax = 0, ebx = scrollIndex * sizeof(rct_scroll), ecx = 0, edx = 0, esi = (int)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; @@ -858,7 +858,7 @@ rct_window *window_get_main() */ void window_scroll_to_location(rct_window *w, int x, int y, int z) { - RCT2_CALLPROC_X(0x006E7C9C, x, 0, y, z, w, 0, 0); + RCT2_CALLPROC_X(0x006E7C9C, x, 0, y, z, (int)w, 0, 0); } /** @@ -867,7 +867,7 @@ void window_scroll_to_location(rct_window *w, int x, int y, int z) */ void window_rotate_camera(rct_window *w) { - RCT2_CALLPROC_X(0x0068881A, 0, 0, 0, 0, w, 0, 0); + RCT2_CALLPROC_X(0x0068881A, 0, 0, 0, 0, (int)w, 0, 0); } /** @@ -876,7 +876,7 @@ void window_rotate_camera(rct_window *w) */ void window_zoom_in(rct_window *w) { - RCT2_CALLPROC_X(0x006887A6, 0, 0, 0, 0, w, 0, 0); + RCT2_CALLPROC_X(0x006887A6, 0, 0, 0, 0, (int)w, 0, 0); } /** @@ -885,7 +885,7 @@ void window_zoom_in(rct_window *w) */ void window_zoom_out(rct_window *w) { - RCT2_CALLPROC_X(0x006887E0, 0, 0, 0, 0, w, 0, 0); + RCT2_CALLPROC_X(0x006887E0, 0, 0, 0, 0, (int)w, 0, 0); } /** @@ -894,7 +894,7 @@ void window_zoom_out(rct_window *w) */ void window_show_textinput(rct_window *w, int widgetIndex, uint16 title, uint16 text, int value) { - RCT2_CALLPROC_X(0x006EE308, title, text, value, widgetIndex, w, 0, 0); + RCT2_CALLPROC_X(0x006EE308, title, text, value, widgetIndex, (int)w, 0, 0); } /** @@ -911,11 +911,6 @@ void window_draw(rct_window *w, int left, int top, int right, int bottom) rct_drawpixelinfo *dpi, copy; int overflow; - char *copyBits; - int copyLeft; - int copyWidth; - int copyPitch; - // RCT2_CALLPROC_X(0x006E756C, left, top, 0, right, w, 0, bottom); // return; @@ -989,10 +984,10 @@ void window_draw(rct_window *w, int left, int top, int right, int bottom) RCT2_GLOBAL(0x0141F743, uint8) = v->colours[3] & 0x7F; // Invalidate the window - RCT2_CALLPROC_X(v->event_handlers[WE_INVALIDATE], 0, 0, 0, 0, v, 0, 0); + RCT2_CALLPROC_X(v->event_handlers[WE_INVALIDATE], 0, 0, 0, 0, (int)v, 0, 0); // Paint the window - RCT2_CALLPROC_X(v->event_handlers[WE_PAINT], 0, 0, 0, 0, v, dpi, 0); + RCT2_CALLPROC_X(v->event_handlers[WE_PAINT], 0, 0, 0, 0, (int)v, (int)dpi, 0); } } @@ -1115,8 +1110,8 @@ void window_resize(rct_window *w, int dw, int dh) w->width = clamp(w->min_width, w->width + dw, w->max_width); w->height = clamp(w->min_height, w->height + dh, w->max_height); - RCT2_CALLPROC_X(w->event_handlers[WE_RESIZE], w->width, w->height, 0, 0, w, 0, 0); - RCT2_CALLPROC_X(w->event_handlers[WE_INVALIDATE], 0, 0, 0, 0, w, 0, 0); + RCT2_CALLPROC_X(w->event_handlers[WE_RESIZE], w->width, w->height, 0, 0, (int)w, 0, 0); + RCT2_CALLPROC_X(w->event_handlers[WE_INVALIDATE], 0, 0, 0, 0, (int)w, 0, 0); // Update scroll widgets for (i = 0; i < 3; i++) { @@ -1217,7 +1212,7 @@ void tool_cancel() RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWNUMBER, rct_windownumber) ); if (w != NULL) - RCT2_CALLPROC_X(w->event_handlers[WE_TOOL_ABORT], 0, 0, 0, RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WIDGETINDEX, uint16), w, 0, 0); + RCT2_CALLPROC_X(w->event_handlers[WE_TOOL_ABORT], 0, 0, 0, RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WIDGETINDEX, uint16), (int)w, 0, 0); } } } @@ -1226,7 +1221,8 @@ void tool_cancel() * * rct2: 0x0068F083 */ -void window_guest_list_init_vars_a() { +void window_guest_list_init_vars_a() +{ RCT2_GLOBAL(0x013B0E6C, uint32) = 1; RCT2_GLOBAL(0x00F1AF1C, uint32) = 0xFFFFFFFF; RCT2_GLOBAL(0x00F1EE02, uint32) = 0xFFFFFFFF; @@ -1237,7 +1233,8 @@ void window_guest_list_init_vars_a() { * * rct2: 0x0068F050 */ -void window_guest_list_init_vars_b() { +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; @@ -1249,8 +1246,7 @@ void window_guest_list_init_vars_b() { /** * Wrapper for window events so C functions can call them */ -void window_event_helper(rct_window* w, short widgetIndex, WINDOW_EVENTS event) { - - RCT2_CALLPROC_X(w->event_handlers[event], 0, 0, 0, widgetIndex, w, 0, 0); - +void window_event_helper(rct_window* w, short widgetIndex, WINDOW_EVENTS event) +{ + RCT2_CALLPROC_X(w->event_handlers[event], 0, 0, 0, widgetIndex, (int)w, 0, 0); } diff --git a/src/window_news.c b/src/window_news.c index 1e849ce080..5d097d4770 100644 --- a/src/window_news.c +++ b/src/window_news.c @@ -318,7 +318,7 @@ static void window_news_scrollpaint() // Date text RCT2_GLOBAL(0x013CE952, uint16) = STR_DATE_DAY_1 + newsItem->day - 1; - RCT2_GLOBAL(0x013CE952 + 2, uint16) = STR_MONTH_MARCH + (newsItem->month % 8); + RCT2_GLOBAL(0x013CE952 + 2, uint16) = STR_MONTH_MARCH + (newsItem->month_year % 8); gfx_draw_string_left(dpi, 2235, 0x013CE952, 2, 4, y); // Item text From 7c6a193b422ede84123e43dc403c2c0d25009842 Mon Sep 17 00:00:00 2001 From: IntelOrca Date: Mon, 12 May 2014 02:18:08 +0100 Subject: [PATCH 41/41] remove all remaining warnings --- src/game.c | 9 ++- src/scenario.c | 6 +- src/window_about.c | 38 +++++------ src/window_banner.c | 7 +- src/window_cheats.c | 13 ++-- src/window_clear_scenery.c | 4 +- src/window_dropdown.c | 20 +++--- src/window_footpath.c | 41 ++++++----- src/window_game_bottom_toolbar.c | 10 ++- src/window_game_top_toolbar.c | 16 ++--- src/window_guest_list.c | 29 ++++---- src/window_land.c | 16 ++--- src/window_main.c | 4 +- src/window_news.c | 11 ++- src/window_options.c | 4 +- src/window_park.c | 109 ++++++++++++++---------------- src/window_ride_list.c | 19 +++--- src/window_save_prompt.c | 4 +- src/window_title_exit.c | 4 +- src/window_title_logo.c | 6 +- src/window_title_menu.c | 4 +- src/window_title_scenarioselect.c | 24 +++---- src/window_tooltip.c | 14 ++-- src/window_water.c | 4 +- 24 files changed, 197 insertions(+), 219 deletions(-) diff --git a/src/game.c b/src/game.c index 18f6c14414..c3f7c0f44c 100644 --- a/src/game.c +++ b/src/game.c @@ -201,7 +201,8 @@ void game_handle_input() RCT2_CALLPROC_EBPSAFE(0x006E8346); // update_cursor_position { - int eax, ebx, ecx, edx, esi, edi, ebp; + // int eax, ebx, ecx, edx, esi, edi, ebp; + int eax, ebx, ecx; for (;;) { game_get_next_input(&eax, &ebx, &ecx); @@ -1337,7 +1338,7 @@ static void game_load_or_quit() __asm mov input_di, di if (!(input_bl & 1)) - return 0; + return; // 0; switch (input_dl) { case 0: @@ -1361,13 +1362,15 @@ static void game_load_or_quit() */ static int open_landscape_file_dialog() { + int result; format_string((char*)0x0141ED68, STR_LOAD_LANDSCAPE_DIALOG_TITLE, 0); strcpy((char*)0x0141EF68, (char*)RCT2_ADDRESS_LANDSCAPES_PATH); format_string((char*)0x0141EE68, STR_RCT2_LANDSCAPE_FILE, 0); pause_sounds(); - osinterface_open_common_file_dialog(1, (char*)0x0141ED68, (char*)0x0141EF68, "*.SV6;*.SV4;*.SC6", (char*)0x0141EE68); + result = osinterface_open_common_file_dialog(1, (char*)0x0141ED68, (char*)0x0141EF68, "*.SV6;*.SV4;*.SC6", (char*)0x0141EE68); unpause_sounds(); // window_proc + return result; } /** diff --git a/src/scenario.c b/src/scenario.c index a766c87c36..4e4461e635 100644 --- a/src/scenario.c +++ b/src/scenario.c @@ -657,7 +657,7 @@ void scenario_objective8_check() for (int j = 0; j < limit; ++j) { sum += ((uint32*)&ride->pad_088[92])[j]; } - if ((sum >> 16) > objective_length) { + if ((sum >> 16) > (uint32)objective_length) { type_already_counted[subtype_id]++; rcs++; } @@ -844,7 +844,7 @@ void scenario_update() uint32 month_tick = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_TICKS, uint16), next_month_tick = month_tick + 4; uint8 month = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, sint16) & 7, - current_days_in_month = days_in_month[month], + current_days_in_month = (uint8)days_in_month[month], objective_type = RCT2_GLOBAL(RCT2_ADDRESS_OBJECTIVE_TYPE, uint8); if (screen_flags & (~SCREEN_FLAGS_PLAYING)) // only in normal play mode @@ -894,7 +894,7 @@ void scenario_update() finance_pay_ride_upkeep(); } - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_TICKS, uint16) = next_month_tick; + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_TICKS, uint16) = (uint16)next_month_tick; if (next_month_tick >= 0x10000) { // month ends actions RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, sint16)++; diff --git a/src/window_about.c b/src/window_about.c index c6657996f8..4250d65cdd 100644 --- a/src/window_about.c +++ b/src/window_about.c @@ -46,7 +46,7 @@ static void window_about_emptysub() { } static void window_about_mouseup(); static void window_about_paint(); -static uint32 window_about_events[] = { +static void* window_about_events[] = { window_about_emptysub, window_about_mouseup, window_about_emptysub, @@ -83,7 +83,6 @@ static uint32 window_about_events[] = { */ void window_about_open() { - int x, y; rct_window* window; // Check if window is already open @@ -96,7 +95,7 @@ void window_about_open() max(28, RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, uint16) / 2 - 165), 400, 330, - window_about_events, + (uint32*)window_about_events, WC_ABOUT, 0 ); @@ -115,7 +114,6 @@ void window_about_open() */ static void window_about_mouseup() { - int i; short widgetIndex; rct_window *w; @@ -155,40 +153,40 @@ static void window_about_paint() // Version RCT2_GLOBAL(0x009C383C, uint8) = 49; - gfx_draw_string_centred(dpi, STR_VERSION_X, x, y, 0, 0x009E2D28); + gfx_draw_string_centred(dpi, STR_VERSION_X, x, y, 0, (void*)0x009E2D28); // Credits RCT2_GLOBAL(0x009C383C, uint8) = 48; y += 10; - gfx_draw_string_centred(dpi, STR_COPYRIGHT_CS, x, y, 0, 0x009E2D28); + gfx_draw_string_centred(dpi, STR_COPYRIGHT_CS, x, y, 0, (void*)0x009E2D28); y += 79; - gfx_draw_string_centred(dpi, STR_DESIGNED_AND_PROGRAMMED_BY_CS, x, y, 0, 0x009E2D28); + gfx_draw_string_centred(dpi, STR_DESIGNED_AND_PROGRAMMED_BY_CS, x, y, 0, (void*)0x009E2D28); y += 10; - gfx_draw_string_centred(dpi, STR_GRAPHICS_BY_SF, x, y, 0, 0x009E2D28); + gfx_draw_string_centred(dpi, STR_GRAPHICS_BY_SF, x, y, 0, (void*)0x009E2D28); y += 10; - gfx_draw_string_centred(dpi, STR_SOUND_AND_MUSIC_BY_AB, x, y, 0, 0x009E2D28); + gfx_draw_string_centred(dpi, STR_SOUND_AND_MUSIC_BY_AB, x, y, 0, (void*)0x009E2D28); y += 10; - gfx_draw_string_centred(dpi, STR_ADDITIONAL_SOUNDS_RECORDED_BY_DE, x, y, 0, 0x009E2D28); + gfx_draw_string_centred(dpi, STR_ADDITIONAL_SOUNDS_RECORDED_BY_DE, x, y, 0, (void*)0x009E2D28); y += 13; - gfx_draw_string_centred(dpi, STR_REPRESENTATION_BY_JL, x, y, 0, 0x009E2D28); + gfx_draw_string_centred(dpi, STR_REPRESENTATION_BY_JL, x, y, 0, (void*)0x009E2D28); y += 25; - gfx_draw_string_centred(dpi, STR_THANKS_TO, x, y, 0, 0x009E2D28); + gfx_draw_string_centred(dpi, STR_THANKS_TO, x, y, 0, (void*)0x009E2D28); y += 10; - gfx_draw_string_centred(dpi, STR_THANKS_TO_PEOPLE, x, y, 0, 0x009E2D28); + gfx_draw_string_centred(dpi, STR_THANKS_TO_PEOPLE, x, y, 0, (void*)0x009E2D28); y += 10; - gfx_draw_string_centred(dpi, STR_CREDIT_SPARE_1, x, y, 0, 0x009E2D28); + gfx_draw_string_centred(dpi, STR_CREDIT_SPARE_1, x, y, 0, (void*)0x009E2D28); y += 10; - gfx_draw_string_centred(dpi, STR_CREDIT_SPARE_2, x, y, 0, 0x009E2D28); + gfx_draw_string_centred(dpi, STR_CREDIT_SPARE_2, x, y, 0, (void*)0x009E2D28); y += 10; - gfx_draw_string_centred(dpi, STR_CREDIT_SPARE_3, x, y, 0, 0x009E2D28); + gfx_draw_string_centred(dpi, STR_CREDIT_SPARE_3, x, y, 0, (void*)0x009E2D28); y += 10; - gfx_draw_string_centred(dpi, STR_CREDIT_SPARE_4, x, y, 0, 0x009E2D28); + gfx_draw_string_centred(dpi, STR_CREDIT_SPARE_4, x, y, 0, (void*)0x009E2D28); y += 10; - gfx_draw_string_centred(dpi, STR_CREDIT_SPARE_5, x, y, 0, 0x009E2D28); + gfx_draw_string_centred(dpi, STR_CREDIT_SPARE_5, x, y, 0, (void*)0x009E2D28); y += 10; - gfx_draw_string_centred(dpi, STR_CREDIT_SPARE_6, x, y, 0, 0x009E2D28); + gfx_draw_string_centred(dpi, STR_CREDIT_SPARE_6, x, y, 0, (void*)0x009E2D28); y += 10; - gfx_draw_string_centred(dpi, STR_CREDIT_SPARE_7, x, y, 0, 0x009E2D28); + gfx_draw_string_centred(dpi, STR_CREDIT_SPARE_7, x, y, 0, (void*)0x009E2D28); // Images gfx_draw_sprite(dpi, SPR_CREDITS_CHRIS_SAWYER_SMALL, w->x + 92, w->y + 40); diff --git a/src/window_banner.c b/src/window_banner.c index 89bf755a46..8f930d330b 100644 --- a/src/window_banner.c +++ b/src/window_banner.c @@ -61,7 +61,7 @@ static void window_banner_textinput(); static void window_banner_invalidate(); static void window_banner_paint(); -static uint32 window_banner_events[] = { +static void* window_banner_events[] = { window_banner_emptysub, window_banner_mouseup, window_banner_emptysub, @@ -82,7 +82,7 @@ static uint32 window_banner_events[] = { window_banner_emptysub, window_banner_emptysub, window_banner_textinput, - 0x006BA7B5, + (void*)0x006BA7B5, window_banner_emptysub, window_banner_emptysub, window_banner_emptysub, @@ -100,7 +100,6 @@ void window_banner_open() { rct_windownumber windownumber; rct_window* w; - rct_viewport *viewport; rct_widget *viewportWidget; //__asm mov windownumber, ax // not quite right I think @@ -111,7 +110,7 @@ void window_banner_open() if (w != NULL) return; - w = window_create_auto_pos(113, 96, window_banner_events, WC_BANNER, 0); + w = window_create_auto_pos(113, 96, (uint32*)window_banner_events, WC_BANNER, 0); w->widgets = window_banner_widgets; w->enabled_widgets = (1 << WIDX_CLOSE) | diff --git a/src/window_cheats.c b/src/window_cheats.c index 4e9b188f53..8dfbb32e21 100644 --- a/src/window_cheats.c +++ b/src/window_cheats.c @@ -84,7 +84,7 @@ static void window_cheats_invalidate(); static void window_cheats_paint(); static void window_cheats_set_page(rct_window *w, int page); -static uint32 window_cheats_money_events[] = { +static void* window_cheats_money_events[] = { window_cheats_emptysub, window_cheats_money_mouseup, window_cheats_emptysub, @@ -115,7 +115,7 @@ static uint32 window_cheats_money_events[] = { window_cheats_emptysub }; -static uint32 window_cheats_guests_events[] = { +static void* window_cheats_guests_events[] = { window_cheats_emptysub, window_cheats_guests_mouseup, window_cheats_emptysub, @@ -146,7 +146,7 @@ static uint32 window_cheats_guests_events[] = { window_cheats_emptysub }; -static uint32 *window_cheats_page_events[] = { +static void* window_cheats_page_events[] = { window_cheats_money_events, window_cheats_guests_events, }; @@ -167,7 +167,7 @@ void window_cheats_open() if (window != NULL) return; - window = window_create(32, 32, WW, WH, window_cheats_money_events, WC_CHEATS, 0); + window = window_create(32, 32, WW, WH, (uint32*)window_cheats_money_events, WC_CHEATS, 0); window->widgets = window_cheats_money_widgets; window->enabled_widgets = window_cheats_page_enabled_widgets[0]; window_init_scroll_widgets(window); @@ -211,7 +211,6 @@ static void window_cheats_money_mouseup() static void window_cheats_guests_mouseup() { - int i; short widgetIndex; rct_window *w; @@ -260,7 +259,7 @@ static void window_cheats_invalidate() __asm mov w, esi strcpy((char*)0x009BC677, "Cheats"); - rct_widget **widgets = window_cheats_page_widgets[w->page]; + rct_widget *widgets = window_cheats_page_widgets[w->page]; if (w->widgets != widgets) { w->widgets = widgets; window_init_scroll_widgets(w); @@ -269,7 +268,7 @@ static void window_cheats_invalidate() // Set correct active tab for (i = 0; i < 7; i++) w->pressed_widgets &= ~(1 << (WIDX_TAB_1 + i)); - w->pressed_widgets |= 1 << (WIDX_TAB_1 + w->page); + w->pressed_widgets |= 1LL << (WIDX_TAB_1 + w->page); } static void window_cheats_paint() diff --git a/src/window_clear_scenery.c b/src/window_clear_scenery.c index f5a708f83d..81cc447c78 100644 --- a/src/window_clear_scenery.c +++ b/src/window_clear_scenery.c @@ -53,7 +53,7 @@ static void window_clear_scenery_update(); static void window_clear_scenery_invalidate(); static void window_clear_scenery_paint(); -static uint32 window_clear_scenery_events[] = { +static void* window_clear_scenery_events[] = { window_clear_scenery_close, window_clear_scenery_mouseup, window_clear_scenery_emptysub, @@ -96,7 +96,7 @@ void window_clear_scenery_open() if (window_find_by_id(WC_CLEAR_SCENERY, 0) != NULL) return; - window = window_create(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, sint16) - 98, 29, 98, 67, window_clear_scenery_events, WC_CLEAR_SCENERY, 0); + window = window_create(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, sint16) - 98, 29, 98, 67, (uint32*)window_clear_scenery_events, WC_CLEAR_SCENERY, 0); window->widgets = window_clear_scenery_widgets; window->enabled_widgets = (1 << WIDX_CLOSE) | (1 << WIDX_INCREMENT) | (1 << WIDX_DECREMENT); window_init_scroll_widgets(window); diff --git a/src/window_dropdown.c b/src/window_dropdown.c index 14c27202a2..84607a4632 100644 --- a/src/window_dropdown.c +++ b/src/window_dropdown.c @@ -57,7 +57,7 @@ uint32 gDropdownItemsChecked; static void window_dropdown_emptysub() { } static void window_dropdown_paint(); -static uint32 window_dropdown_events[] = { +static void* window_dropdown_events[] = { window_dropdown_emptysub, window_dropdown_emptysub, window_dropdown_emptysub, @@ -130,12 +130,10 @@ void window_dropdown_show_text(int x, int y, int extray, uint8 colour, uint8 fla void window_dropdown_show_text_custom_width(int x, int y, int extray, uint8 colour, uint8 flags, int num_items, int width) { rct_window* w; - int i, string_width, max_string_width; - char buffer[256]; // Copy the formats and arguments until all use of it is decompiled - memcpy(0x009DEBA4, gDropdownItemsFormat, 40 * 2); - memcpy(0x009DEBF4, gDropdownItemsArgs, 40 * 8); + memcpy((void*)0x009DEBA4, gDropdownItemsFormat, 40 * 2); + memcpy((void*)0x009DEBF4, gDropdownItemsArgs, 40 * 8); RCT2_GLOBAL(0x009DE518, uint32) &= ~(0x04 | 0x02); if (flags & 0x80) @@ -159,7 +157,7 @@ void window_dropdown_show_text_custom_width(int x, int y, int extray, uint8 colo x, y + extray, window_dropdown_widgets[WIDX_BACKGROUND].right + 1, window_dropdown_widgets[WIDX_BACKGROUND].bottom + 1, - window_dropdown_events, + (uint32*)window_dropdown_events, WC_DROPDOWN, 0x02 ); @@ -199,12 +197,12 @@ void window_dropdown_show_text_custom_width(int x, int y, int extray, uint8 colo */ void window_dropdown_show_image(int x, int y, int extray, uint8 colour, uint8 flags, int numItems, int itemWidth, int itemHeight, int numColumns) { - int i, width, height; + int width, height; rct_window* w; // Copy the formats and arguments until all use of it is decompiled - memcpy(0x009DEBA4, gDropdownItemsFormat, 40 * 2); - memcpy(0x009DEBF4, gDropdownItemsArgs, 40 * 8); + memcpy((void*)0x009DEBA4, gDropdownItemsFormat, 40 * 2); + memcpy((void*)0x009DEBF4, gDropdownItemsArgs, 40 * 8); RCT2_GLOBAL(0x009DE518, uint32) &= ~(0x04 | 0x02); if (flags & 0x80) @@ -237,7 +235,7 @@ void window_dropdown_show_image(int x, int y, int extray, uint8 colour, uint8 fl x, y + extray, window_dropdown_widgets[WIDX_BACKGROUND].right + 1, window_dropdown_widgets[WIDX_BACKGROUND].bottom + 1, - window_dropdown_events, + (uint32*)window_dropdown_events, WC_DROPDOWN, WF_STICK_TO_FRONT ); @@ -312,7 +310,7 @@ static void window_dropdown_paint() item = gDropdownItemsFormat[i]; if (item == (uint16)-1 || item == (uint16)-2) { // Image item - image = gDropdownItemsArgs[i]; + image = *((uint32*)&gDropdownItemsArgs[i]); if (item == (uint16)-2 && _dropdown_highlighted_index == i) image++; diff --git a/src/window_footpath.c b/src/window_footpath.c index 44ab834559..38da0c66e6 100644 --- a/src/window_footpath.c +++ b/src/window_footpath.c @@ -116,7 +116,7 @@ static void window_footpath_toolup(); static void window_footpath_invalidate(); static void window_footpath_paint(); -static uint32 window_footpath_events[] = { +static void* window_footpath_events[] = { window_footpath_close, window_footpath_mouseup, window_footpath_emptysub, @@ -174,7 +174,7 @@ void window_footpath_open() 29, 106, 381, - window_footpath_events, + (uint32*)window_footpath_events, WC_FOOTPATH, 0 ); @@ -305,25 +305,25 @@ static void window_footpath_mousedown() window_footpath_show_footpath_types_dialog(w, widget, 1); break; case WIDX_DIRECTION_NW: - RCT2_CALLPROC_X(0x006A8111, 0, 0, 0, 0, w, 0, 0); + RCT2_CALLPROC_X(0x006A8111, 0, 0, 0, 0, (int)w, 0, 0); break; case WIDX_DIRECTION_NE: - RCT2_CALLPROC_X(0x006A8135, 0, 0, 0, 0, w, 0, 0); + RCT2_CALLPROC_X(0x006A8135, 0, 0, 0, 0, (int)w, 0, 0); break; case WIDX_DIRECTION_SW: - RCT2_CALLPROC_X(0x006A815C, 0, 0, 0, 0, w, 0, 0); + RCT2_CALLPROC_X(0x006A815C, 0, 0, 0, 0, (int)w, 0, 0); break; case WIDX_DIRECTION_SE: - RCT2_CALLPROC_X(0x006A8183, 0, 0, 0, 0, w, 0, 0); + RCT2_CALLPROC_X(0x006A8183, 0, 0, 0, 0, (int)w, 0, 0); break; case WIDX_SLOPEDOWN: - RCT2_CALLPROC_X(0x006A81AA, 0, 0, 0, 0, w, 0, 0); + RCT2_CALLPROC_X(0x006A81AA, 0, 0, 0, 0, (int)w, 0, 0); break; case WIDX_LEVEL: - RCT2_CALLPROC_X(0x006A81C5, 0, 0, 0, 0, w, 0, 0); + RCT2_CALLPROC_X(0x006A81C5, 0, 0, 0, 0, (int)w, 0, 0); break; case WIDX_SLOPEUP: - RCT2_CALLPROC_X(0x006A81E0, 0, 0, 0, 0, w, 0, 0); + RCT2_CALLPROC_X(0x006A81E0, 0, 0, 0, 0, (int)w, 0, 0); break; } } @@ -388,10 +388,9 @@ static void window_footpath_dropdown() */ static void window_footpath_toolupdate() { - int x, y, z; + int x, y; short widgetIndex; rct_window *w; - rct_map_element *mapElement; __asm mov x, eax __asm mov y, ebx @@ -401,7 +400,7 @@ static void window_footpath_toolupdate() if (widgetIndex == WIDX_CONSTRUCT_ON_LAND) { window_footpath_set_provisional_path_at_point(x, y); } else if (widgetIndex == WIDX_CONSTRUCT_BRIDGE_OR_TUNNEL) { - RCT2_CALLPROC_X(0x006A8388, 0, 0, 0, 0, w, 0, 0); + RCT2_CALLPROC_X(0x006A8388, 0, 0, 0, 0, (int)w, 0, 0); } } @@ -411,10 +410,9 @@ static void window_footpath_toolupdate() */ static void window_footpath_tooldown() { - int x, y, z; + int x, y; short widgetIndex; rct_window *w; - rct_map_element *mapElement; __asm mov x, eax __asm mov y, ebx @@ -424,7 +422,7 @@ static void window_footpath_tooldown() if (widgetIndex == WIDX_CONSTRUCT_ON_LAND) { window_footpath_place_path_at_point(x, y); } else if (widgetIndex == WIDX_CONSTRUCT_BRIDGE_OR_TUNNEL) { - RCT2_CALLPROC_X(0x006A840F, x, y, 0, 0, w, 0, 0); + RCT2_CALLPROC_X(0x006A840F, x, y, 0, 0, (int)w, 0, 0); } } @@ -444,7 +442,7 @@ static void window_footpath_tooldrag() __asm mov w, esi if (widgetIndex == WIDX_CONSTRUCT_ON_LAND) { - RCT2_CALLPROC_X(0x006A82C5, x, y, 0, 0, w, 0, 0); + RCT2_CALLPROC_X(0x006A82C5, x, y, 0, 0, (int)w, 0, 0); } } @@ -464,7 +462,7 @@ static void window_footpath_toolup() __asm mov w, esi if (widgetIndex == WIDX_CONSTRUCT_ON_LAND) { - RCT2_CALLPROC_X(0x006A8380, x, y, 0, 0, w, 0, 0); + RCT2_CALLPROC_X(0x006A8380, x, y, 0, 0, (int)w, 0, 0); } } @@ -649,7 +647,7 @@ static void window_footpath_set_provisional_path_at_point(int x, int y) x = eax & 0xFFFF; z = ebx & 0xFF; y = ecx & 0xFFFF; - mapElement = edx; + mapElement = (rct_map_element*)edx; if (z == 0) { RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) &= ~1; @@ -686,8 +684,7 @@ static void window_footpath_set_provisional_path_at_point(int x, int y) */ static int window_footpath_set_provisional_path(int type, int x, int y, int z, int slope) { - int cost; - int eax, ebx, ecx, edx, esi, edi, ebp; + int eax, cost; RCT2_CALLPROC_EBPSAFE(0x006A77FF); @@ -732,7 +729,7 @@ static void window_footpath_place_path_at_point(int x, int y) x = eax & 0xFFFF; z = ebx & 0xFF; y = ecx & 0xFFFF; - mapElement = edx; + mapElement = (rct_map_element*)edx; if (z == 0) return; @@ -775,7 +772,7 @@ static void window_footpath_construct() */ static void window_footpath_remove() { - int x, y, z, lastTile; + int x, y, lastTile; rct_map_element *mapElement; // RCT2_CALLPROC_EBPSAFE(0x006A7863); diff --git a/src/window_game_bottom_toolbar.c b/src/window_game_bottom_toolbar.c index 00eacc24e3..49c820abf2 100644 --- a/src/window_game_bottom_toolbar.c +++ b/src/window_game_bottom_toolbar.c @@ -77,7 +77,7 @@ static void window_game_bottom_toolbar_draw_right_panel(rct_drawpixelinfo *dpi, static void window_game_bottom_toolbar_draw_news_item(rct_drawpixelinfo *dpi, rct_window *w); static void window_game_bottom_toolbar_draw_tutorial_text(rct_drawpixelinfo *dpi, rct_window *w); -static uint32 window_game_bottom_toolbar_events[] = { +static void* window_game_bottom_toolbar_events[] = { window_game_bottom_toolbar_emptysub, window_game_bottom_toolbar_mouseup, window_game_bottom_toolbar_emptysub, @@ -119,7 +119,7 @@ void window_game_bottom_toolbar_open() window = window_create( 0, RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, sint16) - 32, RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, sint16), 32, - window_game_bottom_toolbar_events, + (uint32*)window_game_bottom_toolbar_events, WC_BOTTOM_TOOLBAR, WF_STICK_TO_FRONT | WF_TRANSPARENT | WF_5 ); @@ -204,8 +204,7 @@ static void window_game_bottom_toolbar_tooltip() { int month, day; short widgetIndex; - rct_window *w, *mainWindow; - rct_news_item *newsItem; + rct_window *w; __asm mov widgetIndex, dx __asm mov w, esi @@ -332,7 +331,6 @@ void window_game_bottom_toolbar_invalidate_news_item() */ static void window_game_bottom_toolbar_paint() { - int x, y, imgId; rct_window *w; rct_drawpixelinfo *dpi; @@ -525,7 +523,7 @@ static void window_game_bottom_toolbar_draw_news_item(rct_drawpixelinfo *dpi, rc (window_game_bottom_toolbar_widgets[WIDX_MIDDLE_OUTSET].left + window_game_bottom_toolbar_widgets[WIDX_MIDDLE_OUTSET].right) / 2 + w->x, w->y + window_game_bottom_toolbar_widgets[WIDX_MIDDLE_OUTSET].top + 11, 0, - dpi, + (int)dpi, (newsItem->ticks << 16) | (window_game_bottom_toolbar_widgets[WIDX_MIDDLE_OUTSET].right - window_game_bottom_toolbar_widgets[WIDX_MIDDLE_OUTSET].left - 62) ); diff --git a/src/window_game_top_toolbar.c b/src/window_game_top_toolbar.c index d64bb1b862..f6d893d16d 100644 --- a/src/window_game_top_toolbar.c +++ b/src/window_game_top_toolbar.c @@ -82,7 +82,7 @@ static void window_game_top_toolbar_dropdown(); static void window_game_top_toolbar_invalidate(); static void window_game_top_toolbar_paint(); -static uint32 window_game_top_toolbar_events[] = { +static void* window_game_top_toolbar_events[] = { window_game_top_toolbar_emptysub, window_game_top_toolbar_mouseup, window_game_top_toolbar_emptysub, @@ -92,11 +92,11 @@ static uint32 window_game_top_toolbar_events[] = { window_game_top_toolbar_emptysub, window_game_top_toolbar_emptysub, window_game_top_toolbar_emptysub, - 0x0066CB25, - 0x0066CB73, - 0x0066CB4E, - 0x0066CC5B, - 0x0066CA58, + (void*)0x0066CB25, + (void*)0x0066CB73, + (void*)0x0066CB4E, + (void*)0x0066CC5B, + (void*)0x0066CA58, window_game_top_toolbar_emptysub, window_game_top_toolbar_emptysub, window_game_top_toolbar_emptysub, @@ -124,7 +124,7 @@ void window_game_top_toolbar_open() window = window_create( 0, 0, RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, sint16), 28, - window_game_top_toolbar_events, + (uint32*)window_game_top_toolbar_events, WC_TOP_TOOLBAR, WF_STICK_TO_FRONT | WF_TRANSPARENT | WF_5 ); @@ -356,7 +356,7 @@ static void window_game_top_toolbar_dropdown() break; } - char *src = 0x0141EF67; + char *src = (char*)0x0141EF67; do { src++; } while (*src != '.' && *src != '\0'); diff --git a/src/window_guest_list.c b/src/window_guest_list.c index 0dbd247bb3..5bd202fa28 100644 --- a/src/window_guest_list.c +++ b/src/window_guest_list.c @@ -84,7 +84,7 @@ static void window_guest_list_invalidate(); static void window_guest_list_paint(); static void window_guest_list_scrollpaint(); -static uint32 window_guest_list_events[] = { +static void* window_guest_list_events[] = { window_guest_list_emptysub, window_guest_list_mouseup, window_guest_list_resize, @@ -146,7 +146,7 @@ void window_guest_list_open() if (window != NULL) return; - window = window_create_auto_pos(350, 330, window_guest_list_events, WC_GUEST_LIST, 0x0400); + window = window_create_auto_pos(350, 330, (uint32*)window_guest_list_events, WC_GUEST_LIST, 0x0400); window->widgets = window_guest_list_widgets; window->enabled_widgets = (1 << WIDX_CLOSE) | @@ -184,7 +184,6 @@ void window_guest_list_open() */ static void window_guest_list_mouseup() { - int i; short widgetIndex; rct_window *w; @@ -442,7 +441,7 @@ static void window_guest_list_scrollmousedown() if (i == 0) { // Open guest window - RCT2_CALLPROC_X(0x006989E9, 0, 0, 0, peep, 0, 0, 0); + RCT2_CALLPROC_X(0x006989E9, 0, 0, 0, (int)peep, 0, 0, 0); break; } else { i--; @@ -505,7 +504,7 @@ 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 |= (1LL << (_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; @@ -576,14 +575,14 @@ static void window_guest_list_paint() } else { format = STR_ALL_GUESTS_SUMMARISED; } - gfx_draw_string_left_clipped(dpi, format, 0x00F1EDF6, 0, x, y, 310); + gfx_draw_string_left_clipped(dpi, format, (void*)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); + gfx_draw_string_left(dpi, (w->var_492 == 1 ? 1755 : 1754), (void*)0x013CE952, 0, x, y); } } @@ -594,7 +593,7 @@ static void window_guest_list_paint() static void window_guest_list_scrollpaint() { int eax, ebx, ecx, edx, esi, edi, ebp; - int spriteIdx, format, numGuests, i, j, x, y; + int spriteIdx, format, numGuests, i, j, y; rct_window *w; rct_drawpixelinfo *dpi; rct_peep *peep; @@ -645,7 +644,7 @@ static void window_guest_list_scrollpaint() // 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); + gfx_draw_string_left_clipped(dpi, format, (void*)0x013CE952, 0, 0, y - 1, 113); switch (_window_guest_list_selected_view) { case VIEW_ACTIONS: @@ -665,7 +664,7 @@ static void window_guest_list_scrollpaint() 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); + gfx_draw_string_left_clipped(dpi, format, (void*)0x013CE952, 0, 133, y - 1, 314); break; case VIEW_THOUGHTS: // For each thought @@ -686,7 +685,7 @@ static void window_guest_list_scrollpaint() 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); + gfx_draw_string_left_clipped(dpi, format, (void*)0x013CE952, 0, 118, y - 1, 329); break; } break; @@ -726,11 +725,11 @@ static void window_guest_list_scrollpaint() 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); + gfx_draw_string_left_clipped(dpi, format, (void*)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); + gfx_draw_string_right(dpi, format, (void*)0x0013CE95A, 0, 326, y - 1); } y += 21; } @@ -750,7 +749,7 @@ static int window_guest_list_is_peep_in_filter(rct_peep* peep) temp = _window_guest_list_selected_view; _window_guest_list_selected_view = _window_guest_list_selected_filter; - esi = peep; + esi = (int)peep; RCT2_CALLFUNC_X(0x0069B7EA, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); ebx &= 0xFFFF; @@ -798,6 +797,8 @@ static int sub_69B7EA(rct_peep *peep, int *outEAX) *outEAX = 0; return 0; } + + return 0; } /** diff --git a/src/window_land.c b/src/window_land.c index ca9b9ea295..2a2c90e7b5 100644 --- a/src/window_land.c +++ b/src/window_land.c @@ -58,7 +58,7 @@ static void window_land_update(); static void window_land_invalidate(); static void window_land_paint(); -static uint32 window_land_events[] = { +static void* window_land_events[] = { window_land_close, window_land_mouseup, window_land_emptysub, @@ -122,7 +122,7 @@ void window_land_open() if (window_find_by_id(WC_LAND, 0) != NULL) return; - window = window_create(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, sint16) - 98, 29, 98, 126, window_land_events, WC_LAND, 0); + window = window_create(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, sint16) - 98, 29, 98, 126, (uint32*)window_land_events, WC_LAND, 0); window->widgets = window_land_widgets; window->enabled_widgets = (1 << WIDX_CLOSE) | @@ -277,7 +277,7 @@ static void window_land_dropdown() type = (dropdownIndex == -1) ? _selectedFloorTexture : - gDropdownItemsArgs[dropdownIndex] - SPR_FLOOR_TEXTURE_GRASS; + *((uint32*)&gDropdownItemsArgs[dropdownIndex]) - SPR_FLOOR_TEXTURE_GRASS; if (RCT2_GLOBAL(RCT2_ADDRESS_SELECTED_TERRAIN_SURFACE, uint8) == type) { RCT2_GLOBAL(RCT2_ADDRESS_SELECTED_TERRAIN_SURFACE, uint8) = 255; @@ -293,7 +293,7 @@ static void window_land_dropdown() type = (dropdownIndex == -1) ? _selectedWallTexture : - gDropdownItemsArgs[dropdownIndex] - SPR_WALL_TEXTURE_ROCK; + *((uint32*)&gDropdownItemsArgs[dropdownIndex]) - SPR_WALL_TEXTURE_ROCK; if (RCT2_GLOBAL(RCT2_ADDRESS_SELECTED_TERRAIN_EDGE, uint8) == type) { RCT2_GLOBAL(RCT2_ADDRESS_SELECTED_TERRAIN_EDGE, uint8) = 255; @@ -368,19 +368,19 @@ static void window_land_paint() RCT2_GLOBAL(0x009BC678, char) = FORMAT_COMMA16; RCT2_GLOBAL(0x009BC679, char) = 0; RCT2_GLOBAL(0x013CE952, sint16) = RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16); - gfx_draw_string_centred(dpi, 3165, x, y - 2, 0, 0x013CE952); + gfx_draw_string_centred(dpi, 3165, x, y - 2, 0, (void*)0x013CE952); } y = w->y + window_land_widgets[WIDX_PREVIEW].bottom + 5; // Draw raise cost amount if (RCT2_GLOBAL(RCT2_ADDRESS_LAND_RAISE_COST, uint32) != 0x80000000 && RCT2_GLOBAL(RCT2_ADDRESS_LAND_RAISE_COST, uint32) != 0) - gfx_draw_string_centred(dpi, 984, x, y, 0, RCT2_ADDRESS_LAND_RAISE_COST); + gfx_draw_string_centred(dpi, 984, x, y, 0, (void*)RCT2_ADDRESS_LAND_RAISE_COST); y += 10; // Draw lower cost amount if (RCT2_GLOBAL(RCT2_ADDRESS_LAND_LOWER_COST, uint32) != 0x80000000 && RCT2_GLOBAL(RCT2_ADDRESS_LAND_LOWER_COST, uint32) != 0) - gfx_draw_string_centred(dpi, 985, x, y, 0, RCT2_ADDRESS_LAND_LOWER_COST); + gfx_draw_string_centred(dpi, 985, x, y, 0, (void*)RCT2_ADDRESS_LAND_LOWER_COST); y += 50; // Draw paint price @@ -393,7 +393,7 @@ static void window_land_paint() if (price != 0 && !(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY)) { RCT2_GLOBAL(0x013CE952, sint32) = price; - gfx_draw_string_centred(dpi, 986, x, y, 0, 0x013CE952); + gfx_draw_string_centred(dpi, 986, x, y, 0, (void*)0x013CE952); } } diff --git a/src/window_main.c b/src/window_main.c index 2c95d7cbc8..314fe51d94 100644 --- a/src/window_main.c +++ b/src/window_main.c @@ -34,14 +34,14 @@ rct_widget window_main_widgets[] = { void window_main_open() { rct_window* window; - rct_widget* main_widgets = 0x009A9414; + rct_widget* main_widgets = (rct_widget*)0x009A9414; main_widgets[0].right = RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, sint16); main_widgets[0].bottom = RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, sint16); window = window_create( 0, 0, window_main_widgets[0].right, window_main_widgets[0].bottom, - 0x0097C0BC, + (uint32*)0x0097C0BC, WC_MAIN_WINDOW, WF_STICK_TO_BACK ); diff --git a/src/window_news.c b/src/window_news.c index 5d097d4770..4fa036bae0 100644 --- a/src/window_news.c +++ b/src/window_news.c @@ -52,7 +52,7 @@ static void window_news_tooltip(); static void window_news_paint(); static void window_news_scrollpaint(); -static uint32 window_news_events[] = { +static void* window_news_events[] = { window_news_emptysub, window_news_mouseup, window_news_emptysub, @@ -89,7 +89,6 @@ static uint32 window_news_events[] = { */ void window_news_open() { - int x, y; rct_window* window; // Check if window is already open @@ -98,7 +97,7 @@ void window_news_open() window = window_create_auto_pos( 400, 300, - window_news_events, + (uint32*)window_news_events, WC_RECENT_NEWS, 0 ); @@ -127,7 +126,6 @@ void window_news_open() */ static void window_news_mouseup() { - int i; short widgetIndex; rct_window *w; @@ -276,7 +274,6 @@ static void window_news_tooltip() */ static void window_news_paint() { - int x, y; rct_window *w; rct_drawpixelinfo *dpi; @@ -319,11 +316,11 @@ static void window_news_scrollpaint() // Date text RCT2_GLOBAL(0x013CE952, uint16) = STR_DATE_DAY_1 + newsItem->day - 1; RCT2_GLOBAL(0x013CE952 + 2, uint16) = STR_MONTH_MARCH + (newsItem->month_year % 8); - gfx_draw_string_left(dpi, 2235, 0x013CE952, 2, 4, y); + gfx_draw_string_left(dpi, 2235, (void*)0x013CE952, 2, 4, y); // Item text RCT2_GLOBAL(0x009B5F2C, uint8) = newsItem->colour; - strcpy(0x009B5F2D, newsItem->text); + strcpy((char*)0x009B5F2D, newsItem->text); gfx_draw_string_left_wrapped(dpi, 0, 2, y + 10, 325, 1926, 14); // Subject button diff --git a/src/window_options.c b/src/window_options.c index a9f81e2eeb..142ca1dcb7 100644 --- a/src/window_options.c +++ b/src/window_options.c @@ -104,7 +104,7 @@ static void window_options_dropdown(); static void window_options_update(); static void window_options_paint(); -static uint32 window_options_events[] = { +static void* window_options_events[] = { window_options_emptysub, window_options_mouseup, window_options_emptysub, @@ -148,7 +148,7 @@ void window_options_open() if (w != NULL) return; - w = window_create_auto_pos(310, 372, window_options_events, WC_OPTIONS, 0); + w = window_create_auto_pos(310, 372, (uint32*)window_options_events, WC_OPTIONS, 0); w->widgets = window_options_widgets; w->enabled_widgets = (1 << WIDX_CLOSE) | diff --git a/src/window_park.c b/src/window_park.c index 6e3911f424..c7ee646eae 100644 --- a/src/window_park.c +++ b/src/window_park.c @@ -264,7 +264,7 @@ static void window_park_awards_update(); static void window_park_awards_invalidate(); static void window_park_awards_paint(); -static uint32 window_park_entrance_events[] = { +static void* window_park_entrance_events[] = { window_park_entrance_close, window_park_entrance_mouseup, window_park_entrance_resize, @@ -295,7 +295,7 @@ static uint32 window_park_entrance_events[] = { window_park_emptysub }; -static uint32 window_park_rating_events[] = { +static void* window_park_rating_events[] = { window_park_emptysub, window_park_rating_mouseup, window_park_rating_resize, @@ -326,7 +326,7 @@ static uint32 window_park_rating_events[] = { window_park_emptysub }; -static uint32 window_park_guests_events[] = { +static void* window_park_guests_events[] = { window_park_emptysub, window_park_guests_mouseup, window_park_guests_resize, @@ -357,7 +357,7 @@ static uint32 window_park_guests_events[] = { window_park_emptysub }; -static uint32 window_park_price_events[] = { +static void* window_park_price_events[] = { window_park_emptysub, window_park_price_mouseup, window_park_price_resize, @@ -388,7 +388,7 @@ static uint32 window_park_price_events[] = { window_park_emptysub }; -static uint32 window_park_stats_events[] = { +static void* window_park_stats_events[] = { window_park_emptysub, window_park_stats_mouseup, window_park_stats_resize, @@ -419,7 +419,7 @@ static uint32 window_park_stats_events[] = { window_park_emptysub }; -static uint32 window_park_objective_events[] = { +static void* window_park_objective_events[] = { window_park_emptysub, window_park_objective_mouseup, window_park_objective_resize, @@ -450,7 +450,7 @@ static uint32 window_park_objective_events[] = { window_park_emptysub }; -static uint32 window_park_awards_events[] = { +static void* window_park_awards_events[] = { window_park_emptysub, window_park_awards_mouseup, window_park_awards_resize, @@ -481,7 +481,7 @@ static uint32 window_park_awards_events[] = { window_park_emptysub }; -static uint32 *window_park_page_events[] = { +static void* window_park_page_events[] = { window_park_entrance_events, window_park_rating_events, window_park_guests_events, @@ -589,7 +589,7 @@ rct_window *window_park_open() { rct_window* w; - w = window_create_auto_pos(230, 174, window_park_entrance_events, WC_PARK_INFORMATION, 0x0400); + w = window_create_auto_pos(230, 174, (uint32*)window_park_entrance_events, WC_PARK_INFORMATION, 0x0400); w->widgets = window_park_entrance_widgets; w->enabled_widgets = window_park_page_enabled_widgets[WINDOW_PARK_PAGE_ENTRANCE]; w->number = 0; @@ -599,7 +599,7 @@ rct_window *window_park_open() w->var_490 = -1; w->var_48C = -1; w->var_492 = 0; - RCT2_CALLPROC_X(0x00667F8B, 0, 0, 0, 0, w, 0, 0); + RCT2_CALLPROC_X(0x00667F8B, 0, 0, 0, 0, (int)w, 0, 0); w->colours[0] = 1; w->colours[1] = 19; w->colours[2] = 19; @@ -628,7 +628,7 @@ void window_park_entrance_open() window_invalidate(window); window->widgets = window_park_entrance_widgets; window->enabled_widgets = window_park_page_enabled_widgets[WINDOW_PARK_PAGE_ENTRANCE]; - window->event_handlers = window_park_entrance_events; + window->event_handlers = (uint32*)window_park_entrance_events; window->pressed_widgets = 0; window_init_scroll_widgets(window); window_park_init_viewport(window); @@ -675,10 +675,10 @@ static void window_park_entrance_mouseup() window_park_set_page(w, widgetIndex - WIDX_TAB_1); break; case WIDX_BUY_LAND_RIGHTS: - RCT2_CALLPROC_X(0x006682F7, 0, 0, 0, widgetIndex, w, 0, 0); + RCT2_CALLPROC_X(0x006682F7, 0, 0, 0, widgetIndex, (int)w, 0, 0); break; case WIDX_BUY_CONSTRUCTION_RIGHTS: - RCT2_CALLPROC_X(0x00668393, 0, 0, 0, widgetIndex, w, 0, 0); + RCT2_CALLPROC_X(0x00668393, 0, 0, 0, widgetIndex, (int)w, 0, 0); break; case WIDX_LOCATE: window_park_scroll_to_viewport(w); @@ -791,7 +791,7 @@ static void window_park_entrance_toolupdate() { int x, y; short widgetIndex; - rct_window *w, *mainWindow; + rct_window *w; __asm mov x, eax __asm mov y, ebx @@ -799,7 +799,7 @@ static void window_park_entrance_toolupdate() __asm mov w, esi if (widgetIndex == WIDX_BUY_LAND_RIGHTS) { - RCT2_CALLPROC_X(0x0068AAE1, x, y, 0, 0, w, 0, 0); + RCT2_CALLPROC_X(0x0068AAE1, x, y, 0, 0, (int)w, 0, 0); RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) &= 0xFFFE; screen_pos_to_map_pos(&x, &y); if (x != SPRITE_LOCATION_NULL) { @@ -809,7 +809,7 @@ static void window_park_entrance_toolupdate() 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); + RCT2_CALLPROC_X(0x0068AAE1, x, y, 0, 0, (int)w, 0, 0); } } } @@ -821,14 +821,14 @@ static void window_park_entrance_toolupdate() static void window_park_entrance_tooldown() { short x, y, widgetIndex; - rct_window *w, *mainWindow; + rct_window *w; __asm mov x, ax __asm mov y, bx __asm mov widgetIndex, dx __asm mov w, esi - RCT2_CALLPROC_X(0x006681E6, x, y, 0, widgetIndex, w, 0, 0); + RCT2_CALLPROC_X(0x006681E6, x, y, 0, widgetIndex, (int)w, 0, 0); } /** @@ -838,14 +838,14 @@ static void window_park_entrance_tooldown() static void window_park_entrance_tooldrag() { short x, y, widgetIndex; - rct_window *w, *mainWindow; + rct_window *w; __asm mov x, ax __asm mov y, bx __asm mov widgetIndex, dx __asm mov w, esi - RCT2_CALLPROC_X(0x006681FB, x, y, 0, widgetIndex, w, 0, 0); + RCT2_CALLPROC_X(0x006681FB, x, y, 0, widgetIndex, (int)w, 0, 0); } /** @@ -855,7 +855,7 @@ static void window_park_entrance_tooldrag() static void window_park_entrance_toolabort() { short widgetIndex; - rct_window *w, *mainWindow; + rct_window *w; __asm mov widgetIndex, dx __asm mov w, esi @@ -952,7 +952,6 @@ static void window_park_entrance_invalidate() */ static void window_park_entrance_paint() { - int i, x, y; rct_window *w; rct_drawpixelinfo *dpi; rct_widget *labelWidget; @@ -977,7 +976,7 @@ static void window_park_entrance_paint() gfx_draw_string_centred_clipped( dpi, 1191, - 0x013CE952, + (void*)0x013CE952, 0, w->x + (labelWidget->left + labelWidget->right) / 2, w->y + labelWidget->top, @@ -1025,7 +1024,7 @@ static void window_park_init_viewport(rct_window *w) } // Call invalidate event - RCT2_CALLPROC_X(w->event_handlers[WE_INVALIDATE], 0, 0, 0, 0, w, 0, 0); + RCT2_CALLPROC_X(w->event_handlers[WE_INVALIDATE], 0, 0, 0, 0, (int)w, 0, 0); w->var_482 = x; w->var_484 = y; @@ -1108,7 +1107,7 @@ void window_park_rating_open() window->widgets = window_park_rating_widgets; window->enabled_widgets = window_park_page_enabled_widgets[WINDOW_PARK_PAGE_RATING]; window->var_020 = 0; - window->event_handlers = window_park_rating_events; + window->event_handlers = (uint32*)window_park_rating_events; window_init_scroll_widgets(window); } @@ -1163,9 +1162,8 @@ static void window_park_rating_update() */ static void window_park_rating_invalidate() { - int i; rct_window *w; - rct_widget **widgets; + rct_widget *widgets; __asm mov w, esi @@ -1207,7 +1205,7 @@ static void window_park_rating_paint() widget = &window_park_rating_widgets[WIDX_PAGE_BACKGROUND]; // Current value - gfx_draw_string_left(dpi, STR_PARK_RATING_LABEL, RCT2_ADDRESS_CURRENT_PARK_RATING, 0, x + widget->left + 3, y + widget->top + 2); + gfx_draw_string_left(dpi, STR_PARK_RATING_LABEL, (void*)RCT2_ADDRESS_CURRENT_PARK_RATING, 0, x + widget->left + 3, y + widget->top + 2); // Graph border gfx_fill_rect_inset(dpi, x + widget->left + 4, y + widget->top + 15, x + widget->right - 4, y + widget->bottom - 4, w->colours[1], 0x30); @@ -1251,7 +1249,7 @@ void window_park_guests_open() window->widgets = window_park_guests_widgets; window->enabled_widgets = window_park_page_enabled_widgets[WINDOW_PARK_PAGE_GUESTS]; window->var_020 = 0; - window->event_handlers = window_park_guests_events; + window->event_handlers = (uint32*)window_park_guests_events; window_init_scroll_widgets(window); } @@ -1307,9 +1305,8 @@ static void window_park_guests_update() */ static void window_park_guests_invalidate() { - int i; rct_window *w; - rct_widget **widgets; + rct_widget *widgets; __asm mov w, esi @@ -1351,7 +1348,7 @@ static void window_park_guests_paint() widget = &window_park_guests_widgets[WIDX_PAGE_BACKGROUND]; // Current value - gfx_draw_string_left(dpi, STR_GUESTS_IN_PARK_LABEL, RCT2_ADDRESS_GUESTS_IN_PARK, 0, x + widget->left + 3, y + widget->top + 2); + gfx_draw_string_left(dpi, STR_GUESTS_IN_PARK_LABEL, (void*)RCT2_ADDRESS_GUESTS_IN_PARK, 0, x + widget->left + 3, y + widget->top + 2); // Graph border gfx_fill_rect_inset(dpi, x + widget->left + 4, y + widget->top + 15, x + widget->right - 4, y + widget->bottom - 4, w->colours[1], 0x30); @@ -1458,9 +1455,8 @@ static void window_park_price_update() */ static void window_park_price_invalidate() { - int i; rct_window *w; - rct_widget **widgets; + rct_widget *widgets; __asm mov w, esi @@ -1511,9 +1507,9 @@ static void window_park_price_paint() x = w->x + window_park_price_widgets[WIDX_PAGE_BACKGROUND].left + 4; y = w->y + window_park_price_widgets[WIDX_PAGE_BACKGROUND].top + 30; - gfx_draw_string_left(dpi, STR_TOTAL_ADMISSIONS, RCT2_ADDRESS_TOTAL_ADMISSIONS, 0, x, y); + gfx_draw_string_left(dpi, STR_TOTAL_ADMISSIONS, (void*)RCT2_ADDRESS_TOTAL_ADMISSIONS, 0, x, y); y += 10; - gfx_draw_string_left(dpi, STR_INCOME_FROM_ADMISSIONS, RCT2_ADDRESS_INCOME_FROM_ADMISSIONS, 0, x, y); + gfx_draw_string_left(dpi, STR_INCOME_FROM_ADMISSIONS, (void*)RCT2_ADDRESS_INCOME_FROM_ADMISSIONS, 0, x, y); } #pragma endregion @@ -1586,9 +1582,8 @@ static void window_park_stats_update() */ static void window_park_stats_invalidate() { - int i; rct_window *w; - rct_widget **widgets; + rct_widget *widgets; __asm mov w, esi @@ -1616,7 +1611,6 @@ static void window_park_stats_paint() int x, y, parkSize, stringIndex; rct_window *w; rct_drawpixelinfo *dpi; - rct_award *award; __asm mov w, esi __asm mov dpi, edi @@ -1635,25 +1629,25 @@ static void window_park_stats_paint() parkSize = squaredmetres_to_squaredfeet(parkSize); } RCT2_GLOBAL(0x013CE952, uint32) = parkSize; - gfx_draw_string_left(dpi, stringIndex, 0x013CE952, 0, x, y); + gfx_draw_string_left(dpi, stringIndex, (void*)0x013CE952, 0, x, y); y += 10; // Draw number of rides / attractions if (w->var_490 != -1) { RCT2_GLOBAL(0x013CE952, uint32) = w->var_490; - gfx_draw_string_left(dpi, STR_NUMBER_OF_RIDES_LABEL, 0x013CE952, 0, x, y); + gfx_draw_string_left(dpi, STR_NUMBER_OF_RIDES_LABEL, (void*)0x013CE952, 0, x, y); } y += 10; // Draw number of staff if (w->var_48C != -1) { RCT2_GLOBAL(0x013CE952, uint32) = w->var_48C; - gfx_draw_string_left(dpi, STR_STAFF_LABEL, 0x013CE952, 0, x, y); + gfx_draw_string_left(dpi, STR_STAFF_LABEL, (void*)0x013CE952, 0, x, y); } y += 10; // Draw number of guests in park - gfx_draw_string_left(dpi, STR_GUESTS_IN_PARK_LABEL, RCT2_ADDRESS_GUESTS_IN_PARK, 0, x, y); + gfx_draw_string_left(dpi, STR_GUESTS_IN_PARK_LABEL, (void*)RCT2_ADDRESS_GUESTS_IN_PARK, 0, x, y); } #pragma endregion @@ -1685,7 +1679,7 @@ void window_park_objective_open() window->widgets = window_park_objective_widgets; window->enabled_widgets = window_park_page_enabled_widgets[WINDOW_PARK_PAGE_OBJECTIVE]; window->var_020 = 0; - window->event_handlers = window_park_objective_events; + window->event_handlers = (uint32*)window_park_objective_events; window_init_scroll_widgets(window); window->x = RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, sint16) / 2 - 115; window->y = RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, sint16) / 2 - 87; @@ -1698,7 +1692,6 @@ void window_park_objective_open() */ static void window_park_objective_mouseup() { - int tabIndex; short widgetIndex; rct_window *w; @@ -1757,7 +1750,6 @@ static void window_park_objective_update() */ static void window_park_objective_invalidate() { - int i; rct_window *w; __asm mov w, esi @@ -1765,8 +1757,8 @@ static void window_park_objective_invalidate() window_park_set_pressed_tab(w); // Set window title arguments - *((short*)0x013CE952) = RCT2_GLOBAL(0x013573D4, uint16); - *((short*)0x013CE954) = RCT2_GLOBAL(0x013573D8, uint32); + *((uint16*)0x013CE952) = RCT2_GLOBAL(0x013573D4, uint16); + *((uint32*)0x013CE954) = RCT2_GLOBAL(0x013573D8, uint32); // if (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & 0x02) @@ -1784,7 +1776,7 @@ static void window_park_objective_invalidate() */ static void window_park_objective_paint() { - int i, x, y; + int x, y; rct_window *w; rct_drawpixelinfo *dpi; @@ -1856,7 +1848,7 @@ void window_park_awards_open() window->widgets = window_park_awards_widgets; window->enabled_widgets = window_park_page_enabled_widgets[WINDOW_PARK_PAGE_AWARDS]; window->var_020 = 0; - window->event_handlers = window_park_awards_events; + window->event_handlers = (uint32*)window_park_awards_events; window_init_scroll_widgets(window); } @@ -1911,9 +1903,8 @@ static void window_park_awards_update() */ static void window_park_awards_invalidate() { - int i; rct_window *w; - rct_widget **widgets; + rct_widget *widgets; __asm mov w, esi @@ -1959,7 +1950,7 @@ static void window_park_awards_paint() continue; gfx_draw_sprite(dpi, SPR_AWARD_MOST_UNTIDY + award->type, x, y); - gfx_draw_string_left_wrapped(dpi, STR_AWARD_MOST_UNTIDY, x + 34, y + 6, 180, 0, 0); + gfx_draw_string_left_wrapped(dpi, (void*)STR_AWARD_MOST_UNTIDY, x + 34, y + 6, 180, 0, 0); y += 32; count++; @@ -2002,11 +1993,11 @@ static void window_park_set_page(rct_window *w, int page) w->var_020 = RCT2_GLOBAL(0x0097BAE0 + (page * 4), uint32); w->event_handlers = window_park_page_events[page]; w->widgets = window_park_page_widgets[page]; - RCT2_CALLPROC_X(0x00667F8B, 0, 0, 0, 0, w, 0, 0); + RCT2_CALLPROC_X(0x00667F8B, 0, 0, 0, 0, (int)w, 0, 0); window_invalidate(w); - RCT2_CALLPROC_X(w->event_handlers[WE_RESIZE], 0, 0, 0, 0, w, 0, 0); - RCT2_CALLPROC_X(w->event_handlers[WE_INVALIDATE], 0, 0, 0, 0, w, 0, 0); + RCT2_CALLPROC_X(w->event_handlers[WE_RESIZE], 0, 0, 0, 0, (int)w, 0, 0); + RCT2_CALLPROC_X(w->event_handlers[WE_INVALIDATE], 0, 0, 0, 0, (int)w, 0, 0); if (listen != 0 && w->viewport != NULL) w->viewport->flags |= VIEWPORT_FLAG_SOUND_ON; } @@ -2029,7 +2020,7 @@ static void window_park_align_tabs(rct_window *w) x = w->widgets[WIDX_TAB_1].left; tab_width = w->widgets[WIDX_TAB_1].right - w->widgets[WIDX_TAB_1].left; for (i = 0; i < 7; i++) { - if (w->disabled_widgets & (1 << (WIDX_TAB_1 + i))) + if (w->disabled_widgets & (1LL << (WIDX_TAB_1 + i))) continue; w->widgets[WIDX_TAB_1 + i].left = x; w->widgets[WIDX_TAB_1 + i].right = x + tab_width; @@ -2042,7 +2033,7 @@ static void window_park_set_pressed_tab(rct_window *w) int i; for (i = 0; i < 7; i++) w->pressed_widgets &= ~(1 << (WIDX_TAB_1 + i)); - w->pressed_widgets |= 1 << (WIDX_TAB_1 + w->page); + w->pressed_widgets |= 1LL << (WIDX_TAB_1 + w->page); } static void window_park_draw_tab_images(rct_drawpixelinfo *dpi, rct_window *w) @@ -2125,7 +2116,7 @@ static void window_park_graph_draw_months(rct_drawpixelinfo *dpi, uint8 *history if (history[i] != 0 && history[i] != 255 && yearOver32 % 4 == 0) { // Draw month text RCT2_GLOBAL(0x013CE952, uint32) = ((yearOver32 / 4) + 8) % 8 + STR_MONTH_SHORT_MAR; - gfx_draw_string_centred(dpi, 2222, x, y - 10, 0, 0x013CE952); + gfx_draw_string_centred(dpi, 2222, x, y - 10, 0, (void*)0x013CE952); // Draw month mark gfx_fill_rect(dpi, x, y, x, y + 3, 10); diff --git a/src/window_ride_list.c b/src/window_ride_list.c index 390261673b..f7e877ef3d 100644 --- a/src/window_ride_list.c +++ b/src/window_ride_list.c @@ -79,7 +79,7 @@ static void window_ride_list_invalidate(); static void window_ride_list_paint(); static void window_ride_list_scrollpaint(); -static uint32 window_ride_list_events[] = { +static void* window_ride_list_events[] = { window_ride_list_emptysub, window_ride_list_mouseup, window_ride_list_resize, @@ -140,7 +140,7 @@ void window_ride_list_open() // Check if window is already open window = window_bring_to_front_by_id(WC_RIDE_LIST, 0); if (window == NULL) { - window = window_create_auto_pos(340, 240, window_ride_list_events, WC_RIDE_LIST, 0x0400); + window = window_create_auto_pos(340, 240, (uint32*)window_ride_list_events, WC_RIDE_LIST, 0x0400); window->widgets = window_ride_list_widgets; window->enabled_widgets = (1 << WIDX_CLOSE) | @@ -175,7 +175,6 @@ void window_ride_list_open() */ static void window_ride_list_mouseup() { - int i; short widgetIndex; rct_window *w; @@ -273,10 +272,8 @@ static void window_ride_list_mousedown() */ static void window_ride_list_dropdown() { - int i; short dropdownIndex, widgetIndex; rct_window *w; - rct_ride *ride; __asm mov dropdownIndex, ax __asm mov widgetIndex, dx @@ -291,7 +288,7 @@ static void window_ride_list_dropdown() if (dropdownIndex == -1) return; - _window_ride_list_information_type = gDropdownItemsArgs[dropdownIndex] - STR_STATUS; + _window_ride_list_information_type = *((uint32*)&gDropdownItemsArgs[dropdownIndex]) - STR_STATUS; window_invalidate(w); } } @@ -398,7 +395,7 @@ static void window_ride_list_tooltip() */ static void window_ride_list_invalidate() { - int i, x, y; + int i; rct_window *w; __asm mov w, esi @@ -408,7 +405,7 @@ static void window_ride_list_invalidate() // Set correct active tab for (i = 0; i < 3; i++) w->pressed_widgets &= ~(1 << (WIDX_TAB_1 + i)); - w->pressed_widgets |= 1 << (WIDX_TAB_1 + w->page); + w->pressed_widgets |= 1LL << (WIDX_TAB_1 + w->page); window_ride_list_widgets[WIDX_TITLE].image = STR_RIDES + w->page; @@ -554,7 +551,7 @@ static void window_ride_list_scrollpaint() format = 1192; RCT2_GLOBAL(0x013CE952, uint16) = formatSecondary; - gfx_draw_string_left_clipped(dpi, format, 0x013CE952, 0, 160, y - 1, 157); + gfx_draw_string_left_clipped(dpi, format, (void*)0x013CE952, 0, 160, y - 1, 157); y += 10; } } @@ -593,7 +590,7 @@ static void window_ride_list_draw_tab_images(rct_drawpixelinfo *dpi, rct_window static void window_ride_list_refresh_list(rct_window *w) { int i, j, k, countA, countB; - sint16 swapper; + uint8 swapper; rct_ride *ride, *otherRide; countA = countB = 0; @@ -636,7 +633,7 @@ static void window_ride_list_refresh_list(rct_window *w) otherRide = &(RCT2_ADDRESS(RCT2_ADDRESS_RIDE_LIST, rct_ride)[w->var_076[k]]); RCT2_GLOBAL(0x013CE952, uint32) = otherRide->var_04C; RCT2_CALLPROC_X(0x006C2538, otherRide->var_04A, 0, 0x013CE952, 0, 0, 0x0141EF68, 0); - if (strcmp(0x0141ED68, 0x0141EF68) >= 0) + if (strcmp((char*)0x0141ED68, (char*)0x0141EF68) >= 0) break; swapper = w->var_076[k]; diff --git a/src/window_save_prompt.c b/src/window_save_prompt.c index 3978cc1154..a0a06597fd 100644 --- a/src/window_save_prompt.c +++ b/src/window_save_prompt.c @@ -54,7 +54,7 @@ static void window_save_prompt_close(); static void window_save_prompt_mouseup(); static void window_save_prompt_paint(); -static uint32 window_save_prompt_events[] = { +static void* window_save_prompt_events[] = { window_save_prompt_close, window_save_prompt_mouseup, window_save_prompt_emptysub, @@ -102,7 +102,7 @@ void window_save_prompt_open() max(28, (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, sint16) / 2) - 25), 260, 50, - window_save_prompt_events, + (uint32*)window_save_prompt_events, WC_SAVE_PROMPT, 0 ); diff --git a/src/window_title_exit.c b/src/window_title_exit.c index 1eaa52b6a8..780e4cf3b4 100644 --- a/src/window_title_exit.c +++ b/src/window_title_exit.c @@ -34,7 +34,7 @@ static void window_title_exit_emptysub() {} static void window_title_exit_paint(); static void window_title_exit_mouseup(); -static uint32 window_title_exit_events[] = { +static void* window_title_exit_events[] = { window_title_exit_emptysub, window_title_exit_mouseup, window_title_exit_emptysub, @@ -76,7 +76,7 @@ void window_title_exit_open() window = window_create( RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, sint16) - 40, RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, sint16) - 64, 40, 64, - window_title_exit_events, + (uint32*)window_title_exit_events, WC_TITLE_EXIT, WF_STICK_TO_FRONT ); diff --git a/src/window_title_logo.c b/src/window_title_logo.c index a81ec804b1..f30a66cea4 100644 --- a/src/window_title_logo.c +++ b/src/window_title_logo.c @@ -32,7 +32,7 @@ static rct_widget window_title_logo_widgets[] = { static void window_title_logo_emptysub() {} static void window_title_logo_paint(); -static uint32 window_title_logo_events[] = { +static void* window_title_logo_events[] = { window_title_logo_emptysub, window_title_logo_emptysub, window_title_logo_emptysub, @@ -79,8 +79,8 @@ void window_title_logo_open() packs++; // Create the window - window = window_create(0, 0, 200, 106 + (10 * packs), window_title_logo_events, WC_TITLE_LOGO, WF_STICK_TO_FRONT); - window->widgets = 0x009A9658; // mouse move bug in original game, keep this address and no crash happens + window = window_create(0, 0, 200, 106 + (10 * packs), (uint32*)window_title_logo_events, WC_TITLE_LOGO, WF_STICK_TO_FRONT); + window->widgets = (rct_widget*)0x009A9658; // mouse move bug in original game, keep this address and no crash happens window_init_scroll_widgets(window); window->flags |= 16; window->colours[0] = 129; diff --git a/src/window_title_menu.c b/src/window_title_menu.c index f34c875127..e139ce8397 100644 --- a/src/window_title_menu.c +++ b/src/window_title_menu.c @@ -50,7 +50,7 @@ static void window_title_menu_dropdown(); static void window_title_menu_unknown17(); static void window_title_menu_paint(); -static uint32 window_title_menu_events[] = { +static void* window_title_menu_events[] = { window_title_menu_emptysub, window_title_menu_mouseup, window_title_menu_emptysub, @@ -92,7 +92,7 @@ void window_title_menu_open() window = window_create( (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, sint16) - 328) / 2, RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, sint16) - 142, 328, 82, - window_title_menu_events, + (uint32*)window_title_menu_events, WC_TITLE_MENU, WF_STICK_TO_FRONT ); diff --git a/src/window_title_scenarioselect.c b/src/window_title_scenarioselect.c index 00556c1ee2..70bb883045 100644 --- a/src/window_title_scenarioselect.c +++ b/src/window_title_scenarioselect.c @@ -66,7 +66,7 @@ static void window_scenarioselect_invalidate(); static void window_scenarioselect_paint(); static void window_scenarioselect_scrollpaint(); -static uint32 window_scenarioselect_events[] = { +static void* window_scenarioselect_events[] = { window_scenarioselect_emptysub, window_scenarioselect_mouseup, window_scenarioselect_emptysub, @@ -116,7 +116,7 @@ void window_scenarioselect_open() max(28, (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, sint16) / 2) - 167), 610, 334, - window_scenarioselect_events, + (uint32*)window_scenarioselect_events, WC_SCENARIO_SELECT, WF_STICK_TO_FRONT | WF_10 ); @@ -128,7 +128,7 @@ void window_scenarioselect_open() window->colours[1] = 26; window->colours[2] = 26; window->var_480 = -1; - window->var_494 = NULL; + window->var_494 = 0; window_scenarioselect_init_tabs(); @@ -189,10 +189,10 @@ static void window_scenarioselect_mousedown() if (widgetIndex >= WIDX_TAB1 && widgetIndex <= WIDX_TAB5) { w->var_4AC = widgetIndex - 4; - w->var_494 = NULL; + w->var_494 = 0; window_invalidate(w); - RCT2_CALLPROC_X(w->event_handlers[WE_RESIZE], 0, 0, 0, 0, w, 0, 0); - RCT2_CALLPROC_X(w->event_handlers[WE_INVALIDATE], 0, 0, 0, 0, w, 0, 0); + RCT2_CALLPROC_X(w->event_handlers[WE_RESIZE], 0, 0, 0, 0, (int)w, 0, 0); + RCT2_CALLPROC_X(w->event_handlers[WE_INVALIDATE], 0, 0, 0, 0, (int)w, 0, 0); window_init_scroll_widgets(w); window_invalidate(w); } @@ -273,8 +273,8 @@ static void window_scenarioselect_scrollmouseover() selected = scenario; break; } - if (w->var_494 != selected) { - w->var_494 = selected; + if (w->var_494 != (uint32)selected) { + w->var_494 = (uint32)selected; window_invalidate(w); } } @@ -286,7 +286,7 @@ static void window_scenarioselect_invalidate() __asm mov w, esi w->pressed_widgets &= ~(0x10 | 0x20 | 0x40 | 0x80 | 0x100); - w->pressed_widgets |= 1 << (w->var_4AC + 4); + w->pressed_widgets |= 1LL << (w->var_4AC + 4); } static void window_scenarioselect_paint() @@ -326,13 +326,13 @@ static void window_scenarioselect_paint() // Scenario name x = w->x + window_scenarioselect_widgets[WIDX_SCENARIOLIST].right + 4; y = w->y + window_scenarioselect_widgets[WIDX_TABCONTENT].top + 5; - strcpy(0x009BC677, scenario->name); + strcpy((char*)0x009BC677, scenario->name); *((short*)(0x0013CE952 + 0)) = 3165; gfx_draw_string_centred_clipped(dpi, 1193, (void*)0x013CE952, 0, x + 85, y, 170); y += 15; // Scenario details - strcpy(0x009BC677, scenario->details); + strcpy((char*)0x009BC677, scenario->details); *((short*)(0x0013CE952 + 0)) = 3165; y += gfx_draw_string_left_wrapped(dpi, (void*)0x013CE952, x, y, 170, 1191, 0) + 5; @@ -345,7 +345,7 @@ static void window_scenarioselect_paint() // Scenario score if (scenario->flags & SCENARIO_FLAGS_COMPLETED) { - strcpy(0x009BC677, scenario->completed_by); + strcpy((char*)0x009BC677, scenario->completed_by); *((short*)(0x0013CE952 + 0)) = 3165; *((int*)(0x0013CE952 + 2)) = scenario->company_value; y += gfx_draw_string_left_wrapped(dpi, (void*)0x013CE952, x, y, 170, STR_COMPLETED_BY_WITH_COMPANY_VALUE, 0); diff --git a/src/window_tooltip.c b/src/window_tooltip.c index bc13d6fbd1..95312aea2f 100644 --- a/src/window_tooltip.c +++ b/src/window_tooltip.c @@ -38,7 +38,7 @@ static void window_tooltip_onclose(); static void window_tooltip_update(); static void window_tooltip_paint(); -static uint32 window_tooltip_events[] = { +static void* window_tooltip_events[] = { window_tooltip_onclose, window_tooltip_emptysub, window_tooltip_emptysub, @@ -93,7 +93,7 @@ void window_tooltip_open(rct_window *widgetWindow, int widgetIndex, int x, int y return; widget = &widgetWindow->widgets[widgetIndex]; - RCT2_CALLPROC_X(widgetWindow->event_handlers[WE_INVALIDATE], 0, 0, 0, 0, widgetWindow, 0, 0); + RCT2_CALLPROC_X(widgetWindow->event_handlers[WE_INVALIDATE], 0, 0, 0, 0, (int)widgetWindow, 0, 0); if (widget->tooltip == 0xFFFF) return; @@ -103,7 +103,7 @@ void window_tooltip_open(rct_window *widgetWindow, int widgetIndex, int x, int y int eax, ebx, ecx, edx, esi, edi, ebp; eax = widgetIndex; - esi = widgetWindow; + esi = (int)widgetWindow; RCT2_CALLFUNC_X(widgetWindow->event_handlers[WE_TOOLTIP], &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); if ((eax & 0xFFFF) == 0xFFFF) return; @@ -114,7 +114,7 @@ void window_tooltip_open(rct_window *widgetWindow, int widgetIndex, int x, int y RCT2_GLOBAL(0x0142006C, sint32) = -1; - format_string(0x0141ED68, widget->tooltip, 0x013CE952); + format_string((char*)0x0141ED68, widget->tooltip, (void*)0x013CE952); RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, uint16) = 224; esi = 0x0141ED68; @@ -136,12 +136,12 @@ void window_tooltip_open(rct_window *widgetWindow, int widgetIndex, int x, int y window_tooltip_widgets[WIDX_BACKGROUND].right = width; window_tooltip_widgets[WIDX_BACKGROUND].bottom = height; - memcpy(0x0141FE44, 0x0141ED68, 512); + memcpy((void*)0x0141FE44, (void*)0x0141ED68, 512); x = clamp(0, x - (width / 2), RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, uint16) - width); y = clamp(22, y + 26, RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, uint16) - height - 40); - w = window_create(x, y, width, height, window_tooltip_events, WC_TOOLTIP, WF_TRANSPARENT | WF_STICK_TO_FRONT); + w = window_create(x, y, width, height, (uint32*)window_tooltip_events, WC_TOOLTIP, WF_TRANSPARENT | WF_STICK_TO_FRONT); w->widgets = window_tooltip_widgets; RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_NOT_SHOWN_TICKS, uint16) = 0; @@ -213,5 +213,5 @@ static void window_tooltip_paint() gfx_draw_pixel(dpi, right - 1, bottom - 1, 0x0200002F); // Text - RCT2_CALLPROC_X(0x006C1DB7, 0, 0, w->x + ((w->width + 1) / 2) - 1, w->y + 1, 0x0141FE44, dpi, RCT2_GLOBAL(0x01420044, uint16)); + RCT2_CALLPROC_X(0x006C1DB7, 0, 0, w->x + ((w->width + 1) / 2) - 1, w->y + 1, 0x0141FE44, (int)dpi, RCT2_GLOBAL(0x01420044, uint16)); } \ No newline at end of file diff --git a/src/window_water.c b/src/window_water.c index 1e91cbf5b5..0c22ddabae 100644 --- a/src/window_water.c +++ b/src/window_water.c @@ -53,7 +53,7 @@ static void window_water_update(); static void window_water_invalidate(); static void window_water_paint(); -static uint32 window_water_events[] = { +static void* window_water_events[] = { window_water_close, window_water_mouseup, window_water_emptysub, @@ -96,7 +96,7 @@ void window_water_open() if (window_find_by_id(WC_WATER, 0) != NULL) return; - window = window_create(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, sint16) - 76, 29, 76, 77, window_water_events, WC_WATER, 0); + window = window_create(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, sint16) - 76, 29, 76, 77, (uint32*)window_water_events, WC_WATER, 0); window->widgets = window_water_widgets; window->enabled_widgets = 0x04 | 0x10 | 0x20; window_init_scroll_widgets(window);