From 392ff7bfeaba47d2e8aa1924d4600864b8fce872 Mon Sep 17 00:00:00 2001 From: IntelOrca Date: Wed, 11 Feb 2015 22:17:49 +0000 Subject: [PATCH] remove expansion packs from title sequence, closes #752 --- src/platform/osinterface.c | 44 -------------------------------- src/platform/osinterface.h | 10 -------- src/platform/platform.h | 4 +++ src/platform/windows.c | 52 ++++++++++++++++++++++++++++++++++++++ src/rct2.c | 2 ++ src/rct2.h | 10 ++++++++ src/windows/title_logo.c | 19 +++++++------- 7 files changed, 78 insertions(+), 63 deletions(-) diff --git a/src/platform/osinterface.c b/src/platform/osinterface.c index 87c42e018d..36726dab1f 100644 --- a/src/platform/osinterface.c +++ b/src/platform/osinterface.c @@ -558,50 +558,6 @@ void osinterface_free() SDL_Quit(); } -/** - * - * rct2: 0x00407978 - */ -int osinterface_407978(rct2_install_info* install_info, char* source, char* font, uint8 charset) -{ - char subkey[MAX_PATH]; - char subkey2[MAX_PATH]; - strcpy(subkey, "Software\\Infogrames\\"); - strcat(subkey, source); - strcpy(subkey2, "Software\\Fish Technology Group\\"); - strcat(subkey2, source); - LOGFONTA lf; - memset(&lf, 0, sizeof(lf)); - lf.lfCharSet = charset; - lf.lfHeight = 12; - lf.lfWeight = 400; - strcpy(lf.lfFaceName, font); - RCT2_GLOBAL(RCT2_ADDRESS_HFONT, HFONT) = CreateFontIndirectA(&lf); - HKEY hkey; - if (RegOpenKeyA(HKEY_LOCAL_MACHINE, subkey, &hkey) != ERROR_SUCCESS && RegOpenKeyA(HKEY_LOCAL_MACHINE, subkey2, &hkey) != ERROR_SUCCESS) { - return 0; - } else { - DWORD type; - DWORD size = 260; - RegQueryValueExA(hkey, "Title", 0, &type, install_info->title, &size); - size = 260; - RegQueryValueExA(hkey, "Path", 0, &type, install_info->path, &size); - install_info->var_20C = 235960; - size = 4; - RegQueryValueExA(hkey, "InstallLevel", 0, &type, (LPBYTE)&install_info->installlevel, &size); - for (int i = 0; i <= 15; i++) { - char name[100]; - sprintf(name, "AddonPack%d", i); - size = sizeof(install_info->addon[i]); - if (RegQueryValueExA(hkey, name, 0, &type, install_info->addon[i], &size) == ERROR_SUCCESS) { - install_info->addons |= (1 << i); - } - } - RegCloseKey(hkey); - return 1; - } -} - /** * * rct2: 0x00407D80 diff --git a/src/platform/osinterface.h b/src/platform/osinterface.h index 27561cd889..26405d9288 100644 --- a/src/platform/osinterface.h +++ b/src/platform/osinterface.h @@ -69,16 +69,6 @@ typedef struct { int old; } openrct2_cursor; -typedef struct { - uint32 installlevel; - char title[260]; - char path[260]; - uint32 var_20C; - uint8 pad_210[0x100]; - char addon[16][0x80]; - uint32 addons; //0xB10 -} rct2_install_info; - extern openrct2_cursor gCursorState; extern const unsigned char *gKeysState; extern unsigned char *gKeysPressed; diff --git a/src/platform/platform.h b/src/platform/platform.h index 8d8ca037e0..edc385787b 100644 --- a/src/platform/platform.h +++ b/src/platform/platform.h @@ -65,4 +65,8 @@ void platform_get_cursor_position(int *x, int *y); void platform_set_cursor_position(int x, int y); unsigned int platform_get_ticks(); +#ifdef _WIN32 + int windows_get_registry_install_info(rct2_install_info *installInfo, char *source, char *font, uint8 charset); +#endif + #endif \ No newline at end of file diff --git a/src/platform/windows.c b/src/platform/windows.c index a40c6e8bb4..c8f2377e06 100644 --- a/src/platform/windows.c +++ b/src/platform/windows.c @@ -223,6 +223,58 @@ unsigned int platform_get_ticks() return GetTickCount(); } +/** + * + * rct2: 0x00407978 + */ +int windows_get_registry_install_info(rct2_install_info *installInfo, char *source, char *font, uint8 charset) +{ + char subkeyInfogrames[MAX_PATH], subkeyFishTechGroup[MAX_PATH], keyName[100]; + LOGFONTA lf; + HKEY hKey; + DWORD type, size; + + strcpy(subkeyInfogrames, "Software\\Infogrames\\"); + strcat(subkeyInfogrames, source); + strcpy(subkeyFishTechGroup, "Software\\Fish Technology Group\\"); + strcat(subkeyFishTechGroup, source); + + memset(&lf, 0, sizeof(lf)); + lf.lfCharSet = charset; + lf.lfHeight = 12; + lf.lfWeight = 400; + strcpy(lf.lfFaceName, font); + + RCT2_GLOBAL(RCT2_ADDRESS_HFONT, HFONT) = CreateFontIndirectA(&lf); + + if (RegOpenKeyA(HKEY_LOCAL_MACHINE, subkeyInfogrames, &hKey) != ERROR_SUCCESS) + return 0; + + if (RegOpenKeyA(HKEY_LOCAL_MACHINE, subkeyFishTechGroup, &hKey) != ERROR_SUCCESS) + return 0; + + + size = 260; + RegQueryValueExA(hKey, "Title", 0, &type, installInfo->title, &size); + + size = 260; + RegQueryValueExA(hKey, "Path", 0, &type, installInfo->path, &size); + + installInfo->var_20C = 235960; + + size = 4; + RegQueryValueExA(hKey, "InstallLevel", 0, &type, (LPBYTE)&installInfo->installLevel, &size); + for (int i = 0; i <= 15; i++) { + sprintf(keyName, "AddonPack%d", i); + size = sizeof(installInfo->expansionPackNames[i]); + if (RegQueryValueExA(hKey, keyName, 0, &type, installInfo->expansionPackNames[i], &size) == ERROR_SUCCESS) + installInfo->activeExpansionPacks |= (1 << i); + } + + RegCloseKey(hKey); + return 1; +} + /** * http://alter.org.ua/en/docs/win/args/ */ diff --git a/src/rct2.c b/src/rct2.c index 5b6b415fa8..7a8a4234a7 100644 --- a/src/rct2.c +++ b/src/rct2.c @@ -129,6 +129,8 @@ int rct2_init() */ int rct2_init_directories() { + // windows_get_registry_install_info((rct2_install_info*)0x009AA10C, "RollerCoaster Tycoon 2 Setup", "MS Sans Serif", 0); + // check install directory if (!platform_directory_exists(gGeneral_config.game_path)) { log_verbose("install directory does not exist, %s", gGeneral_config.game_path); diff --git a/src/rct2.h b/src/rct2.h index 445fc51a09..0b035a6aea 100644 --- a/src/rct2.h +++ b/src/rct2.h @@ -109,6 +109,16 @@ typedef fixed32_1dp money32; typedef void (EMPTY_ARGS_VOID_POINTER)(); typedef unsigned short rct_string_id; +typedef struct { + uint32 installLevel; + char title[260]; + char path[260]; + uint32 var_20C; + uint8 pad_210[256]; + char expansionPackNames[16][128]; + uint32 activeExpansionPacks; //0xB10 +} rct2_install_info; + enum { // Although this is labeled a flag it actually means when // zero the screen is in playing mode. diff --git a/src/windows/title_logo.c b/src/windows/title_logo.c index 835ab23d67..b76ca5c05a 100644 --- a/src/windows/title_logo.c +++ b/src/windows/title_logo.c @@ -63,6 +63,8 @@ static void* window_title_logo_events[] = { window_title_logo_emptysub }; +static void window_title_logo_draw_expansion_packs(rct_drawpixelinfo *dpi); + /** * Creates the window containing the logo and the expansion packs on the title screen. * rct2: 0x0066B679 (part of 0x0066B3E8) @@ -94,23 +96,26 @@ void window_title_logo_open() */ static void window_title_logo_paint() { - int packs, x, y, i; - char *buffer, *names; rct_window *w; rct_drawpixelinfo *dpi; window_paint_get_registers(w, dpi); gfx_draw_sprite(dpi, SPR_MENU_LOGO, w->x, w->y, 0); + window_title_logo_draw_expansion_packs(dpi); +} + +static void window_title_logo_draw_expansion_packs(rct_drawpixelinfo *dpi) +{ + int packs, x, y, i; + char *buffer, *names; x = 0; y = 105; packs = RCT2_GLOBAL(RCT2_ADDRESS_EXPANSION_FLAGS, uint16); names = RCT2_ADDRESS(RCT2_ADDRESS_EXPANSION_NAMES, char); - buffer = (char*)RCT2_ADDRESS_COMMON_STRING_FORMAT_BUFFER; - while (packs != 0) { if (packs & 1) { // Prefix for expansion name @@ -120,23 +125,19 @@ static void window_title_logo_paint() buffer[3] = '+'; buffer[4] = ' '; - i = 0; - // Copies the expansion name to the buffer, offset by 5 + i = 0; do { buffer[5 + i] = names[i]; i++; } while (names[i - 1] != 0); RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, uint32) = 0; - gfx_draw_string(dpi, buffer, 0, x, y); - y += 10; } packs = packs >> 1; - names += 128; } } \ No newline at end of file