mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-18 20:43:04 +01:00
Merge pull request #2039 from HaasJona/peep_count
Recalculate peep count after loading a save
This commit is contained in:
20
src/game.c
20
src/game.c
@@ -775,15 +775,33 @@ int game_load_sv6(SDL_RWops* rw)
|
||||
return 0;//This never gets called
|
||||
}
|
||||
|
||||
// The rest is the same as in scenario load and play
|
||||
// The rest is the same as in scenario_load
|
||||
reset_loaded_objects();
|
||||
map_update_tile_pointers();
|
||||
reset_0x69EBE4();
|
||||
openrct2_reset_object_tween_locations();
|
||||
game_convert_strings_to_utf8();
|
||||
game_fix_save_vars(); // OpenRCT2 fix broken save games
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
// OpenRCT2 workaround to recalculate some values which are saved redundantly in the save to fix corrupted files.
|
||||
// For example recalculate guest count by looking at all the guests instead of trusting the value in the file.
|
||||
void game_fix_save_vars() {
|
||||
|
||||
// Recalculates peep count after loading a save to fix corrupted files
|
||||
rct_peep* peep;
|
||||
uint16 spriteIndex;
|
||||
uint16 peepCount = 0;
|
||||
FOR_ALL_GUESTS(spriteIndex, peep) {
|
||||
if(!peep->outside_of_park)
|
||||
peepCount++;
|
||||
}
|
||||
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_GUESTS_IN_PARK, uint16) = peepCount;
|
||||
}
|
||||
|
||||
// Load game state for multiplayer
|
||||
int game_load_network(SDL_RWops* rw)
|
||||
{
|
||||
|
||||
@@ -140,5 +140,6 @@ void rct2_exit_reason(rct_string_id title, rct_string_id body);
|
||||
void game_autosave();
|
||||
void game_convert_strings_to_utf8();
|
||||
void game_convert_strings_to_rct2(rct_s6_data *s6);
|
||||
void game_fix_save_vars();
|
||||
|
||||
#endif
|
||||
|
||||
@@ -204,6 +204,8 @@ int scenario_load(const char *path)
|
||||
reset_0x69EBE4();
|
||||
openrct2_reset_object_tween_locations();
|
||||
game_convert_strings_to_utf8();
|
||||
game_fix_save_vars(); // OpenRCT2 fix broken save games
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user