Skip to content

Commit

Permalink
Merge pull request #22155 from Harry-Hopkinson/refactor-constant-nota…
Browse files Browse the repository at this point in the history
…tion

Refactor constant notation to use kCamelCase
  • Loading branch information
Gymnasiast committed Jun 9, 2024
2 parents 0254b57 + 6e1b7ee commit 8175575
Show file tree
Hide file tree
Showing 11 changed files with 131 additions and 132 deletions.
4 changes: 2 additions & 2 deletions src/openrct2/rct1/Csg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ bool RCT1DataPresentAtLocation(u8string_view path)

bool CsgIsUsable(const Gx& csg)
{
return csg.header.total_size == RCT1::Limits::LL_CSG1_DAT_FileSize
&& csg.header.num_entries == RCT1::Limits::Num_LL_CSG_Entries;
return csg.header.total_size == RCT1::Limits::kLLCsg1DatFileSize
&& csg.header.num_entries == RCT1::Limits::kNumLLCsgEntries;
}

bool CsgAtLocationIsUsable(u8string_view path)
Expand Down
22 changes: 11 additions & 11 deletions src/openrct2/rct1/Limits.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@
namespace RCT1::Limits
{
using namespace RCT12::Limits;
constexpr uint16_t MaxTileElements = 0xC000;
constexpr uint16_t MaxEntities = 5000;
constexpr uint16_t kMaxTileElements = 0xC000;
constexpr uint16_t kMaxEntities = 5000;
constexpr uint8_t kMaxTrainsPerRide = 12;
constexpr uint8_t MaxMapSize = 128;
constexpr uint8_t MaxStaff = 116;
constexpr uint16_t MaxAnimatedObjects = 1000;
constexpr uint8_t MaxBanners = 100;
constexpr int32_t CoordsZStep = 4;
constexpr uint32_t Num_LL_CSG_Entries = 69917;
constexpr uint32_t LL_CSG1_DAT_FileSize = 41402869;
constexpr uint32_t NumTerrainSurfaces = 16;
constexpr uint32_t NumTerrainEdges = 15;
constexpr uint8_t kMaxMapSize = 128;
constexpr uint8_t kMaxStaff = 116;
constexpr uint16_t kMaxAnimatedObjects = 1000;
constexpr uint8_t kMaxBanners = 100;
constexpr int32_t kCoordsZStep = 4;
constexpr uint32_t kNumLLCsgEntries = 69917;
constexpr uint32_t kLLCsg1DatFileSize = 41402869;
constexpr uint32_t kNumTerrainSurfaces = 16;
constexpr uint32_t kNumTerrainEdges = 15;
} // namespace RCT1::Limits
12 changes: 6 additions & 6 deletions src/openrct2/rct1/RCT1.h
Original file line number Diff line number Diff line change
Expand Up @@ -731,9 +731,9 @@ namespace RCT1
uint32_t Ticks;
uint32_t RandomA;
uint32_t RandomB;
RCT12TileElement TileElements[Limits::MaxTileElements];
RCT12TileElement TileElements[Limits::kMaxTileElements];
uint32_t UnkCounter;
Entity Entities[Limits::MaxEntities];
Entity Entities[Limits::kMaxEntities];
uint16_t NextEntityIndex;
uint16_t FirstVehicleEntityIndex;
uint16_t FirstPeepEntityIndex;
Expand Down Expand Up @@ -852,7 +852,7 @@ namespace RCT1
uint16_t Unk199C9A;
ResearchItem ResearchItemsLL[250];
uint8_t Unk19A0D9[5118];
RCT12Banner Banners[Limits::MaxBanners];
RCT12Banner Banners[Limits::kMaxBanners];
char StringTable[Limits::MaxUserStrings][Limits::MaxUserStringLength];
uint32_t GameTimeCounter;
Ride Rides[Limits::kMaxRidesInPark];
Expand All @@ -861,7 +861,7 @@ namespace RCT1
int16_t ViewY;
uint8_t ViewZoom;
uint8_t ViewRotation;
RCT12MapAnimation MapAnimations[Limits::MaxAnimatedObjects];
RCT12MapAnimation MapAnimations[Limits::kMaxAnimatedObjects];
uint32_t NumMapAnimations;
uint8_t Unk1CADBC[12];
uint16_t ScrollingTextStep;
Expand All @@ -871,8 +871,8 @@ namespace RCT1
RCT12RideMeasurement RideMeasurements[8];
uint32_t NextGuestIndex;
uint16_t GameCounter5;
uint8_t PatrolAreas[(Limits::MaxStaff + Limits::StaffTypeCount) * Limits::PatrolAreaSize];
uint8_t StaffModes[Limits::MaxStaff];
uint8_t PatrolAreas[(Limits::kMaxStaff + Limits::StaffTypeCount) * Limits::PatrolAreaSize];
uint8_t StaffModes[Limits::kMaxStaff];
uint8_t Unk1F431E[4];
uint8_t Unk1F4322[8];
uint8_t Climate;
Expand Down
26 changes: 13 additions & 13 deletions src/openrct2/rct1/S4Importer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ namespace RCT1
// Avoid reusing the value used for last import
_parkValueConversionFactor = 0;

