From 0d5b3ebd7fdbaaf42251d393154e8832199e0940 Mon Sep 17 00:00:00 2001 From: frosch Date: Sun, 27 Apr 2025 17:09:01 +0200 Subject: [PATCH] Codechange: Declare all IntervalTimers const, which can be const. --- src/airport_gui.cpp | 2 +- src/cheat_gui.cpp | 2 +- src/company_cmd.cpp | 2 +- src/company_gui.cpp | 8 ++++---- src/console_cmds.cpp | 2 +- src/console_gui.cpp | 2 +- src/currency.cpp | 2 +- src/disaster_vehicle.cpp | 2 +- src/dock_gui.cpp | 2 +- src/dropdown.cpp | 2 +- src/economy.cpp | 4 ++-- src/engine.cpp | 4 ++-- src/framerate_gui.cpp | 4 ++-- src/graph_gui.cpp | 2 +- src/highscore_gui.cpp | 2 +- src/industry_cmd.cpp | 4 ++-- src/industry_gui.cpp | 4 ++-- src/main_gui.cpp | 2 +- src/misc_gui.cpp | 2 +- src/network/network_chat_gui.cpp | 2 +- src/network/network_gui.cpp | 2 +- src/network/network_server.cpp | 12 ++++++------ src/news_gui.cpp | 2 +- src/picker_gui.h | 4 ++-- src/rail_gui.cpp | 2 +- src/signs_gui.cpp | 2 +- src/smallmap_gui.cpp | 4 ++-- src/station_cmd.cpp | 2 +- src/statusbar_gui.cpp | 4 ++-- src/subsidy.cpp | 2 +- src/texteff.cpp | 2 +- src/timetable_gui.cpp | 2 +- src/toolbar_gui.cpp | 4 ++-- src/town_cmd.cpp | 4 ++-- src/town_gui.cpp | 8 ++++---- src/vehicle.cpp | 2 +- src/window.cpp | 6 +++--- 37 files changed, 60 insertions(+), 60 deletions(-) diff --git a/src/airport_gui.cpp b/src/airport_gui.cpp index 5b58df17ca..9e42f241c2 100644 --- a/src/airport_gui.cpp +++ b/src/airport_gui.cpp @@ -575,7 +575,7 @@ public: CheckRedrawStationCoverage(this); } - IntervalTimer yearly_interval = {{TimerGameCalendar::YEAR, TimerGameCalendar::Priority::NONE}, [this](auto) { + const IntervalTimer yearly_interval = {{TimerGameCalendar::YEAR, TimerGameCalendar::Priority::NONE}, [this](auto) { this->InvalidateData(); }}; }; diff --git a/src/cheat_gui.cpp b/src/cheat_gui.cpp index 0b2c502d8a..9c9745d882 100644 --- a/src/cheat_gui.cpp +++ b/src/cheat_gui.cpp @@ -635,7 +635,7 @@ struct CheatWindow : Window { this->SetDirty(); } - IntervalTimer daily_interval = {{TimerGameCalendar::MONTH, TimerGameCalendar::Priority::NONE}, [this](auto) { + const IntervalTimer daily_interval = {{TimerGameCalendar::MONTH, TimerGameCalendar::Priority::NONE}, [this](auto) { this->SetDirty(); }}; }; diff --git a/src/company_cmd.cpp b/src/company_cmd.cpp index d4146c5189..f5bb4d9433 100644 --- a/src/company_cmd.cpp +++ b/src/company_cmd.cpp @@ -812,7 +812,7 @@ void OnTick_Companies() * A year has passed, update the economic data of all companies, and perhaps show the * financial overview window of the local company. */ -static IntervalTimer _economy_companies_yearly({TimerGameEconomy::YEAR, TimerGameEconomy::Priority::COMPANY}, [](auto) +static const IntervalTimer _economy_companies_yearly({TimerGameEconomy::YEAR, TimerGameEconomy::Priority::COMPANY}, [](auto) { /* Copy statistics */ for (Company *c : Company::Iterate()) { diff --git a/src/company_gui.cpp b/src/company_gui.cpp index 2fc4e69a86..301f80019c 100644 --- a/src/company_gui.cpp +++ b/src/company_gui.cpp @@ -540,7 +540,7 @@ struct CompanyFinancesWindow : Window { * Check on a regular interval if the maximum amount of money has changed. * If it has, rescale the window to fit the new amount. */ - IntervalTimer rescale_interval = {std::chrono::seconds(3), [this](auto) { + const IntervalTimer rescale_interval = {std::chrono::seconds(3), [this](auto) { const Company *c = Company::Get(this->window_number); if (c->money > CompanyFinancesWindow::max_money) { CompanyFinancesWindow::max_money = std::max(c->money * 2, CompanyFinancesWindow::max_money * 4); @@ -1991,7 +1991,7 @@ struct CompanyInfrastructureWindow : Window } } - IntervalTimer redraw_interval = {std::chrono::seconds(1), [this](auto) { + const IntervalTimer redraw_interval = {std::chrono::seconds(1), [this](auto) { this->UpdateInfrastructureList(); this->SetWidgetDirty(WID_CI_LIST); }}; @@ -2433,7 +2433,7 @@ struct CompanyWindow : Window } /** Redraw the window on a regular interval. */ - IntervalTimer redraw_interval = {std::chrono::seconds(3), [this](auto) { + const IntervalTimer redraw_interval = {std::chrono::seconds(3), [this](auto) { this->SetDirty(); }}; @@ -2579,7 +2579,7 @@ struct BuyCompanyWindow : Window { /** * Check on a regular interval if the company value has changed. */ - IntervalTimer rescale_interval = {std::chrono::seconds(3), [this](auto) { + const IntervalTimer rescale_interval = {std::chrono::seconds(3), [this](auto) { /* Value can't change when in bankruptcy. */ if (!this->hostile_takeover) return; diff --git a/src/console_cmds.cpp b/src/console_cmds.cpp index a174ee5247..0d6d4b1a94 100644 --- a/src/console_cmds.cpp +++ b/src/console_cmds.cpp @@ -57,7 +57,7 @@ static uint _script_current_depth; ///< Depth of scripts running (used to abort static std::string _scheduled_monthly_script; ///< Script scheduled to execute by the 'schedule' console command (empty if no script is scheduled). /** Timer that runs every month of game time for the 'schedule' console command. */ -static IntervalTimer _scheduled_monthly_timer = {{TimerGameCalendar::MONTH, TimerGameCalendar::Priority::NONE}, [](auto) { +static const IntervalTimer _scheduled_monthly_timer = {{TimerGameCalendar::MONTH, TimerGameCalendar::Priority::NONE}, [](auto) { if (_scheduled_monthly_script.empty()) { return; } diff --git a/src/console_gui.cpp b/src/console_gui.cpp index ad670390b1..def783bbb7 100644 --- a/src/console_gui.cpp +++ b/src/console_gui.cpp @@ -220,7 +220,7 @@ struct IConsoleWindow : Window } /** Check on a regular interval if the console buffer needs truncating. */ - IntervalTimer truncate_interval = {std::chrono::seconds(3), [this](auto) { + const IntervalTimer truncate_interval = {std::chrono::seconds(3), [this](auto) { assert(this->height >= 0 && this->line_height > 0); size_t visible_lines = static_cast(this->height / this->line_height); diff --git a/src/currency.cpp b/src/currency.cpp index 1e8389c2c4..a839ab83c1 100644 --- a/src/currency.cpp +++ b/src/currency.cpp @@ -143,7 +143,7 @@ uint64_t GetMaskOfAllowedCurrencies() /** * Verify if the currency chosen by the user is about to be converted to Euro */ -static IntervalTimer _check_switch_to_euro({TimerGameCalendar::YEAR, TimerGameCalendar::Priority::NONE}, [](auto) +static const IntervalTimer _check_switch_to_euro({TimerGameCalendar::YEAR, TimerGameCalendar::Priority::NONE}, [](auto) { if (_currency_specs[_settings_game.locale.currency].to_euro != CF_NOEURO && _currency_specs[_settings_game.locale.currency].to_euro != CF_ISEURO && diff --git a/src/disaster_vehicle.cpp b/src/disaster_vehicle.cpp index e6b7635f0f..0b279b6059 100644 --- a/src/disaster_vehicle.cpp +++ b/src/disaster_vehicle.cpp @@ -940,7 +940,7 @@ static void ResetDisasterDelay() _disaster_delay = GB(Random(), 0, 9) + 730; } -static IntervalTimer _economy_disaster_daily({TimerGameEconomy::DAY, TimerGameEconomy::Priority::DISASTER}, [](auto) +static const IntervalTimer _economy_disaster_daily({TimerGameEconomy::DAY, TimerGameEconomy::Priority::DISASTER}, [](auto) { if (--_disaster_delay != 0) return; diff --git a/src/dock_gui.cpp b/src/dock_gui.cpp index 2a2528e082..fe9e13bbdc 100644 --- a/src/dock_gui.cpp +++ b/src/dock_gui.cpp @@ -481,7 +481,7 @@ public: CheckRedrawStationCoverage(this); } - IntervalTimer yearly_interval = {{TimerGameCalendar::YEAR, TimerGameCalendar::Priority::NONE}, [this](auto) { + const IntervalTimer yearly_interval = {{TimerGameCalendar::YEAR, TimerGameCalendar::Priority::NONE}, [this](auto) { this->InvalidateData(); }}; }; diff --git a/src/dropdown.cpp b/src/dropdown.cpp index 27f41572c5..d2f7785b24 100644 --- a/src/dropdown.cpp +++ b/src/dropdown.cpp @@ -293,7 +293,7 @@ struct DropdownWindow : Window { } /** Rate limit how fast scrolling happens. */ - IntervalTimer scroll_interval = {std::chrono::milliseconds(30), [this](auto) { + const IntervalTimer scroll_interval = {std::chrono::milliseconds(30), [this](auto) { if (this->scrolling == 0) return; if (this->vscroll->UpdatePosition(this->scrolling)) this->SetDirty(); diff --git a/src/economy.cpp b/src/economy.cpp index 23473a128c..babfe3801f 100644 --- a/src/economy.cpp +++ b/src/economy.cpp @@ -1969,7 +1969,7 @@ void LoadUnloadStation(Station *st) /** * Every calendar month update of inflation. */ -static IntervalTimer _calendar_inflation_monthly({TimerGameCalendar::MONTH, TimerGameCalendar::Priority::COMPANY}, [](auto) +static const IntervalTimer _calendar_inflation_monthly({TimerGameCalendar::MONTH, TimerGameCalendar::Priority::COMPANY}, [](auto) { if (_settings_game.economy.inflation) { AddInflation(); @@ -1980,7 +1980,7 @@ static IntervalTimer _calendar_inflation_monthly({TimerGameCa /** * Every economy month update of company economic data, plus economy fluctuations. */ -static IntervalTimer _economy_companies_monthly({ TimerGameEconomy::MONTH, TimerGameEconomy::Priority::COMPANY }, [](auto) +static const IntervalTimer _economy_companies_monthly({ TimerGameEconomy::MONTH, TimerGameEconomy::Priority::COMPANY }, [](auto) { CompaniesGenStatistics(); CompaniesPayInterest(); diff --git a/src/engine.cpp b/src/engine.cpp index 102a284c63..37566df260 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -959,7 +959,7 @@ static bool IsVehicleTypeDisabled(VehicleType type, bool ai) } /** Daily check to offer an exclusive engine preview to the companies. */ -static IntervalTimer _calendar_engines_daily({TimerGameCalendar::DAY, TimerGameCalendar::Priority::ENGINE}, [](auto) +static const IntervalTimer _calendar_engines_daily({TimerGameCalendar::DAY, TimerGameCalendar::Priority::ENGINE}, [](auto) { for (Company *c : Company::Iterate()) { c->avail_railtypes = AddDateIntroducedRailTypes(c->avail_railtypes, TimerGameCalendar::date); @@ -1192,7 +1192,7 @@ void CalendarEnginesMonthlyLoop() } } -static IntervalTimer _calendar_engines_monthly({TimerGameCalendar::MONTH, TimerGameCalendar::Priority::ENGINE}, [](auto) +static const IntervalTimer _calendar_engines_monthly({TimerGameCalendar::MONTH, TimerGameCalendar::Priority::ENGINE}, [](auto) { CalendarEnginesMonthlyLoop(); }); diff --git a/src/framerate_gui.cpp b/src/framerate_gui.cpp index 9850252f5e..b63e6822ea 100644 --- a/src/framerate_gui.cpp +++ b/src/framerate_gui.cpp @@ -457,7 +457,7 @@ struct FramerateWindow : Window { } /** Update the window on a regular interval. */ - IntervalTimer update_interval = {std::chrono::milliseconds(100), [this](auto) { + const IntervalTimer update_interval = {std::chrono::milliseconds(100), [this](auto) { this->UpdateData(); this->SetDirty(); }}; @@ -838,7 +838,7 @@ struct FrametimeGraphWindow : Window { } /** Update the scaling on a regular interval. */ - IntervalTimer update_interval = {std::chrono::milliseconds(500), [this](auto) { + const IntervalTimer update_interval = {std::chrono::milliseconds(500), [this](auto) { this->UpdateScale(); }}; diff --git a/src/graph_gui.cpp b/src/graph_gui.cpp index cf3bf7d7de..edbeb7809e 100644 --- a/src/graph_gui.cpp +++ b/src/graph_gui.cpp @@ -1212,7 +1212,7 @@ struct PaymentRatesGraphWindow : BaseGraphWindow { } /** Update the payment rates on a regular interval. */ - IntervalTimer update_payment_interval = {std::chrono::seconds(3), [this](auto) { + const IntervalTimer update_payment_interval = {std::chrono::seconds(3), [this](auto) { this->UpdatePaymentRates(); }}; diff --git a/src/highscore_gui.cpp b/src/highscore_gui.cpp index be1f5bb760..798e1ec61a 100644 --- a/src/highscore_gui.cpp +++ b/src/highscore_gui.cpp @@ -252,7 +252,7 @@ void ShowEndGameChart() new EndGameWindow(_endgame_desc); } -static IntervalTimer _check_end_game({TimerGameCalendar::YEAR, TimerGameCalendar::Priority::NONE}, [](auto) +static const IntervalTimer _check_end_game({TimerGameCalendar::YEAR, TimerGameCalendar::Priority::NONE}, [](auto) { /* 0 = never */ if (_settings_game.game_creation.ending_year == 0) return; diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp index 771408c3d1..1c6f24fbb1 100644 --- a/src/industry_cmd.cpp +++ b/src/industry_cmd.cpp @@ -3001,7 +3001,7 @@ static void ChangeIndustryProduction(Industry *i, bool monthly) * For small maps, it implies that less than one change per month is required, while on bigger maps, * it would be way more. The daily loop handles those changes. */ -static IntervalTimer _economy_industries_daily({TimerGameEconomy::DAY, TimerGameEconomy::Priority::INDUSTRY}, [](auto) +static const IntervalTimer _economy_industries_daily({TimerGameEconomy::DAY, TimerGameEconomy::Priority::INDUSTRY}, [](auto) { _economy.industry_daily_change_counter += _economy.industry_daily_increment; @@ -3043,7 +3043,7 @@ static IntervalTimer _economy_industries_daily({TimerGameEcono InvalidateWindowData(WC_INDUSTRY_DIRECTORY, 0, IDIWD_PRODUCTION_CHANGE); }); -static IntervalTimer _economy_industries_monthly({TimerGameEconomy::MONTH, TimerGameEconomy::Priority::INDUSTRY}, [](auto) +static const IntervalTimer _economy_industries_monthly({TimerGameEconomy::MONTH, TimerGameEconomy::Priority::INDUSTRY}, [](auto) { Backup cur_company(_current_company, OWNER_NONE); diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp index 2af39379fe..1314d76202 100644 --- a/src/industry_gui.cpp +++ b/src/industry_gui.cpp @@ -737,7 +737,7 @@ public: if (success && !_settings_client.gui.persistent_buildingtools) ResetObjectToPlace(); } - IntervalTimer update_interval = {std::chrono::seconds(3), [this](auto) { + const IntervalTimer update_interval = {std::chrono::seconds(3), [this](auto) { if (_game_mode == GM_EDITOR) return; if (this->selected_type == IT_INVALID) return; @@ -1872,7 +1872,7 @@ public: } /** Rebuild the industry list on a regular interval. */ - IntervalTimer rebuild_interval = {std::chrono::seconds(3), [this](auto) { + const IntervalTimer rebuild_interval = {std::chrono::seconds(3), [this](auto) { this->industries.ForceResort(); this->BuildSortIndustriesList(); }}; diff --git a/src/main_gui.cpp b/src/main_gui.cpp index e07bc35621..0a3e8d8c11 100644 --- a/src/main_gui.cpp +++ b/src/main_gui.cpp @@ -238,7 +238,7 @@ struct MainWindow : Window } /** Refresh the link-graph overlay on a regular interval. */ - IntervalTimer refresh_interval = {std::chrono::milliseconds(7650), [this](auto) { + const IntervalTimer refresh_interval = {std::chrono::milliseconds(7650), [this](auto) { RefreshLinkGraph(); }}; diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp index fc2a633b4f..719f5a5dfa 100644 --- a/src/misc_gui.cpp +++ b/src/misc_gui.cpp @@ -465,7 +465,7 @@ struct AboutWindow : public Window { * * The interval of 2100ms is chosen to maintain parity: 2100 / GetCharacterHeight(FS_NORMAL) = 150ms. */ - IntervalTimer scroll_interval = {std::chrono::milliseconds(2100) / GetCharacterHeight(FS_NORMAL), [this](uint count) { + const IntervalTimer scroll_interval = {std::chrono::milliseconds(2100) / GetCharacterHeight(FS_NORMAL), [this](uint count) { this->text_position -= count; /* If the last text has scrolled start a new from the start */ if (this->text_position < (int)(this->GetWidget(WID_A_SCROLLING_TEXT)->pos_y - std::size(_credits) * this->line_height)) { diff --git a/src/network/network_chat_gui.cpp b/src/network/network_chat_gui.cpp index 84fce1e53f..30bf187c10 100644 --- a/src/network/network_chat_gui.cpp +++ b/src/network/network_chat_gui.cpp @@ -165,7 +165,7 @@ void NetworkUndrawChatMessage() } /** Check if a message is expired on a regular interval. */ -static IntervalTimer network_message_expired_interval(std::chrono::seconds(1), [](auto) { +static const IntervalTimer network_message_expired_interval(std::chrono::seconds(1), [](auto) { auto now = std::chrono::steady_clock::now(); for (auto &cmsg : _chatmsg_list) { /* Message has expired, remove from the list */ diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp index 4b294c743c..d7064a037f 100644 --- a/src/network/network_gui.cpp +++ b/src/network/network_gui.cpp @@ -833,7 +833,7 @@ public: } /** Refresh the online servers on a regular interval. */ - IntervalTimer refresh_interval = {std::chrono::seconds(30), [this](uint) { + const IntervalTimer refresh_interval = {std::chrono::seconds(30), [this](uint) { if (!this->searched_internet) return; _network_coordinator_client.GetListing(); diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp index 862057107e..3087db360e 100644 --- a/src/network/network_server.cpp +++ b/src/network/network_server.cpp @@ -1864,14 +1864,14 @@ static void NetworkCheckRestartMapYear() } /** Calendar yearly "callback". Called whenever the calendar year changes. */ -static IntervalTimer _calendar_network_yearly({ TimerGameCalendar::YEAR, TimerGameCalendar::Priority::NONE }, [](auto) { +static const IntervalTimer _calendar_network_yearly({ TimerGameCalendar::YEAR, TimerGameCalendar::Priority::NONE }, [](auto) { if (!_network_server) return; NetworkCheckRestartMapYear(); }); /** Economy yearly "callback". Called whenever the economy year changes. */ -static IntervalTimer _economy_network_yearly({TimerGameEconomy::YEAR, TimerGameEconomy::Priority::NONE}, [](auto) +static const IntervalTimer _economy_network_yearly({TimerGameEconomy::YEAR, TimerGameEconomy::Priority::NONE}, [](auto) { if (!_network_server) return; @@ -1879,7 +1879,7 @@ static IntervalTimer _economy_network_yearly({TimerGameEconomy }); /** Quarterly "callback". Called whenever the economy quarter changes. */ -static IntervalTimer _network_quarterly({TimerGameEconomy::QUARTER, TimerGameEconomy::Priority::NONE}, [](auto) +static const IntervalTimer _network_quarterly({TimerGameEconomy::QUARTER, TimerGameEconomy::Priority::NONE}, [](auto) { if (!_network_server) return; @@ -1888,7 +1888,7 @@ static IntervalTimer _network_quarterly({TimerGameEconomy::QUA }); /** Economy monthly "callback". Called whenever the economy month changes. */ -static IntervalTimer _network_monthly({TimerGameEconomy::MONTH, TimerGameEconomy::Priority::NONE}, [](auto) +static const IntervalTimer _network_monthly({TimerGameEconomy::MONTH, TimerGameEconomy::Priority::NONE}, [](auto) { if (!_network_server) return; @@ -1897,7 +1897,7 @@ static IntervalTimer _network_monthly({TimerGameEconomy::MONTH }); /** Economy weekly "callback". Called whenever the economy week changes. */ -static IntervalTimer _network_weekly({TimerGameEconomy::WEEK, TimerGameEconomy::Priority::NONE}, [](auto) +static const IntervalTimer _network_weekly({TimerGameEconomy::WEEK, TimerGameEconomy::Priority::NONE}, [](auto) { if (!_network_server) return; @@ -1905,7 +1905,7 @@ static IntervalTimer _network_weekly({TimerGameEconomy::WEEK, }); /** Daily "callback". Called whenever the economy date changes. */ -static IntervalTimer _economy_network_daily({TimerGameEconomy::DAY, TimerGameEconomy::Priority::NONE}, [](auto) +static const IntervalTimer _economy_network_daily({TimerGameEconomy::DAY, TimerGameEconomy::Priority::NONE}, [](auto) { if (!_network_server) return; diff --git a/src/news_gui.cpp b/src/news_gui.cpp index 1fecfec7fd..cd804fdb44 100644 --- a/src/news_gui.cpp +++ b/src/news_gui.cpp @@ -652,7 +652,7 @@ struct NewsWindow : Window { * * The interval of 210ms is chosen to maintain 15ms at normal zoom: 210 / GetCharacterHeight(FS_NORMAL) = 15ms. */ - IntervalTimer scroll_interval = {std::chrono::milliseconds(210) / GetCharacterHeight(FS_NORMAL), [this](uint count) { + const IntervalTimer scroll_interval = {std::chrono::milliseconds(210) / GetCharacterHeight(FS_NORMAL), [this](uint count) { int newtop = std::max(this->top - 2 * static_cast(count), _screen.height - this->height - this->status_height - this->chat_height); this->SetWindowTop(newtop); }}; diff --git a/src/picker_gui.h b/src/picker_gui.h index 48ba38883f..9d72235f6b 100644 --- a/src/picker_gui.h +++ b/src/picker_gui.h @@ -222,11 +222,11 @@ private: GUIBadgeClasses badge_classes; - IntervalTimer yearly_interval = {{TimerGameCalendar::YEAR, TimerGameCalendar::Priority::NONE}, [this](auto) { + const IntervalTimer yearly_interval = {{TimerGameCalendar::YEAR, TimerGameCalendar::Priority::NONE}, [this](auto) { this->SetDirty(); }}; - IntervalTimer refresh_interval = {std::chrono::seconds(3), [this](auto) { + const IntervalTimer refresh_interval = {std::chrono::seconds(3), [this](auto) { RefreshUsedTypeList(); }}; }; diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp index 137e17ad8e..8117cbd40a 100644 --- a/src/rail_gui.cpp +++ b/src/rail_gui.cpp @@ -2002,7 +2002,7 @@ void ResetSignalVariant(int32_t) } } -static IntervalTimer _check_reset_signal({TimerGameCalendar::YEAR, TimerGameCalendar::Priority::NONE}, [](auto) +static const IntervalTimer _check_reset_signal({TimerGameCalendar::YEAR, TimerGameCalendar::Priority::NONE}, [](auto) { if (TimerGameCalendar::year != _settings_client.gui.semaphore_build_before) return; diff --git a/src/signs_gui.cpp b/src/signs_gui.cpp index 687968150c..45f0018b54 100644 --- a/src/signs_gui.cpp +++ b/src/signs_gui.cpp @@ -308,7 +308,7 @@ struct SignListWindow : Window, SignList { } /** Resort the sign listing on a regular interval. */ - IntervalTimer rebuild_interval = {std::chrono::seconds(3), [this](auto) { + const IntervalTimer rebuild_interval = {std::chrono::seconds(3), [this](auto) { this->BuildSortSignList(); this->SetDirty(); }}; diff --git a/src/smallmap_gui.cpp b/src/smallmap_gui.cpp index 5bda9cc041..bd2bfe6d93 100644 --- a/src/smallmap_gui.cpp +++ b/src/smallmap_gui.cpp @@ -730,12 +730,12 @@ protected: } /** Blink the industries (if selected) on a regular interval. */ - IntervalTimer blink_interval = {std::chrono::milliseconds(450), [this](auto) { + const IntervalTimer blink_interval = {std::chrono::milliseconds(450), [this](auto) { Blink(); }}; /** Update the whole map on a regular interval. */ - IntervalTimer refresh_interval = {std::chrono::milliseconds(930), [this](auto) { + const IntervalTimer refresh_interval = {std::chrono::milliseconds(930), [this](auto) { ForceRefresh(); }}; diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index 72152ba5d1..00407f7668 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -4226,7 +4226,7 @@ void OnTick_Station() } /** Economy monthly loop for stations. */ -static IntervalTimer _economy_stations_monthly({TimerGameEconomy::MONTH, TimerGameEconomy::Priority::STATION}, [](auto) +static const IntervalTimer _economy_stations_monthly({TimerGameEconomy::MONTH, TimerGameEconomy::Priority::STATION}, [](auto) { for (Station *st : Station::Iterate()) { for (GoodsEntry &ge : st->goods) { diff --git a/src/statusbar_gui.cpp b/src/statusbar_gui.cpp index a146d8fceb..ffd5e90494 100644 --- a/src/statusbar_gui.cpp +++ b/src/statusbar_gui.cpp @@ -192,7 +192,7 @@ struct StatusBarWindow : Window { } /** Move information on the ticker slowly from one side to the other. */ - IntervalTimer ticker_scroll_interval = {std::chrono::milliseconds(15), [this](uint count) { + const IntervalTimer ticker_scroll_interval = {std::chrono::milliseconds(15), [this](uint count) { if (_pause_mode.Any()) return; if (this->ticker_scroll < TICKER_STOP) { @@ -205,7 +205,7 @@ struct StatusBarWindow : Window { this->SetWidgetDirty(WID_S_MIDDLE); }}; - IntervalTimer daily_interval = {{TimerGameCalendar::DAY, TimerGameCalendar::Priority::NONE}, [this](auto) { + const IntervalTimer daily_interval = {{TimerGameCalendar::DAY, TimerGameCalendar::Priority::NONE}, [this](auto) { this->SetWidgetDirty(WID_S_LEFT); }}; }; diff --git a/src/subsidy.cpp b/src/subsidy.cpp index 537063dbb6..33c4094ae6 100644 --- a/src/subsidy.cpp +++ b/src/subsidy.cpp @@ -422,7 +422,7 @@ bool FindSubsidyCargoDestination(CargoType cargo_type, Source src) } /** Perform the economy monthly update of open subsidies, and try to create a new one. */ -static IntervalTimer _economy_subsidies_monthly({TimerGameEconomy::MONTH, TimerGameEconomy::Priority::SUBSIDY}, [](auto) +static const IntervalTimer _economy_subsidies_monthly({TimerGameEconomy::MONTH, TimerGameEconomy::Priority::SUBSIDY}, [](auto) { bool modified = false; diff --git a/src/texteff.cpp b/src/texteff.cpp index 8855e3a4f6..82f832e2de 100644 --- a/src/texteff.cpp +++ b/src/texteff.cpp @@ -89,7 +89,7 @@ void RemoveTextEffect(TextEffectID te_id) } /** Slowly move text effects upwards. */ -IntervalTimer move_all_text_effects_interval = {std::chrono::milliseconds(30), [](uint count) { +const IntervalTimer move_all_text_effects_interval = {std::chrono::milliseconds(30), [](uint count) { if (_pause_mode.Any() && _game_mode != GM_EDITOR && _settings_game.construction.command_pause_level <= CMDPL_NO_CONSTRUCTION) return; for (TextEffect &te : _text_effects) { diff --git a/src/timetable_gui.cpp b/src/timetable_gui.cpp index b1557de493..17ccea5c4e 100644 --- a/src/timetable_gui.cpp +++ b/src/timetable_gui.cpp @@ -802,7 +802,7 @@ struct TimetableWindow : Window { /** * In real-time mode, the timetable GUI shows relative times and needs to be redrawn every second. */ - IntervalTimer redraw_interval = { { TimerGameTick::Priority::NONE, Ticks::TICKS_PER_SECOND }, [this](auto) { + const IntervalTimer redraw_interval = { { TimerGameTick::Priority::NONE, Ticks::TICKS_PER_SECOND }, [this](auto) { if (_settings_client.gui.timetable_mode == TimetableMode::Seconds) { this->SetDirty(); } diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp index 4aecc3d4fe..d8e684cd4b 100644 --- a/src/toolbar_gui.cpp +++ b/src/toolbar_gui.cpp @@ -2104,7 +2104,7 @@ struct MainToolbarWindow : Window { } /** Refresh the state of pause / game-speed on a regular interval.*/ - IntervalTimer refresh_interval = {std::chrono::milliseconds(30), [this](auto) { + const IntervalTimer refresh_interval = {std::chrono::milliseconds(30), [this](auto) { if (this->IsWidgetLowered(WID_TN_PAUSE) != _pause_mode.Any()) { this->ToggleWidgetLoweredState(WID_TN_PAUSE); this->SetWidgetDirty(WID_TN_PAUSE); @@ -2471,7 +2471,7 @@ struct ScenarioEditorToolbarWindow : Window { } /** Refresh the state of pause / game-speed on a regular interval.*/ - IntervalTimer refresh_interval = {std::chrono::milliseconds(30), [this](auto) { + const IntervalTimer refresh_interval = {std::chrono::milliseconds(30), [this](auto) { if (this->IsWidgetLowered(WID_TE_PAUSE) != _pause_mode.Any()) { this->ToggleWidgetLoweredState(WID_TE_PAUSE); this->SetDirty(); diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp index 7ff6f6beb6..3817dc4c71 100644 --- a/src/town_cmd.cpp +++ b/src/town_cmd.cpp @@ -4040,7 +4040,7 @@ CommandCost CheckforTownRating(DoCommandFlags flags, Town *t, TownRatingCheckTyp return CommandCost(); } -static IntervalTimer _economy_towns_monthly({TimerGameEconomy::MONTH, TimerGameEconomy::Priority::TOWN}, [](auto) +static const IntervalTimer _economy_towns_monthly({TimerGameEconomy::MONTH, TimerGameEconomy::Priority::TOWN}, [](auto) { for (Town *t : Town::Iterate()) { /* Check for active town actions and decrement their counters. */ @@ -4067,7 +4067,7 @@ static IntervalTimer _economy_towns_monthly({TimerGameEconomy: } }); -static IntervalTimer _economy_towns_yearly({TimerGameEconomy::YEAR, TimerGameEconomy::Priority::TOWN}, [](auto) +static const IntervalTimer _economy_towns_yearly({TimerGameEconomy::YEAR, TimerGameEconomy::Priority::TOWN}, [](auto) { /* Increment house ages */ for (const auto t : Map::Iterate()) { diff --git a/src/town_gui.cpp b/src/town_gui.cpp index 4606a2fd44..8f794b5748 100644 --- a/src/town_gui.cpp +++ b/src/town_gui.cpp @@ -332,7 +332,7 @@ public: } /** Redraw the whole window on a regular interval. */ - IntervalTimer redraw_interval = {std::chrono::seconds(3), [this](auto) { + const IntervalTimer redraw_interval = {std::chrono::seconds(3), [this](auto) { this->SetDirty(); }}; @@ -605,7 +605,7 @@ public: Command::Post(STR_ERROR_CAN_T_RENAME_TOWN, static_cast(this->window_number), *str); } - IntervalTimer daily_interval = {{TimerGameCalendar::DAY, TimerGameCalendar::Priority::NONE}, [this](auto) { + const IntervalTimer daily_interval = {{TimerGameCalendar::DAY, TimerGameCalendar::Priority::NONE}, [this](auto) { /* Refresh after possible snowline change */ this->SetDirty(); }}; @@ -987,7 +987,7 @@ public: } /** Redraw the whole window on a regular interval. */ - IntervalTimer rebuild_interval = {std::chrono::seconds(3), [this](auto) { + const IntervalTimer rebuild_interval = {std::chrono::seconds(3), [this](auto) { this->BuildSortTownList(); this->SetDirty(); }}; @@ -1775,7 +1775,7 @@ struct BuildHouseWindow : public PickerWindow { Command::Post(STR_ERROR_CAN_T_BUILD_HOUSE, CcPlaySound_CONSTRUCTION_OTHER, tile, spec->Index(), this->house_protected); } - IntervalTimer view_refresh_interval = {std::chrono::milliseconds(2500), [this](auto) { + const IntervalTimer view_refresh_interval = {std::chrono::milliseconds(2500), [this](auto) { /* There are four different 'views' that are random based on house tile position. As this is not * user-controllable, instead we automatically cycle through them. */ HousePickerCallbacks::sel_view = (HousePickerCallbacks::sel_view + 1) % 4; diff --git a/src/vehicle.cpp b/src/vehicle.cpp index 0d4fef53c7..e1f67b3352 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -2987,7 +2987,7 @@ void Vehicle::RemoveFromShared() this->previous_shared = nullptr; } -static IntervalTimer _economy_vehicles_yearly({TimerGameEconomy::YEAR, TimerGameEconomy::Priority::VEHICLE}, [](auto) +static const IntervalTimer _economy_vehicles_yearly({TimerGameEconomy::YEAR, TimerGameEconomy::Priority::VEHICLE}, [](auto) { for (Vehicle *v : Vehicle::Iterate()) { if (v->IsPrimaryVehicle()) { diff --git a/src/window.cpp b/src/window.cpp index 651bbfde9d..21546d30b7 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -3068,7 +3068,7 @@ void CallWindowRealtimeTickEvent(uint delta_ms) } /** Update various of window-related information on a regular interval. */ -static IntervalTimer window_interval(std::chrono::milliseconds(30), [](auto) { +static const IntervalTimer window_interval(std::chrono::milliseconds(30), [](auto) { extern int _caret_timer; _caret_timer += 3; CursorTick(); @@ -3079,12 +3079,12 @@ static IntervalTimer window_interval(std::chrono::milliseconds(30), }); /** Blink the window highlight colour constantly. */ -static IntervalTimer highlight_interval(std::chrono::milliseconds(450), [](auto) { +static const IntervalTimer highlight_interval(std::chrono::milliseconds(450), [](auto) { _window_highlight_colour = !_window_highlight_colour; }); /** Blink all windows marked with a white border. */ -static IntervalTimer white_border_interval(std::chrono::milliseconds(30), [](auto) { +static const IntervalTimer white_border_interval(std::chrono::milliseconds(30), [](auto) { if (_network_dedicated) return; for (Window *w : Window::Iterate()) {