OpenTTD

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

- File List
- Globals

Data Structures | Typedefs | Enumerations | Functions
settings_internal.h File Reference

Functions and types used internally for the settings configurations. More...

`#include "saveload/saveload.h"`

Go to the source code of this file.

## Data Structures
struct | SettingDescBase
| Properties of config file settings. More...
struct | SettingDesc

## Typedefs
typedef SimpleTinyEnumT < SettingDescTypeLong, byte > | SettingDescType
typedef SimpleTinyEnumT < SettingGuiFlagLong, uint16 > | SettingGuiFlag
typedef bool | OnChange (int32 var)
| callback prototype on data modification
typedef size_t | OnConvert (const char *value)
| callback prototype for conversion error
typedef SettingDesc | SettingDescGlobVarList

## Enumerations
enum | SettingDescTypeLong { SDT_BEGIN = 0, SDT_NUMX = 0, SDT_BOOLX = 1, SDT_ONEOFMANY = 2, SDT_MANYOFMANY = 3, SDT_INTLIST = 4, SDT_STRING = 5, SDT_END }
| Convention/Type of settings. More...
enum | SettingGuiFlagLong { SGF_NONE = 0, SGF_0ISDISABLED = 1 << 0, SGF_DISPLAY_ABS = 1 << 1, SGF_MULTISTRING = 1 << 2, SGF_NETWORK_ONLY = 1 << 3, SGF_CURRENCY = 1 << 4, SGF_NO_NETWORK = 1 << 5, SGF_NEWGAME_ONLY = 1 << 6, SGF_SCENEDIT_TOO = 1 << 7, SGF_PER_COMPANY = 1 << 8 }
enum | SettingCategory { SC_NONE = 0, SC_BASIC_LIST = 1 << 0, SC_ADVANCED_LIST = 1 << 1, SC_EXPERT_LIST = 1 << 2, SC_BASIC = SC_BASIC_LIST | SC_ADVANCED_LIST | SC_EXPERT_LIST, SC_ADVANCED = SC_ADVANCED_LIST | SC_EXPERT_LIST, SC_EXPERT = SC_EXPERT_LIST, SC_END }
| A SettingCategory defines a grouping of the settings. More...
enum | SettingType { ST_GAME, ST_COMPANY, ST_CLIENT, ST_ALL }
| Type of settings for filtering. More...

## Functions
const SettingDesc * | GetSettingFromName (const char *name, uint *i)
| Given a name of setting, return a setting description of it.
bool | SetSettingValue (uint index, int32 value, bool force_newgame=false)
| Top function to save the new value of an element of the Settings struct.
bool | SetSettingValue (uint index, const char *value, bool force_newgame=false)
| Set a setting value with a string.
void | SetCompanySetting (uint index, int32 value)
| Top function to save the new value of an element of the Settings struct.

## Detailed Description

Functions and types used internally for the settings configurations.

Definition in file settings_internal.h.

## Enumeration Type Documentation

enum SettingCategory

A SettingCategory defines a grouping of the settings.

The group SC_BASIC is intended for settings which also a novice player would like to change and is able to understand. The group SC_ADVANCED is intended for settings which an experienced player would like to use. This is the case for most settings. Finally SC_EXPERT settings only few people want to see in rare cases. The grouping is meant to be inclusive, i.e. all settings in SC_BASIC also will be included in the set of settings in SC_ADVANCED. The group SC_EXPERT contains all settings.

Enumerator:

  SC_BASIC_LIST | Settings displayed in the list of basic settings.
  SC_ADVANCED_LIST | Settings displayed in the list of advanced settings.
  SC_EXPERT_LIST | Settings displayed in the list of expert settings.
  SC_BASIC | Basic settings are part of all lists.
  SC_ADVANCED | Advanced settings are part of advanced and expert list.
  SC_EXPERT | Expert settings can only be seen in the expert list.

Definition at line 63 of file settings_internal.h.

enum SettingDescTypeLong

Convention/Type of settings.

This is then further specified if necessary with the SLE_ (SLE_VAR/SLE_FILE) enums in saveload.h

See Also
  VarTypes
  SettingDescBase

