Allow shops and stalls to set their own clearances

This commit is contained in:
Gymnasiast 2021-11-02 23:48:25 +01:00
parent 70af1c6c0d
commit 23a5044509
No known key found for this signature in database
GPG Key ID: DBFFF47AB2CA3EDD
13 changed files with 37 additions and 15 deletions

View File

@ -2689,6 +2689,10 @@ private:
const auto& ted = GetTrackElementDescriptor(trackType);
const auto* trackBlock = ted.Block;
const auto* rideEntry = currentRide->GetRideEntry();
auto clearanceHeight = (rideEntry != nullptr) ? rideEntry->Clearance
: currentRide->GetRideTypeDescriptor().Heights.ClearanceHeight;
while (trackBlock->index != 255)
{
auto quarterTile = trackBlock->var_08.Rotate(trackDirection);
@ -2696,8 +2700,7 @@ private:
CoordsXY coords = originCoords + offsets.Rotate(trackDirection);
int32_t baseZ = originZ + trackBlock->z;
int32_t clearanceZ = trackBlock->var_07 + currentRide->GetRideTypeDescriptor().Heights.ClearanceHeight + baseZ
+ (4 * COORDS_Z_STEP);
int32_t clearanceZ = trackBlock->var_07 + clearanceHeight + baseZ + (4 * COORDS_Z_STEP);
auto centreTileCoords = TileCoordsXY{ coords };
auto eastTileCoords = centreTileCoords + TileDirectionDelta[TILE_ELEMENT_DIRECTION_EAST];

View File

@ -209,6 +209,7 @@ GameActions::Result TrackPlaceAction::Query() const
// If that is not the case, then perform the remaining checks
trackBlock = ted.Block;
auto clearanceHeight = rideEntry->Clearance;
money32 costs = 0;
money64 supportCosts = 0;
@ -227,14 +228,13 @@ GameActions::Result TrackPlaceAction::Query() const
int32_t baseZ = Floor2(mapLoc.z, COORDS_Z_STEP);
int32_t clearanceZ = trackBlock->var_07;
if (trackBlock->flags & RCT_PREVIEW_TRACK_FLAG_IS_VERTICAL
&& ride->GetRideTypeDescriptor().Heights.ClearanceHeight > 24)
if (trackBlock->flags & RCT_PREVIEW_TRACK_FLAG_IS_VERTICAL && clearanceHeight > 24)
{
clearanceZ += 24;
}
else
{
clearanceZ += ride->GetRideTypeDescriptor().Heights.ClearanceHeight;
clearanceZ += clearanceHeight;
}
clearanceZ = Floor2(clearanceZ, COORDS_Z_STEP) + baseZ;
@ -441,6 +441,7 @@ GameActions::Result TrackPlaceAction::Execute() const
money32 costs = 0;
money64 supportCosts = 0;
const PreviewTrack* trackBlock = ted.Block;
auto clearanceHeight = rideEntry->Clearance;
CoordsXYZ originLocation = CoordsXYZ{ _origin.x, _origin.y, _origin.z }
+ CoordsXYZ{ CoordsXY{ trackBlock->x, trackBlock->y }.Rotate(_origin.direction), trackBlock->z };
for (int32_t blockIndex = 0; trackBlock->index != 0xFF; trackBlock++, blockIndex++)
@ -452,14 +453,13 @@ GameActions::Result TrackPlaceAction::Execute() const
int32_t baseZ = Floor2(mapLoc.z, COORDS_Z_STEP);
int32_t clearanceZ = trackBlock->var_07;
if (trackBlock->flags & RCT_PREVIEW_TRACK_FLAG_IS_VERTICAL
&& ride->GetRideTypeDescriptor().Heights.ClearanceHeight > 24)
if (trackBlock->flags & RCT_PREVIEW_TRACK_FLAG_IS_VERTICAL && clearanceHeight > 24)
{
clearanceZ += 24;
}
else
{
clearanceZ += ride->GetRideTypeDescriptor().Heights.ClearanceHeight;
clearanceZ += clearanceHeight;
}
clearanceZ = Floor2(clearanceZ, COORDS_Z_STEP) + baseZ;

View File

@ -196,6 +196,7 @@ void RideObject::ReadLegacy(IReadObjectContext* context, IStream* stream)
context->LogError(ObjectError::InvalidProperty, "Nausea multiplier too high.");
}
RideObjectUpdateRideType(_legacyType);
_legacyType.Clearance = GetDefaultClearance();
}
void RideObject::Load()
@ -471,6 +472,7 @@ void RideObject::ReadJson(IReadObjectContext* context, json_t& root)
}
_legacyType.max_height = Json::GetNumber<uint8_t>(properties["maxHeight"]);
_legacyType.Clearance = Json::GetNumber<uint8_t>(properties["clearance"], GetDefaultClearance());
// This needs to be set for both shops/facilities _and_ regular rides.
for (auto& item : _legacyType.shop_item)
@ -1016,3 +1018,10 @@ void RideObject::ReadLegacySpriteGroups(CarEntry* vehicle, uint16_t spriteGroups
vehicle->SpriteGroups[EnumValue(SpriteGroupType::CurvedLiftHill)].spritePrecision = baseSpritePrecision;
}
}
uint8_t RideObject::GetDefaultClearance() const
{
auto rideType = _legacyType.GetFirstNonNullRideType();
const auto& rtd = GetRideTypeDescriptor(rideType);
return rtd.Heights.ClearanceHeight;
}

