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

Fix GetOrAllocateRide

This commit is contained in:
Ted John
2019-08-04 20:44:11 +01:00
parent f49447bed5
commit cbc74a3c51

View File

@@ -184,15 +184,12 @@ ride_id_t GetNextFreeRideId()
Ride* GetOrAllocateRide(ride_id_t index)
{
Ride* result{};
if (index < _rides.size())
if (_rides.size() <= index)
{
result = &_rides[index];
}
else
{
result = &_rides.emplace_back();
_rides.resize(index + 1);
}
auto result = &_rides[index];
result->id = index;
return result;
}
@@ -204,6 +201,7 @@ Ride* get_ride(ride_id_t index)
auto& ride = _rides[index];
if (ride.type != RIDE_TYPE_NULL)
{
assert(ride.id == index);
return &ride;
}
}