From 9b499ea239adf78bda8e59e73d7d92b0136341e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=B6eh=20Matt?= Date: Sat, 9 Nov 2019 17:00:09 +0100 Subject: [PATCH] Fix #10087: crash loading a save with corrupt peeps (#10122) --- src/openrct2/Game.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/openrct2/Game.cpp b/src/openrct2/Game.cpp index 8682640b1a..63f5d4bc5f 100644 --- a/src/openrct2/Game.cpp +++ b/src/openrct2/Game.cpp @@ -603,11 +603,18 @@ void game_fix_save_vars() { continue; } + Ride* ride = get_ride(rideIdx); + if (ride == nullptr) + { + log_warning("Couldn't find ride %u, resetting ride on peep %u", rideIdx, spriteIndex); + peep->current_ride = RIDE_ID_NULL; + continue; + } set_format_arg(0, uint32_t, peep->id); auto curName = peep->GetName(); log_warning( "Peep %u (%s) has invalid ride station = %u for ride %u.", spriteIndex, curName.c_str(), srcStation, rideIdx); - int8_t station = ride_get_first_valid_station_exit(get_ride(rideIdx)); + int8_t station = ride_get_first_valid_station_exit(ride); if (station == -1) { log_warning("Couldn't find station, removing peep %u", spriteIndex);