diff --git a/src/openrct2/ride/Ride.cpp b/src/openrct2/ride/Ride.cpp index a320f0ac49..afbe502129 100644 --- a/src/openrct2/ride/Ride.cpp +++ b/src/openrct2/ride/Ride.cpp @@ -828,11 +828,11 @@ void Ride::FormatStatusTo(Formatter& ft) const } } -int32_t ride_get_total_length(const Ride* ride) +int32_t Ride::GetTotalLength() const { int32_t i, totalLength = 0; - for (i = 0; i < ride->num_stations; i++) - totalLength += ride->stations[i].SegmentLength; + for (i = 0; i < num_stations; i++) + totalLength += stations[i].SegmentLength; return totalLength; } diff --git a/src/openrct2/ride/Ride.h b/src/openrct2/ride/Ride.h index 1034cb15ff..5bedbfb8d5 100644 --- a/src/openrct2/ride/Ride.h +++ b/src/openrct2/ride/Ride.h @@ -378,6 +378,8 @@ public: void UpdateSatisfaction(const uint8_t happiness); void UpdatePopularity(const uint8_t pop_amount); void RemovePeeps(); + + int32_t GetTotalLength() const; }; #pragma pack(push, 1) @@ -1036,7 +1038,6 @@ bool ride_modify(CoordsXYE* input); void ride_clear_blocked_tiles(Ride* ride); Staff* ride_get_mechanic(Ride* ride); Staff* ride_get_assigned_mechanic(Ride* ride); -int32_t ride_get_total_length(const Ride* ride); int32_t ride_get_total_time(Ride* ride); TrackColour ride_get_track_colour(Ride* ride, int32_t colourScheme); VehicleColour ride_get_vehicle_colour(Ride* ride, int32_t vehicleIndex); diff --git a/src/openrct2/ride/RideRatings.cpp b/src/openrct2/ride/RideRatings.cpp index c7d29591dc..62703bc495 100644 --- a/src/openrct2/ride/RideRatings.cpp +++ b/src/openrct2/ride/RideRatings.cpp @@ -880,7 +880,7 @@ static uint16_t ride_compute_upkeep(RideRatingUpdateState& state, Ride* ride) dropFactor &= 3; upkeep += trackCost * dropFactor; - uint32_t totalLength = ride_get_total_length(ride) >> 16; + uint32_t totalLength = ride->GetTotalLength() >> 16; // The data originally here was 20's and 0's. The 20's all represented // rides that had tracks. The 0's were fixed rides like crooked house or @@ -1099,7 +1099,7 @@ static uint32_t ride_ratings_get_proximity_score(RideRatingUpdateState& state) */ static ShelteredEights get_num_of_sheltered_eighths(Ride* ride) { - int32_t totalLength = ride_get_total_length(ride); + int32_t totalLength = ride->GetTotalLength(); int32_t shelteredLength = ride->sheltered_length; int32_t lengthEighth = totalLength / 8; int32_t lengthCounter = lengthEighth; @@ -1503,7 +1503,7 @@ static void ride_ratings_add(RatingTuple* rating, int32_t excitement, int32_t in static void ride_ratings_apply_length(RatingTuple* ratings, Ride* ride, int32_t maxLength, int32_t excitementMultiplier) { - ride_ratings_add(ratings, (std::min(ride_get_total_length(ride) >> 16, maxLength) * excitementMultiplier) >> 16, 0, 0); + ride_ratings_add(ratings, (std::min(ride->GetTotalLength() >> 16, maxLength) * excitementMultiplier) >> 16, 0, 0); } static void ride_ratings_apply_synchronisation(RatingTuple* ratings, Ride* ride, int32_t excitement, int32_t intensity) @@ -2196,7 +2196,7 @@ void ride_ratings_calculate_launched_freefall(Ride* ride, RideRatingUpdateState& ride_ratings_add(&ratings, RIDE_RATING(0, 30), RIDE_RATING(0, 65), RIDE_RATING(0, 45)); } - int32_t excitementModifier = ((ride_get_total_length(ride) >> 16) * 32768) >> 16; + int32_t excitementModifier = ((ride->GetTotalLength() >> 16) * 32768) >> 16; ride_ratings_add(&ratings, excitementModifier, 0, 0); #ifdef ORIGINAL_RATINGS @@ -2212,7 +2212,7 @@ void ride_ratings_calculate_launched_freefall(Ride* ride, RideRatingUpdateState& // Fix #3282: When the ride mode is in downward launch mode, the intensity and // nausea were fixed regardless of how high the ride is. The following // calculation is based on roto-drop which is a similar mechanic. - int32_t lengthFactor = ((ride_get_total_length(ride) >> 16) * 209715) >> 16; + int32_t lengthFactor = ((ride->GetTotalLength() >> 16) * 209715) >> 16; ride_ratings_add(&ratings, lengthFactor, lengthFactor * 2, lengthFactor * 2); } #endif @@ -2280,7 +2280,7 @@ void ride_ratings_calculate_observation_tower(Ride* ride, RideRatingUpdateState& RatingTuple ratings; ride_ratings_set(&ratings, RIDE_RATING(1, 50), RIDE_RATING(0, 00), RIDE_RATING(0, 10)); ride_ratings_add( - &ratings, ((ride_get_total_length(ride) >> 16) * 45875) >> 16, 0, ((ride_get_total_length(ride) >> 16) * 26214) >> 16); + &ratings, ((ride->GetTotalLength() >> 16) * 45875) >> 16, 0, ((ride->GetTotalLength() >> 16) * 26214) >> 16); ride_ratings_apply_proximity(state, &ratings, 20130); ride_ratings_apply_scenery(&ratings, ride, 83662); @@ -3009,7 +3009,7 @@ void ride_ratings_calculate_lift(Ride* ride, RideRatingUpdateState& state) RatingTuple ratings; ride_ratings_set(&ratings, RIDE_RATING(1, 11), RIDE_RATING(0, 35), RIDE_RATING(0, 30)); - int32_t totalLength = ride_get_total_length(ride) >> 16; + int32_t totalLength = ride->GetTotalLength() >> 16; ride_ratings_add(&ratings, (totalLength * 45875) >> 16, 0, (totalLength * 26214) >> 16); ride_ratings_apply_proximity(state, &ratings, 11183); @@ -3808,7 +3808,7 @@ void ride_ratings_calculate_roto_drop(Ride* ride, RideRatingUpdateState& state) RatingTuple ratings; ride_ratings_set(&ratings, RIDE_RATING(2, 80), RIDE_RATING(3, 50), RIDE_RATING(3, 50)); - int32_t lengthFactor = ((ride_get_total_length(ride) >> 16) * 209715) >> 16; + int32_t lengthFactor = ((ride->GetTotalLength() >> 16) * 209715) >> 16; ride_ratings_add(&ratings, lengthFactor, lengthFactor * 2, lengthFactor * 2); ride_ratings_apply_proximity(state, &ratings, 11183); diff --git a/src/openrct2/ride/TrackDesign.cpp b/src/openrct2/ride/TrackDesign.cpp index 2da0f8c34d..afdc27b8da 100644 --- a/src/openrct2/ride/TrackDesign.cpp +++ b/src/openrct2/ride/TrackDesign.cpp @@ -124,7 +124,7 @@ rct_string_id TrackDesign::CreateTrackDesign(TrackDesignState& tds, const Ride& entrance_style = ride.entrance_style; max_speed = static_cast(ride.max_speed / 65536); average_speed = static_cast(ride.average_speed / 65536); - ride_length = ride_get_total_length(&ride) / 65536; + ride_length = ride.GetTotalLength() / 65536; max_positive_vertical_g = ride.max_positive_vertical_g / 32; max_negative_vertical_g = ride.max_negative_vertical_g / 32; max_lateral_g = ride.max_lateral_g / 32; diff --git a/src/openrct2/scenario/Scenario.cpp b/src/openrct2/scenario/Scenario.cpp index 9da92eb379..b38039d88d 100644 --- a/src/openrct2/scenario/Scenario.cpp +++ b/src/openrct2/scenario/Scenario.cpp @@ -768,7 +768,7 @@ ObjectiveStatus Objective::Check10RollerCoastersLength() const { if (ride_entry_has_category(rideEntry, RIDE_CATEGORY_ROLLERCOASTER) && !type_already_counted[ride.subtype]) { - if ((ride_get_total_length(&ride) >> 16) >= MinimumLength) + if ((ride.GetTotalLength() >> 16) >= MinimumLength) { type_already_counted[ride.subtype] = true; rcs++;