1 /*****************************************************************************
2  * Copyright (c) 2014-2020 OpenRCT2 developers
3  *
4  * For a complete list of all authors, please refer to contributors.md
5  * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
6  *
7  * OpenRCT2 is licensed under the GNU General Public License version 3.
8  *****************************************************************************/
9 
10 #pragma once
11 
12 #include "../audio/audio.h"
13 #include "../common.h"
14 #include "../ride/RideTypes.h"
15 #include "../world/EntityBase.h"
16 #include "../world/Location.hpp"
17 #include "Station.h"
18 #include "VehicleColour.h"
19 #include "VehicleEntry.h"
20 #include "VehicleSubpositionData.h"
21 
22 #include <array>
23 #include <cstddef>
24 #include <vector>
25 
26 using track_type_t = uint16_t;
27 
28 struct Ride;
29 struct rct_ride_entry;
30 class DataSerialiser;
31 
32 struct GForces
33 {
34     int32_t VerticalG{};
35     int32_t LateralG{};
36 };
37 
38 // Size: 0x09
39 struct rct_vehicle_info
40 {
41     int16_t x;             // 0x00
42     int16_t y;             // 0x02
43     int16_t z;             // 0x04
44     uint8_t direction;     // 0x06
45     uint8_t Pitch;         // 0x07
46     uint8_t bank_rotation; // 0x08
47 };
48 
49 struct SoundIdVolume;
50 
51 constexpr const uint16_t VehicleTrackDirectionMask = 0b0000000000000011;
52 constexpr const uint16_t VehicleTrackTypeMask = 0b1111111111111100;
53 
54 enum class MiniGolfAnimation : uint8_t;
55 
56 struct Vehicle : EntityBase
57 {
58     static constexpr auto cEntityType = EntityType::Vehicle;
59 
60     enum class Type : uint8_t
61     {
62         Head,
63         Tail,
64     };
65 
66     enum class Status : uint8_t
67     {
68         MovingToEndOfStation,
69         WaitingForPassengers,
70         WaitingToDepart,
71         Departing,
72         Travelling,
73         Arriving,
74         UnloadingPassengers,
75         TravellingBoat,
76         Crashing,
77         Crashed,
78         TravellingDodgems,
79         Swinging,
80         Rotating,
81         FerrisWheelRotating,
82         SimulatorOperating,
83         ShowingFilm,
84         SpaceRingsOperating,
85         TopSpinOperating,
86         HauntedHouseOperating,
87         DoingCircusShow,
88         CrookedHouseOperating,
89         WaitingForCableLift,
90         TravellingCableLift,
91         Stopping,
92         WaitingForPassengers17,
93         WaitingToStart,
94         Starting,
95         Operating1A,
96         Stopping1B,
97         UnloadingPassengers1C,
98         StoppedByBlockBrakes
99     };
100 
101     Type SubType;
102     uint8_t Pitch;
103     uint8_t bank_rotation;
104     int32_t remaining_distance;
105     int32_t velocity;
106     int32_t acceleration;
107     ride_id_t ride;
108     uint8_t vehicle_type;
109     rct_vehicle_colour colours;
110     union
111     {
112         uint16_t track_progress;
113         struct
114         {
115             int8_t var_34;
116             uint8_t var_35;
117         };
118     };
119     uint16_t TrackTypeAndDirection;
120     CoordsXYZ TrackLocation;
121     uint16_t next_vehicle_on_train;
122 
123     // The previous vehicle on the same train or the last vehicle on the previous or only train.
124     uint16_t prev_vehicle_on_ride;
125 
126     // The next vehicle on the same train or the first vehicle on the next or only train
127     uint16_t next_vehicle_on_ride;
128 
129     uint16_t var_44;
130     uint16_t mass;
131     uint16_t update_flags;
132     uint8_t SwingSprite;
133     StationIndex current_station;
134     union
135     {
136         int16_t SwingPosition;
137         int16_t current_time;
138         struct
139         {
140             int8_t ferris_wheel_var_0;
141             int8_t ferris_wheel_var_1;
142         };
143     };
144     union
145     {
146         int16_t SwingSpeed;
147         int16_t crash_z;
148     };
149     Status status;
150     uint8_t sub_state;
151     uint16_t peep[32];
152     uint8_t peep_tshirt_colours[32];
153     uint8_t num_seats;
154     uint8_t num_peeps;
155     uint8_t next_free_seat;
156     uint8_t restraints_position; // 0 == Close, 255 == Open
157     union
158     {
159         int16_t spin_speed;
160         int16_t crash_x;
161     };
162     uint16_t sound2_flags;
163     uint8_t spin_sprite; // lowest 3 bits not used for sprite selection (divide by 8 to use)
164     OpenRCT2::Audio::SoundId sound1_id;
165     uint8_t sound1_volume;
166     OpenRCT2::Audio::SoundId sound2_id;
167     uint8_t sound2_volume;
168     int8_t sound_vector_factor;
169     union
170     {
171         uint16_t var_C0;
172         int16_t crash_y;
173         uint16_t time_waiting;
174         uint16_t cable_lift_target;
175     };
176     uint8_t speed;
177     uint8_t powered_acceleration;
178     union
179     {
180         uint8_t dodgems_collision_direction;
181         uint8_t var_C4;
182     };
183     uint8_t animation_frame;
184     uint8_t pad_C6[0x2];
185     uint32_t animationState;
186     OpenRCT2::Audio::SoundId scream_sound_id;
187     VehicleTrackSubposition TrackSubposition;
188     union
189     {
190         uint8_t var_CE;
191         uint8_t num_laps;
192     };
193     union
194     {
195         uint8_t var_CF;
196         uint8_t brake_speed;
197     };
198     uint16_t lost_time_out;
199     int8_t vertical_drop_countdown;
200     uint8_t var_D3;
201     MiniGolfAnimation mini_golf_current_animation;
202     uint8_t mini_golf_flags;
203     ObjectEntryIndex ride_subtype;
204     uint8_t colours_extended;
205     uint8_t seat_rotation;
206     uint8_t target_seat_rotation;
207     CoordsXY BoatLocation;
208     bool IsCrashedVehicle;
209 
IsHeadVehicle210     constexpr bool IsHead() const
211     {
212         return SubType == Vehicle::Type::Head;
213     }
214     void Update();
215     Vehicle* GetHead();
216     const Vehicle* GetHead() const;
217     Vehicle* GetCar(size_t carIndex) const;
218     void SetState(Vehicle::Status vehicleStatus, uint8_t subState = 0);
219     bool IsGhost() const;
220     void UpdateSoundParams(std::vector<OpenRCT2::Audio::VehicleSoundParams>& vehicleSoundParamsList) const;
221     bool DodgemsCarWouldCollideAt(const CoordsXY& coords, uint16_t* spriteId) const;
222     int32_t UpdateTrackMotion(int32_t* outStation);
223     int32_t CableLiftUpdateTrackMotion();
224     GForces GetGForces() const;
225     void SetMapToolbar() const;
226     int32_t IsUsedInPairs() const;
227     rct_ride_entry* GetRideEntry() const;
228     rct_ride_entry_vehicle* Entry() const;
229     Ride* GetRide() const;
230     Vehicle* TrainHead() const;
231     Vehicle* TrainTail() const;
232     void EnableCollisionsForTrain();
233     /**
234      * Instantly moves the specific car forward or backwards along the track.
235      */
236     void MoveRelativeDistance(int32_t distance);
GetTrackTypeVehicle237     track_type_t GetTrackType() const
238     {
239         return TrackTypeAndDirection >> 2;
240     }
GetTrackDirectionVehicle241     uint8_t GetTrackDirection() const
242     {
243         return TrackTypeAndDirection & VehicleTrackDirectionMask;
244     }
SetTrackTypeVehicle245     void SetTrackType(track_type_t trackType)
246     {
247         // set the upper 14 bits to 0, then set track type
248         TrackTypeAndDirection &= ~VehicleTrackTypeMask;
249         TrackTypeAndDirection |= trackType << 2;
250     }
SetTrackDirectionVehicle251     void SetTrackDirection(uint8_t trackDirection)
252     {
253         // set the lower 2 bits only
254         TrackTypeAndDirection &= ~VehicleTrackDirectionMask;
255         TrackTypeAndDirection |= trackDirection & VehicleTrackDirectionMask;
256     }
HasUpdateFlagVehicle257     bool HasUpdateFlag(uint32_t flag) const
258     {
259         return (update_flags & flag) != 0;
260     }
ClearUpdateFlagVehicle261     void ClearUpdateFlag(uint32_t flag)
262     {
263         update_flags &= ~flag;
264     }
SetUpdateFlagVehicle265     void SetUpdateFlag(uint32_t flag)
266     {
267         update_flags |= flag;
268     }
269     void ApplyMass(int16_t appliedMass);
270     void Serialise(DataSerialiser& stream);
271 
272 private:
273     bool SoundCanPlay() const;
274     uint16_t GetSoundPriority() const;
275     const rct_vehicle_info* GetMoveInfo() const;
276     uint16_t GetTrackProgress() const;
277     OpenRCT2::Audio::VehicleSoundParams CreateSoundParam(uint16_t priority) const;
278     void CableLiftUpdate();
279     bool CableLiftUpdateTrackMotionForwards();
280     bool CableLiftUpdateTrackMotionBackwards();
281     void CableLiftUpdateMovingToEndOfStation();
282     void CableLiftUpdateWaitingToDepart();
283     void CableLiftUpdateDeparting();
284     void CableLiftUpdateTravelling();
285     void CableLiftUpdateArriving();
286     void Sub6DBF3E();
287     void UpdateMeasurements();
288     void UpdateMovingToEndOfStation();
289     void UpdateWaitingForPassengers();
290     void UpdateWaitingToDepart();
291     void UpdateCrash();
292     void UpdateDodgemsMode();
293     void UpdateSwinging();
294     void UpdateSimulatorOperating();
295     void UpdateTopSpinOperating();
296     void UpdateFerrisWheelRotating();
297     void UpdateSpaceRingsOperating();
298     void UpdateHauntedHouseOperating();
299     void UpdateCrookedHouseOperating();
300     void UpdateRotating();
301     void UpdateDeparting();
302     void FinishDeparting();
303     void UpdateTravelling();
304     void UpdateTravellingCableLift();
305     void UpdateTravellingBoat();
306     void UpdateMotionBoatHire();
307     void TryReconnectBoatToTrack(const CoordsXY& currentBoatLocation, const CoordsXY& trackCoords);
308     void UpdateDepartingBoatHire();
309     void UpdateTravellingBoatHireSetup();
310     void UpdateBoatLocation();
311     void UpdateArrivingPassThroughStation(
312         const Ride& curRide, const rct_ride_entry_vehicle& vehicleEntry, bool stationBrakesWork);
313     void UpdateArriving();
314     void UpdateUnloadingPassengers();
315     void UpdateWaitingForCableLift();
316     void UpdateShowingFilm();
317     void UpdateDoingCircusShow();
318     void UpdateCrossings() const;
319     void UpdateSound();
320     void GetLiftHillSound(Ride* curRide, SoundIdVolume& curSound);
321     OpenRCT2::Audio::SoundId UpdateScreamSound();
322     OpenRCT2::Audio::SoundId ProduceScreamSound(const int32_t totalNumPeeps);
323     void UpdateCrashSetup();
324     void UpdateCollisionSetup();
325     int32_t UpdateMotionDodgems();
326     void UpdateAnimationAnimalFlying();
327     void UpdateAdditionalAnimation();
328     void CheckIfMissing();
329     bool CurrentTowerElementIsTop();
330     bool UpdateTrackMotionForwards(rct_ride_entry_vehicle* vehicleEntry, Ride* curRide, rct_ride_entry* rideEntry);
331     bool UpdateTrackMotionBackwards(rct_ride_entry_vehicle* vehicleEntry, Ride* curRide, rct_ride_entry* rideEntry);
332     int32_t UpdateTrackMotionPoweredRideAcceleration(
333         rct_ride_entry_vehicle* vehicleEntry, uint32_t totalMass, const int32_t curAcceleration);
334     int32_t NumPeepsUntilTrainTail() const;
335     void InvalidateWindow();
336     void TestReset();
337     void UpdateTestFinish();
338     void PeepEasterEggHereWeAre() const;
339     bool CanDepartSynchronised() const;
340     void ReverseReverserCar();
341     void UpdateReverserCarBogies();
342     void UpdateHandleWaterSplash() const;
343     void Claxon() const;
344     void UpdateTrackMotionUpStopCheck() const;
345     void ApplyNonStopBlockBrake();
346     void ApplyStopBlockBrake();
347     void CheckAndApplyBlockSectionStopSite();
348     void UpdateVelocity();
349     void UpdateSpinningCar();
350     void UpdateSwingingCar();
351     int32_t GetSwingAmount() const;
352     bool OpenRestraints();
353     bool CloseRestraints();
354     void CrashOnWater();
355     void CrashOnLand();
356     void SimulateCrash() const;
357     void KillAllPassengersInTrain();
358     void KillPassengers(Ride* curRide);
359     void TrainReadyToDepart(uint8_t num_peeps_on_train, uint8_t num_used_seats);
360     int32_t UpdateTrackMotionMiniGolfCalculateAcceleration(const rct_ride_entry_vehicle& vehicleEntry);
361     int32_t UpdateTrackMotionMiniGolf(int32_t* outStation);
362     void UpdateTrackMotionMiniGolfVehicle(Ride* curRide, rct_ride_entry* rideEntry, rct_ride_entry_vehicle* vehicleEntry);
363     bool UpdateTrackMotionForwardsGetNewTrack(uint16_t trackType, Ride* curRide, rct_ride_entry* rideEntry);
364     bool UpdateTrackMotionBackwardsGetNewTrack(uint16_t trackType, Ride* curRide, uint16_t* progress);
365     bool UpdateMotionCollisionDetection(const CoordsXYZ& loc, uint16_t* otherVehicleIndex);
366     void UpdateGoKartAttemptSwitchLanes();
367     void UpdateSceneryDoor() const;
368     void UpdateSceneryDoorBackwards() const;
369     void UpdateLandscapeDoor() const;
370     void UpdateLandscapeDoorBackwards() const;
371 };
372 static_assert(sizeof(Vehicle) <= 512);
373 
374 struct train_ref
375 {
376     Vehicle* head;
377     Vehicle* tail;
378 };
379 
380 namespace MiniGolfFlag
381 {
382     constexpr uint8_t Flag0 = (1 << 0);
383     constexpr uint8_t Flag1 = (1 << 1);
384     constexpr uint8_t Flag2 = (1 << 2);
385     constexpr uint8_t Flag3 = (1 << 3);
386     constexpr uint8_t Flag4 = (1 << 4);
387     constexpr uint8_t Flag5 = (1 << 5); // transitioning between hole
388 } // namespace MiniGolfFlag
389 
390 enum class MiniGolfState : int16_t
391 {
392     Unk0,
393     Unk1, // Unused
394     Unk2,
395     Unk3,
396     Unk4,
397     Unk5,
398     Unk6,
399 };
400 
401 enum class MiniGolfAnimation : uint8_t
402 {
403     Walk,
404     PlaceBallDown,
405     SwingLeft,
406     PickupBall,
407     Jump,
408     PlaceBallUp,
409     PuttLeft,
410     Swing,
411     Putt,
412 };
413 
414 enum : uint32_t
415 {
416     VEHICLE_ENTRY_FLAG_POWERED_RIDE_UNRESTRICTED_GRAVITY = 1
417         << 0, // Set on powered vehicles that do not slow down when going down a hill.
418     VEHICLE_ENTRY_FLAG_NO_UPSTOP_WHEELS = 1 << 1,
419     VEHICLE_ENTRY_FLAG_NO_UPSTOP_BOBSLEIGH = 1 << 2,
420     VEHICLE_ENTRY_FLAG_MINI_GOLF = 1 << 3,
421     VEHICLE_ENTRY_FLAG_REVERSER_BOGIE = 1 << 4,
422     VEHICLE_ENTRY_FLAG_REVERSER_PASSENGER_CAR = 1 << 5,
423     VEHICLE_ENTRY_FLAG_HAS_INVERTED_SPRITE_SET = 1 << 6, // Set on vehicles that support running inverted for extended periods
424                                                          // of time, i.e. the Flying, Lay-down and Multi-dimension RCs.
425     VEHICLE_ENTRY_FLAG_DODGEM_INUSE_LIGHTS = 1
426         << 7, // When set the vehicle has an additional frame for when in use. Used only by dodgems.
427     VEHICLE_ENTRY_FLAG_ALLOW_DOORS_DEPRECATED = 1 << 8, // Not used any more - every vehicle will now work with doors.
428     VEHICLE_ENTRY_FLAG_ENABLE_ADDITIONAL_COLOUR_2 = 1 << 9,
429     VEHICLE_ENTRY_FLAG_RECALCULATE_SPRITE_BOUNDS = 1 << 10, // Only used during loading of the objects.
430     VEHICLE_ENTRY_FLAG_USE_16_ROTATION_FRAMES = 1
431         << 11, // Instead of the default 32 rotation frames. Only used for boat hire and works only for non sloped sprites.
432     VEHICLE_ENTRY_FLAG_OVERRIDE_NUM_VERTICAL_FRAMES = 1
433         << 12, // Setting this will cause the game to set vehicleEntry->num_vertical_frames to
434                // vehicleEntry->num_vertical_frames_override, rather than determining it itself.
435     VEHICLE_ENTRY_FLAG_SPRITE_BOUNDS_INCLUDE_INVERTED_SET = 1
436         << 13, // Used together with HAS_INVERTED_SPRITE_SET and RECALCULATE_SPRITE_BOUNDS and includes the inverted sprites
437                // into the function that recalculates the sprite bounds.
438     VEHICLE_ENTRY_FLAG_SPINNING_ADDITIONAL_FRAMES = 1
439         << 14, // 16x additional frames for vehicle. A spinning item with additional frames must always face forward to
440                // load/unload. Spinning without can load/unload at 4 rotations.
441     VEHICLE_ENTRY_FLAG_LIFT = 1 << 15,
442     VEHICLE_ENTRY_FLAG_ENABLE_ADDITIONAL_COLOUR_1 = 1 << 16,
443     VEHICLE_ENTRY_FLAG_SWINGING = 1 << 17,
444     VEHICLE_ENTRY_FLAG_SPINNING = 1 << 18,
445     VEHICLE_ENTRY_FLAG_POWERED = 1 << 19,
446     VEHICLE_ENTRY_FLAG_RIDERS_SCREAM = 1 << 20,
447     VEHICLE_ENTRY_FLAG_SUSPENDED_SWING = 1 << 21, // Suspended swinging coaster, or bobsleigh if SLIDE_SWING is also enabled.
448     VEHICLE_ENTRY_FLAG_BOAT_HIRE_COLLISION_DETECTION = 1 << 22,
449     VEHICLE_ENTRY_FLAG_VEHICLE_ANIMATION = 1 << 23, // Set on animated vehicles like the Multi-dimension coaster trains,
450                                                     // Miniature Railway locomotives and Helicycles.
451     VEHICLE_ENTRY_FLAG_RIDER_ANIMATION = 1 << 24,   // Set when the animation updates rider sprite positions.
452     VEHICLE_ENTRY_FLAG_WOODEN_WILD_MOUSE_SWING = 1 << 25,
453     VEHICLE_ENTRY_FLAG_LOADING_WAYPOINTS = 1
454         << 26, // Peep loading positions have x and y coordinates. Normal rides just have offsets.
455     VEHICLE_ENTRY_FLAG_SLIDE_SWING = 1
456         << 27, // Set on dingy slides. They have there own swing value calculations and have a different amount of images.
457                // Also set on bobsleighs together with the SUSPENDED_SWING flag.
458     VEHICLE_ENTRY_FLAG_CHAIRLIFT = 1 << 28,
459     VEHICLE_ENTRY_FLAG_WATER_RIDE = 1 << 29, // Set on rides where water would provide continuous propulsion.
460     VEHICLE_ENTRY_FLAG_GO_KART = 1 << 30,
461     VEHICLE_ENTRY_FLAG_DODGEM_CAR_PLACEMENT = 1u << 31,
462 };
463 
464 enum
465 {
466     VEHICLE_ENTRY_ANIMATION_NONE,
467     VEHICLE_ENTRY_ANIMATION_MINITURE_RAILWAY_LOCOMOTIVE,
468     VEHICLE_ENTRY_ANIMATION_SWAN,
469     VEHICLE_ENTRY_ANIMATION_CANOES,
470     VEHICLE_ENTRY_ANIMATION_ROW_BOATS,
471     VEHICLE_ENTRY_ANIMATION_WATER_TRICYCLES,
472     VEHICLE_ENTRY_ANIMATION_OBSERVATION_TOWER,
473     VEHICLE_ENTRY_ANIMATION_HELICARS,
474     VEHICLE_ENTRY_ANIMATION_MONORAIL_CYCLES,
475     VEHICLE_ENTRY_ANIMATION_MULTI_DIM_COASTER,
476     VEHICLE_ENTRY_ANIMATION_ANIMAL_FLYING // OpenRCT2-specific feature
477 };
478 
479 enum : uint32_t
480 {
481     VEHICLE_UPDATE_FLAG_ON_LIFT_HILL = (1 << 0),
482     VEHICLE_UPDATE_FLAG_COLLISION_DISABLED = (1 << 1),
483     VEHICLE_UPDATE_FLAG_WAIT_ON_ADJACENT = (1 << 2),
484     VEHICLE_UPDATE_FLAG_REVERSING_SHUTTLE = (1 << 3), // Shuttle is in reverse
485     VEHICLE_UPDATE_FLAG_TRAIN_READY_DEPART = (1 << 4),
486     VEHICLE_UPDATE_FLAG_TESTING = (1 << 5),
487     VEHICLE_UPDATE_FLAG_6 = (1 << 6),
488     VEHICLE_UPDATE_FLAG_ZERO_VELOCITY = (1 << 7), // Used on rides when safety cutout stops them on a lift
489     VEHICLE_UPDATE_FLAG_BROKEN_CAR = (1 << 8),
490     VEHICLE_UPDATE_FLAG_BROKEN_TRAIN = (1 << 9),
491     VEHICLE_UPDATE_FLAG_ON_BRAKE_FOR_DROP = (1 << 10),
492     VEHICLE_UPDATE_FLAG_USE_INVERTED_SPRITES = (1 << 11), // Used on rides where trains can run for extended periods of time,
493                                                           // i.e. the Flying, Lay-down and Multi-dimension RCs.
494     VEHICLE_UPDATE_FLAG_12 = (1 << 12),
495     VEHICLE_UPDATE_FLAG_ROTATION_OFF_WILD_MOUSE = (1 << 13), // After passing a rotation toggle track piece this will enable
496     VEHICLE_UPDATE_FLAG_SINGLE_CAR_POSITION = (1 << 14), // OpenRCT2 Flag: Used to override UpdateMotion to move the position of
497                                                          // an individual car on a train
498 };
499 
500 enum : uint32_t
501 {
502     VEHICLE_SPRITE_FLAG_FLAT = (1 << 0),
503     VEHICLE_SPRITE_FLAG_GENTLE_SLOPES = (1 << 1),
504     VEHICLE_SPRITE_FLAG_STEEP_SLOPES = (1 << 2),
505     VEHICLE_SPRITE_FLAG_VERTICAL_SLOPES = (1 << 3),
506     VEHICLE_SPRITE_FLAG_DIAGONAL_SLOPES = (1 << 4),
507     VEHICLE_SPRITE_FLAG_FLAT_BANKED = (1 << 5),
508     VEHICLE_SPRITE_FLAG_INLINE_TWISTS = (1 << 6),
509     VEHICLE_SPRITE_FLAG_FLAT_TO_GENTLE_SLOPE_BANKED_TRANSITIONS = (1 << 7),
510     VEHICLE_SPRITE_FLAG_DIAGONAL_GENTLE_SLOPE_BANKED_TRANSITIONS = (1 << 8),
511     VEHICLE_SPRITE_FLAG_GENTLE_SLOPE_BANKED_TRANSITIONS = (1 << 9),
512     VEHICLE_SPRITE_FLAG_GENTLE_SLOPE_BANKED_TURNS = (1 << 10),
513     VEHICLE_SPRITE_FLAG_FLAT_TO_GENTLE_SLOPE_WHILE_BANKED_TRANSITIONS = (1 << 11),
514     VEHICLE_SPRITE_FLAG_CORKSCREWS = (1 << 12),
515     VEHICLE_SPRITE_FLAG_RESTRAINT_ANIMATION = (1 << 13),
516     VEHICLE_SPRITE_FLAG_CURVED_LIFT_HILL = (1 << 14),
517     // Used only on lifts (the transport ride), to only use 4 rotation sprites instead of 32.
518     VEHICLE_SPRITE_FLAG_USE_4_ROTATION_FRAMES = (1 << 15),
519 };
520 
521 enum
522 {
523     VEHICLE_VISUAL_DEFAULT,
524     VEHICLE_VISUAL_FLAT_RIDE_OR_CAR_RIDE,
525     VEHICLE_VISUAL_LAUNCHED_FREEFALL,
526     VEHICLE_VISUAL_OBSERVATION_TOWER,
527     VEHICLE_VISUAL_RIVER_RAPIDS,
528     VEHICLE_VISUAL_MINI_GOLF_PLAYER,
529     VEHICLE_VISUAL_MINI_GOLF_BALL,
530     VEHICLE_VISUAL_REVERSER,
531     VEHICLE_VISUAL_SPLASH_BOATS_OR_WATER_COASTER,
532     VEHICLE_VISUAL_ROTO_DROP,
533     VEHICLE_VISUAL_SPLASH1_EFFECT,
534     VEHICLE_VISUAL_SPLASH2_EFFECT,
535     VEHICLE_VISUAL_SPLASH3_EFFECT,
536     VEHICLE_VISUAL_SPLASH4_EFFECT,
537     VEHICLE_VISUAL_SPLASH5_EFFECT,
538     VEHICLE_VISUAL_VIRGINIA_REEL,
539     VEHICLE_VISUAL_SUBMARINE
540 };
541 
542 enum : uint32_t
543 {
544     VEHICLE_UPDATE_MOTION_TRACK_FLAG_VEHICLE_AT_STATION = 1 << 0,
545     VEHICLE_UPDATE_MOTION_TRACK_FLAG_1 = 1 << 1,
546     VEHICLE_UPDATE_MOTION_TRACK_FLAG_2 = 1 << 2,
547     VEHICLE_UPDATE_MOTION_TRACK_FLAG_3 = 1 << 3,
548     VEHICLE_UPDATE_MOTION_TRACK_FLAG_VEHICLE_ON_LIFT_HILL = 1 << 4,
549     VEHICLE_UPDATE_MOTION_TRACK_FLAG_5 = 1 << 5,
550     VEHICLE_UPDATE_MOTION_TRACK_FLAG_VEHICLE_DERAILED = 1 << 6,
551     VEHICLE_UPDATE_MOTION_TRACK_FLAG_VEHICLE_COLLISION = 1 << 7,
552     VEHICLE_UPDATE_MOTION_TRACK_FLAG_8 = 1 << 8,
553     VEHICLE_UPDATE_MOTION_TRACK_FLAG_9 = 1 << 9,
554     VEHICLE_UPDATE_MOTION_TRACK_FLAG_VEHICLE_AT_BLOCK_BRAKE = 1 << 10,
555     VEHICLE_UPDATE_MOTION_TRACK_FLAG_11 = 1 << 11,
556     VEHICLE_UPDATE_MOTION_TRACK_FLAG_12 = 1 << 12,
557 };
558 
559 enum
560 {
561     VEHICLE_SOUND2_FLAGS_LIFT_HILL = 1 << 1 // When on a lift hill generate sound
562 };
563 
564 enum
565 {
566     FRICTION_SOUND_WOOD_SMALL = 1,
567     FRICTION_SOUND_STEEL = 2,
568     FRICTION_SOUND_PETROL = 21,
569     FRICTION_SOUND_TRAIN = 31,
570     FRICTION_SOUND_WATERSLIDE = 32,
571     FRICTION_SOUND_WOOD_LARGE = 54,
572     FRICTION_SOUND_STEEL_SMOOTH = 57,
573     FRICTION_SOUND_NONE = 255
574 };
575 
576 enum
577 {
578     SOUND_RANGE_SCREAMS_0 = 0,
579     SOUND_RANGE_SCREAMS_1 = 1,
580     SOUND_RANGE_SCREAMS_2 = 2,
581     SOUND_RANGE_WHISTLE = 3,
582     SOUND_RANGE_BELL = 4,
583     SOUND_RANGE_NONE = 255
584 };
585 
586 #define VEHICLE_SEAT_PAIR_FLAG 0x80
587 #define VEHICLE_SEAT_NUM_MASK 0x7F
588 
589 Vehicle* try_get_vehicle(uint16_t spriteIndex);
590 void vehicle_update_all();
591 void vehicle_sounds_update();
592 
593 extern Vehicle* gCurrentVehicle;
594 extern StationIndex _vehicleStationIndex;
595 extern uint32_t _vehicleMotionTrackFlags;
596 extern int32_t _vehicleVelocityF64E08;
597 extern int32_t _vehicleVelocityF64E0C;
598 extern int32_t _vehicleUnkF64E10;
599 extern uint8_t _vehicleF64E2C;
600 extern Vehicle* _vehicleFrontVehicle;
601 extern CoordsXYZ unk_F64E20;
602