Fix crash when map element is null in a save

This commit is contained in:
Flukiestemperor 2015-10-30 06:44:19 -05:00
parent 1f9c02fc5f
commit a819a6f177
1 changed files with 13 additions and 0 deletions

View File

@ -792,6 +792,19 @@ void game_fix_save_vars() {
}
RCT2_GLOBAL(RCT2_ADDRESS_GUESTS_IN_PARK, uint16) = peepCount;
// Fixes broken saves where a surface element could be null
for (int y = 0; y < 256; y++) {
for (int x = 0; x < 256; x++) {
rct_map_element *mapElement = map_get_surface_element_at(x, y);
if (mapElement == NULL)
{
log_error("Null map element at x = %d and y = %d. Fixing...", x, y);
map_element_insert(x, y, 14, 0);
}
}
}
}
// Load game state for multiplayer