diff --git a/src/openrct2-ui/interface/LandTool.cpp b/src/openrct2-ui/interface/LandTool.cpp index f1316a23a0..35a224adf9 100644 --- a/src/openrct2-ui/interface/LandTool.cpp +++ b/src/openrct2-ui/interface/LandTool.cpp @@ -47,7 +47,7 @@ money64 gWaterToolLowerCost; uint32_t LandTool::SizeToSpriteIndex(uint16_t size) { - if (size <= MAX_TOOL_SIZE_WITH_SPRITE) + if (size <= kLandToolMaximumSizeWithSprite) { return toolSizeSpriteIndices[size]; } diff --git a/src/openrct2-ui/interface/LandTool.h b/src/openrct2-ui/interface/LandTool.h index ad6f317057..db1e3145d7 100644 --- a/src/openrct2-ui/interface/LandTool.h +++ b/src/openrct2-ui/interface/LandTool.h @@ -13,10 +13,10 @@ #include #include -#define MINIMUM_TOOL_SIZE 1 -#define MAXIMUM_TOOL_SIZE 64 +constexpr uint16_t kLandToolMinimumSize = 1; +constexpr uint16_t kLandToolMaximumSize = 64; // The highest tool size to have a sprite. Bigger tool sizes simply display a number. -#define MAX_TOOL_SIZE_WITH_SPRITE 7 +constexpr uint16_t kLandToolMaximumSizeWithSprite = 7; extern uint16_t gLandToolSize; extern money64 gLandToolRaiseCost; diff --git a/src/openrct2-ui/windows/ClearScenery.cpp b/src/openrct2-ui/windows/ClearScenery.cpp index 06f8574f5e..bd06d6c4af 100644 --- a/src/openrct2-ui/windows/ClearScenery.cpp +++ b/src/openrct2-ui/windows/ClearScenery.cpp @@ -97,8 +97,8 @@ public: case WIDX_PREVIEW: { Formatter ft; - ft.Add(MINIMUM_TOOL_SIZE); - ft.Add(MAXIMUM_TOOL_SIZE); + ft.Add(kLandToolMinimumSize); + ft.Add(kLandToolMaximumSize); TextInputOpen(WIDX_PREVIEW, STR_SELECTION_SIZE, STR_ENTER_SELECTION_SIZE, ft, STR_NONE, STR_NONE, 3); break; } @@ -123,14 +123,14 @@ public: { case WIDX_DECREMENT: // Decrement land tool size, if it stays within the limit - gLandToolSize = std::max(MINIMUM_TOOL_SIZE, gLandToolSize - 1); + gLandToolSize = std::max(kLandToolMinimumSize, gLandToolSize - 1); // Invalidate the window Invalidate(); break; case WIDX_INCREMENT: // Increment land tool size, if it stays within the limit - gLandToolSize = std::min(MAXIMUM_TOOL_SIZE, gLandToolSize + 1); + gLandToolSize = std::min(kLandToolMaximumSize, gLandToolSize + 1); // Invalidate the window Invalidate(); @@ -146,7 +146,7 @@ public: try { int32_t size = std::stol(std::string(text)); - size = std::clamp(size, MINIMUM_TOOL_SIZE, MAXIMUM_TOOL_SIZE); + size = std::clamp(size, kLandToolMinimumSize, kLandToolMaximumSize); gLandToolSize = size; Invalidate(); } @@ -181,7 +181,7 @@ public: // Draw number for tool sizes bigger than 7 ScreenCoordsXY screenCoords = { windowPos.x + window_clear_scenery_widgets[WIDX_PREVIEW].midX(), windowPos.y + window_clear_scenery_widgets[WIDX_PREVIEW].midY() }; - if (gLandToolSize > MAX_TOOL_SIZE_WITH_SPRITE) + if (gLandToolSize > kLandToolMaximumSizeWithSprite) { auto ft = Formatter(); ft.Add(gLandToolSize); diff --git a/src/openrct2-ui/windows/Land.cpp b/src/openrct2-ui/windows/Land.cpp index b44886c11e..ec548ca77b 100644 --- a/src/openrct2-ui/windows/Land.cpp +++ b/src/openrct2-ui/windows/Land.cpp @@ -62,8 +62,8 @@ private: void InputSize() { Formatter ft; - ft.Add(MINIMUM_TOOL_SIZE); - ft.Add(MAXIMUM_TOOL_SIZE); + ft.Add(kLandToolMinimumSize); + ft.Add(kLandToolMaximumSize); WindowTextInputOpen(this, WIDX_PREVIEW, STR_SELECTION_SIZE, STR_ENTER_SELECTION_SIZE, ft, STR_NONE, STR_NONE, 3); } @@ -132,14 +132,14 @@ public: break; case WIDX_DECREMENT: // Decrement land tool size - gLandToolSize = std::max(MINIMUM_TOOL_SIZE, gLandToolSize - 1); + gLandToolSize = std::max(kLandToolMinimumSize, gLandToolSize - 1); // Invalidate the window Invalidate(); break; case WIDX_INCREMENT: // Increment land tool size - gLandToolSize = std::min(MAXIMUM_TOOL_SIZE, gLandToolSize + 1); + gLandToolSize = std::min(kLandToolMaximumSize, gLandToolSize + 1); // Invalidate the window Invalidate(); @@ -202,8 +202,8 @@ public: int32_t size = strtol(textStr.c_str(), &end, 10); if (*end == '\0') { - size = std::max(MINIMUM_TOOL_SIZE, size); - size = std::min(MAXIMUM_TOOL_SIZE, size); + size = std::max(kLandToolMinimumSize, size); + size = std::min(kLandToolMaximumSize, size); gLandToolSize = size; Invalidate(); @@ -244,7 +244,7 @@ public: DrawDropdownButtons(dpi); // Draw number for tool sizes bigger than 7 - if (gLandToolSize > MAX_TOOL_SIZE_WITH_SPRITE) + if (gLandToolSize > kLandToolMaximumSizeWithSprite) { auto ft = Formatter(); ft.Add(gLandToolSize); diff --git a/src/openrct2-ui/windows/LandRights.cpp b/src/openrct2-ui/windows/LandRights.cpp index 01a252bf6b..38523d4daa 100644 --- a/src/openrct2-ui/windows/LandRights.cpp +++ b/src/openrct2-ui/windows/LandRights.cpp @@ -131,14 +131,14 @@ public: { case WIDX_DECREMENT: // Decrement land rights tool size - gLandToolSize = std::max(MINIMUM_TOOL_SIZE, gLandToolSize - 1); + gLandToolSize = std::max(kLandToolMinimumSize, gLandToolSize - 1); // Invalidate the window Invalidate(); break; case WIDX_INCREMENT: // Decrement land rights tool size - gLandToolSize = std::min(MAXIMUM_TOOL_SIZE, gLandToolSize + 1); + gLandToolSize = std::min(kLandToolMaximumSize, gLandToolSize + 1); // Invalidate the window Invalidate(); @@ -157,10 +157,10 @@ public: const auto res = String::Parse(text); if (res.has_value()) { - int32_t size; + uint16_t size; size = res.value(); - size = std::max(MINIMUM_TOOL_SIZE, size); - size = std::min(MAXIMUM_TOOL_SIZE, size); + size = std::max(kLandToolMinimumSize, size); + size = std::min(kLandToolMaximumSize, size); gLandToolSize = size; Invalidate(); } @@ -220,7 +220,7 @@ public: DrawWidgets(dpi); // Draw number for tool sizes bigger than 7 - if (gLandToolSize > MAX_TOOL_SIZE_WITH_SPRITE) + if (gLandToolSize > kLandToolMaximumSizeWithSprite) { auto ft = Formatter(); ft.Add(gLandToolSize); @@ -393,8 +393,8 @@ private: void InputSize() { Formatter ft; - ft.Add(MINIMUM_TOOL_SIZE); - ft.Add(MAXIMUM_TOOL_SIZE); + ft.Add(kLandToolMinimumSize); + ft.Add(kLandToolMaximumSize); WindowTextInputOpen(this, WIDX_PREVIEW, STR_SELECTION_SIZE, STR_ENTER_SELECTION_SIZE, ft, STR_NONE, STR_NONE, 3); } diff --git a/src/openrct2-ui/windows/Map.cpp b/src/openrct2-ui/windows/Map.cpp index ea19e56c17..1b245162d8 100644 --- a/src/openrct2-ui/windows/Map.cpp +++ b/src/openrct2-ui/windows/Map.cpp @@ -205,7 +205,7 @@ public: break; _activeTool = 2; // Prevent mountain tool size. - _landRightsToolSize = std::max(MINIMUM_TOOL_SIZE, _landRightsToolSize); + _landRightsToolSize = std::max(kLandToolMinimumSize, _landRightsToolSize); ShowGridlines(); ShowLandRights(); ShowConstructionRights(); @@ -313,13 +313,13 @@ public: break; case WIDX_LAND_TOOL_SMALLER: // Decrement land rights tool size - _landRightsToolSize = std::max(MINIMUM_TOOL_SIZE, _landRightsToolSize - 1); + _landRightsToolSize = std::max(kLandToolMinimumSize, _landRightsToolSize - 1); Invalidate(); break; case WIDX_LAND_TOOL_LARGER: // Increment land rights tool size - _landRightsToolSize = std::min(MAXIMUM_TOOL_SIZE, _landRightsToolSize + 1); + _landRightsToolSize = std::min(kLandToolMaximumSize, _landRightsToolSize + 1); Invalidate(); break; @@ -616,7 +616,7 @@ public: int32_t size = strtol(textStr.c_str(), &end, 10); if (*end == '\0') { - size = std::clamp(size, MINIMUM_TOOL_SIZE, MAXIMUM_TOOL_SIZE); + size = std::clamp(size, kLandToolMinimumSize, kLandToolMaximumSize); _landRightsToolSize = size; Invalidate(); } @@ -865,7 +865,7 @@ public: + ScreenCoordsXY{ window_map_widgets[WIDX_LAND_TOOL].midX(), window_map_widgets[WIDX_LAND_TOOL].midY() }; // Draw land tool size - if (WidgetIsActiveTool(*this, WIDX_SET_LAND_RIGHTS) && _landRightsToolSize > MAX_TOOL_SIZE_WITH_SPRITE) + if (WidgetIsActiveTool(*this, WIDX_SET_LAND_RIGHTS) && _landRightsToolSize > kLandToolMaximumSizeWithSprite) { auto ft = Formatter(); ft.Add(_landRightsToolSize); @@ -1326,8 +1326,8 @@ private: void InputLandSize() { Formatter ft; - ft.Add(MINIMUM_TOOL_SIZE); - ft.Add(MAXIMUM_TOOL_SIZE); + ft.Add(kLandToolMinimumSize); + ft.Add(kLandToolMaximumSize); TextInputOpen(WIDX_LAND_TOOL, STR_SELECTION_SIZE, STR_ENTER_SELECTION_SIZE, ft, STR_NONE, STR_NONE, 3); } diff --git a/src/openrct2-ui/windows/PatrolArea.cpp b/src/openrct2-ui/windows/PatrolArea.cpp index e9205b9091..75e70d9834 100644 --- a/src/openrct2-ui/windows/PatrolArea.cpp +++ b/src/openrct2-ui/windows/PatrolArea.cpp @@ -86,11 +86,11 @@ public: switch (widgetIndex) { case WIDX_DECREMENT: - gLandToolSize = std::max(MINIMUM_TOOL_SIZE, gLandToolSize - 1); + gLandToolSize = std::max(kLandToolMinimumSize, gLandToolSize - 1); Invalidate(); break; case WIDX_INCREMENT: - gLandToolSize = std::min(MAXIMUM_TOOL_SIZE, gLandToolSize + 1); + gLandToolSize = std::min(kLandToolMaximumSize, gLandToolSize + 1); Invalidate(); break; } @@ -109,8 +109,8 @@ public: { int32_t size; size = res.value(); - size = std::max(MINIMUM_TOOL_SIZE, size); - size = std::min(MAXIMUM_TOOL_SIZE, size); + size = std::max(kLandToolMinimumSize, size); + size = std::min(kLandToolMaximumSize, size); gLandToolSize = size; Invalidate(); } @@ -136,7 +136,7 @@ public: DrawWidgets(dpi); // Draw number for tool sizes bigger than 7 - if (gLandToolSize > MAX_TOOL_SIZE_WITH_SPRITE) + if (gLandToolSize > kLandToolMaximumSizeWithSprite) { auto screenCoords = ScreenCoordsXY{ windowPos.x + PatrolAreaWidgets[WIDX_PREVIEW].midX(), windowPos.y + PatrolAreaWidgets[WIDX_PREVIEW].midY() }; @@ -257,8 +257,8 @@ private: void InputSize() { Formatter ft; - ft.Add(MINIMUM_TOOL_SIZE); - ft.Add(MAXIMUM_TOOL_SIZE); + ft.Add(kLandToolMinimumSize); + ft.Add(kLandToolMaximumSize); WindowTextInputOpen(this, WIDX_PREVIEW, STR_SELECTION_SIZE, STR_ENTER_SELECTION_SIZE, ft, STR_NONE, STR_NONE, 3); } diff --git a/src/openrct2-ui/windows/SceneryScatter.cpp b/src/openrct2-ui/windows/SceneryScatter.cpp index 6583183351..ad8107368a 100644 --- a/src/openrct2-ui/windows/SceneryScatter.cpp +++ b/src/openrct2-ui/windows/SceneryScatter.cpp @@ -80,8 +80,8 @@ public: switch (widgetIndex) { case WIDX_PREVIEW: - ft.Add(MINIMUM_TOOL_SIZE); - ft.Add(MAXIMUM_TOOL_SIZE); + ft.Add(kLandToolMinimumSize); + ft.Add(kLandToolMaximumSize); maxLength = 3; break; } @@ -120,13 +120,13 @@ public: { case WIDX_DECREMENT: // Decrement land tool size, if it stays within the limit - gWindowSceneryScatterSize = std::max(MINIMUM_TOOL_SIZE, gWindowSceneryScatterSize - 1); + gWindowSceneryScatterSize = std::max(kLandToolMinimumSize, gWindowSceneryScatterSize - 1); Invalidate(); break; case WIDX_INCREMENT: // Increment land tool size, if it stays within the limit - gWindowSceneryScatterSize = std::min(MAXIMUM_TOOL_SIZE, gWindowSceneryScatterSize + 1); + gWindowSceneryScatterSize = std::min(kLandToolMaximumSize, gWindowSceneryScatterSize + 1); Invalidate(); break; } @@ -144,7 +144,7 @@ public: switch (widgetIndex) { case WIDX_PREVIEW: - gWindowSceneryScatterSize = std::clamp(res.value(), MINIMUM_TOOL_SIZE, MAXIMUM_TOOL_SIZE); + gWindowSceneryScatterSize = std::clamp(res.value(), kLandToolMinimumSize, kLandToolMaximumSize); break; } Invalidate(); @@ -181,7 +181,7 @@ public: WindowDrawWidgets(*this, dpi); // Draw area as a number for tool sizes bigger than 7 - if (gWindowSceneryScatterSize > MAX_TOOL_SIZE_WITH_SPRITE) + if (gWindowSceneryScatterSize > kLandToolMaximumSizeWithSprite) { const auto& preview = widgets[WIDX_PREVIEW]; const auto screenCoords = ScreenCoordsXY{ windowPos.x + preview.midX(), windowPos.y + preview.midY() }; diff --git a/src/openrct2-ui/windows/Water.cpp b/src/openrct2-ui/windows/Water.cpp index f7a651abd6..9eeab3ff87 100644 --- a/src/openrct2-ui/windows/Water.cpp +++ b/src/openrct2-ui/windows/Water.cpp @@ -86,14 +86,14 @@ public: { case WIDX_DECREMENT: // Decrement land tool size - gLandToolSize = std::max(MINIMUM_TOOL_SIZE, gLandToolSize - 1); + gLandToolSize = std::max(kLandToolMinimumSize, gLandToolSize - 1); // Invalidate the window Invalidate(); break; case WIDX_INCREMENT: // Increment land tool size - gLandToolSize = std::min(MAXIMUM_TOOL_SIZE, gLandToolSize + 1); + gLandToolSize = std::min(kLandToolMaximumSize, gLandToolSize + 1); // Invalidate the window Invalidate(); @@ -124,8 +124,8 @@ public: size = strtol(textStr.c_str(), &end, 10); if (*end == '\0') { - size = std::max(MINIMUM_TOOL_SIZE, size); - size = std::min(MAXIMUM_TOOL_SIZE, size); + size = std::max(kLandToolMinimumSize, size); + size = std::min(kLandToolMaximumSize, size); gLandToolSize = size; Invalidate(); @@ -148,7 +148,7 @@ public: DrawWidgets(dpi); // Draw number for tool sizes bigger than 7 - if (gLandToolSize > MAX_TOOL_SIZE_WITH_SPRITE) + if (gLandToolSize > kLandToolMaximumSizeWithSprite) { auto ft = Formatter(); ft.Add(gLandToolSize); @@ -186,8 +186,8 @@ private: void InputSize() { Formatter ft; - ft.Add(MINIMUM_TOOL_SIZE); - ft.Add(MAXIMUM_TOOL_SIZE); + ft.Add(kLandToolMinimumSize); + ft.Add(kLandToolMaximumSize); WindowTextInputOpen(this, WIDX_PREVIEW, STR_SELECTION_SIZE, STR_ENTER_SELECTION_SIZE, ft, STR_NONE, STR_NONE, 3); } }; diff --git a/src/openrct2/Context.cpp b/src/openrct2/Context.cpp index 3d308e594d..a3bf35234f 100644 --- a/src/openrct2/Context.cpp +++ b/src/openrct2/Context.cpp @@ -628,7 +628,7 @@ namespace OpenRCT2 { parkImporter = ParkImporter::CreateParkFile(*_objectRepository); } - else if (info.Version <= FILE_TYPE_S4_CUTOFF) + else if (info.Version <= kFileTypeS4Cutoff) { // Save is an S4 (RCT1 format) parkImporter = ParkImporter::CreateS4(); diff --git a/src/openrct2/FileClassifier.h b/src/openrct2/FileClassifier.h index 2ea4c0a302..448f104fbe 100644 --- a/src/openrct2/FileClassifier.h +++ b/src/openrct2/FileClassifier.h @@ -48,7 +48,7 @@ struct ClassifiedFileInfo uint32_t Version = 0; }; -#define FILE_TYPE_S4_CUTOFF 2 +constexpr uint32_t kFileTypeS4Cutoff = 2; bool TryClassifyFile(const std::string& path, ClassifiedFileInfo* result); bool TryClassifyFile(OpenRCT2::IStream* stream, ClassifiedFileInfo* result); diff --git a/src/openrct2/Intro.cpp b/src/openrct2/Intro.cpp index 1ae897691b..0af93c2535 100644 --- a/src/openrct2/Intro.cpp +++ b/src/openrct2/Intro.cpp @@ -20,9 +20,9 @@ using namespace OpenRCT2::Audio; -#define BACKROUND_COLOUR_DARK PALETTE_INDEX_10 -#define BACKROUND_COLOUR_LOGO PALETTE_INDEX_245 -#define BORDER_COLOUR_PUBLISHER PALETTE_INDEX_129 +static constexpr PaletteIndex kBackgroundColourDark = PALETTE_INDEX_10; +static constexpr PaletteIndex kBackgroundColourLogo = PALETTE_INDEX_245; +static constexpr PaletteIndex kBorderColourPublisher = PALETTE_INDEX_129; constexpr int32_t PALETTE_G1_IDX_DEVELOPER = 23217; constexpr int32_t PALETTE_G1_IDX_LOGO = 23224; @@ -178,17 +178,17 @@ void IntroDraw(DrawPixelInfo& dpi) case IntroState::Disclaimer2: break; case IntroState::PublisherBegin: - GfxClear(&dpi, BACKROUND_COLOUR_DARK); + GfxClear(&dpi, kBackgroundColourDark); break; case IntroState::PublisherScroll: - GfxClear(&dpi, BACKROUND_COLOUR_DARK); + GfxClear(&dpi, kBackgroundColourDark); // Draw a white rectangle for the logo background (gives a bit of white margin) GfxFillRect( dpi, { { (screenWidth / 2) - 320 + 50, _introStateCounter + 50 }, { (screenWidth / 2) - 320 + 50 + 540, _introStateCounter + 50 + 425 } }, - BORDER_COLOUR_PUBLISHER); + kBorderColourPublisher); // Draw Infogrames logo GfxDrawSprite(dpi, ImageId(SPR_INTRO_INFOGRAMES_00), { (screenWidth / 2) - 320 + 69, _introStateCounter + 69 }); @@ -197,11 +197,11 @@ void IntroDraw(DrawPixelInfo& dpi) GfxDrawSprite(dpi, ImageId(SPR_INTRO_INFOGRAMES_11), { (screenWidth / 2) - 320 + 319, _introStateCounter + 319 }); break; case IntroState::DeveloperBegin: - GfxClear(&dpi, BACKROUND_COLOUR_DARK); + GfxClear(&dpi, kBackgroundColourDark); GfxTransposePalette(PALETTE_G1_IDX_DEVELOPER, 255); break; case IntroState::DeveloperScroll: - GfxClear(&dpi, BACKROUND_COLOUR_DARK); + GfxClear(&dpi, kBackgroundColourDark); // Draw Chris Sawyer logo GfxDrawSprite(dpi, ImageId(SPR_INTRO_CHRIS_SAWYER_00), { (screenWidth / 2) - 320 + 70, _introStateCounter }); @@ -233,7 +233,7 @@ void IntroDraw(DrawPixelInfo& dpi) ScreenIntroDrawLogo(dpi); break; case IntroState::Clear: - GfxClear(&dpi, BACKROUND_COLOUR_DARK); + GfxClear(&dpi, kBackgroundColourDark); break; default: break; @@ -293,7 +293,7 @@ static void ScreenIntroDrawLogo(DrawPixelInfo& dpi) DrawingEngineInvalidateImage(SPR_INTRO_LOGO_11); DrawingEngineInvalidateImage(SPR_INTRO_LOGO_21); - GfxClear(&dpi, BACKROUND_COLOUR_LOGO); + GfxClear(&dpi, kBackgroundColourLogo); GfxDrawSprite(dpi, ImageId(SPR_INTRO_LOGO_00), { imageX + 0, 0 }); GfxDrawSprite(dpi, ImageId(SPR_INTRO_LOGO_10), { imageX + 220, 0 }); GfxDrawSprite(dpi, ImageId(SPR_INTRO_LOGO_20), { imageX + 440, 0 }); diff --git a/src/openrct2/command_line/ParkInfoCommands.cpp b/src/openrct2/command_line/ParkInfoCommands.cpp index 07af5affd9..7a68e4ea3f 100644 --- a/src/openrct2/command_line/ParkInfoCommands.cpp +++ b/src/openrct2/command_line/ParkInfoCommands.cpp @@ -73,7 +73,7 @@ static exitcode_t HandleObjectsInfo(CommandLineArgEnumerator* argEnumerator) { parkImporter = ParkImporter::CreateParkFile(objectRepository); } - else if (info.Version <= FILE_TYPE_S4_CUTOFF) + else if (info.Version <= kFileTypeS4Cutoff) { // Save is an S4 (RCT1 format) parkImporter = ParkImporter::CreateS4();