1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-15 19:13:07 +01:00

Default initialize all members in Ride

This commit is contained in:
ζeh Matt
2024-03-03 12:47:50 +02:00
committed by Gymnasiast
parent 27e43b3a94
commit d969a4f80d

View File

@@ -50,20 +50,20 @@ constexpr uint16_t const MAZE_CLEARANCE_HEIGHT = 4 * COORDS_Z_STEP;
struct RideStation
{
static constexpr uint8_t NO_TRAIN = std::numeric_limits<uint8_t>::max();
CoordsXY Start;
uint8_t Height;
uint8_t Length;
uint8_t Depart;
uint8_t TrainAtStation;
uint8_t Height{};
uint8_t Length{};
uint8_t Depart{};
uint8_t TrainAtStation{ NO_TRAIN };
TileCoordsXYZD Entrance;
TileCoordsXYZD Exit;
int32_t SegmentLength; // Length of track between this station and the next.
uint16_t SegmentTime; // Time for train to reach the next station from this station.
uint8_t QueueTime;
uint16_t QueueLength;
EntityId LastPeepInQueue;
static constexpr uint8_t NO_TRAIN = std::numeric_limits<uint8_t>::max();
int32_t SegmentLength{}; // Length of track between this station and the next.
uint16_t SegmentTime{}; // Time for train to reach the next station from this station.
uint8_t QueueTime{};
uint16_t QueueLength{};
EntityId LastPeepInQueue{ EntityId::GetNull() };
int32_t GetBaseZ() const;
void SetBaseZ(int32_t newZ);
@@ -113,20 +113,20 @@ enum class RideStatus : uint8_t;
*/
struct Ride
{
RideId id = RideId::GetNull();
ride_type_t type = RIDE_TYPE_NULL;
RideId id{ RideId::GetNull() };
ride_type_t type{ RIDE_TYPE_NULL };
// pointer to static info. for example, wild mouse type is 0x36, subtype is
// 0x4c.
ObjectEntryIndex subtype;
RideMode mode;
uint8_t colour_scheme_type;
VehicleColour vehicle_colours[OpenRCT2::Limits::MaxVehicleColours];
ObjectEntryIndex subtype{ OBJECT_ENTRY_INDEX_NULL };
RideMode mode{};
uint8_t colour_scheme_type{};
VehicleColour vehicle_colours[OpenRCT2::Limits::MaxVehicleColours]{};
// 0 = closed, 1 = open, 2 = test
RideStatus status;
RideStatus status{};
std::string custom_name;
uint16_t default_name_number;
uint16_t default_name_number{};
CoordsXY overall_view;
EntityId vehicles[OpenRCT2::Limits::MaxTrainsPerRide + 1]; // Points to the first car in the train
EntityId vehicles[OpenRCT2::Limits::MaxTrainsPerRide + 1]{}; // Points to the first car in the train
uint8_t depart_flags;
uint8_t num_stations;
uint8_t NumTrains;
@@ -145,54 +145,54 @@ struct Ride
uint8_t NumLaps;
uint8_t launch_speed;
uint8_t speed;
uint8_t rotations;
uint8_t rotations{};
};
uint8_t boat_hire_return_direction;
uint8_t boat_hire_return_direction{};
TileCoordsXY boat_hire_return_position;
// bits 0 through 4 are the number of helix sections
// bit 5: spinning tunnel, water splash, or rapids
// bit 6: log reverser, waterfall
// bit 7: whirlpool
uint8_t special_track_elements;
uint8_t special_track_elements{};
// Divide this value by 29127 to get the human-readable max speed
// (in RCT2, display_speed = (max_speed * 9) >> 18)
int32_t max_speed;
int32_t average_speed;
uint8_t current_test_segment;
uint8_t average_speed_test_timeout;
fixed16_2dp max_positive_vertical_g;
fixed16_2dp max_negative_vertical_g;
fixed16_2dp max_lateral_g;
fixed16_2dp previous_vertical_g;
fixed16_2dp previous_lateral_g;
uint32_t testing_flags;
int32_t max_speed{};
int32_t average_speed{};
uint8_t current_test_segment{};
uint8_t average_speed_test_timeout{};
fixed16_2dp max_positive_vertical_g{};
fixed16_2dp max_negative_vertical_g{};
fixed16_2dp max_lateral_g{};
fixed16_2dp previous_vertical_g{};
fixed16_2dp previous_lateral_g{};
uint32_t testing_flags{};
// x y z map location of the current track piece during a test
// this is to prevent counting special tracks multiple times
TileCoordsXYZ CurTestTrackLocation;
// Next 3 variables are related (XXXX XYYY ZZZa aaaa)
uint16_t turn_count_default; // X = current turn count
uint16_t turn_count_banked;
uint16_t turn_count_sloped; // X = number turns > 3 elements
uint16_t turn_count_default{}; // X = current turn count
uint16_t turn_count_banked{};
uint16_t turn_count_sloped{}; // X = number turns > 3 elements
// Y is number of powered lifts, X is drops
uint8_t drops; // (YYXX XXXX)
uint8_t start_drop_height;
uint8_t highest_drop_height;
int32_t sheltered_length;
uint8_t drops{}; // (YYXX XXXX)
uint8_t start_drop_height{};
uint8_t highest_drop_height{};
int32_t sheltered_length{};
// Unused always 0? Should affect nausea
uint16_t var_11C;
uint8_t num_sheltered_sections; // (?abY YYYY)
uint16_t var_11C{};
uint8_t num_sheltered_sections{}; // (?abY YYYY)
// Customer counter in the current 960 game tick (about 30 seconds) interval
uint16_t cur_num_customers;
uint16_t cur_num_customers{};
// Counts ticks to update customer intervals, resets each 960 game ticks.
uint16_t num_customers_timeout;
uint16_t num_customers_timeout{};
// Customer count in the last 10 * 960 game ticks (sliding window)
uint16_t num_customers[OpenRCT2::Limits::CustomerHistorySize];
money64 price[RCT2::ObjectLimits::MaxShopItemsPerRideEntry];
uint16_t num_customers[OpenRCT2::Limits::CustomerHistorySize]{};
money64 price[RCT2::ObjectLimits::MaxShopItemsPerRideEntry]{};
TileCoordsXYZ ChairliftBullwheelLocation[2];
union
{
RatingTuple ratings;
RatingTuple ratings{};
struct
{
ride_rating excitement;
@@ -200,39 +200,39 @@ struct Ride
ride_rating nausea;
};
};
money64 value;
uint16_t chairlift_bullwheel_rotation;
uint8_t satisfaction;
uint8_t satisfaction_time_out;
uint8_t satisfaction_next;
money64 value{};
uint16_t chairlift_bullwheel_rotation{};
uint8_t satisfaction{};
uint8_t satisfaction_time_out{};
uint8_t satisfaction_next{};
// Various flags stating whether a window needs to be refreshed
uint8_t window_invalidate_flags;
uint32_t total_customers;
money64 total_profit;
uint8_t popularity;
uint8_t popularity_time_out; // Updated every purchase and ?possibly by time?
uint8_t popularity_next; // When timeout reached this will be the next popularity
uint16_t num_riders;
uint8_t music_tune_id;
uint8_t slide_in_use;
uint8_t window_invalidate_flags{};
uint32_t total_customers{};
money64 total_profit{};
uint8_t popularity{};
uint8_t popularity_time_out{}; // Updated every purchase and ?possibly by time?
uint8_t popularity_next{}; // When timeout reached this will be the next popularity
uint16_t num_riders{};
uint8_t music_tune_id{};
uint8_t slide_in_use{};
union
{
EntityId slide_peep;
uint16_t maze_tiles;
uint16_t maze_tiles{};
};
uint8_t slide_peep_t_shirt_colour;
uint8_t spiral_slide_progress;
int32_t build_date;
money64 upkeep_cost;
EntityId race_winner;
uint32_t music_position;
uint8_t breakdown_reason_pending;
uint8_t mechanic_status;
EntityId mechanic;
StationIndex inspection_station;
uint8_t broken_vehicle;
uint8_t broken_car;
uint8_t breakdown_reason;
uint8_t slide_peep_t_shirt_colour{};
uint8_t spiral_slide_progress{};
int32_t build_date{};
money64 upkeep_cost{};
EntityId race_winner{};
uint32_t music_position{};
uint8_t breakdown_reason_pending{};
uint8_t mechanic_status{};
EntityId mechanic{ EntityId::GetNull() };
StationIndex inspection_station{ StationIndex::GetNull() };
uint8_t broken_vehicle{};
uint8_t broken_car{};
uint8_t breakdown_reason{};
union
{
struct
@@ -240,52 +240,52 @@ struct Ride
uint8_t reliability_subvalue; // 0 - 255, acts like the decimals for reliability_percentage
uint8_t reliability_percentage; // Starts at 100 and decreases from there.
};
uint16_t reliability;
uint16_t reliability{};
};
// Small constant used to increase the unreliability as the game continues,
// making breakdowns more and more likely.
uint8_t unreliability_factor;
uint8_t unreliability_factor{};
// Range from [0, 100]
uint8_t downtime;
uint8_t inspection_interval;
uint8_t last_inspection;
uint8_t downtime_history[OpenRCT2::Limits::DowntimeHistorySize];
uint32_t no_primary_items_sold;
uint32_t no_secondary_items_sold;
uint8_t breakdown_sound_modifier;
uint8_t downtime{};
uint8_t inspection_interval{};
uint8_t last_inspection{};
uint8_t downtime_history[OpenRCT2::Limits::DowntimeHistorySize]{};
uint32_t no_primary_items_sold{};
uint32_t no_secondary_items_sold{};
uint8_t breakdown_sound_modifier{};
// Used to oscillate the sound when ride breaks down.
// 0 = no change, 255 = max change
uint8_t not_fixed_timeout;
uint8_t last_crash_type;
uint8_t connected_message_throttle;
money64 income_per_hour;
money64 profit;
TrackColour track_colour[OpenRCT2::Limits::NumColourSchemes];
ObjectEntryIndex music;
ObjectEntryIndex entrance_style;
uint16_t vehicle_change_timeout;
uint8_t num_block_brakes;
uint8_t lift_hill_speed;
uint32_t guests_favourite;
uint32_t lifecycle_flags;
uint16_t total_air_time;
StationIndex current_test_station;
uint8_t num_circuits;
CoordsXYZ CableLiftLoc;
EntityId cable_lift;
uint8_t not_fixed_timeout{};
uint8_t last_crash_type{};
uint8_t connected_message_throttle{};
money64 income_per_hour{};
money64 profit{};
TrackColour track_colour[OpenRCT2::Limits::NumColourSchemes]{};
ObjectEntryIndex music{ OBJECT_ENTRY_INDEX_NULL };
ObjectEntryIndex entrance_style{ OBJECT_ENTRY_INDEX_NULL };
uint16_t vehicle_change_timeout{};
uint8_t num_block_brakes{};
uint8_t lift_hill_speed{};
uint32_t guests_favourite{};
uint32_t lifecycle_flags{};
uint16_t total_air_time{};
StationIndex current_test_station{ StationIndex::GetNull() };
uint8_t num_circuits{};
CoordsXYZ CableLiftLoc{};
EntityId cable_lift{ EntityId::GetNull() };
// These two fields are used to warn users about issues.
// Such issue can be hacked rides with incompatible options set.
// They don't require export/import.
uint8_t current_issues;
uint32_t last_issue_time;
uint8_t current_issues{};
uint32_t last_issue_time{};
// TO-DO: those friend functions are temporary, find a way to not access the private fields
friend void UpdateSpiralSlide(Ride& ride);
friend void UpdateChairlift(Ride& ride);
private:
std::array<RideStation, OpenRCT2::Limits::MaxStationsPerRide> stations;
std::array<RideStation, OpenRCT2::Limits::MaxStationsPerRide> stations{};
public:
RideStation& GetStation(StationIndex stationIndex = StationIndex::FromUnderlying(0));
@@ -299,9 +299,9 @@ public:
StationIndex::UnderlyingType GetStationNumber(StationIndex in) const;
public:
uint16_t inversions;
uint16_t holes;
uint8_t sheltered_eighths;
uint16_t inversions{};
uint16_t holes{};
uint8_t sheltered_eighths{};
std::unique_ptr<RideMeasurement> measurement;