1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-21 05:53:02 +01:00

Merge pull request #806 from duncanspumpkin/fix_object_list

Object List Fix #698
This commit is contained in:
Ted John
2015-02-15 18:15:30 +00:00
2 changed files with 10 additions and 3 deletions

View File

@@ -254,6 +254,7 @@
#define RCT2_ADDRESS_CONSTRUCT_PATH_VALID_DIRECTIONS 0x00F3EF9E
#define RCT2_ADDRESS_OBJECT_LIST_NO_ITEMS 0x00F42B6C
#define RCT2_ADDRESS_ORIGINAL_RCT2_OBJECT_COUNT 0x00F42B70
#define RCT2_ADDRESS_CURR_OBJECT_CHUNK_POINTER 0x00F42BC0

View File

@@ -265,6 +265,7 @@ void object_list_load()
uint32 fileCount = 0;
uint32 current_item_offset = 0;
RCT2_GLOBAL(RCT2_ADDRESS_ORIGINAL_RCT2_OBJECT_COUNT, uint32) = 0;
log_verbose("building cache of available objects...");
@@ -344,6 +345,9 @@ static int object_list_cache_load(int totalFiles, uint64 totalFileSize, int file
if (fread(RCT2_GLOBAL(RCT2_ADDRESS_INSTALLED_OBJECT_LIST, void*), pluginHeader.object_list_size, 1, file) == 1) {
RCT2_GLOBAL(RCT2_ADDRESS_OBJECT_LIST_NO_ITEMS, uint32) = pluginHeader.object_list_no_items;
if (pluginHeader.object_list_no_items != (pluginHeader.total_files & 0xFFFFFF))
log_error("Potential mismatch in file numbers. Possible corrupt file. Consider deleting plugin.dat.");
fclose(file);
sub_6A9FC0();
object_list_examine();
@@ -616,6 +620,7 @@ static uint32 install_object_entry(rct_object_entry* entry, rct_object_entry* in
/** Use object_load_file to fill in missing chunk information **/
int chunk_size;
if (!object_load_file(-1, entry, &chunk_size, installed_entry)){
log_error("Object Load File failed. Potentially corrupt file: %.8s", entry->name);
RCT2_GLOBAL(0x009ADAF4, sint32) = -1;
RCT2_GLOBAL(0x009ADAFD, uint8) = 0;
RCT2_GLOBAL(RCT2_ADDRESS_OBJECT_LIST_NO_ITEMS, uint32)--;
@@ -629,9 +634,10 @@ static uint32 install_object_entry(rct_object_entry* entry, rct_object_entry* in
RCT2_GLOBAL(0x009ADAFD, uint8) = 0;
if ((entry->flags & 0xF0) == 0x80) {
RCT2_GLOBAL(0x00F42B70, uint32)++;
if (RCT2_GLOBAL(0x00F42B70, uint32) > 772){
RCT2_GLOBAL(0x00F42B70, uint32)--;
RCT2_GLOBAL(RCT2_ADDRESS_ORIGINAL_RCT2_OBJECT_COUNT, uint32)++;
if (RCT2_GLOBAL(RCT2_ADDRESS_ORIGINAL_RCT2_OBJECT_COUNT, uint32) > 772){
log_error("Incorrect number of vanilla RCT2 objects.");
RCT2_GLOBAL(RCT2_ADDRESS_ORIGINAL_RCT2_OBJECT_COUNT, uint32)--;
RCT2_GLOBAL(RCT2_ADDRESS_OBJECT_LIST_NO_ITEMS, uint32)--;
object_unload(objectType, (rct_object_entry_extended*)entry);
return 0;