From 2f6f728200dd2529d0acefa73dfb96a595c4a2d5 Mon Sep 17 00:00:00 2001 From: duncanspumpkin Date: Wed, 9 Nov 2016 19:00:09 +0000 Subject: [PATCH] Fix #4714. Prevent invalid peep access on closed golf rides. When a golf ride is closed it will remove the peep from the vehicle (the ball). Due to the way vehicles leave stations the vehicle would still travel to the next hole but when it tried to update the peeps action it would crash. This skips updating the peeps action but lets the ball still continue. This will cause a phantom ball to go around the golf course until all the vehicles are back in their closed state. --- src/ride/vehicle.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/ride/vehicle.c b/src/ride/vehicle.c index 95b366aa91..01c017ce07 100644 --- a/src/ride/vehicle.c +++ b/src/ride/vehicle.c @@ -8139,16 +8139,21 @@ loc_6DC743: break; case 4: // loc_6DC820 z = moveInfo->z; - if (z == 2) { - rct_peep *peep = GET_PEEP(vehicle->peep[0]); - if (peep->id & 7) { - z = 7; + // When the ride is closed occasionally the peep is removed + // but the vehicle is still on the track. This will prevent + // it from crashing in that situation. + if (vehicle->peep[0]) { + if (z == 2) { + rct_peep *peep = GET_PEEP(vehicle->peep[0]); + if (peep->id & 7) { + z = 7; + } } - } - if (z == 6) { - rct_peep *peep = GET_PEEP(vehicle->peep[0]); - if (peep->id & 7) { - z = 8; + if (z == 6) { + rct_peep *peep = GET_PEEP(vehicle->peep[0]); + if (peep->id & 7) { + z = 8; + } } } vehicle->mini_golf_current_animation = (uint8)z;