mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-16 03:23:15 +01:00
Use std::span for GetStations
This commit is contained in:
committed by
Aaron van Geffen
parent
3d4b106059
commit
1d7bd7ac27
@@ -1046,12 +1046,12 @@ const RideStation& Ride::GetStation(StationIndex stationIndex) const
|
||||
return stations[stationIndex.ToUnderlying()];
|
||||
}
|
||||
|
||||
std::array<RideStation, OpenRCT2::Limits::kMaxStationsPerRide>& Ride::GetStations()
|
||||
std::span<RideStation> Ride::GetStations()
|
||||
{
|
||||
return stations;
|
||||
}
|
||||
|
||||
const std::array<RideStation, OpenRCT2::Limits::kMaxStationsPerRide>& Ride::GetStations() const
|
||||
std::span<const RideStation> Ride::GetStations() const
|
||||
{
|
||||
return stations;
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <array>
|
||||
#include <limits>
|
||||
#include <memory>
|
||||
#include <span>
|
||||
#include <string_view>
|
||||
|
||||
struct IObjectManager;
|
||||
@@ -293,8 +294,8 @@ private:
|
||||
public:
|
||||
RideStation& GetStation(StationIndex stationIndex = StationIndex::FromUnderlying(0));
|
||||
const RideStation& GetStation(StationIndex stationIndex = StationIndex::FromUnderlying(0)) const;
|
||||
std::array<RideStation, OpenRCT2::Limits::kMaxStationsPerRide>& GetStations();
|
||||
const std::array<RideStation, OpenRCT2::Limits::kMaxStationsPerRide>& GetStations() const;
|
||||
std::span<RideStation> GetStations();
|
||||
std::span<const RideStation> GetStations() const;
|
||||
StationIndex GetStationIndex(const RideStation* station) const;
|
||||
|
||||
// Returns the logical station number from the given station. Index 0 = station 1, index 1 = station 2. It accounts for gaps
|
||||
|
||||
@@ -2308,7 +2308,7 @@ static void test_finish(Ride& ride)
|
||||
ride.lifecycle_flags &= ~RIDE_LIFECYCLE_TEST_IN_PROGRESS;
|
||||
ride.lifecycle_flags |= RIDE_LIFECYCLE_TESTED;
|
||||
|
||||
auto& rideStations = ride.GetStations();
|
||||
auto rideStations = ride.GetStations();
|
||||
for (int32_t i = ride.num_stations - 1; i >= 1; i--)
|
||||
{
|
||||
if (rideStations[i - 1].SegmentTime != 0)
|
||||
|
||||
@@ -2352,7 +2352,7 @@ void ShiftMap(const TileCoordsXY& amount)
|
||||
// Rides
|
||||
for (auto& ride : GetRideManager())
|
||||
{
|
||||
auto& stations = ride.GetStations();
|
||||
auto stations = ride.GetStations();
|
||||
for (auto& station : stations)
|
||||
{
|
||||
shiftIfNotNull(station.Start, amountToMove);
|
||||
|
||||
Reference in New Issue
Block a user