Files
@ r18227:b1309a1c6836
Branch filter:
Location: cpp/openttd-patchpack/source/src/table/settings.h.preamble
r18227:b1309a1c6836
8.0 KiB
text/plain
(svn r23073) -Update: Add another generated file to .hgignore.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | /* $Id$ */
/*
* This file is part of OpenTTD.
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file table/settings.h Settings to save in the savegame and config file. */
/* Callback function used in _settings[] as well as _company_settings[] */
static size_t ConvertLandscape(const char *value);
/****************************
* OTTD specific INI stuff
****************************/
/**
* 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).
* 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.
* 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.
*/
#define NSD_GENERAL(name, def, cmd, guiflags, min, max, interval, many, str, strval, proc, load)\
{name, (const void*)(size_t)(def), {(byte)cmd}, {(uint16)guiflags}, min, max, interval, many, str, strval, proc, load}
/* Macros for various objects to go in the configuration file.
* This section is for global variables */
#define SDTG_GENERAL(name, sdt_cmd, sle_cmd, type, flags, guiflags, var, length, def, min, max, interval, full, str, strval, proc, from, to)\
{NSD_GENERAL(name, def, sdt_cmd, guiflags, min, max, interval, full, str, strval, proc, NULL), SLEG_GENERAL(sle_cmd, var, type | flags, length, from, to)}
#define SDTG_VAR(name, type, flags, guiflags, var, def, min, max, interval, str, strval, proc, from, to)\
SDTG_GENERAL(name, SDT_NUMX, SL_VAR, type, flags, guiflags, var, 0, def, min, max, interval, NULL, str, strval, proc, from, to)
#define SDTG_BOOL(name, flags, guiflags, var, def, str, strval, proc, from, to)\
SDTG_GENERAL(name, SDT_BOOLX, SL_VAR, SLE_BOOL, flags, guiflags, var, 0, def, 0, 1, 0, NULL, str, strval, proc, from, to)
#define SDTG_LIST(name, type, length, flags, guiflags, var, def, str, strval, proc, from, to)\
SDTG_GENERAL(name, SDT_INTLIST, SL_ARR, type, flags, guiflags, var, length, def, 0, 0, 0, NULL, str, strval, proc, from, to)
#define SDTG_STR(name, type, flags, guiflags, var, def, str, strval, proc, from, to)\
SDTG_GENERAL(name, SDT_STRING, SL_STR, type, flags, guiflags, var, lengthof(var), def, 0, 0, 0, NULL, str, strval, proc, from, to)
#define SDTG_OMANY(name, type, flags, guiflags, var, def, max, full, str, strval, proc, from, to)\
SDTG_GENERAL(name, SDT_ONEOFMANY, SL_VAR, type, flags, guiflags, var, 0, def, 0, max, 0, full, str, strval, proc, from, to)
#define SDTG_MMANY(name, type, flags, guiflags, var, def, full, str, strval, proc, from, to)\
SDTG_GENERAL(name, SDT_MANYOFMANY, SL_VAR, type, flags, guiflags, var, 0, def, 0, 0, 0, full, str, strval, proc, from, to)
#define SDTG_NULL(length, from, to)\
{{"", NULL, {0}, {0}, 0, 0, 0, NULL, STR_NULL, STR_NULL, NULL, NULL}, SLEG_NULL(length, from, to)}
#define SDTG_END() {{NULL, NULL, {0}, {0}, 0, 0, 0, NULL, STR_NULL, STR_NULL, NULL, NULL}, SLEG_END()}
/* Macros for various objects to go in the configuration file.
* This section is for structures where their various members are saved */
#define SDT_GENERAL(name, sdt_cmd, sle_cmd, type, flags, guiflags, base, var, length, def, min, max, interval, full, str, strval, proc, load, from, to)\
{NSD_GENERAL(name, def, sdt_cmd, guiflags, min, max, interval, full, str, strval, proc, load), SLE_GENERAL(sle_cmd, base, var, type | flags, length, from, to)}
#define SDT_VAR(base, var, type, flags, guiflags, def, min, max, interval, str, strval, proc, from, to)\
SDT_GENERAL(#var, SDT_NUMX, SL_VAR, type, flags, guiflags, base, var, 1, def, min, max, interval, NULL, str, strval, proc, NULL, from, to)
#define SDT_BOOL(base, var, flags, guiflags, def, str, strval, proc, from, to)\
SDT_GENERAL(#var, SDT_BOOLX, SL_VAR, SLE_BOOL, flags, guiflags, base, var, 1, def, 0, 1, 0, NULL, str, strval, proc, NULL, from, to)
#define SDT_LIST(base, var, type, flags, guiflags, def, str, strval, proc, from, to)\
SDT_GENERAL(#var, SDT_INTLIST, SL_ARR, type, flags, guiflags, base, var, lengthof(((base*)8)->var), def, 0, 0, 0, NULL, str, strval, proc, NULL, from, to)
#define SDT_STR(base, var, type, flags, guiflags, def, str, strval, proc, from, to)\
SDT_GENERAL(#var, SDT_STRING, SL_STR, type, flags, guiflags, base, var, lengthof(((base*)8)->var), def, 0, 0, 0, NULL, str, strval, proc, NULL, from, to)
#define SDT_CHR(base, var, flags, guiflags, def, str, strval, proc, from, to)\
SDT_GENERAL(#var, SDT_STRING, SL_VAR, SLE_CHAR, flags, guiflags, base, var, 1, def, 0, 0, 0, NULL, str, strval, proc, NULL, from, to)
#define SDT_OMANY(base, var, type, flags, guiflags, def, max, full, str, strval, proc, from, to, load)\
SDT_GENERAL(#var, SDT_ONEOFMANY, SL_VAR, type, flags, guiflags, base, var, 1, def, 0, max, 0, full, str, strval, proc, load, from, to)
#define SDT_MMANY(base, var, type, flags, guiflags, def, full, str, proc, strval, from, to)\
SDT_GENERAL(#var, SDT_MANYOFMANY, SL_VAR, type, flags, guiflags, base, var, 1, def, 0, 0, 0, full, str, strval, proc, NULL, from, to)
#define SDT_NULL(length, from, to)\
{{"", NULL, {0}, {0}, 0, 0, 0, NULL, STR_NULL, STR_NULL, NULL, NULL}, SLE_CONDNULL(length, from, to)}
#define SDTC_VAR(var, type, flags, guiflags, def, min, max, interval, str, strval, proc, from, to)\
SDTG_GENERAL(#var, SDT_NUMX, SL_VAR, type, flags, guiflags, _settings_client.var, 1, def, min, max, interval, NULL, str, strval, proc, from, to)
#define SDTC_BOOL(var, flags, guiflags, def, str, strval, proc, from, to)\
SDTG_GENERAL(#var, SDT_BOOLX, SL_VAR, SLE_BOOL, flags, guiflags, _settings_client.var, 1, def, 0, 1, 0, NULL, str, strval, proc, from, to)
#define SDTC_LIST(var, type, flags, guiflags, def, str, strval, proc, from, to)\
SDTG_GENERAL(#var, SDT_INTLIST, SL_ARR, type, flags, guiflags, _settings_client.var, lengthof(_settings_client.var), def, 0, 0, 0, NULL, str, strval, proc, from, to)
#define SDTC_STR(var, type, flags, guiflags, def, str, strval, proc, from, to)\
SDTG_GENERAL(#var, SDT_STRING, SL_STR, type, flags, guiflags, _settings_client.var, lengthof(_settings_client.var), def, 0, 0, 0, NULL, str, strval, proc, from, to)
#define SDTC_OMANY(var, type, flags, guiflags, def, max, full, str, strval, proc, from, to)\
SDTG_GENERAL(#var, SDT_ONEOFMANY, SL_VAR, type, flags, guiflags, _settings_client.var, 1, def, 0, max, 0, full, str, strval, proc, from, to)
#define SDT_END() {{NULL, NULL, {0}, {0}, 0, 0, 0, NULL, STR_NULL, STR_NULL, NULL, NULL}, SLE_END()}
|