Part of #21421: replace define with constexpr (#21679)

This commit is contained in:
Claudio Tiecher 2024-04-01 12:00:32 +02:00 committed by GitHub
parent 9062049be1
commit a94e6c54d8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
32 changed files with 79 additions and 85 deletions

View File

@ -1697,11 +1697,11 @@ void InputScrollViewport(const ScreenCoordsXY& scrollScreenCoords)
// Clamp to the map minimum value
int32_t at_map_edge = 0;
int32_t at_map_edge_dy = 0;
if (mapCoord.x < MAP_MINIMUM_X_Y || mapCoord.y < MAP_MINIMUM_X_Y)
if (mapCoord.x < kMapMinimumXY || mapCoord.y < kMapMinimumXY)
{
at_map_edge = 1;
}
if (mapCoord_dy.x < MAP_MINIMUM_X_Y || mapCoord_dy.y < MAP_MINIMUM_X_Y)
if (mapCoord_dy.x < kMapMinimumXY || mapCoord_dy.y < kMapMinimumXY)
{
at_map_edge_dy = 1;
}

View File

@ -815,7 +815,7 @@ static constexpr uint8_t ConstructionPreviewImages[][4] = {
auto surfaceElement = info.Element->AsSurface();
if (surfaceElement != nullptr)
{
slope = DefaultPathSlope[surfaceElement->GetSlope() & TILE_ELEMENT_SURFACE_RAISED_CORNERS_MASK];
slope = DefaultPathSlope[surfaceElement->GetSlope() & kTileElementSurfaceRaisedCornersMask];
}
break;
}
@ -920,7 +920,7 @@ static constexpr uint8_t ConstructionPreviewImages[][4] = {
switch (info.SpriteType)
{
case ViewportInteractionItem::Terrain:
slope = DefaultPathSlope[info.Element->AsSurface()->GetSlope() & TILE_ELEMENT_SURFACE_RAISED_CORNERS_MASK];
slope = DefaultPathSlope[info.Element->AsSurface()->GetSlope() & kTileElementSurfaceRaisedCornersMask];
break;
case ViewportInteractionItem::Footpath:
slope = info.Element->AsPath()->GetSlopeDirection();

View File

@ -1408,8 +1408,8 @@ static constexpr ScreenCoordsXY MiniMapOffsets[] = {
_resizeDirection = (callingWidget == WIDX_MAP_SIZE_SPINNER_Y) ? ResizeDirection::Y : ResizeDirection::X;
Formatter ft;
ft.Add<int16_t>(MINIMUM_MAP_SIZE_PRACTICAL);
ft.Add<int16_t>(MAXIMUM_MAP_SIZE_PRACTICAL);
ft.Add<int16_t>(kMinimumMapSizePractical);
ft.Add<int16_t>(kMaximumMapSizePractical);
TextInputOpen(callingWidget, STR_MAP_SIZE_2, STR_ENTER_MAP_SIZE, ft, STR_NONE, STR_NONE, 4);
}

View File

@ -417,8 +417,8 @@ static uint64_t PressedWidgets[WINDOW_MAPGEN_PAGE_COUNT] = {
void InputMapSize(WidgetIndex callingWidget, int32_t currentValue)
{
Formatter ft;
ft.Add<int16_t>(MINIMUM_MAP_SIZE_PRACTICAL);
ft.Add<int16_t>(MAXIMUM_MAP_SIZE_PRACTICAL);
ft.Add<int16_t>(kMinimumMapSizePractical);
ft.Add<int16_t>(kMaximumMapSizePractical);
// Practical map size is 2 lower than the technical map size
currentValue -= 2;

View File

@ -659,7 +659,7 @@ namespace OpenRCT2
MapAnimationAutoCreate();
EntityTweener::Get().Reset();
gScreenAge = 0;
gLastAutoSaveUpdate = AUTOSAVE_PAUSE;
gLastAutoSaveUpdate = kAutosavePause;
#ifndef DISABLE_NETWORK
bool sendMap = false;

View File

@ -358,7 +358,7 @@ void GameState::UpdateLogic()
// WindowDispatchUpdateAll();
// Start autosave timer after update
if (gLastAutoSaveUpdate == AUTOSAVE_PAUSE)
if (gLastAutoSaveUpdate == kAutosavePause)
{
gLastAutoSaveUpdate = Platform::GetTicks();
}

View File

@ -139,7 +139,7 @@ GameActions::Result FootpathPlaceAction::Execute() const
auto zLow = _loc.z;
auto zHigh = zLow + PATH_CLEARANCE;
WallRemoveIntersectingWalls(
{ _loc, zLow, zHigh + ((_slope & TILE_ELEMENT_SURFACE_RAISED_CORNERS_MASK) ? 16 : 0) },
{ _loc, zLow, zHigh + ((_slope & kTileElementSurfaceRaisedCornersMask) ? 16 : 0) },
DirectionReverse(_direction));
WallRemoveIntersectingWalls(
{ _loc.x - CoordsDirectionDelta[_direction].x, _loc.y - CoordsDirectionDelta[_direction].y, zLow, zHigh },

View File

@ -422,7 +422,7 @@ namespace GameActions
}
// Allow autosave to commence
if (gLastAutoSaveUpdate == AUTOSAVE_PAUSE)
if (gLastAutoSaveUpdate == kAutosavePause)
{
gLastAutoSaveUpdate = Platform::GetTicks();
}

View File

@ -104,9 +104,9 @@ GameActions::Result LandLowerAction::QueryExecute(bool isExecuting) const
withinOwnership = true;
uint8_t height = surfaceElement->BaseHeight;
if (surfaceElement->GetSlope() & TILE_ELEMENT_SURFACE_RAISED_CORNERS_MASK)
if (surfaceElement->GetSlope() & kTileElementSurfaceRaisedCornersMask)
height += 2;
if (surfaceElement->GetSlope() & TILE_ELEMENT_SURFACE_DIAGONAL_FLAG)
if (surfaceElement->GetSlope() & kTileElementSurfaceDiagonalFlag)
height += 2;
if (height < maxHeight)
@ -118,7 +118,7 @@ GameActions::Result LandLowerAction::QueryExecute(bool isExecuting) const
if (newSlope & SURFACE_STYLE_FLAG_RAISE_OR_LOWER_BASE_HEIGHT)
height -= 2;
newSlope &= TILE_ELEMENT_SURFACE_SLOPE_MASK;
newSlope &= kTileElementSurfaceSlopeMask;
auto landSetHeightAction = LandSetHeightAction({ x, y }, height, newSlope);
landSetHeightAction.SetFlags(GetFlags());

View File

@ -122,7 +122,7 @@ GameActions::Result LandRaiseAction::QueryExecute(bool isExecuting) const
height += 2;
}
}
newSlope &= TILE_ELEMENT_SURFACE_SLOPE_MASK;
newSlope &= kTileElementSurfaceSlopeMask;
auto landSetHeightAction = LandSetHeightAction({ x, y }, height, newSlope);
landSetHeightAction.SetFlags(GetFlags());

View File

@ -127,10 +127,10 @@ GameActions::Result LandSetHeightAction::Query() const
if (!GetGameState().Cheats.DisableClearanceChecks)
{
uint8_t zCorner = _height;
if (_style & TILE_ELEMENT_SURFACE_RAISED_CORNERS_MASK)
if (_style & kTileElementSurfaceRaisedCornersMask)
{
zCorner += 2;
if (_style & TILE_ELEMENT_SURFACE_DIAGONAL_FLAG)
if (_style & kTileElementSurfaceDiagonalFlag)
{
zCorner += 2;
}
@ -197,12 +197,12 @@ StringId LandSetHeightAction::CheckParameters() const
return STR_TOO_HIGH;
}
if (_height > kMaximumLandHeight - 2 && (_style & TILE_ELEMENT_SURFACE_SLOPE_MASK) != 0)
if (_height > kMaximumLandHeight - 2 && (_style & kTileElementSurfaceSlopeMask) != 0)
{
return STR_TOO_HIGH;
}
if (_height == kMaximumLandHeight - 2 && (_style & TILE_ELEMENT_SURFACE_DIAGONAL_FLAG))
if (_height == kMaximumLandHeight - 2 && (_style & kTileElementSurfaceDiagonalFlag))
{
return STR_TOO_HIGH;
}
@ -302,10 +302,10 @@ TileElement* LandSetHeightAction::CheckFloatingStructures(TileElement* surfaceEl
uint32_t waterHeight = surfaceElement->AsSurface()->GetWaterHeight();
if (waterHeight != 0)
{
if (_style & TILE_ELEMENT_SURFACE_SLOPE_MASK)
if (_style & kTileElementSurfaceSlopeMask)
{
zCorner += 2;
if (_style & TILE_ELEMENT_SURFACE_DIAGONAL_FLAG)
if (_style & kTileElementSurfaceDiagonalFlag)
{
zCorner += 2;
}
@ -325,7 +325,7 @@ money64 LandSetHeightAction::GetSurfaceHeightChangeCost(SurfaceElement* surfaceE
for (Direction i : ALL_DIRECTIONS)
{
int32_t cornerHeight = TileElementGetCornerHeight(surfaceElement, i);
cornerHeight -= MapGetCornerHeight(_height, _style & TILE_ELEMENT_SURFACE_SLOPE_MASK, i);
cornerHeight -= MapGetCornerHeight(_height, _style & kTileElementSurfaceSlopeMask, i);
cost += 2.50_GBP * abs(cornerHeight);
}
return cost;

View File

@ -146,7 +146,7 @@ namespace Config
auto model = &gConfigGeneral;
model->AlwaysShowGridlines = reader->GetBoolean("always_show_gridlines", false);
model->AutosaveFrequency = reader->GetInt32("autosave", AUTOSAVE_EVERY_5MINUTES);
model->AutosaveAmount = reader->GetInt32("autosave_amount", DEFAULT_NUM_AUTOSAVES_TO_KEEP);
model->AutosaveAmount = reader->GetInt32("autosave_amount", kDefaultNumAutosavesToKeep);
model->ConfirmationPrompt = reader->GetBoolean("confirmation_prompt", false);
model->CurrencyFormat = reader->GetEnum<CurrencyType>(
"currency_format", Platform::GetLocaleCurrency(), Enum_Currency);

View File

@ -1549,14 +1549,14 @@ bool Staff::UpdatePatrollingFindWatering()
continue;
}
if (tile_element->AsSmallScenery()->GetAge() < SCENERY_WITHER_AGE_THRESHOLD_2)
if (tile_element->AsSmallScenery()->GetAge() < kSceneryWitherAgeThreshold2)
{
if (chosen_position >= 4)
{
continue;
}
if (tile_element->AsSmallScenery()->GetAge() < SCENERY_WITHER_AGE_THRESHOLD_1)
if (tile_element->AsSmallScenery()->GetAge() < kSceneryWitherAgeThreshold1)
{
continue;
}

View File

@ -643,14 +643,14 @@ void ViewportUpdatePosition(WindowBase* window)
// Clamp to the map minimum value
int32_t at_map_edge = 0;
if (mapCoord.x < MAP_MINIMUM_X_Y)
if (mapCoord.x < kMapMinimumXY)
{
mapCoord.x = MAP_MINIMUM_X_Y;
mapCoord.x = kMapMinimumXY;
at_map_edge = 1;
}
if (mapCoord.y < MAP_MINIMUM_X_Y)
if (mapCoord.y < kMapMinimumXY)
{
mapCoord.y = MAP_MINIMUM_X_Y;
mapCoord.y = kMapMinimumXY;
at_map_edge = 1;
}

View File

@ -2805,7 +2805,7 @@ bool NetworkBase::LoadMap(IStream* stream)
EntityTweener::Get().Reset();
MapAnimationAutoCreate();
gLastAutoSaveUpdate = AUTOSAVE_PAUSE;
gLastAutoSaveUpdate = kAutosavePause;
result = true;
}
catch (const std::exception& e)

View File

@ -287,7 +287,7 @@ bool MetalASupportsPaintSetup(
int8_t yOffset = SupportBoundBoxes[segment].y;
uint32_t imageIndex = _97B15C[supportType].base_id;
imageIndex += metal_supports_slope_image_map[supportSegments[segment].slope & TILE_ELEMENT_SURFACE_SLOPE_MASK];
imageIndex += metal_supports_slope_image_map[supportSegments[segment].slope & kTileElementSurfaceSlopeMask];
auto image_id = imageTemplate.WithIndex(imageIndex);
PaintAddImageAsParent(session, image_id, { xOffset, yOffset, supportSegments[segment].height }, { 0, 0, 5 });
@ -493,7 +493,7 @@ bool MetalBSupportsPaintSetup(
}
else
{
uint32_t imageOffset = metal_supports_slope_image_map[supportSegments[segment].slope & TILE_ELEMENT_SURFACE_SLOPE_MASK];
uint32_t imageOffset = metal_supports_slope_image_map[supportSegments[segment].slope & kTileElementSurfaceSlopeMask];
uint32_t imageId = _97B15C[supportType].base_id + imageOffset;
PaintAddImageAsParent(
@ -679,7 +679,7 @@ bool PathPoleSupportsPaintSetup(
}
else
{
uint8_t imageOffset = metal_supports_slope_image_map[supportSegments[segment].slope & TILE_ELEMENT_SURFACE_SLOPE_MASK];
uint8_t imageOffset = metal_supports_slope_image_map[supportSegments[segment].slope & kTileElementSurfaceSlopeMask];
baseHeight = supportSegments[segment].height;
PaintAddImageAsParent(

View File

@ -447,7 +447,7 @@ bool WoodenASupportsPaintSetup(
}
else
{
auto imageId = imageTemplate.WithIndex(imageIndex + word_97B3C4[slope & TILE_ELEMENT_SURFACE_SLOPE_MASK]);
auto imageId = imageTemplate.WithIndex(imageIndex + word_97B3C4[slope & kTileElementSurfaceSlopeMask]);
PaintAddImageAsParent(session, imageId, { 0, 0, baseHeight }, { { 0, 0, baseHeight + 2 }, { 32, 32, 11 } });
PaintAddImageAsParent(
@ -475,7 +475,7 @@ bool WoodenASupportsPaintSetup(
}
else
{
auto imageId = imageTemplate.WithIndex(imageIndex + word_97B3C4[slope & TILE_ELEMENT_SURFACE_SLOPE_MASK]);
auto imageId = imageTemplate.WithIndex(imageIndex + word_97B3C4[slope & kTileElementSurfaceSlopeMask]);
PaintAddImageAsParent(session, imageId, { 0, 0, baseHeight }, { { 0, 0, baseHeight + 2 }, { 32, 32, 11 } });
hasSupports = true;
}
@ -579,7 +579,7 @@ bool WoodenBSupportsPaintSetup(
}
else
{
auto imageId = imageTemplate.WithIndex(imageIndex + word_97B3C4[slope & TILE_ELEMENT_SURFACE_SLOPE_MASK]);
auto imageId = imageTemplate.WithIndex(imageIndex + word_97B3C4[slope & kTileElementSurfaceSlopeMask]);
PaintAddImageAsParent(session, imageId, { 0, 0, baseHeight }, { { 0, 0, baseHeight + 2 }, { 32, 32, 11 } });
PaintAddImageAsParent(
@ -607,7 +607,7 @@ bool WoodenBSupportsPaintSetup(
}
else
{
auto imageId = imageTemplate.WithIndex(imageIndex + word_97B3C4[slope & TILE_ELEMENT_SURFACE_SLOPE_MASK]);
auto imageId = imageTemplate.WithIndex(imageIndex + word_97B3C4[slope & kTileElementSurfaceSlopeMask]);
PaintAddImageAsParent(session, imageId, { 0, 0, baseHeight }, { { 0, 0, baseHeight + 2 }, { 32, 32, 3 } });
hasSupports = true;
}
@ -704,7 +704,7 @@ bool PathBoxSupportsPaintSetup(
return false;
}
uint32_t imageId = supportOrientationOffset + word_97B3C4[session.Support.slope & TILE_ELEMENT_SURFACE_SLOPE_MASK]
uint32_t imageId = supportOrientationOffset + word_97B3C4[session.Support.slope & kTileElementSurfaceSlopeMask]
+ pathPaintInfo.BridgeImageId;
PaintAddImageAsParent(
@ -725,7 +725,7 @@ bool PathBoxSupportsPaintSetup(
return false;
}
uint32_t ebx = supportOrientationOffset + word_97B3C4[session.Support.slope & TILE_ELEMENT_SURFACE_SLOPE_MASK]
uint32_t ebx = supportOrientationOffset + word_97B3C4[session.Support.slope & kTileElementSurfaceSlopeMask]
+ pathPaintInfo.BridgeImageId;
PaintAddImageAsParent(

View File

@ -180,11 +180,11 @@ static void PaintSmallSceneryBody(
ImageIndex baseImageIndex = sceneryEntry->image + direction;
if (sceneryEntry->HasFlag(SMALL_SCENERY_FLAG_CAN_WITHER))
{
if (sceneryElement.GetAge() >= SCENERY_WITHER_AGE_THRESHOLD_1)
if (sceneryElement.GetAge() >= kSceneryWitherAgeThreshold1)
{
baseImageIndex += 4;
}
if (sceneryElement.GetAge() >= SCENERY_WITHER_AGE_THRESHOLD_2)
if (sceneryElement.GetAge() >= kSceneryWitherAgeThreshold2)
{
baseImageIndex += 4;
}

View File

@ -926,14 +926,14 @@ static std::pair<int32_t, int32_t> SurfaceGetHeightAboveWater(
{
localHeight += LAND_HEIGHT_STEP;
if (waterHeight != localHeight || !(localSurfaceShape & TILE_ELEMENT_SURFACE_DIAGONAL_FLAG))
if (waterHeight != localHeight || !(localSurfaceShape & static_cast<int32_t>(kTileElementSurfaceDiagonalFlag)))
{
localHeight = waterHeight;
localSurfaceShape = TILE_ELEMENT_SLOPE_FLAT;
}
else
{
localSurfaceShape = Numerics::ror4(surfaceShape ^ TILE_ELEMENT_SURFACE_RAISED_CORNERS_MASK, 2);
localSurfaceShape = Numerics::ror4(surfaceShape ^ static_cast<int8_t>(kTileElementSurfaceRaisedCornersMask), 2);
}
}
}

View File

@ -59,7 +59,7 @@ uint8_t RCT12TileElementBase::GetDirection() const
uint8_t RCT12TileElementBase::GetOccupiedQuadrants() const
{
return Flags & TILE_ELEMENT_OCCUPIED_QUADRANTS_MASK;
return Flags & kTileElementOccupiedQuadrantsMask;
}
bool RCT12TileElementBase::IsLastForTile() const
@ -74,7 +74,7 @@ bool RCT12TileElementBase::IsGhost() const
uint8_t RCT12SurfaceElement::GetSlope() const
{
return (Slope & TILE_ELEMENT_SURFACE_SLOPE_MASK);
return (Slope & kTileElementSurfaceSlopeMask);
}
uint32_t RCT12SurfaceElement::GetSurfaceStyle() const
@ -99,7 +99,7 @@ uint8_t RCT12SurfaceElement::GetGrassLength() const
uint8_t RCT12SurfaceElement::GetOwnership() const
{
return (Ownership & TILE_ELEMENT_SURFACE_OWNERSHIP_MASK);
return (Ownership & kTileElementSurfaceOwnershipMask);
}
uint32_t RCT12SurfaceElement::GetWaterHeight() const
@ -109,7 +109,7 @@ uint32_t RCT12SurfaceElement::GetWaterHeight() const
uint8_t RCT12SurfaceElement::GetParkFences() const
{
return (Ownership & TILE_ELEMENT_SURFACE_PARK_FENCE_MASK);
return (Ownership & kTileElementSurfaceParkFenceMask);
}
bool RCT12SurfaceElement::HasTrackThatNeedsWater() const

View File

@ -10,7 +10,7 @@
#include "../entity/EntityRegistry.h"
#include "Vehicle.h"
constexpr int operator"" _MPH(unsigned long long x)
constexpr int operator"" _MPH(unsigned long long x) noexcept
{
return x * 29127;
}

View File

@ -256,7 +256,7 @@ static void ScenarioCheckEntranceFeeTooHigh()
void ScenarioAutosaveCheck()
{
if (gLastAutoSaveUpdate == AUTOSAVE_PAUSE)
if (gLastAutoSaveUpdate == kAutosavePause)
return;
// Milliseconds since last save
@ -284,7 +284,7 @@ void ScenarioAutosaveCheck()
if (shouldSave)
{
gLastAutoSaveUpdate = AUTOSAVE_PAUSE;
gLastAutoSaveUpdate = kAutosavePause;
GameAutosave();
}
}

View File

@ -43,9 +43,6 @@ enum
S6_TYPE_SCENARIO
};
#define S6_RCT2_VERSION 120001
#define S6_MAGIC_NUMBER 0x00031144
enum SCENARIO_CATEGORY
{
// RCT2 categories (keep order)
@ -151,8 +148,8 @@ enum
AUTOSAVE_NEVER
};
#define AUTOSAVE_PAUSE 0
#define DEFAULT_NUM_AUTOSAVES_TO_KEEP 10
constexpr uint8_t kAutosavePause = 0;
constexpr uint8_t kDefaultNumAutosavesToKeep = 10;
static constexpr money64 COMPANY_VALUE_ON_FAILED_OBJECTIVE = 0x8000000000000001;

View File

@ -13,7 +13,7 @@
#include <cstdint>
#define TITLE_COMMAND_SCENARIO_LENGTH 64
constexpr uint8_t kTitleCommandScenarioLength = 64;
namespace OpenRCT2::Title
{
@ -22,7 +22,7 @@ namespace OpenRCT2::Title
static constexpr const char* Name = "Load Scenario Command";
static constexpr const char* ScriptingName = "loadsc";
utf8 Scenario[TITLE_COMMAND_SCENARIO_LENGTH]{};
utf8 Scenario[kTitleCommandScenarioLength]{};
int16_t operator()(int16_t timer);
};

View File

@ -27,8 +27,8 @@ constexpr uint8_t kMapBaseZ = 7;
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 int16_t kMinimumMapSizePractical = (kMinimumMapSizeTechnical - 2);
constexpr int16_t kMaximumMapSizePractical = (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;
@ -40,13 +40,10 @@ 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 (-kMaximumMapSizeTechnical)
constexpr int16_t kMapMinimumXY = (-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 (kMaximumMapSizeTechnical * kMaximumMapSizeTechnical)
#define TILE_UNDEFINED_TILE_ELEMENT NULL
using PeepSpawn = CoordsXYZD;

View File

@ -693,8 +693,8 @@ bool MapGenLoadHeightmap(const utf8* path)
try
{
auto image = Imaging::ReadFromFile(path, format);
auto width = std::min<uint32_t>(image.Width, MAXIMUM_MAP_SIZE_PRACTICAL);
auto height = std::min<uint32_t>(image.Height, MAXIMUM_MAP_SIZE_PRACTICAL);
auto width = std::min<uint32_t>(image.Width, kMaximumMapSizePractical);
auto height = std::min<uint32_t>(image.Height, kMaximumMapSizePractical);
if (width != image.Width || height != image.Height)
{
ContextShowError(STR_HEIGHT_MAP_ERROR, STR_ERROR_HEIHGT_MAP_TOO_BIG, {});

View File

@ -15,8 +15,8 @@
#include <vector>
#define SCENERY_WITHER_AGE_THRESHOLD_1 0x28
#define SCENERY_WITHER_AGE_THRESHOLD_2 0x37
constexpr uint8_t kSceneryWitherAgeThreshold1 = 0x28;
constexpr uint8_t kSceneryWitherAgeThreshold2 = 0x37;
enum
{

View File

@ -67,7 +67,7 @@ void SmallSceneryElement::IncreaseAge(const CoordsXY& sceneryPos)
uint8_t newAge = age++;
// Only invalidate tiles when scenery crosses the withering thresholds, and can be withered.
if (newAge == SCENERY_WITHER_AGE_THRESHOLD_1 || newAge == SCENERY_WITHER_AGE_THRESHOLD_2)
if (newAge == kSceneryWitherAgeThreshold1 || newAge == kSceneryWitherAgeThreshold2)
{
auto* sceneryEntry = GetEntry();

View File

@ -192,24 +192,24 @@ void SurfaceElement::UpdateGrassLength(const CoordsXY& coords)
uint8_t SurfaceElement::GetOwnership() const
{
return (Ownership & TILE_ELEMENT_SURFACE_OWNERSHIP_MASK);
return (Ownership & kTileElementSurfaceOwnershipMask);
}
void SurfaceElement::SetOwnership(uint8_t newOwnership)
{
Ownership &= ~TILE_ELEMENT_SURFACE_OWNERSHIP_MASK;
Ownership |= (newOwnership & TILE_ELEMENT_SURFACE_OWNERSHIP_MASK);
Ownership &= ~kTileElementSurfaceOwnershipMask;
Ownership |= (newOwnership & kTileElementSurfaceOwnershipMask);
}
uint8_t SurfaceElement::GetParkFences() const
{
return (Ownership & TILE_ELEMENT_SURFACE_PARK_FENCE_MASK);
return (Ownership & kTileElementSurfaceParkFenceMask);
}
void SurfaceElement::SetParkFences(uint8_t newParkFences)
{
Ownership &= ~TILE_ELEMENT_SURFACE_PARK_FENCE_MASK;
Ownership |= (newParkFences & TILE_ELEMENT_SURFACE_PARK_FENCE_MASK);
Ownership &= ~kTileElementSurfaceParkFenceMask;
Ownership |= (newParkFences & kTileElementSurfaceParkFenceMask);
}
uint8_t SurfaceElement::GetSlope() const

View File

@ -111,10 +111,10 @@ enum
};
// Surface
#define TILE_ELEMENT_SURFACE_DIAGONAL_FLAG 0x10 // in TileElement.properties.surface.slope
#define TILE_ELEMENT_SURFACE_RAISED_CORNERS_MASK 0x0F // in TileElement.properties.surface.slope
#define TILE_ELEMENT_SURFACE_SLOPE_MASK \
(TILE_ELEMENT_SURFACE_DIAGONAL_FLAG | TILE_ELEMENT_SURFACE_RAISED_CORNERS_MASK) // in TileElement.properties.surface.slope
constexpr uint8_t kTileElementSurfaceDiagonalFlag = 0x10; // in TileElement.properties.surface.slope
constexpr uint8_t kTileElementSurfaceRaisedCornersMask = 0x0F; // in TileElement.properties.surface.slope
constexpr uint8_t kTileElementSurfaceSlopeMask
= (kTileElementSurfaceDiagonalFlag | kTileElementSurfaceRaisedCornersMask); // in TileElement.properties.surface.slope
#define TILE_ELEMENT_SURFACE_OWNERSHIP_MASK 0xF0
#define TILE_ELEMENT_SURFACE_PARK_FENCE_MASK 0x0F
constexpr uint8_t kTileElementSurfaceOwnershipMask = 0xF0;
constexpr uint8_t kTileElementSurfaceParkFenceMask = 0x0F;

View File

@ -703,7 +703,7 @@ enum
constexpr uint8_t kTileElementQuadrantMask = 0b11000000;
constexpr uint8_t kTileElementTypeMask = 0b00111100;
constexpr uint8_t kTileElementDirectionMask = 0b00000011;
#define TILE_ELEMENT_OCCUPIED_QUADRANTS_MASK 0b00001111
constexpr uint8_t kTileElementOccupiedQuadrantsMask = 0b00001111;
enum
{

View File

@ -87,13 +87,13 @@ void TileElementBase::Remove()
uint8_t TileElementBase::GetOccupiedQuadrants() const
{
return Flags & TILE_ELEMENT_OCCUPIED_QUADRANTS_MASK;
return Flags & kTileElementOccupiedQuadrantsMask;
}
void TileElementBase::SetOccupiedQuadrants(uint8_t quadrants)
{
Flags &= ~TILE_ELEMENT_OCCUPIED_QUADRANTS_MASK;
Flags |= (quadrants & TILE_ELEMENT_OCCUPIED_QUADRANTS_MASK);
Flags &= ~kTileElementOccupiedQuadrantsMask;
Flags |= (quadrants & kTileElementOccupiedQuadrantsMask);
}
int32_t TileElementBase::GetBaseZ() const