diff --git a/src/addresses.h b/src/addresses.h index e55b0cee86..55cd3f585d 100644 --- a/src/addresses.h +++ b/src/addresses.h @@ -126,6 +126,10 @@ #define RCT2_ADDRESS_RUN_INTRO_TICK_PART 0x009AC319 +// 0 = none, 255 = load file, 254 = anything else +#define RCT2_ADDRESS_ERROR_TYPE 0x009AC31B +#define RCT2_ADDRESS_ERROR_STRING_ID 0x009AC31C + #define RCT2_ADDRESS_WINDOW_MAP_FLASHING_FLAGS 0x009AC861 #define RCT2_ADDRESS_RIDE_ENTRIES 0x009ACFA4 @@ -268,6 +272,9 @@ #define RCT2_ADDRESS_SCENARIO_TEXT_TEMP_OBJECT 0x00F42BC8 +// 1 if custom objects installed, 0 otherwise +#define RCT2_ADDRESS_CUSTOM_OBJECTS_INSTALLED 0x00F42BDA + #define RCT2_ADDRESS_VOLUME_ADJUST_ZOOM 0x00F438AC #define RCT2_ADDRESS_STAFF_HIGHLIGHTED_INDEX 0x00F43908 diff --git a/src/editor.c b/src/editor.c index 09e1eb8c76..600eddf059 100644 --- a/src/editor.c +++ b/src/editor.c @@ -588,8 +588,8 @@ static int editor_load_landscape_from_sv4(const char *path) // Open file fp = fopen(path, "rb"); if (fp == NULL) { - RCT2_GLOBAL(0x009AC31B, uint8) = 255; - RCT2_GLOBAL(0x009AC31C, uint16) = 3011; + RCT2_GLOBAL(RCT2_ADDRESS_ERROR_TYPE, uint8) = 255; + RCT2_GLOBAL(RCT2_ADDRESS_ERROR_STRING_ID, uint16) = 3011; return 0; } @@ -615,8 +615,8 @@ static int editor_load_landscape_from_sc4(const char *path) // Open file fp = fopen(path, "rb"); if (fp == NULL) { - RCT2_GLOBAL(0x009AC31B, uint8) = 255; - RCT2_GLOBAL(0x009AC31C, uint16) = 3011; + RCT2_GLOBAL(RCT2_ADDRESS_ERROR_TYPE, uint8) = 255; + RCT2_GLOBAL(RCT2_ADDRESS_ERROR_STRING_ID, uint16) = 3011; return 0; } @@ -759,8 +759,8 @@ static int editor_read_s6(const char *path) if (file != NULL) { if (!sawyercoding_validate_checksum(file)) { fclose(file); - RCT2_GLOBAL(0x009AC31B, uint8) = 255; - RCT2_GLOBAL(0x009AC31C, uint16) = STR_FILE_CONTAINS_INVALID_DATA; + RCT2_GLOBAL(RCT2_ADDRESS_ERROR_TYPE, uint8) = 255; + RCT2_GLOBAL(RCT2_ADDRESS_ERROR_STRING_ID, uint16) = STR_FILE_CONTAINS_INVALID_DATA; log_error("failed to load scenario, invalid checksum"); return 0; @@ -963,8 +963,8 @@ static int editor_read_s6(const char *path) } log_error("failed to find scenario file."); - RCT2_GLOBAL(0x009AC31B, uint8) = 255; - RCT2_GLOBAL(0x009AC31C, uint16) = STR_FILE_CONTAINS_INVALID_DATA; + RCT2_GLOBAL(RCT2_ADDRESS_ERROR_TYPE, uint8) = 255; + RCT2_GLOBAL(RCT2_ADDRESS_ERROR_STRING_ID, uint16) = STR_FILE_CONTAINS_INVALID_DATA; return 0; } diff --git a/src/game.c b/src/game.c index 707af12c5a..dc702c2d7e 100644 --- a/src/game.c +++ b/src/game.c @@ -298,8 +298,6 @@ void game_update() void game_logic_update() { - short stringId, _dx; - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TICKS, sint32)++; RCT2_GLOBAL(RCT2_ADDRESS_SCENARIO_TICKS, sint32)++; RCT2_GLOBAL(0x009DEA66, sint16)++; @@ -329,16 +327,16 @@ void game_logic_update() // Update windows window_dispatch_update_all(); - if (RCT2_GLOBAL(0x009AC31B, uint8) != 0) { - stringId = STR_UNABLE_TO_LOAD_FILE; - _dx = RCT2_GLOBAL(0x009AC31C, uint16); - if (RCT2_GLOBAL(0x009AC31B, uint8) != 254) { - stringId = RCT2_GLOBAL(0x009AC31C, uint16); - _dx = 0xFFFF; + if (RCT2_GLOBAL(RCT2_ADDRESS_ERROR_TYPE, uint8) != 0) { + rct_string_id title_text = STR_UNABLE_TO_LOAD_FILE; + rct_string_id body_text = RCT2_GLOBAL(RCT2_ADDRESS_ERROR_STRING_ID, uint16); + if (RCT2_GLOBAL(RCT2_ADDRESS_ERROR_TYPE, uint8) == 254) { + title_text = RCT2_GLOBAL(RCT2_ADDRESS_ERROR_STRING_ID, uint16); + body_text = 0xFFFF; } - RCT2_GLOBAL(0x009AC31B, uint8) = 0; + RCT2_GLOBAL(RCT2_ADDRESS_ERROR_TYPE, uint8) = 0; - window_error_open(stringId, _dx); + window_error_open(title_text, body_text); } } @@ -601,7 +599,7 @@ int game_load_save(const char *path) if (file == NULL) { log_error("unable to open %s", path); - RCT2_GLOBAL(0x009AC31B, uint8) = 255; + RCT2_GLOBAL(RCT2_ADDRESS_ERROR_TYPE, uint8) = 255; RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_STRING_ID, uint16) = STR_FILE_CONTAINS_INVALID_DATA; return 0; } @@ -611,7 +609,7 @@ int game_load_save(const char *path) log_error("invalid checksum, %s", path); - RCT2_GLOBAL(0x009AC31B, uint8) = 255; + RCT2_GLOBAL(RCT2_ADDRESS_ERROR_TYPE, uint8) = 255; RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_STRING_ID, uint16) = STR_FILE_CONTAINS_INVALID_DATA; return 0; } diff --git a/src/object_list.c b/src/object_list.c index ed9e7f809a..6de10f3a3a 100644 --- a/src/object_list.c +++ b/src/object_list.c @@ -153,10 +153,12 @@ static void object_list_examine() int i; rct_object_entry *object; + RCT2_GLOBAL(RCT2_ADDRESS_CUSTOM_OBJECTS_INSTALLED, uint8) = 0; + object = RCT2_GLOBAL(RCT2_ADDRESS_INSTALLED_OBJECT_LIST, rct_object_entry*); for (i = 0; i < RCT2_GLOBAL(RCT2_ADDRESS_OBJECT_LIST_NO_ITEMS, sint32); i++) { - if (object->flags & 0xF0) - RCT2_GLOBAL(0x00F42BDA, uint8) |= 1; + if (!(object->flags & 0xF0)) + RCT2_GLOBAL(RCT2_ADDRESS_CUSTOM_OBJECTS_INSTALLED, uint8) |= 1; object = object_get_next(object); } @@ -297,7 +299,7 @@ void object_list_load() object_list_cache_save(fileCount, totalFileSize, fileDateModifiedChecksum, current_item_offset); - // + // Reload track list ride_list_item ride_list; ride_list.entry_index = 0xFC; ride_list.type = 0xFC; @@ -402,15 +404,15 @@ void set_load_objects_fail_reason(){ format_string(string_buffer, 3323, 0); //Missing object data, ID: RCT2_CALLPROC_X(0x6AB344, 0, 0, 0, 0, 0, (int)string_buffer, 0x13CE952); - RCT2_GLOBAL(0x9AC31B, uint8) = 0xFF; - RCT2_GLOBAL(0x9AC31C, uint16) = 3165; + RCT2_GLOBAL(RCT2_ADDRESS_ERROR_TYPE, uint8) = 0xFF; + RCT2_GLOBAL(RCT2_ADDRESS_ERROR_STRING_ID, uint16) = 3165; return; } char* exapansion_name = &RCT2_ADDRESS(RCT2_ADDRESS_EXPANSION_NAMES, char)[128 * expansion]; if (*exapansion_name == '\0'){ - RCT2_GLOBAL(0x9AC31B, uint8) = 0xFF; - RCT2_GLOBAL(0x9AC31C, uint16) = 3325; + RCT2_GLOBAL(RCT2_ADDRESS_ERROR_TYPE, uint8) = 0xFF; + RCT2_GLOBAL(RCT2_ADDRESS_ERROR_STRING_ID, uint16) = 3325; return; } @@ -418,8 +420,8 @@ void set_load_objects_fail_reason(){ format_string(string_buffer, 3324, 0); // Requires expansion pack strcat(string_buffer, exapansion_name); - RCT2_GLOBAL(0x9AC31B, uint8) = 0xFF; - RCT2_GLOBAL(0x9AC31C, uint16) = 3165; + RCT2_GLOBAL(RCT2_ADDRESS_ERROR_TYPE, uint8) = 0xFF; + RCT2_GLOBAL(RCT2_ADDRESS_ERROR_STRING_ID, uint16) = 3165; } /** @@ -595,7 +597,9 @@ static uint32 install_object_entry(rct_object_entry* entry, rct_object_entry* in // Chunk size is set to unknown *((sint32*)installed_entry_pointer) = -1; + // No unknown objects set to 0 *(installed_entry_pointer + 4) = 0; + // No theme objects set to 0 *((sint32*)(installed_entry_pointer + 5)) = 0; *((uint16*)(installed_entry_pointer + 9)) = 0; *((uint32*)(installed_entry_pointer + 11)) = 0; diff --git a/src/scenario.c b/src/scenario.c index 65158dbffe..242dfc6b23 100644 --- a/src/scenario.c +++ b/src/scenario.c @@ -82,8 +82,8 @@ int scenario_load_basic(const char *path, rct_s6_header *header, rct_s6_info *in } log_error("invalid scenario, %s", path); - // RCT2_GLOBAL(0x009AC31B, sint8) = -1; - // RCT2_GLOBAL(0x009AC31C, sint16) = 3011; + // RCT2_GLOBAL(RCT2_ADDRESS_ERROR_TYPE, sint8) = -1; + // RCT2_GLOBAL(RCT2_ADDRESS_ERROR_STRING_ID, sint16) = 3011; return 0; } @@ -105,8 +105,8 @@ int scenario_load(const char *path) if (file != NULL) { if (!sawyercoding_validate_checksum(file)) { fclose(file); - RCT2_GLOBAL(0x009AC31B, uint8) = 255; - RCT2_GLOBAL(0x009AC31C, uint16) = STR_FILE_CONTAINS_INVALID_DATA; + RCT2_GLOBAL(RCT2_ADDRESS_ERROR_TYPE, uint8) = 255; + RCT2_GLOBAL(RCT2_ADDRESS_ERROR_STRING_ID, uint16) = STR_FILE_CONTAINS_INVALID_DATA; log_error("failed to load scenario, invalid checksum"); return 0; @@ -182,8 +182,8 @@ int scenario_load(const char *path) } log_error("failed to find scenario file."); - RCT2_GLOBAL(0x009AC31B, uint8) = 255; - RCT2_GLOBAL(0x009AC31C, uint16) = STR_FILE_CONTAINS_INVALID_DATA; + RCT2_GLOBAL(RCT2_ADDRESS_ERROR_TYPE, uint8) = 255; + RCT2_GLOBAL(RCT2_ADDRESS_ERROR_STRING_ID, uint16) = STR_FILE_CONTAINS_INVALID_DATA; return 0; } diff --git a/src/windows/options.c b/src/windows/options.c index 0d959a466b..a7fc5f3934 100644 --- a/src/windows/options.c +++ b/src/windows/options.c @@ -803,7 +803,7 @@ static void window_options_invalidate() w->disabled_widgets |= (1ULL << WIDX_REAL_NAME_CHECKBOX); // save plugin data checkbox: visible or not - if (RCT2_GLOBAL(0x00F42BDA, uint8) == 1) + if (RCT2_GLOBAL(RCT2_ADDRESS_CUSTOM_OBJECTS_INSTALLED, uint8) == 1) window_options_widgets[WIDX_SAVE_PLUGIN_DATA_CHECKBOX].type = WWT_EMPTY; else window_options_widgets[WIDX_SAVE_PLUGIN_DATA_CHECKBOX].type = WWT_CHECKBOX;