OpenTTD Source 20260107-master-g88a467db19
settings_table.cpp
Go to the documentation of this file.
1/*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
10#include "stdafx.h"
11#include "settings_table.h"
12#include "currency.h"
13#include "screenshot.h"
14#include "network/network.h"
16#include "network/core/config.h"
19#include "genworld.h"
20#include "train.h"
21#include "news_func.h"
22#include "window_func.h"
23#include "company_func.h"
25#if defined(WITH_FREETYPE) || defined(_WIN32) || defined(WITH_COCOA)
26#define HAS_TRUETYPE_FONT
27#include "fontcache.h"
28#endif
29#include "textbuf_gui.h"
30#include "rail_gui.h"
31#include "elrail_func.h"
32#include "error.h"
33#include "town.h"
37#include "blitter/factory.hpp"
38#include "base_media_base.h"
39#include "base_media_music.h"
40#include "base_media_sounds.h"
41#include "ai/ai_config.hpp"
42#include "ai/ai.hpp"
43#include "game/game_config.hpp"
44#include "ship.h"
45#include "smallmap_gui.h"
46#include "roadveh.h"
47#include "roadveh_cmd.h"
48#include "vehicle_func.h"
49#include "viewport_func.h"
50#include "void_map.h"
51#include "station_func.h"
52#include "station_base.h"
53
54#include "table/strings.h"
55#include "table/settings.h"
56
57#include "safeguards.h"
58
59SettingTable _company_settings{ _company_settings_table };
60SettingTable _currency_settings{ _currency_settings_table };
61SettingTable _difficulty_settings{ _difficulty_settings_table };
62SettingTable _multimedia_settings{ _multimedia_settings_table };
63SettingTable _economy_settings{ _economy_settings_table };
64SettingTable _game_settings{ _game_settings_table };
65SettingTable _gui_settings{ _gui_settings_table };
66SettingTable _linkgraph_settings{ _linkgraph_settings_table };
67SettingTable _locale_settings{ _locale_settings_table };
68SettingTable _misc_settings{ _misc_settings_table };
69SettingTable _network_private_settings{ _network_private_settings_table };
70SettingTable _network_secrets_settings{ _network_secrets_settings_table };
71SettingTable _network_settings{ _network_settings_table };
72SettingTable _news_display_settings{ _news_display_settings_table };
73SettingTable _old_gameopt_settings{ _old_gameopt_settings_table };
74SettingTable _pathfinding_settings{ _pathfinding_settings_table };
75SettingTable _script_settings{ _script_settings_table };
76SettingTable _window_settings{ _window_settings_table };
77SettingTable _world_settings{ _world_settings_table };
78#if defined(_WIN32) && !defined(DEDICATED)
79SettingTable _win32_settings{ _win32_settings_table };
80#endif /* _WIN32 */
81
82
83/* Begin - Callback Functions for the various settings. */
84
87{
88 return TimerGameEconomy::UsingWallclockUnits(_game_mode == GM_MENU) ? sd.str + 1 : sd.str;
89}
90
93{
94 return TimerGameEconomy::UsingWallclockUnits(_game_mode == GM_MENU) ? sd.str_help + 1 : sd.str_help;
95}
96
98static std::pair<StringParameter, StringParameter> SettingsValueVelocityUnit(const IntSettingDesc &, int32_t value)
99{
100 StringID val;
101 switch (value) {
102 case 0: val = STR_CONFIG_SETTING_LOCALISATION_UNITS_VELOCITY_IMPERIAL; break;
103 case 1: val = STR_CONFIG_SETTING_LOCALISATION_UNITS_VELOCITY_METRIC; break;
104 case 2: val = STR_CONFIG_SETTING_LOCALISATION_UNITS_VELOCITY_SI; break;
105 case 3: val = TimerGameEconomy::UsingWallclockUnits(_game_mode == GM_MENU) ? STR_CONFIG_SETTING_LOCALISATION_UNITS_VELOCITY_GAMEUNITS_SECS : STR_CONFIG_SETTING_LOCALISATION_UNITS_VELOCITY_GAMEUNITS_DAYS; break;
106 case 4: val = STR_CONFIG_SETTING_LOCALISATION_UNITS_VELOCITY_KNOTS; break;
107 default: NOT_REACHED();
108 }
109 return {val, {}};
110}
111
113static std::pair<StringParameter, StringParameter> SettingsValueAbsolute(const IntSettingDesc &sd, int32_t value)
114{
115 return {sd.str_val + ((value >= 0) ? 1 : 0), abs(value)};
116}
117
119static std::pair<StringParameter, StringParameter> ServiceIntervalSettingsValueText(const IntSettingDesc &sd, int32_t value)
120{
122 if (_game_mode == GM_MENU || !Company::IsValidID(_current_company)) {
124 } else {
125 vds = &Company::Get(_current_company)->settings.vehicle;
126 }
127
128 StringID str;
129 if (value == 0) {
130 str = sd.str_val + 3;
131 } else if (vds->servint_ispercent) {
132 str = sd.str_val + 2;
133 } else if (TimerGameEconomy::UsingWallclockUnits(_game_mode == GM_MENU)) {
134 str = sd.str_val + 1;
135 } else {
136 str = sd.str_val;
137 }
138 return {str, value};
139}
140
142static void v_PositionMainToolbar(int32_t)
143{
144 if (_game_mode != GM_MENU) PositionMainToolbar(nullptr);
145}
146
148static void v_PositionStatusbar(int32_t)
149{
150 if (_game_mode != GM_MENU) {
151 PositionStatusbar(nullptr);
152 PositionNewsMessage(nullptr);
154 }
155}
156
160static void RedrawSmallmap(int32_t)
161{
165}
166
168static void UpdateLinkgraphColours(int32_t)
169{
172}
173
174static void StationSpreadChanged(int32_t)
175{
178}
179
180static void UpdateConsists(int32_t)
181{
182 for (Train *t : Train::Iterate()) {
183 /* Update the consist of all trains so the maximum speed is set correctly. */
184 if (t->IsFrontEngine() || t->IsFreeWagon()) t->ConsistChanged(CCF_TRACK);
185 }
187}
188
193static void UpdateAllServiceInterval(int32_t new_value)
194{
195 bool update_vehicles;
197 if (_game_mode == GM_MENU || !Company::IsValidID(_current_company)) {
199 update_vehicles = false;
200 } else {
201 vds = &Company::Get(_current_company)->settings.vehicle;
202 update_vehicles = true;
203 }
204
205 if (new_value != 0) {
206 /* Service intervals are in percents. */
207 vds->servint_trains = DEF_SERVINT_PERCENT;
208 vds->servint_roadveh = DEF_SERVINT_PERCENT;
209 vds->servint_aircraft = DEF_SERVINT_PERCENT;
210 vds->servint_ships = DEF_SERVINT_PERCENT;
211 } else if (TimerGameEconomy::UsingWallclockUnits(_game_mode == GM_MENU)) {
212 /* Service intervals are in minutes. */
213 vds->servint_trains = DEF_SERVINT_MINUTES_TRAINS;
214 vds->servint_roadveh = DEF_SERVINT_MINUTES_ROADVEH;
215 vds->servint_aircraft = DEF_SERVINT_MINUTES_AIRCRAFT;
216 vds->servint_ships = DEF_SERVINT_MINUTES_SHIPS;
217 } else {
218 /* Service intervals are in days. */
219 vds->servint_trains = DEF_SERVINT_DAYS_TRAINS;
220 vds->servint_roadveh = DEF_SERVINT_DAYS_ROADVEH;
221 vds->servint_aircraft = DEF_SERVINT_DAYS_AIRCRAFT;
222 vds->servint_ships = DEF_SERVINT_DAYS_SHIPS;
223 }
224
225 if (update_vehicles) {
227 for (Vehicle *v : Vehicle::Iterate()) {
228 if (v->owner == _current_company && v->IsPrimaryVehicle() && !v->ServiceIntervalIsCustom()) {
229 v->SetServiceInterval(CompanyServiceInterval(c, v->type));
230 v->SetServiceIntervalIsPercent(new_value != 0);
231 }
232 }
233 }
234
236}
237
238static bool CanUpdateServiceInterval(VehicleType, int32_t &new_value)
239{
241 if (_game_mode == GM_MENU || !Company::IsValidID(_current_company)) {
243 } else {
244 vds = &Company::Get(_current_company)->settings.vehicle;
245 }
246
247 /* Test if the interval is valid */
248 int32_t interval = GetServiceIntervalClamped(new_value, vds->servint_ispercent);
249 return new_value == 0 || interval == new_value;
250}
251
252static void UpdateServiceInterval(VehicleType type, int32_t new_value)
253{
254 if (_game_mode != GM_MENU && Company::IsValidID(_current_company)) {
255 for (Vehicle *v : Vehicle::Iterate()) {
256 if (v->owner == _current_company && v->type == type && v->IsPrimaryVehicle() && !v->ServiceIntervalIsCustom()) {
257 v->SetServiceInterval(new_value);
258 }
259 }
260 }
261
263}
264
269{
271 if (_game_mode == GM_MENU || !Company::IsValidID(_current_company)) {
273 } else {
274 vds = &Company::Get(_current_company)->settings.vehicle;
275 }
276
277 if (vds->servint_ispercent) return DEF_SERVINT_PERCENT;
278
279 if (TimerGameEconomy::UsingWallclockUnits(_game_mode == GM_MENU)) {
280 switch (type) {
281 case VEH_TRAIN: return DEF_SERVINT_MINUTES_TRAINS;
282 case VEH_ROAD: return DEF_SERVINT_MINUTES_ROADVEH;
283 case VEH_AIRCRAFT: return DEF_SERVINT_MINUTES_AIRCRAFT;
284 case VEH_SHIP: return DEF_SERVINT_MINUTES_SHIPS;
285 default: NOT_REACHED();
286 }
287 }
288
289 return sd.def;
290}
291
292static std::tuple<int32_t, uint32_t> GetServiceIntervalRange(const IntSettingDesc &)
293{
295 if (_game_mode == GM_MENU || !Company::IsValidID(_current_company)) {
297 } else {
298 vds = &Company::Get(_current_company)->settings.vehicle;
299 }
300
301 if (vds->servint_ispercent) return { MIN_SERVINT_PERCENT, MAX_SERVINT_PERCENT };
302
303 if (TimerGameEconomy::UsingWallclockUnits(_game_mode == GM_MENU)) {
304 return { MIN_SERVINT_MINUTES, MAX_SERVINT_MINUTES };
305 }
306
307 return { MIN_SERVINT_DAYS, MAX_SERVINT_DAYS };
308}
309
310static void TrainAccelerationModelChanged(int32_t)
311{
312 for (Train *t : Train::Iterate()) {
313 if (t->IsFrontEngine()) {
314 t->tcache.cached_max_curve_speed = t->GetCurveSpeedLimit();
315 t->UpdateAcceleration();
316 }
317 }
318
319 /* These windows show acceleration values only when realistic acceleration is on. They must be redrawn after a setting change. */
323}
324
328static void TrainSlopeSteepnessChanged(int32_t)
329{
330 for (Train *t : Train::Iterate()) {
331 if (t->IsFrontEngine()) t->CargoChanged();
332 }
333}
334
339{
341 for (RoadVehicle *rv : RoadVehicle::Iterate()) {
342 if (rv->IsFrontEngine()) {
343 rv->CargoChanged();
344 }
345 }
346 }
347
348 /* These windows show acceleration values only when realistic acceleration is on. They must be redrawn after a setting change. */
352}
353
358{
359 for (RoadVehicle *rv : RoadVehicle::Iterate()) {
360 if (rv->IsFrontEngine()) rv->CargoChanged();
361 }
362}
363
364static void TownFoundingChanged(int32_t)
365{
366 if (_game_mode != GM_EDITOR && _settings_game.economy.found_town == TF_FORBIDDEN) {
368 } else {
370 }
371}
372
373static void ZoomMinMaxChanged(int32_t)
374{
375 ConstrainAllViewportsZoom();
378 if (AdjustGUIZoom(false)) {
379 ReInitAllWindows(true);
380 }
381}
382
383static void SpriteZoomMinChanged(int32_t)
384{
386 /* Force all sprites to redraw at the new chosen zoom level */
388}
389
401
402static void InvalidateCompanyLiveryWindow(int32_t)
403{
405 ResetVehicleColourMap();
406}
407
408static void DifficultyNoiseChange(int32_t)
409{
410 if (_game_mode == GM_NORMAL) {
414 }
415 }
416}
417
418static void MaxNoAIsChange(int32_t)
419{
420 if (GetGameSettings().difficulty.max_no_competitors != 0 &&
421 AI::GetInfoList()->empty() &&
423 ShowErrorMessage(GetEncodedString(STR_WARNING_NO_SUITABLE_AI), {}, WL_CRITICAL);
424 }
425
427}
428
433static bool CheckRoadSide(int32_t &)
434{
435 return _game_mode == GM_MENU || !RoadVehiclesAreBuilt();
436}
437
445static std::optional<uint32_t> ConvertLandscape(std::string_view value)
446{
447 /* try with the old values */
448 static constexpr std::initializer_list<std::string_view> _old_landscape_values{"normal"sv, "hilly"sv, "desert"sv, "candy"sv};
449 return OneOfManySettingDesc::ParseSingleValue(value, _old_landscape_values);
450}
451
452static bool CheckFreeformEdges(int32_t &new_value)
453{
454 if (_game_mode == GM_MENU) return true;
455 if (new_value != 0) {
456 for (Ship *s : Ship::Iterate()) {
457 /* Check if there is a ship on the northern border. */
458 if (TileX(s->tile) == 0 || TileY(s->tile) == 0) {
459 ShowErrorMessage(GetEncodedString(STR_CONFIG_SETTING_EDGES_NOT_EMPTY), {}, WL_ERROR);
460 return false;
461 }
462 }
463 for (const BaseStation *st : BaseStation::Iterate()) {
464 /* Check if there is a non-deleted buoy on the northern border. */
465 if (st->IsInUse() && (TileX(st->xy) == 0 || TileY(st->xy) == 0)) {
466 ShowErrorMessage(GetEncodedString(STR_CONFIG_SETTING_EDGES_NOT_EMPTY), {}, WL_ERROR);
467 return false;
468 }
469 }
470 } else {
471 for (uint i = 0; i < Map::MaxX(); i++) {
472 if (TileHeight(TileXY(i, 1)) != 0) {
473 ShowErrorMessage(GetEncodedString(STR_CONFIG_SETTING_EDGES_NOT_WATER), {}, WL_ERROR);
474 return false;
475 }
476 }
477 for (uint i = 1; i < Map::MaxX(); i++) {
478 if (!IsTileType(TileXY(i, Map::MaxY() - 1), MP_WATER) || TileHeight(TileXY(1, Map::MaxY())) != 0) {
479 ShowErrorMessage(GetEncodedString(STR_CONFIG_SETTING_EDGES_NOT_WATER), {}, WL_ERROR);
480 return false;
481 }
482 }
483 for (uint i = 0; i < Map::MaxY(); i++) {
484 if (TileHeight(TileXY(1, i)) != 0) {
485 ShowErrorMessage(GetEncodedString(STR_CONFIG_SETTING_EDGES_NOT_WATER), {}, WL_ERROR);
486 return false;
487 }
488 }
489 for (uint i = 1; i < Map::MaxY(); i++) {
490 if (!IsTileType(TileXY(Map::MaxX() - 1, i), MP_WATER) || TileHeight(TileXY(Map::MaxX(), i)) != 0) {
491 ShowErrorMessage(GetEncodedString(STR_CONFIG_SETTING_EDGES_NOT_WATER), {}, WL_ERROR);
492 return false;
493 }
494 }
495 }
496 return true;
497}
498
499static void UpdateFreeformEdges(int32_t new_value)
500{
501 if (_game_mode == GM_MENU) return;
502
503 if (new_value != 0) {
504 for (uint x = 0; x < Map::SizeX(); x++) MakeVoid(TileXY(x, 0));
505 for (uint y = 0; y < Map::SizeY(); y++) MakeVoid(TileXY(0, y));
506 } else {
507 /* Make tiles at the border water again. */
508 for (uint i = 0; i < Map::MaxX(); i++) {
509 SetTileHeight(TileXY(i, 0), 0);
511 }
512 for (uint i = 0; i < Map::MaxY(); i++) {
513 SetTileHeight(TileXY(0, i), 0);
515 }
516 }
518}
519
524static bool CheckDynamicEngines(int32_t &)
525{
526 if (_game_mode == GM_MENU) return true;
527
529 ShowErrorMessage(GetEncodedString(STR_CONFIG_SETTING_DYNAMIC_ENGINES_EXISTING_VEHICLES), {}, WL_ERROR);
530 return false;
531 }
532
533 return true;
534}
535
536static bool CheckMaxHeightLevel(int32_t &new_value)
537{
538 if (_game_mode == GM_NORMAL) return false;
539 if (_game_mode != GM_EDITOR) return true;
540
541 /* Check if at least one mountain on the map is higher than the new value.
542 * If yes, disallow the change. */
543 for (const auto t : Map::Iterate()) {
544 if ((int32_t)TileHeight(t) > new_value) {
545 ShowErrorMessage(GetEncodedString(STR_CONFIG_SETTING_TOO_HIGH_MOUNTAIN), {}, WL_ERROR);
546 /* Return old, unchanged value */
547 return false;
548 }
549 }
550
551 return true;
552}
553
554static void StationCatchmentChanged(int32_t)
555{
558}
559
560static void MaxVehiclesChanged(int32_t)
561{
564}
565
571static bool ReplaceAsteriskWithEmptyPassword(std::string &newval)
572{
573 if (newval == "*") newval.clear();
574 return true;
575}
576
588
593static void ChangeTimekeepingUnits(int32_t)
594{
595 /* If service intervals are in time units (calendar days or real-world minutes), reset them to the correct defaults. */
598 }
599
600 /* If we are using calendar timekeeping, "minutes per year" must be default. */
602 _settings_newgame.economy.minutes_per_calendar_year = CalendarTime::DEF_MINUTES_PER_YEAR;
603 }
604
606
607 /* It is possible to change these units in Scenario Editor. We must set the economy date appropriately. */
608 if (_game_mode == GM_EDITOR) {
609 TimerGameEconomy::Date new_economy_date;
610 TimerGameEconomy::DateFract new_economy_date_fract;
611
613 /* If the new mode is wallclock units, set the economy year back to 1. */
615 new_economy_date_fract = 0;
616 } else {
617 /* If the new mode is calendar units, sync the economy year with the calendar year. */
618 new_economy_date = TimerGameEconomy::Date{TimerGameCalendar::date.base()};
619 new_economy_date_fract = TimerGameCalendar::date_fract;
620 }
621
622 /* If you open a savegame as a scenario, there may already be link graphs and/or vehicles. These use economy date. */
624 for (auto v : Vehicle::Iterate()) v->ShiftDates(new_economy_date - TimerGameEconomy::date);
625
626 /* Only change the date after changing cached values above. */
627 TimerGameEconomy::SetDate(new_economy_date, new_economy_date_fract);
628 }
629}
630
635static void ChangeMinutesPerYear(int32_t new_value)
636{
637 /* We don't allow setting Minutes Per Year below default, unless it's to 0 for frozen calendar time. */
638 if (new_value < CalendarTime::DEF_MINUTES_PER_YEAR) {
639 int clamped;
640
641 /* If the new value is 1, we're probably at 0 and trying to increase the value, so we should jump up to default. */
642 if (new_value == 1) {
643 clamped = CalendarTime::DEF_MINUTES_PER_YEAR;
644 } else {
645 clamped = CalendarTime::FROZEN_MINUTES_PER_YEAR;
646 }
647
648 /* Override the setting with the clamped value. */
649 if (_game_mode == GM_MENU) {
651 } else {
653 }
654 }
655
656 /* If the setting value is not the default, force the game to use wallclock timekeeping units.
657 * 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.
658 */
659 if (_game_mode == GM_MENU && (_settings_newgame.economy.minutes_per_calendar_year != CalendarTime::DEF_MINUTES_PER_YEAR)) {
660 if (_settings_newgame.economy.timekeeping_units != TKU_WALLCLOCK) {
662 ChangeTimekeepingUnits(TKU_WALLCLOCK);
663 }
664 }
665}
666
667/* Get the valid range of the "minutes per calendar year" setting. */
668static std::tuple<int32_t, uint32_t> GetMinutesPerYearRange(const IntSettingDesc &)
669{
670 /* Allow a non-default value only if using Wallclock timekeeping units. */
671 if (TimerGameEconomy::UsingWallclockUnits(_game_mode == GM_MENU)) return { CalendarTime::FROZEN_MINUTES_PER_YEAR, CalendarTime::MAX_MINUTES_PER_YEAR };
672
673 return { CalendarTime::DEF_MINUTES_PER_YEAR, CalendarTime::DEF_MINUTES_PER_YEAR };
674}
675
681static bool CanChangeTimetableMode(int32_t &)
682{
684}
685
686/* End - Callback Functions */
Base functions for all AIs.
AIConfig stores the configuration settings of every AI.
Generic functions for replacing base data (graphics, sounds).
Generic functions for replacing base music data.
Generic functions for replacing base sounds data.
static const ScriptInfoList * GetInfoList()
Wrapper function for AIScanner::GetAIInfoList.
Definition ai_core.cpp:298
static LinkGraphSchedule instance
Static instance of LinkGraphSchedule.
void ShiftDates(TimerGameEconomy::Date interval)
Shift all dates (join dates and edge annotations) of link graphs and link graph jobs by the number of...
static Date date
Current date in days (day counter).
static DateFract date_fract
Fractional part of the day.
static Date date
Current date in days (day counter).
static bool UsingWallclockUnits(bool newgame=false)
Check if we are using wallclock units.
static void SetDate(Date date, DateFract fract)
Set the date.
static Date ConvertYMDToDate(Year year, Month month, Day day)
Converts a tuple of Year, Month and Day to a Date.
uint16_t DateFract
The fraction of a date we're in, i.e.
int CompanyServiceInterval(const Company *c, VehicleType type)
Get the service interval for the given company and vehicle type.
CompanyID _current_company
Company currently doing an action.
Functions related to companies.
Configuration options of the network stuff.
Functions to handle different currencies.
Header file for electrified rail specific functions.
Functions related to errors.
@ WL_ERROR
Errors (eg. saving/loading failed)
Definition error.h:26
@ WL_CRITICAL
Critical errors, the MessageBox is shown in all cases.
Definition error.h:27
void ShowErrorMessage(EncodedString &&summary_msg, int x, int y, CommandCost &cc)
Display an error message in a window.
Factory to 'query' all available blitters.
Functions to read fonts from files and cache them.
GameConfig stores the configuration settings of every Game.
Functions related to world/map generation.
bool AdjustGUIZoom(bool automatic)
Resolve GUI zoom level and adjust GUI to new zoom, if auto-suggestion is requested.
Definition gfx.cpp:1818
void MarkWholeScreenDirty()
This function mark the whole screen as dirty.
Definition gfx.cpp:1549
Declaration of link graph schedule used for cargo distribution.
static TileIndex TileXY(uint x, uint y)
Returns the TileIndex of a coordinate.
Definition map_func.h:385
static uint TileY(TileIndex tile)
Get the Y component of a tile.
Definition map_func.h:437
static uint TileX(TileIndex tile)
Get the X component of a tile.
Definition map_func.h:427
constexpr T abs(const T a)
Returns the absolute value of (scalar) variable.
Definition math_func.hpp:23
Base for all music playback.
bool _networking
are we in networking mode?
Definition network.cpp:66
bool _network_server
network-server is active
Definition network.cpp:67
Basic functions/variables used all over the place.
Network functions used by other parts of OpenTTD.
void NetworkServerUpdateGameInfo()
Update the server's NetworkServerGameInfo due to changes in settings.
void NetworkServerSendConfigUpdate()
Send Config Update.
Functions related to news.
uint16_t GetServiceIntervalClamped(int interval, bool ispercent)
Clamp the service interval to the correct min/max.
General types related to pathfinders.
Functions/types etc.
bool RoadVehiclesAreBuilt()
Verify whether a road vehicle is available.
Definition road_cmd.cpp:169
Road vehicle states.
Command definitions related to road vehicles.
A number of safeguards to prevent using unsafe methods.
Functions to make screenshots.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition settings.cpp:61
GameSettings _settings_newgame
Game settings for new games (updated from the intro screen).
Definition settings.cpp:62
ClientSettings _settings_client
The current settings for this game.
Definition settings.cpp:60
static void RoadVehSlopeSteepnessChanged(int32_t)
This function updates the road vehicle acceleration cache after a steepness change.
static void RoadVehAccelerationModelChanged(int32_t)
This function updates realistic acceleration caches when the setting "Road vehicle acceleration model...
static void UpdateAllServiceInterval(int32_t new_value)
Check and update if needed all vehicle service intervals.
static void v_PositionStatusbar(int32_t)
Reposition the statusbar as the setting changed.
static int32_t GetDefaultServiceInterval(const IntSettingDesc &sd, VehicleType type)
Checks if the service intervals in the settings are specified as percentages and corrects the default...
static void TrainSlopeSteepnessChanged(int32_t)
This function updates the train acceleration cache after a steepness change.
static void UpdateLinkgraphColours(int32_t)
Redraw linkgraph links after a colour scheme change.
static void RedrawSmallmap(int32_t)
Redraw the smallmap after a colour scheme change.
static bool ReplaceAsteriskWithEmptyPassword(std::string &newval)
Replace a passwords that are a literal asterisk with an empty string.
static StringID SettingHelpWallclock(const IntSettingDesc &sd)
Switch setting help depending on wallclock setting.
static std::pair< StringParameter, StringParameter > SettingsValueVelocityUnit(const IntSettingDesc &, int32_t value)
Setting values for velocity unit localisation.
static bool CheckDynamicEngines(int32_t &)
Changing the setting "allow multiple NewGRF sets" is not allowed if there are vehicles.
static bool CheckRoadSide(int32_t &)
Check whether the road side may be changed.
static void v_PositionMainToolbar(int32_t)
Reposition the main toolbar as the setting changed.
static std::optional< uint32_t > ConvertLandscape(std::string_view value)
Conversion callback for _gameopt_settings_game.landscape It converts (or try) between old values and ...
static bool CanChangeTimetableMode(int32_t &)
Pre-callback check when trying to change the timetable mode.
static void UpdateClientConfigValues()
Update the game info, and send it to the clients when we are running as a server.
static std::pair< StringParameter, StringParameter > ServiceIntervalSettingsValueText(const IntSettingDesc &sd, int32_t value)
Service Interval Settings Default Value displays the correct units or as a percentage.
static void ChangeMinutesPerYear(int32_t new_value)
Callback after the player changes the minutes per year.
static StringID SettingTitleWallclock(const IntSettingDesc &sd)
Switch setting title depending on wallclock setting.
static std::pair< StringParameter, StringParameter > SettingsValueAbsolute(const IntSettingDesc &sd, int32_t value)
A negative value has another string (the one after "strval").
static void ChangeTimekeepingUnits(int32_t)
Callback for when the player changes the timekeeping units.
static void InvalidateNewGRFChangeWindows(int32_t)
Update any possible saveload window and delete any newgrf dialogue as its widget parts might change.
Definition of the configuration tables of the settings.
GameSettings & GetGameSettings()
Get the settings-object applicable for the current situation: the newgame settings when we're in the ...
Base for ships.
void BuildLandLegend()
(Re)build the colour tables for the legends.
void BuildOwnerLegend()
Completes the array for the owned property legend.
void BuildLinkStatsLegend()
Populate legend table for the link stat view.
Smallmap GUI functions.
Base for all sound drivers.
void GfxClearSpriteCache()
Remove all encoded sprites from the sprite cache without discarding sprite location information.
Base classes/functions for stations.
void UpdateAirportsNoise()
Recalculate the noise generated by the airports of each town.
Functions related to stations.
Definition of base types and functions in a cross-platform compatible way.
EncodedString GetEncodedString(StringID str)
Encode a string with no parameters into an encoded string.
Definition strings.cpp:90
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
Base class for all station-ish types.
CompanySettings company
default values for per-company settings
VehicleDefaultSettings vehicle
default settings for vehicles
TownFounding found_town
town founding.
TimekeepingUnits timekeeping_units
time units to use for the game economy, either calendar or wallclock
bool station_noise_level
build new airports when the town noise level is still within accepted limits
uint16_t minutes_per_calendar_year
minutes per calendar year. Special value 0 means that calendar time is frozen.
static bool ResetToCurrentNewGRFConfig()
Tries to reset the engine mapping to match the current NewGRF configuration.
Definition engine.cpp:588
EconomySettings economy
settings to change the economy
VehicleSettings vehicle
options for vehicles
Base integer type, including boolean, settings.
StringID str_help
(Translated) string with help text; gui only.
StringID str_val
(Translated) first string describing the value.
int32_t def
default value given when none is present
StringID str
(translated) string with descriptive text; gui and console
Size related data of the map.
Definition map_func.h:206
static uint SizeX()
Get the size of the map along the X.
Definition map_func.h:272
static uint SizeY()
Get the size of the map along the Y.
Definition map_func.h:281
static uint MaxY()
Gets the maximum Y coordinate within the map, including MP_VOID.
Definition map_func.h:308
static uint MaxX()
Gets the maximum X coordinate within the map, including MP_VOID.
Definition map_func.h:299
static std::optional< uint32_t > ParseSingleValue(std::string_view str, std::span< const std::string_view > many)
Find the index value of a ONEofMANY type in a string.
Definition settings.cpp:188
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
static Titem * Get(auto index)
Returns Titem with given index.
static bool IsValidID(auto index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
Buses, trucks and trams belong to this class.
Definition roadveh.h:98
All ships have this type.
Definition ship.h:32
static Pool::IterateWrapper< T > Iterate(size_t from=0)
Returns an iterable ensemble of all valid vehicles of type T.
static void RecomputeCatchmentForAll()
Recomputes catchment of all stations.
Definition station.cpp:534
Templated helper to make a type-safe 'typedef' representing a single POD value.
'Train' is either a loco or a wagon.
Definition train.h:91
Default settings for vehicles.
uint16_t servint_aircraft
service interval for aircraft
uint16_t servint_roadveh
service interval for road vehicles
uint16_t servint_ships
service interval for ships
bool servint_ispercent
service intervals are in percents
uint16_t servint_trains
service interval for trains
uint8_t roadveh_acceleration_model
realistic acceleration for road vehicles
Vehicle data structure.
Stuff related to the text buffer GUI.
static bool IsTileType(Tile tile, TileType type)
Checks if a tile is a given tiletype.
Definition tile_map.h:150
static uint TileHeight(Tile tile)
Returns the height of a tile.
Definition tile_map.h:29
void SetTileType(Tile tile, TileType type)
Set the type of a tile.
Definition tile_map.h:131
void SetTileHeight(Tile tile, uint height)
Sets the height of a tile.
Definition tile_map.h:57
@ MP_WATER
Water tile.
Definition tile_type.h:54
Definition of the game-calendar-timer.
Base of the town class.
@ TF_FORBIDDEN
Forbidden.
Definition town_type.h:105
Base for the train class.
static constexpr ConsistChangeFlags CCF_TRACK
Valid changes while vehicle is driving, and possibly changing tracks.
Definition train.h:52
Functions related to vehicles.
VehicleType
Available vehicle types.
@ VEH_ROAD
Road vehicle type.
@ VEH_AIRCRAFT
Aircraft vehicle type.
@ VEH_SHIP
Ship vehicle type.
@ VEH_TRAIN
Train vehicle type.
Base of all video drivers.
Functions related to (drawing on) viewports.
Map accessors for void tiles.
void MakeVoid(Tile t)
Make a nice void tile ;)
Definition void_map.h:19
int PositionStatusbar(Window *w)
(Re)position statusbar window at the screen.
Definition window.cpp:3483
void CloseWindowById(WindowClass cls, WindowNumber number, bool force, int data)
Close a window by its class and window number (if it is open).
Definition window.cpp:1195
int PositionMainToolbar(Window *w)
(Re)position main toolbar window at the screen.
Definition window.cpp:3472
int PositionNetworkChatWindow(Window *w)
(Re)position network chat window at the screen.
Definition window.cpp:3505
void ReInitAllWindows(bool zoom_changed)
Re-initialize all windows.
Definition window.cpp:3417
void CloseWindowByClass(WindowClass cls, int data)
Close all windows of a given class.
Definition window.cpp:1207
int PositionNewsMessage(Window *w)
(Re)position news message window at the screen.
Definition window.cpp:3494
void SetWindowClassesDirty(WindowClass cls)
Mark all windows of a particular class as dirty (in need of repainting)
Definition window.cpp:3208
void InvalidateWindowData(WindowClass cls, WindowNumber number, int data, bool gui_scope)
Mark window data of the window of a given class and specific window number as invalid (in need of re-...
Definition window.cpp:3300
void InvalidateWindowClassesData(WindowClass cls, int data, bool gui_scope)
Mark window data of all windows of a given class as invalid (in need of re-computing) Note that by de...
Definition window.cpp:3318
Window functions not directly related to making/drawing windows.
@ WC_BUILD_STATION
Build station; Window numbers:
@ WC_SPRITE_ALIGNER
Sprite aligner (debug); Window numbers:
@ WC_COMPANY_COLOUR
Company colour selection; Window numbers:
@ WC_FOUND_TOWN
Found a town; Window numbers:
@ WC_BUILD_TOOLBAR
Build toolbar; Window numbers:
Definition window_type.h:78
@ WC_SELECT_STATION
Select station (when joining stations); Window numbers:
@ WC_ENGINE_PREVIEW
Engine preview window; Window numbers:
@ WC_CLIENT_LIST
Client list; Window numbers:
@ WC_TOWN_VIEW
Town view; Window numbers:
@ WC_GAME_OPTIONS
Game options window; Window numbers:
@ WC_SMALLMAP
Small map; Window numbers:
@ WC_SAVELOAD
Saveload window; Window numbers:
@ WC_VEHICLE_DETAILS
Vehicle details; Window numbers:
@ WC_BUILD_VEHICLE
Build vehicle; Window numbers: