From 18f2f7eb2d5e7d0dbea59f3b886b6e4ac12c95b4 Mon Sep 17 00:00:00 2001 From: Tyler Trahan Date: Sat, 10 Jan 2026 17:40:48 -0500 Subject: [PATCH] Codechange: Use enum class for setting values (#15074) --- src/genworld_gui.cpp | 24 ++-- src/industry_cmd.cpp | 18 +-- src/industry_gui.cpp | 2 +- src/landscape.cpp | 2 +- src/main_gui.cpp | 2 +- src/network/network_coordinator.cpp | 6 +- src/network/network_gui.cpp | 6 +- src/network/network_survey.cpp | 2 +- src/openttd.cpp | 2 +- src/saveload/afterload.cpp | 10 +- src/settings.cpp | 8 +- src/settings_gui.cpp | 14 +-- src/settings_table.cpp | 9 +- src/settings_type.h | 110 +++++++++--------- src/smallmap_gui.cpp | 4 +- src/table/settings/difficulty_settings.ini | 14 +-- src/table/settings/economy_settings.ini | 18 +-- src/table/settings/gui_settings.ini | 24 ++-- .../settings/network_private_settings.ini | 12 +- src/table/settings/world_settings.ini | 6 +- src/timer/timer_game_economy.cpp | 4 +- src/toolbar_gui.cpp | 4 +- src/town_cmd.cpp | 6 +- src/town_gui.cpp | 2 +- src/tree_cmd.cpp | 8 +- src/vehicle.cpp | 12 +- src/vehicle_gui.cpp | 2 +- src/viewport_gui.cpp | 2 +- src/window.cpp | 20 ++-- 29 files changed, 175 insertions(+), 178 deletions(-) diff --git a/src/genworld_gui.cpp b/src/genworld_gui.cpp index feedb47d20..203b71a06e 100644 --- a/src/genworld_gui.cpp +++ b/src/genworld_gui.cpp @@ -393,7 +393,7 @@ static const StringID _num_inds[] = {STR_FUNDING_ONLY, STR_MINIMAL, STR_NUM_V static const StringID _variety[] = {STR_VARIETY_NONE, STR_VARIETY_VERY_LOW, STR_VARIETY_LOW, STR_VARIETY_MEDIUM, STR_VARIETY_HIGH, STR_VARIETY_VERY_HIGH}; static const StringID _average_height[] = {STR_CONFIG_SETTING_AVERAGE_HEIGHT_AUTO, STR_CONFIG_SETTING_AVERAGE_HEIGHT_LOWLANDS, STR_CONFIG_SETTING_AVERAGE_HEIGHT_NORMAL, STR_CONFIG_SETTING_AVERAGE_HEIGHT_PLATEAUS}; -static_assert(std::size(_num_inds) == ID_END); +static_assert(std::size(_num_inds) == to_underlying(IndustryDensity::End)); struct GenerateLandscapeWindow : public Window { WidgetID widget_id{}; @@ -458,10 +458,10 @@ struct GenerateLandscapeWindow : public Window { if (_game_mode == GM_EDITOR) { return GetString(STR_CONFIG_SETTING_OFF); } - if (_settings_newgame.difficulty.industry_density == ID_CUSTOM) { + if (_settings_newgame.difficulty.industry_density == IndustryDensity::Custom) { return GetString(STR_NUM_CUSTOM_NUMBER, _settings_newgame.game_creation.custom_industry_number); } - return GetString(_num_inds[_settings_newgame.difficulty.industry_density]); + return GetString(_num_inds[to_underlying(_settings_newgame.difficulty.industry_density)]); case WID_GL_MAX_HEIGHT_PULLDOWN: if (_settings_newgame.difficulty.terrain_type == GenworldMaxHeight::Custom) { @@ -480,7 +480,7 @@ struct GenerateLandscapeWindow : public Window { case WID_GL_SMOOTHNESS_PULLDOWN: return GetString(_smoothness[_settings_newgame.game_creation.tgen_smoothness]); case WID_GL_VARIETY_PULLDOWN: return GetString(_variety[_settings_newgame.game_creation.variety]); case WID_GL_AVERAGE_HEIGHT_PULLDOWN: return GetString(_average_height[to_underlying(_settings_newgame.game_creation.average_height)]); - case WID_GL_BORDERS_PULLDOWN: return GetString(_borders[_settings_newgame.game_creation.water_border_presets]); + case WID_GL_BORDERS_PULLDOWN: return GetString(_borders[to_underlying(_settings_newgame.game_creation.water_border_presets)]); case WID_GL_WATER_NE: return GetString((_settings_newgame.game_creation.water_borders == BorderFlag::Random) ? STR_MAPGEN_BORDER_RANDOM : _settings_newgame.game_creation.water_borders.Test(BorderFlag::NorthEast) ? STR_MAPGEN_BORDER_WATER : STR_MAPGEN_BORDER_FREEFORM); case WID_GL_WATER_NW: return GetString((_settings_newgame.game_creation.water_borders == BorderFlag::Random) ? STR_MAPGEN_BORDER_RANDOM : _settings_newgame.game_creation.water_borders.Test(BorderFlag::NorthWest) ? STR_MAPGEN_BORDER_WATER : STR_MAPGEN_BORDER_FREEFORM); case WID_GL_WATER_SE: return GetString((_settings_newgame.game_creation.water_borders == BorderFlag::Random) ? STR_MAPGEN_BORDER_RANDOM : _settings_newgame.game_creation.water_borders.Test(BorderFlag::SouthEast) ? STR_MAPGEN_BORDER_WATER : STR_MAPGEN_BORDER_FREEFORM); @@ -679,7 +679,7 @@ struct GenerateLandscapeWindow : public Window { break; case WID_GL_INDUSTRY_PULLDOWN: // Number of industries - ShowDropDownMenu(this, _num_inds, _settings_newgame.difficulty.industry_density, WID_GL_INDUSTRY_PULLDOWN, 0, 0); + ShowDropDownMenu(this, _num_inds, to_underlying(_settings_newgame.difficulty.industry_density), WID_GL_INDUSTRY_PULLDOWN, 0, 0); break; case WID_GL_GENERATE_BUTTON: { // Generate @@ -818,7 +818,7 @@ struct GenerateLandscapeWindow : public Window { /* Map borders */ case WID_GL_BORDERS_PULLDOWN: - ShowDropDownMenu(this, _borders, _settings_newgame.game_creation.water_border_presets, WID_GL_BORDERS_PULLDOWN, 0, 0); + ShowDropDownMenu(this, _borders, to_underlying(_settings_newgame.game_creation.water_border_presets), WID_GL_BORDERS_PULLDOWN, 0, 0); break; case WID_GL_WATER_NW: @@ -896,11 +896,11 @@ struct GenerateLandscapeWindow : public Window { break; case WID_GL_INDUSTRY_PULLDOWN: - if ((uint)index == ID_CUSTOM) { + if (static_cast(index) == IndustryDensity::Custom) { this->widget_id = widget; ShowQueryString(GetString(STR_JUST_INT, _settings_newgame.game_creation.custom_industry_number), STR_MAPGEN_NUMBER_OF_INDUSTRIES, 5, this, CS_NUMERAL, {}); } - _settings_newgame.difficulty.industry_density = index; + _settings_newgame.difficulty.industry_density = static_cast(index); break; case WID_GL_MAX_HEIGHT_PULLDOWN: { @@ -913,16 +913,16 @@ struct GenerateLandscapeWindow : public Window { } case WID_GL_BORDERS_PULLDOWN: { - switch (index) { - case BFP_RANDOM: + switch (static_cast(index)) { + case BorderFlagPresets::Random: _settings_newgame.game_creation.water_borders = BorderFlag::Random; _settings_newgame.construction.freeform_edges = true; break; - case BFP_MANUAL: + case BorderFlagPresets::Manual: _settings_newgame.game_creation.water_borders = {}; _settings_newgame.construction.freeform_edges = true; break; - case BFP_INFINITE_WATER: + case BorderFlagPresets::InfiniteWater: _settings_newgame.game_creation.water_borders = BORDERFLAGS_ALL; _settings_newgame.construction.freeform_edges = false; break; diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp index 2400eb9a93..099bcf54b0 100644 --- a/src/industry_cmd.cpp +++ b/src/industry_cmd.cpp @@ -2309,7 +2309,7 @@ static uint32_t GetScaledIndustryGenerationProbability(IndustryType it, std::opt uint32_t chance = ind_spc->appear_creation[to_underlying(_settings_game.game_creation.landscape)]; if (!ind_spc->enabled || ind_spc->layouts.empty() || - (_game_mode != GM_EDITOR && _settings_game.difficulty.industry_density == ID_FUND_ONLY) || + (_game_mode != GM_EDITOR && _settings_game.difficulty.industry_density == IndustryDensity::FundedOnly) || (chance = GetIndustryProbabilityCallback(it, IACT_MAPGENERATION, chance)) == 0) { *force_at_least_one = false; return 0; @@ -2332,7 +2332,7 @@ static uint32_t GetScaledIndustryGenerationProbability(IndustryType it, std::opt */ static uint16_t GetIndustryGamePlayProbability(IndustryType it, uint8_t *min_number) { - if (_settings_game.difficulty.industry_density == ID_FUND_ONLY) { + if (_settings_game.difficulty.industry_density == IndustryDensity::FundedOnly) { *min_number = 0; return 0; } @@ -2367,12 +2367,12 @@ static uint GetNumberOfIndustries() 0, // custom }; - assert(lengthof(numof_industry_table) == ID_END); - uint difficulty = (_game_mode != GM_EDITOR) ? _settings_game.difficulty.industry_density : (uint)ID_VERY_LOW; + assert(lengthof(numof_industry_table) == to_underlying(IndustryDensity::End)); + IndustryDensity density = (_game_mode != GM_EDITOR) ? _settings_game.difficulty.industry_density : IndustryDensity::VeryLow; - if (difficulty == ID_CUSTOM) return std::min(IndustryPool::MAX_SIZE, _settings_game.game_creation.custom_industry_number); + if (density == IndustryDensity::Custom) return std::min(IndustryPool::MAX_SIZE, _settings_game.game_creation.custom_industry_number); - return std::min(IndustryPool::MAX_SIZE, Map::ScaleBySize(numof_industry_table[difficulty])); + return std::min(IndustryPool::MAX_SIZE, Map::ScaleBySize(numof_industry_table[to_underlying(density)])); } /** @@ -2446,7 +2446,7 @@ void IndustryBuildData::Reset() void IndustryBuildData::EconomyMonthlyLoop() { static const int NEWINDS_PER_MONTH = 0x38000 / (10 * 12); // lower 16 bits is a float fraction, 3.5 industries per decade, divided by 10 * 12 months. - if (_settings_game.difficulty.industry_density == ID_FUND_ONLY) return; // 'no industries' setting. + if (_settings_game.difficulty.industry_density == IndustryDensity::FundedOnly) return; // 'no industries' setting. /* To prevent running out of unused industries for the player to connect, * add a fraction of new industries each month, but only if the manager can keep up. */ @@ -2487,7 +2487,7 @@ static IndustryGenerationProbabilities GetScaledProbabilities(bool water) */ void GenerateIndustries() { - if (_game_mode != GM_EDITOR && _settings_game.difficulty.industry_density == ID_FUND_ONLY) return; // No industries in the game. + if (_game_mode != GM_EDITOR && _settings_game.difficulty.industry_density == IndustryDensity::FundedOnly) return; // No industries in the game. /* Get the probabilities for all industries. This is done first as we need the total of * both land and water for scaling later. */ @@ -2503,7 +2503,7 @@ void GenerateIndustries() if (lprob.total + wprob.total > 0) total_amount = p.total * GetNumberOfIndustries() / (lprob.total + wprob.total); /* Scale land-based industries to the land proportion, unless the player has set a custom industry count. */ - if (!water && _settings_game.difficulty.industry_density != ID_CUSTOM) total_amount = Map::ScaleByLandProportion(total_amount); + if (!water && _settings_game.difficulty.industry_density != IndustryDensity::Custom) total_amount = Map::ScaleByLandProportion(total_amount); /* Ensure that forced industries are generated even if the scaled amounts are too low. */ if (p.total == 0 || total_amount < p.num_forced) { diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp index cdb3b8d946..b7ae536c17 100644 --- a/src/industry_gui.cpp +++ b/src/industry_gui.cpp @@ -1127,7 +1127,7 @@ public: void OnMouseWheel(int wheel, WidgetID widget) override { if (widget != WID_IV_VIEWPORT) return; - if (_settings_client.gui.scrollwheel_scrolling != SWS_OFF) { + if (_settings_client.gui.scrollwheel_scrolling != ScrollWheelScrolling::Off) { DoZoomInOutWindow(wheel < 0 ? ZOOM_IN : ZOOM_OUT, this); } } diff --git a/src/landscape.cpp b/src/landscape.cpp index 1a4e35c678..2f2ad555db 100644 --- a/src/landscape.cpp +++ b/src/landscape.cpp @@ -1124,7 +1124,7 @@ static void MakeWetlands(TileIndex centre, uint height, uint river_length) /* This tile is ground, which we always make rough. */ SetClearGroundDensity(tile, CLEAR_ROUGH, 3); /* Maybe place trees? */ - if (has_trees && _settings_game.game_creation.tree_placer != TP_NONE) { + if (has_trees && _settings_game.game_creation.tree_placer != TreePlacer::None) { PlaceTree(tile, Random(), true); } } diff --git a/src/main_gui.cpp b/src/main_gui.cpp index f54c7d6016..ea54a1dcef 100644 --- a/src/main_gui.cpp +++ b/src/main_gui.cpp @@ -439,7 +439,7 @@ struct MainWindow : Window void OnMouseWheel(int wheel, WidgetID widget) override { if (widget != WID_M_VIEWPORT) return; - if (_settings_client.gui.scrollwheel_scrolling != SWS_OFF) { + if (_settings_client.gui.scrollwheel_scrolling != ScrollWheelScrolling::Off) { bool in = wheel < 0; /* When following, only change zoom - otherwise zoom to the cursor. */ diff --git a/src/network/network_coordinator.cpp b/src/network/network_coordinator.cpp index f3493ce279..d08dc73736 100644 --- a/src/network/network_coordinator.cpp +++ b/src/network/network_coordinator.cpp @@ -397,15 +397,15 @@ bool ClientNetworkCoordinatorSocketHandler::Receive_GC_TURN_CONNECT(Packet &p) } switch (_settings_client.network.use_relay_service) { - case URS_NEVER: + case UseRelayService::Never: this->ConnectFailure(token, 0); break; - case URS_ASK: + case UseRelayService::Ask: ShowNetworkAskRelay(connecter_it->second.first, std::move(connection_string), std::move(token)); break; - case URS_ALLOW: + case UseRelayService::Allow: this->StartTurnConnection(token); break; } diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp index a92c58f7a3..c366eef8c0 100644 --- a/src/network/network_gui.cpp +++ b/src/network/network_gui.cpp @@ -2190,7 +2190,7 @@ struct NetworkAskRelayWindow : public Window { break; case WID_NAR_YES_ALWAYS: - _settings_client.network.use_relay_service = URS_ALLOW; + _settings_client.network.use_relay_service = UseRelayService::Allow; _network_coordinator_client.StartTurnConnection(this->token); this->Close(NRWCD_HANDLED); break; @@ -2281,12 +2281,12 @@ struct NetworkAskSurveyWindow : public Window { break; case WID_NAS_NO: - _settings_client.network.participate_survey = PS_NO; + _settings_client.network.participate_survey = ParticipateSurvey::No; this->Close(); break; case WID_NAS_YES: - _settings_client.network.participate_survey = PS_YES; + _settings_client.network.participate_survey = ParticipateSurvey::Yes; this->Close(); break; } diff --git a/src/network/network_survey.cpp b/src/network/network_survey.cpp index 7fb511c598..2ad90ba06a 100644 --- a/src/network/network_survey.cpp +++ b/src/network/network_survey.cpp @@ -90,7 +90,7 @@ void NetworkSurveyHandler::Transmit(Reason reason, bool blocking) return; } - if (_settings_client.network.participate_survey != PS_YES) { + if (_settings_client.network.participate_survey != ParticipateSurvey::Yes) { Debug(net, 5, "Survey: user is not participating in survey; skipping survey"); return; } diff --git a/src/openttd.cpp b/src/openttd.cpp index 7d585b09e0..cdcaf33f33 100644 --- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -1163,7 +1163,7 @@ void SwitchToMode(SwitchMode new_mode) ShowErrorMessage(GetEncodedString(STR_WARNING_FALLBACK_SOUNDSET), {}, WL_CRITICAL); BaseSounds::ini_set = BaseSounds::GetUsedSet()->name; } - if (_settings_client.network.participate_survey == PS_ASK) { + if (_settings_client.network.participate_survey == ParticipateSurvey::Ask) { /* No matter how often you go back to the main menu, only ask the first time. */ static bool asked_once = false; if (!asked_once) { diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp index 5b8acc9cf8..48f3dda30a 100644 --- a/src/saveload/afterload.cpp +++ b/src/saveload/afterload.cpp @@ -733,7 +733,7 @@ bool AfterLoadGame() TimerGameCalendar::SetDate(TimerGameCalendar::date, TimerGameCalendar::date_fract); /* Only new games can use wallclock units. */ - if (IsSavegameVersionBefore(SLV_ECONOMY_MODE_TIMEKEEPING_UNITS)) _settings_game.economy.timekeeping_units = TKU_CALENDAR; + if (IsSavegameVersionBefore(SLV_ECONOMY_MODE_TIMEKEEPING_UNITS)) _settings_game.economy.timekeeping_units = TimekeepingUnits::Calendar; /* Set the correct default for 'minutes per year' if the savegame was created before the setting existed. */ if (IsSavegameVersionBefore(SLV_CALENDAR_SUB_DATE_FRACT)) _settings_game.economy.minutes_per_calendar_year = CalendarTime::DEF_MINUTES_PER_YEAR; @@ -1702,8 +1702,8 @@ bool AfterLoadGame() if (IsSavegameVersionBefore(SLV_58)) { /* Setting difficulty industry_density other than zero get bumped to +1 * since a new option (very low at position 1) has been added */ - if (_settings_game.difficulty.industry_density > 0) { - _settings_game.difficulty.industry_density++; + if (_settings_game.difficulty.industry_density > IndustryDensity::FundedOnly) { + _settings_game.difficulty.industry_density = static_cast(to_underlying(_settings_game.difficulty.industry_density) + 1); } /* Same goes for number of towns, although no test is needed, just an increment */ @@ -2850,8 +2850,8 @@ bool AfterLoadGame() if (IsSavegameVersionBefore(SLV_160)) { /* Setting difficulty industry_density other than zero get bumped to +1 * since a new option (minimal at position 1) has been added */ - if (_settings_game.difficulty.industry_density > 0) { - _settings_game.difficulty.industry_density++; + if (_settings_game.difficulty.industry_density > IndustryDensity::FundedOnly) { + _settings_game.difficulty.industry_density = static_cast(to_underlying(_settings_game.difficulty.industry_density) + 1); } } diff --git a/src/settings.cpp b/src/settings.cpp index 8282809901..2e24977359 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -1408,11 +1408,11 @@ void LoadFromConfig(bool startup) const IniItem *use_relay_service = network->GetItem("use_relay_service"); if (use_relay_service != nullptr) { if (use_relay_service->value == "never") { - _settings_client.network.use_relay_service = UseRelayService::URS_NEVER; + _settings_client.network.use_relay_service = UseRelayService::Never; } else if (use_relay_service->value == "ask") { - _settings_client.network.use_relay_service = UseRelayService::URS_ASK; + _settings_client.network.use_relay_service = UseRelayService::Ask; } else if (use_relay_service->value == "allow") { - _settings_client.network.use_relay_service = UseRelayService::URS_ALLOW; + _settings_client.network.use_relay_service = UseRelayService::Allow; } } } @@ -1442,7 +1442,7 @@ void LoadFromConfig(bool startup) /* Persist the right click close option from older versions. */ if (generic_version < IFV_RIGHT_CLICK_CLOSE && IsConversionNeeded(generic_ini, "gui", "right_mouse_wnd_close", "right_click_wnd_close", &old_item)) { auto old_value = BoolSettingDesc::ParseSingleValue(*old_item->value); - _settings_client.gui.right_click_wnd_close = old_value.value_or(false) ? RCC_YES : RCC_NO; + _settings_client.gui.right_click_wnd_close = old_value.value_or(false) ? RightClickClose::Yes : RightClickClose::No; } _grfconfig_newgame = GRFLoadConfig(generic_ini, "newgrf", false); diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index 8e9e4f1042..6de6a1f052 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -960,17 +960,17 @@ struct GameOptionsWindow : Window { case WID_GO_SURVEY_PARTICIPATE_BUTTON: switch (_settings_client.network.participate_survey) { - case PS_ASK: - case PS_NO: - _settings_client.network.participate_survey = PS_YES; + case ParticipateSurvey::Ask: + case ParticipateSurvey::No: + _settings_client.network.participate_survey = ParticipateSurvey::Yes; break; - case PS_YES: - _settings_client.network.participate_survey = PS_NO; + case ParticipateSurvey::Yes: + _settings_client.network.participate_survey = ParticipateSurvey::No; break; } - this->SetWidgetLoweredState(WID_GO_SURVEY_PARTICIPATE_BUTTON, _settings_client.network.participate_survey == PS_YES); + this->SetWidgetLoweredState(WID_GO_SURVEY_PARTICIPATE_BUTTON, _settings_client.network.participate_survey == ParticipateSurvey::Yes); this->SetWidgetDirty(WID_GO_SURVEY_PARTICIPATE_BUTTON); this->SetWidgetDirty(WID_GO_SURVEY_PARTICIPATE_TEXT); break; @@ -1528,7 +1528,7 @@ struct GameOptionsWindow : Window { void OnInvalidateData([[maybe_unused]] int data = 0, [[maybe_unused]] bool gui_scope = true) override { if (!gui_scope) return; - this->SetWidgetLoweredState(WID_GO_SURVEY_PARTICIPATE_BUTTON, _settings_client.network.participate_survey == PS_YES); + this->SetWidgetLoweredState(WID_GO_SURVEY_PARTICIPATE_BUTTON, _settings_client.network.participate_survey == ParticipateSurvey::Yes); this->SetWidgetLoweredState(WID_GO_FULLSCREEN_BUTTON, _fullscreen); this->SetWidgetLoweredState(WID_GO_VIDEO_ACCEL_BUTTON, _video_hw_accel); this->SetWidgetDisabledState(WID_GO_REFRESH_RATE_DROPDOWN, _video_vsync); diff --git a/src/settings_table.cpp b/src/settings_table.cpp index 009176dcf7..796312e9af 100644 --- a/src/settings_table.cpp +++ b/src/settings_table.cpp @@ -588,9 +588,8 @@ static void UpdateClientConfigValues() /** * Callback for when the player changes the timekeeping units. - * @param Unused. */ -static void ChangeTimekeepingUnits(int32_t) +static void ChangeTimekeepingUnits() { /* If service intervals are in time units (calendar days or real-world minutes), reset them to the correct defaults. */ if (!_settings_client.company.vehicle.servint_ispercent) { @@ -657,9 +656,9 @@ static void ChangeMinutesPerYear(int32_t new_value) * This can only happen in the menu, since the pre_cb ensures this setting can only be changed there, or if we're already using wallclock units. */ if (_game_mode == GM_MENU && (_settings_newgame.economy.minutes_per_calendar_year != CalendarTime::DEF_MINUTES_PER_YEAR)) { - if (_settings_newgame.economy.timekeeping_units != TKU_WALLCLOCK) { - _settings_newgame.economy.timekeeping_units = TKU_WALLCLOCK; - ChangeTimekeepingUnits(TKU_WALLCLOCK); + if (_settings_newgame.economy.timekeeping_units != TimekeepingUnits::Wallclock) { + _settings_newgame.economy.timekeeping_units = TimekeepingUnits::Wallclock; + ChangeTimekeepingUnits(); } } } diff --git a/src/settings_type.h b/src/settings_type.h index 32b0fba43d..a7f01416b4 100644 --- a/src/settings_type.h +++ b/src/settings_type.h @@ -52,17 +52,17 @@ enum SettingsProfile : uint8_t { }; /** Available industry map generation densities. */ -enum IndustryDensity : uint8_t { - ID_FUND_ONLY, ///< The game does not build industries. - ID_MINIMAL, ///< Start with just the industries that must be present. - ID_VERY_LOW, ///< Very few industries at game start. - ID_LOW, ///< Few industries at game start. - ID_NORMAL, ///< Normal amount of industries at game start. - ID_HIGH, ///< Many industries at game start. +enum class IndustryDensity : uint8_t { + FundedOnly, ///< The game does not build industries. + Minimal, ///< Start with just the industries that must be present. + VeryLow, ///< Very few industries at game start. + Low, ///< Few industries at game start. + Normal, ///< Normal amount of industries at game start. + High, ///< Many industries at game start. - ID_CUSTOM, ///< Custom number of industries. + Custom, ///< Custom number of industries. - ID_END, ///< Number of industry density settings. + End, ///< Number of industry density settings. }; /** Possible options for the Maximum Height pulldown in the Genworld GUI. */ @@ -84,37 +84,37 @@ enum class GenworldAverageHeight : uint8_t { }; /** Possible options for the Borders pulldown in the Genworld GUI. */ -enum BorderFlagPresets : uint8_t { - BFP_RANDOM = 0, - BFP_MANUAL, - BFP_INFINITE_WATER, +enum class BorderFlagPresets : uint8_t { + Random = 0, + Manual, + InfiniteWater, }; /** Possible values for the "timekeeping_units" setting. */ -enum TimekeepingUnits : uint8_t { - TKU_CALENDAR = 0, - TKU_WALLCLOCK, +enum class TimekeepingUnits : uint8_t { + Calendar = 0, + Wallclock, }; /** Possible values for "use_relay_service" setting. */ -enum UseRelayService : uint8_t { - URS_NEVER = 0, - URS_ASK, - URS_ALLOW, +enum class UseRelayService : uint8_t { + Never = 0, + Ask, + Allow, }; /** Possible values for "participate_survey" setting. */ -enum ParticipateSurvey : uint8_t { - PS_ASK = 0, - PS_NO, - PS_YES, +enum class ParticipateSurvey : uint8_t { + Ask = 0, + No, + Yes, }; /** Right-click to close window actions. */ -enum RightClickClose : uint8_t { - RCC_NO = 0, - RCC_YES, - RCC_YES_EXCEPT_STICKY, +enum class RightClickClose : uint8_t { + No = 0, + Yes, + YesExceptSticky, }; /** @@ -122,24 +122,24 @@ enum RightClickClose : uint8_t { * * This enumeration defines all possible tree placer algorithm in the game. */ -enum TreePlacer : uint8_t { - TP_NONE, ///< No tree placer algorithm - TP_ORIGINAL, ///< The original algorithm - TP_IMPROVED, ///< A 'improved' algorithm +enum class TreePlacer: uint8_t { + None, ///< No tree placer algorithm + Original, ///< The original algorithm + Improved, ///< A 'improved' algorithm }; /** Possible values for "place_houses" setting. */ -enum PlaceHouses : uint8_t { - PH_FORBIDDEN = 0, - PH_ALLOWED, - PH_ALLOWED_CONSTRUCTED, +enum class PlaceHouses : uint8_t { + Forbidden = 0, + Allowed, + AllowedConstructed, }; /** Possible values for "vehicle_breakdowns" setting. */ -enum VehicleBreakdowns : uint8_t { - VB_NONE = 0, - VB_REDUCED, - VB_NORMAL, +enum class VehicleBreakdowns : uint8_t { + None = 0, + Reduced, + Normal, }; /** Settings related to the difficulty of the game */ @@ -150,12 +150,12 @@ struct DifficultySettings { uint8_t max_no_competitors; ///< the number of competitors (AIs) uint16_t competitors_interval; ///< the interval (in minutes) between adding competitors uint8_t number_towns; ///< the amount of towns - uint8_t industry_density; ///< The industry density. @see IndustryDensity + IndustryDensity industry_density; ///< The industry density. @see IndustryDensity uint32_t max_loan; ///< the maximum initial loan uint8_t initial_interest; ///< amount of interest (to pay over the loan) uint8_t vehicle_costs; ///< amount of money spent on vehicle running cost uint8_t competitor_speed; ///< the speed at which the AI builds - uint8_t vehicle_breakdowns; ///< likelihood of vehicles breaking down + VehicleBreakdowns vehicle_breakdowns; ///< likelihood of vehicles breaking down uint8_t subsidy_multiplier; ///< payment multiplier for subsidized deliveries uint16_t subsidy_duration; ///< duration of subsidies uint8_t construction_cost; ///< how expensive is building @@ -169,19 +169,19 @@ struct DifficultySettings { }; /** Settings relating to viewport/smallmap scrolling. */ -enum ViewportScrollMode : uint8_t { - VSM_VIEWPORT_RMB_FIXED, ///< Viewport moves with mouse movement on holding right mouse button, cursor position is fixed. - VSM_MAP_RMB_FIXED, ///< Map moves with mouse movement on holding right mouse button, cursor position is fixed. - VSM_MAP_RMB, ///< Map moves with mouse movement on holding right mouse button, cursor moves. - VSM_MAP_LMB, ///< Map moves with mouse movement on holding left mouse button, cursor moves. - VSM_END, ///< Number of scroll mode settings. +enum class ViewportScrollMode : uint8_t { + ViewportRMBFixed, ///< Viewport moves with mouse movement on holding right mouse button, cursor position is fixed. + MapRMBFixed, ///< Map moves with mouse movement on holding right mouse button, cursor position is fixed. + MapRMB, ///< Map moves with mouse movement on holding right mouse button, cursor moves. + MapLMB, ///< Map moves with mouse movement on holding left mouse button, cursor moves. + End, ///< Number of scroll mode settings. }; /** Settings related to scroll wheel behavior. */ -enum ScrollWheelScrollingSetting : uint8_t { - SWS_ZOOM_MAP = 0, ///< Scroll wheel zooms the map. - SWS_SCROLL_MAP = 1, ///< Scroll wheel scrolls the map. - SWS_OFF = 2 ///< Scroll wheel has no effect. +enum class ScrollWheelScrolling : uint8_t { + ZoomMap = 0, ///< Scroll wheel zooms the map. + ScrollMap = 1, ///< Scroll wheel scrolls the map. + Off = 2, ///< Scroll wheel has no effect. }; /** Settings related to the GUI and other stuff that is not saved in the savegame. */ @@ -201,7 +201,7 @@ struct GUISettings { bool link_terraform_toolbar; ///< display terraform toolbar when displaying rail, road, water and airport toolbars uint8_t smallmap_land_colour; ///< colour used for land and heightmap at the smallmap uint8_t linkgraph_colours; ///< linkgraph overlay colours - uint8_t scroll_mode; ///< viewport scroll mode + ViewportScrollMode scroll_mode; ///< viewport scroll mode bool smooth_scroll; ///< smooth scroll viewports bool measure_tooltip; ///< show a permanent tooltip when dragging tools uint8_t liveries; ///< options for displaying company liveries, 0=none, 1=self, 2=all @@ -225,7 +225,7 @@ struct GUISettings { uint8_t max_num_autosaves; ///< controls how many autosavegames are made before the game starts to overwrite (names them 0 to max_num_autosaves - 1) bool population_in_label; ///< show the population of a town in its label? uint8_t right_mouse_btn_emulation; ///< should we emulate right mouse clicking? - uint8_t scrollwheel_scrolling; ///< scrolling using the scroll wheel? + ScrollWheelScrolling scrollwheel_scrolling; ///< scrolling using the scroll wheel? uint8_t scrollwheel_multiplier; ///< how much 'wheel' per incoming event from the OS? bool timetable_arrival_departure; ///< show arrivals and departures in vehicle timetables RightClickClose right_click_wnd_close; ///< close window with right click @@ -413,7 +413,7 @@ struct GameCreationSettings { uint8_t desert_coverage; ///< the amount of desert coverage on the map uint8_t heightmap_height; ///< highest mountain for heightmap (towards what it scales) uint8_t tgen_smoothness; ///< how rough is the terrain from 0-3 - uint8_t tree_placer; ///< the tree placer algorithm + TreePlacer tree_placer; ///< the tree placer algorithm uint8_t heightmap_rotation; ///< rotation director for the heightmap uint8_t se_flat_world_height; ///< land height a flat world gets in SE uint8_t town_name; ///< the town name generator used for town names diff --git a/src/smallmap_gui.cpp b/src/smallmap_gui.cpp index d4ad136eae..cdb71ab92f 100644 --- a/src/smallmap_gui.cpp +++ b/src/smallmap_gui.cpp @@ -1860,7 +1860,7 @@ public: void OnMouseWheel(int wheel, WidgetID widget) override { if (widget != WID_SM_MAP) return; - if (_settings_client.gui.scrollwheel_scrolling != SWS_OFF) { + if (_settings_client.gui.scrollwheel_scrolling != ScrollWheelScrolling::Off) { const NWidgetBase *wid = this->GetWidget(WID_SM_MAP); int cursor_x = _cursor.pos.x - this->left - wid->pos_x; int cursor_y = _cursor.pos.y - this->top - wid->pos_y; @@ -1871,7 +1871,7 @@ public: void OnScroll(Point delta) override { - if (_settings_client.gui.scroll_mode == VSM_VIEWPORT_RMB_FIXED || _settings_client.gui.scroll_mode == VSM_MAP_RMB_FIXED) _cursor.fix_at = true; + if (_settings_client.gui.scroll_mode == ViewportScrollMode::ViewportRMBFixed || _settings_client.gui.scroll_mode == ViewportScrollMode::MapRMBFixed) _cursor.fix_at = true; /* While tile is at (delta.x, delta.y)? */ int sub; diff --git a/src/table/settings/difficulty_settings.ini b/src/table/settings/difficulty_settings.ini index e8be630f07..4e4adb5068 100644 --- a/src/table/settings/difficulty_settings.ini +++ b/src/table/settings/difficulty_settings.ini @@ -97,10 +97,9 @@ var = difficulty.industry_density type = SLE_UINT8 from = SLV_97 flags = SettingFlag::GuiDropdown -def = ID_NORMAL -min = 0 -max = ID_END - 1 -interval = 1 +def = IndustryDensity::Normal +min = IndustryDensity::FundedOnly +max = IndustryDensity::Custom str = STR_CONFIG_SETTING_INDUSTRY_DENSITY strhelp = STR_CONFIG_SETTING_INDUSTRY_DENSITY_HELPTEXT strval = STR_FUNDING_ONLY @@ -176,10 +175,9 @@ var = difficulty.vehicle_breakdowns type = SLE_UINT8 from = SLV_97 flags = SettingFlag::GuiDropdown -def = VB_REDUCED -min = VB_NONE -max = VB_NORMAL -interval = 1 +def = VehicleBreakdowns::Reduced +min = VehicleBreakdowns::None +max = VehicleBreakdowns::Normal str = STR_CONFIG_SETTING_VEHICLE_BREAKDOWNS strhelp = STR_CONFIG_SETTING_VEHICLE_BREAKDOWNS_HELPTEXT strval = STR_DISASTER_NONE diff --git a/src/table/settings/economy_settings.ini b/src/table/settings/economy_settings.ini index 9a8013336c..a61466d64f 100644 --- a/src/table/settings/economy_settings.ini +++ b/src/table/settings/economy_settings.ini @@ -9,7 +9,7 @@ [pre-amble] static void TownFoundingChanged(int32_t new_value); -static void ChangeTimekeepingUnits(int32_t new_value); +static void ChangeTimekeepingUnits(); static void ChangeMinutesPerYear(int32_t new_value); static std::tuple GetMinutesPerYearRange(const IntSettingDesc &sd); @@ -87,9 +87,9 @@ cat = SC_BASIC var = economy.place_houses type = SLE_UINT8 flags = SettingFlag::GuiDropdown -def = PH_FORBIDDEN -min = PH_FORBIDDEN -max = PH_ALLOWED_CONSTRUCTED +def = PlaceHouses::Forbidden +min = PlaceHouses::Forbidden +max = PlaceHouses::AllowedConstructed full = _place_houses str = STR_CONFIG_SETTING_HOUSE_PLACER strhelp = STR_CONFIG_SETTING_HOUSE_PLACER_HELPTEXT @@ -322,13 +322,13 @@ cat = SC_BASIC var = economy.timekeeping_units type = SLE_UINT8 flags = SettingFlag::GuiDropdown, SettingFlag::NewgameOnly, SettingFlag::SceneditToo -def = TKU_CALENDAR -min = TKU_CALENDAR -max = TKU_WALLCLOCK +def = TimekeepingUnits::Calendar +min = TimekeepingUnits::Calendar +max = TimekeepingUnits::Wallclock str = STR_CONFIG_SETTING_TIMEKEEPING_UNITS strval = STR_CONFIG_SETTING_TIMEKEEPING_UNITS_CALENDAR strhelp = STR_CONFIG_SETTING_TIMEKEEPING_UNITS_HELPTEXT -post_cb = ChangeTimekeepingUnits +post_cb = [](auto) { ChangeTimekeepingUnits(); } cat = SC_BASIC [SDT_VAR] @@ -342,7 +342,7 @@ interval = 1 str = STR_CONFIG_SETTING_MINUTES_PER_YEAR strhelp = STR_CONFIG_SETTING_MINUTES_PER_YEAR_HELPTEXT strval = STR_CONFIG_SETTING_MINUTES_PER_YEAR_VALUE -pre_cb = [](auto) { return _game_mode == GM_MENU || _settings_game.economy.timekeeping_units == 1; } +pre_cb = [](auto) { return _game_mode == GM_MENU || _settings_game.economy.timekeeping_units == TimekeepingUnits::Wallclock; } post_cb = ChangeMinutesPerYear range_cb = GetMinutesPerYearRange cat = SC_BASIC diff --git a/src/table/settings/gui_settings.ini b/src/table/settings/gui_settings.ini index 10e3e383de..3ebb955b64 100644 --- a/src/table/settings/gui_settings.ini +++ b/src/table/settings/gui_settings.ini @@ -106,9 +106,9 @@ ifdef = UNIX var = gui.scroll_mode type = SLE_UINT8 flags = SettingFlag::NotInSave, SettingFlag::NoNetworkSync, SettingFlag::GuiDropdown -def = VSM_MAP_RMB -min = VSM_VIEWPORT_RMB_FIXED -max = VSM_MAP_LMB +def = ViewportScrollMode::MapRMB +min = ViewportScrollMode::ViewportRMBFixed +max = ViewportScrollMode::MapLMB str = STR_CONFIG_SETTING_SCROLLMODE strhelp = STR_CONFIG_SETTING_SCROLLMODE_HELPTEXT strval = STR_CONFIG_SETTING_SCROLLMODE_DEFAULT @@ -119,9 +119,9 @@ ifndef = UNIX var = gui.scroll_mode type = SLE_UINT8 flags = SettingFlag::NotInSave, SettingFlag::NoNetworkSync, SettingFlag::GuiDropdown -def = VSM_VIEWPORT_RMB_FIXED -min = VSM_VIEWPORT_RMB_FIXED -max = VSM_MAP_LMB +def = ViewportScrollMode::ViewportRMBFixed +min = ViewportScrollMode::ViewportRMBFixed +max = ViewportScrollMode::MapLMB str = STR_CONFIG_SETTING_SCROLLMODE strhelp = STR_CONFIG_SETTING_SCROLLMODE_HELPTEXT strval = STR_CONFIG_SETTING_SCROLLMODE_DEFAULT @@ -138,9 +138,9 @@ strhelp = STR_CONFIG_SETTING_SMOOTH_SCROLLING_HELPTEXT var = gui.right_click_wnd_close type = SLE_UINT8 flags = SettingFlag::NotInSave, SettingFlag::NoNetworkSync, SettingFlag::GuiDropdown -def = RCC_NO -min = RCC_NO -max = RCC_YES_EXCEPT_STICKY +def = RightClickClose::No +min = RightClickClose::No +max = RightClickClose::YesExceptSticky full = _right_click_close str = STR_CONFIG_SETTING_RIGHT_MOUSE_WND_CLOSE strhelp = STR_CONFIG_SETTING_RIGHT_MOUSE_WND_CLOSE_HELPTEXT @@ -396,9 +396,9 @@ cat = SC_BASIC var = gui.scrollwheel_scrolling type = SLE_UINT8 flags = SettingFlag::NotInSave, SettingFlag::NoNetworkSync, SettingFlag::GuiDropdown -def = SWS_ZOOM_MAP -min = SWS_ZOOM_MAP -max = SWS_OFF +def = ScrollWheelScrolling::ZoomMap +min = ScrollWheelScrolling::ZoomMap +max = ScrollWheelScrolling::Off str = STR_CONFIG_SETTING_SCROLLWHEEL_SCROLLING strhelp = STR_CONFIG_SETTING_SCROLLWHEEL_SCROLLING_HELPTEXT strval = STR_CONFIG_SETTING_SCROLLWHEEL_ZOOM diff --git a/src/table/settings/network_private_settings.ini b/src/table/settings/network_private_settings.ini index 969bd62010..bff14782a2 100644 --- a/src/table/settings/network_private_settings.ini +++ b/src/table/settings/network_private_settings.ini @@ -81,9 +81,9 @@ cat = SC_EXPERT var = network.use_relay_service type = SLE_UINT8 flags = SettingFlag::GuiDropdown, SettingFlag::NotInSave, SettingFlag::NoNetworkSync -def = URS_ASK -min = URS_NO -max = URS_ALLOW +def = UseRelayService::Ask +min = UseRelayService::Never +max = UseRelayService::Allow full = _use_relay_service str = STR_CONFIG_SETTING_USE_RELAY_SERVICE strhelp = STR_CONFIG_SETTING_USE_RELAY_SERVICE_HELPTEXT @@ -94,7 +94,7 @@ cat = SC_BASIC var = network.participate_survey type = SLE_UINT8 flags = SettingFlag::NotInSave, SettingFlag::NoNetworkSync -def = PS_ASK -min = PS_ASK -max = PS_YES +def = ParticipateSurvey::Ask +min = ParticipateSurvey::Ask +max = ParticipateSurvey::Yes full = _participate_survey diff --git a/src/table/settings/world_settings.ini b/src/table/settings/world_settings.ini index 1cbacba67c..7a1276eef2 100644 --- a/src/table/settings/world_settings.ini +++ b/src/table/settings/world_settings.ini @@ -283,9 +283,9 @@ max = 16 [SDT_VAR] var = game_creation.water_border_presets type = SLE_UINT8 -def = BFP_RANDOM -min = BFP_RANDOM -max = BFP_INFINITE_WATER +def = BorderFlagPresets::Random +min = BorderFlagPresets::Random +max = BorderFlagPresets::InfiniteWater [SDT_VAR] var = game_creation.custom_town_number diff --git a/src/timer/timer_game_economy.cpp b/src/timer/timer_game_economy.cpp index 0d008b3427..0284e22a35 100644 --- a/src/timer/timer_game_economy.cpp +++ b/src/timer/timer_game_economy.cpp @@ -94,9 +94,9 @@ uint TimerGameEconomy::days_since_last_month = {}; */ /* static */ bool TimerGameEconomy::UsingWallclockUnits(bool newgame) { - if (newgame) return (_settings_newgame.economy.timekeeping_units == TKU_WALLCLOCK); + if (newgame) return (_settings_newgame.economy.timekeeping_units == TimekeepingUnits::Wallclock); - return (_settings_game.economy.timekeeping_units == TKU_WALLCLOCK); + return (_settings_game.economy.timekeeping_units == TimekeepingUnits::Wallclock); } template <> diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp index 7f8c7200f3..d66b323eb1 100644 --- a/src/toolbar_gui.cpp +++ b/src/toolbar_gui.cpp @@ -482,7 +482,7 @@ static CallBackFunction ToolbarTownClick(Window *w) DropDownList list; list.push_back(MakeDropDownListStringItem(STR_TOWN_MENU_TOWN_DIRECTORY, TME_SHOW_DIRECTORY)); if (_settings_game.economy.found_town != TF_FORBIDDEN) list.push_back(MakeDropDownListStringItem(STR_TOWN_MENU_FOUND_TOWN, TME_SHOW_FOUND_TOWN)); - if (_settings_game.economy.place_houses != PH_FORBIDDEN) list.push_back(MakeDropDownListStringItem(STR_SCENEDIT_TOWN_MENU_PACE_HOUSE, TME_SHOW_PLACE_HOUSES)); + if (_settings_game.economy.place_houses != PlaceHouses::Forbidden) list.push_back(MakeDropDownListStringItem(STR_SCENEDIT_TOWN_MENU_PACE_HOUSE, TME_SHOW_PLACE_HOUSES)); PopupMainToolbarMenu(w, WID_TN_TOWNS, std::move(list), 0); @@ -503,7 +503,7 @@ static CallBackFunction MenuClickTown(int index) if (_settings_game.economy.found_town != TF_FORBIDDEN) ShowFoundTownWindow(); break; case TME_SHOW_PLACE_HOUSES: // Setting could be changed when the dropdown was open - if (_settings_game.economy.place_houses != PH_FORBIDDEN) ShowBuildHousePicker(nullptr); + if (_settings_game.economy.place_houses != PlaceHouses::Forbidden) ShowBuildHousePicker(nullptr); break; } return CBF_NONE; diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp index fd4f03ac39..c4970d81b9 100644 --- a/src/town_cmd.cpp +++ b/src/town_cmd.cpp @@ -2946,7 +2946,7 @@ static bool TryBuildTownHouse(Town *t, TileIndex tile, TownExpandModes modes) */ CommandCost CmdPlaceHouse(DoCommandFlags flags, TileIndex tile, HouseID house, bool is_protected, bool replace) { - if (_game_mode != GM_EDITOR && _settings_game.economy.place_houses == PH_FORBIDDEN) return CMD_ERROR; + if (_game_mode != GM_EDITOR && _settings_game.economy.place_houses == PlaceHouses::Forbidden) return CMD_ERROR; if (Town::GetNumItems() == 0) return CommandCost(STR_ERROR_MUST_FOUND_TOWN_FIRST); @@ -2993,7 +2993,7 @@ CommandCost CmdPlaceHouse(DoCommandFlags flags, TileIndex tile, HouseID house, b } Town *t = ClosestTownFromTile(tile, UINT_MAX); - bool house_completed = _settings_game.economy.place_houses == PH_ALLOWED_CONSTRUCTED; + bool house_completed = _settings_game.economy.place_houses == PlaceHouses::AllowedConstructed; BuildTownHouse(t, tile, hs, house, Random(), house_completed, is_protected); } @@ -3015,7 +3015,7 @@ CommandCost CmdPlaceHouseArea(DoCommandFlags flags, TileIndex tile, TileIndex st { if (start_tile >= Map::Size()) return CMD_ERROR; - if (_game_mode != GM_EDITOR && _settings_game.economy.place_houses == PH_FORBIDDEN) return CMD_ERROR; + if (_game_mode != GM_EDITOR && _settings_game.economy.place_houses == PlaceHouses::Forbidden) return CMD_ERROR; if (Town::GetNumItems() == 0) return CommandCost(STR_ERROR_MUST_FOUND_TOWN_FIRST); diff --git a/src/town_gui.cpp b/src/town_gui.cpp index 70a1e42e9a..0e36544d62 100644 --- a/src/town_gui.cpp +++ b/src/town_gui.cpp @@ -580,7 +580,7 @@ public: void OnMouseWheel(int wheel, WidgetID widget) override { if (widget != WID_TV_VIEWPORT) return; - if (_settings_client.gui.scrollwheel_scrolling != SWS_OFF) { + if (_settings_client.gui.scrollwheel_scrolling != ScrollWheelScrolling::Off) { DoZoomInOutWindow(wheel < 0 ? ZOOM_IN : ZOOM_OUT, this); } } diff --git a/src/tree_cmd.cpp b/src/tree_cmd.cpp index 1123177a04..29b710ebed 100644 --- a/src/tree_cmd.cpp +++ b/src/tree_cmd.cpp @@ -371,7 +371,7 @@ void PlaceTreesRandomly() if (CanPlantTreesOnTile(tile, true)) { PlaceTree(tile, r); - if (_settings_game.game_creation.tree_placer != TP_IMPROVED) continue; + if (_settings_game.game_creation.tree_placer != TreePlacer::Improved) continue; /* Place a number of trees based on the tile height. * This gives a cool effect of multiple trees close together. @@ -470,11 +470,11 @@ void GenerateTrees() { uint i, total; - if (_settings_game.game_creation.tree_placer == TP_NONE) return; + if (_settings_game.game_creation.tree_placer == TreePlacer::None) return; switch (_settings_game.game_creation.tree_placer) { - case TP_ORIGINAL: i = _settings_game.game_creation.landscape == LandscapeType::Arctic ? 15 : 6; break; - case TP_IMPROVED: i = _settings_game.game_creation.landscape == LandscapeType::Arctic ? 4 : 2; break; + case TreePlacer::Original: i = _settings_game.game_creation.landscape == LandscapeType::Arctic ? 15 : 6; break; + case TreePlacer::Improved: i = _settings_game.game_creation.landscape == LandscapeType::Arctic ? 4 : 2; break; default: NOT_REACHED(); } diff --git a/src/vehicle.cpp b/src/vehicle.cpp index b572b9f501..64b90dc6f1 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -187,7 +187,7 @@ void VehicleServiceInDepot(Vehicle *v) v->reliability = v->GetEngine()->reliability; /* Prevent vehicles from breaking down directly after exiting the depot. */ v->breakdown_chance /= 4; - if (_settings_game.difficulty.vehicle_breakdowns == VB_REDUCED) v->breakdown_chance = 0; // on reduced breakdown + if (_settings_game.difficulty.vehicle_breakdowns == VehicleBreakdowns::Reduced) v->breakdown_chance = 0; // on reduced breakdown v = v->Next(); } while (v != nullptr && v->HasEngineType()); } @@ -222,7 +222,7 @@ bool Vehicle::NeedsServicing() const /* If we're servicing anyway, because we have not disabled servicing when * there are no breakdowns or we are playing with breakdowns, bail out. */ if (!_settings_game.order.no_servicing_if_no_breakdowns || - _settings_game.difficulty.vehicle_breakdowns != VB_NONE) { + _settings_game.difficulty.vehicle_breakdowns != VehicleBreakdowns::None) { return true; } @@ -1295,10 +1295,10 @@ void CheckVehicleBreakdown(Vehicle *v) if (_game_mode == GM_MENU) return; /* If both breakdowns and automatic servicing are disabled, we don't decrease reliability or break down. */ - if (_settings_game.difficulty.vehicle_breakdowns == VB_NONE && _settings_game.order.no_servicing_if_no_breakdowns) return; + if (_settings_game.difficulty.vehicle_breakdowns == VehicleBreakdowns::None && _settings_game.order.no_servicing_if_no_breakdowns) return; /* With Reduced breakdowns, vehicles (un)loading at stations don't lose reliability. */ - if (_settings_game.difficulty.vehicle_breakdowns == VB_REDUCED && v->current_order.IsType(OT_LOADING)) return; + if (_settings_game.difficulty.vehicle_breakdowns == VehicleBreakdowns::Reduced && v->current_order.IsType(OT_LOADING)) return; /* Decrease reliability. */ int rel, rel_old; @@ -1307,7 +1307,7 @@ void CheckVehicleBreakdown(Vehicle *v) /* Some vehicles lose reliability but won't break down. */ /* Breakdowns are disabled. */ - if (_settings_game.difficulty.vehicle_breakdowns == VB_NONE) return; + if (_settings_game.difficulty.vehicle_breakdowns == VehicleBreakdowns::None) return; /* The vehicle is already broken down. */ if (v->breakdown_ctr != 0) return; /* The vehicle is stopped or going very slow. */ @@ -1329,7 +1329,7 @@ void CheckVehicleBreakdown(Vehicle *v) if (v->type == VEH_SHIP) rel += 0x6666; /* Reduce the chance if the player has chosen the Reduced setting. */ - if (_settings_game.difficulty.vehicle_breakdowns == VB_REDUCED) rel += 0x6666; + if (_settings_game.difficulty.vehicle_breakdowns == VehicleBreakdowns::Reduced) rel += 0x6666; /* Check the random chance and inform the vehicle of the result. */ if (_breakdown_chance[ClampTo(rel) >> 10] <= v->breakdown_chance) { diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp index 100328c4a2..7324a6e2f9 100644 --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -3345,7 +3345,7 @@ public: void OnMouseWheel(int wheel, WidgetID widget) override { if (widget != WID_VV_VIEWPORT) return; - if (_settings_client.gui.scrollwheel_scrolling != SWS_OFF) { + if (_settings_client.gui.scrollwheel_scrolling != ScrollWheelScrolling::Off) { DoZoomInOutWindow(wheel < 0 ? ZOOM_IN : ZOOM_OUT, this); } } diff --git a/src/viewport_gui.cpp b/src/viewport_gui.cpp index 25c99eadee..20e447c497 100644 --- a/src/viewport_gui.cpp +++ b/src/viewport_gui.cpp @@ -127,7 +127,7 @@ public: void OnMouseWheel(int wheel, WidgetID widget) override { if (widget != WID_EV_VIEWPORT) return; - if (_settings_client.gui.scrollwheel_scrolling != SWS_OFF) { + if (_settings_client.gui.scrollwheel_scrolling != ScrollWheelScrolling::Off) { ZoomInOrOutToCursorWindow(wheel < 0, this); } } diff --git a/src/window.cpp b/src/window.cpp index 86a7739f7c..ddd04915fa 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -773,9 +773,9 @@ static void DispatchRightClickEvent(Window *w, int x, int y) } /* Right-click close is enabled and there is a closebox. */ - if (_settings_client.gui.right_click_wnd_close == RCC_YES && !w->window_desc.flags.Test(WindowDefaultFlag::NoClose)) { + if (_settings_client.gui.right_click_wnd_close == RightClickClose::Yes && !w->window_desc.flags.Test(WindowDefaultFlag::NoClose)) { w->Close(); - } else if (_settings_client.gui.right_click_wnd_close == RCC_YES_EXCEPT_STICKY && !w->flags.Test(WindowFlag::Sticky) && !w->window_desc.flags.Test(WindowDefaultFlag::NoClose)) { + } else if (_settings_client.gui.right_click_wnd_close == RightClickClose::YesExceptSticky && !w->flags.Test(WindowFlag::Sticky) && !w->window_desc.flags.Test(WindowDefaultFlag::NoClose)) { /* Right-click close is enabled, but excluding sticky windows. */ w->Close(); } else if (_settings_client.gui.hover_delay_ms == 0 && !w->OnTooltip(pt, wid->GetIndex(), TCC_RIGHT_CLICK) && wid->GetToolTip() != STR_NULL) { @@ -2438,7 +2438,7 @@ static EventState HandleActiveWidget() */ static EventState HandleViewportScroll() { - bool scrollwheel_scrolling = _settings_client.gui.scrollwheel_scrolling == SWS_SCROLL_MAP && _cursor.wheel_moved; + bool scrollwheel_scrolling = _settings_client.gui.scrollwheel_scrolling == ScrollWheelScrolling::ScrollMap && _cursor.wheel_moved; if (!_scrolling_viewport) return ES_NOT_HANDLED; @@ -2447,7 +2447,7 @@ static EventState HandleViewportScroll() * outside of the window and should not left-mouse scroll anymore. */ if (_last_scroll_window == nullptr) _last_scroll_window = FindWindowFromPt(_cursor.pos.x, _cursor.pos.y); - if (_last_scroll_window == nullptr || !((_settings_client.gui.scroll_mode != VSM_MAP_LMB && _right_button_down) || scrollwheel_scrolling || (_settings_client.gui.scroll_mode == VSM_MAP_LMB && _left_button_down))) { + if (_last_scroll_window == nullptr || !((_settings_client.gui.scroll_mode != ViewportScrollMode::MapLMB && _right_button_down) || scrollwheel_scrolling || (_settings_client.gui.scroll_mode == ViewportScrollMode::MapLMB && _left_button_down))) { _cursor.fix_at = false; _scrolling_viewport = false; _last_scroll_window = nullptr; @@ -2472,7 +2472,7 @@ static EventState HandleViewportScroll() _cursor.v_wheel = std::modf(_cursor.v_wheel, &temp); _cursor.h_wheel = std::modf(_cursor.h_wheel, &temp); } else { - if (_settings_client.gui.scroll_mode != VSM_VIEWPORT_RMB_FIXED) { + if (_settings_client.gui.scroll_mode != ViewportScrollMode::ViewportRMBFixed) { delta.x = -_cursor.delta.x; delta.y = -_cursor.delta.y; } else { @@ -2871,7 +2871,7 @@ static void MouseLoop(MouseClick click, int mousewheel) HandleMouseOver(); - bool scrollwheel_scrolling = _settings_client.gui.scrollwheel_scrolling == SWS_SCROLL_MAP && _cursor.wheel_moved; + bool scrollwheel_scrolling = _settings_client.gui.scrollwheel_scrolling == ScrollWheelScrolling::ScrollMap && _cursor.wheel_moved; if (click == MC_NONE && mousewheel == 0 && !scrollwheel_scrolling) return; int x = _cursor.pos.x; @@ -2909,7 +2909,7 @@ static void MouseLoop(MouseClick click, int mousewheel) case MC_LEFT: if (HandleViewportClicked(*vp, x, y)) return; if (!w->flags.Test(WindowFlag::DisableVpScroll) && - _settings_client.gui.scroll_mode == VSM_MAP_LMB) { + _settings_client.gui.scroll_mode == ViewportScrollMode::MapLMB) { _scrolling_viewport = true; _cursor.fix_at = false; return; @@ -2918,10 +2918,10 @@ static void MouseLoop(MouseClick click, int mousewheel) case MC_RIGHT: if (!w->flags.Test(WindowFlag::DisableVpScroll) && - _settings_client.gui.scroll_mode != VSM_MAP_LMB) { + _settings_client.gui.scroll_mode != ViewportScrollMode::MapLMB) { _scrolling_viewport = true; - _cursor.fix_at = (_settings_client.gui.scroll_mode == VSM_VIEWPORT_RMB_FIXED || - _settings_client.gui.scroll_mode == VSM_MAP_RMB_FIXED); + _cursor.fix_at = (_settings_client.gui.scroll_mode == ViewportScrollMode::ViewportRMBFixed || + _settings_client.gui.scroll_mode == ViewportScrollMode::MapRMBFixed); DispatchRightClickEvent(w, x - w->left, y - w->top); return; }