|
OpenTTD
|
All actions handling saving and loading of the settings/configuration goes on in this file. More...
#include "stdafx.h"#include "currency.h"#include "screenshot.h"#include "network/network.h"#include "network/network_func.h"#include "settings_internal.h"#include "command_func.h"#include "console_func.h"#include "pathfinder/pathfinder_type.h"#include "genworld.h"#include "train.h"#include "news_func.h"#include "window_func.h"#include "sound_func.h"#include "company_func.h"#include "rev.h"#include "fontcache.h"#include "textbuf_gui.h"#include "rail_gui.h"#include "elrail_func.h"#include "error.h"#include "town.h"#include "video/video_driver.hpp"#include "sound/sound_driver.hpp"#include "music/music_driver.hpp"#include "blitter/factory.hpp"#include "base_media_base.h"#include "gamelog.h"#include "settings_func.h"#include "ini_type.h"#include "ai/ai_config.hpp"#include "ai/ai.hpp"#include "game/game_config.hpp"#include "game/game.hpp"#include "ship.h"#include "smallmap_gui.h"#include "roadveh.h"#include "fios.h"#include "strings_func.h"#include "void_map.h"#include "station_base.h"#include "table/strings.h"#include "table/settings.h"#include "safeguards.h"Go to the source code of this file.
Typedefs | |
| typedef std::list< ErrorMessageData > | ErrorList |
| typedef void | SettingDescProc(IniFile *ini, const SettingDesc *desc, const char *grpname, void *object) |
| typedef void | SettingDescProcList(IniFile *ini, const char *grpname, StringList *list) |
Functions | |
| static bool | IsSignedVarMemType (VarType vt) |
| static size_t | LookupOneOfMany (const char *many, const char *one, size_t onelen=0) |
| Find the index value of a ONEofMANY type in a string separated by |. More... | |
| static size_t | LookupManyOfMany (const char *many, const char *str) |
| Find the set-integer value MANYofMANY type in a string. More... | |
| static int | ParseIntList (const char *p, int *items, int maxitems) |
| Parse an integerlist string and set each found value. More... | |
| static bool | LoadIntList (const char *str, void *array, int nelems, VarType type) |
| Load parsed string-values into an integer-array (intlist) More... | |
| static void | MakeIntList (char *buf, const char *last, const void *array, int nelems, VarType type) |
| Convert an integer-array (intlist) to a string representation. More... | |
| static void | MakeOneOfMany (char *buf, const char *last, const char *many, int id) |
| Convert a ONEofMANY structure to a string representation. More... | |
| static void | MakeManyOfMany (char *buf, const char *last, const char *many, uint32 x) |
| Convert a MANYofMANY structure to a string representation. More... | |
| static const void * | StringToVal (const SettingDescBase *desc, const char *orig_str) |
| Convert a string representation (external) of a setting to the internal rep. More... | |
| static void | Write_ValidateSetting (void *ptr, const SettingDesc *sd, int32 val) |
| Set the value of a setting and if needed clamp the value to the preset minimum and maximum. More... | |
| static void | IniLoadSettings (IniFile *ini, const SettingDesc *sd, const char *grpname, void *object) |
| Load values from a group of an IniFile structure into the internal representation. More... | |
| static void | IniSaveSettings (IniFile *ini, const SettingDesc *sd, const char *grpname, void *object) |
| Save the values of settings to the inifile. More... | |
| static void | IniLoadSettingList (IniFile *ini, const char *grpname, StringList *list) |
| Loads all items from a 'grpname' section into a list The list parameter can be a NULL pointer, in this case nothing will be saved and a callback function should be defined that will take over the list-handling and store the data itself somewhere. More... | |
| static void | IniSaveSettingList (IniFile *ini, const char *grpname, StringList *list) |
| Saves all items from a list into the 'grpname' section The list parameter can be a NULL pointer, in this case a callback function should be defined that will provide the source data to be saved. More... | |
| void | IniLoadWindowSettings (IniFile *ini, const char *grpname, void *desc) |
| Load a WindowDesc from config. More... | |
| void | IniSaveWindowSettings (IniFile *ini, const char *grpname, void *desc) |
| Save a WindowDesc to config. More... | |
| static bool | v_PositionMainToolbar (int32 p1) |
| Reposition the main toolbar as the setting changed. More... | |
| static bool | v_PositionStatusbar (int32 p1) |
| Reposition the statusbar as the setting changed. More... | |
| static bool | PopulationInLabelActive (int32 p1) |
| static bool | RedrawScreen (int32 p1) |
| static bool | RedrawSmallmap (int32 p1) |
| Redraw the smallmap after a colour scheme change. More... | |
| static bool | InvalidateDetailsWindow (int32 p1) |
| static bool | StationSpreadChanged (int32 p1) |
| static bool | InvalidateBuildIndustryWindow (int32 p1) |
| static bool | CloseSignalGUI (int32 p1) |
| static bool | InvalidateTownViewWindow (int32 p1) |
| static bool | DeleteSelectStationWindow (int32 p1) |
| static bool | UpdateConsists (int32 p1) |
| static bool | CheckInterval (int32 p1) |
| static bool | UpdateInterval (VehicleType type, int32 p1) |
| static bool | UpdateIntervalTrains (int32 p1) |
| static bool | UpdateIntervalRoadVeh (int32 p1) |
| static bool | UpdateIntervalShips (int32 p1) |
| static bool | UpdateIntervalAircraft (int32 p1) |
| static bool | TrainAccelerationModelChanged (int32 p1) |
| static bool | TrainSlopeSteepnessChanged (int32 p1) |
| This function updates the train acceleration cache after a steepness change. More... | |
| static bool | RoadVehAccelerationModelChanged (int32 p1) |
| This function updates realistic acceleration caches when the setting "Road vehicle acceleration model" is set. More... | |
| static bool | RoadVehSlopeSteepnessChanged (int32 p1) |
| This function updates the road vehicle acceleration cache after a steepness change. More... | |
| static bool | DragSignalsDensityChanged (int32) |
| static bool | TownFoundingChanged (int32 p1) |
| static bool | InvalidateVehTimetableWindow (int32 p1) |
| static bool | ZoomMinMaxChanged (int32 p1) |
| static bool | InvalidateNewGRFChangeWindows (int32 p1) |
| Update any possible saveload window and delete any newgrf dialogue as its widget parts might change. More... | |
| static bool | InvalidateCompanyLiveryWindow (int32 p1) |
| static bool | InvalidateIndustryViewWindow (int32 p1) |
| static bool | InvalidateAISettingsWindow (int32 p1) |
| static bool | RedrawTownAuthority (int32 p1) |
| Update the town authority window after a town authority setting change. More... | |
| static bool | InvalidateCompanyInfrastructureWindow (int32 p1) |
| Invalidate the company infrastructure details window after a infrastructure maintenance setting change. More... | |
| static bool | InvalidateCompanyWindow (int32 p1) |
| Invalidate the company details window after the shares setting changed. More... | |
| static void | ValidateSettings () |
| Checks if any settings are set to incorrect values, and sets them to correct values in that case. More... | |
| static bool | DifficultyNoiseChange (int32 i) |
| static bool | MaxNoAIsChange (int32 i) |
| static bool | CheckRoadSide (int p1) |
| Check whether the road side may be changed. More... | |
| static size_t | ConvertLandscape (const char *value) |
| Conversion callback for _gameopt_settings_game.landscape It converts (or try) between old values and the new ones, without losing initial setting of the user. More... | |
| static bool | CheckFreeformEdges (int32 p1) |
| static bool | ChangeDynamicEngines (int32 p1) |
| Changing the setting "allow multiple NewGRF sets" is not allowed if there are vehicles. | |
| static bool | ChangeMaxHeightLevel (int32 p1) |
| static bool | StationCatchmentChanged (int32 p1) |
| static bool | MaxVehiclesChanged (int32 p1) |
| static bool | InvalidateShipPathCache (int32 p1) |
| static bool | UpdateClientName (int32 p1) |
| static bool | UpdateServerPassword (int32 p1) |
| static bool | UpdateRconPassword (int32 p1) |
| static bool | UpdateClientConfigValues (int32 p1) |
| static void | PrepareOldDiffCustom () |
| Prepare for reading and old diff_custom by zero-ing the memory. | |
| static void | HandleOldDiffCustom (bool savegame) |
| Reading of the old diff_custom array and transforming it to the new format. More... | |
| static void | AILoadConfig (IniFile *ini, const char *grpname) |
| static void | GameLoadConfig (IniFile *ini, const char *grpname) |
| static int | DecodeHexNibble (char c) |
Convert a character to a hex nibble value, or -1 otherwise. More... | |
| static bool | DecodeHexText (char *pos, uint8 *dest, size_t dest_size) |
| Parse a sequence of characters (supposedly hex digits) into a sequence of bytes. More... | |
| static GRFConfig * | GRFLoadConfig (IniFile *ini, const char *grpname, bool is_static) |
| Load a GRF configuration. More... | |
| static void | AISaveConfig (IniFile *ini, const char *grpname) |
| static void | GameSaveConfig (IniFile *ini, const char *grpname) |
| static void | SaveVersionInConfig (IniFile *ini) |
| Save the version of OpenTTD to the ini file. More... | |
| static void | GRFSaveConfig (IniFile *ini, const char *grpname, const GRFConfig *list) |
| static void | HandleSettingDescs (IniFile *ini, SettingDescProc *proc, SettingDescProcList *proc_list, bool basic_settings=true, bool other_settings=true) |
| static IniFile * | IniLoadConfig () |
| void | LoadFromConfig (bool minimal) |
| Load the values from the configuration files. More... | |
| void | SaveToConfig () |
| Save the values to the configuration file. | |
| void | GetGRFPresetList (GRFPresetList *list) |
| Get the list of known NewGrf presets. More... | |
| GRFConfig * | LoadGRFPresetFromConfig (const char *config_name) |
| Load a NewGRF configuration by preset-name. More... | |
| void | SaveGRFPresetToConfig (const char *config_name, GRFConfig *config) |
| Save a NewGRF configuration with a preset name. More... | |
| void | DeleteGRFPresetFromConfig (const char *config_name) |
| Delete a NewGRF configuration by preset name. More... | |
| const SettingDesc * | GetSettingDescription (uint index) |
| CommandCost | CmdChangeSetting (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) |
| Network-safe changing of settings (server-only). More... | |
| CommandCost | CmdChangeCompanySetting (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) |
| Change one of the per-company settings. More... | |
| bool | SetSettingValue (uint index, int32 value, bool force_newgame) |
| Top function to save the new value of an element of the Settings struct. More... | |
| void | SetCompanySetting (uint index, int32 value) |
| Top function to save the new value of an element of the Settings struct. More... | |
| void | SetDefaultCompanySettings (CompanyID cid) |
| Set the company settings for a new company to their default values. | |
| void | SyncCompanySettings () |
| Sync all company settings in a multiplayer game. | |
| uint | GetCompanySettingIndex (const char *name) |
| Get the index in the _company_settings array of a setting. More... | |
| bool | SetSettingValue (uint index, const char *value, bool force_newgame) |
| Set a setting value with a string. More... | |
| const SettingDesc * | GetSettingFromName (const char *name, uint *i) |
| Given a name of setting, return a setting description of it. More... | |
| void | IConsoleSetSetting (const char *name, const char *value, bool force_newgame) |
| void | IConsoleSetSetting (const char *name, int value) |
| void | IConsoleGetSetting (const char *name, bool force_newgame) |
| Output value of a specific setting to the console. More... | |
| void | IConsoleListSettings (const char *prefilter) |
| List all settings and their value to the console. More... | |
| static void | LoadSettings (const SettingDesc *osd, void *object) |
| Save and load handler for settings. More... | |
| static void | SaveSettings (const SettingDesc *sd, void *object) |
| Save and load handler for settings. More... | |
| static void | Load_OPTS () |
| static void | Load_PATS () |
| static void | Check_PATS () |
| static void | Save_PATS () |
| void | CheckConfig () |
Variables | |
| ClientSettings | _settings_client |
| The current settings for this game. More... | |
| GameSettings | _settings_game |
| Game settings of a running game or the scenario editor. More... | |
| GameSettings | _settings_newgame |
| Game settings for new games (updated from the intro screen). More... | |
| VehicleDefaultSettings | _old_vds |
| Used for loading default vehicles settings from old savegames. More... | |
| char * | _config_file |
| Configuration file of OpenTTD. | |
| static ErrorList | _settings_error_list |
| Errors while loading minimal settings. | |
| static const char *const | _list_group_names [] |
| Groups in openttd.cfg that are actually lists. More... | |
| const ChunkHandler | _setting_chunk_handlers [] |
All actions handling saving and loading of the settings/configuration goes on in this file.
The file consists of three parts:
Definition in file settings.cpp.
|
static |
Check whether the road side may be changed.
| p1 | unused |
Definition at line 1186 of file settings.cpp.
References RoadVehiclesAreBuilt().
| CommandCost CmdChangeCompanySetting | ( | TileIndex | tile, |
| DoCommandFlag | flags, | ||
| uint32 | p1, | ||
| uint32 | p2, | ||
| const char * | text | ||
| ) |
Change one of the per-company settings.
| tile | unused |
| flags | operation to perform |
| p1 | the index of the setting in the _company_settings array which identifies it |
| p2 | the new value for the setting The new value is properly clamped to its minimum/maximum when setting |
| text | unused |
Definition at line 1895 of file settings.cpp.
References _current_company, CMD_ERROR, DC_EXEC, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Get(), GetVariableAddress(), lengthof, SettingDesc::save, and settings.
| CommandCost CmdChangeSetting | ( | TileIndex | tile, |
| DoCommandFlag | flags, | ||
| uint32 | p1, | ||
| uint32 | p2, | ||
| const char * | text | ||
| ) |
Network-safe changing of settings (server-only).
| tile | unused |
| flags | operation to perform |
| p1 | the index of the setting in the SettingDesc array which identifies it |
| p2 | the new value for the setting The new value is properly clamped to its minimum/maximum when setting |
| text | unused |
Definition at line 1848 of file settings.cpp.
|
static |
Conversion callback for _gameopt_settings_game.landscape It converts (or try) between old values and the new ones, without losing initial setting of the user.
| value | that was read from config file |
Definition at line 1199 of file settings.cpp.
References LookupOneOfMany().
|
static |
Convert a character to a hex nibble value, or -1 otherwise.
| c | Character to convert. |
-1 if not a hex digit. Definition at line 1460 of file settings.cpp.
Referenced by DecodeHexText().
|
static |
Parse a sequence of characters (supposedly hex digits) into a sequence of bytes.
After the hex number should be a '|' character.
| pos | First character to convert. | |
| [out] | dest | Output byte array to write the bytes. |
| dest_size | Number of bytes in dest. |
Definition at line 1476 of file settings.cpp.
References DecodeHexNibble().
Referenced by GRFLoadConfig().
| void DeleteGRFPresetFromConfig | ( | const char * | config_name | ) |
Delete a NewGRF configuration by preset name.
| config_name | Name of the preset. |
Definition at line 1819 of file settings.cpp.
References seprintf().
| uint GetCompanySettingIndex | ( | const char * | name | ) |
Get the index in the _company_settings array of a setting.
| name | The name of the setting |
Definition at line 2018 of file settings.cpp.
References GetSettingFromName().
Referenced by ReplaceVehicleWindow::OnClick().
| void GetGRFPresetList | ( | GRFPresetList * | list | ) |
Get the list of known NewGrf presets.
| [in,out] | list | Pointer to list for storing the preset names. |
Definition at line 1763 of file settings.cpp.
References AutoFreeSmallVector< T, S >::Clear().
Referenced by NewGRFWindow::OnQueryTextFinished(), and SavePresetWindow::SavePresetWindow().
| const SettingDesc* GetSettingFromName | ( | const char * | name, |
| uint * | i | ||
| ) |
Given a name of setting, return a setting description of it.
| name | Name of the setting to return a setting description of |
| i | Pointer to an integer that will contain the index of the setting after the call, if it is successful. |
NULL indicates failure to obtain the description Definition at line 2058 of file settings.cpp.
References SaveLoad::cmd, and SettingDesc::save.
Referenced by GetCompanySettingIndex(), NewsTypeData::GetDisplay(), IConsoleGetSetting(), SettingEntry::Init(), and GameOptionsWindow::OnDropdownSelect().
Load a GRF configuration.
| ini | The configuration to read from. |
| grpname | Group name containing the configuration of the GRF. |
| is_static | GRF is static. |
Definition at line 1495 of file settings.cpp.
References DecodeHexText(), FGCM_EXACT, FGCM_NEWEST_VALID, GRFConfig::filename, FillGRFDetails(), FindGRFConfig(), FioCheckFileExists(), GRFConfig::flags, GCF_INVALID, GCF_STATIC, GCF_SYSTEM, GCF_UNSAFE, GCS_NOT_FOUND, IniLoadFile::GetGroup(), GRFIdentifier::grfid, HasBit(), GRFConfig::ident, IniGroup::item, lengthof, IniItem::name, NEWGRF_DIR, IniItem::next, GRFConfig::next, GRFConfig::num_params, GRFConfig::param, ParseIntList(), SetBit(), SetDParam(), SetDParamStr(), ShowErrorMessage(), GRFConfig::status, StrEmpty(), IniItem::value, and WL_CRITICAL.
|
static |
Reading of the old diff_custom array and transforming it to the new format.
| savegame | is it read from the config or savegame. In the latter case we are sure there is an array; in the former case we have to check that. |
Definition at line 1378 of file settings.cpp.
References GetVariableAddress(), IsSavegameVersionBefore(), SettingDesc::save, SlIsObjectCurrentlyValid(), SLV_4, SaveLoad::version_from, SaveLoad::version_to, and Write_ValidateSetting().
| void IConsoleGetSetting | ( | const char * | name, |
| bool | force_newgame | ||
| ) |
Output value of a specific setting to the console.
| name | Name of the setting to output its value |
| force_newgame | force the newgame settings |
Definition at line 2137 of file settings.cpp.
References CC_WARNING, GetSettingFromName(), GetVariableAddress(), and IConsolePrintF().
| void IConsoleListSettings | ( | const char * | prefilter | ) |
List all settings and their value to the console.
| prefilter | If not NULL, only list settings with names that begin with prefilter prefix |
Definition at line 2170 of file settings.cpp.
References CC_WARNING, SaveLoad::cmd, IConsolePrintF(), and SettingDesc::save.
|
static |
Loads all items from a 'grpname' section into a list The list parameter can be a NULL pointer, in this case nothing will be saved and a callback function should be defined that will take over the list-handling and store the data itself somewhere.
| ini | IniFile handle to the ini file with the source data |
| grpname | character string identifying the section-header of the ini file that will be parsed |
| list | new list with entries of the given section |
Definition at line 704 of file settings.cpp.
References SmallVector< T, S >::Append(), AutoFreeSmallVector< T, S >::Clear(), IniLoadFile::GetGroup(), IniGroup::item, IniItem::next, and stredup().
|
static |
Load values from a group of an IniFile structure into the internal representation.
| ini | pointer to IniFile structure that holds administrative information |
| sd | pointer to SettingDesc structure whose internally pointed variables will be given values |
| grpname | the group of the IniFile to search in for the new values |
| object | pointer to the object been loaded |
Definition at line 477 of file settings.cpp.
References SaveLoad::cmd, IniLoadFile::GetGroup(), and SettingDesc::save.
Referenced by IniLoadWindowSettings().
| void IniLoadWindowSettings | ( | IniFile * | ini, |
| const char * | grpname, | ||
| void * | desc | ||
| ) |
Load a WindowDesc from config.
| ini | IniFile handle to the ini file with the source data |
| grpname | character string identifying the section-header of the ini file that will be parsed |
| desc | Destination WindowDesc |
Definition at line 744 of file settings.cpp.
References IniLoadSettings().
Referenced by WindowDesc::LoadFromConfig().
|
static |
Saves all items from a list into the 'grpname' section The list parameter can be a NULL pointer, in this case a callback function should be defined that will provide the source data to be saved.
| ini | IniFile handle to the ini file where the destination data is saved |
| grpname | character string identifying the section-header of the ini file |
| list | pointer to an string(pointer) array that will be used as the source to be saved into the relevant ini section |
Definition at line 726 of file settings.cpp.
References SmallVector< T, S >::Begin(), IniGroup::Clear(), SmallVector< T, S >::End(), IniLoadFile::GetGroup(), IniGroup::GetItem(), and IniItem::SetValue().
|
static |
Save the values of settings to the inifile.
| ini | pointer to IniFile structure |
| sd | read-only SettingDesc structure which contains the unmodified, loaded values of the configuration file and various information about it |
| grpname | holds the name of the group (eg. [network]) where these will be saved |
| object | pointer to the object been saved The function works as follows: for each item in the SettingDesc structure we have a look if the value has changed since we started the game (the original values are reloaded when saving). If settings indeed have changed, we get these and save them. |
Definition at line 575 of file settings.cpp.
References SaveLoad::cmd, and SettingDesc::save.
Referenced by IniSaveWindowSettings().
| void IniSaveWindowSettings | ( | IniFile * | ini, |
| const char * | grpname, | ||
| void * | desc | ||
| ) |
Save a WindowDesc to config.
| ini | IniFile handle to the ini file where the destination data is saved |
| grpname | character string identifying the section-header of the ini file |
| desc | Source WindowDesc |
Definition at line 755 of file settings.cpp.
References IniSaveSettings().
Referenced by WindowDesc::SaveToConfig().
|
static |
Invalidate the company infrastructure details window after a infrastructure maintenance setting change.
| p1 | Unused. |
Definition at line 1130 of file settings.cpp.
References InvalidateWindowClassesData(), and WC_COMPANY_INFRASTRUCTURE.
|
static |
Invalidate the company details window after the shares setting changed.
| p1 | Unused. |
Definition at line 1141 of file settings.cpp.
References InvalidateWindowClassesData(), and WC_COMPANY.
|
static |
Update any possible saveload window and delete any newgrf dialogue as its widget parts might change.
Reinit all windows as it allows access to the newgrf debug button.
| p1 | unused. |
Definition at line 1088 of file settings.cpp.
References DeleteWindowByClass(), InvalidateWindowClassesData(), ReInitAllWindows(), WC_GAME_OPTIONS, and WC_SAVELOAD.
| void LoadFromConfig | ( | bool | minimal | ) |
Load the values from the configuration files.
| minimal | Load the minimal amount of the configuration to "bootstrap" the blitter and such. |
Definition at line 1710 of file settings.cpp.
Referenced by AfterNewGRFScan::OnNewGRFsScanned().
| GRFConfig* LoadGRFPresetFromConfig | ( | const char * | config_name | ) |
Load a NewGRF configuration by preset-name.
| config_name | Name of the preset. |
Definition at line 1784 of file settings.cpp.
References seprintf().
Referenced by NewGRFWindow::OnDropdownSelect().
|
static |
Load parsed string-values into an integer-array (intlist)
| str | the string that contains the values (and will be parsed) |
| array | pointer to the integer-arrays that will be filled |
| nelems | the number of elements the array holds. Maximum is 64 elements |
| type | the type of elements the array holds (eg INT8, UINT16, etc.) |
Definition at line 216 of file settings.cpp.
References lengthof, and ParseIntList().
|
static |
Save and load handler for settings.
| osd | SettingDesc struct containing all information |
| object | can be either NULL in which case we load global variables or a pointer to a struct which is getting saved |
Definition at line 2199 of file settings.cpp.
References SaveLoad::cmd, and SettingDesc::save.
|
static |
Find the set-integer value MANYofMANY type in a string.
| many | full domain of values the MANYofMANY setting can have |
| str | the current string value of the setting, each individual of separated by a whitespace,tab or | character |
Definition at line 138 of file settings.cpp.
References LookupOneOfMany(), and SetBit().
Referenced by StringToVal().
|
static |
Find the index value of a ONEofMANY type in a string separated by |.
| many | full domain of values the ONEofMANY setting can have |
| one | the current value of the setting for which a value needs found |
| onelen | force calculation of the *one parameter |
Definition at line 109 of file settings.cpp.
Referenced by ConvertLandscape(), LookupManyOfMany(), and StringToVal().
|
static |
Convert an integer-array (intlist) to a string representation.
Each value is separated by a comma or a space character
| buf | output buffer where the string-representation will be stored |
| last | last item to write to in the output buffer |
| array | pointer to the integer-arrays that is read from |
| nelems | the number of elements the array holds. |
| type | the type of elements the array holds (eg INT8, UINT16, etc.) |
Definition at line 261 of file settings.cpp.
|
static |
Convert a MANYofMANY structure to a string representation.
| buf | output buffer where the string-representation will be stored |
| last | last item to write to in the output buffer |
| many | the full-domain string of possible values |
| x | the value of the variable and whose string-representation must be found in the bitmasked many string |
Definition at line 316 of file settings.cpp.
|
static |
Convert a ONEofMANY structure to a string representation.
| buf | output buffer where the string-representation will be stored |
| last | last item to write to in the output buffer |
| many | the full-domain string of possible values |
| id | the value of the variable and whose string-representation must be found |
Definition at line 288 of file settings.cpp.
References seprintf().
|
static |
Parse an integerlist string and set each found value.
| p | the string to be parsed. Each element in the list is separated by a comma or a space character |
| items | pointer to the integerlist-array that will be filled with values |
| maxitems | the maximum number of elements the integerlist-array has |
Definition at line 170 of file settings.cpp.
References ClampToI32().
Referenced by GRFLoadConfig(), and LoadIntList().
|
static |
Redraw the smallmap after a colour scheme change.
| p1 | Callback parameter. |
Definition at line 823 of file settings.cpp.
References BuildLandLegend(), BuildOwnerLegend(), SetWindowClassesDirty(), and WC_SMALLMAP.
|
static |
Update the town authority window after a town authority setting change.
| p1 | Unused. |
Definition at line 1119 of file settings.cpp.
References SetWindowClassesDirty(), and WC_TOWN_AUTHORITY.
|
static |
This function updates realistic acceleration caches when the setting "Road vehicle acceleration model" is set.
| p1 | Callback parameter |
Definition at line 1010 of file settings.cpp.
References VehicleSettings::roadveh_acceleration_model, and GameSettings::vehicle.
|
static |
This function updates the road vehicle acceleration cache after a steepness change.
| p1 | Callback parameter. |
Definition at line 1034 of file settings.cpp.
| void SaveGRFPresetToConfig | ( | const char * | config_name, |
| GRFConfig * | config | ||
| ) |
Save a NewGRF configuration with a preset name.
| config_name | Name of the preset. |
| config | NewGRF configuration to save. |
Definition at line 1803 of file settings.cpp.
References seprintf().
Referenced by NewGRFWindow::OnQueryTextFinished().
|
static |
Save and load handler for settings.
| sd | SettingDesc struct containing all information |
| object | can be either NULL in which case we load global variables or a pointer to a struct which is getting saved |
Definition at line 2216 of file settings.cpp.
References SaveLoad::cmd, and SettingDesc::save.
|
static |
Save the version of OpenTTD to the ini file.
| ini | the ini to write to |
Definition at line 1639 of file settings.cpp.
References IniLoadFile::GetGroup(), lastof, and seprintf().
| void SetCompanySetting | ( | uint | index, |
| int32 | value | ||
| ) |
Top function to save the new value of an element of the Settings struct.
| index | offset in the SettingDesc array of the CompanySettings struct which identifies the setting member we want to change |
| value | new value of the setting |
Definition at line 1970 of file settings.cpp.
References _local_company, and Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::IsValidID().
| bool SetSettingValue | ( | uint | index, |
| int32 | value, | ||
| bool | force_newgame | ||
| ) |
Top function to save the new value of an element of the Settings struct.
| index | offset in the SettingDesc array of the Settings struct which identifies the setting member we want to change |
| value | new value of the setting |
| force_newgame | force the newgame settings |
Definition at line 1929 of file settings.cpp.
References SaveLoad::conv, GetGameSettings(), GetVariableAddress(), SettingDesc::save, SLF_NO_NETWORK_SYNC, and Write_ValidateSetting().
| bool SetSettingValue | ( | uint | index, |
| const char * | value, | ||
| bool | force_newgame | ||
| ) |
Set a setting value with a string.
| index | the settings index. |
| value | the value to write |
| force_newgame | force the newgame settings |
Definition at line 2033 of file settings.cpp.
|
static |
Convert a string representation (external) of a setting to the internal rep.
| desc | SettingDesc struct that holds all information about the variable |
| orig_str | input string that will be parsed based on the type of desc |
Definition at line 349 of file settings.cpp.
References _settings_error_list, SettingDescBase::cmd, SettingDescBase::def, LookupManyOfMany(), LookupOneOfMany(), SettingDescBase::many, SettingDescBase::name, SettingDescBase::proc_cnvt, SDT_BOOLX, SDT_INTLIST, SDT_MANYOFMANY, SDT_NUMX, SDT_ONEOFMANY, SDT_STRING, and ErrorMessageData::SetDParamStr().
|
static |
This function updates the train acceleration cache after a steepness change.
| p1 | Callback parameter. |
Definition at line 995 of file settings.cpp.
|
static |
Reposition the main toolbar as the setting changed.
Definition at line 789 of file settings.cpp.
|
static |
Reposition the statusbar as the setting changed.
Definition at line 796 of file settings.cpp.
|
static |
Checks if any settings are set to incorrect values, and sets them to correct values in that case.
Definition at line 1148 of file settings.cpp.
References CUSTOM_SEA_LEVEL_MIN_PERCENTAGE, CUSTOM_SEA_LEVEL_NUMBER_DIFFICULTY, GameSettings::difficulty, GameSettings::game_creation, GameCreationSettings::land_generator, LG_ORIGINAL, and DifficultySettings::quantity_sea_lakes.
|
static |
Set the value of a setting and if needed clamp the value to the preset minimum and maximum.
| ptr | the variable itself |
| sd | pointer to the 'information'-database of the variable |
| val | signed long version of the new value |
Definition at line 424 of file settings.cpp.
References SettingDescBase::cmd, SaveLoad::conv, SettingDesc::desc, GetVarMemType(), SettingDesc::save, SDT_BOOLX, SDT_MANYOFMANY, SDT_NUMX, SDT_ONEOFMANY, and SLE_VAR_NULL.
Referenced by HandleOldDiffCustom(), and SetSettingValue().
|
static |
Groups in openttd.cfg that are actually lists.
Definition at line 94 of file settings.cpp.
| VehicleDefaultSettings _old_vds |
Used for loading default vehicles settings from old savegames.
Old vehicle settings, which were game settings before, and are company settings now.
Definition at line 79 of file settings.cpp.
| const ChunkHandler _setting_chunk_handlers[] |
| ClientSettings _settings_client |
The current settings for this game.
Definition at line 76 of file settings.cpp.
Referenced by AIDebugWindow::AIDebugWindow(), ServerNetworkAdminSocketHandler::AllowConnection(), ServerNetworkGameSocketHandler::AllowConnection(), BuildAirportWindow::BuildAirportClassDropDown(), BuildLandLegend(), BuildOwnerLegend(), MusicSystem::BuildPlaylists(), BuildRailClick_Remove(), CcBuildBridge(), CcBuildRailTunnel(), CcBuildRoadTunnel(), CcRoadStop(), AnimationBase< IndustryAnimationBase, IndustryTileSpec, Industry, int, GetSimpleIndustryCallback >::ChangeAnimationFrame(), CheckMinActiveClients(), CheckOrders(), CheckPauseOnJoin(), BuildRailStationWindow::CheckSelectedSize(), CheckSoftLimit(), ClearPathReservation(), ClientNetworkEmergencySave(), CompanyServiceInterval(), Order::ConvertFromOldSavegame(), DEF_CONSOLE_HOOK(), GRFFileScanner::DoScan(), ClientNetworkContentSocketHandler::DownloadSelectedContent(), NetworkStartServerWindow::DrawWidget(), FloodVehicle(), GetLogPrefix(), GetOrderCmdFromTile(), GetSmallMapContoursPixels(), GetSmallMapIndustriesPixels(), GetSmallMapVehiclesPixels(), Vehicle::HandlePathfindingResult(), HandlePlacePushButton(), HandleViewportScroll(), HandleZoomMessage(), IConsoleDebug(), IConsoleWarning(), MusicSystem::IsPlaying(), MusicSystem::IsShuffle(), MaybeBarCrossingWithSound(), MaybeStartNewCompany(), NetworkAutoCleanCompanies(), NetworkCheckRestartMap(), NetworkClientPreferTeamChat(), NetworkDisconnect(), NetworkInitChatMessage(), NetworkMaxCompaniesReached(), NetworkServer_Tick(), NetworkServerSetCompanyPassword(), NetworkStartUp(), NetworkUDPAdvertise(), NetworkUDPAdvertiseThread(), NetworkUDPRemoveAdvertiseThread(), NetworkUpdateClientName(), MusicSystem::Next(), TransparenciesWindow::OnClick(), SmallMapWindow::OnClick(), BuildDocksStationWindow::OnClick(), BuildAirportWindow::OnClick(), NetworkGameWindow::OnClick(), BuildRailStationWindow::OnClick(), BuildRailDepotWindow::OnClick(), BuildRailWaypointWindow::OnClick(), IndustryCargoesWindow::OnClick(), NetworkGameWindow::OnDropdownSelect(), NetworkStartServerWindow::OnDropdownSelect(), GameSettingsWindow::OnDropdownSelect(), NetworkGameWindow::OnEditboxChanged(), NetworkStartServerWindow::OnEditboxChanged(), MusicTrackSelectionWindow::OnInvalidateData(), MusicWindow::OnInvalidateData(), BuildSignalWindow::OnInvalidateData(), ExtraViewportWindow::OnMouseWheel(), SmallMapWindow::OnMouseWheel(), MainWindow::OnMouseWheel(), AfterNewGRFScan::OnNewGRFsScanned(), OnNewMonth(), CompanyFinancesWindow::OnPaint(), BuildDocksStationWindow::OnPaint(), BuildRoadStationWindow::OnPaint(), BuildRailStationWindow::OnPaint(), TimetableWindow::OnQueryTextFinished(), NetworkStartServerWindow::OnQueryTextFinished(), LinkGraphLegendWindow::OnRightClick(), SmallMapWindow::OnScroll(), OrdersWindow::OrderClick_NearestDepot(), MusicSystem::Play(), PlayVehicleSound(), PopupMainToolbMenu(), PositionMainToolbar(), PositionNetworkChatWindow(), PositionNewsMessage(), PositionStatusbar(), MusicSystem::Prev(), AISettingsWindow::RebuildVisibleSettings(), ServerNetworkUDPSocketHandler::Receive_CLIENT_FIND_SERVER(), MasterNetworkUDPSocketHandler::Receive_MASTER_ACK_REGISTER(), ScriptScanner::RegisterScript(), ResetSignalVariant(), MusicSystem::SaveCustomPlaylist(), StationViewWindow::SelectGroupBy(), StationViewWindow::SelectSortBy(), StationViewWindow::SelectSortOrder(), ServerNetworkGameSocketHandler::SendConfigUpdate(), ServerNetworkGameSocketHandler::SendNeedCompanyPassword(), ServerNetworkGameSocketHandler::SendWelcome(), ServerNetworkAdminSocketHandler::SendWelcome(), ServerNetworkGameSocketHandler::ServerNetworkGameSocketHandler(), MusicTrackSelectionWindow::SetStringParameters(), NetworkGameWindow::SetStringParameters(), NetworkStartServerWindow::SetStringParameters(), BuildSignalWindow::SetStringParameters(), GRFConfig::SetSuitablePalette(), SetTimetableParams(), SetupScreenshotViewport(), ShowNewspaper(), ShowSelectBaseStationIfNeeded(), ShowTicker(), MusicSystem::Shuffle(), SndPlayScreenCoordFx(), MusicSystem::Stop(), NewGRFWindow::TagNameFilter(), IConsoleLine::Truncate(), MusicSystem::Unshuffle(), OrdersWindow::UpdateAutoRefitState(), TimetableWindow::UpdateSelectionStates(), CompanyFinancesWindow::UpdateWidgetSize(), and VpSelectTilesWithMethod().
| GameSettings _settings_game |
Game settings of a running game or the scenario editor.
The current settings for this game.
Definition at line 77 of file settings.cpp.
Referenced by AddInflation(), AffectSpeedByZChange(), AutoslopeEnabled(), BuildLandLegend(), BuildTownHouse(), CalcEngineReliability(), CanFollowRoad(), AI::CanStartNew(), CheckBridgeAvailability(), CheckBuildableTile(), CheckforTownRating(), CheckIfAuthorityAllowsNewStation(), CheckIfCanLevelIndustryPlatform(), CheckIfTrainNeedsService(), CheckIndustryCloseDownProtection(), CheckNewIndustry_Farm(), CheckNewIndustry_Forest(), CheckNewTrain(), CheckNextTrainTile(), CheckRailSlope(), CheckRoadSlope(), CheckSwitchToEuro(), CheckTrainAttachment(), CheckTrainStayInDepot(), ClickChangeMaxHlCheat(), CmdBuildRoadDepot(), CmdBuildTrainDepot(), CmdConvertRail(), CmdFoundTown(), CmdGiveMoney(), CmdLevelLand(), CompaniesMonthlyLoop(), Company::Company(), ConvertDisplaySpeedToKmhishSpeed(), ConvertDisplaySpeedToSpeed(), ConvertKmhishSpeedToDisplaySpeed(), ConvertSpeedToDisplaySpeed(), CreateRivers(), DeleteStaleLinks(), DisplayVehicleSortDropDown(), DistanceFromEdgeDir(), DoTrainPathfind(), LinkGraphOverlay::DrawContent(), StationViewWindow::DrawEntries(), DrawRoadAsSnowDesert(), ScenarioEditorToolbarWindow::DrawWidget(), ExtendTrainReservation(), FindSafePosition(), FindSpring(), FindStationsAroundTiles(), FindTownForIndustry(), FlatEmptyWorld(), FormatNumber(), FreightWagonMult(), AI::GameLoop(), ScriptInstance::GameLoop(), GenerateLandscape(), GenerateTerrainPerlin(), GenerateTownName(), GenerateTrees(), GetAirportNoiseLevelForTown(), GetAmplitude(), Station::GetCatchmentRadius(), RoadVehicle::GetCurrentMaxSpeed(), Train::GetCurrentMaxSpeed(), GetDriveableTrackdirBits(), GetFreeUnitNumber(), GetGlobalVariable(), GetIndustryGamePlayProbability(), Engine::GetLifeLengthInDays(), GetLoadAmount(), GetMaskOfTownActions(), GetNormalGrowthRate(), GetOtherAqueductEnd(), GetRandomTreeType(), GetScaledIndustryGenerationProbability(), RoadVehicle::GetSlopeSteepness(), Train::GetSlopeSteepness(), GetSnowLine(), GetTerrainType(), TownScopeResolver::GetVariable(), GfxLoadSprites(), GUIPlaceProcDragXY(), HasRailCatenaryDrawn(), HeightMapCoastLines(), HeightMapNormalize(), HeightMapSineTransform(), HighestSnowLine(), IndustryCargoesWindow::HousesCanAccept(), InitializeGRFSpecial(), AirportSpec::IsAvailable(), Engine::IsEnabled(), ObjectSpec::IsEverAvailable(), IsRoadAllowedHere(), IsVehicleTypeDisabled(), LoadNewGRF(), LoadSpriteTables(), LowestSnowLine(), Town::MaxTownNoise(), MaybeCrashAirplane(), MayCompanyTakeOver(), IndustryBuildData::MonthlyLoop(), Vehicle::NeedsServicing(), NetworkServerSetCompanyPassword(), NPFFindSafeTile(), NPFSaveTargetData(), LandInfoWindow::OnInit(), BuildIndustryWindow::OnInvalidateData(), BuildVehicleWindow::OnInvalidateData(), CompanyWindow::OnInvalidateData(), BuildAirportWindow::OnPaint(), BuildDocksStationWindow::OnPaint(), BuildRoadStationWindow::OnPaint(), ScenarioEditorToolbarWindow::OnPaint(), CreateScenarioWindow::OnQueryTextFinished(), OnTick_LinkGraph(), ScriptInstance::Pause(), SmallMapWindow::RebuildColourIndexIfNecessary(), ServerNetworkUDPSocketHandler::Receive_CLIENT_FIND_SERVER(), RecomputePrices(), AI::ResetConfig(), RoadFindPathToDest(), ServerNetworkGameSocketHandler::SendNeedCompanyPassword(), ServerNetworkGameSocketHandler::SendWelcome(), ServerNetworkAdminSocketHandler::SendWelcome(), SetStartingYear(), SetupScreenshotViewport(), StationViewWindow::ShowCargo(), StationJoinerNeeded(), TestAutoslopeOnRailTile(), TGPGetMaxHeight(), ToolbarScenDatePanel(), TownLayoutAllows2x2HouseHere(), TownLayoutAllowsHouseHere(), TrainCheckIfLineEnds(), TryReserveSafeTrack(), AI::Uninitialize(), UpdateAircraftSpeed(), RoadVehicle::UpdateSpeed(), Train::UpdateSpeed(), UpdateTownGrowth(), IndustrySpec::UsesSmoothEconomy(), YapfRoadVehicleChooseTrack(), YapfRoadVehicleFindNearestDepot(), YapfShipCheckReverse(), YapfShipChooseTrack(), YapfTrainCheckReverse(), YapfTrainChooseTrack(), YapfTrainFindNearestDepot(), YapfTrainFindNearestSafeTile(), and LinkGraphJob::~LinkGraphJob().
| GameSettings _settings_newgame |
Game settings for new games (updated from the intro screen).
The settings values that are used for new games and/or modified in config file.
Definition at line 78 of file settings.cpp.
Referenced by CreateScenarioWindow::OnClick(), GenerateLandscapeWindow::OnDropdownSelect(), CreateScenarioWindow::OnDropdownSelect(), SelectGameWindow::OnInvalidateData(), GenerateLandscapeWindow::OnInvalidateData(), CreateScenarioWindow::OnPaint(), CreateScenarioWindow::OnQueryTextFinished(), AI::ResetConfig(), SetNewLandscapeType(), GenerateLandscapeWindow::SetStringParameters(), CreateScenarioWindow::SetStringParameters(), StartNewGameWithoutGUI(), and AI::Uninitialize().