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 "../common.h"
13 #include "../localisation/Formatter.h"
14 #include "../rct12/RCT12.h"
15 #include "../rct2/RCT2.h"
16 #include "../world/Map.h"
17 #include "RideRatings.h"
18 #include "RideTypes.h"
19 #include "ShopItem.h"
20 #include "VehicleEntry.h"
21 
22 #include <limits>
23 #include <string_view>
24 
25 struct IObjectManager;
26 class Formatter;
27 class StationObject;
28 struct Ride;
29 struct RideTypeDescriptor;
30 struct Guest;
31 struct Staff;
32 struct Vehicle;
33 
34 #define MAX_RIDE_TYPES_PER_RIDE_ENTRY 3
35 // The max number of different types of vehicle.
36 // Examples of vehicles here are the locomotive, tender and carriage of the Miniature Railway.
37 #define MAX_VEHICLES_PER_RIDE_ENTRY 4
38 constexpr const uint8_t MAX_VEHICLES_PER_RIDE = 31;
39 constexpr const uint8_t MAX_CIRCUITS_PER_RIDE = 20;
40 constexpr const uint8_t MAX_CARS_PER_TRAIN = 255;
41 constexpr const uint8_t MAX_VEHICLE_COLOURS = std::max(MAX_CARS_PER_TRAIN, MAX_VEHICLES_PER_RIDE);
42 #define NUM_COLOUR_SCHEMES 4
43 #define MAX_CATEGORIES_PER_RIDE 2
44 #define DOWNTIME_HISTORY_SIZE 8
45 #define CUSTOMER_HISTORY_SIZE 10
46 #define MAX_STATIONS 4
47 #define MAX_RIDES 255
48 #define RIDE_TYPE_NULL 255
49 #define RIDE_ADJACENCY_CHECK_DISTANCE 5
50 
51 constexpr uint16_t const MAX_STATION_LOCATIONS = MAX_STATIONS * 2; // Entrance and exit per station
52 constexpr uint16_t const MAX_INVERSIONS = RCT12_MAX_INVERSIONS;
53 constexpr uint16_t const MAX_GOLF_HOLES = RCT12_MAX_GOLF_HOLES;
54 constexpr uint16_t const MAX_HELICES = RCT12_MAX_HELICES;
55 
56 constexpr uint16_t const MAZE_CLEARANCE_HEIGHT = 4 * COORDS_Z_STEP;
57 
58 constexpr const uint8_t NUM_SHOP_ITEMS_PER_RIDE = 2;
59 
60 #pragma pack(push, 1)
61 struct TrackColour
62 {
63     uint8_t main;
64     uint8_t additional;
65     uint8_t supports;
66 };
67 assert_struct_size(TrackColour, 3);
68 
69 struct vehicle_colour
70 {
71     uint8_t main;
72     uint8_t additional_1;
73     uint8_t additional_2;
74 };
75 assert_struct_size(vehicle_colour, 3);
76 
77 struct track_colour_preset_list
78 {
79     uint8_t count;
80     TrackColour list[256];
81 };
82 assert_struct_size(track_colour_preset_list, (1 + 256 * 3));
83 
84 struct vehicle_colour_preset_list
85 {
86     uint8_t count;
87     vehicle_colour list[256];
88 };
89 assert_struct_size(vehicle_colour_preset_list, (1 + 256 * 3));
90 
91 struct RideNaming
92 {
93     rct_string_id Name;
94     rct_string_id Description;
95 };
96 assert_struct_size(RideNaming, 4);
97 
98 #pragma pack(pop)
99 
100 /**
101  * Ride type structure.
102  */
103 struct rct_ride_entry
104 {
105     RideNaming naming;
106     // The first three images are previews. They correspond to the ride_type[] array.
107     uint32_t images_offset;
108     uint32_t flags;
109     uint8_t ride_type[RCT2_MAX_RIDE_TYPES_PER_RIDE_ENTRY];
110     uint8_t min_cars_in_train;
111     uint8_t max_cars_in_train;
112     uint8_t cars_per_flat_ride;
113     // Number of cars that can't hold passengers
114     uint8_t zero_cars;
115     // The index to the vehicle type displayed in the vehicle tab.
116     uint8_t tab_vehicle;
117     uint8_t default_vehicle;
118     // Convert from first - fourth vehicle to vehicle structure
119     uint8_t front_vehicle;
120     uint8_t second_vehicle;
121     uint8_t rear_vehicle;
122     uint8_t third_vehicle;
123     uint8_t BuildMenuPriority;
124     rct_ride_entry_vehicle vehicles[RCT2_MAX_VEHICLES_PER_RIDE_ENTRY];
125     vehicle_colour_preset_list* vehicle_preset_list;
126     int8_t excitement_multiplier;
127     int8_t intensity_multiplier;
128     int8_t nausea_multiplier;
129     uint8_t max_height;
130     ShopItem shop_item[NUM_SHOP_ITEMS_PER_RIDE];
131     rct_string_id capacity;
132     void* obj;
133 
GetVehiclerct_ride_entry134     const rct_ride_entry_vehicle* GetVehicle(size_t id) const
135     {
136         if (id < std::size(vehicles))
137         {
138             return &vehicles[id];
139         }
140         return nullptr;
141     }
142 
GetDefaultVehiclerct_ride_entry143     const rct_ride_entry_vehicle* GetDefaultVehicle() const
144     {
145         return GetVehicle(default_vehicle);
146     }
147 };
148 
149 struct RideStation
150 {
151     CoordsXY Start;
152     uint8_t Height;
153     uint8_t Length;
154     uint8_t Depart;
155     uint8_t TrainAtStation;
156     TileCoordsXYZD Entrance;
157     TileCoordsXYZD Exit;
158     int32_t SegmentLength; // Length of track between this station and the next.
159     uint16_t SegmentTime;  // Time for train to reach the next station from this station.
160     uint8_t QueueTime;
161     uint16_t QueueLength;
162     uint16_t LastPeepInQueue;
163 
164     static constexpr uint8_t NO_TRAIN = std::numeric_limits<uint8_t>::max();
165 
166     int32_t GetBaseZ() const;
167     void SetBaseZ(int32_t newZ);
168     CoordsXYZ GetStart() const;
169 };
170 
171 struct RideMeasurement
172 {
173     static constexpr size_t MAX_ITEMS = 4800;
174 
175     uint8_t flags{};
176     uint32_t last_use_tick{};
177     uint16_t num_items{};
178     uint16_t current_item{};
179     uint8_t vehicle_index{};
180     StationIndex current_station{};
181     int8_t vertical[MAX_ITEMS]{};
182     int8_t lateral[MAX_ITEMS]{};
183     uint8_t velocity[MAX_ITEMS]{};
184     uint8_t altitude[MAX_ITEMS]{};
185 };
186 
187 enum class RideClassification
188 {
189     Ride,
190     ShopOrStall,
191     KioskOrFacility
192 };
193 
194 namespace ShelteredSectionsBits
195 {
196     constexpr const uint8_t NumShelteredSectionsMask = 0b00011111;
197     constexpr const uint8_t RotatingWhileSheltered = 0b00100000;
198     constexpr const uint8_t BankingWhileSheltered = 0b01000000;
199 }; // namespace ShelteredSectionsBits
200 
201 struct TrackDesign;
202 enum class RideMode : uint8_t;
203 enum class RideStatus : uint8_t;
204 
205 /**
206  * Ride structure.
207  *
208  * This is based on RCT2's ride structure.
209  * Padding and no longer used fields have been removed.
210  */
211 struct Ride
212 {
213     ride_id_t id = RIDE_ID_NULL;
214     uint8_t type = RIDE_TYPE_NULL;
215     // pointer to static info. for example, wild mouse type is 0x36, subtype is
216     // 0x4c.
217     ObjectEntryIndex subtype;
218     RideMode mode;
219     uint8_t colour_scheme_type;
220     VehicleColour vehicle_colours[MAX_VEHICLE_COLOURS];
221     // 0 = closed, 1 = open, 2 = test
222     RideStatus status;
223     std::string custom_name;
224     uint16_t default_name_number;
225     CoordsXY overall_view;
226     uint16_t vehicles[MAX_VEHICLES_PER_RIDE + 1]; // Points to the first car in the train
227     uint8_t depart_flags;
228     uint8_t num_stations;
229     uint8_t num_vehicles;
230     uint8_t num_cars_per_train;
231     uint8_t proposed_num_vehicles;
232     uint8_t proposed_num_cars_per_train;
233     uint8_t max_trains;
234     uint8_t MinCarsPerTrain;
235     uint8_t MaxCarsPerTrain;
236     uint8_t min_waiting_time;
237     uint8_t max_waiting_time;
238     union
239     {
240         uint8_t operation_option;
241         uint8_t time_limit;
242         uint8_t num_laps;
243         uint8_t launch_speed;
244         uint8_t speed;
245         uint8_t rotations;
246     };
247 
248     uint8_t boat_hire_return_direction;
249     TileCoordsXY boat_hire_return_position;
250     // bits 0 through 4 are the number of helix sections
251     // bit 5: spinning tunnel, water splash, or rapids
252     // bit 6: log reverser, waterfall
253     // bit 7: whirlpool
254     uint8_t special_track_elements;
255     // Divide this value by 29127 to get the human-readable max speed
256     // (in RCT2, display_speed = (max_speed * 9) >> 18)
257     int32_t max_speed;
258     int32_t average_speed;
259     uint8_t current_test_segment;
260     uint8_t average_speed_test_timeout;
261     fixed16_2dp max_positive_vertical_g;
262     fixed16_2dp max_negative_vertical_g;
263     fixed16_2dp max_lateral_g;
264     fixed16_2dp previous_vertical_g;
265     fixed16_2dp previous_lateral_g;
266     uint32_t testing_flags;
267     // x y z map location of the current track piece during a test
268     // this is to prevent counting special tracks multiple times
269     TileCoordsXYZ CurTestTrackLocation;
270     // Next 3 variables are related (XXXX XYYY ZZZa aaaa)
271     uint16_t turn_count_default; // X = current turn count
272     uint16_t turn_count_banked;
273     uint16_t turn_count_sloped; // X = number turns > 3 elements
274     // Y is number of powered lifts, X is drops
275     uint8_t drops; // (YYXX XXXX)
276     uint8_t start_drop_height;
277     uint8_t highest_drop_height;
278     int32_t sheltered_length;
279     // Unused always 0? Should affect nausea
280     uint16_t var_11C;
281     uint8_t num_sheltered_sections; // (?abY YYYY)
282     // Customer counter in the current 960 game tick (about 30 seconds) interval
283     uint16_t cur_num_customers;
284     // Counts ticks to update customer intervals, resets each 960 game ticks.
285     uint16_t num_customers_timeout;
286     // Customer count in the last 10 * 960 game ticks (sliding window)
287     uint16_t num_customers[CUSTOMER_HISTORY_SIZE];
288     money16 price[NUM_SHOP_ITEMS_PER_RIDE];
289     TileCoordsXYZ ChairliftBullwheelLocation[2];
290     union
291     {
292         RatingTuple ratings;
293         struct
294         {
295             ride_rating excitement;
296             ride_rating intensity;
297             ride_rating nausea;
298         };
299     };
300     uint16_t value;
301     uint16_t chairlift_bullwheel_rotation;
302     uint8_t satisfaction;
303     uint8_t satisfaction_time_out;
304     uint8_t satisfaction_next;
305     // Various flags stating whether a window needs to be refreshed
306     uint8_t window_invalidate_flags;
307     uint32_t total_customers;
308     money64 total_profit;
309     uint8_t popularity;
310     uint8_t popularity_time_out; // Updated every purchase and ?possibly by time?
311     uint8_t popularity_next;     // When timeout reached this will be the next popularity
312     uint16_t num_riders;
313     uint8_t music_tune_id;
314     uint8_t slide_in_use;
315     union
316     {
317         uint16_t slide_peep;
318         uint16_t maze_tiles;
319     };
320     uint8_t slide_peep_t_shirt_colour;
321     uint8_t spiral_slide_progress;
322     int32_t build_date;
323     money16 upkeep_cost;
324     uint16_t race_winner;
325     uint32_t music_position;
326     uint8_t breakdown_reason_pending;
327     uint8_t mechanic_status;
328     uint16_t mechanic;
329     StationIndex inspection_station;
330     uint8_t broken_vehicle;
331     uint8_t broken_car;
332     uint8_t breakdown_reason;
333     union
334     {
335         struct
336         {
337             uint8_t reliability_subvalue;   // 0 - 255, acts like the decimals for reliability_percentage
338             uint8_t reliability_percentage; // Starts at 100 and decreases from there.
339         };
340         uint16_t reliability;
341     };
342     // Small constant used to increase the unreliability as the game continues,
343     // making breakdowns more and more likely.
344     uint8_t unreliability_factor;
345     // Range from [0, 100]
346     uint8_t downtime;
347     uint8_t inspection_interval;
348     uint8_t last_inspection;
349     uint8_t downtime_history[DOWNTIME_HISTORY_SIZE];
350     uint32_t no_primary_items_sold;
351     uint32_t no_secondary_items_sold;
352     uint8_t breakdown_sound_modifier;
353     // Used to oscillate the sound when ride breaks down.
354     // 0 = no change, 255 = max change
355     uint8_t not_fixed_timeout;
356     uint8_t last_crash_type;
357     uint8_t connected_message_throttle;
358     money64 income_per_hour;
359     money64 profit;
360     TrackColour track_colour[NUM_COLOUR_SCHEMES];
361     ObjectEntryIndex music;
362     ObjectEntryIndex entrance_style;
363     uint16_t vehicle_change_timeout;
364     uint8_t num_block_brakes;
365     uint8_t lift_hill_speed;
366     uint16_t guests_favourite;
367     uint32_t lifecycle_flags;
368     uint16_t total_air_time;
369     StationIndex current_test_station;
370     uint8_t num_circuits;
371     CoordsXYZ CableLiftLoc;
372     uint16_t cable_lift;
373     // These fields are used to warn users about issues.
374     // Such issue can be hacked rides with incompatible options set.
375     // They don't require export/import.
376     uint8_t current_issues;
377     uint32_t last_issue_time;
378     RideStation stations[MAX_STATIONS];
379     uint16_t inversions;
380     uint16_t holes;
381     uint8_t sheltered_eighths;
382 
383     std::unique_ptr<RideMeasurement> measurement;
384 
385 private:
386     void Update();
387     void UpdateChairlift();
388     void UpdateSpiralSlide();
389     void UpdateQueueLength(StationIndex stationIndex);
390     bool CreateVehicles(const CoordsXYE& element, bool isApplying);
391     void MoveTrainsToBlockBrakes(TrackElement* firstBlock);
392     money64 CalculateIncomePerHour() const;
393     void ChainQueues() const;
394     void ConstructMissingEntranceOrExit() const;
395 
396 public:
397     bool CanBreakDown() const;
398     RideClassification GetClassification() const;
399     bool IsRide() const;
400     void Renew();
401     void Delete();
402     void Crash(uint8_t vehicleIndex);
403     void SetToDefaultInspectionInterval();
404     void SetRideEntry(int32_t rideEntry);
405 
406     void SetNumVehicles(int32_t numVehicles);
407     void SetNumCarsPerVehicle(int32_t numCarsPerVehicle);
408     void UpdateMaxVehicles();
409     void UpdateNumberOfCircuits();
410 
411     bool HasSpinningTunnel() const;
412     bool HasWaterSplash() const;
413     bool HasRapids() const;
414     bool HasLogReverser() const;
415     bool HasWaterfall() const;
416     bool HasWhirlpool() const;
417 
418     bool IsPoweredLaunched() const;
419     bool IsBlockSectioned() const;
420     bool CanHaveMultipleCircuits() const;
421     bool SupportsStatus(RideStatus s) const;
422 
423     void StopGuestsQueuing();
424     void ValidateStations();
425 
426     bool Open(bool isApplying);
427     bool Test(RideStatus newStatus, bool isApplying);
428 
429     RideMode GetDefaultMode() const;
430 
431     void SetColourPreset(uint8_t index);
432 
433     rct_ride_entry* GetRideEntry() const;
434 
435     size_t GetNumPrices() const;
436     int32_t GetAge() const;
437     int32_t GetTotalQueueLength() const;
438     int32_t GetMaxQueueTime() const;
439 
440     void QueueInsertGuestAtFront(StationIndex stationIndex, Guest* peep);
441     Guest* GetQueueHeadGuest(StationIndex stationIndex) const;
442 
443     void SetNameToDefault();
444     std::string GetName() const;
445     void FormatNameTo(Formatter&) const;
446     void FormatStatusTo(Formatter&) const;
447 
448     static void UpdateAll();
449     static bool NameExists(std::string_view name, ride_id_t excludeRideId = RIDE_ID_NULL);
450 
451     [[nodiscard]] std::unique_ptr<TrackDesign> SaveToTrackDesign() const;
452 
453     uint64_t GetAvailableModes() const;
454     const RideTypeDescriptor& GetRideTypeDescriptor() const;
455     TrackElement* GetOriginElement(StationIndex stationIndex) const;
456 
457     std::pair<RideMeasurement*, OpenRCT2String> GetMeasurement();
458 
459     uint8_t GetNumShelteredSections() const;
460     void IncreaseNumShelteredSections();
461 
462     void RemoveVehicles();
463     /**
464      * Updates all pieces of the ride to match the internal ride type. (Track pieces can have different ride types from the ride
465      * they belong to, to enable “merging”.)
466      */
467     void UpdateRideTypeForAllPieces();
468 };
469 
470 #pragma pack(push, 1)
471 
472 struct track_begin_end
473 {
474     int32_t begin_x;
475     int32_t begin_y;
476     int32_t begin_z;
477     int32_t begin_direction;
478     TileElement* begin_element;
479     int32_t end_x;
480     int32_t end_y;
481     int32_t end_direction;
482     TileElement* end_element;
483 };
484 #ifdef PLATFORM_32BIT
485 assert_struct_size(track_begin_end, 36);
486 #endif
487 
488 struct ride_name_args
489 {
490     uint16_t type_name;
491     uint16_t number;
492 };
493 assert_struct_size(ride_name_args, 4);
494 
495 #pragma pack(pop)
496 
497 // Constants used by the lifecycle_flags property at 0x1D0
498 enum
499 {
500     RIDE_LIFECYCLE_ON_TRACK = 1 << 0,
501     RIDE_LIFECYCLE_TESTED = 1 << 1,
502     RIDE_LIFECYCLE_TEST_IN_PROGRESS = 1 << 2,
503     RIDE_LIFECYCLE_NO_RAW_STATS = 1 << 3,
504     RIDE_LIFECYCLE_PASS_STATION_NO_STOPPING = 1 << 4,
505     RIDE_LIFECYCLE_ON_RIDE_PHOTO = 1 << 5,
506     RIDE_LIFECYCLE_BREAKDOWN_PENDING = 1 << 6,
507     RIDE_LIFECYCLE_BROKEN_DOWN = 1 << 7,
508     RIDE_LIFECYCLE_DUE_INSPECTION = 1 << 8,
509     RIDE_LIFECYCLE_QUEUE_FULL = 1 << 9,
510     RIDE_LIFECYCLE_CRASHED = 1 << 10,
511     RIDE_LIFECYCLE_HAS_STALLED_VEHICLE = 1 << 11,
512     RIDE_LIFECYCLE_EVER_BEEN_OPENED = 1 << 12,
513     RIDE_LIFECYCLE_MUSIC = 1 << 13,
514     RIDE_LIFECYCLE_INDESTRUCTIBLE = 1 << 14,
515     RIDE_LIFECYCLE_INDESTRUCTIBLE_TRACK = 1 << 15,
516     RIDE_LIFECYCLE_CABLE_LIFT_HILL_COMPONENT_USED = 1 << 16,
517     RIDE_LIFECYCLE_CABLE_LIFT = 1 << 17,
518     RIDE_LIFECYCLE_NOT_CUSTOM_DESIGN = 1 << 18,   // Used for the Award for Best Custom-designed Rides
519     RIDE_LIFECYCLE_SIX_FLAGS_DEPRECATED = 1 << 19 // Not used anymore
520 };
521 
522 // Constants used by the ride_type->flags property at 0x008
523 enum
524 {
525     RIDE_ENTRY_FLAG_VEHICLE_TAB_SCALE_HALF = 1 << 0,
526     RIDE_ENTRY_FLAG_NO_INVERSIONS = 1 << 1,
527     RIDE_ENTRY_FLAG_NO_BANKED_TRACK = 1 << 2,
528     RIDE_ENTRY_FLAG_PLAY_DEPART_SOUND = 1 << 3,
529     RIDE_ENTRY_FLAG_ALTERNATIVE_SWING_MODE_1 = 1 << 4,
530     // Twist type rotation ride
531     RIDE_ENTRY_FLAG_ALTERNATIVE_ROTATION_MODE_1 = 1 << 5,
532     // Lifting arm rotation ride (enterprise)
533     RIDE_ENTRY_FLAG_ALTERNATIVE_ROTATION_MODE_2 = 1 << 6,
534     RIDE_ENTRY_FLAG_DISABLE_WANDERING_DEPRECATED = 1 << 7,
535     RIDE_ENTRY_FLAG_PLAY_SPLASH_SOUND = 1 << 8,
536     RIDE_ENTRY_FLAG_PLAY_SPLASH_SOUND_SLIDE = 1 << 9,
537     RIDE_ENTRY_FLAG_COVERED_RIDE = 1 << 10,
538     RIDE_ENTRY_FLAG_LIMIT_AIRTIME_BONUS = 1 << 11,
539     RIDE_ENTRY_FLAG_SEPARATE_RIDE_NAME_DEPRECATED = 1 << 12, // Always set with SEPARATE_RIDE, and deprecated in favour of it.
540     RIDE_ENTRY_FLAG_SEPARATE_RIDE_DEPRECATED = 1 << 13,      // Made redundant by ride groups
541     RIDE_ENTRY_FLAG_CANNOT_BREAK_DOWN = 1 << 14,
542     RIDE_ENTRY_DISABLE_LAST_OPERATING_MODE_DEPRECATED = 1 << 15,
543     RIDE_ENTRY_FLAG_DISABLE_DOOR_CONSTRUCTION_DEPRECATED = 1 << 16,
544     RIDE_ENTRY_DISABLE_FIRST_TWO_OPERATING_MODES_DEPRECATED = 1 << 17,
545     RIDE_ENTRY_FLAG_DISABLE_COLLISION_CRASHES = 1 << 18,
546     RIDE_ENTRY_FLAG_DISABLE_COLOUR_TAB = 1 << 19,
547     // Must be set with swing mode 1 as well.
548     RIDE_ENTRY_FLAG_ALTERNATIVE_SWING_MODE_2 = 1 << 20,
549 };
550 
551 enum
552 {
553     RIDE_TESTING_SHELTERED = (1 << 0),
554     RIDE_TESTING_TURN_LEFT = (1 << 1),
555     RIDE_TESTING_TURN_RIGHT = (1 << 2),
556     RIDE_TESTING_TURN_BANKED = (1 << 3),
557     RIDE_TESTING_TURN_SLOPED = (1 << 4),
558     RIDE_TESTING_DROP_DOWN = (1 << 5),
559     RIDE_TESTING_POWERED_LIFT = (1 << 6),
560     RIDE_TESTING_DROP_UP = (1 << 7),
561 };
562 
563 enum
564 {
565     RIDE_TYPE_SPIRAL_ROLLER_COASTER = 0,
566     RIDE_TYPE_STAND_UP_ROLLER_COASTER,
567     RIDE_TYPE_SUSPENDED_SWINGING_COASTER,
568     RIDE_TYPE_INVERTED_ROLLER_COASTER,
569     RIDE_TYPE_JUNIOR_ROLLER_COASTER,
570     RIDE_TYPE_MINIATURE_RAILWAY,
571     RIDE_TYPE_MONORAIL,
572     RIDE_TYPE_MINI_SUSPENDED_COASTER,
573     RIDE_TYPE_BOAT_HIRE,
574     RIDE_TYPE_WOODEN_WILD_MOUSE,
575     RIDE_TYPE_STEEPLECHASE = 10,
576     RIDE_TYPE_CAR_RIDE,
577     RIDE_TYPE_LAUNCHED_FREEFALL,
578     RIDE_TYPE_BOBSLEIGH_COASTER,
579     RIDE_TYPE_OBSERVATION_TOWER,
580     RIDE_TYPE_LOOPING_ROLLER_COASTER,
581     RIDE_TYPE_DINGHY_SLIDE,
582     RIDE_TYPE_MINE_TRAIN_COASTER,
583     RIDE_TYPE_CHAIRLIFT,
584     RIDE_TYPE_CORKSCREW_ROLLER_COASTER,
585     RIDE_TYPE_MAZE = 20,
586     RIDE_TYPE_SPIRAL_SLIDE,
587     RIDE_TYPE_GO_KARTS,
588     RIDE_TYPE_LOG_FLUME,
589     RIDE_TYPE_RIVER_RAPIDS,
590     RIDE_TYPE_DODGEMS,
591     RIDE_TYPE_SWINGING_SHIP,
592     RIDE_TYPE_SWINGING_INVERTER_SHIP,
593     RIDE_TYPE_FOOD_STALL,
594     RIDE_TYPE_1D,
595     RIDE_TYPE_DRINK_STALL = 30,
596     RIDE_TYPE_1F,
597     RIDE_TYPE_SHOP,
598     RIDE_TYPE_MERRY_GO_ROUND,
599     RIDE_TYPE_22,
600     RIDE_TYPE_INFORMATION_KIOSK,
601     RIDE_TYPE_TOILETS,
602     RIDE_TYPE_FERRIS_WHEEL,
603     RIDE_TYPE_MOTION_SIMULATOR,
604     RIDE_TYPE_3D_CINEMA,
605     RIDE_TYPE_TOP_SPIN = 40,
606     RIDE_TYPE_SPACE_RINGS,
607     RIDE_TYPE_REVERSE_FREEFALL_COASTER,
608     RIDE_TYPE_LIFT,
609     RIDE_TYPE_VERTICAL_DROP_ROLLER_COASTER,
610     RIDE_TYPE_CASH_MACHINE,
611     RIDE_TYPE_TWIST,
612     RIDE_TYPE_HAUNTED_HOUSE,
613     RIDE_TYPE_FIRST_AID,
614     RIDE_TYPE_CIRCUS,
615     RIDE_TYPE_GHOST_TRAIN = 50,
616     RIDE_TYPE_TWISTER_ROLLER_COASTER,
617     RIDE_TYPE_WOODEN_ROLLER_COASTER,
618     RIDE_TYPE_SIDE_FRICTION_ROLLER_COASTER,
619     RIDE_TYPE_STEEL_WILD_MOUSE,
620     RIDE_TYPE_MULTI_DIMENSION_ROLLER_COASTER,
621     RIDE_TYPE_MULTI_DIMENSION_ROLLER_COASTER_ALT,
622     RIDE_TYPE_FLYING_ROLLER_COASTER,
623     RIDE_TYPE_FLYING_ROLLER_COASTER_ALT,
624     RIDE_TYPE_VIRGINIA_REEL,
625     RIDE_TYPE_SPLASH_BOATS = 60,
626     RIDE_TYPE_MINI_HELICOPTERS,
627     RIDE_TYPE_LAY_DOWN_ROLLER_COASTER,
628     RIDE_TYPE_SUSPENDED_MONORAIL,
629     RIDE_TYPE_LAY_DOWN_ROLLER_COASTER_ALT,
630     RIDE_TYPE_REVERSER_ROLLER_COASTER,
631     RIDE_TYPE_HEARTLINE_TWISTER_COASTER,
632     RIDE_TYPE_MINI_GOLF,
633     RIDE_TYPE_GIGA_COASTER,
634     RIDE_TYPE_ROTO_DROP,
635     RIDE_TYPE_FLYING_SAUCERS = 70,
636     RIDE_TYPE_CROOKED_HOUSE,
637     RIDE_TYPE_MONORAIL_CYCLES,
638     RIDE_TYPE_COMPACT_INVERTED_COASTER,
639     RIDE_TYPE_WATER_COASTER,
640     RIDE_TYPE_AIR_POWERED_VERTICAL_COASTER,
641     RIDE_TYPE_INVERTED_HAIRPIN_COASTER,
642     RIDE_TYPE_MAGIC_CARPET,
643     RIDE_TYPE_SUBMARINE_RIDE,
644     RIDE_TYPE_RIVER_RAFTS,
645     RIDE_TYPE_50 = 80,
646     RIDE_TYPE_ENTERPRISE,
647     RIDE_TYPE_52,
648     RIDE_TYPE_53,
649     RIDE_TYPE_54,
650     RIDE_TYPE_55,
651     RIDE_TYPE_INVERTED_IMPULSE_COASTER,
652     RIDE_TYPE_MINI_ROLLER_COASTER,
653     RIDE_TYPE_MINE_RIDE,
654     RIDE_TYPE_59,
655     RIDE_TYPE_LIM_LAUNCHED_ROLLER_COASTER = 90,
656     RIDE_TYPE_HYPERCOASTER,
657     RIDE_TYPE_HYPER_TWISTER,
658     RIDE_TYPE_MONSTER_TRUCKS,
659     RIDE_TYPE_SPINNING_WILD_MOUSE,
660     RIDE_TYPE_CLASSIC_MINI_ROLLER_COASTER,
661     RIDE_TYPE_HYBRID_COASTER,
662     RIDE_TYPE_SINGLE_RAIL_ROLLER_COASTER,
663 
664     RIDE_TYPE_COUNT
665 };
666 
667 enum class RideStatus : uint8_t
668 {
669     Closed,
670     Open,
671     Testing,
672     Simulating,
673     Count,
674 };
675 
676 enum class RideMode : uint8_t
677 {
678     Normal,
679     ContinuousCircuit,
680     ReverseInclineLaunchedShuttle,
681     PoweredLaunchPasstrough, // RCT2 style, pass through station
682     Shuttle,
683     BoatHire,
684     UpwardLaunch,
685     RotatingLift,
686     StationToStation,
687     SingleRidePerAdmission,
688     UnlimitedRidesPerAdmission = 10,
689     Maze,
690     Race,
691     Dodgems,
692     Swing,
693     ShopStall,
694     Rotation,
695     ForwardRotation,
696     BackwardRotation,
697     FilmAvengingAviators,
698     MouseTails3DFilm = 20,
699     SpaceRings,
700     Beginners,
701     LimPoweredLaunch,
702     FilmThrillRiders,
703     StormChasers3DFilm,
704     SpaceRaiders3DFilm,
705     Intense,
706     Berserk,
707     HauntedHouse,
708     Circus = 30,
709     DownwardLaunch,
710     CrookedHouse,
711     FreefallDrop,
712     ContinuousCircuitBlockSectioned,
713     PoweredLaunch, // RCT1 style, don't pass through station
714     PoweredLaunchBlockSectioned,
715 
716     Count,
717     NullMode = 255,
718 };
719 
720 RideMode& operator++(RideMode& d, int);
721 
722 enum
723 {
724     RIDE_COLOUR_SCHEME_ALL_SAME,
725     RIDE_COLOUR_SCHEME_DIFFERENT_PER_TRAIN,
726     RIDE_COLOUR_SCHEME_DIFFERENT_PER_CAR
727 };
728 
729 enum
730 {
731     RIDE_CATEGORY_TRANSPORT,
732     RIDE_CATEGORY_GENTLE,
733     RIDE_CATEGORY_ROLLERCOASTER,
734     RIDE_CATEGORY_THRILL,
735     RIDE_CATEGORY_WATER,
736     RIDE_CATEGORY_SHOP,
737 
738     RIDE_CATEGORY_NONE = 255,
739 };
740 
741 enum
742 {
743     MUSIC_STYLE_DODGEMS_BEAT,
744     MUSIC_STYLE_FAIRGROUND_ORGAN,
745     MUSIC_STYLE_ROMAN_FANFARE,
746     MUSIC_STYLE_ORIENTAL,
747     MUSIC_STYLE_MARTIAN,
748     MUSIC_STYLE_JUNGLE_DRUMS,
749     MUSIC_STYLE_EGYPTIAN,
750     MUSIC_STYLE_TOYLAND,
751     MUSIC_STYLE_CIRCUS_SHOW,
752     MUSIC_STYLE_SPACE,
753     MUSIC_STYLE_HORROR,
754     MUSIC_STYLE_TECHNO,
755     MUSIC_STYLE_GENTLE,
756     MUSIC_STYLE_SUMMER,
757     MUSIC_STYLE_WATER,
758     MUSIC_STYLE_WILD_WEST,
759     MUSIC_STYLE_JURASSIC,
760     MUSIC_STYLE_ROCK,
761     MUSIC_STYLE_RAGTIME,
762     MUSIC_STYLE_FANTASY,
763     MUSIC_STYLE_ROCK_STYLE_2,
764     MUSIC_STYLE_ICE,
765     MUSIC_STYLE_SNOW,
766     MUSIC_STYLE_CUSTOM_MUSIC_1,
767     MUSIC_STYLE_CUSTOM_MUSIC_2,
768     MUSIC_STYLE_MEDIEVAL,
769     MUSIC_STYLE_URBAN,
770     MUSIC_STYLE_ORGAN,
771     MUSIC_STYLE_MECHANICAL,
772     MUSIC_STYLE_MODERN,
773     MUSIC_STYLE_PIRATES,
774     MUSIC_STYLE_ROCK_STYLE_3,
775     MUSIC_STYLE_CANDY_STYLE,
776     MUSIC_STYLE_COUNT
777 };
778 
779 enum
780 {
781     BREAKDOWN_NONE = 255,
782     BREAKDOWN_SAFETY_CUT_OUT = 0,
783     BREAKDOWN_RESTRAINTS_STUCK_CLOSED,
784     BREAKDOWN_RESTRAINTS_STUCK_OPEN,
785     BREAKDOWN_DOORS_STUCK_CLOSED,
786     BREAKDOWN_DOORS_STUCK_OPEN,
787     BREAKDOWN_VEHICLE_MALFUNCTION,
788     BREAKDOWN_BRAKES_FAILURE,
789     BREAKDOWN_CONTROL_FAILURE,
790 
791     BREAKDOWN_COUNT
792 };
793 
794 enum
795 {
796     RIDE_MECHANIC_STATUS_UNDEFINED,
797     RIDE_MECHANIC_STATUS_CALLING,
798     RIDE_MECHANIC_STATUS_HEADING,
799     RIDE_MECHANIC_STATUS_FIXING,
800     RIDE_MECHANIC_STATUS_HAS_FIXED_STATION_BRAKES
801 };
802 
803 enum
804 {
805     RIDE_DEPART_WAIT_FOR_LOAD_MASK = 7,
806     RIDE_DEPART_WAIT_FOR_LOAD = 1 << 3,
807     RIDE_DEPART_LEAVE_WHEN_ANOTHER_ARRIVES = 1 << 4,
808     RIDE_DEPART_SYNCHRONISE_WITH_ADJACENT_STATIONS = 1 << 5,
809     RIDE_DEPART_WAIT_FOR_MINIMUM_LENGTH = 1 << 6,
810     RIDE_DEPART_WAIT_FOR_MAXIMUM_LENGTH = 1 << 7
811 };
812 
813 enum
814 {
815     WAIT_FOR_LOAD_QUARTER,
816     WAIT_FOR_LOAD_HALF,
817     WAIT_FOR_LOAD_THREE_QUARTER,
818     WAIT_FOR_LOAD_FULL,
819     WAIT_FOR_LOAD_ANY,
820 };
821 
822 enum
823 {
824     RIDE_COLOUR_SCHEME_MAIN,
825     RIDE_COLOUR_SCHEME_ADDITIONAL_1,
826     RIDE_COLOUR_SCHEME_ADDITIONAL_2,
827     RIDE_COLOUR_SCHEME_ADDITIONAL_3
828 };
829 
830 enum
831 {
832     VEHICLE_COLOUR_SCHEME_SAME,
833     VEHICLE_COLOUR_SCHEME_PER_TRAIN,
834     VEHICLE_COLOUR_SCHEME_PER_VEHICLE
835 };
836 
837 enum
838 {
839     RIDE_INSPECTION_EVERY_10_MINUTES,
840     RIDE_INSPECTION_EVERY_20_MINUTES,
841     RIDE_INSPECTION_EVERY_30_MINUTES,
842     RIDE_INSPECTION_EVERY_45_MINUTES,
843     RIDE_INSPECTION_EVERY_HOUR,
844     RIDE_INSPECTION_EVERY_2_HOURS,
845     RIDE_INSPECTION_NEVER
846 };
847 
848 // Flags used by ride->window_invalidate_flags
849 enum
850 {
851     RIDE_INVALIDATE_RIDE_CUSTOMER = 1,
852     RIDE_INVALIDATE_RIDE_INCOME = 1 << 1,
853     RIDE_INVALIDATE_RIDE_MAIN = 1 << 2,
854     RIDE_INVALIDATE_RIDE_LIST = 1 << 3,
855     RIDE_INVALIDATE_RIDE_OPERATING = 1 << 4,
856     RIDE_INVALIDATE_RIDE_MAINTENANCE = 1 << 5,
857 };
858 
859 enum
860 {
861     RIDE_MEASUREMENT_FLAG_RUNNING = 1 << 0,
862     RIDE_MEASUREMENT_FLAG_UNLOADING = 1 << 1,
863     RIDE_MEASUREMENT_FLAG_G_FORCES = 1 << 2
864 };
865 
866 // Constants for ride->special_track_elements
867 enum
868 {
869     RIDE_ELEMENT_TUNNEL_SPLASH_OR_RAPIDS = 1 << 5,
870     RIDE_ELEMENT_REVERSER_OR_WATERFALL = 1 << 6,
871     RIDE_ELEMENT_WHIRLPOOL = 1 << 7
872 };
873 
874 enum
875 {
876     RIDE_CRASH_TYPE_NONE = 0,
877     RIDE_CRASH_TYPE_NO_FATALITIES = 2,
878     RIDE_CRASH_TYPE_FATALITIES = 8
879 };
880 
881 enum class RideConstructionState : uint8_t
882 {
883     State0,
884     Front,
885     Back,
886     Selected,
887     Place,
888     EntranceExit,
889     MazeBuild,
890     MazeMove,
891     MazeFill
892 };
893 
894 enum
895 {
896     RIDE_SET_VEHICLES_COMMAND_TYPE_NUM_TRAINS,
897     RIDE_SET_VEHICLES_COMMAND_TYPE_NUM_CARS_PER_TRAIN,
898     RIDE_SET_VEHICLES_COMMAND_TYPE_RIDE_ENTRY
899 };
900 
901 enum
902 {
903     RIDE_SETTING_MODE,
904     RIDE_SETTING_DEPARTURE,
905     RIDE_SETTING_MIN_WAITING_TIME,
906     RIDE_SETTING_MAX_WAITING_TIME,
907     RIDE_SETTING_OPERATION_OPTION,
908     RIDE_SETTING_INSPECTION_INTERVAL,
909     RIDE_SETTING_MUSIC,
910     RIDE_SETTING_MUSIC_TYPE,
911     RIDE_SETTING_LIFT_HILL_SPEED,
912     RIDE_SETTING_NUM_CIRCUITS,
913     RIDE_SETTING_RIDE_TYPE,
914 };
915 
916 enum
917 {
918     MAZE_WALL_TYPE_BRICK,
919     MAZE_WALL_TYPE_HEDGE,
920     MAZE_WALL_TYPE_ICE,
921     MAZE_WALL_TYPE_WOOD,
922 };
923 
924 enum
925 {
926     TRACK_SELECTION_FLAG_ARROW = 1 << 0,
927     TRACK_SELECTION_FLAG_TRACK = 1 << 1,
928     TRACK_SELECTION_FLAG_ENTRANCE_OR_EXIT = 1 << 2,
929     TRACK_SELECTION_FLAG_RECHECK = 1 << 3,
930     TRACK_SELECTION_FLAG_TRACK_PLACE_ACTION_QUEUED = 1 << 4,
931 };
932 
933 enum
934 {
935     RIDE_MODIFY_DEMOLISH,
936     RIDE_MODIFY_RENEW,
937 };
938 
939 enum
940 {
941     RIDE_ISSUE_NONE = 0,
942     RIDE_ISSUE_GUESTS_STUCK = (1 << 0),
943 };
944 
945 enum
946 {
947     TRACK_BLOCK_2 = (1 << 2)
948 };
949 
950 enum
951 {
952     TRACK_ELEMENT_SET_HIGHLIGHT_FALSE = (1 << 0),
953     TRACK_ELEMENT_SET_HIGHLIGHT_TRUE = (1 << 1),
954     TRACK_ELEMENT_SET_COLOUR_SCHEME = (1 << 2),
955     TRACK_ELEMENT_SET_HAS_CABLE_LIFT_TRUE = (1 << 3),
956     TRACK_ELEMENT_SET_HAS_CABLE_LIFT_FALSE = (1 << 4),
957     TRACK_ELEMENT_SET_SEAT_ROTATION = (1 << 5)
958 };
959 
960 struct RideOperatingSettings
961 {
962     uint8_t MinValue;
963     uint8_t MaxValue;
964     uint8_t MaxBrakesSpeed;
965     uint8_t PoweredLiftAcceleration;
966     uint8_t BoosterAcceleration;
967     int8_t BoosterSpeedFactor; // The factor to shift the raw booster speed with
968 };
969 
970 #define MAX_RIDE_MEASUREMENTS 8
971 #define RIDE_VALUE_UNDEFINED 0xFFFF
972 #define RIDE_INITIAL_RELIABILITY ((100 << 8) | 0xFF) // Upper byte is percentage, lower byte is "decimal".
973 
974 #define STATION_DEPART_FLAG (1 << 7)
975 #define STATION_DEPART_MASK (~STATION_DEPART_FLAG)
976 
977 #define CURRENT_TURN_COUNT_MASK 0xF800
978 #define TURN_MASK_1_ELEMENT 0x001F
979 #define TURN_MASK_2_ELEMENTS 0x00E0
980 #define TURN_MASK_3_ELEMENTS 0x0700
981 #define TURN_MASK_4_PLUS_ELEMENTS 0xF800
982 
983 constexpr uint32_t CONSTRUCTION_LIFT_HILL_SELECTED = 1 << 0;
984 constexpr uint32_t CONSTRUCTION_INVERTED_TRACK_SELECTED = 1 << 1;
985 
986 Ride* get_ride(ride_id_t index);
987 
988 struct RideManager
989 {
990     const Ride* operator[](ride_id_t id) const
991     {
992         return get_ride(id);
993     }
994 
995     Ride* operator[](ride_id_t id)
996     {
997         return get_ride(id);
998     }
999 
1000     class Iterator
1001     {
1002         friend RideManager;
1003 
1004     private:
1005         RideManager* _rideManager;
1006         size_t _index{};
1007         size_t _endIndex{};
1008 
1009     public:
1010         using difference_type = intptr_t;
1011         using value_type = Ride;
1012         using pointer = const Ride*;
1013         using reference = const Ride&;
1014         using iterator_category = std::forward_iterator_tag;
1015 
1016     private:
IteratorRideManager1017         Iterator(RideManager& rideManager, size_t beginIndex, size_t endIndex)
1018             : _rideManager(&rideManager)
1019             , _index(beginIndex)
1020             , _endIndex(endIndex)
1021         {
1022             if (_index < _endIndex && (*_rideManager)[static_cast<ride_id_t>(_index)] == nullptr)
1023             {
1024                 ++(*this);
1025             }
1026         }
1027 
1028     public:
1029         Iterator& operator++()
1030         {
1031             do
1032             {
1033                 _index++;
1034             } while (_index < _endIndex && (*_rideManager)[static_cast<ride_id_t>(_index)] == nullptr);
1035             return *this;
1036         }
1037         Iterator operator++(int)
1038         {
1039             auto result = *this;
1040             ++(*this);
1041             return result;
1042         }
1043         bool operator==(Iterator other) const
1044         {
1045             return _index == other._index;
1046         }
1047         bool operator!=(Iterator other) const
1048         {
1049             return !(*this == other);
1050         }
1051         Ride& operator*()
1052         {
1053             return *(*_rideManager)[static_cast<ride_id_t>(_index)];
1054         }
1055     };
1056 
1057     size_t size() const;
1058     Iterator begin();
1059     Iterator end();
beginRideManager1060     Iterator begin() const
1061     {
1062         return (const_cast<RideManager*>(this))->begin();
1063     }
endRideManager1064     Iterator end() const
1065     {
1066         return (const_cast<RideManager*>(this))->end();
1067     }
1068 };
1069 
1070 RideManager GetRideManager();
1071 ride_id_t GetNextFreeRideId();
1072 Ride* GetOrAllocateRide(ride_id_t index);
1073 rct_ride_entry* get_ride_entry(ObjectEntryIndex index);
1074 std::string_view get_ride_entry_name(ObjectEntryIndex index);
1075 
1076 extern money16 gTotalRideValueForMoney;
1077 
1078 extern const rct_string_id ColourSchemeNames[4];
1079 
1080 extern money32 _currentTrackPrice;
1081 
1082 extern uint16_t _numCurrentPossibleRideConfigurations;
1083 extern uint16_t _numCurrentPossibleSpecialTrackPieces;
1084 
1085 extern uint32_t _currentTrackCurve;
1086 extern RideConstructionState _rideConstructionState;
1087 extern ride_id_t _currentRideIndex;
1088 
1089 extern CoordsXYZ _currentTrackBegin;
1090 
1091 extern uint8_t _currentTrackPieceDirection;
1092 extern track_type_t _currentTrackPieceType;
1093 extern uint8_t _currentTrackSelectionFlags;
1094 extern uint32_t _rideConstructionNextArrowPulse;
1095 extern uint8_t _currentTrackSlopeEnd;
1096 extern uint8_t _currentTrackBankEnd;
1097 extern uint8_t _currentTrackLiftHill;
1098 extern uint8_t _currentTrackAlternative;
1099 extern track_type_t _selectedTrackType;
1100 
1101 extern uint8_t _previousTrackBankEnd;
1102 extern uint8_t _previousTrackSlopeEnd;
1103 
1104 extern CoordsXYZ _previousTrackPiece;
1105 
1106 extern uint8_t _currentBrakeSpeed2;
1107 extern uint8_t _currentSeatRotationAngle;
1108 
1109 extern CoordsXYZD _unkF440C5;
1110 
1111 extern uint8_t gRideEntranceExitPlaceType;
1112 extern ride_id_t gRideEntranceExitPlaceRideIndex;
1113 extern StationIndex gRideEntranceExitPlaceStationIndex;
1114 extern RideConstructionState gRideEntranceExitPlacePreviousRideConstructionState;
1115 extern uint8_t gRideEntranceExitPlaceDirection;
1116 
1117 extern bool gGotoStartPlacementMode;
1118 
1119 extern ObjectEntryIndex gLastEntranceStyle;
1120 
1121 int32_t ride_get_count();
1122 void ride_init_all();
1123 void reset_all_ride_build_dates();
1124 void ride_update_favourited_stat();
1125 void ride_check_all_reachable();
1126 void ride_update_satisfaction(Ride* ride, uint8_t happiness);
1127 void ride_update_popularity(Ride* ride, uint8_t pop_amount);
1128 bool ride_try_get_origin_element(const Ride* ride, CoordsXYE* output);
1129 int32_t ride_find_track_gap(const Ride* ride, CoordsXYE* input, CoordsXYE* output);
1130 void ride_construct_new(RideSelection listItem);
1131 void ride_construct(Ride* ride);
1132 bool ride_modify(CoordsXYE* input);
1133 void ride_remove_peeps(Ride* ride);
1134 void ride_clear_blocked_tiles(Ride* ride);
1135 Staff* ride_get_mechanic(Ride* ride);
1136 Staff* ride_get_assigned_mechanic(Ride* ride);
1137 int32_t ride_get_total_length(const Ride* ride);
1138 int32_t ride_get_total_time(Ride* ride);
1139 TrackColour ride_get_track_colour(Ride* ride, int32_t colourScheme);
1140 vehicle_colour ride_get_vehicle_colour(Ride* ride, int32_t vehicleIndex);
1141 int32_t ride_get_unused_preset_vehicle_colour(ObjectEntryIndex subType);
1142 void ride_set_vehicle_colours_to_random_preset(Ride* ride, uint8_t preset_index);
1143 void ride_measurements_update();
1144 void ride_breakdown_add_news_item(Ride* ride);
1145 Staff* ride_find_closest_mechanic(Ride* ride, int32_t forInspection);
1146 int32_t ride_initialise_construction_window(Ride* ride);
1147 void ride_construction_invalidate_current_track();
1148 std::optional<CoordsXYZ> GetTrackElementOriginAndApplyChanges(
1149     const CoordsXYZD& location, track_type_t type, uint16_t extra_params, TileElement** output_element, uint16_t flags);
1150 void ride_set_map_tooltip(TileElement* tileElement);
1151 void ride_prepare_breakdown(Ride* ride, int32_t breakdownReason);
1152 TileElement* ride_get_station_start_track_element(const Ride* ride, StationIndex stationIndex);
1153 TileElement* ride_get_station_exit_element(const CoordsXYZ& elementPos);
1154 void ride_set_status(Ride* ride, RideStatus status);
1155 void ride_set_name(Ride* ride, const char* name, uint32_t flags);
1156 int32_t ride_get_refund_price(const Ride* ride);
1157 int32_t ride_get_random_colour_preset_index(uint8_t ride_type);
1158 money32 ride_get_common_price(Ride* forRide);
1159 RideNaming get_ride_naming(const uint8_t rideType, rct_ride_entry* rideEntry);
1160 
1161 void ride_clear_for_construction(Ride* ride);
1162 void ride_entrance_exit_place_provisional_ghost();
1163 void ride_entrance_exit_remove_ghost();
1164 void ride_restore_provisional_track_piece();
1165 void ride_remove_provisional_track_piece();
1166 void set_vehicle_type_image_max_sizes(rct_ride_entry_vehicle* vehicle_type, int32_t num_images);
1167 void invalidate_test_results(Ride* ride);
1168 
1169 void ride_select_next_section();
1170 void ride_select_previous_section();
1171 
1172 void increment_turn_count_1_element(Ride* ride, uint8_t type);
1173 void increment_turn_count_2_elements(Ride* ride, uint8_t type);
1174 void increment_turn_count_3_elements(Ride* ride, uint8_t type);
1175 void increment_turn_count_4_plus_elements(Ride* ride, uint8_t type);
1176 int32_t get_turn_count_1_element(Ride* ride, uint8_t type);
1177 int32_t get_turn_count_2_elements(Ride* ride, uint8_t type);
1178 int32_t get_turn_count_3_elements(Ride* ride, uint8_t type);
1179 int32_t get_turn_count_4_plus_elements(Ride* ride, uint8_t type);
1180 
1181 uint8_t ride_get_helix_sections(Ride* ride);
1182 
1183 bool ride_has_any_track_elements(const Ride* ride);
1184 
1185 void ride_construction_set_default_next_piece();
1186 
1187 bool track_block_get_next(CoordsXYE* input, CoordsXYE* output, int32_t* z, int32_t* direction);
1188 bool track_block_get_next_from_zero(
1189     const CoordsXYZ& startPos, Ride* ride, uint8_t direction_start, CoordsXYE* output, int32_t* z, int32_t* direction,
1190     bool isGhost);
1191 
1192 bool track_block_get_previous(const CoordsXYE& trackPos, track_begin_end* outTrackBeginEnd);
1193 bool track_block_get_previous_from_zero(
1194     const CoordsXYZ& startPos, Ride* ride, uint8_t direction, track_begin_end* outTrackBeginEnd);
1195 
1196 void ride_get_start_of_track(CoordsXYE* output);
1197 
1198 void window_ride_construction_update_active_elements();
1199 void ride_construction_remove_ghosts();
1200 money32 ride_entrance_exit_place_ghost(
1201     Ride* ride, const CoordsXY& entranceExitCoords, Direction direction, int32_t placeType, StationIndex stationNum);
1202 CoordsXYZD ride_get_entrance_or_exit_position_from_screen_position(const ScreenCoordsXY& screenCoords);
1203 
1204 bool ride_select_backwards_from_front();
1205 bool ride_select_forwards_from_back();
1206 
1207 bool ride_are_all_possible_entrances_and_exits_built(Ride* ride);
1208 void ride_fix_breakdown(Ride* ride, int32_t reliabilityIncreaseFactor);
1209 
1210 void ride_entry_get_train_layout(int32_t rideEntryIndex, int32_t numCarsPerTrain, uint8_t* trainLayout);
1211 uint8_t ride_entry_get_vehicle_at_position(int32_t rideEntryIndex, int32_t numCarsPerTrain, int32_t position);
1212 void ride_update_vehicle_colours(Ride* ride);
1213 uint64_t ride_entry_get_supported_track_pieces(const rct_ride_entry* rideEntry);
1214 
1215 enum class RideSetSetting : uint8_t;
1216 money32 set_operating_setting(ride_id_t rideId, RideSetSetting setting, uint8_t value);
1217 money32 set_operating_setting_nested(ride_id_t rideId, RideSetSetting setting, uint8_t value, uint8_t flags);
1218 
1219 void UpdateGhostTrackAndArrow();
1220 
1221 void ride_reset_all_names();
1222 
1223 void window_ride_construction_mouseup_demolish_next_piece(const CoordsXYZD& piecePos, int32_t type);
1224 
1225 uint32_t ride_customers_per_hour(const Ride* ride);
1226 uint32_t ride_customers_in_last_5_minutes(const Ride* ride);
1227 
1228 Vehicle* ride_get_broken_vehicle(const Ride* ride);
1229 
1230 void window_ride_construction_do_station_check();
1231 void window_ride_construction_do_entrance_exit_check();
1232 
1233 money16 ride_get_price(const Ride* ride);
1234 
1235 TileElement* get_station_platform(const CoordsXYRangedZ& coords);
1236 bool ride_has_adjacent_station(Ride* ride);
1237 bool ride_has_station_shelter(Ride* ride);
1238 bool ride_has_ratings(const Ride* ride);
1239 
1240 uint8_t ride_entry_get_first_non_null_ride_type(const rct_ride_entry* rideEntry);
1241 int32_t get_booster_speed(uint8_t rideType, int32_t rawSpeed);
1242 void fix_invalid_vehicle_sprite_sizes();
1243 bool ride_entry_has_category(const rct_ride_entry* rideEntry, uint8_t category);
1244 
1245 int32_t ride_get_entry_index(int32_t rideType, int32_t rideSubType);
1246 StationObject* ride_get_station_object(const Ride* ride);
1247 
1248 void ride_action_modify(Ride* ride, int32_t modifyType, int32_t flags);
1249 
1250 void determine_ride_entrance_and_exit_locations();
1251 void ride_clear_leftover_entrances(Ride* ride);
1252