diff --git a/src/openrct2/rct1/RCT1.h b/src/openrct2/rct1/RCT1.h index f941c3a513..9a82a4b8b1 100644 --- a/src/openrct2/rct1/RCT1.h +++ b/src/openrct2/rct1/RCT1.h @@ -637,8 +637,8 @@ struct rct1_s4 uint8_t unk_198856; uint8_t research_level; uint32_t unk_198858; - uint8_t available_rides[32]; - uint8_t available_vehicles[32]; + uint32_t available_rides[8]; + uint32_t available_vehicles[8]; uint32_t ride_feature_1[128]; uint32_t ride_feature_2[128]; uint16_t guests_in_park; diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index 166b971f35..e469c48dd9 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -464,6 +464,32 @@ private: } } } + + // In addition to the research list, there is also a list of invented ride/vehicles in general. + // This is especially useful if the research list is damaged or if the save is hacked. + for (int32_t rideType = 0; rideType < RCT1_RIDE_TYPE_COUNT; rideType++) + { + int32_t quadIndex = rideType >> 5; + int32_t bitIndex = rideType & 0x1F; + bool invented = (_s4.available_rides[quadIndex] & ((uint32_t)1 << bitIndex)); + + if (invented) + { + AddEntryForRideType(rideType); + } + } + + for (int32_t vehicleType = 0; vehicleType < RCT1_VEHICLE_TYPE_COUNT; vehicleType++) + { + int32_t quadIndex = vehicleType >> 5; + int32_t bitIndex = vehicleType & 0x1F; + bool invented = (_s4.available_vehicles[quadIndex] & ((uint32_t)1 << bitIndex)); + + if (invented) + { + AddEntryForVehicleType(RIDE_TYPE_NULL, vehicleType); + } + } } void AddAvailableEntriesFromMap() @@ -602,7 +628,8 @@ private: size_t entryIndex = _rideEntries.GetOrAddEntry(entryName); _vehicleTypeToRideEntryMap[vehicleType] = (uint8_t)entryIndex; - _rideTypeToRideEntryMap[rideType] = (uint8_t)entryIndex; + if (rideType != RIDE_TYPE_NULL) + _rideTypeToRideEntryMap[rideType] = (uint8_t)entryIndex; } } @@ -2284,6 +2311,31 @@ private: } } + // Also import the tables that register the invented status, in case the research list is damaged. + for (int32_t rideType = 0; rideType < RCT1_RIDE_TYPE_COUNT; rideType++) + { + int32_t quadIndex = rideType >> 5; + int32_t bitIndex = rideType & 0x1F; + bool invented = (_s4.available_rides[quadIndex] & ((uint32_t)1 << bitIndex)); + + if (invented) + { + ride_type_set_invented(RCT1::GetRideType(rideType)); + } + } + + for (int32_t vehicleType = 0; vehicleType < RCT1_VEHICLE_TYPE_COUNT; vehicleType++) + { + int32_t quadIndex = vehicleType >> 5; + int32_t bitIndex = vehicleType & 0x1F; + bool invented = (_s4.available_vehicles[quadIndex] & ((uint32_t)1 << bitIndex)); + + if (invented) + { + ride_entry_set_invented(_vehicleTypeToRideEntryMap[vehicleType]); + } + } + // Research funding / priority uint8_t activeResearchTypes = 0; if (_s4.research_priority & RCT1_RESEARCH_CATEGORY_ROLLERCOASTERS)