mirror of https://github.com/OpenRCT2/OpenRCT2.git
Update rating skipping unused ride ids (#14425)
* Skip empty ride ids when evaluating ride ratings This isn't much of a problem atm but when we increase the limit it may start to become an issue * Increment network version * Update changelog
This commit is contained in:
parent
048352edca
commit
7f085e2752
|
@ -8,6 +8,7 @@
|
|||
- Change: [#18230] Make the large flat to steep pieces available on the corkscrew roller coaster without cheats.
|
||||
- Change: [#18381] Convert custom invisible paths to the built-in ones.
|
||||
- Fix: [#14312] Research ride type message incorrect.
|
||||
- Fix: [#14425] Ride ratings do not skip unallocated ride ids.
|
||||
- Fix: [#15969] Guests heading for ride use vanilla behaviour
|
||||
- Fix: [#17316] Sides of River Rapids’ corners overlay other parts of the track.
|
||||
- Fix: [#17657] When switching from buying land rights to buying construction rights, grid disables and won't re-enable afterwards.
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
// It is used for making sure only compatible builds get connected, even within
|
||||
// single OpenRCT2 version.
|
||||
|
||||
#define NETWORK_STREAM_VERSION "7"
|
||||
#define NETWORK_STREAM_VERSION "8"
|
||||
|
||||
#define NETWORK_STREAM_ID OPENRCT2_VERSION "-" NETWORK_STREAM_VERSION
|
||||
|
||||
|
|
|
@ -145,6 +145,11 @@ RideManager::Iterator RideManager::end()
|
|||
return RideManager::Iterator(*this, endIndex, endIndex);
|
||||
}
|
||||
|
||||
RideManager::Iterator RideManager::get(RideId rideId)
|
||||
{
|
||||
return RideManager::Iterator(*this, rideId.ToUnderlying(), _rides.size());
|
||||
}
|
||||
|
||||
RideId GetNextFreeRideId()
|
||||
{
|
||||
auto result = static_cast<RideId::UnderlyingType>(_rides.size());
|
||||
|
|
|
@ -979,6 +979,7 @@ struct RideManager
|
|||
size_t size() const;
|
||||
Iterator begin();
|
||||
Iterator end();
|
||||
Iterator get(RideId rideId);
|
||||
Iterator begin() const
|
||||
{
|
||||
return (const_cast<RideManager*>(this))->begin();
|
||||
|
|
|
@ -154,24 +154,45 @@ static void ride_ratings_update_state(RideRatingUpdateState& state)
|
|||
}
|
||||
}
|
||||
|
||||
static RideId GetNextRideToUpdate(RideId currentRide)
|
||||
{
|
||||
auto rm = GetRideManager();
|
||||
if (rm.size() == 0)
|
||||
{
|
||||
return RideId::GetNull();
|
||||
}
|
||||
// Skip all empty ride ids
|
||||
auto nextRide = std::next(rm.get(currentRide));
|
||||
// If at end, loop around
|
||||
if (nextRide == rm.end())
|
||||
{
|
||||
nextRide = rm.begin();
|
||||
}
|
||||
return (*nextRide).id;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006B5A5C
|
||||
*/
|
||||
static void ride_ratings_update_state_0(RideRatingUpdateState& state)
|
||||
{
|
||||
auto nextRide = RideId::FromUnderlying(state.CurrentRide.ToUnderlying() + 1);
|
||||
if (nextRide.ToUnderlying() >= OpenRCT2::Limits::MaxRidesInPark)
|
||||
// It is possible that the current ride being calculated has
|
||||
// been removed or due to import invalid. For both, reset
|
||||
// ratings and start check at the start
|
||||
if (get_ride(state.CurrentRide) == nullptr)
|
||||
{
|
||||
nextRide = {};
|
||||
state.CurrentRide = {};
|
||||
}
|
||||
|
||||
auto ride = get_ride(nextRide);
|
||||
if (ride != nullptr && ride->status != RideStatus::Closed && !(ride->lifecycle_flags & RIDE_LIFECYCLE_FIXED_RATINGS))
|
||||
auto nextRideId = GetNextRideToUpdate(state.CurrentRide);
|
||||
auto nextRide = get_ride(nextRideId);
|
||||
if (nextRide != nullptr && nextRide->status != RideStatus::Closed
|
||||
&& !(nextRide->lifecycle_flags & RIDE_LIFECYCLE_FIXED_RATINGS))
|
||||
{
|
||||
state.State = RIDE_RATINGS_STATE_INITIALISE;
|
||||
}
|
||||
state.CurrentRide = nextRide;
|
||||
state.CurrentRide = nextRideId;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue