From 4459d127d00d7b5ca4785a13a4d3489e953cdeef Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Wed, 19 Nov 2014 21:46:32 +0000 Subject: [PATCH] Found cause of crash. Game will enter hybrid state when failed to load. --- src/game.c | 13 +++++++------ src/object_list.c | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/game.c b/src/game.c index 4a0a92fa08..cc188a1fb2 100644 --- a/src/game.c +++ b/src/game.c @@ -648,12 +648,7 @@ int game_load_save(const char *path) } } - 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; - }; + uint8 load_success = object_read_and_load_entries(file); // Read flags (16 bytes) sawyercoding_read_chunk(file, (uint8*)RCT2_ADDRESS_CURRENT_MONTH_YEAR); @@ -670,6 +665,12 @@ int game_load_save(const char *path) // Check expansion pack // RCT2_CALLPROC_EBPSAFE(0x006757E6); + if (!load_success){ + RCT2_CALLPROC_X(0x675827, 0, 0, 0, 0, 0, 0, 0); + RCT2_CALLPROC_X(0x66DC83, 0, 0, 0, 0, 0, 0, 0); + return; + } + // The rest is the same as in scenario load and play RCT2_CALLPROC_EBPSAFE(0x006A9FC0); map_update_tile_pointers(); diff --git a/src/object_list.c b/src/object_list.c index 4ddcf45712..6120d9e57b 100644 --- a/src/object_list.c +++ b/src/object_list.c @@ -202,7 +202,7 @@ int object_read_and_load_entries(FILE *file) // Failed to load the object //Destroy progress bar - memcpy((char*)0x13CE952, entries[i].name, 8); + memcpy((char*)0x13CE952, &entries[i], sizeof(rct_object_entry)); free(entries); object_unload_all(); RCT2_GLOBAL(0x14241BC, uint32) = 0;