1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-18 04:23:20 +01:00

Fix #2320: Game crash after opening the inventions list

When loading saved games, fix research items that point to invalid entries.
This commit is contained in:
Ted John
2016-10-01 14:56:44 +01:00
parent 23094d25bb
commit 548724a06f

View File

@@ -773,6 +773,29 @@ void game_fix_save_vars() {
}
}
}
// Fix invalid research items
for (int i = 0; i < 500; i++) {
rct_research_item *researchItem = &gResearchItems[i];
if (researchItem->entryIndex == RESEARCHED_ITEMS_SEPARATOR) continue;
if (researchItem->entryIndex == RESEARCHED_ITEMS_END) continue;
if (researchItem->entryIndex == RESEARCHED_ITEMS_END_2) break;
if (researchItem->entryIndex & 0x10000) {
uint8 entryIndex = researchItem->entryIndex & 0xFF;
rct_ride_entry *rideEntry = get_ride_entry(entryIndex);
if (rideEntry == NULL || rideEntry == (rct_ride_entry*)-1) {
research_remove(researchItem->entryIndex);
i--;
}
} else {
uint8 entryIndex = researchItem->entryIndex;
rct_scenery_set_entry *sceneryGroupEntry = get_scenery_group_entry(entryIndex);
if (sceneryGroupEntry == NULL || sceneryGroupEntry == (rct_scenery_set_entry*)-1) {
research_remove(researchItem->entryIndex);
i--;
}
}
}
}
/**