View File

@ -64,4 +64,5 @@ private:
static colour_t ParseColour(const std::string& s);
void ReadLegacySpriteGroups(CarEntry* vehicle, uint16_t spriteGroups);
uint8_t GetDefaultClearance() const;
};

View File

@ -40,6 +40,14 @@ enum class ResearchCategory : uint8_t;
using ride_ratings_calculation = void (*)(Ride& ride, RideRatingUpdateState& state);
constexpr const uint8_t DefaultFoodStallHeight = 8 * COORDS_Z_STEP;
constexpr const uint8_t DefaultDrinksStallHeight = 8 * COORDS_Z_STEP;
constexpr const uint8_t DefaultShopHeight = 8 * COORDS_Z_STEP;
constexpr const uint8_t DefaultToiletHeight = 4 * COORDS_Z_STEP;
constexpr const uint8_t DefaultInformationKioskHeight = 6 * COORDS_Z_STEP;
constexpr const uint8_t DefaultFirstAidHeight = 6 * COORDS_Z_STEP;
constexpr const uint8_t DefaultCashMachineHeight = 8 * COORDS_Z_STEP;
struct RideComponentName
{
StringId singular;

View File

@ -73,6 +73,7 @@ struct RideObjectEntry
ShopItem shop_item[RCT2::ObjectLimits::MaxShopItemsPerRideEntry];
StringId capacity;
void* obj;
uint8_t Clearance;
const CarEntry* GetCar(size_t id) const
{

View File

@ -32,7 +32,7 @@ constexpr const RideTypeDescriptor CashMachineRTD =
SET_FIELD(NameConvention, { RideComponentType::Car, RideComponentType::Building, RideComponentType::Station }),
SET_FIELD(EnumName, nameof(RIDE_TYPE_CASH_MACHINE)),
SET_FIELD(AvailableBreakdowns, 0),
SET_FIELD(Heights, { 12, 64, 0, 0, }),
SET_FIELD(Heights, { 12, DefaultCashMachineHeight, 0, 0, }),
SET_FIELD(MaxMass, 255),
SET_FIELD(LiftData, { OpenRCT2::Audio::SoundId::Null, 5, 5 }),
SET_FIELD(RatingsCalculationFunction, RideRatingsCalculateCashMachine),

View File

@ -33,7 +33,7 @@ constexpr const RideTypeDescriptor DrinkStallRTD =
SET_FIELD(NameConvention, { RideComponentType::Car, RideComponentType::Building, RideComponentType::Station }),
SET_FIELD(EnumName, nameof(RIDE_TYPE_DRINK_STALL)),
SET_FIELD(AvailableBreakdowns, 0),
SET_FIELD(Heights, { 12, 64, 0, 0, }),
SET_FIELD(Heights, { 12, DefaultDrinksStallHeight, 0, 0, }),
SET_FIELD(MaxMass, 255),
SET_FIELD(LiftData, { OpenRCT2::Audio::SoundId::Null, 5, 5 }),
SET_FIELD(RatingsCalculationFunction, RideRatingsCalculateDrinkStall),

View File

@ -33,7 +33,7 @@ constexpr const RideTypeDescriptor FirstAidRTD =
SET_FIELD(NameConvention, { RideComponentType::Car, RideComponentType::Building, RideComponentType::Station }),
SET_FIELD(EnumName, nameof(RIDE_TYPE_FIRST_AID)),
SET_FIELD(AvailableBreakdowns, 0),
SET_FIELD(Heights, { 12, 48, 0, 0, }),
SET_FIELD(Heights, { 12, DefaultFirstAidHeight, 0, 0, }),
SET_FIELD(MaxMass, 255),
SET_FIELD(LiftData, { OpenRCT2::Audio::SoundId::Null, 5, 5 }),
SET_FIELD(RatingsCalculationFunction, RideRatingsCalculateFirstAid),

View File

@ -33,7 +33,7 @@ constexpr const RideTypeDescriptor FoodStallRTD =
SET_FIELD(NameConvention, { RideComponentType::Car, RideComponentType::Building, RideComponentType::Station }),
SET_FIELD(EnumName, nameof(RIDE_TYPE_FOOD_STALL)),
SET_FIELD(AvailableBreakdowns, 0),
SET_FIELD(Heights, { 12, 64, 0, 0, }),
SET_FIELD(Heights, { 12, DefaultFoodStallHeight, 0, 0, }),
SET_FIELD(MaxMass, 255),
SET_FIELD(LiftData, { OpenRCT2::Audio::SoundId::Null, 5, 5 }),
SET_FIELD(RatingsCalculationFunction, RideRatingsCalculateFoodStall),

View File

@ -33,7 +33,7 @@ constexpr const RideTypeDescriptor InformationKioskRTD =
SET_FIELD(NameConvention, { RideComponentType::Car, RideComponentType::Building, RideComponentType::Station }),
SET_FIELD(EnumName, nameof(RIDE_TYPE_INFORMATION_KIOSK)),
SET_FIELD(AvailableBreakdowns, 0),
SET_FIELD(Heights, { 12, 48, 0, 0, }),
SET_FIELD(Heights, { 12, DefaultInformationKioskHeight, 0, 0, }),
SET_FIELD(MaxMass, 255),
SET_FIELD(LiftData, { OpenRCT2::Audio::SoundId::Null, 5, 5 }),
SET_FIELD(RatingsCalculationFunction, RideRatingsCalculateInformationKiosk),

View File

@ -33,7 +33,7 @@ constexpr const RideTypeDescriptor ShopRTD =
SET_FIELD(NameConvention, { RideComponentType::Car, RideComponentType::Building, RideComponentType::Station }),
SET_FIELD(EnumName, nameof(RIDE_TYPE_SHOP)),
SET_FIELD(AvailableBreakdowns, 0),
SET_FIELD(Heights, { 12, 64, 0, 0, }),
SET_FIELD(Heights, { 12, DefaultShopHeight, 0, 0, }),
SET_FIELD(MaxMass, 255),
SET_FIELD(LiftData, { OpenRCT2::Audio::SoundId::Null, 5, 5 }),
SET_FIELD(RatingsCalculationFunction, RideRatingsCalculateShop),

View File

@ -33,7 +33,7 @@ constexpr const RideTypeDescriptor ToiletsRTD =
SET_FIELD(NameConvention, { RideComponentType::Car, RideComponentType::Building, RideComponentType::Station }),
SET_FIELD(EnumName, nameof(RIDE_TYPE_TOILETS)),
SET_FIELD(AvailableBreakdowns, 0),
SET_FIELD(Heights, { 12, 32, 0, 0, }),
SET_FIELD(Heights, { 12, DefaultToiletHeight, 0, 0, }),
SET_FIELD(MaxMass, 255),
SET_FIELD(LiftData, { OpenRCT2::Audio::SoundId::Null, 5, 5 }),
SET_FIELD(RatingsCalculationFunction, RideRatingsCalculateToilets),