From 25184a23fc4df9c1de6e539715a56d38eda5a83e Mon Sep 17 00:00:00 2001 From: Cyprian Klimaszewski Date: Mon, 12 Jan 2026 23:28:49 +0100 Subject: [PATCH] Codechange: Make EconomyType an enum class. --- src/economy_type.h | 12 ++++++------ src/industry_cmd.cpp | 6 +++--- src/table/settings/economy_settings.ini | 6 +++--- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/economy_type.h b/src/economy_type.h index dca2ed1e97..d3e9afcf53 100644 --- a/src/economy_type.h +++ b/src/economy_type.h @@ -17,12 +17,12 @@ typedef OverflowSafeInt64 Money; /** Type of the game economy. */ -enum EconomyType : uint8_t { - ET_BEGIN = 0, ///< The lowest valid value. - ET_ORIGINAL = 0, ///< Imitates original TTD economy. - ET_SMOOTH = 1, ///< Makes production changes more often, and in smaller steps. - ET_FROZEN = 2, ///< Stops production changes and industry closures. - ET_END = 3, ///< Economy type end marker. +enum class EconomyType : uint8_t { + Begin, ///< The lowest valid value. + Original = EconomyType::Begin, ///< Imitates original TTD economy. + Smooth, ///< Makes production changes more often, and in smaller steps. + Frozen, ///< Stops production changes and industry closures. + End, ///< Economy type end marker. }; /** diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp index b23fb69e0b..9695b0e11c 100644 --- a/src/industry_cmd.cpp +++ b/src/industry_cmd.cpp @@ -2915,7 +2915,7 @@ static void ChangeIndustryProduction(Industry *i, bool monthly) } } else { if (monthly == original_economy) return; - if (!original_economy && _settings_game.economy.type == ET_FROZEN) return; + if (!original_economy && _settings_game.economy.type == EconomyType::Frozen) return; if (indspec->life_type == INDUSTRYLIFE_BLACK_HOLE) return; } @@ -2932,7 +2932,7 @@ static void ChangeIndustryProduction(Industry *i, bool monthly) div = 1; // Decrease production } } - } else if (_settings_game.economy.type == ET_SMOOTH) { + } else if (_settings_game.economy.type == EconomyType::Smooth) { closeit = !i->ctlflags.Any({IndustryControlFlag::NoClosure, IndustryControlFlag::NoProductionDecrease}); for (auto &p : i->produced) { if (!IsValidCargoType(p.cargo)) continue; @@ -3224,7 +3224,7 @@ Money IndustrySpec::GetRemovalCost() const */ bool IndustrySpec::UsesOriginalEconomy() const { - return _settings_game.economy.type == ET_ORIGINAL || + return _settings_game.economy.type == EconomyType::Original || this->callback_mask.Any({ IndustryCallbackMask::Production256Ticks, IndustryCallbackMask::ProductionCargoArrival, // production callbacks diff --git a/src/table/settings/economy_settings.ini b/src/table/settings/economy_settings.ini index a61466d64f..fc195d7f80 100644 --- a/src/table/settings/economy_settings.ini +++ b/src/table/settings/economy_settings.ini @@ -190,9 +190,9 @@ cat = SC_BASIC var = economy.type type = SLE_UINT8 flags = SettingFlag::GuiDropdown -def = ET_SMOOTH -min = ET_BEGIN -max = ET_END - 1 +def = EconomyType::Smooth +min = EconomyType::Begin +max = EconomyType::Frozen str = STR_CONFIG_SETTING_ECONOMY_TYPE strhelp = STR_CONFIG_SETTING_ECONOMY_TYPE_HELPTEXT help_cb = SettingHelpWallclock