25#if defined(WITH_FREETYPE) || defined(_WIN32) || defined(WITH_COCOA)
26#define HAS_TRUETYPE_FONT
56#include "table/strings.h"
57#include "table/settings.h"
61SettingTable _company_settings{ _company_settings_table };
62SettingTable _currency_settings{ _currency_settings_table };
63SettingTable _difficulty_settings{ _difficulty_settings_table };
64SettingTable _multimedia_settings{ _multimedia_settings_table };
65SettingTable _economy_settings{ _economy_settings_table };
66SettingTable _game_settings{ _game_settings_table };
67SettingTable _gui_settings{ _gui_settings_table };
68SettingTable _linkgraph_settings{ _linkgraph_settings_table };
69SettingTable _locale_settings{ _locale_settings_table };
70SettingTable _misc_settings{ _misc_settings_table };
71SettingTable _network_private_settings{ _network_private_settings_table };
72SettingTable _network_secrets_settings{ _network_secrets_settings_table };
73SettingTable _network_settings{ _network_settings_table };
74SettingTable _news_display_settings{ _news_display_settings_table };
75SettingTable _old_gameopt_settings{ _old_gameopt_settings_table };
76SettingTable _pathfinding_settings{ _pathfinding_settings_table };
77SettingTable _script_settings{ _script_settings_table };
78SettingTable _window_settings{ _window_settings_table };
79SettingTable _world_settings{ _world_settings_table };
80#if defined(_WIN32) && !defined(DEDICATED)
81SettingTable _win32_settings{ _win32_settings_table };
104 case 0: val = STR_CONFIG_SETTING_LOCALISATION_UNITS_VELOCITY_IMPERIAL;
break;
105 case 1: val = STR_CONFIG_SETTING_LOCALISATION_UNITS_VELOCITY_METRIC;
break;
106 case 2: val = STR_CONFIG_SETTING_LOCALISATION_UNITS_VELOCITY_SI;
break;
107 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;
108 case 4: val = STR_CONFIG_SETTING_LOCALISATION_UNITS_VELOCITY_KNOTS;
break;
109 default: NOT_REACHED();
117 return {sd.
str_val + ((value >= 0) ? 1 : 0),
abs(value)};
152 if (_game_mode != GM_MENU) {
176static void StationSpreadChanged(int32_t)
182static void UpdateConsists(int32_t)
186 if (t->IsFrontEngine() || t->IsFreeWagon()) t->ConsistChanged(
CCF_TRACK);
197 bool update_vehicles;
201 update_vehicles =
false;
204 update_vehicles =
true;
207 if (new_value != 0) {
227 if (update_vehicles) {
230 if (v->owner ==
_current_company && v->IsPrimaryVehicle() && !v->ServiceIntervalIsCustom()) {
232 v->SetServiceIntervalIsPercent(new_value != 0);
240static bool CanUpdateServiceInterval(
VehicleType, int32_t &new_value)
251 return new_value == 0 || interval == new_value;
254static void UpdateServiceInterval(
VehicleType type, int32_t new_value)
258 if (v->owner ==
_current_company && v->type == type && v->IsPrimaryVehicle() && !v->ServiceIntervalIsCustom()) {
259 v->SetServiceInterval(new_value);
286 case VEH_TRAIN:
return DEF_SERVINT_MINUTES_TRAINS;
287 case VEH_ROAD:
return DEF_SERVINT_MINUTES_ROADVEH;
289 case VEH_SHIP:
return DEF_SERVINT_MINUTES_SHIPS;
290 default: NOT_REACHED();
297static std::tuple<int32_t, uint32_t> GetServiceIntervalRange(
const IntSettingDesc &)
309 return { MIN_SERVINT_MINUTES, MAX_SERVINT_MINUTES };
312 return { MIN_SERVINT_DAYS, MAX_SERVINT_DAYS };
315static void TrainAccelerationModelChanged(int32_t)
318 if (t->IsFrontEngine()) {
319 t->tcache.cached_max_curve_speed = t->GetCurveSpeedLimit();
320 t->UpdateAcceleration();
336 if (t->IsFrontEngine()) t->CargoChanged();
345 if (
_settings_game.vehicle.roadveh_acceleration_model != AM_ORIGINAL) {
347 if (rv->IsFrontEngine()) {
365 if (rv->IsFrontEngine()) rv->CargoChanged();
375 v->acache.cached_max_range =
Engine::Get(v->engine_type)->GetRange();
376 v->acache.cached_max_range_sqr = v->acache.cached_max_range * v->acache.cached_max_range;
387static void TownFoundingChanged(int32_t)
396static void ZoomMinMaxChanged(int32_t)
398 ConstrainAllViewportsZoom();
406static void SpriteZoomMinChanged(int32_t)
425static void InvalidateCompanyLiveryWindow(int32_t)
428 ResetVehicleColourMap();
431static void DifficultyNoiseChange(int32_t)
433 if (_game_mode == GM_NORMAL) {
441static void MaxNoAIsChange(int32_t)
471 static constexpr std::initializer_list<std::string_view> _old_landscape_values{
"normal"sv,
"hilly"sv,
"desert"sv,
"candy"sv};
475static bool CheckFreeformEdges(int32_t &new_value)
477 if (_game_mode == GM_MENU)
return true;
478 if (new_value != 0) {
481 if (
TileX(s->tile) == 0 ||
TileY(s->tile) == 0) {
488 if (st->IsInUse() && (
TileX(st->xy) == 0 ||
TileY(st->xy) == 0)) {
522static void UpdateFreeformEdges(int32_t new_value)
524 if (_game_mode == GM_MENU)
return;
526 if (new_value != 0) {
550 if (_game_mode == GM_MENU)
return true;
560static bool CheckMaxHeightLevel(int32_t &new_value)
562 if (_game_mode == GM_NORMAL)
return false;
563 if (_game_mode != GM_EDITOR)
return true;
578static void StationCatchmentChanged(int32_t)
584static void MaxVehiclesChanged(int32_t)
597 if (newval ==
"*") newval.clear();
625 _settings_newgame.economy.minutes_per_calendar_year = CalendarTime::DEF_MINUTES_PER_YEAR;
631 if (_game_mode == GM_EDITOR) {
638 new_economy_date_fract = 0;
661 if (new_value < CalendarTime::DEF_MINUTES_PER_YEAR) {
665 if (new_value == 1) {
666 clamped = CalendarTime::DEF_MINUTES_PER_YEAR;
668 clamped = CalendarTime::FROZEN_MINUTES_PER_YEAR;
672 if (_game_mode == GM_MENU) {
682 if (_game_mode == GM_MENU && (
_settings_newgame.economy.minutes_per_calendar_year != CalendarTime::DEF_MINUTES_PER_YEAR)) {
683 if (
_settings_newgame.economy.timekeeping_units != TimekeepingUnits::Wallclock) {
691static std::tuple<int32_t, uint32_t> GetMinutesPerYearRange(
const IntSettingDesc &)
696 return { CalendarTime::DEF_MINUTES_PER_YEAR, CalendarTime::DEF_MINUTES_PER_YEAR };
Base functions for all AIs.
AIConfig stores the configuration settings of every AI.
@ DestinationTooFar
Next destination is too far away.
Command definitions related to aircraft.
static const ScriptInfoList * GetInfoList()
Get the list of all registered scripts.
static constexpr int MAX_MINUTES_PER_YEAR
One week of real time. The actual max that doesn't overflow TimerGameCalendar::sub_date_fract is 1062...
static LinkGraphSchedule instance
Static instance of LinkGraphSchedule.
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.
StrongType::Typedef< int32_t, struct YearTag< struct Economy >, StrongType::Compare, StrongType::Integer > Year
StrongType::Typedef< int32_t, DateTag< struct Economy >, StrongType::Compare, StrongType::Integer > Date
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).
@ WL_CRITICAL
Critical errors, the MessageBox is shown in all cases.
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.
void MarkWholeScreenDirty()
This function mark the whole screen as dirty.
Declaration of link graph schedule used for cargo distribution.
static TileIndex TileXY(uint x, uint y)
Returns the TileIndex of a coordinate.
static uint TileY(TileIndex tile)
Get the Y component of a tile.
static uint TileX(TileIndex tile)
Get the X component of a tile.
constexpr T abs(const T a)
Returns the absolute value of (scalar) variable.
Base for all music playback.
bool _networking
are we in networking mode?
bool _network_server
network-server is active
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.
void DeleteVehicleNews(VehicleID vid, AdviceType advice_type=AdviceType::Invalid)
Delete news with a given advice type about a vehicle.
@ AircraftDestinationTooFar
Next (order) destination is too far for the aircraft type.
uint16_t GetServiceIntervalClamped(int interval, bool ispercent)
Clamp the service interval to the correct min/max.
General types related to pathfinders.
bool RoadVehiclesAreBuilt()
Verify whether a road vehicle is available.
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.
GameSettings _settings_newgame
Game settings for new games (updated from the intro screen).
ClientSettings _settings_client
The current settings for this game.
static void ChangeTimekeepingUnits()
Callback for when the player changes the timekeeping units.
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 bool CheckDynamicEngines(int32_t &value)
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 AircraftRangeChanged(int32_t)
This function updates the aircraft cache when the aircraft range setting is 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 std::pair< StringParameter, StringParameter > SettingsValueVelocityUnit(const IntSettingDesc &sd, int32_t value)
Setting values for velocity unit localisation.
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 ...
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.
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.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
Aircraft, helicopters, rotors and their shadows belong to this class.
Base class for all station-ish types.
static bool ResetToCurrentNewGRFConfig()
Tries to reset the engine mapping to match the current NewGRF configuration.
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
static uint SizeX()
Get the size of the map along the X.
static uint SizeY()
Get the size of the map along the Y.
static IterateWrapper Iterate()
Returns an iterable ensemble of all Tiles.
static uint MaxY()
Gets the maximum Y coordinate within the map, including TileType::Void.
static uint MaxX()
Gets the maximum X coordinate within the map, including TileType::Void.
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.
static Pool::IterateWrapper< Vehicle > Iterate(size_t from=0)
static Company * Get(auto index)
static bool IsValidID(auto index)
Buses, trucks and trams belong to this class.
All ships have this type.
static void RecomputeCatchmentForAll()
Recomputes catchment of all stations.
'Train' is either a loco or a wagon.
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
Stuff related to the text buffer GUI.
static bool IsTileType(Tile tile, TileType type)
Checks if a tile is a given tiletype.
static uint TileHeight(Tile tile)
Returns the height of a tile.
void SetTileType(Tile tile, TileType type)
Set the type of a tile.
void SetTileHeight(Tile tile, uint height)
Sets the height of a tile.
Definition of the game-calendar-timer.
Base for the train class.
static constexpr ConsistChangeFlags CCF_TRACK
Valid changes while vehicle is driving, and possibly changing tracks.
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 ;).
int PositionStatusbar(Window *w)
(Re)position statusbar window at the screen.
void CloseWindowById(WindowClass cls, WindowNumber number, bool force, int data)
Close a window by its class and window number (if it is open).
int PositionMainToolbar(Window *w)
(Re)position main toolbar window at the screen.
int PositionNetworkChatWindow(Window *w)
(Re)position network chat window at the screen.
void ReInitAllWindows(bool zoom_changed)
Re-initialize all windows.
void CloseWindowByClass(WindowClass cls, int data)
Close all windows of a given class.
int PositionNewsMessage(Window *w)
(Re)position news message window at the screen.
void SetWindowClassesDirty(WindowClass cls)
Mark all windows of a particular class as dirty (in need of repainting).
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-...
void SetWindowWidgetDirty(WindowClass cls, WindowNumber number, WidgetID widget_index)
Mark a particular widget in a particular window as dirty (in need of repainting).
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...
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:
@ 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_VEHICLE_VIEW
Vehicle view; Window numbers:
@ WC_BUILD_VEHICLE
Build vehicle; Window numbers: