Merge pull request #21850 from Gymnasiast/backport/brake-stuff

Small backport of changes for #15314
This commit is contained in:
Michael Steenbeek 2024-04-30 13:57:37 +02:00 committed by GitHub
commit 921860729b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 54 additions and 37 deletions

View File

@ -3698,6 +3698,7 @@ STR_6623 :Type help for a list of available commands. Type hide t
STR_6624 :Tile Inspector: Sort elements
STR_6625 :Invalid colour
STR_6626 :Animation is backwards
STR_6627 :Track speed too high!
#############
# Scenarios #

View File

@ -219,7 +219,7 @@ static Widget _rideConstructionWidgets[] = {
ShowGridlines();
_currentTrackPrice = kMoney64Undefined;
_currentBrakeSpeed2 = 8;
_currentBrakeSpeed = 8;
_currentSeatRotationAngle = 4;
_currentTrackCurve = currentRide->GetRideTypeDescriptor().StartTrackPiece | RideConstructionSpecialPieceSelected;
@ -1335,10 +1335,9 @@ static Widget _rideConstructionWidgets[] = {
}
else
{
uint8_t* brakesSpeedPtr = &_currentBrakeSpeed2;
uint8_t maxBrakesSpeed = 30;
uint8_t* brakesSpeedPtr = &_currentBrakeSpeed;
uint8_t brakesSpeed = *brakesSpeedPtr + 2;
if (brakesSpeed <= maxBrakesSpeed)
if (brakesSpeed <= kMaximumBrakeSpeed)
{
if (_rideConstructionState == RideConstructionState::Selected)
{
@ -1362,7 +1361,7 @@ static Widget _rideConstructionWidgets[] = {
}
else
{
uint8_t* brakesSpeedPtr = &_currentBrakeSpeed2;
uint8_t* brakesSpeedPtr = &_currentBrakeSpeed;
uint8_t brakesSpeed = *brakesSpeedPtr - 2;
if (brakesSpeed >= 2)
{
@ -1450,7 +1449,7 @@ static Widget _rideConstructionWidgets[] = {
break;
case TrackElemType::BlockBrakes:
case TrackElemType::DiagBlockBrakes:
_currentBrakeSpeed2 = kRCT2DefaultBlockBrakeSpeed;
_currentBrakeSpeed = kRCT2DefaultBlockBrakeSpeed;
}
_currentTrackCurve = trackPiece | RideConstructionSpecialPieceSelected;
WindowRideConstructionUpdateActiveElements();
@ -1508,7 +1507,7 @@ static Widget _rideConstructionWidgets[] = {
if (_currentlyShowingBrakeOrBoosterSpeed)
{
uint16_t brakeSpeed2 = ((_currentBrakeSpeed2 * 9) >> 2) & 0xFFFF;
uint16_t brakeSpeed2 = ((_currentBrakeSpeed * 9) >> 2) & 0xFFFF;
if (TrackTypeIsBooster(_selectedTrackType)
|| TrackTypeIsBooster(_currentTrackCurve & ~RideConstructionSpecialPieceSelected))
{
@ -3050,7 +3049,7 @@ static Widget _rideConstructionWidgets[] = {
{
_selectedTrackType = tileElement->AsTrack()->GetTrackType();
if (TrackTypeHasSpeedSetting(tileElement->AsTrack()->GetTrackType()))
_currentBrakeSpeed2 = tileElement->AsTrack()->GetBrakeBoosterSpeed();
_currentBrakeSpeed = tileElement->AsTrack()->GetBrakeBoosterSpeed();
_currentSeatRotationAngle = tileElement->AsTrack()->GetSeatRotation();
}
}

View File

@ -104,6 +104,13 @@ GameActions::Result TrackPlaceAction::Query() const
GameActions::Status::InvalidParameters, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, STR_ERR_VALUE_OUT_OF_RANGE);
}
if (_brakeSpeed > kMaximumBrakeSpeed)
{
LOG_WARNING("Invalid speed for track placement, speed = %d", _brakeSpeed);
return GameActions::Result(
GameActions::Status::InvalidParameters, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, STR_SPEED_TOO_HIGH);
}
auto res = GameActions::Result();
res.Expenditure = ExpenditureType::RideConstruction;
res.Position.x = _origin.x + 16;

View File

@ -68,6 +68,12 @@ GameActions::Result TrackSetBrakeSpeedAction::QueryExecute(bool isExecuting) con
GameActions::Status::InvalidParameters, STR_ERR_INVALID_PARAMETER, STR_ERR_TILE_ELEMENT_NOT_FOUND);
}
if (_brakeSpeed > kMaximumBrakeSpeed)
{
LOG_WARNING("Invalid speed for track, speed = %d", _brakeSpeed);
return GameActions::Result(GameActions::Status::InvalidParameters, STR_SPEED_TOO_HIGH, STR_NONE);
}
if (isExecuting)
{
GetTrackElementOriginAndApplyChanges(

View File

@ -4045,6 +4045,8 @@ enum : uint16_t
STR_TILE_INSPECTOR_WALL_ANIMATION_IS_BACKWARDS = 6626,
STR_SPEED_TOO_HIGH = 6627,
// Have to include resource strings (from scenarios and objects) for the time being now that language is partially working
/* MAX_STR_COUNT = 32768 */ // MAX_STR_COUNT - upper limit for number of strings, not the current count strings
};

View File

@ -46,7 +46,7 @@ using namespace OpenRCT2;
// It is used for making sure only compatible builds get connected, even within
// single OpenRCT2 version.
#define NETWORK_STREAM_VERSION "3"
#define NETWORK_STREAM_VERSION "4"
#define NETWORK_STREAM_ID OPENRCT2_VERSION "-" NETWORK_STREAM_VERSION

View File

@ -74,7 +74,7 @@ TrackPitch _previousTrackPitchEnd;
CoordsXYZ _previousTrackPiece;
uint8_t _currentBrakeSpeed2;
uint8_t _currentBrakeSpeed;
uint8_t _currentSeatRotationAngle;
CoordsXYZD _unkF440C5;

View File

@ -62,7 +62,7 @@ extern TrackPitch _previousTrackPitchEnd;
extern CoordsXYZ _previousTrackPiece;
extern uint8_t _currentBrakeSpeed2;
extern uint8_t _currentBrakeSpeed;
extern uint8_t _currentSeatRotationAngle;
extern CoordsXYZD _unkF440C5;

View File

@ -306,45 +306,45 @@ struct TrackDrawerDescriptor
struct RideTypeDescriptor
{
uint8_t Category;
uint8_t Category{};
/** rct2: 0x0097CC68 */
track_type_t StartTrackPiece;
track_type_t StartTrackPiece{};
TrackDrawerDescriptor TrackPaintFunctions{};
TrackDrawerDescriptor InvertedTrackPaintFunctions{};
uint64_t Flags;
uint64_t Flags{};
/** rct2: 0x0097C8AC */
uint64_t RideModes;
RideMode DefaultMode;
uint64_t RideModes{};
RideMode DefaultMode{};
/** rct2: 0x0097CF40 */
RideOperatingSettings OperatingSettings;
RideNaming Naming;
RideNameConvention NameConvention;
const char* EnumName;
uint8_t AvailableBreakdowns;
RideOperatingSettings OperatingSettings{};
RideNaming Naming{};
RideNameConvention NameConvention{};
const char* EnumName{};
uint8_t AvailableBreakdowns{};
/** rct2: 0x0097D218 */
RideHeights Heights;
uint8_t MaxMass;
RideHeights Heights{};
uint8_t MaxMass{};
/** rct2: 0x0097D7C8, 0x0097D7C9, 0x0097D7CA */
RideLiftData LiftData;
RideLiftData LiftData{};
// rct2: 0x0097CD1E
RatingTuple RatingsMultipliers;
UpkeepCostsDescriptor UpkeepCosts;
RatingTuple RatingsMultipliers{};
UpkeepCostsDescriptor UpkeepCosts{};
// rct2: 0x0097DD78
RideBuildCost BuildCosts;
money64 DefaultPrices[RCT2::ObjectLimits::MaxShopItemsPerRideEntry];
std::string_view DefaultMusic;
RideBuildCost BuildCosts{};
money64 DefaultPrices[RCT2::ObjectLimits::MaxShopItemsPerRideEntry]{};
std::string_view DefaultMusic{};
/** rct2: 0x0097D7CB */
ShopItemIndex PhotoItem;
ShopItemIndex PhotoItem{};
/** rct2: 0x0097D21E */
uint8_t BonusValue;
TrackColourPresetList ColourPresets;
RideColourPreview ColourPreview;
RideColourKey ColourKey;
uint8_t BonusValue{};
TrackColourPresetList ColourPresets{};
RideColourPreview ColourPreview{};
RideColourKey ColourKey{};
// json name lookup
std::string_view Name;
std::string_view Name{};
RideRatingsDescriptor RatingsData;
RideRatingsDescriptor RatingsData{};
UpdateRotatingFunction UpdateRotating = UpdateRotatingDefault;

View File

@ -22,6 +22,8 @@ constexpr uint8_t kRCT2DefaultBlockBrakeSpeed = 2;
constexpr int32_t kBlockBrakeBaseSpeed = 0x20364;
constexpr int32_t kBlockBrakeSpeedOffset = kBlockBrakeBaseSpeed - (kRCT2DefaultBlockBrakeSpeed << 16);
constexpr uint8_t kMaximumBrakeSpeed = 30;
using track_type_t = uint16_t;
struct ResultWithMessage;

View File

@ -372,7 +372,7 @@ bool WindowRideConstructionUpdateState(
if (TrackTypeHasSpeedSetting(trackType))
{
properties = _currentBrakeSpeed2;
properties = _currentBrakeSpeed;
}
else
{