1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-24 15:24:30 +01:00

Fix #7006: Use RTDs for determining ride category

This commit is contained in:
Gymnasiast
2020-04-30 12:58:20 +02:00
parent 505ac0f1a0
commit 6cdee9db93
8 changed files with 58 additions and 69 deletions

View File

@@ -60,9 +60,8 @@ void RideObject::ReadLegacy(IReadObjectContext* context, IStream* stream)
_legacyType.intensity_multiplier = stream->ReadValue<int8_t>();
_legacyType.nausea_multiplier = stream->ReadValue<int8_t>();
_legacyType.max_height = stream->ReadValue<uint8_t>();
_legacyType.enabledTrackPieces = stream->ReadValue<uint64_t>();
_legacyType.category[0] = stream->ReadValue<uint8_t>();
_legacyType.category[1] = stream->ReadValue<uint8_t>();
// Skipping a uint64_t for the enabled track pieces and two uint8_ts for the categories.
stream->Seek(10, STREAM_SEEK_CURRENT);
_legacyType.shop_item = stream->ReadValue<uint8_t>();
_legacyType.shop_item_secondary = stream->ReadValue<uint8_t>();
@@ -382,32 +381,32 @@ std::string RideObject::GetCapacity() const
void RideObject::SetRepositoryItem(ObjectRepositoryItem* item) const
{
// Find the first non-null ride type, to be used when checking the ride group and determining the category.
uint8_t firstRideType = ride_entry_get_first_non_null_ride_type(&_legacyType);
uint8_t category = RideTypeDescriptors[firstRideType].Category;
for (int32_t i = 0; i < RCT2_MAX_RIDE_TYPES_PER_RIDE_ENTRY; i++)
{
item->RideInfo.RideType[i] = _legacyType.ride_type[i];
}
for (int32_t i = 0; i < RCT2_MAX_CATEGORIES_PER_RIDE; i++)
{
item->RideInfo.RideCategory[i] = _legacyType.category[i];
item->RideInfo.RideCategory[i] = category;
}
uint8_t flags = 0;
item->RideInfo.RideFlags = flags;
// Find the first non-null ride type, to be used when checking the ride group
uint8_t rideTypeIdx = ride_entry_get_first_non_null_ride_type(&_legacyType);
item->RideInfo.RideFlags = 0;
// Determines the ride group. Will fall back to 0 if there is none found.
uint8_t rideGroupIndex = 0;
const RideGroup* rideGroup = RideGroupManager::GetRideGroup(rideTypeIdx, &_legacyType);
const RideGroup* rideGroup = RideGroupManager::GetRideGroup(firstRideType, &_legacyType);
// If the ride group is nullptr, the track type does not have ride groups.
if (rideGroup != nullptr)
{
for (uint8_t i = rideGroupIndex + 1; i < MAX_RIDE_GROUPS_PER_RIDE_TYPE; i++)
{
const RideGroup* irg = RideGroupManager::RideGroupFind(rideTypeIdx, i);
const RideGroup* irg = RideGroupManager::RideGroupFind(firstRideType, i);
if (irg != nullptr)
{
@@ -547,17 +546,6 @@ void RideObject::ReadJson(IReadObjectContext* context, const json_t* root)
_legacyType.ride_type[i] = rideType;
}
auto rideCategories = ObjectJsonHelpers::GetJsonStringArray(json_object_get(properties, "category"));
if (rideCategories.size() >= 1)
{
_legacyType.category[0] = ParseRideCategory(rideCategories[0]);
_legacyType.category[1] = _legacyType.category[0];
}
if (rideCategories.size() >= 2)
{
_legacyType.category[1] = ParseRideCategory(rideCategories[1]);
}
_legacyType.max_height = ObjectJsonHelpers::GetInteger(properties, "maxHeight");
// This needs to be set for both shops/facilities _and_ regular rides.