Enumerator:

  SDT_NUMX | any number-type
  SDT_BOOLX | a boolean number
  SDT_ONEOFMANY | bitmasked number where only ONE bit may be set
  SDT_MANYOFMANY | bitmasked number where MULTIPLE bits may be set
  SDT_INTLIST | list of integers separated by a comma ','
  SDT_STRING | string with a pre-allocated buffer

Definition at line 23 of file settings_internal.h.

enum SettingGuiFlagLong

Enumerator:

  SGF_0ISDISABLED | a value of zero means the feature is disabled
  SGF_DISPLAY_ABS | display absolute value of the setting
  SGF_MULTISTRING | the value represents a limited number of string-options (internally integer)
  SGF_NETWORK_ONLY | this setting only applies to network games
  SGF_CURRENCY | the number represents money, so when reading value multiply by exchange rate
  SGF_NO_NETWORK | this setting does not apply to network games; it may not be changed during the game
  SGF_NEWGAME_ONLY | this setting cannot be changed in a game
  SGF_SCENEDIT_TOO | this setting can be changed in the scenario editor (only makes sense when SGF_NEWGAME_ONLY is set)
  SGF_PER_COMPANY | this setting can be different for each company (saved in company struct)

Definition at line 38 of file settings_internal.h.

enum SettingType

Type of settings for filtering.

Enumerator:

  ST_GAME | Game setting.
  ST_COMPANY | Company setting.
  ST_CLIENT | Client setting.
  ST_ALL | Used in setting filter to match all types.

Definition at line 82 of file settings_internal.h.

## Function Documentation

const SettingDesc* GetSettingFromName | ( | const char * | name,
|  | uint * | i
| ) |  |

Given a name of setting, return a setting description of it.

Parameters

  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.

Returns
  Pointer to the setting description of setting name if it can be found, `NULL` indicates failure to obtain the description

Definition at line 2047 of file settings.cpp.

References SaveLoad::cmd, SettingDesc::desc, SettingDescBase::name, SettingDesc::save, SlIsObjectCurrentlyValid(), SaveLoad::version_from, and SaveLoad::version_to.

Referenced by GetCompanySettingIndex(), NewsTypeData::GetDisplay(), IConsoleGetSetting(), SettingEntry::Init(), and GameOptionsWindow::OnDropdownSelect().

void SetCompanySetting | ( | uint | index,
|  | int32 | value
| ) |  |

Top function to save the new value of an element of the Settings struct.

Parameters

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

References _local_company, CMD_CHANGE_COMPANY_SETTING, ClientSettings::company, SaveLoad::conv, SettingDesc::desc, DoCommandP(), GetVariableAddress(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::IsValidID(), SettingDescBase::proc, ReadValue(), SettingDesc::save, and Write_ValidateSetting().

Referenced by GameSettingsWindow::OnClick(), GameSettingsWindow::OnDropdownSelect(), and GameSettingsWindow::OnQueryTextFinished().

bool SetSettingValue | ( | uint | index,
|  | int32 | value,
|  | bool | force_newgame
| ) |  |

Top function to save the new value of an element of the Settings struct.

Parameters

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

References _network_server, _networking, CMD_CHANGE_SETTING, SaveLoad::conv, SettingDesc::desc, DoCommandP(), GetGameSettings(), GetVariableAddress(), SettingDescBase::proc, ReadValue(), SettingDesc::save, SetWindowClassesDirty(), SLF_NO_NETWORK_SYNC, WC_GAME_OPTIONS, and Write_ValidateSetting().

Referenced by GameSettingsWindow::OnClick(), GameOptionsWindow::OnDropdownSelect(), GameSettingsWindow::OnDropdownSelect(), and GameSettingsWindow::OnQueryTextFinished().

bool SetSettingValue | ( | uint | index,
|  | const char * | value,
|  | bool | force_newgame
| ) |  |

Set a setting value with a string.

Parameters

  index | the settings index.
  value | the value to write
  force_newgame | force the newgame settings

Note
  Strings WILL NOT be synced over the network

Definition at line 2022 of file settings.cpp.

References _settings_game, SaveLoad::conv, SettingDesc::desc, free(), GetVariableAddress(), GetVarMemType(), SaveLoad::length, SettingDescBase::proc, SettingDesc::save, SLE_VAR_STRQ, SLF_NO_NETWORK_SYNC, strecpy(), and stredup().