1
0
mirror of https://github.com/OpenTTD/OpenTTD synced 2026-01-27 06:04:25 +01:00

Codechange: Make EconomyType an enum class.

This commit is contained in:
Cyprian Klimaszewski
2026-01-12 23:28:49 +01:00
committed by rubidium42
parent 322ce224b4
commit 25184a23fc
3 changed files with 12 additions and 12 deletions

View File

@@ -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.
};
/**

View File

@@ -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

View File

@@ -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