mirror of https://github.com/OpenRCT2/OpenRCT2.git
Added some checks on object loading to eventualy fix #225
This commit is contained in:
parent
4d41118be7
commit
ddc047241e
|
@ -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);
|
||||
|
|
20
src/object.c
20
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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue