# settings.h File Reference

Settings to save in the savegame and config file. More...

Go to the source code of this file.

## Defines
#define | NSD_GENERAL(name, def, cmd, guiflags, min, max, interval, many, str, proc, load) {name, (const void*)(def), {(byte)cmd}, {(uint16)guiflags}, min, max, interval, many, str, proc, load}
| Settings-macro usage: The list might look daunting at first, but is in general easy to understand.
#define | SDTG_GENERAL(name, sdt_cmd, sle_cmd, type, flags, guiflags, var, length, def, min, max, interval, full, str, proc, from, to) {NSD_GENERAL(name, def, sdt_cmd, guiflags, min, max, interval, full, str, proc, NULL), SLEG_GENERAL(sle_cmd, var, type | flags, length, from, to)}
#define | SDTG_CONDVAR(name, type, flags, guiflags, var, def, min, max, interval, str, proc, from, to) SDTG_GENERAL(name, SDT_NUMX, SL_VAR, type, flags, guiflags, var, 0, def, min, max, interval, NULL, str, proc, from, to)
#define | SDTG_VAR(name, type, flags, guiflags, var, def, min, max, interval, str, proc) SDTG_CONDVAR(name, type, flags, guiflags, var, def, min, max, interval, str, proc, 0, SL_MAX_VERSION)
#define | SDTG_CONDBOOL(name, flags, guiflags, var, def, str, proc, from, to) SDTG_GENERAL(name, SDT_BOOLX, SL_VAR, SLE_BOOL, flags, guiflags, var, 0, def, 0, 1, 0, NULL, str, proc, from, to)
#define | SDTG_BOOL(name, flags, guiflags, var, def, str, proc) SDTG_CONDBOOL(name, flags, guiflags, var, def, str, proc, 0, SL_MAX_VERSION)
#define | SDTG_CONDLIST(name, type, length, flags, guiflags, var, def, str, proc, from, to) SDTG_GENERAL(name, SDT_INTLIST, SL_ARR, type, flags, guiflags, var, length, def, 0, 0, 0, NULL, str, proc, from, to)
#define | SDTG_LIST(name, type, flags, guiflags, var, def, str, proc) SDTG_GENERAL(name, SDT_INTLIST, SL_ARR, type, flags, guiflags, var, lengthof(var), def, 0, 0, 0, NULL, str, proc, 0, SL_MAX_VERSION)
#define | SDTG_CONDSTR(name, type, length, flags, guiflags, var, def, str, proc, from, to) SDTG_GENERAL(name, SDT_STRING, SL_STR, type, flags, guiflags, var, length, def, 0, 0, 0, NULL, str, proc, from, to)
#define | SDTG_STR(name, type, flags, guiflags, var, def, str, proc) SDTG_GENERAL(name, SDT_STRING, SL_STR, type, flags, guiflags, var, lengthof(var), def, 0, 0, 0, NULL, str, proc, 0, SL_MAX_VERSION)
#define | SDTG_CONDOMANY(name, type, flags, guiflags, var, def, max, full, str, proc, from, to) SDTG_GENERAL(name, SDT_ONEOFMANY, SL_VAR, type, flags, guiflags, var, 0, def, 0, max, 0, full, str, proc, from, to)
#define | SDTG_OMANY(name, type, flags, guiflags, var, def, max, full, str, proc) SDTG_CONDOMANY(name, type, flags, guiflags, var, def, max, full, str, proc, 0, SL_MAX_VERSION)
#define | SDTG_CONDMMANY(name, type, flags, guiflags, var, def, full, str, proc, from, to) SDTG_GENERAL(name, SDT_MANYOFMANY, SL_VAR, type, flags, guiflags, var, 0, def, 0, 0, 0, full, str, proc, from, to)
#define | SDTG_MMANY(name, type, flags, guiflags, var, def, full, str, proc) SDTG_CONDMMANY(name, type, flags, guiflags, var, def, full, str, proc, 0, SL_MAX_VERSION)
#define | SDTG_CONDNULL(length, from, to) {{"", NULL, {0}, {0}, 0, 0, 0, NULL, STR_NULL, NULL, NULL}, SLEG_CONDNULL(length, from, to)}
#define | SDTG_END() {{NULL, NULL, {0}, {0}, 0, 0, 0, NULL, STR_NULL, NULL, NULL}, SLEG_END()}
#define | SDT_GENERAL(name, sdt_cmd, sle_cmd, type, flags, guiflags, base, var, length, def, min, max, interval, full, str, proc, load, from, to) {NSD_GENERAL(name, def, sdt_cmd, guiflags, min, max, interval, full, str, proc, load), SLE_GENERAL(sle_cmd, base, var, type | flags, length, from, to)}
#define | SDT_CONDVAR(base, var, type, from, to, flags, guiflags, def, min, max, interval, str, proc) SDT_GENERAL(#var, SDT_NUMX, SL_VAR, type, flags, guiflags, base, var, 1, def, min, max, interval, NULL, str, proc, NULL, from, to)
#define | SDT_VAR(base, var, type, flags, guiflags, def, min, max, interval, str, proc) SDT_CONDVAR(base, var, type, 0, SL_MAX_VERSION, flags, guiflags, def, min, max, interval, str, proc)
#define | SDT_CONDBOOL(base, var, from, to, flags, guiflags, def, str, proc) SDT_GENERAL(#var, SDT_BOOLX, SL_VAR, SLE_BOOL, flags, guiflags, base, var, 1, def, 0, 1, 0, NULL, str, proc, NULL, from, to)
#define | SDT_BOOL(base, var, flags, guiflags, def, str, proc) SDT_CONDBOOL(base, var, 0, SL_MAX_VERSION, flags, guiflags, def, str, proc)
#define | SDT_CONDLIST(base, var, type, from, to, flags, guiflags, def, str, proc) SDT_GENERAL(#var, SDT_INTLIST, SL_ARR, type, flags, guiflags, base, var, lengthof(((base*)8)->var), def, 0, 0, 0, NULL, str, proc, NULL, from, to)
#define | SDT_LIST(base, var, type, flags, guiflags, def, str, proc) SDT_CONDLIST(base, var, type, 0, SL_MAX_VERSION, flags, guiflags, def, str, proc)
#define | SDT_CONDSTR(base, var, type, from, to, flags, guiflags, def, str, proc) SDT_GENERAL(#var, SDT_STRING, SL_STR, type, flags, guiflags, base, var, lengthof(((base*)8)->var), def, 0, 0, 0, NULL, str, proc, NULL, from, to)
#define | SDT_STR(base, var, type, flags, guiflags, def, str, proc) SDT_CONDSTR(base, var, type, 0, SL_MAX_VERSION, flags, guiflags, def, str, proc)
#define | SDT_CONDSTRO(base, var, length, type, from, to, flags, def, str, proc) SDT_GENERAL(#var, SDT_STRING, SL_STR, type, flags, 0, base, var, length, def, 0, 0, NULL, str, proc, from, to)
#define | SDT_CONDCHR(base, var, from, to, flags, guiflags, def, str, proc) SDT_GENERAL(#var, SDT_STRING, SL_VAR, SLE_CHAR, flags, guiflags, base, var, 1, def, 0, 0, 0, NULL, str, proc, NULL, from, to)
#define | SDT_CHR(base, var, flags, guiflags, def, str, proc) SDT_CONDCHR(base, var, 0, SL_MAX_VERSION, flags, guiflags, def, str, proc)
#define | SDT_CONDOMANY(base, var, type, from, to, flags, guiflags, def, max, full, str, proc, load) SDT_GENERAL(#var, SDT_ONEOFMANY, SL_VAR, type, flags, guiflags, base, var, 1, def, 0, max, 0, full, str, proc, load, from, to)
#define | SDT_OMANY(base, var, type, flags, guiflags, def, max, full, str, proc, load) SDT_CONDOMANY(base, var, type, 0, SL_MAX_VERSION, flags, guiflags, def, max, full, str, proc, load)
#define | SDT_CONDMMANY(base, var, type, from, to, flags, guiflags, def, full, str, proc) SDT_GENERAL(#var, SDT_MANYOFMANY, SL_VAR, type, flags, guiflags, base, var, 1, def, 0, 0, 0, full, str, proc, NULL, from, to)
#define | SDT_MMANY(base, var, type, flags, guiflags, def, full, str, proc) SDT_CONDMMANY(base, var, type, 0, SL_MAX_VERSION, flags, guiflags, def, full, str, proc)
#define | SDT_CONDNULL(length, from, to) {{"", NULL, {0}, {0}, 0, 0, 0, NULL, STR_NULL, NULL, NULL}, SLE_CONDNULL(length, from, to)}
#define | SDTC_CONDVAR(var, type, from, to, flags, guiflags, def, min, max, interval, str, proc) SDTG_GENERAL(#var, SDT_NUMX, SL_VAR, type, flags, guiflags, _settings_client.var, 1, def, min, max, interval, NULL, str, proc, from, to)
#define | SDTC_VAR(var, type, flags, guiflags, def, min, max, interval, str, proc) SDTC_CONDVAR(var, type, 0, SL_MAX_VERSION, flags, guiflags, def, min, max, interval, str, proc)
#define | SDTC_CONDBOOL(var, from, to, flags, guiflags, def, str, proc) SDTG_GENERAL(#var, SDT_BOOLX, SL_VAR, SLE_BOOL, flags, guiflags, _settings_client.var, 1, def, 0, 1, 0, NULL, str, proc, from, to)
#define | SDTC_BOOL(var, flags, guiflags, def, str, proc) SDTC_CONDBOOL(var, 0, SL_MAX_VERSION, flags, guiflags, def, str, proc)
#define | SDTC_CONDLIST(var, type, length, flags, guiflags, def, str, proc, from, to) SDTG_GENERAL(#var, SDT_INTLIST, SL_ARR, type, flags, guiflags, _settings_client.var, length, def, 0, 0, 0, NULL, str, proc, from, to)
#define | SDTC_LIST(var, type, flags, guiflags, def, str, proc) SDTG_GENERAL(#var, SDT_INTLIST, SL_ARR, type, flags, guiflags, _settings_client.var, lengthof(_settings_client.var), def, 0, 0, 0, NULL, str, proc, 0, SL_MAX_VERSION)
#define | SDTC_CONDSTR(var, type, length, flags, guiflags, def, str, proc, from, to) SDTG_GENERAL(#var, SDT_STRING, SL_STR, type, flags, guiflags, _settings_client.var, length, def, 0, 0, 0, NULL, str, proc, from, to)
#define | SDTC_STR(var, type, flags, guiflags, def, str, proc) SDTG_GENERAL(#var, SDT_STRING, SL_STR, type, flags, guiflags, _settings_client.var, lengthof(_settings_client.var), def, 0, 0, 0, NULL, str, proc, 0, SL_MAX_VERSION)
#define | SDTC_CONDOMANY(var, type, from, to, flags, guiflags, def, max, full, str, proc) SDTG_GENERAL(#var, SDT_ONEOFMANY, SL_VAR, type, flags, guiflags, _settings_client.var, 1, def, 0, max, 0, full, str, proc, from, to)
#define | SDTC_OMANY(var, type, flags, guiflags, def, max, full, str, proc) SDTC_CONDOMANY(var, type, 0, SL_MAX_VERSION, flags, guiflags, def, max, full, str, proc)
#define | SDT_END() {{NULL, NULL, {0}, {0}, 0, 0, 0, NULL, STR_NULL, NULL, NULL}, SLE_END()}
#define | S SLF_SAVE_NO | SLF_NETWORK_NO
#define | C SLF_CONFIG_NO
#define | N SLF_NETWORK_NO
#define | D0 SGF_0ISDISABLED
#define | NC SGF_NOCOMMA
#define | MS SGF_MULTISTRING
#define | NO SGF_NETWORK_ONLY
#define | CR SGF_CURRENCY
#define | NN SGF_NO_NETWORK
#define | NG SGF_NEWGAME_ONLY
#define | NS SGF_NEWGAME_ONLY | SGF_SCENEDIT_TOO
#define | PC SGF_PER_COMPANY
## Functions
static bool | v_PositionMainToolbar (int32 p1)
static bool | PopulationInLabelActive (int32 p1)
static bool | RedrawScreen (int32 p1)
static bool | InvalidateDetailsWindow (int32 p1)
static bool | InvalidateStationBuildWindow (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 | TrainAccelerationModelChanged (int32 p1)
static bool | TrainSlopeSteepnessChanged (int32 p1)
static bool | DragSignalsDensityChanged (int32)
static bool | TownFoundingChanged (int32 p1)
static bool | DifficultyReset (int32 level)
static bool | DifficultyChange (int32)
static bool | DifficultyNoiseChange (int32 i)
static bool | CheckRoadSide (int p1)
static int32 | ConvertLandscape (const char *value)
static bool | CheckFreeformEdges (int32 p1)
static bool | ChangeDynamicEngines (int32 p1)
static bool | StationCatchmentChanged (int32 p1)
static bool | InvalidateVehTimetableWindow (int32 p1)
## Variables
static const SettingDesc | _music_settings []
static const SettingDescGlobVarList | _misc_settings []
static const uint | GAME_DIFFICULTY_NUM = 18
static uint16 | _old_diff_custom [GAME_DIFFICULTY_NUM]
static const char * | _locale_currencies = "GBP|USD|EUR|YEN|ATS|BEF|CHF|CZK|DEM|DKK|ESP|FIM|FRF|GRD|HUF|ISK|ITL|NLG|NOK|PLN|RON|RUR|SIT|SEK|YTL|SKK|BRL|EEK|custom"
static const char * | _locale_units = "imperial|metric|si"
static const char * | _town_names = "english|french|german|american|latin|silly|swedish|dutch|finnish|polish|slovak|norwegian|hungarian|austrian|romanian|czech|swiss|danish|turkish|italian|catalan"
static const char * | _climates = "temperate|arctic|tropic|toyland"
static const char * | _autosave_interval = "off|monthly|quarterly|half year|yearly"
static const char * | _roadsides = "left|right"
static const char * | _savegame_date = "long|short|iso"
static const SettingDesc | _gameopt_settings []
const SettingDesc | _settings []
static const SettingDesc | _company_settings []
static const SettingDesc | _currency_settings []

## Detailed Description

Settings to save in the savegame and config file.

Definition in file settings.h.

## Define Documentation

#define NSD_GENERAL | ( | name,
|  | def,
|  | cmd,
|  | guiflags,
|  | min,
|  | max,
|  | interval,
|  | many,
|  | str,
|  | proc,
|  | load |  | ) | {name, (const void*)(def), {(byte)cmd}, {(uint16)guiflags}, min, max, interval, many, str, proc, load}

Settings-macro usage: The list might look daunting at first, but is in general easy to understand.

We have two types of list: 1. SDTG_something 2. SDT_something The 'G' stands for global, so this is the one you will use for a SettingDescGlobVarList section meaning global variables. The other uses a Base/Offset and runtime variable selection mechanism, known from the saveload convention (it also has global so it should not be hard). Of each type there are again two versions, the normal one and one prefixed with 'COND'. COND means that the setting is only valid in certain savegame versions (since settings are saved to the savegame, this bookkeeping is necessary. Now there are a lot of types. Easy ones are:

- VAR: any number type, 'type' field specifies what number. eg int8 or uint32
- BOOL: a boolean number type
- STR: a string or character. 'type' field specifies what string. Normal, string, or quoted A bit more difficult to use are MMANY (meaning ManyOfMany) and OMANY (OneOfMany) These are actually normal numbers, only bitmasked. In MMANY several bits can be set, in the other only one. The most complex type is INTLIST. This is basically an array of numbers. If the intlist is only valid in certain savegame versions because for example it has grown in size its length cannot be automatically be calculated so use SDT(G)_CONDLISTO() meaning Old. If nothing fits you, you can use the GENERAL macros, but it exposes the internal structure somewhat so it needs a little looking. There are _NULL() macros as well, these fill up space so you can add more settings there (in place) and you DON'T have to increase the savegame version.

While reading values from openttd.cfg, some values may not be converted properly, for any kind of reasons. In order to allow a process of self-cleaning mechanism, a callback procedure is made available. You will have to supply the function, which will work on a string, one function per setting. And of course, enable the callback param on the appropriate macro.

Definition at line 87 of file settings.h.

## Variable Documentation

const SettingDesc _company_settings[]`[static]`

Initial value:

     {
      SDT_BOOL(CompanySettings, engine_renew,                          0, PC,     false,                  STR_CONFIG_SETTING_AUTORENEW_VEHICLE,     NULL),
       SDT_VAR(CompanySettings, engine_renew_months,        SLE_INT16, 0, PC,         6, -12,      12, 0, STR_CONFIG_SETTING_AUTORENEW_MONTHS,      NULL),
       SDT_VAR(CompanySettings, engine_renew_money,          SLE_UINT, 0, PC|CR, 100000,   0, 2000000, 0, STR_CONFIG_SETTING_AUTORENEW_MONEY,       NULL),
      SDT_BOOL(CompanySettings, renew_keep_length,                     0, PC,     false,                  STR_NULL,                                 NULL),
      SDT_BOOL(CompanySettings, vehicle.servint_ispercent,             0, PC,     false,                  STR_CONFIG_SETTING_SERVINT_ISPERCENT,     CheckInterval),
       SDT_VAR(CompanySettings, vehicle.servint_trains,    SLE_UINT16, 0, PC|D0,    150,   5,     800, 0, STR_CONFIG_SETTING_SERVINT_TRAINS,        InvalidateDetailsWindow),
       SDT_VAR(CompanySettings, vehicle.servint_roadveh,   SLE_UINT16, 0, PC|D0,    150,   5,     800, 0, STR_CONFIG_SETTING_SERVINT_ROAD_VEHICLES, InvalidateDetailsWindow),
       SDT_VAR(CompanySettings, vehicle.servint_ships,     SLE_UINT16, 0, PC|D0,    360,   5,     800, 0, STR_CONFIG_SETTING_SERVINT_SHIPS,         InvalidateDetailsWindow),
       SDT_VAR(CompanySettings, vehicle.servint_aircraft,  SLE_UINT16, 0, PC|D0,    100,   5,     800, 0, STR_CONFIG_SETTING_SERVINT_AIRCRAFT,      InvalidateDetailsWindow),

    }

Definition at line 650 of file settings.h.

const SettingDesc _currency_settings[]`[static]`

Initial value:

     {
      SDT_VAR(CurrencySpec, rate,    SLE_UINT16, S, 0, 1,      0, UINT16_MAX, 0, STR_NULL, NULL),
      SDT_CHR(CurrencySpec, separator,           S, 0, ".",                      STR_NULL, NULL),
      SDT_VAR(CurrencySpec, to_euro,  SLE_INT32, S, 0, 0, MIN_YEAR, MAX_YEAR, 0, STR_NULL, NULL),
      SDT_STR(CurrencySpec, prefix,   SLE_STRBQ, S, 0, NULL,                     STR_NULL, NULL),
      SDT_STR(CurrencySpec, suffix,   SLE_STRBQ, S, 0, " credits",               STR_NULL, NULL),

    }

Definition at line 663 of file settings.h.

const SettingDesc _gameopt_settings[]`[static]`

Initial value:

     {

       SDTG_GENERAL("diff_custom", SDT_INTLIST, SL_ARR, SLE_FILE_I16 | SLE_VAR_U16,    C, 0, _old_diff_custom, 17, 0, 0, 0, 0, NULL, STR_NULL, NULL, 0,  3),
       SDTG_GENERAL("diff_custom", SDT_INTLIST, SL_ARR, SLE_UINT16,                    C, 0, _old_diff_custom, 18, 0, 0, 0, 0, NULL, STR_NULL, NULL, 4, SL_MAX_VERSION),

            SDT_VAR(GameSettings, difficulty.diff_level,    SLE_UINT8,                     0, 0, 0, 0,  3, 0, STR_NULL, NULL),
          SDT_OMANY(GameSettings, locale.currency,          SLE_UINT8,                     N, 0, 0, CUSTOM_CURRENCY_ID, _locale_currencies, STR_NULL, NULL, NULL),
          SDT_OMANY(GameSettings, locale.units,             SLE_UINT8,                     N, 0, 1, 2, _locale_units, STR_NULL, NULL, NULL),

          SDT_OMANY(GameSettings, game_creation.town_name,  SLE_UINT8,                     0, 0, 0, 255, _town_names, STR_NULL, NULL, NULL),
          SDT_OMANY(GameSettings, game_creation.landscape,  SLE_UINT8,                     0, 0, 0, 3, _climates, STR_NULL, NULL, ConvertLandscape),
            SDT_VAR(GameSettings, game_creation.snow_line,  SLE_UINT8,                     0, 0, DEF_SNOWLINE_HEIGHT * TILE_HEIGHT, MIN_SNOWLINE_HEIGHT * TILE_HEIGHT, DEF_SNOWLINE_HEIGHT * TILE_HEIGHT, 0, STR_NULL, NULL),
       SDT_CONDNULL(                                                1,  0, 22),
     SDTC_CONDOMANY(              gui.autosave,             SLE_UINT8, 23, SL_MAX_VERSION, S, 0, 1, 4, _autosave_interval, STR_NULL, NULL),
          SDT_OMANY(GameSettings, vehicle.road_side,        SLE_UINT8,                     0, 0, 1, 1, _roadsides, STR_NULL, NULL, NULL),

    }

Definition at line 297 of file settings.h.

const SettingDesc _music_settings[]`[static]`

Initial value:

     {
       SDT_VAR(MusicFileSettings, playlist,   SLE_UINT8, S, 0,   0, 0,   5, 1,  STR_NULL, NULL),
       SDT_VAR(MusicFileSettings, music_vol,  SLE_UINT8, S, 0, 127, 0, 127, 1,  STR_NULL, NULL),
       SDT_VAR(MusicFileSettings, effect_vol, SLE_UINT8, S, 0, 127, 0, 127, 1,  STR_NULL, NULL),
      SDT_LIST(MusicFileSettings, custom_1,   SLE_UINT8, S, 0, NULL,            STR_NULL, NULL),
      SDT_LIST(MusicFileSettings, custom_2,   SLE_UINT8, S, 0, NULL,            STR_NULL, NULL),
      SDT_BOOL(MusicFileSettings, playing,               S, 0, true,            STR_NULL, NULL),
      SDT_BOOL(MusicFileSettings, shuffle,               S, 0, false,           STR_NULL, NULL),

    }

Definition at line 219 of file settings.h.