From ec6b73831764ad9f26f28cd9c1b9a84e281da153 Mon Sep 17 00:00:00 2001 From: Gymnasiast Date: Sat, 20 Apr 2019 22:43:28 +0200 Subject: [PATCH 1/3] Fix #8079: Crash when unloading buggy custom rides --- distribution/changelog.txt | 1 + src/openrct2/peep/Guest.cpp | 34 +++++++++++++++++++--------------- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/distribution/changelog.txt b/distribution/changelog.txt index b41c9335e9..bd469e201b 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -13,6 +13,7 @@ - Fix: [#6006] Objects higher than 6 metres are considered trees (original bug). - Fix: [#7884] Unfinished preserved rides can be demolished with quick demolish. - Fix: [#7913] RCT1/RCT2 title sequence timing is off. +- Fix: [#8079, #8969] Crash when unloading buggy custom rides. - Fix: [#8219] Faulty folder recreation in "save" folder. - Fix: [#8537] Imported RCT1 rides/shops are all numbered 1. - Fix: [#8649] Setting date does not work in multiplayer. diff --git a/src/openrct2/peep/Guest.cpp b/src/openrct2/peep/Guest.cpp index 6d19e463a0..9fa5bf938e 100644 --- a/src/openrct2/peep/Guest.cpp +++ b/src/openrct2/peep/Guest.cpp @@ -4028,22 +4028,26 @@ void Guest::UpdateRideLeaveVehicle() platformLocation.x = vehicle->x + word_981D6C[platformLocation.direction].x * 12; platformLocation.y = vehicle->y + word_981D6C[platformLocation.direction].y * 12; - int8_t loadPosition = vehicle_entry->peep_loading_positions[current_seat]; - - switch (vehicle->sprite_direction / 8) + // This can evaluate to false with buggy custom rides. + if (current_seat < vehicle_entry->peep_loading_positions.size()) { - case 0: - platformLocation.x -= loadPosition; - break; - case 1: - platformLocation.y += loadPosition; - break; - case 2: - platformLocation.x += loadPosition; - break; - case 3: - platformLocation.y -= loadPosition; - break; + int8_t loadPosition = vehicle_entry->peep_loading_positions[current_seat]; + + switch (vehicle->sprite_direction / 8) + { + case 0: + platformLocation.x -= loadPosition; + break; + case 1: + platformLocation.y += loadPosition; + break; + case 2: + platformLocation.x += loadPosition; + break; + case 3: + platformLocation.y -= loadPosition; + break; + } } platformLocation.z = ride->stations[current_ride_station].Height * 8; From 89f591ffcb45defc9ea9e3a0e62d807362963a41 Mon Sep 17 00:00:00 2001 From: Gymnasiast Date: Sun, 21 Apr 2019 12:21:24 +0200 Subject: [PATCH 2/3] Also add #7700 to changelog [ci skip] --- distribution/changelog.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/distribution/changelog.txt b/distribution/changelog.txt index bd469e201b..f06f8da6dd 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -13,7 +13,7 @@ - Fix: [#6006] Objects higher than 6 metres are considered trees (original bug). - Fix: [#7884] Unfinished preserved rides can be demolished with quick demolish. - Fix: [#7913] RCT1/RCT2 title sequence timing is off. -- Fix: [#8079, #8969] Crash when unloading buggy custom rides. +- Fix: [#7700, #8079, #8969] Crash when unloading buggy custom rides. - Fix: [#8219] Faulty folder recreation in "save" folder. - Fix: [#8537] Imported RCT1 rides/shops are all numbered 1. - Fix: [#8649] Setting date does not work in multiplayer. From 6d3eca31fd6ca8a2e475cae0d07cc8a587e10761 Mon Sep 17 00:00:00 2001 From: Gymnasiast Date: Mon, 22 Apr 2019 23:27:25 +0200 Subject: [PATCH 3/3] Add log_verbose for vehicle entries with broken peep loading positions --- src/openrct2/peep/Guest.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/openrct2/peep/Guest.cpp b/src/openrct2/peep/Guest.cpp index 9fa5bf938e..d4437e38b6 100644 --- a/src/openrct2/peep/Guest.cpp +++ b/src/openrct2/peep/Guest.cpp @@ -4049,6 +4049,12 @@ void Guest::UpdateRideLeaveVehicle() break; } } + else + { + log_verbose( + "current_seat %d is too large! (Vehicle entry has room for %d.)", current_seat, + vehicle_entry->peep_loading_positions.size()); + } platformLocation.z = ride->stations[current_ride_station].Height * 8;