Merge pull request #21667 from janclod/replace-define-with-constexpr-1

Part of #21421: Replace define with constexpr
This commit is contained in:
Michael Steenbeek 2024-03-26 11:48:35 +01:00 committed by GitHub
commit 8e157bd709
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
33 changed files with 193 additions and 186 deletions

View File

@ -121,6 +121,7 @@ Appreciation for contributors who have provided substantial work, but are no lon
* Alex Parisi (alex-parisi) - Added API for returning metadata from all registered plugins.
## Bug fixes & Refactors
* Claudio Tiecher (janclod)
* (KirilAngelov)
* (halfbro)
* (Myrtle)

View File

@ -55,7 +55,7 @@ namespace OpenRCT2::Ui::Windows
return MapColour2((colour & 0xFF00) >> 8, PALETTE_INDEX_10);
}
constexpr int32_t MAP_WINDOW_MAP_SIZE = MAXIMUM_MAP_SIZE_TECHNICAL * 2;
constexpr int32_t MAP_WINDOW_MAP_SIZE = kMaximumMapSizeTechnical * 2;
static constexpr StringId WINDOW_TITLE = STR_MAP_LABEL;
static constexpr int32_t WH = 259;
@ -131,10 +131,10 @@ static Widget window_map_widgets[] = {
// used in transforming viewport view coordinates to minimap coordinates
// rct2: 0x00981BBC
static constexpr ScreenCoordsXY MiniMapOffsets[] = {
{ MAXIMUM_MAP_SIZE_TECHNICAL - 8, 0 },
{ 2 * MAXIMUM_MAP_SIZE_TECHNICAL - 8, MAXIMUM_MAP_SIZE_TECHNICAL },
{ MAXIMUM_MAP_SIZE_TECHNICAL - 8, 2 * MAXIMUM_MAP_SIZE_TECHNICAL },
{ 0 - 8, MAXIMUM_MAP_SIZE_TECHNICAL },
{ kMaximumMapSizeTechnical - 8, 0 },
{ 2 * kMaximumMapSizeTechnical - 8, kMaximumMapSizeTechnical },
{ kMaximumMapSizeTechnical - 8, 2 * kMaximumMapSizeTechnical },
{ 0 - 8, kMaximumMapSizeTechnical },
};
// clang-format on
@ -691,7 +691,8 @@ static constexpr ScreenCoordsXY MiniMapOffsets[] = {
{
// The practical size is 2 lower than the technical size
size += 2;
size = std::clamp(size, MINIMUM_MAP_SIZE_TECHNICAL, MAXIMUM_MAP_SIZE_TECHNICAL);
size = std::clamp(
size, static_cast<int>(kMinimumMapSizeTechnical), static_cast<int>(kMaximumMapSizeTechnical));
TileCoordsXY newMapSize = GetGameState().MapSize;
if (_resizeDirection != ResizeDirection::X)
@ -1069,7 +1070,7 @@ static constexpr ScreenCoordsXY MiniMapOffsets[] = {
{
int32_t x = 0, y = 0, dx = 0, dy = 0;
int32_t pos = (_currentLine * (MAP_WINDOW_MAP_SIZE - 1)) + MAXIMUM_MAP_SIZE_TECHNICAL - 1;
int32_t pos = (_currentLine * (MAP_WINDOW_MAP_SIZE - 1)) + kMaximumMapSizeTechnical - 1;
auto destinationPosition = ScreenCoordsXY{ pos % MAP_WINDOW_MAP_SIZE, pos / MAP_WINDOW_MAP_SIZE };
auto destination = _mapImageData.data() + (destinationPosition.y * MAP_WINDOW_MAP_SIZE) + destinationPosition.x;
switch (GetCurrentRotation())
@ -1100,7 +1101,7 @@ static constexpr ScreenCoordsXY MiniMapOffsets[] = {
break;
}
for (int32_t i = 0; i < MAXIMUM_MAP_SIZE_TECHNICAL; i++)
for (int32_t i = 0; i < kMaximumMapSizeTechnical; i++)
{
if (!MapIsEdge({ x, y }))
{
@ -1125,7 +1126,7 @@ static constexpr ScreenCoordsXY MiniMapOffsets[] = {
destination = _mapImageData.data() + (destinationPosition.y * MAP_WINDOW_MAP_SIZE) + destinationPosition.x;
}
_currentLine++;
if (_currentLine >= MAXIMUM_MAP_SIZE_TECHNICAL)
if (_currentLine >= kMaximumMapSizeTechnical)
_currentLine = 0;
}
@ -1414,7 +1415,7 @@ static constexpr ScreenCoordsXY MiniMapOffsets[] = {
CoordsXY ScreenToMap(ScreenCoordsXY screenCoords)
{
screenCoords.x = ((screenCoords.x + 8) - MAXIMUM_MAP_SIZE_TECHNICAL) / 2;
screenCoords.x = ((screenCoords.x + 8) - kMaximumMapSizeTechnical) / 2;
screenCoords.y = ((screenCoords.y + 8)) / 2;
auto location = TileCoordsXY(screenCoords.y - screenCoords.x, screenCoords.x + screenCoords.y).ToCoordsXY();
@ -1457,7 +1458,7 @@ static constexpr ScreenCoordsXY MiniMapOffsets[] = {
x /= 32;
y /= 32;
return { -x + y + MAXIMUM_MAP_SIZE_TECHNICAL - 8, x + y - 8 };
return { -x + y + kMaximumMapSizeTechnical - 8, x + y - 8 };
}
void ResizeMap()

View File

@ -405,9 +405,13 @@ static uint64_t PressedWidgets[WINDOW_MAPGEN_PAGE_COUNT] = {
_resizeDirection = ResizeDirection::Both;
if (_resizeDirection != ResizeDirection::X)
_mapSize.y = std::clamp(_mapSize.y + sizeOffset, MINIMUM_MAP_SIZE_TECHNICAL, MAXIMUM_MAP_SIZE_TECHNICAL);
_mapSize.y = std::clamp(
_mapSize.y + sizeOffset, static_cast<int>(kMinimumMapSizeTechnical),
static_cast<int>(kMaximumMapSizeTechnical));
if (_resizeDirection != ResizeDirection::Y)
_mapSize.x = std::clamp(_mapSize.x + sizeOffset, MINIMUM_MAP_SIZE_TECHNICAL, MAXIMUM_MAP_SIZE_TECHNICAL);
_mapSize.x = std::clamp(
_mapSize.x + sizeOffset, static_cast<int>(kMinimumMapSizeTechnical),
static_cast<int>(kMaximumMapSizeTechnical));
}
void InputMapSize(WidgetIndex callingWidget, int32_t currentValue)

View File

@ -2628,7 +2628,7 @@ static Widget _rideConstructionWidgets[] = {
auto& gameState = OpenRCT2::GetGameState();
auto preserveMapSize = gameState.MapSize;
gameState.MapSize = { MAXIMUM_MAP_SIZE_TECHNICAL, MAXIMUM_MAP_SIZE_TECHNICAL };
gameState.MapSize = { kMaximumMapSizeTechnical, kMaximumMapSizeTechnical };
// Setup non changing parts of the temporary track tile element
tempTrackTileElement.SetType(TileElementType::Track);

View File

@ -741,8 +741,7 @@ static uint64_t PageDisabledWidgets[] = {
switch (widgetIndex)
{
case WIDX_SPINNER_X_INCREASE:
windowTileInspectorTile.x = std::min<int32_t>(
windowTileInspectorTile.x + 1, MAXIMUM_MAP_SIZE_TECHNICAL - 1);
windowTileInspectorTile.x = std::min<int32_t>(windowTileInspectorTile.x + 1, kMaximumMapSizeTechnical - 1);
_toolMap.x = std::min<int32_t>(_toolMap.x + 32, MAXIMUM_TILE_START_XY);
LoadTile(nullptr);
break;
@ -754,8 +753,7 @@ static uint64_t PageDisabledWidgets[] = {
break;
case WIDX_SPINNER_Y_INCREASE:
windowTileInspectorTile.y = std::min<int32_t>(
windowTileInspectorTile.y + 1, MAXIMUM_MAP_SIZE_TECHNICAL - 1);
windowTileInspectorTile.y = std::min<int32_t>(windowTileInspectorTile.y + 1, kMaximumMapSizeTechnical - 1);
_toolMap.y = std::min<int32_t>(_toolMap.y + 32, MAXIMUM_TILE_START_XY);
LoadTile(nullptr);
break;
@ -2075,10 +2073,10 @@ static uint64_t PageDisabledWidgets[] = {
}
// X and Y spinners
SetWidgetDisabledAndInvalidate(
WIDX_SPINNER_X_INCREASE, !(_tileSelected && ((_toolMap.x / 32) < MAXIMUM_MAP_SIZE_TECHNICAL - 1)));
WIDX_SPINNER_X_INCREASE, !(_tileSelected && ((_toolMap.x / 32) < kMaximumMapSizeTechnical - 1)));
SetWidgetDisabledAndInvalidate(WIDX_SPINNER_X_DECREASE, !(_tileSelected && ((_toolMap.x / 32) > 0)));
SetWidgetDisabledAndInvalidate(
WIDX_SPINNER_Y_INCREASE, !(_tileSelected && ((_toolMap.y / 32) < MAXIMUM_MAP_SIZE_TECHNICAL - 1)));
WIDX_SPINNER_Y_INCREASE, !(_tileSelected && ((_toolMap.y / 32) < kMaximumMapSizeTechnical - 1)));
SetWidgetDisabledAndInvalidate(WIDX_SPINNER_Y_DECREASE, !(_tileSelected && ((_toolMap.y / 32) > 0)));
// Sort buttons

View File

@ -450,9 +450,9 @@ static void FixInvalidSurfaces()
// Fixes broken saves where a surface element could be null
// and broken saves with incorrect invisible map border tiles
for (int32_t y = 0; y < MAXIMUM_MAP_SIZE_TECHNICAL; y++)
for (int32_t y = 0; y < kMaximumMapSizeTechnical; y++)
{
for (int32_t x = 0; x < MAXIMUM_MAP_SIZE_TECHNICAL; x++)
for (int32_t x = 0; x < kMaximumMapSizeTechnical; x++)
{
auto* surfaceElement = MapGetSurfaceElementAt(TileCoordsXY{ x, y });

View File

@ -135,7 +135,7 @@ GameActions::Result FootpathLayoutPlaceAction::ElementInsertQuery(GameActions::R
auto zHigh = zLow + PATH_CLEARANCE;
if (_slope & FOOTPATH_PROPERTIES_FLAG_IS_SLOPED)
{
quarterTile = QuarterTile{ 0b1111, 0b1100 }.Rotate(_slope & TILE_ELEMENT_DIRECTION_MASK);
quarterTile = QuarterTile{ 0b1111, 0b1100 }.Rotate(_slope & kTileElementDirectionMask);
zHigh += PATH_HEIGHT_STEP;
}
@ -205,7 +205,7 @@ GameActions::Result FootpathLayoutPlaceAction::ElementInsertExecute(GameActions:
auto zHigh = zLow + PATH_CLEARANCE;
if (_slope & FOOTPATH_PROPERTIES_FLAG_IS_SLOPED)
{
quarterTile = QuarterTile{ 0b1111, 0b1100 }.Rotate(_slope & TILE_ELEMENT_DIRECTION_MASK);
quarterTile = QuarterTile{ 0b1111, 0b1100 }.Rotate(_slope & kTileElementDirectionMask);
zHigh += PATH_HEIGHT_STEP;
}

View File

@ -282,7 +282,7 @@ GameActions::Result FootpathPlaceAction::ElementInsertQuery(GameActions::Result
auto zHigh = zLow + PATH_CLEARANCE;
if (_slope & FOOTPATH_PROPERTIES_FLAG_IS_SLOPED)
{
quarterTile = QuarterTile{ 0b1111, 0b1100 }.Rotate(_slope & TILE_ELEMENT_DIRECTION_MASK);
quarterTile = QuarterTile{ 0b1111, 0b1100 }.Rotate(_slope & kTileElementDirectionMask);
zHigh += PATH_HEIGHT_STEP;
}
@ -351,7 +351,7 @@ GameActions::Result FootpathPlaceAction::ElementInsertExecute(GameActions::Resul
auto zHigh = zLow + PATH_CLEARANCE;
if (_slope & FOOTPATH_PROPERTIES_FLAG_IS_SLOPED)
{
quarterTile = QuarterTile{ 0b1111, 0b1100 }.Rotate(_slope & TILE_ELEMENT_DIRECTION_MASK);
quarterTile = QuarterTile{ 0b1111, 0b1100 }.Rotate(_slope & kTileElementDirectionMask);
zHigh += PATH_HEIGHT_STEP;
}

View File

@ -35,11 +35,11 @@ void MapChangeSizeAction::Serialise(DataSerialiser& stream)
GameActions::Result MapChangeSizeAction::Query() const
{
if (_targetSize.x > MAXIMUM_MAP_SIZE_TECHNICAL || _targetSize.y > MAXIMUM_MAP_SIZE_TECHNICAL)
if (_targetSize.x > kMaximumMapSizeTechnical || _targetSize.y > kMaximumMapSizeTechnical)
{
return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_INCREASE_MAP_SIZE_ANY_FURTHER, STR_NONE);
}
if (_targetSize.x < MINIMUM_MAP_SIZE_TECHNICAL || _targetSize.y < MINIMUM_MAP_SIZE_TECHNICAL)
if (_targetSize.x < kMinimumMapSizeTechnical || _targetSize.y < kMinimumMapSizeTechnical)
{
return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_DECREASE_MAP_SIZE_ANY_FURTHER, STR_NONE);
}

View File

@ -412,7 +412,7 @@ bool WallPlaceAction::WallCheckObstructionWithTrack(
using namespace OpenRCT2::TrackMetaData;
const auto& ted = GetTrackElementDescriptor(trackType);
int32_t sequence = trackElement->GetSequenceIndex();
int32_t direction = (_edge - trackElement->GetDirection()) & TILE_ELEMENT_DIRECTION_MASK;
int32_t direction = (_edge - trackElement->GetDirection()) & kTileElementDirectionMask;
auto ride = GetRide(trackElement->GetRideIndex());
if (ride == nullptr)
{
@ -484,7 +484,7 @@ bool WallPlaceAction::WallCheckObstructionWithTrack(
return false;
}
direction = (trackElement->GetDirection() + ted.Coordinates.rotation_end) & TILE_ELEMENT_DIRECTION_MASK;
direction = (trackElement->GetDirection() + ted.Coordinates.rotation_end) & kTileElementDirectionMask;
if (direction != _edge)
{
return false;
@ -561,7 +561,7 @@ GameActions::Result WallPlaceAction::WallCheckObstruction(
auto sequence = largeSceneryElement->GetSequenceIndex();
const LargeSceneryTile& tile = sceneryEntry->tiles[sequence];
int32_t direction = ((_edge - tileElement->GetDirection()) & TILE_ELEMENT_DIRECTION_MASK) + 8;
int32_t direction = ((_edge - tileElement->GetDirection()) & kTileElementDirectionMask) + 8;
if (!(tile.flags & (1 << direction)))
{
MapGetObstructionErrorText(tileElement, res);

View File

@ -44,7 +44,7 @@ static std::vector<EntityId> _freeIdList;
static bool _entityFlashingList[MAX_ENTITIES];
constexpr const uint32_t SPATIAL_INDEX_SIZE = (MAXIMUM_MAP_SIZE_TECHNICAL * MAXIMUM_MAP_SIZE_TECHNICAL) + 1;
constexpr const uint32_t SPATIAL_INDEX_SIZE = (kMaximumMapSizeTechnical * kMaximumMapSizeTechnical) + 1;
constexpr uint32_t SPATIAL_INDEX_LOCATION_NULL = SPATIAL_INDEX_SIZE - 1;
static std::array<std::vector<EntityId>, SPATIAL_INDEX_SIZE> gEntitySpatialIndex;
@ -60,10 +60,10 @@ static constexpr size_t GetSpatialIndexOffset(const CoordsXY& loc)
const auto tileX = std::abs(loc.x) / COORDS_XY_STEP;
const auto tileY = std::abs(loc.y) / COORDS_XY_STEP;
if (tileX >= MAXIMUM_MAP_SIZE_TECHNICAL || tileY >= MAXIMUM_MAP_SIZE_TECHNICAL)
if (tileX >= kMaximumMapSizeTechnical || tileY >= kMaximumMapSizeTechnical)
return SPATIAL_INDEX_LOCATION_NULL;
return tileX * MAXIMUM_MAP_SIZE_TECHNICAL + tileY;
return tileX * kMaximumMapSizeTechnical + tileY;
}
constexpr bool EntityTypeIsMiscEntity(const EntityType type)

View File

@ -2581,7 +2581,7 @@ bool Guest::FindVehicleToEnter(const Ride& ride, std::vector<uint8_t>& car_array
car_array.push_back(i);
return true;
}
num_seats &= VEHICLE_SEAT_NUM_MASK;
num_seats &= kVehicleSeatNumMask;
}
if (num_seats == vehicle->next_free_seat)
continue;

View File

@ -17,7 +17,7 @@
// The number of elements in the GameState_t.StaffPatrolAreas array per staff member. Every bit in the array represents a 4x4
// square. Right now, it's a 32-bit array like in RCT2. 32 * 128 = 4096 bits, which is also the number of 4x4 squares on a
// 256x256 map.
constexpr size_t STAFF_PATROL_AREA_BLOCKS_PER_LINE = MAXIMUM_MAP_SIZE_TECHNICAL / 4;
constexpr size_t STAFF_PATROL_AREA_BLOCKS_PER_LINE = kMaximumMapSizeTechnical / 4;
constexpr size_t STAFF_PATROL_AREA_SIZE = (STAFF_PATROL_AREA_BLOCKS_PER_LINE * STAFF_PATROL_AREA_BLOCKS_PER_LINE) / 32;
class PatrolArea
@ -32,8 +32,8 @@ private:
std::vector<TileCoordsXY> SortedTiles;
};
static constexpr auto CellColumns = (MAXIMUM_MAP_SIZE_TECHNICAL + (Cell::Width - 1)) / Cell::Width;
static constexpr auto CellRows = (MAXIMUM_MAP_SIZE_TECHNICAL + (Cell::Height - 1)) / Cell::Height;
static constexpr auto CellColumns = (kMaximumMapSizeTechnical + (Cell::Width - 1)) / Cell::Width;
static constexpr auto CellRows = (kMaximumMapSizeTechnical + (Cell::Height - 1)) / Cell::Height;
static constexpr auto NumCells = CellColumns * CellRows;
std::array<Cell, NumCells> Areas;

View File

@ -714,7 +714,7 @@ CarEntry RideObject::ReadJsonCar([[maybe_unused]] IReadObjectContext* context, j
car.num_seats = Json::GetNumber<uint8_t>(jCar["numSeats"]);
if (Json::GetBoolean(jCar["seatsInPairs"], true) && car.num_seats > 1)
{
car.num_seats |= VEHICLE_SEAT_PAIR_FLAG;
car.num_seats |= kVehicleSeatPairFlag;
}
car.sprite_width = Json::GetNumber<uint8_t>(jCar["spriteWidth"]);

View File

@ -121,9 +121,9 @@ struct TunnelEntry
uint8_t type;
};
// The maximum size must be MAXIMUM_MAP_SIZE_TECHNICAL multiplied by 2 because
// The maximum size must be kMaximumMapSizeTechnical multiplied by 2 because
// the quadrant index is based on the x and y components combined.
static constexpr int32_t MaxPaintQuadrants = MAXIMUM_MAP_SIZE_TECHNICAL * 2;
static constexpr int32_t MaxPaintQuadrants = kMaximumMapSizeTechnical * 2;
#define TUNNEL_MAX_COUNT 65

View File

@ -1528,9 +1528,9 @@ namespace RCT1
std::vector<TileElement> tileElements;
const auto maxSize = _s4.MapSize == 0 ? Limits::MaxMapSize : _s4.MapSize;
for (TileCoordsXY coords = { 0, 0 }; coords.y < MAXIMUM_MAP_SIZE_TECHNICAL; coords.y++)
for (TileCoordsXY coords = { 0, 0 }; coords.y < kMaximumMapSizeTechnical; coords.y++)
{
for (coords.x = 0; coords.x < MAXIMUM_MAP_SIZE_TECHNICAL; coords.x++)
for (coords.x = 0; coords.x < kMaximumMapSizeTechnical; coords.x++)
{
auto tileAdded = false;
if (coords.x < maxSize && coords.y < maxSize)

View File

@ -31,7 +31,7 @@ using namespace OpenRCT2;
RCT12TileElementType RCT12TileElementBase::GetType() const
{
auto elem_type = static_cast<RCT12TileElementType>((this->Type & TILE_ELEMENT_TYPE_MASK) >> 2);
auto elem_type = static_cast<RCT12TileElementType>((this->Type & kTileElementTypeMask) >> 2);
switch (elem_type)
{
case RCT12TileElementType::Surface:
@ -54,7 +54,7 @@ RCT12TileElementType RCT12TileElementBase::GetType() const
uint8_t RCT12TileElementBase::GetDirection() const
{
return this->Type & TILE_ELEMENT_DIRECTION_MASK;
return this->Type & kTileElementDirectionMask;
}
uint8_t RCT12TileElementBase::GetOccupiedQuadrants() const
@ -308,7 +308,7 @@ uint8_t RCT12SmallSceneryElement::GetAge() const
uint8_t RCT12SmallSceneryElement::GetSceneryQuadrant() const
{
return (this->Type & TILE_ELEMENT_QUADRANT_MASK) >> 6;
return (this->Type & kTileElementQuadrantMask) >> 6;
}
colour_t RCT12SmallSceneryElement::GetPrimaryColour() const
@ -358,7 +358,7 @@ uint8_t RCT12WallElement::GetEntryIndex() const
uint8_t RCT12WallElement::GetSlope() const
{
return (Type & TILE_ELEMENT_QUADRANT_MASK) >> 6;
return (Type & kTileElementQuadrantMask) >> 6;
}
colour_t RCT12WallElement::GetPrimaryColour() const

View File

@ -1802,9 +1802,9 @@ namespace RCT2
bool nextElementInvisible = false;
bool restOfTileInvisible = false;
const auto maxSize = std::min(Limits::MaxMapSize, _s6.MapSize);
for (TileCoordsXY coords = { 0, 0 }; coords.y < MAXIMUM_MAP_SIZE_TECHNICAL; coords.y++)
for (TileCoordsXY coords = { 0, 0 }; coords.y < kMaximumMapSizeTechnical; coords.y++)
{
for (coords.x = 0; coords.x < MAXIMUM_MAP_SIZE_TECHNICAL; coords.x++)
for (coords.x = 0; coords.x < kMaximumMapSizeTechnical; coords.x++)
{
nextElementInvisible = false;
restOfTileInvisible = false;

View File

@ -618,7 +618,7 @@ bool TrackBlockGetNext(CoordsXYE* input, CoordsXYE* output, int32_t* z, int32_t*
OriginZ -= trackBlock->z;
OriginZ += trackCoordinate.z_end;
uint8_t directionStart = ((trackCoordinate.rotation_end + rotation) & TILE_ELEMENT_DIRECTION_MASK)
uint8_t directionStart = ((trackCoordinate.rotation_end + rotation) & kTileElementDirectionMask)
| (trackCoordinate.rotation_end & TRACK_BLOCK_2);
return TrackBlockGetNextFromZero({ coords, OriginZ }, *ride, directionStart, output, z, direction, false);
@ -757,7 +757,7 @@ bool TrackBlockGetPrevious(const CoordsXYE& trackPos, TrackBeginEnd* outTrackBeg
z -= trackBlock->z;
z += trackCoordinate.z_begin;
rotation = ((trackCoordinate.rotation_begin + rotation) & TILE_ELEMENT_DIRECTION_MASK)
rotation = ((trackCoordinate.rotation_begin + rotation) & kTileElementDirectionMask)
| (trackCoordinate.rotation_begin & TRACK_BLOCK_2);
return TrackBlockGetPreviousFromZero({ coords, z }, *ride, rotation, outTrackBeginEnd);

View File

@ -307,7 +307,7 @@ ResultWithMessage TrackDesign::CreateTrackDesignTrack(TrackDesignState& tds, con
Direction entranceDirection = tileElement->GetDirection();
entranceDirection -= _saveDirection;
entranceDirection &= TILE_ELEMENT_DIRECTION_MASK;
entranceDirection &= kTileElementDirectionMask;
mapLocation -= tds.Origin;
// Rotate entrance coordinates backwards to the correct direction
@ -973,7 +973,7 @@ static GameActions::Result TrackDesignPlaceSceneryElementRemoveGhost(
}
int32_t z = scenery.loc.z + originZ;
uint8_t sceneryRotation = (rotation + scenery.flags) & TILE_ELEMENT_DIRECTION_MASK;
uint8_t sceneryRotation = (rotation + scenery.flags) & kTileElementDirectionMask;
const uint32_t flags = GAME_COMMAND_FLAG_APPLY | GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_NO_SPEND
| GAME_COMMAND_FLAG_GHOST;
std::unique_ptr<GameAction> ga;
@ -2098,7 +2098,7 @@ void TrackDesignDrawPreview(TrackDesign* td6, uint8_t* pixels)
*/
static void TrackDesignPreviewClearMap()
{
auto numTiles = MAXIMUM_MAP_SIZE_TECHNICAL * MAXIMUM_MAP_SIZE_TECHNICAL;
auto numTiles = kMaximumMapSizeTechnical * kMaximumMapSizeTechnical;
GetGameState().MapSize = TRACK_DESIGN_PREVIEW_MAP_SIZE;

View File

@ -5115,7 +5115,7 @@ Vehicle* Vehicle::TrainTail() const
int32_t Vehicle::IsUsedInPairs() const
{
return num_seats & VEHICLE_SEAT_PAIR_FLAG;
return num_seats & kVehicleSeatPairFlag;
}
/**

View File

@ -516,8 +516,8 @@ enum
SOUND_RANGE_NONE = 255
};
#define VEHICLE_SEAT_PAIR_FLAG 0x80
#define VEHICLE_SEAT_NUM_MASK 0x7F
constexpr uint8_t kVehicleSeatPairFlag = 0x80;
constexpr uint8_t kVehicleSeatNumMask = 0x7F;
Vehicle* TryGetVehicle(EntityId spriteIndex);
void VehicleUpdateAll();

View File

@ -10,7 +10,10 @@
#include "../entity/EntityRegistry.h"
#include "Vehicle.h"
#define MPH(x) (x * 29127)
constexpr int operator"" _MPH(unsigned long long x)
{
return x * 29127;
}
// Acceleration to apply when rider is braking
constexpr int32_t minBrake = (1 << 16);
@ -20,7 +23,7 @@ constexpr int32_t minBrake = (1 << 16);
constexpr int32_t maxBrake = (12 << 16);
// Velocity above which riders will attempt to maintain separation from the vehicle in front
constexpr int32_t minFollowVelocity = MPH(4);
constexpr int32_t minFollowVelocity = 4_MPH;
// Minimum separation distance that riders will allow (regardless of followDistance)
constexpr int32_t minFollowDistance = 32;
@ -35,92 +38,92 @@ struct RiderControlSettings
};
static RiderControlSettings riderTable[256] = {
{ MPH(22), MPH(11), MPH(10), 10 }, { MPH(23), MPH(10), MPH(5), 9 }, { MPH(23), MPH(8), MPH(7), 11 },
{ MPH(27), MPH(17), MPH(12), 6 }, { MPH(25), MPH(18), MPH(15), 6 }, { MPH(23), MPH(14), MPH(12), 9 },
{ MPH(20), MPH(12), MPH(12), 5 }, { MPH(23), MPH(10), MPH(5), 11 }, { MPH(26), MPH(9), MPH(4), 11 },
{ MPH(16), MPH(11), MPH(9), 7 }, { MPH(28), MPH(10), MPH(9), 10 }, { MPH(24), MPH(18), MPH(8), 4 },
{ MPH(23), MPH(15), MPH(13), 5 }, { MPH(18), MPH(10), MPH(10), 10 }, { MPH(25), MPH(15), MPH(8), 9 },
{ MPH(18), MPH(12), MPH(12), 7 }, { MPH(24), MPH(14), MPH(7), 7 }, { MPH(27), MPH(19), MPH(13), 7 },
{ MPH(26), MPH(19), MPH(9), 5 }, { MPH(22), MPH(10), MPH(6), 9 }, { MPH(20), MPH(12), MPH(11), 10 },
{ MPH(27), MPH(16), MPH(12), 7 }, { MPH(22), MPH(13), MPH(10), 7 }, { MPH(23), MPH(11), MPH(10), 11 },
{ MPH(17), MPH(10), MPH(9), 8 }, { MPH(19), MPH(13), MPH(10), 5 }, { MPH(14), MPH(8), MPH(11), 10 },
{ MPH(22), MPH(15), MPH(12), 8 }, { MPH(15), MPH(7), MPH(8), 8 }, { MPH(23), MPH(17), MPH(14), 4 },
{ MPH(25), MPH(14), MPH(13), 7 }, { MPH(22), MPH(8), MPH(6), 13 }, { MPH(27), MPH(11), MPH(6), 11 },
{ MPH(19), MPH(10), MPH(9), 11 }, { MPH(24), MPH(13), MPH(11), 7 }, { MPH(12), MPH(7), MPH(8), 7 },
{ MPH(27), MPH(11), MPH(5), 9 }, { MPH(15), MPH(9), MPH(7), 7 }, { MPH(16), MPH(10), MPH(9), 8 },
{ MPH(11), MPH(7), MPH(7), 9 }, { MPH(25), MPH(17), MPH(9), 6 }, { MPH(22), MPH(10), MPH(4), 13 },
{ MPH(25), MPH(13), MPH(7), 10 }, { MPH(28), MPH(18), MPH(10), 5 }, { MPH(21), MPH(11), MPH(10), 10 },
{ MPH(23), MPH(11), MPH(11), 7 }, { MPH(21), MPH(15), MPH(8), 5 }, { MPH(27), MPH(14), MPH(6), 9 },
{ MPH(26), MPH(17), MPH(12), 6 }, { MPH(17), MPH(7), MPH(6), 12 }, { MPH(17), MPH(9), MPH(8), 9 },
{ MPH(17), MPH(10), MPH(12), 6 }, { MPH(20), MPH(10), MPH(9), 9 }, { MPH(26), MPH(14), MPH(10), 7 },
{ MPH(28), MPH(14), MPH(7), 12 }, { MPH(24), MPH(11), MPH(7), 9 }, { MPH(26), MPH(12), MPH(6), 8 },
{ MPH(24), MPH(12), MPH(11), 9 }, { MPH(24), MPH(11), MPH(5), 7 }, { MPH(29), MPH(21), MPH(16), 5 },
{ MPH(22), MPH(13), MPH(13), 5 }, { MPH(27), MPH(20), MPH(12), 6 }, { MPH(21), MPH(14), MPH(7), 9 },
{ MPH(27), MPH(18), MPH(7), 6 }, { MPH(19), MPH(12), MPH(12), 6 }, { MPH(25), MPH(18), MPH(9), 7 },
{ MPH(20), MPH(10), MPH(10), 10 }, { MPH(19), MPH(9), MPH(7), 9 }, { MPH(24), MPH(14), MPH(7), 7 },
{ MPH(25), MPH(12), MPH(10), 10 }, { MPH(24), MPH(15), MPH(8), 7 }, { MPH(23), MPH(11), MPH(6), 8 },
{ MPH(18), MPH(11), MPH(7), 9 }, { MPH(23), MPH(8), MPH(5), 11 }, { MPH(12), MPH(8), MPH(12), 8 },
{ MPH(22), MPH(14), MPH(12), 9 }, { MPH(25), MPH(13), MPH(14), 8 }, { MPH(26), MPH(12), MPH(5), 12 },
{ MPH(29), MPH(15), MPH(6), 10 }, { MPH(20), MPH(12), MPH(8), 9 }, { MPH(25), MPH(13), MPH(10), 8 },
{ MPH(23), MPH(12), MPH(8), 9 }, { MPH(20), MPH(11), MPH(5), 11 }, { MPH(22), MPH(11), MPH(5), 11 },
{ MPH(21), MPH(9), MPH(6), 9 }, { MPH(28), MPH(13), MPH(8), 10 }, { MPH(27), MPH(14), MPH(10), 11 },
{ MPH(22), MPH(16), MPH(10), 5 }, { MPH(25), MPH(14), MPH(9), 6 }, { MPH(20), MPH(10), MPH(7), 10 },
{ MPH(24), MPH(15), MPH(13), 7 }, { MPH(22), MPH(11), MPH(4), 9 }, { MPH(19), MPH(9), MPH(4), 12 },
{ MPH(19), MPH(11), MPH(8), 7 }, { MPH(24), MPH(16), MPH(15), 5 }, { MPH(15), MPH(11), MPH(9), 7 },
{ MPH(25), MPH(10), MPH(7), 10 }, { MPH(23), MPH(11), MPH(5), 9 }, { MPH(24), MPH(13), MPH(11), 8 },
{ MPH(26), MPH(16), MPH(9), 8 }, { MPH(25), MPH(16), MPH(10), 6 }, { MPH(26), MPH(16), MPH(8), 6 },
{ MPH(26), MPH(16), MPH(12), 7 }, { MPH(25), MPH(11), MPH(10), 11 }, { MPH(21), MPH(13), MPH(13), 6 },
{ MPH(9), MPH(6), MPH(4), 11 }, { MPH(26), MPH(11), MPH(5), 10 }, { MPH(25), MPH(18), MPH(14), 5 },
{ MPH(26), MPH(16), MPH(9), 4 }, { MPH(24), MPH(11), MPH(11), 9 }, { MPH(26), MPH(16), MPH(11), 8 },
{ MPH(29), MPH(12), MPH(5), 10 }, { MPH(26), MPH(11), MPH(4), 12 }, { MPH(19), MPH(9), MPH(12), 8 },
{ MPH(18), MPH(8), MPH(5), 12 }, { MPH(28), MPH(11), MPH(4), 10 }, { MPH(25), MPH(16), MPH(10), 8 },
{ MPH(29), MPH(17), MPH(12), 6 }, { MPH(18), MPH(11), MPH(10), 8 }, { MPH(25), MPH(10), MPH(9), 10 },
{ MPH(25), MPH(12), MPH(6), 12 }, { MPH(23), MPH(12), MPH(8), 8 }, { MPH(27), MPH(9), MPH(9), 11 },
{ MPH(27), MPH(19), MPH(10), 3 }, { MPH(28), MPH(12), MPH(10), 8 }, { MPH(25), MPH(14), MPH(10), 7 },
{ MPH(28), MPH(17), MPH(8), 7 }, { MPH(24), MPH(13), MPH(4), 9 }, { MPH(25), MPH(12), MPH(8), 9 },
{ MPH(18), MPH(9), MPH(6), 13 }, { MPH(19), MPH(8), MPH(7), 11 }, { MPH(28), MPH(12), MPH(7), 10 },
{ MPH(21), MPH(10), MPH(6), 9 }, { MPH(26), MPH(13), MPH(8), 9 }, { MPH(21), MPH(12), MPH(12), 6 },
{ MPH(25), MPH(15), MPH(8), 5 }, { MPH(17), MPH(12), MPH(13), 7 }, { MPH(20), MPH(9), MPH(6), 12 },
{ MPH(27), MPH(18), MPH(13), 5 }, { MPH(22), MPH(14), MPH(14), 5 }, { MPH(19), MPH(12), MPH(15), 5 },
{ MPH(26), MPH(13), MPH(10), 10 }, { MPH(23), MPH(11), MPH(8), 10 }, { MPH(28), MPH(17), MPH(11), 8 },
{ MPH(23), MPH(9), MPH(5), 10 }, { MPH(20), MPH(11), MPH(10), 7 }, { MPH(24), MPH(9), MPH(7), 12 },
{ MPH(25), MPH(13), MPH(8), 8 }, { MPH(25), MPH(18), MPH(14), 6 }, { MPH(22), MPH(16), MPH(12), 7 },
{ MPH(21), MPH(12), MPH(11), 8 }, { MPH(22), MPH(16), MPH(10), 6 }, { MPH(21), MPH(15), MPH(11), 6 },
{ MPH(24), MPH(16), MPH(12), 7 }, { MPH(28), MPH(21), MPH(9), 4 }, { MPH(26), MPH(14), MPH(12), 8 },
{ MPH(23), MPH(13), MPH(8), 7 }, { MPH(26), MPH(16), MPH(14), 7 }, { MPH(23), MPH(14), MPH(8), 7 },
{ MPH(21), MPH(13), MPH(8), 7 }, { MPH(26), MPH(17), MPH(7), 6 }, { MPH(28), MPH(10), MPH(9), 10 },
{ MPH(28), MPH(11), MPH(6), 12 }, { MPH(21), MPH(9), MPH(9), 10 }, { MPH(27), MPH(12), MPH(10), 9 },
{ MPH(20), MPH(10), MPH(11), 8 }, { MPH(26), MPH(17), MPH(15), 6 }, { MPH(23), MPH(9), MPH(6), 11 },
{ MPH(26), MPH(17), MPH(10), 8 }, { MPH(22), MPH(13), MPH(12), 9 }, { MPH(24), MPH(12), MPH(11), 8 },
{ MPH(27), MPH(17), MPH(9), 7 }, { MPH(27), MPH(14), MPH(7), 10 }, { MPH(26), MPH(9), MPH(6), 9 },
{ MPH(23), MPH(10), MPH(11), 9 }, { MPH(30), MPH(23), MPH(10), 3 }, { MPH(14), MPH(7), MPH(7), 10 },
{ MPH(25), MPH(12), MPH(9), 10 }, { MPH(20), MPH(12), MPH(8), 4 }, { MPH(24), MPH(16), MPH(12), 7 },
{ MPH(24), MPH(13), MPH(6), 10 }, { MPH(24), MPH(14), MPH(9), 5 }, { MPH(27), MPH(14), MPH(7), 8 },
{ MPH(26), MPH(12), MPH(9), 9 }, { MPH(23), MPH(14), MPH(8), 8 }, { MPH(25), MPH(16), MPH(11), 6 },
{ MPH(29), MPH(17), MPH(7), 9 }, { MPH(25), MPH(17), MPH(15), 5 }, { MPH(27), MPH(16), MPH(11), 4 },
{ MPH(13), MPH(8), MPH(10), 10 }, { MPH(27), MPH(17), MPH(8), 7 }, { MPH(22), MPH(13), MPH(6), 7 },
{ MPH(25), MPH(18), MPH(16), 4 }, { MPH(23), MPH(12), MPH(6), 8 }, { MPH(22), MPH(16), MPH(12), 5 },
{ MPH(25), MPH(14), MPH(10), 6 }, { MPH(19), MPH(11), MPH(10), 8 }, { MPH(24), MPH(10), MPH(10), 8 },
{ MPH(27), MPH(17), MPH(12), 7 }, { MPH(27), MPH(16), MPH(12), 5 }, { MPH(24), MPH(16), MPH(8), 7 },
{ MPH(20), MPH(9), MPH(8), 9 }, { MPH(27), MPH(19), MPH(15), 4 }, { MPH(21), MPH(10), MPH(11), 8 },
{ MPH(17), MPH(8), MPH(5), 11 }, { MPH(16), MPH(10), MPH(10), 8 }, { MPH(29), MPH(18), MPH(10), 7 },
{ MPH(23), MPH(16), MPH(14), 5 }, { MPH(16), MPH(8), MPH(6), 10 }, { MPH(24), MPH(10), MPH(8), 11 },
{ MPH(21), MPH(11), MPH(7), 11 }, { MPH(26), MPH(13), MPH(8), 7 }, { MPH(22), MPH(10), MPH(8), 11 },
{ MPH(25), MPH(13), MPH(11), 9 }, { MPH(24), MPH(15), MPH(8), 5 }, { MPH(26), MPH(12), MPH(6), 8 },
{ MPH(21), MPH(15), MPH(15), 7 }, { MPH(28), MPH(19), MPH(14), 6 }, { MPH(23), MPH(14), MPH(9), 8 },
{ MPH(25), MPH(13), MPH(6), 9 }, { MPH(18), MPH(11), MPH(12), 7 }, { MPH(22), MPH(13), MPH(7), 6 },
{ MPH(23), MPH(13), MPH(7), 8 }, { MPH(27), MPH(18), MPH(9), 5 }, { MPH(20), MPH(9), MPH(6), 10 },
{ MPH(29), MPH(9), MPH(9), 12 }, { MPH(26), MPH(12), MPH(9), 11 }, { MPH(27), MPH(10), MPH(5), 11 },
{ MPH(26), MPH(20), MPH(9), 3 }, { MPH(18), MPH(10), MPH(11), 8 }, { MPH(28), MPH(16), MPH(12), 8 },
{ MPH(13), MPH(9), MPH(7), 9 }, { MPH(24), MPH(15), MPH(9), 6 }, { MPH(20), MPH(11), MPH(9), 8 },
{ MPH(24), MPH(15), MPH(12), 4 }, { MPH(24), MPH(14), MPH(9), 5 }, { MPH(22), MPH(11), MPH(8), 10 },
{ MPH(24), MPH(11), MPH(10), 10 }, { MPH(24), MPH(17), MPH(10), 7 }, { MPH(28), MPH(18), MPH(13), 7 },
{ MPH(23), MPH(11), MPH(8), 12 }, { MPH(25), MPH(12), MPH(11), 8 }, { MPH(21), MPH(10), MPH(11), 8 },
{ MPH(15), MPH(8), MPH(7), 10 }, { MPH(26), MPH(16), MPH(9), 8 }, { MPH(21), MPH(10), MPH(9), 10 },
{ MPH(27), MPH(17), MPH(16), 6 }, { MPH(22), MPH(12), MPH(6), 9 }, { MPH(25), MPH(9), MPH(4), 11 },
{ MPH(26), MPH(16), MPH(13), 9 }, { MPH(26), MPH(19), MPH(11), 6 }, { MPH(24), MPH(15), MPH(13), 7 },
{ MPH(16), MPH(9), MPH(10), 8 }, { MPH(21), MPH(11), MPH(7), 6 }, { MPH(28), MPH(20), MPH(15), 6 },
{ MPH(25), MPH(15), MPH(9), 6 }
{ 22_MPH, 11_MPH, 10_MPH, 10 }, { 23_MPH, 10_MPH, 5_MPH, 9 }, { 23_MPH, 8_MPH, 7_MPH, 11 },
{ 27_MPH, 17_MPH, 12_MPH, 6 }, { 25_MPH, 18_MPH, 15_MPH, 6 }, { 23_MPH, 14_MPH, 12_MPH, 9 },
{ 20_MPH, 12_MPH, 12_MPH, 5 }, { 23_MPH, 10_MPH, 5_MPH, 11 }, { 26_MPH, 9_MPH, 4_MPH, 11 },
{ 16_MPH, 11_MPH, 9_MPH, 7 }, { 28_MPH, 10_MPH, 9_MPH, 10 }, { 24_MPH, 18_MPH, 8_MPH, 4 },
{ 23_MPH, 15_MPH, 13_MPH, 5 }, { 18_MPH, 10_MPH, 10_MPH, 10 }, { 25_MPH, 15_MPH, 8_MPH, 9 },
{ 18_MPH, 12_MPH, 12_MPH, 7 }, { 24_MPH, 14_MPH, 7_MPH, 7 }, { 27_MPH, 19_MPH, 13_MPH, 7 },
{ 26_MPH, 19_MPH, 9_MPH, 5 }, { 22_MPH, 10_MPH, 6_MPH, 9 }, { 20_MPH, 12_MPH, 11_MPH, 10 },
{ 27_MPH, 16_MPH, 12_MPH, 7 }, { 22_MPH, 13_MPH, 10_MPH, 7 }, { 23_MPH, 11_MPH, 10_MPH, 11 },
{ 17_MPH, 10_MPH, 9_MPH, 8 }, { 19_MPH, 13_MPH, 10_MPH, 5 }, { 14_MPH, 8_MPH, 11_MPH, 10 },
{ 22_MPH, 15_MPH, 12_MPH, 8 }, { 15_MPH, 7_MPH, 8_MPH, 8 }, { 23_MPH, 17_MPH, 14_MPH, 4 },
{ 25_MPH, 14_MPH, 13_MPH, 7 }, { 22_MPH, 8_MPH, 6_MPH, 13 }, { 27_MPH, 11_MPH, 6_MPH, 11 },
{ 19_MPH, 10_MPH, 9_MPH, 11 }, { 24_MPH, 13_MPH, 11_MPH, 7 }, { 12_MPH, 7_MPH, 8_MPH, 7 },
{ 27_MPH, 11_MPH, 5_MPH, 9 }, { 15_MPH, 9_MPH, 7_MPH, 7 }, { 16_MPH, 10_MPH, 9_MPH, 8 },
{ 11_MPH, 7_MPH, 7_MPH, 9 }, { 25_MPH, 17_MPH, 9_MPH, 6 }, { 22_MPH, 10_MPH, 4_MPH, 13 },
{ 25_MPH, 13_MPH, 7_MPH, 10 }, { 28_MPH, 18_MPH, 10_MPH, 5 }, { 21_MPH, 11_MPH, 10_MPH, 10 },
{ 23_MPH, 11_MPH, 11_MPH, 7 }, { 21_MPH, 15_MPH, 8_MPH, 5 }, { 27_MPH, 14_MPH, 6_MPH, 9 },
{ 26_MPH, 17_MPH, 12_MPH, 6 }, { 17_MPH, 7_MPH, 6_MPH, 12 }, { 17_MPH, 9_MPH, 8_MPH, 9 },
{ 17_MPH, 10_MPH, 12_MPH, 6 }, { 20_MPH, 10_MPH, 9_MPH, 9 }, { 26_MPH, 14_MPH, 10_MPH, 7 },
{ 28_MPH, 14_MPH, 7_MPH, 12 }, { 24_MPH, 11_MPH, 7_MPH, 9 }, { 26_MPH, 12_MPH, 6_MPH, 8 },
{ 24_MPH, 12_MPH, 11_MPH, 9 }, { 24_MPH, 11_MPH, 5_MPH, 7 }, { 29_MPH, 21_MPH, 16_MPH, 5 },
{ 22_MPH, 13_MPH, 13_MPH, 5 }, { 27_MPH, 20_MPH, 12_MPH, 6 }, { 21_MPH, 14_MPH, 7_MPH, 9 },
{ 27_MPH, 18_MPH, 7_MPH, 6 }, { 19_MPH, 12_MPH, 12_MPH, 6 }, { 25_MPH, 18_MPH, 9_MPH, 7 },
{ 20_MPH, 10_MPH, 10_MPH, 10 }, { 19_MPH, 9_MPH, 7_MPH, 9 }, { 24_MPH, 14_MPH, 7_MPH, 7 },
{ 25_MPH, 12_MPH, 10_MPH, 10 }, { 24_MPH, 15_MPH, 8_MPH, 7 }, { 23_MPH, 11_MPH, 6_MPH, 8 },
{ 18_MPH, 11_MPH, 7_MPH, 9 }, { 23_MPH, 8_MPH, 5_MPH, 11 }, { 12_MPH, 8_MPH, 12_MPH, 8 },
{ 22_MPH, 14_MPH, 12_MPH, 9 }, { 25_MPH, 13_MPH, 14_MPH, 8 }, { 26_MPH, 12_MPH, 5_MPH, 12 },
{ 29_MPH, 15_MPH, 6_MPH, 10 }, { 20_MPH, 12_MPH, 8_MPH, 9 }, { 25_MPH, 13_MPH, 10_MPH, 8 },
{ 23_MPH, 12_MPH, 8_MPH, 9 }, { 20_MPH, 11_MPH, 5_MPH, 11 }, { 22_MPH, 11_MPH, 5_MPH, 11 },
{ 21_MPH, 9_MPH, 6_MPH, 9 }, { 28_MPH, 13_MPH, 8_MPH, 10 }, { 27_MPH, 14_MPH, 10_MPH, 11 },
{ 22_MPH, 16_MPH, 10_MPH, 5 }, { 25_MPH, 14_MPH, 9_MPH, 6 }, { 20_MPH, 10_MPH, 7_MPH, 10 },
{ 24_MPH, 15_MPH, 13_MPH, 7 }, { 22_MPH, 11_MPH, 4_MPH, 9 }, { 19_MPH, 9_MPH, 4_MPH, 12 },
{ 19_MPH, 11_MPH, 8_MPH, 7 }, { 24_MPH, 16_MPH, 15_MPH, 5 }, { 15_MPH, 11_MPH, 9_MPH, 7 },
{ 25_MPH, 10_MPH, 7_MPH, 10 }, { 23_MPH, 11_MPH, 5_MPH, 9 }, { 24_MPH, 13_MPH, 11_MPH, 8 },
{ 26_MPH, 16_MPH, 9_MPH, 8 }, { 25_MPH, 16_MPH, 10_MPH, 6 }, { 26_MPH, 16_MPH, 8_MPH, 6 },
{ 26_MPH, 16_MPH, 12_MPH, 7 }, { 25_MPH, 11_MPH, 10_MPH, 11 }, { 21_MPH, 13_MPH, 13_MPH, 6 },
{ 9_MPH, 6_MPH, 4_MPH, 11 }, { 26_MPH, 11_MPH, 5_MPH, 10 }, { 25_MPH, 18_MPH, 14_MPH, 5 },
{ 26_MPH, 16_MPH, 9_MPH, 4 }, { 24_MPH, 11_MPH, 11_MPH, 9 }, { 26_MPH, 16_MPH, 11_MPH, 8 },
{ 29_MPH, 12_MPH, 5_MPH, 10 }, { 26_MPH, 11_MPH, 4_MPH, 12 }, { 19_MPH, 9_MPH, 12_MPH, 8 },
{ 18_MPH, 8_MPH, 5_MPH, 12 }, { 28_MPH, 11_MPH, 4_MPH, 10 }, { 25_MPH, 16_MPH, 10_MPH, 8 },
{ 29_MPH, 17_MPH, 12_MPH, 6 }, { 18_MPH, 11_MPH, 10_MPH, 8 }, { 25_MPH, 10_MPH, 9_MPH, 10 },
{ 25_MPH, 12_MPH, 6_MPH, 12 }, { 23_MPH, 12_MPH, 8_MPH, 8 }, { 27_MPH, 9_MPH, 9_MPH, 11 },
{ 27_MPH, 19_MPH, 10_MPH, 3 }, { 28_MPH, 12_MPH, 10_MPH, 8 }, { 25_MPH, 14_MPH, 10_MPH, 7 },
{ 28_MPH, 17_MPH, 8_MPH, 7 }, { 24_MPH, 13_MPH, 4_MPH, 9 }, { 25_MPH, 12_MPH, 8_MPH, 9 },
{ 18_MPH, 9_MPH, 6_MPH, 13 }, { 19_MPH, 8_MPH, 7_MPH, 11 }, { 28_MPH, 12_MPH, 7_MPH, 10 },
{ 21_MPH, 10_MPH, 6_MPH, 9 }, { 26_MPH, 13_MPH, 8_MPH, 9 }, { 21_MPH, 12_MPH, 12_MPH, 6 },
{ 25_MPH, 15_MPH, 8_MPH, 5 }, { 17_MPH, 12_MPH, 13_MPH, 7 }, { 20_MPH, 9_MPH, 6_MPH, 12 },
{ 27_MPH, 18_MPH, 13_MPH, 5 }, { 22_MPH, 14_MPH, 14_MPH, 5 }, { 19_MPH, 12_MPH, 15_MPH, 5 },
{ 26_MPH, 13_MPH, 10_MPH, 10 }, { 23_MPH, 11_MPH, 8_MPH, 10 }, { 28_MPH, 17_MPH, 11_MPH, 8 },
{ 23_MPH, 9_MPH, 5_MPH, 10 }, { 20_MPH, 11_MPH, 10_MPH, 7 }, { 24_MPH, 9_MPH, 7_MPH, 12 },
{ 25_MPH, 13_MPH, 8_MPH, 8 }, { 25_MPH, 18_MPH, 14_MPH, 6 }, { 22_MPH, 16_MPH, 12_MPH, 7 },
{ 21_MPH, 12_MPH, 11_MPH, 8 }, { 22_MPH, 16_MPH, 10_MPH, 6 }, { 21_MPH, 15_MPH, 11_MPH, 6 },
{ 24_MPH, 16_MPH, 12_MPH, 7 }, { 28_MPH, 21_MPH, 9_MPH, 4 }, { 26_MPH, 14_MPH, 12_MPH, 8 },
{ 23_MPH, 13_MPH, 8_MPH, 7 }, { 26_MPH, 16_MPH, 14_MPH, 7 }, { 23_MPH, 14_MPH, 8_MPH, 7 },
{ 21_MPH, 13_MPH, 8_MPH, 7 }, { 26_MPH, 17_MPH, 7_MPH, 6 }, { 28_MPH, 10_MPH, 9_MPH, 10 },
{ 28_MPH, 11_MPH, 6_MPH, 12 }, { 21_MPH, 9_MPH, 9_MPH, 10 }, { 27_MPH, 12_MPH, 10_MPH, 9 },
{ 20_MPH, 10_MPH, 11_MPH, 8 }, { 26_MPH, 17_MPH, 15_MPH, 6 }, { 23_MPH, 9_MPH, 6_MPH, 11 },
{ 26_MPH, 17_MPH, 10_MPH, 8 }, { 22_MPH, 13_MPH, 12_MPH, 9 }, { 24_MPH, 12_MPH, 11_MPH, 8 },
{ 27_MPH, 17_MPH, 9_MPH, 7 }, { 27_MPH, 14_MPH, 7_MPH, 10 }, { 26_MPH, 9_MPH, 6_MPH, 9 },
{ 23_MPH, 10_MPH, 11_MPH, 9 }, { 30_MPH, 23_MPH, 10_MPH, 3 }, { 14_MPH, 7_MPH, 7_MPH, 10 },
{ 25_MPH, 12_MPH, 9_MPH, 10 }, { 20_MPH, 12_MPH, 8_MPH, 4 }, { 24_MPH, 16_MPH, 12_MPH, 7 },
{ 24_MPH, 13_MPH, 6_MPH, 10 }, { 24_MPH, 14_MPH, 9_MPH, 5 }, { 27_MPH, 14_MPH, 7_MPH, 8 },
{ 26_MPH, 12_MPH, 9_MPH, 9 }, { 23_MPH, 14_MPH, 8_MPH, 8 }, { 25_MPH, 16_MPH, 11_MPH, 6 },
{ 29_MPH, 17_MPH, 7_MPH, 9 }, { 25_MPH, 17_MPH, 15_MPH, 5 }, { 27_MPH, 16_MPH, 11_MPH, 4 },
{ 13_MPH, 8_MPH, 10_MPH, 10 }, { 27_MPH, 17_MPH, 8_MPH, 7 }, { 22_MPH, 13_MPH, 6_MPH, 7 },
{ 25_MPH, 18_MPH, 16_MPH, 4 }, { 23_MPH, 12_MPH, 6_MPH, 8 }, { 22_MPH, 16_MPH, 12_MPH, 5 },
{ 25_MPH, 14_MPH, 10_MPH, 6 }, { 19_MPH, 11_MPH, 10_MPH, 8 }, { 24_MPH, 10_MPH, 10_MPH, 8 },
{ 27_MPH, 17_MPH, 12_MPH, 7 }, { 27_MPH, 16_MPH, 12_MPH, 5 }, { 24_MPH, 16_MPH, 8_MPH, 7 },
{ 20_MPH, 9_MPH, 8_MPH, 9 }, { 27_MPH, 19_MPH, 15_MPH, 4 }, { 21_MPH, 10_MPH, 11_MPH, 8 },
{ 17_MPH, 8_MPH, 5_MPH, 11 }, { 16_MPH, 10_MPH, 10_MPH, 8 }, { 29_MPH, 18_MPH, 10_MPH, 7 },
{ 23_MPH, 16_MPH, 14_MPH, 5 }, { 16_MPH, 8_MPH, 6_MPH, 10 }, { 24_MPH, 10_MPH, 8_MPH, 11 },
{ 21_MPH, 11_MPH, 7_MPH, 11 }, { 26_MPH, 13_MPH, 8_MPH, 7 }, { 22_MPH, 10_MPH, 8_MPH, 11 },
{ 25_MPH, 13_MPH, 11_MPH, 9 }, { 24_MPH, 15_MPH, 8_MPH, 5 }, { 26_MPH, 12_MPH, 6_MPH, 8 },
{ 21_MPH, 15_MPH, 15_MPH, 7 }, { 28_MPH, 19_MPH, 14_MPH, 6 }, { 23_MPH, 14_MPH, 9_MPH, 8 },
{ 25_MPH, 13_MPH, 6_MPH, 9 }, { 18_MPH, 11_MPH, 12_MPH, 7 }, { 22_MPH, 13_MPH, 7_MPH, 6 },
{ 23_MPH, 13_MPH, 7_MPH, 8 }, { 27_MPH, 18_MPH, 9_MPH, 5 }, { 20_MPH, 9_MPH, 6_MPH, 10 },
{ 29_MPH, 9_MPH, 9_MPH, 12 }, { 26_MPH, 12_MPH, 9_MPH, 11 }, { 27_MPH, 10_MPH, 5_MPH, 11 },
{ 26_MPH, 20_MPH, 9_MPH, 3 }, { 18_MPH, 10_MPH, 11_MPH, 8 }, { 28_MPH, 16_MPH, 12_MPH, 8 },
{ 13_MPH, 9_MPH, 7_MPH, 9 }, { 24_MPH, 15_MPH, 9_MPH, 6 }, { 20_MPH, 11_MPH, 9_MPH, 8 },
{ 24_MPH, 15_MPH, 12_MPH, 4 }, { 24_MPH, 14_MPH, 9_MPH, 5 }, { 22_MPH, 11_MPH, 8_MPH, 10 },
{ 24_MPH, 11_MPH, 10_MPH, 10 }, { 24_MPH, 17_MPH, 10_MPH, 7 }, { 28_MPH, 18_MPH, 13_MPH, 7 },
{ 23_MPH, 11_MPH, 8_MPH, 12 }, { 25_MPH, 12_MPH, 11_MPH, 8 }, { 21_MPH, 10_MPH, 11_MPH, 8 },
{ 15_MPH, 8_MPH, 7_MPH, 10 }, { 26_MPH, 16_MPH, 9_MPH, 8 }, { 21_MPH, 10_MPH, 9_MPH, 10 },
{ 27_MPH, 17_MPH, 16_MPH, 6 }, { 22_MPH, 12_MPH, 6_MPH, 9 }, { 25_MPH, 9_MPH, 4_MPH, 11 },
{ 26_MPH, 16_MPH, 13_MPH, 9 }, { 26_MPH, 19_MPH, 11_MPH, 6 }, { 24_MPH, 15_MPH, 13_MPH, 7 },
{ 16_MPH, 9_MPH, 10_MPH, 8 }, { 21_MPH, 11_MPH, 7_MPH, 6 }, { 28_MPH, 20_MPH, 15_MPH, 6 },
{ 25_MPH, 15_MPH, 9_MPH, 6 }
};
int32_t Vehicle::CalculateRiderBraking() const
@ -139,7 +142,7 @@ int32_t Vehicle::CalculateRiderBraking() const
int32_t relativeVelocity = velocity - prevVehicle->velocity;
int32_t z_diff = abs(z - prevVehicle->z);
if (distance < followDistance && z_diff < 16 && relativeVelocity > -MPH(2))
if (distance < followDistance && z_diff < 16 && relativeVelocity > -2_MPH)
{
if (distance < followDistance / 2 || relativeVelocity > riderSettings.brakeThreshold)
{

View File

@ -155,7 +155,7 @@ namespace OpenRCT2::Scripting
uint8_t ScVehicle::numSeats_get() const
{
auto vehicle = GetVehicle();
return vehicle != nullptr ? vehicle->num_seats & VEHICLE_SEAT_NUM_MASK : 0;
return vehicle != nullptr ? vehicle->num_seats & kVehicleSeatNumMask : 0;
}
void ScVehicle::numSeats_set(uint8_t value)
{
@ -163,8 +163,8 @@ namespace OpenRCT2::Scripting
auto vehicle = GetVehicle();
if (vehicle != nullptr)
{
vehicle->num_seats &= ~VEHICLE_SEAT_NUM_MASK;
vehicle->num_seats |= value & VEHICLE_SEAT_NUM_MASK;
vehicle->num_seats &= ~kVehicleSeatNumMask;
vehicle->num_seats |= value & kVehicleSeatNumMask;
}
}

View File

@ -887,7 +887,7 @@ static void Loc6A6D7E(
{
return;
}
uint16_t dx = DirectionReverse((direction - tileElement->GetDirection()) & TILE_ELEMENT_DIRECTION_MASK);
uint16_t dx = DirectionReverse((direction - tileElement->GetDirection()) & kTileElementDirectionMask);
if (!(ted.SequenceProperties[trackSequence] & (1 << dx)))
{
@ -973,7 +973,7 @@ static void Loc6A6C85(
{
return;
}
uint16_t dx = (direction - tileElementPos.element->GetDirection()) & TILE_ELEMENT_DIRECTION_MASK;
uint16_t dx = (direction - tileElementPos.element->GetDirection()) & kTileElementDirectionMask;
if (!(ted.SequenceProperties[trackSequence] & (1 << dx)))
{
return;
@ -2215,7 +2215,7 @@ bool TileElementWantsPathConnectionTowards(const TileCoordsXYZD& coords, const T
const auto& ted = GetTrackElementDescriptor(trackType);
if (ted.SequenceProperties[trackSequence] & TRACK_SEQUENCE_FLAG_CONNECTS_TO_PATH)
{
uint16_t dx = ((coords.direction - tileElement->GetDirection()) & TILE_ELEMENT_DIRECTION_MASK);
uint16_t dx = ((coords.direction - tileElement->GetDirection()) & kTileElementDirectionMask);
if (ted.SequenceProperties[trackSequence] & (1 << dx))
{
// Track element has the flags required for the given direction

View File

@ -152,7 +152,7 @@ void SetTileElements(std::vector<TileElement>&& tileElements)
auto& gameState = GetGameState();
gameState.TileElements = std::move(tileElements);
_tileIndex = TilePointerIndex<TileElement>(
MAXIMUM_MAP_SIZE_TECHNICAL, gameState.TileElements.data(), gameState.TileElements.size());
kMaximumMapSizeTechnical, gameState.TileElements.data(), gameState.TileElements.size());
_tileElementsInUse = gameState.TileElements.size();
}
@ -177,9 +177,9 @@ std::vector<TileElement> GetReorganisedTileElementsWithoutGhosts()
{
std::vector<TileElement> newElements;
newElements.reserve(std::max(MIN_TILE_ELEMENTS, GetGameState().TileElements.size()));
for (int32_t y = 0; y < MAXIMUM_MAP_SIZE_TECHNICAL; y++)
for (int32_t y = 0; y < kMaximumMapSizeTechnical; y++)
{
for (int32_t x = 0; x < MAXIMUM_MAP_SIZE_TECHNICAL; x++)
for (int32_t x = 0; x < kMaximumMapSizeTechnical; x++)
{
auto oldSize = newElements.size();
@ -217,9 +217,9 @@ static void ReorganiseTileElements(size_t capacity)
std::vector<TileElement> newElements;
newElements.reserve(std::max(MIN_TILE_ELEMENTS, capacity));
for (int32_t y = 0; y < MAXIMUM_MAP_SIZE_TECHNICAL; y++)
for (int32_t y = 0; y < kMaximumMapSizeTechnical; y++)
{
for (int32_t x = 0; x < MAXIMUM_MAP_SIZE_TECHNICAL; x++)
for (int32_t x = 0; x < kMaximumMapSizeTechnical; x++)
{
const auto* element = MapGetFirstElementAt(TileCoordsXY{ x, y });
if (element == nullptr)
@ -336,8 +336,8 @@ void TileElementIteratorRestartForTile(TileElementIterator* it)
static bool IsTileLocationValid(const TileCoordsXY& coords)
{
const bool is_x_valid = coords.x < MAXIMUM_MAP_SIZE_TECHNICAL && coords.x >= 0;
const bool is_y_valid = coords.y < MAXIMUM_MAP_SIZE_TECHNICAL && coords.y >= 0;
const bool is_x_valid = coords.x < kMaximumMapSizeTechnical && coords.x >= 0;
const bool is_y_valid = coords.y < kMaximumMapSizeTechnical && coords.y >= 0;
return is_x_valid && is_y_valid;
}
@ -454,7 +454,7 @@ BannerElement* MapGetBannerElementAt(const CoordsXYZ& bannerPos, uint8_t positio
*/
void MapInit(const TileCoordsXY& size)
{
auto numTiles = MAXIMUM_MAP_SIZE_TECHNICAL * MAXIMUM_MAP_SIZE_TECHNICAL;
auto numTiles = kMaximumMapSizeTechnical * kMaximumMapSizeTechnical;
SetTileElements(std::vector<TileElement>(numTiles, GetDefaultSurfaceElement()));
auto& gameState = GetGameState();
@ -1420,7 +1420,7 @@ static void MapExtendBoundarySurfaceExtendTile(const SurfaceElement& sourceTile,
void MapExtendBoundarySurfaceY()
{
auto y = GetGameState().MapSize.y - 2;
for (auto x = 0; x < MAXIMUM_MAP_SIZE_TECHNICAL; x++)
for (auto x = 0; x < kMaximumMapSizeTechnical; x++)
{
auto existingTileElement = MapGetSurfaceElementAt(TileCoordsXY{ x, y - 1 });
auto newTileElement = MapGetSurfaceElementAt(TileCoordsXY{ x, y });
@ -1440,7 +1440,7 @@ void MapExtendBoundarySurfaceY()
void MapExtendBoundarySurfaceX()
{
auto x = GetGameState().MapSize.x - 2;
for (auto y = 0; y < MAXIMUM_MAP_SIZE_TECHNICAL; y++)
for (auto y = 0; y < kMaximumMapSizeTechnical; y++)
{
auto existingTileElement = MapGetSurfaceElementAt(TileCoordsXY{ x - 1, y });
auto newTileElement = MapGetSurfaceElementAt(TileCoordsXY{ x, y });

View File

@ -25,11 +25,11 @@ constexpr uint8_t kMaximumWaterHeight = 254;
*/
constexpr uint8_t kMapBaseZ = 7;
#define MINIMUM_MAP_SIZE_TECHNICAL 5
#define MAXIMUM_MAP_SIZE_TECHNICAL 1001
#define MINIMUM_MAP_SIZE_PRACTICAL (MINIMUM_MAP_SIZE_TECHNICAL - 2)
#define MAXIMUM_MAP_SIZE_PRACTICAL (MAXIMUM_MAP_SIZE_TECHNICAL - 2)
constexpr const int32_t MAXIMUM_MAP_SIZE_BIG = COORDS_XY_STEP * MAXIMUM_MAP_SIZE_TECHNICAL;
constexpr uint8_t kMinimumMapSizeTechnical = 5;
constexpr uint16_t kMaximumMapSizeTechnical = 1001;
#define MINIMUM_MAP_SIZE_PRACTICAL (kMinimumMapSizeTechnical - 2)
#define MAXIMUM_MAP_SIZE_PRACTICAL (kMaximumMapSizeTechnical - 2)
constexpr const int32_t MAXIMUM_MAP_SIZE_BIG = COORDS_XY_STEP * kMaximumMapSizeTechnical;
constexpr int32_t MAXIMUM_TILE_START_XY = MAXIMUM_MAP_SIZE_BIG - COORDS_XY_STEP;
constexpr const int32_t LAND_HEIGHT_STEP = 2 * COORDS_Z_STEP;
constexpr const int32_t WATER_HEIGHT_STEP = 2 * COORDS_Z_STEP;
@ -40,11 +40,11 @@ constexpr uint8_t ConstructionRightsClearanceSmall = 3;
// Same as previous, but in big coords.
constexpr const uint8_t ConstructionRightsClearanceBig = 3 * COORDS_Z_STEP;
#define MAP_MINIMUM_X_Y (-MAXIMUM_MAP_SIZE_TECHNICAL)
#define MAP_MINIMUM_X_Y (-kMaximumMapSizeTechnical)
constexpr uint32_t MAX_TILE_ELEMENTS_WITH_SPARE_ROOM = 0x1000000;
constexpr uint32_t MAX_TILE_ELEMENTS = MAX_TILE_ELEMENTS_WITH_SPARE_ROOM - 512;
#define MAX_TILE_TILE_ELEMENT_POINTERS (MAXIMUM_MAP_SIZE_TECHNICAL * MAXIMUM_MAP_SIZE_TECHNICAL)
#define MAX_TILE_TILE_ELEMENT_POINTERS (kMaximumMapSizeTechnical * kMaximumMapSizeTechnical)
#define TILE_UNDEFINED_TILE_ELEMENT NULL

View File

@ -28,12 +28,12 @@
uint8_t SmallSceneryElement::GetSceneryQuadrant() const
{
return (this->Type & TILE_ELEMENT_QUADRANT_MASK) >> 6;
return (this->Type & kTileElementQuadrantMask) >> 6;
}
void SmallSceneryElement::SetSceneryQuadrant(uint8_t newQuadrant)
{
Type &= ~TILE_ELEMENT_QUADRANT_MASK;
Type &= ~kTileElementQuadrantMask;
Type |= (newQuadrant << 6);
}

View File

@ -700,9 +700,9 @@ enum
MAP_ELEM_TRACK_SEQUENCE_GREEN_LIGHT = (1 << 7),
};
#define TILE_ELEMENT_QUADRANT_MASK 0b11000000
#define TILE_ELEMENT_TYPE_MASK 0b00111100
#define TILE_ELEMENT_DIRECTION_MASK 0b00000011
constexpr uint8_t kTileElementQuadrantMask = 0b11000000;
constexpr uint8_t kTileElementTypeMask = 0b00111100;
constexpr uint8_t kTileElementDirectionMask = 0b00000011;
#define TILE_ELEMENT_OCCUPIED_QUADRANTS_MASK 0b00001111
enum

View File

@ -12,29 +12,29 @@
TileElementType TileElementBase::GetType() const
{
return static_cast<TileElementType>((this->Type & TILE_ELEMENT_TYPE_MASK) >> 2);
return static_cast<TileElementType>((this->Type & kTileElementTypeMask) >> 2);
}
void TileElementBase::SetType(TileElementType newType)
{
this->Type &= ~TILE_ELEMENT_TYPE_MASK;
this->Type |= ((EnumValue(newType) << 2) & TILE_ELEMENT_TYPE_MASK);
this->Type &= ~kTileElementTypeMask;
this->Type |= ((EnumValue(newType) << 2) & kTileElementTypeMask);
}
Direction TileElementBase::GetDirection() const
{
return this->Type & TILE_ELEMENT_DIRECTION_MASK;
return this->Type & kTileElementDirectionMask;
}
void TileElementBase::SetDirection(Direction direction)
{
this->Type &= ~TILE_ELEMENT_DIRECTION_MASK;
this->Type |= (direction & TILE_ELEMENT_DIRECTION_MASK);
this->Type &= ~kTileElementDirectionMask;
this->Type |= (direction & kTileElementDirectionMask);
}
Direction TileElementBase::GetDirectionWithOffset(uint8_t offset) const
{
return ((this->Type & TILE_ELEMENT_DIRECTION_MASK) + offset) & TILE_ELEMENT_DIRECTION_MASK;
return ((this->Type & kTileElementDirectionMask) + offset) & kTileElementDirectionMask;
}
bool TileElementBase::IsLastForTile() const

View File

@ -219,7 +219,7 @@ namespace OpenRCT2::TileInspector
case TileElementType::Path:
if (tileElement->AsPath()->IsSloped())
{
newRotation = (tileElement->AsPath()->GetSlopeDirection() + 1) & TILE_ELEMENT_DIRECTION_MASK;
newRotation = (tileElement->AsPath()->GetSlopeDirection() + 1) & kTileElementDirectionMask;
tileElement->AsPath()->SetSlopeDirection(newRotation);
}
pathEdges = tileElement->AsPath()->GetEdges();

View File

@ -82,12 +82,12 @@ void WallRemoveIntersectingWalls(const CoordsXYRangedZ& wallPos, Direction direc
uint8_t WallElement::GetSlope() const
{
return (Type & TILE_ELEMENT_QUADRANT_MASK) >> 6;
return (Type & kTileElementQuadrantMask) >> 6;
}
void WallElement::SetSlope(uint8_t newSlope)
{
Type &= ~TILE_ELEMENT_QUADRANT_MASK;
Type &= ~kTileElementQuadrantMask;
Type |= (newSlope << 6);
}

View File

@ -117,9 +117,9 @@ template<typename T> bool CompareLists(const CoordsXY& pos)
template<typename T> void CheckMapTiles()
{
for (int y = 0; y < MAXIMUM_MAP_SIZE_TECHNICAL; ++y)
for (int y = 0; y < kMaximumMapSizeTechnical; ++y)
{
for (int x = 0; x < MAXIMUM_MAP_SIZE_TECHNICAL; ++x)
for (int x = 0; x < kMaximumMapSizeTechnical; ++x)
{
auto pos = TileCoordsXY(x, y).ToCoordsXY();