diff --git a/src/openrct2-ui/UiContext.cpp b/src/openrct2-ui/UiContext.cpp index def05b4eee..16faf0a902 100644 --- a/src/openrct2-ui/UiContext.cpp +++ b/src/openrct2-ui/UiContext.cpp @@ -177,7 +177,7 @@ public: SDL_WINDOW_FULLSCREEN, SDL_WINDOW_FULLSCREEN_DESKTOP, }; - uint32_t windowFlags = _sdlFullscreenFlags[static_cast(mode)]; + uint32_t windowFlags = _sdlFullscreenFlags[EnumValue(mode)]; // HACK Changing window size when in fullscreen usually has no effect if (mode == FULLSCREEN_MODE::FULLSCREEN) diff --git a/src/openrct2-ui/windows/Finances.cpp b/src/openrct2-ui/windows/Finances.cpp index ad2e3aad5e..4910574e97 100644 --- a/src/openrct2-ui/windows/Finances.cpp +++ b/src/openrct2-ui/windows/Finances.cpp @@ -181,7 +181,7 @@ static_assert(std::size(_windowFinancesPageWidgets) == WINDOW_FINANCES_PAGE_COUN #pragma endregion -static constexpr StringId _windowFinancesSummaryRowLabels[static_cast(ExpenditureType::Count)] = { +static constexpr StringId _windowFinancesSummaryRowLabels[EnumValue(ExpenditureType::Count)] = { STR_FINANCES_SUMMARY_RIDE_CONSTRUCTION, STR_FINANCES_SUMMARY_RIDE_RUNNING_COSTS, STR_FINANCES_SUMMARY_LAND_PURCHASE, diff --git a/src/openrct2-ui/windows/Options.cpp b/src/openrct2-ui/windows/Options.cpp index 5e7d60256e..e9acc5492f 100644 --- a/src/openrct2-ui/windows/Options.cpp +++ b/src/openrct2-ui/windows/Options.cpp @@ -1043,7 +1043,7 @@ private: STR_VIRTUAL_FLOOR_STYLE_GLASSY, }; - widgets[WIDX_VIRTUAL_FLOOR].text = _virtualFloorStyleStrings[static_cast(gConfigGeneral.VirtualFloorStyle)]; + widgets[WIDX_VIRTUAL_FLOOR].text = _virtualFloorStyleStrings[EnumValue(gConfigGeneral.VirtualFloorStyle)]; SetCheckboxValue(WIDX_ENABLE_LIGHT_FX_CHECKBOX, gConfigGeneral.EnableLightFx); if (gConfigGeneral.DayNightCycle && gConfigGeneral.DrawingEngine == DrawingEngine::SoftwareWithHardwareDisplay) diff --git a/src/openrct2/GameState.h b/src/openrct2/GameState.h index 09034b7945..578613dd93 100644 --- a/src/openrct2/GameState.h +++ b/src/openrct2/GameState.h @@ -18,6 +18,7 @@ #include "management/NewsItem.h" #include "ride/Ride.h" #include "scenario/Scenario.h" +#include "util/Util.h" #include "world/Banner.h" #include "world/Climate.h" #include "world/Location.hpp" @@ -78,7 +79,7 @@ namespace OpenRCT2 money64 BankLoan; uint8_t BankLoanInterestRate; money64 MaxBankLoan; - money64 ExpenditureTable[EXPENDITURE_TABLE_MONTH_COUNT][static_cast(ExpenditureType::Count)]; + money64 ExpenditureTable[EXPENDITURE_TABLE_MONTH_COUNT][EnumValue(ExpenditureType::Count)]; random_engine_t ScenarioRand; TileCoordsXY MapSize; diff --git a/src/openrct2/management/Finance.cpp b/src/openrct2/management/Finance.cpp index b7afabef08..cd0abc8660 100644 --- a/src/openrct2/management/Finance.cpp +++ b/src/openrct2/management/Finance.cpp @@ -37,7 +37,7 @@ const money64 research_cost_table[RESEARCH_FUNDING_COUNT] = { 400.00_GBP, // Maximum funding }; -static constexpr int32_t dword_988E60[static_cast(ExpenditureType::Count)] = { +static constexpr int32_t dword_988E60[EnumValue(ExpenditureType::Count)] = { 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, }; @@ -80,8 +80,8 @@ void FinancePayment(money64 amount, ExpenditureType type) auto& gameState = GetGameState(); gameState.Cash = AddClamp_money64(gameState.Cash, -amount); - gameState.ExpenditureTable[0][static_cast(type)] -= amount; - if (dword_988E60[static_cast(type)] & 1) + gameState.ExpenditureTable[0][EnumValue(type)] -= amount; + if (dword_988E60[EnumValue(type)] & 1) { // Cumulative amount of money spent this day gameState.CurrentExpenditure -= amount; @@ -366,10 +366,10 @@ money64 FinanceGetLastMonthShopProfit() { const auto* lastMonthExpenditure = GetGameState().ExpenditureTable[1]; - profit += lastMonthExpenditure[static_cast(ExpenditureType::ShopSales)]; - profit += lastMonthExpenditure[static_cast(ExpenditureType::ShopStock)]; - profit += lastMonthExpenditure[static_cast(ExpenditureType::FoodDrinkSales)]; - profit += lastMonthExpenditure[static_cast(ExpenditureType::FoodDrinkStock)]; + profit += lastMonthExpenditure[EnumValue(ExpenditureType::ShopSales)]; + profit += lastMonthExpenditure[EnumValue(ExpenditureType::ShopStock)]; + profit += lastMonthExpenditure[EnumValue(ExpenditureType::FoodDrinkSales)]; + profit += lastMonthExpenditure[EnumValue(ExpenditureType::FoodDrinkStock)]; } return profit; } \ No newline at end of file diff --git a/src/openrct2/scenario/Scenario.cpp b/src/openrct2/scenario/Scenario.cpp index 239f233a1b..f1424db3f0 100644 --- a/src/openrct2/scenario/Scenario.cpp +++ b/src/openrct2/scenario/Scenario.cpp @@ -743,7 +743,7 @@ ObjectiveStatus Objective::CheckGuestsAndRating() const ObjectiveStatus Objective::CheckMonthlyRideIncome() const { - money64 lastMonthRideIncome = GetGameState().ExpenditureTable[1][static_cast(ExpenditureType::ParkRideTickets)]; + money64 lastMonthRideIncome = GetGameState().ExpenditureTable[1][EnumValue(ExpenditureType::ParkRideTickets)]; if (lastMonthRideIncome >= Currency) { return ObjectiveStatus::Success; @@ -832,10 +832,10 @@ ObjectiveStatus Objective::CheckRepayLoanAndParkValue() const ObjectiveStatus Objective::CheckMonthlyFoodIncome() const { const auto* lastMonthExpenditure = GetGameState().ExpenditureTable[1]; - auto lastMonthProfit = lastMonthExpenditure[static_cast(ExpenditureType::ShopSales)] - + lastMonthExpenditure[static_cast(ExpenditureType::ShopStock)] - + lastMonthExpenditure[static_cast(ExpenditureType::FoodDrinkSales)] - + lastMonthExpenditure[static_cast(ExpenditureType::FoodDrinkStock)]; + auto lastMonthProfit = lastMonthExpenditure[EnumValue(ExpenditureType::ShopSales)] + + lastMonthExpenditure[EnumValue(ExpenditureType::ShopStock)] + + lastMonthExpenditure[EnumValue(ExpenditureType::FoodDrinkSales)] + + lastMonthExpenditure[EnumValue(ExpenditureType::FoodDrinkStock)]; if (lastMonthProfit >= Currency) {