diff --git a/src/game.c b/src/game.c index a0d310d434..68f5448448 100644 --- a/src/game.c +++ b/src/game.c @@ -732,7 +732,12 @@ int game_load_save() } } - object_read_and_load_entries(file); + if (!object_read_and_load_entries(file)){ + fclose(file); + RCT2_GLOBAL(0x009AC31B, uint8) = 255; + RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_STRING_ID, uint16) = STR_FILE_CONTAINS_INVALID_DATA; + return 0; + }; // Read flags (16 bytes) sawyercoding_read_chunk(file, (uint8*)RCT2_ADDRESS_CURRENT_MONTH_YEAR); diff --git a/src/object.c b/src/object.c index 1df31a9b79..24798d7fdb 100644 --- a/src/object.c +++ b/src/object.c @@ -30,15 +30,7 @@ */ int object_load(int groupIndex, rct_object_entry *entry) { - RCT2_CALLPROC_X(0x006A985D, 0, 0, groupIndex, 0, 0, 0, (int)entry); - #ifdef _MSC_VER - __asm jb fail - #else - __asm__ goto ( "jb %l0" : : : : fail ); - #endif - return 1; -fail: - return 0; + return !(RCT2_CALLPROC_X(0x006A985D, 0, 0, groupIndex, 0, 0, 0, (int)entry) & 0x100); } /** @@ -122,15 +114,7 @@ int object_paint(int type, int eax, int ebx, int ecx, int edx, int esi, int edi, if (type == 10){ if (eax == 0) return object_scenario_load_custom_text((char*)esi); } - RCT2_CALLPROC_X(RCT2_ADDRESS(0x0098D9D4, uint32)[type], eax, ebx, ecx, edx, esi, edi, ebp); - #ifdef _MSC_VER - __asm jb success - #else - __asm__ goto ( "jb %l0" : : : : success ); - #endif - return 0; -success: - return 1; + return RCT2_CALLPROC_X(RCT2_ADDRESS(0x0098D9D4, uint32)[type], eax, ebx, ecx, edx, esi, edi, ebp) & 0x400; } /** diff --git a/src/object.h b/src/object.h index a9d8bdbdfc..04e14eb220 100644 --- a/src/object.h +++ b/src/object.h @@ -46,7 +46,7 @@ typedef struct { } rct_object_entry_extended; void object_list_load(); -void object_read_and_load_entries(FILE *file); +int object_read_and_load_entries(FILE *file); int object_load_packed(); void object_unload_all(); diff --git a/src/object_list.c b/src/object_list.c index 78d5686d07..9765363808 100644 --- a/src/object_list.c +++ b/src/object_list.c @@ -157,7 +157,7 @@ static int check_object_entry(rct_object_entry *entry) * * rct2: 0x006AA0C6 */ -void object_read_and_load_entries(FILE *file) +int object_read_and_load_entries(FILE *file) { object_unload_all(); @@ -185,13 +185,14 @@ void object_read_and_load_entries(FILE *file) if (!object_load(entryGroupIndex, &entries[i])) { // Failed to load the object free(entries); - + memcpy((char*)0x13CE952, entries[i].name, 8); object_unload_all(); - return; + return 0; } } free(entries); + return 1; } /**