uint16_t mapSize = _s4.MapSize == 0 ? Limits::MaxMapSize : _s4.MapSize;
uint16_t mapSize = _s4.MapSize == 0 ? Limits::kMaxMapSize : _s4.MapSize;

gScenarioFileName = GetRCT1ScenarioName();

Expand Down Expand Up @@ -465,7 +465,7 @@ namespace RCT1

void AddAvailableEntriesFromMap()
{
size_t maxTiles = Limits::MaxMapSize * Limits::MaxMapSize;
size_t maxTiles = Limits::kMaxMapSize * Limits::kMaxMapSize;
size_t tileIndex = 0;
RCT12TileElement* tileElement = _s4.TileElements;

Expand Down Expand Up @@ -885,7 +885,7 @@ namespace RCT1
auto tileStartLoc = TileCoordsXY{ src->StationStarts[i].x, src->StationStarts[i].y };
dstStation.Start = tileStartLoc.ToCoordsXY();
}
dstStation.SetBaseZ(src->StationHeights[i] * Limits::CoordsZStep);
dstStation.SetBaseZ(src->StationHeights[i] * Limits::kCoordsZStep);
dstStation.Length = src->StationLengths[i];
dstStation.Depart = src->StationLights[i];

Expand Down Expand Up @@ -1233,7 +1233,7 @@ namespace RCT1

