From 3fcc7ab4efe62e5c43e8ef0f84a9bc877f33c11b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Thu, 28 Jul 2016 00:09:17 +0200 Subject: [PATCH] Fix #3822: Crash in check_and_apply_block_section_stop_site --- src/ride/vehicle.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/ride/vehicle.c b/src/ride/vehicle.c index 21aa4df5b8..e218442651 100644 --- a/src/ride/vehicle.c +++ b/src/ride/vehicle.c @@ -3185,6 +3185,10 @@ static void vehicle_update_arriving(rct_vehicle* vehicle) { vehicle->track_z / 8 ); + if (mapElement == NULL) { + return; + } + vehicle->current_station = map_get_station(mapElement); vehicle->num_laps++; @@ -5641,6 +5645,10 @@ static void check_and_apply_block_section_stop_site(rct_vehicle *vehicle) trackType ); + if (trackElement == NULL) { + return; + } + switch (trackType) { case TRACK_ELEM_BLOCK_BRAKES: if (ride_is_block_sectioned(ride)) @@ -6917,8 +6925,12 @@ static void sub_6DBF3E(rct_vehicle *vehicle) trackType, 0 ); - } + + if (mapElement == NULL) { + return; + } + if (RCT2_GLOBAL(0x00F64E1C, uint32) == 0xFFFFFFFF) { RCT2_GLOBAL(0x00F64E1C, uint32) = (mapElement->properties.track.sequence >> 4) & 7; } @@ -6985,6 +6997,11 @@ static bool vehicle_update_track_motion_forwards_get_new_track(rct_vehicle *vehi trackType, 0 ); + + if (mapElement == NULL) { + return false; + } + if (trackType == TRACK_ELEM_CABLE_LIFT_HILL && vehicle == gCurrentVehicle) { RCT2_GLOBAL(0x00F64E18, uint32) |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_11; }