OpenTTD: src/settings_func.h File Reference

OpenTTD

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files

- File List
- Globals

Typedefs | Functions
settings_func.h File Reference

Functions related to setting/changing the settings. More...

`#include "core/smallvec_type.hpp"`
`#include "company_type.h"`

Go to the source code of this file.

## Typedefs
typedef AutoFreeSmallVector < char *, 4 > | GRFPresetList

## Functions
void | IConsoleSetSetting (const char *name, const char *value, bool force_newgame=false)
void | IConsoleSetSetting (const char *name, int32 value)
void | IConsoleGetSetting (const char *name, bool force_newgame=false)
| Output value of a specific setting to the console.
void | IConsoleListSettings (const char *prefilter)
| List all settings and their value to the console.
void | LoadFromConfig (bool minimal=false)
| Load the values from the configuration files.
void | SaveToConfig ()
| Save the values to the configuration file.
void | CheckConfig ()
void | IniLoadWindowSettings (IniFile *ini, const char *grpname, void *desc)
| Load a WindowDesc from config.
void | IniSaveWindowSettings (IniFile *ini, const char *grpname, void *desc)
| Save a WindowDesc to config.
void | GetGRFPresetList (GRFPresetList *list)
| Get the list of known NewGrf presets.
struct GRFConfig * | LoadGRFPresetFromConfig (const char *config_name)
| Load a NewGRF configuration by preset-name.
void | SaveGRFPresetToConfig (const char *config_name, struct GRFConfig *config)
| Save a NewGRF configuration with a preset name.
void | DeleteGRFPresetFromConfig (const char *config_name)
| Delete a NewGRF configuration by preset name.
uint | GetCompanySettingIndex (const char *name)
| Get the index in the _company_settings array of a setting.
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.

## Detailed Description

Functions related to setting/changing the settings.

Definition in file settings_func.h.

## Function Documentation

void DeleteGRFPresetFromConfig | ( | const char * | config_name | ) |

Delete a NewGRF configuration by preset name.

Parameters

  config_name | Name of the preset.

Definition at line 1808 of file settings.cpp.

References _config_file, IniLoadFile::RemoveGroup(), IniFile::SaveToDisk(), and seprintf().

Referenced by NewGRFWindow::OnClick().

uint GetCompanySettingIndex | ( | const char * | name | ) |

Get the index in the _company_settings array of a setting.

Parameters

  name | The name of the setting

Returns
  The index in the _company_settings array

Definition at line 2007 of file settings.cpp.

References SettingDesc::desc, SettingDescBase::flags, GetSettingFromName(), and SGF_PER_COMPANY.

Referenced by ReplaceVehicleWindow::OnClick().

void GetGRFPresetList | ( | GRFPresetList * | list | ) |

Get the list of known NewGrf presets.

Parameters

  list[inout] | Pointer to list for storing the preset names.

Definition at line 1752 of file settings.cpp.

References SmallVector< T, S >::Append(), AutoFreeSmallVector< T, S >::Clear(), IniLoadFile::group, IniGroup::name, IniGroup::next, and stredup().

Referenced by NewGRFWindow::OnClick(), NewGRFWindow::OnQueryTextFinished(), and SavePresetWindow::SavePresetWindow().

void IConsoleGetSetting | ( | const char * | name,
|  | bool | force_newgame
| ) |  |

Output value of a specific setting to the console.

Parameters

  name | Name of the setting to output its value
  force_newgame | force the newgame settings

Definition at line 2126 of file settings.cpp.

References CC_WARNING, SettingDescBase::cmd, SaveLoad::conv, SettingDesc::desc, SettingDescBase::flags, GetSettingFromName(), GetVariableAddress(), GetVarMemType(), IConsolePrintF(), lastof, SettingDescBase::max, SettingDescBase::min, ReadValue(), SettingDesc::save, SDT_BOOLX, SDT_STRING, seprintf(), SGF_0ISDISABLED, and SLE_VAR_STRQ.

void IConsoleListSettings | ( | const char * | prefilter | ) |

List all settings and their value to the console.

Parameters

  prefilter | If not `NULL`, only list settings with names that begin with prefilter prefix

Definition at line 2159 of file settings.cpp.

References CC_DEFAULT, CC_WARNING, SettingDescBase::cmd, SaveLoad::cmd, SaveLoad::conv, SettingDesc::desc, GetGameSettings(), GetVariableAddress(), GetVarMemType(), IConsolePrintF(), lastof, SettingDescBase::min, SettingDescBase::name, ReadValue(), SettingDesc::save, SDT_BOOLX, SDT_STRING, seprintf(), SLE_VAR_STRQ, SlIsObjectCurrentlyValid(), SaveLoad::version_from, and SaveLoad::version_to.

void IniLoadWindowSettings | ( | IniFile * | ini,
|  | const char * | grpname,
|  | void * | desc
| ) |  |

Load a WindowDesc from config.

Parameters

  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 743 of file settings.cpp.

References IniLoadSettings().

Referenced by WindowDesc::LoadFromConfig().

void IniSaveWindowSettings | ( | IniFile * | ini,
|  | const char * | grpname,
|  | void * | desc
| ) |  |

Save a WindowDesc to config.

Parameters

  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 754 of file settings.cpp.

References IniSaveSettings().

Referenced by WindowDesc::SaveToConfig().

void LoadFromConfig | ( | bool | minimal | ) |

Load the values from the configuration files.

Parameters

  minimal | Load the minimal amount of the configuration to "bootstrap" the blitter and such.

Definition at line 1699 of file settings.cpp.

References _grfconfig_newgame, _grfconfig_static, _settings_error_list, FindWindowById(), GRFLoadConfig(), HandleOldDiffCustom(), IniLoadSettingList(), IniLoadSettings(), PrepareOldDiffCustom(), ResetCurrencies(), ScheduleErrorMessage(), ShowFirstError(), ValidateSettings(), and WC_ERRMSG.

Referenced by AfterNewGRFScan::OnNewGRFsScanned(), and openttd_main().

struct GRFConfig* LoadGRFPresetFromConfig | ( | const char * | config_name | ) |
| read

Load a NewGRF configuration by preset-name.

Parameters

  config_name | Name of the preset.

Returns
  NewGRF configuration.

See Also
  GetGRFPresetList

Definition at line 1773 of file settings.cpp.

References GRFLoadConfig(), and seprintf().

Referenced by NewGRFWindow::OnDropdownSelect().

void SaveGRFPresetToConfig | ( | const char * | config_name,
|  | GRFConfig * | config
| ) |  |

Save a NewGRF configuration with a preset name.

Parameters

  config_name | Name of the preset.
  config | NewGRF configuration to save.

See Also
  GetGRFPresetList

Definition at line 1792 of file settings.cpp.

References _config_file, IniFile::SaveToDisk(), and seprintf().

Referenced by NewGRFWindow::OnQueryTextFinished().