Create kMaximumBrakeSpeed

This commit is contained in:
Gymnasiast 2024-04-20 14:47:18 +02:00 committed by Michael Steenbeek
parent 575cd756b3
commit dbbfc2f1d1
No known key found for this signature in database
GPG Key ID: 92EB181D74FDE5EF
6 changed files with 19 additions and 2 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

@ -1336,9 +1336,8 @@ static Widget _rideConstructionWidgets[] = {
else
{
uint8_t* brakesSpeedPtr = &_currentBrakeSpeed2;
uint8_t maxBrakesSpeed = 30;
uint8_t brakesSpeed = *brakesSpeedPtr + 2;
if (brakesSpeed <= maxBrakesSpeed)
if (brakesSpeed <= kMaximumBrakeSpeed)
{
if (_rideConstructionState == RideConstructionState::Selected)
{

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

@ -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;