void ImportEntities()
{
for (int i = 0; i < Limits::MaxEntities; i++)
for (int i = 0; i < Limits::kMaxEntities; i++)
{
ImportEntity(_s4.Entities[i].Unknown);
}
Expand Down Expand Up @@ -1321,7 +1321,7 @@ namespace RCT1

dst->State = static_cast<PeepState>(src->State);
dst->SubState = src->SubState;
dst->NextLoc = { src->NextX, src->NextY, src->NextZ * Limits::CoordsZStep };
dst->NextLoc = { src->NextX, src->NextY, src->NextZ * Limits::kCoordsZStep };
dst->NextFlags = src->NextFlags;
dst->Var37 = src->Var37;
dst->StepProgress = src->StepProgress;
Expand Down Expand Up @@ -1522,10 +1522,10 @@ namespace RCT1
{
// Build tile pointer cache (needed to get the first element at a certain location)
auto tilePointerIndex = TilePointerIndex<RCT12TileElement>(
Limits::MaxMapSize, _s4.TileElements, std::size(_s4.TileElements));
Limits::kMaxMapSize, _s4.TileElements, std::size(_s4.TileElements));

std::vector<TileElement> tileElements;
const auto maxSize = _s4.MapSize == 0 ? Limits::MaxMapSize : _s4.MapSize;
const auto maxSize = _s4.MapSize == 0 ? Limits::kMaxMapSize : _s4.MapSize;
for (TileCoordsXY coords = { 0, 0 }; coords.y < kMaximumMapSizeTechnical; coords.y++)
{
for (coords.x = 0; coords.x < kMaximumMapSizeTechnical; coords.x++)
Expand Down Expand Up @@ -1583,8 +1583,8 @@ namespace RCT1
// This flag will be set by the caller.
dst->SetLastForTile(false);

dst->SetBaseZ(src->BaseHeight * Limits::CoordsZStep);
dst->SetClearanceZ(src->ClearanceHeight * Limits::CoordsZStep);
dst->SetBaseZ(src->BaseHeight * Limits::kCoordsZStep);
dst->SetClearanceZ(src->ClearanceHeight * Limits::kCoordsZStep);

switch (tileElementType)
{
Expand Down Expand Up @@ -1793,8 +1793,8 @@ namespace RCT1
ConvertWall(type, &colourA, &colourB);

type = _wallTypeToEntryMap[type];
auto baseZ = src->BaseHeight * Limits::CoordsZStep;
auto clearanceZ = src->ClearanceHeight * Limits::CoordsZStep;
auto baseZ = src->BaseHeight * Limits::kCoordsZStep;
auto clearanceZ = src->ClearanceHeight * Limits::kCoordsZStep;
auto edgeSlope = GetWallSlopeFromEdgeSlope(slope, edge & 3);
if (edgeSlope & (EDGE_SLOPE_UPWARDS | EDGE_SLOPE_DOWNWARDS))
{
Expand Down Expand Up @@ -2674,9 +2674,9 @@ namespace RCT1
*/
void CountBlockSections()
{
for (int32_t x = 0; x < Limits::MaxMapSize; x++)
for (int32_t x = 0; x < Limits::kMaxMapSize; x++)
{
for (int32_t y = 0; y < Limits::MaxMapSize; y++)
for (int32_t y = 0; y < Limits::kMaxMapSize; y++)
{
TileElement* tileElement = MapGetFirstElementAt(TileCoordsXY{ x, y });
if (tileElement == nullptr)
Expand Down
12 changes: 6 additions & 6 deletions src/openrct2/rct1/Tables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ namespace RCT1

std::string_view GetTerrainSurfaceObject(uint8_t terrainSurface)
{
static constexpr std::string_view map[Limits::NumTerrainSurfaces] =
static constexpr std::string_view map[Limits::kNumTerrainSurfaces] =
{
"rct2.terrain_surface.grass",
"rct2.terrain_surface.sand",
Expand All @@ -142,7 +142,7 @@ namespace RCT1

std::string_view GetTerrainEdgeObject(uint8_t terrainEdge)
{
static constexpr std::string_view map[Limits::NumTerrainEdges] =
static constexpr std::string_view map[Limits::kNumTerrainEdges] =
{
"rct2.terrain_edge.rock",
"rct1.terrain_edge.brick",
Expand Down Expand Up @@ -686,13 +686,13 @@ namespace RCT1

if (rct1VehicleType == VehicleType::HeartlineTwisterCars)
{
return vehicleSubEntry == HEARTLINE_TWISTER_FORWARDS ? 0 : 1;
return vehicleSubEntry == HEARTLINE_TWISTER_FORWARDS ? 0 : 1;
}
if (rct1VehicleType == VehicleType::HeartlineTwisterCarsReversed)
{
return vehicleSubEntry == HEARTLINE_TWISTER_BACKWARDS ? 0 : 1;
return vehicleSubEntry == HEARTLINE_TWISTER_BACKWARDS ? 0 : 1;
}

return map[vehicleSubEntry];
}

Expand Down Expand Up @@ -1255,7 +1255,7 @@ namespace RCT1

if (wallType < std::size(map))
return map[wallType];

return -1;
}

Expand Down
55 changes: 27 additions & 28 deletions src/openrct2/rct2/Limits.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,37 +13,36 @@
namespace RCT2::Limits
{
using namespace RCT12::Limits;
constexpr uint8_t MaxStaff = 200;
constexpr uint8_t MaxBanners = 250;
constexpr uint8_t kMaxStaff = 200;
constexpr uint8_t kMaxBanners = 250;
constexpr uint8_t kMaxTrainsPerRide = 32;
constexpr uint8_t kMaxVehicleColours = 32;
constexpr uint8_t kDowntimeHistorySize = 8;
constexpr uint16_t MaxEntities = 10000;
constexpr uint16_t MaxEntitiesRCTCExtended = 15000; // Used in files marked with “classic flag” 0xF
constexpr uint32_t MaxTileElements = 0x30000;
constexpr uint16_t MaxAnimatedObjects = 2000;
constexpr uint8_t MaxResearchedRideTypeQuads = 8; // With 32 bits per uint32_t, this means there is room for
// 256 types.
constexpr uint8_t MaxResearchedRideEntryQuads = 8; // With 32 bits per uint32_t, this means there is room for
// 256 entries.
constexpr uint8_t MaxResearchedSceneryItemQuads = 56;
constexpr const uint16_t MaxResearchedSceneryItems = (MaxResearchedSceneryItemQuads * 32); // There are 32
// bits per
// quad.
constexpr uint16_t MaxResearchItems = 500;
constexpr uint16_t kMaxEntities = 10000;
constexpr uint16_t kMaxEntitiesRCTCExtended = 15000; // Used in files marked with “classic flag” 0xF
constexpr uint32_t kMaxTileElements = 0x30000;
constexpr uint16_t kMaxAnimatedObjects = 2000;
constexpr uint8_t kMaxResearchedRideTypeQuads = 8; // With 32 bits per uint32_t, this means there is room for
// 256 types.
constexpr uint8_t kMaxResearchedRideEntryQuads = 8; // With 32 bits per uint32_t, this means there is room for
// 256 entries.
constexpr uint8_t kMaxResearchedSceneryItemQuads = 56;
constexpr const uint16_t kMaxResearchedSceneryItems = (kMaxResearchedSceneryItemQuads * 32); // There are 32
// bits per
// quad.
constexpr uint16_t kMaxResearchItems = 500;

constexpr uint16_t TD6MaxTrackElements = 8192;
constexpr uint16_t kTD6MaxTrackElements = 8192;

constexpr uint8_t MaxSmallSceneryObjects = 252;
constexpr uint8_t MaxLargeSceneryObjects = 128;
constexpr uint8_t MaxWallSceneryObjects = 128;
constexpr uint8_t MaxBannerObjects = 32;
constexpr uint8_t MaxPathObjects = 16;
constexpr uint8_t MaxPathAdditionObjects = 15;
constexpr uint8_t MaxSceneryGroupObjects = 19;
constexpr uint8_t MaxParkEntranceObjects = 1;
constexpr uint8_t MaxWaterObjects = 1;
constexpr uint8_t MaxScenarioTextObjects = 1;
constexpr uint8_t RideTypeCount = 91;
constexpr uint16_t MaxMapSize = 256;
constexpr uint8_t kMaxSmallSceneryObjects = 252;
constexpr uint8_t kMaxLargeSceneryObjects = 128;
constexpr uint8_t kMaxWallSceneryObjects = 128;
constexpr uint8_t kMaxBannerObjects = 32;
constexpr uint8_t kMaxPathObjects = 16;
constexpr uint8_t kMaxPathAdditionObjects = 15;
constexpr uint8_t kMaxSceneryGroupObjects = 19;
constexpr uint8_t kMaxParkEntranceObjects = 1;
constexpr uint8_t kMaxWaterObjects = 1;
constexpr uint8_t kMaxScenarioTextObjects = 1;
constexpr uint16_t kMaxMapSize = 256;
} // namespace RCT2::Limits
Loading

0 comments on commit 8175575

Please sign in to comment.