From ad684b1e575dad83e3f9f41a995f1fea3723bd58 Mon Sep 17 00:00:00 2001 From: Jeroen D Stout Date: Thu, 11 Jan 2018 02:29:21 +0100 Subject: [PATCH] Add claxon to vehicle reserving initial crossing tile --- src/openrct2/ride/Vehicle.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/openrct2/ride/Vehicle.cpp b/src/openrct2/ride/Vehicle.cpp index 693981010a..5e6ca0878d 100644 --- a/src/openrct2/ride/Vehicle.cpp +++ b/src/openrct2/ride/Vehicle.cpp @@ -50,6 +50,7 @@ static void vehicle_update(rct_vehicle * vehicle); static void vehicle_update_crossings(rct_vehicle * vehicle); +static void vehicle_claxon(rct_vehicle * vehicle); static void vehicle_update_showing_film(rct_vehicle * vehicle); static void vehicle_update_doing_circus_show(rct_vehicle * vehicle); @@ -9944,6 +9945,7 @@ void vehicle_update_crossings(rct_vehicle * vehicle) { sint16 autoReserveAhead = 4 + abs(vehicle->velocity) / 150000; sint16 crossingBonus = 0; + bool playedClaxon = false; // vehicle positions mean we have to take larger // margins for travelling backwards @@ -9962,6 +9964,10 @@ void vehicle_update_crossings(rct_vehicle * vehicle) if (tileElement) { + if (!playedClaxon && 0 == (tileElement->flags & TILE_ELEMENT_FLAG_BLOCKED_BY_VEHICLE)) + { + vehicle_claxon(vehicle); + } crossingBonus = 4; tileElement->flags |= TILE_ELEMENT_FLAG_BLOCKED_BY_VEHICLE; } @@ -10040,3 +10046,9 @@ void vehicle_update_crossings(rct_vehicle * vehicle) } } } + +void vehicle_claxon(rct_vehicle * vehicle) +{ + rct_ride_entry* rideEntry = get_ride_entry(vehicle->ride_subtype); + audio_play_sound_at_location((rideEntry->vehicles[0].sound_range == 3)? SOUND_TRAIN_WHISTLE : SOUND_TRAM, vehicle->x, vehicle->y, vehicle->z); +} \ No newline at end of file