From c879c1697e2bc10749ff01faa7e33eca3a7ae0c0 Mon Sep 17 00:00:00 2001 From: duncanspumpkin Date: Mon, 25 Jan 2016 18:17:25 +0000 Subject: [PATCH] Fix #2110. Boat hire mode no longer causes a crash with incorrect vehicle type This fixes the crash but you can't at present set the number of cars to 1 so its still not completely possible to do what @webhawk wanted --- src/ride/vehicle.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/ride/vehicle.c b/src/ride/vehicle.c index 3fb1e93ddc..74547ba14b 100644 --- a/src/ride/vehicle.c +++ b/src/ride/vehicle.c @@ -3406,11 +3406,15 @@ static void vehicle_update_motion_boat_hire(rct_vehicle *vehicle) edx = -edx; } edx >>= 5; - int eax = ((vehicle->velocity >> 1) + edx) / vehicle->friction; + + // Hack to fix people messing with boat hire + int friction = vehicle->friction == 0 ? 1 : vehicle->friction; + + int eax = ((vehicle->velocity >> 1) + edx) / friction; int ecx = -eax; if (vehicleEntry->flags_b & VEHICLE_ENTRY_FLAG_B_3) { eax = vehicle->speed << 14; - int ebx = (vehicle->speed * vehicle->friction) >> 2; + int ebx = (vehicle->speed * friction) >> 2; if (vehicle->update_flags & VEHICLE_UPDATE_FLAG_3) { eax = -eax; } @@ -6424,6 +6428,10 @@ static bool vehicle_update_motion_collision_detection( if (!(vehicleEntry->flags_b & VEHICLE_ENTRY_FLAG_B_6)){ vehicle->var_C4 = 0; + + // If hacking boat hire rides you can end up here + if (otherVehicleIndex == NULL) return false; + rct_vehicle* collideVehicle = GET_VEHICLE(*otherVehicleIndex); if (vehicle == collideVehicle) return false;