allow block brakes to be built with speed

This commit is contained in:
Spacek531 2023-03-05 22:19:06 -08:00
parent c57f0bd962
commit 99ffaa8b71
5 changed files with 21 additions and 10 deletions

View File

@ -1405,6 +1405,8 @@ public:
_currentTrackBankEnd = TRACK_BANK_NONE;
_currentTrackLiftHill &= ~CONSTRUCTION_LIFT_HILL_SELECTED;
break;
case TrackElemType::BlockBrakes:
_currentBrakeSpeed2 = kRCT2DefaultBlockBrakeSpeed;
}
_currentTrackCurve = trackPiece | RideConstructionSpecialPieceSelected;
WindowRideConstructionUpdateActiveElements();

View File

@ -573,12 +573,16 @@ GameActions::Result TrackPlaceAction::Execute() const
case TrackElemType::SpinningTunnel:
MapAnimationCreate(MAP_ANIMATION_TYPE_TRACK_SPINNINGTUNNEL, CoordsXYZ{ mapLoc, trackElement->GetBaseZ() });
break;
case TrackElemType::Brakes:
trackElement->SetBrakeClosed(true);
break;
}
if (TrackTypeHasSpeedSetting(_trackType))
{
trackElement->SetBrakeBoosterSpeed(_brakeSpeed);
}
else if (ride->GetRideTypeDescriptor().HasFlag(RIDE_TYPE_FLAG_HAS_LANDSCAPE_DOORS))
if (ride->GetRideTypeDescriptor().HasFlag(RIDE_TYPE_FLAG_HAS_LANDSCAPE_DOORS))
{
trackElement->SetDoorAState(LANDSCAPE_DOOR_CLOSED);
trackElement->SetDoorBState(LANDSCAPE_DOOR_CLOSED);

View File

@ -655,7 +655,7 @@ bool TrackElementIsCovered(track_type_t trackElementType)
bool TrackTypeHasSpeedSetting(track_type_t trackType)
{
return trackType == TrackElemType::Brakes || trackType == TrackElemType::Booster;
return trackType == TrackElemType::Brakes || trackType == TrackElemType::Booster || trackType == TrackElemType::BlockBrakes;
}
bool TrackTypeIsHelix(track_type_t trackType)

View File

@ -18,7 +18,9 @@
constexpr const uint32_t RideConstructionSpecialPieceSelected = 0x10000;
constexpr const int32_t BLOCK_BRAKE_BASE_SPEED = 0x20364;
constexpr const uint8_t kRCT2DefaultBlockBrakeSpeed = 2;
constexpr const int32_t kBlockBrakeBaseSpeed = 0x20364;
constexpr const int32_t kBlockBrakeSpeedOffset = kBlockBrakeBaseSpeed - (kRCT2DefaultBlockBrakeSpeed << 16);
using track_type_t = uint16_t;
using roll_type_t = uint8_t;

View File

@ -6004,15 +6004,14 @@ void Vehicle::ApplyNonStopBlockBrake()
if (velocity >= 0)
{
// If the vehicle is below the speed limit
if (velocity <= BLOCK_BRAKE_BASE_SPEED)
if (velocity <= kBlockBrakeBaseSpeed)
{
// Boost it to the fixed block brake speed
velocity = BLOCK_BRAKE_BASE_SPEED;
velocity = kBlockBrakeBaseSpeed;
acceleration = 0;
}
else
else if (velocity > (brake_speed << 16) + kBlockBrakeSpeedOffset)
{
// Slow it down till the fixed block brake speed
velocity -= velocity >> 4;
acceleration = 0;
}
@ -6185,9 +6184,13 @@ static void block_brakes_open_previous_section(
MapInvalidateElement(location, reinterpret_cast<TileElement*>(trackElement));
auto trackType = trackElement->GetTrackType();
if (trackType == TrackElemType::BlockBrakes || trackType == TrackElemType::EndStation)
if (ride.IsBlockSectioned())
{
if (ride.IsBlockSectioned())
if (trackType == TrackElemType::EndStation)
{
OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::BlockBrakeClose, location);
}
else if (trackType == TrackElemType::BlockBrakes)
{
OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::BlockBrakeClose, location);
}
@ -6981,7 +6984,7 @@ void Vehicle::UpdateLandscapeDoorBackwards() const
static void vehicle_update_play_water_splash_sound()
{
if (_vehicleVelocityF64E08 <= BLOCK_BRAKE_BASE_SPEED)
if (_vehicleVelocityF64E08 <= kBlockBrakeBaseSpeed)
{
return;
}