From 4a94f0291024f71e278b0bf6a4d414419ee4ea4d Mon Sep 17 00:00:00 2001 From: Gymnasiast Date: Wed, 26 Sep 2018 21:20:37 +0200 Subject: [PATCH] Fix crash in vehicle_next_tower_element_is_top() --- src/openrct2/ride/Vehicle.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/openrct2/ride/Vehicle.cpp b/src/openrct2/ride/Vehicle.cpp index ece5b8b3b2..7aff34bfb7 100644 --- a/src/openrct2/ride/Vehicle.cpp +++ b/src/openrct2/ride/Vehicle.cpp @@ -3126,6 +3126,11 @@ static bool vehicle_next_tower_element_is_top(rct_vehicle* vehicle) if (tileElement->clearance_height == (tileElement + 1)->base_height) { + if ((tileElement + 1)->GetType() != TILE_ELEMENT_TYPE_TRACK) + { + return true; + } + if ((tileElement + 1)->AsTrack()->GetTrackType() == TRACK_ELEM_TOWER_SECTION) { return false; @@ -3142,6 +3147,11 @@ static bool vehicle_next_tower_element_is_top(rct_vehicle* vehicle) return true; } + if ((tileElement + 2)->GetType() != TILE_ELEMENT_TYPE_TRACK) + { + return true; + } + return (tileElement + 2)->AsTrack()->GetTrackType() != TRACK_ELEM_TOWER_SECTION; }