src/settings.cpp
author rubidium
Fri, 24 Oct 2008 20:53:57 +0000
changeset 10287 e84ee4b8ba7b
parent 10208 72c00af5c95d
child 10299 946c84fdc58e
permissions -rw-r--r--
(svn r14526) -Fix [FS#2379]: make sure trains stop at the end of a station; a 3/8th length train did stop 2/8th of it's length too early causing a 63/8th long train not to fit in a 4 tile station.
2186
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     1
/* $Id$ */
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     2
6420
456c275f3313 (svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents: 6380
diff changeset
     3
/** @file settings.cpp
3615
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
     4
 * All actions handling saving and loading of the settings/configuration goes on in this file.
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
     5
 * The file consists of four parts:
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
     6
 * <ol>
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
     7
 * <li>Parsing the configuration file (openttd.cfg). This is achieved with the ini_ functions which
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
     8
 *     handle various types, such as normal 'key = value' pairs, lists and value combinations of
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
     9
 *     lists, strings, integers, 'bit'-masks and element selections.
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
    10
 * <li>Defining the data structures that go into the configuration. These include for example
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
    11
 *     the _patches struct, but also network-settings, banlists, newgrf, etc. There are a lot
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
    12
 *     of helper macros available for the various types, and also saving/loading of these settings
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
    13
 *     in a savegame is handled inside these structures.
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
    14
 * <li>Handle reading and writing to the setting-structures from inside the game either from
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
    15
 *     the console for example or through the gui with CMD_ functions.
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
    16
 * <li>Handle saving/loading of the PATS chunk inside the savegame.
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
    17
 * </ol>
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
    18
 * @see SettingDesc
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
    19
 * @see SaveLoad
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
    20
 */
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
    21
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    22
#include "stdafx.h"
1891
862800791170 (svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents: 1777
diff changeset
    23
#include "openttd.h"
2291
c142846954ee (svn r2815) Store the currency information in one central place instead of scattering it in several unrelated files
tron
parents: 2191
diff changeset
    24
#include "currency.h"
2121
267f7d75d036 (svn r2631) Move screenshot related variables from variables.h to screenshot.[ch]
tron
parents: 2044
diff changeset
    25
#include "screenshot.h"
2153
ecfc674410b4 (svn r2663) Include variables.h only in these files which need it, not globally via openttd.h
tron
parents: 2125
diff changeset
    26
#include "variables.h"
5469
7edfc643abbc (svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents: 5346
diff changeset
    27
#include "network/network.h"
9428
1ba05b499957 (svn r13343) -Codechange: reorder/move variable/functions in the network headers so that nothing from the network directory needs to include basically all network headers.
rubidium
parents: 9426
diff changeset
    28
#include "network/network_func.h"
8208
3d0590aa2124 (svn r11771) -Codechange: split settings.h into better separated headers.
rubidium
parents: 8157
diff changeset
    29
#include "settings_internal.h"
8116
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents: 8114
diff changeset
    30
#include "command_func.h"
9336
6baad5b3033d (svn r13228) -Codechange: split console.h.
rubidium
parents: 9334
diff changeset
    31
#include "console_func.h"
3112
a6fda4d4c7ca (svn r3716) - Move the option settings (_game_opt_desc) from misc.c into settings.c. This will be merged with SettingDesc misc_settings above as they are actually the same. No functionality has changed beside the fact that the settings are now in a different Chunkhandler.
Darkvater
parents: 3052
diff changeset
    32
#include "saveload.h"
3358
c69b64a580b2 (svn r4153) -Codechange. Changed NPF_TILE_LENGTH into an enum and moved it out of variables.h. Just a drop in the bucket, but it is a start
celestar
parents: 3352
diff changeset
    33
#include "npf.h"
3900
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3874
diff changeset
    34
#include "yapf/yapf.h"
3628
69646d0924a5 (svn r4527) - Feature [NewGRF]: Add support for specifying parameters to GRF files. Usage: "mygrf = 1". You can pass up to 128 parameters, each one seperated by a comma or a space-character. Big thanks to peter1138 for the inspiration and examples.
Darkvater
parents: 3615
diff changeset
    35
#include "newgrf.h"
5228
26dc9acf7d94 (svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents: 5211
diff changeset
    36
#include "newgrf_config.h"
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4293
diff changeset
    37
#include "genworld.h"
5116
3c0c3da214ca (svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents: 5113
diff changeset
    38
#include "rail.h"
7753
ba9f36f97a33 (svn r11291) -Fix [FS#1345]: changing the wagon_speed_limits patch option caused desyncs.
rubidium
parents: 7742
diff changeset
    39
#include "train.h"
8763
81fadd257f67 (svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents: 8747
diff changeset
    40
#include "news_func.h"
8107
bb7deea89175 (svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents: 8106
diff changeset
    41
#include "window_func.h"
8114
dd6d21dc99c1 (svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents: 8113
diff changeset
    42
#include "strings_func.h"
8144
65cec0877b78 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents: 8140
diff changeset
    43
#include "vehicle_func.h"
8157
1505def01945 (svn r11719) -Codechange: split sound.h in a header with types and one with functions.
rubidium
parents: 8144
diff changeset
    44
#include "sound_func.h"
8213
7bdd7593eb9b (svn r11776) -Codechange: more header splittings to reduce the dependencies.
rubidium
parents: 8208
diff changeset
    45
#include "core/alloc_func.hpp"
10208
72c00af5c95d (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium
parents: 10207
diff changeset
    46
#include "company_func.h"
9085
8b3897a75aed (svn r12944) -Codechange: use rev.h instead of externs at many places
smatz
parents: 9070
diff changeset
    47
#include "rev.h"
5108
aeaef6fe53b7 (svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents: 5107
diff changeset
    48
#ifdef WITH_FREETYPE
aeaef6fe53b7 (svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents: 5107
diff changeset
    49
#include "fontcache.h"
aeaef6fe53b7 (svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents: 5107
diff changeset
    50
#endif
6803
9803e56a8d9c (svn r10042) -Codechange: Replace hardcoded spritecache size with a configuration
peter1138
parents: 6780
diff changeset
    51
#include "spritecache.h"
7849
0a1c0af2c96c (svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents: 7753
diff changeset
    52
#include "transparency.h"
8737
4405e2e80db6 (svn r12425) -Feature [FS#1846]: On Screen Keyboard for input fields so someone without a keyboard can enter text too. Patch by Dominik.
rubidium
parents: 8730
diff changeset
    53
#include "textbuf_gui.h"
8214
971f861d5543 (svn r11777) -Codechange: split the string header and make do not include it when it's not necessary.
rubidium
parents: 8213
diff changeset
    54
#include "string_func.h"
8809
e0d09d74e805 (svn r12550) -Change: the signal GUI is now persistent - has the same data when it is reopened
smatz
parents: 8806
diff changeset
    55
#include "rail_gui.h"
9154
2c042b567165 (svn r13016) -Codechange: unify the detection if rail catenary should be drawn
smatz
parents: 9152
diff changeset
    56
#include "elrail_func.h"
8264
b1e85998c7d3 (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8254
diff changeset
    57
#include "gui.h"
b1e85998c7d3 (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8254
diff changeset
    58
#include "town.h"
8275
f17d0c863ee3 (svn r11839) -Codechange: move some variables from variables.h to a more logical location.
rubidium
parents: 8265
diff changeset
    59
#include "video/video_driver.hpp"
f17d0c863ee3 (svn r11839) -Codechange: move some variables from variables.h to a more logical location.
rubidium
parents: 8265
diff changeset
    60
#include "sound/sound_driver.hpp"
f17d0c863ee3 (svn r11839) -Codechange: move some variables from variables.h to a more logical location.
rubidium
parents: 8265
diff changeset
    61
#include "music/music_driver.hpp"
f17d0c863ee3 (svn r11839) -Codechange: move some variables from variables.h to a more logical location.
rubidium
parents: 8265
diff changeset
    62
#include "blitter/factory.hpp"
10037
a06670f961a8 (svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium
parents: 10026
diff changeset
    63
#include "gfxinit.h"
9457
75f11a6caef8 (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents: 9451
diff changeset
    64
#include "gamelog.h"
9359
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
    65
#include "station_func.h"
9677
4767b9937c04 (svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138
parents: 9673
diff changeset
    66
#include "settings_func.h"
9996
fceaf224b2f0 (svn r14153) -Codechange: split ini file reading/saving from settings.cpp.
rubidium
parents: 9906
diff changeset
    67
#include "ini_type.h"
8264
b1e85998c7d3 (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8254
diff changeset
    68
b1e85998c7d3 (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8254
diff changeset
    69
#include "table/strings.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    70
9413
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
    71
ClientSettings _settings_client;
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
    72
GameSettings _settings_game;
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
    73
GameSettings _settings_newgame;
3121
72fb0554f9f1 (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
    74
3628
69646d0924a5 (svn r4527) - Feature [NewGRF]: Add support for specifying parameters to GRF files. Usage: "mygrf = 1". You can pass up to 128 parameters, each one seperated by a comma or a space-character. Big thanks to peter1138 for the inspiration and examples.
Darkvater
parents: 3615
diff changeset
    75
typedef const char *SettingListCallbackProc(const IniItem *item, uint index);
69646d0924a5 (svn r4527) - Feature [NewGRF]: Add support for specifying parameters to GRF files. Usage: "mygrf = 1". You can pass up to 128 parameters, each one seperated by a comma or a space-character. Big thanks to peter1138 for the inspiration and examples.
Darkvater
parents: 3615
diff changeset
    76
typedef void SettingDescProc(IniFile *ini, const SettingDesc *desc, const char *grpname, void *object);
69646d0924a5 (svn r4527) - Feature [NewGRF]: Add support for specifying parameters to GRF files. Usage: "mygrf = 1". You can pass up to 128 parameters, each one seperated by a comma or a space-character. Big thanks to peter1138 for the inspiration and examples.
Darkvater
parents: 3615
diff changeset
    77
typedef void SettingDescProcList(IniFile *ini, const char *grpname, char **list, uint len, SettingListCallbackProc proc);
69646d0924a5 (svn r4527) - Feature [NewGRF]: Add support for specifying parameters to GRF files. Usage: "mygrf = 1". You can pass up to 128 parameters, each one seperated by a comma or a space-character. Big thanks to peter1138 for the inspiration and examples.
Darkvater
parents: 3615
diff changeset
    78
3900
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3874
diff changeset
    79
static bool IsSignedVarMemType(VarType vt);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    80
9996
fceaf224b2f0 (svn r14153) -Codechange: split ini file reading/saving from settings.cpp.
rubidium
parents: 9906
diff changeset
    81
/**
fceaf224b2f0 (svn r14153) -Codechange: split ini file reading/saving from settings.cpp.
rubidium
parents: 9906
diff changeset
    82
 * Groups in openttd.cfg that are actually lists.
fceaf224b2f0 (svn r14153) -Codechange: split ini file reading/saving from settings.cpp.
rubidium
parents: 9906
diff changeset
    83
 */
fceaf224b2f0 (svn r14153) -Codechange: split ini file reading/saving from settings.cpp.
rubidium
parents: 9906
diff changeset
    84
static const char *_list_group_names[] = {
fceaf224b2f0 (svn r14153) -Codechange: split ini file reading/saving from settings.cpp.
rubidium
parents: 9906
diff changeset
    85
	"bans",
fceaf224b2f0 (svn r14153) -Codechange: split ini file reading/saving from settings.cpp.
rubidium
parents: 9906
diff changeset
    86
	"newgrf",
fceaf224b2f0 (svn r14153) -Codechange: split ini file reading/saving from settings.cpp.
rubidium
parents: 9906
diff changeset
    87
	"servers",
fceaf224b2f0 (svn r14153) -Codechange: split ini file reading/saving from settings.cpp.
rubidium
parents: 9906
diff changeset
    88
	NULL
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    89
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    90
3615
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
    91
/** Find the index value of a ONEofMANY type in a string seperated by |
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
    92
 * @param many full domain of values the ONEofMANY setting can have
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
    93
 * @param one the current value of the setting for which a value needs found
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
    94
 * @param onelen force calculation of the *one parameter
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
    95
 * @return the integer index of the full-list, or -1 if not found */
9152
e5a0faf9018c (svn r13014) -Fix (r13008): mingw revealed some signed/unsigned warnings
glx
parents: 9146
diff changeset
    96
static int lookup_oneofmany(const char *many, const char *one, size_t onelen = 0)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    97
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    98
	const char *s;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    99
	int idx;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   100
9152
e5a0faf9018c (svn r13014) -Fix (r13008): mingw revealed some signed/unsigned warnings
glx
parents: 9146
diff changeset
   101
	if (onelen == 0) onelen = strlen(one);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   102
6420
456c275f3313 (svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents: 6380
diff changeset
   103
	/* check if it's an integer */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   104
	if (*one >= '0' && *one <= '9')
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   105
		return strtoul(one, NULL, 0);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 188
diff changeset
   106
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   107
	idx = 0;
2952
58522ed8f0f1 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2923
diff changeset
   108
	for (;;) {
6420
456c275f3313 (svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents: 6380
diff changeset
   109
		/* find end of item */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   110
		s = many;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   111
		while (*s != '|' && *s != 0) s++;
9152
e5a0faf9018c (svn r13014) -Fix (r13008): mingw revealed some signed/unsigned warnings
glx
parents: 9146
diff changeset
   112
		if ((size_t)(s - many) == onelen && !memcmp(one, many, onelen)) return idx;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   113
		if (*s == 0) return -1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   114
		many = s + 1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   115
		idx++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   116
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   117
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   118
3615
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   119
/** Find the set-integer value MANYofMANY type in a string
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   120
 * @param many full domain of values the MANYofMANY setting can have
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   121
 * @param str the current string value of the setting, each individual
6483
ae78fc3c6b20 (svn r9664) -Documentation: Doxygen corrections,errors and omissions
belugas
parents: 6457
diff changeset
   122
 * of seperated by a whitespace,tab or | character
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   123
 * @return the 'fully' set integer, or -1 if a set is not found */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   124
static uint32 lookup_manyofmany(const char *many, const char *str)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   125
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   126
	const char *s;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   127
	int r;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   128
	uint32 res = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   129
2952
58522ed8f0f1 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2923
diff changeset
   130
	for (;;) {
6420
456c275f3313 (svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents: 6380
diff changeset
   131
		/* skip "whitespace" */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   132
		while (*str == ' ' || *str == '\t' || *str == '|') str++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   133
		if (*str == 0) break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   134
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   135
		s = str;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   136
		while (*s != 0 && *s != ' ' && *s != '\t' && *s != '|') s++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   137
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   138
		r = lookup_oneofmany(many, str, s - str);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   139
		if (r == -1) return (uint32)-1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   140
7931
b0a46cd92225 (svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13
parents: 7928
diff changeset
   141
		SetBit(res, r); // value found, set it
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   142
		if (*s == 0) break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   143
		str = s + 1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   144
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   145
	return res;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   146
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   147
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   148
/** Parse an integerlist string and set each found value
3615
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   149
 * @param p the string to be parsed. Each element in the list is seperated by a
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   150
 * comma or a space character
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   151
 * @param items pointer to the integerlist-array that will be filled with values
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   152
 * @param maxitems the maximum number of elements the integerlist-array has
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   153
 * @return returns the number of items found, or -1 on an error */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   154
static int parse_intlist(const char *p, int *items, int maxitems)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   155
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   156
	int n = 0, v;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   157
	char *end;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   158
2952
58522ed8f0f1 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2923
diff changeset
   159
	for (;;) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   160
		v = strtol(p, &end, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   161
		if (p == end || n == maxitems) return -1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   162
		p = end;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   163
		items[n++] = v;
3598
a02daaf41761 (svn r4489) - Codechange: some small cleanups in the settings-parser code, mainly substituting terminating 0 characters with '\0'.
Darkvater
parents: 3596
diff changeset
   164
		if (*p == '\0') break;
3599
c09257ed88f8 (svn r4490) - Feature: The integer-list parser now accepts a space character as an item seperator next to the comma.
Darkvater
parents: 3598
diff changeset
   165
		if (*p != ',' && *p != ' ') return -1;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   166
		p++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   167
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   168
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   169
	return n;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   170
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   171
3615
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   172
/** Load parsed string-values into an integer-array (intlist)
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   173
 * @param str the string that contains the values (and will be parsed)
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   174
 * @param array pointer to the integer-arrays that will be filled
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   175
 * @param nelems the number of elements the array holds. Maximum is 64 elements
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   176
 * @param type the type of elements the array holds (eg INT8, UINT16, etc.)
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   177
 * @return return true on success and false on error */
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   178
static bool load_intlist(const char *str, void *array, int nelems, VarType type)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   179
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   180
	int items[64];
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   181
	int i, nitems;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 188
diff changeset
   182
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   183
	if (str == NULL) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   184
		memset(items, 0, sizeof(items));
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   185
		nitems = nelems;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   186
	} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   187
		nitems = parse_intlist(str, items, lengthof(items));
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   188
		if (nitems != nelems) return false;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   189
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   190
2952
58522ed8f0f1 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2923
diff changeset
   191
	switch (type) {
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   192
	case SLE_VAR_BL:
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   193
	case SLE_VAR_I8:
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   194
	case SLE_VAR_U8:
2952
58522ed8f0f1 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2923
diff changeset
   195
		for (i = 0; i != nitems; i++) ((byte*)array)[i] = items[i];
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   196
		break;
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   197
	case SLE_VAR_I16:
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   198
	case SLE_VAR_U16:
2952
58522ed8f0f1 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2923
diff changeset
   199
		for (i = 0; i != nitems; i++) ((uint16*)array)[i] = items[i];
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   200
		break;
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   201
	case SLE_VAR_I32:
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   202
	case SLE_VAR_U32:
2952
58522ed8f0f1 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2923
diff changeset
   203
		for (i = 0; i != nitems; i++) ((uint32*)array)[i] = items[i];
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   204
		break;
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   205
	default: NOT_REACHED();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   206
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   207
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   208
	return true;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   209
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   210
3615
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   211
/** Convert an integer-array (intlist) to a string representation. Each value
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   212
 * is seperated by a comma or a space character
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   213
 * @param buf output buffer where the string-representation will be stored
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   214
 * @param array pointer to the integer-arrays that is read from
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   215
 * @param nelems the number of elements the array holds.
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   216
 * @param type the type of elements the array holds (eg INT8, UINT16, etc.) */
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   217
static void make_intlist(char *buf, const void *array, int nelems, VarType type)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   218
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   219
	int i, v = 0;
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   220
	const byte *p = (const byte*)array;
2952
58522ed8f0f1 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2923
diff changeset
   221
58522ed8f0f1 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2923
diff changeset
   222
	for (i = 0; i != nelems; i++) {
58522ed8f0f1 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2923
diff changeset
   223
		switch (type) {
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   224
		case SLE_VAR_BL:
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   225
		case SLE_VAR_I8:  v = *(int8*)p;   p += 1; break;
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   226
		case SLE_VAR_U8:  v = *(byte*)p;   p += 1; break;
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   227
		case SLE_VAR_I16: v = *(int16*)p;  p += 2; break;
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   228
		case SLE_VAR_U16: v = *(uint16*)p; p += 2; break;
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   229
		case SLE_VAR_I32: v = *(int32*)p;  p += 4; break;
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   230
		case SLE_VAR_U32: v = *(uint32*)p; p += 4; break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   231
		default: NOT_REACHED();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   232
		}
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   233
		buf += sprintf(buf, (i == 0) ? "%d" : ",%d", v);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   234
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   235
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   236
3615
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   237
/** Convert a ONEofMANY structure to a string representation.
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   238
 * @param buf output buffer where the string-representation will be stored
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   239
 * @param many the full-domain string of possible values
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   240
 * @param id the value of the variable and whose string-representation must be found */
2973
454819aa8fe0 (svn r3548) - [Patches]: rework two loops in make_oneofmany() and make_manyofmany()
Darkvater
parents: 2972
diff changeset
   241
static void make_oneofmany(char *buf, const char *many, int id)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   242
{
2973
454819aa8fe0 (svn r3548) - [Patches]: rework two loops in make_oneofmany() and make_manyofmany()
Darkvater
parents: 2972
diff changeset
   243
	int orig_id = id;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   244
6420
456c275f3313 (svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents: 6380
diff changeset
   245
	/* Look for the id'th element */
2973
454819aa8fe0 (svn r3548) - [Patches]: rework two loops in make_oneofmany() and make_manyofmany()
Darkvater
parents: 2972
diff changeset
   246
	while (--id >= 0) {
454819aa8fe0 (svn r3548) - [Patches]: rework two loops in make_oneofmany() and make_manyofmany()
Darkvater
parents: 2972
diff changeset
   247
		for (; *many != '|'; many++) {
454819aa8fe0 (svn r3548) - [Patches]: rework two loops in make_oneofmany() and make_manyofmany()
Darkvater
parents: 2972
diff changeset
   248
			if (*many == '\0') { // not found
454819aa8fe0 (svn r3548) - [Patches]: rework two loops in make_oneofmany() and make_manyofmany()
Darkvater
parents: 2972
diff changeset
   249
				sprintf(buf, "%d", orig_id);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   250
				return;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   251
			}
2973
454819aa8fe0 (svn r3548) - [Patches]: rework two loops in make_oneofmany() and make_manyofmany()
Darkvater
parents: 2972
diff changeset
   252
		}
454819aa8fe0 (svn r3548) - [Patches]: rework two loops in make_oneofmany() and make_manyofmany()
Darkvater
parents: 2972
diff changeset
   253
		many++; // pass the |-character
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   254
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   255
6420
456c275f3313 (svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents: 6380
diff changeset
   256
	/* copy string until next item (|) or the end of the list if this is the last one */
2973
454819aa8fe0 (svn r3548) - [Patches]: rework two loops in make_oneofmany() and make_manyofmany()
Darkvater
parents: 2972
diff changeset
   257
	while (*many != '\0' && *many != '|') *buf++ = *many++;
454819aa8fe0 (svn r3548) - [Patches]: rework two loops in make_oneofmany() and make_manyofmany()
Darkvater
parents: 2972
diff changeset
   258
	*buf = '\0';
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   259
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   260
3615
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   261
/** Convert a MANYofMANY structure to a string representation.
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   262
 * @param buf output buffer where the string-representation will be stored
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   263
 * @param many the full-domain string of possible values
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   264
 * @param x the value of the variable and whose string-representation must
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   265
 *        be found in the bitmasked many string */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   266
static void make_manyofmany(char *buf, const char *many, uint32 x)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   267
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   268
	const char *start;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   269
	int i = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   270
	bool init = true;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   271
2973
454819aa8fe0 (svn r3548) - [Patches]: rework two loops in make_oneofmany() and make_manyofmany()
Darkvater
parents: 2972
diff changeset
   272
	for (; x != 0; x >>= 1, i++) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   273
		start = many;
2973
454819aa8fe0 (svn r3548) - [Patches]: rework two loops in make_oneofmany() and make_manyofmany()
Darkvater
parents: 2972
diff changeset
   274
		while (*many != 0 && *many != '|') many++; // advance to the next element
454819aa8fe0 (svn r3548) - [Patches]: rework two loops in make_oneofmany() and make_manyofmany()
Darkvater
parents: 2972
diff changeset
   275
7928
63e18de69e50 (svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents: 7927
diff changeset
   276
		if (HasBit(x, 0)) { // item found, copy it
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   277
			if (!init) *buf++ = '|';
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   278
			init = false;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   279
			if (start == many) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   280
				buf += sprintf(buf, "%d", i);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   281
			} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   282
				memcpy(buf, start, many - start);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   283
				buf += many - start;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   284
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   285
		}
2973
454819aa8fe0 (svn r3548) - [Patches]: rework two loops in make_oneofmany() and make_manyofmany()
Darkvater
parents: 2972
diff changeset
   286
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   287
		if (*many == '|') many++;
2973
454819aa8fe0 (svn r3548) - [Patches]: rework two loops in make_oneofmany() and make_manyofmany()
Darkvater
parents: 2972
diff changeset
   288
	}
454819aa8fe0 (svn r3548) - [Patches]: rework two loops in make_oneofmany() and make_manyofmany()
Darkvater
parents: 2972
diff changeset
   289
454819aa8fe0 (svn r3548) - [Patches]: rework two loops in make_oneofmany() and make_manyofmany()
Darkvater
parents: 2972
diff changeset
   290
	*buf = '\0';
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   291
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   292
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   293
/** Convert a string representation (external) of a setting to the internal rep.
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   294
 * @param desc SettingDesc struct that holds all information about the variable
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   295
 * @param str input string that will be parsed based on the type of desc
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   296
 * @return return the parsed value of the setting */
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   297
static const void *string_to_val(const SettingDescBase *desc, const char *str)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   298
{
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   299
	switch (desc->cmd) {
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   300
	case SDT_NUMX: {
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   301
		char *end;
2991
8a6e9bfa2f2f (svn r3567) -Fix: for once and for all, use 'unsigned long' if you want to cast something
truelight
parents: 2975
diff changeset
   302
		unsigned long val = strtoul(str, &end, 0);
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   303
		if (*end != '\0') ShowInfoF("ini: trailing characters at end of setting '%s'", desc->name);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   304
		return (void*)val;
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   305
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   306
	case SDT_ONEOFMANY: {
9152
e5a0faf9018c (svn r13014) -Fix (r13008): mingw revealed some signed/unsigned warnings
glx
parents: 9146
diff changeset
   307
		long r = lookup_oneofmany(desc->many, str);
6356
2f7f41367170 (svn r9399) -Feature: Openttd.cfg will now present landscape patch entry as been temperate, arctic, tropic or toyland.
belugas
parents: 6355
diff changeset
   308
		/* if the first attempt of conversion from string to the appropriate value fails,
2f7f41367170 (svn r9399) -Feature: Openttd.cfg will now present landscape patch entry as been temperate, arctic, tropic or toyland.
belugas
parents: 6355
diff changeset
   309
		 * look if we have defined a converter from old value to new value. */
2f7f41367170 (svn r9399) -Feature: Openttd.cfg will now present landscape patch entry as been temperate, arctic, tropic or toyland.
belugas
parents: 6355
diff changeset
   310
		if (r == -1 && desc->proc_cnvt != NULL) r = desc->proc_cnvt(str);
2f7f41367170 (svn r9399) -Feature: Openttd.cfg will now present landscape patch entry as been temperate, arctic, tropic or toyland.
belugas
parents: 6355
diff changeset
   311
		if (r != -1) return (void*)r; //and here goes converted value
2f7f41367170 (svn r9399) -Feature: Openttd.cfg will now present landscape patch entry as been temperate, arctic, tropic or toyland.
belugas
parents: 6355
diff changeset
   312
		ShowInfoF("ini: invalid value '%s' for '%s'", str, desc->name); //sorry, we failed
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   313
		return 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   314
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   315
	case SDT_MANYOFMANY: {
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   316
		unsigned long r = lookup_manyofmany(desc->many, str);
2923
f4d43b8c6a40 (svn r3479) -Fix: fixed warnings on 64bit platforms (anyway, most 64bit platforms)
truelight
parents: 2919
diff changeset
   317
		if (r != (unsigned long)-1) return (void*)r;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   318
		ShowInfoF("ini: invalid value '%s' for '%s'", str, desc->name);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   319
		return 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   320
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   321
	case SDT_BOOLX:
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   322
		if (strcmp(str, "true")  == 0 || strcmp(str, "on")  == 0 || strcmp(str, "1") == 0)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   323
			return (void*)true;
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   324
		if (strcmp(str, "false") == 0 || strcmp(str, "off") == 0 || strcmp(str, "0") == 0)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   325
			return (void*)false;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   326
		ShowInfoF("ini: invalid setting value '%s' for '%s'", str, desc->name);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   327
		break;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 188
diff changeset
   328
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   329
	case SDT_STRING:
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   330
	case SDT_INTLIST: return str;
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
   331
	default: break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   332
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   333
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   334
	return NULL;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   335
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   336
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   337
/** Set the value of a setting and if needed clamp the value to
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   338
 * the preset minimum and maximum.
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   339
 * @param ptr the variable itself
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   340
 * @param sd pointer to the 'information'-database of the variable
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   341
 * @param val signed long version of the new value
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   342
 * @pre SettingDesc is of type SDT_BOOLX, SDT_NUMX,
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   343
 * SDT_ONEOFMANY or SDT_MANYOFMANY. Other types are not supported as of now */
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   344
static void Write_ValidateSetting(void *ptr, const SettingDesc *sd, int32 val)
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   345
{
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   346
	const SettingDescBase *sdb = &sd->desc;
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   347
4077
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4065
diff changeset
   348
	if (sdb->cmd != SDT_BOOLX &&
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4065
diff changeset
   349
			sdb->cmd != SDT_NUMX &&
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4065
diff changeset
   350
			sdb->cmd != SDT_ONEOFMANY &&
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4065
diff changeset
   351
			sdb->cmd != SDT_MANYOFMANY) {
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4065
diff changeset
   352
		return;
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4065
diff changeset
   353
	}
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   354
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   355
	/* We cannot know the maximum value of a bitset variable, so just have faith */
3352
99e5e3634e9d (svn r4142) - Fix [FS#74]: Incorrectly loaded settings from the config file when the signed uint32 variable would be negative.
Darkvater
parents: 3342
diff changeset
   356
	if (sdb->cmd != SDT_MANYOFMANY) {
99e5e3634e9d (svn r4142) - Fix [FS#74]: Incorrectly loaded settings from the config file when the signed uint32 variable would be negative.
Darkvater
parents: 3342
diff changeset
   357
		/* We need to take special care of the uint32 type as we receive from the function
99e5e3634e9d (svn r4142) - Fix [FS#74]: Incorrectly loaded settings from the config file when the signed uint32 variable would be negative.
Darkvater
parents: 3342
diff changeset
   358
		 * a signed integer. While here also bail out on 64-bit settings as those are not
99e5e3634e9d (svn r4142) - Fix [FS#74]: Incorrectly loaded settings from the config file when the signed uint32 variable would be negative.
Darkvater
parents: 3342
diff changeset
   359
		 * supported. Unsigned 8 and 16-bit variables are safe since they fit into a signed
99e5e3634e9d (svn r4142) - Fix [FS#74]: Incorrectly loaded settings from the config file when the signed uint32 variable would be negative.
Darkvater
parents: 3342
diff changeset
   360
		 * 32-bit variable
99e5e3634e9d (svn r4142) - Fix [FS#74]: Incorrectly loaded settings from the config file when the signed uint32 variable would be negative.
Darkvater
parents: 3342
diff changeset
   361
		 * TODO: Support 64-bit settings/variables */
99e5e3634e9d (svn r4142) - Fix [FS#74]: Incorrectly loaded settings from the config file when the signed uint32 variable would be negative.
Darkvater
parents: 3342
diff changeset
   362
		switch (GetVarMemType(sd->save.conv)) {
99e5e3634e9d (svn r4142) - Fix [FS#74]: Incorrectly loaded settings from the config file when the signed uint32 variable would be negative.
Darkvater
parents: 3342
diff changeset
   363
			case SLE_VAR_BL:
99e5e3634e9d (svn r4142) - Fix [FS#74]: Incorrectly loaded settings from the config file when the signed uint32 variable would be negative.
Darkvater
parents: 3342
diff changeset
   364
			case SLE_VAR_I8:
99e5e3634e9d (svn r4142) - Fix [FS#74]: Incorrectly loaded settings from the config file when the signed uint32 variable would be negative.
Darkvater
parents: 3342
diff changeset
   365
			case SLE_VAR_U8:
99e5e3634e9d (svn r4142) - Fix [FS#74]: Incorrectly loaded settings from the config file when the signed uint32 variable would be negative.
Darkvater
parents: 3342
diff changeset
   366
			case SLE_VAR_I16:
99e5e3634e9d (svn r4142) - Fix [FS#74]: Incorrectly loaded settings from the config file when the signed uint32 variable would be negative.
Darkvater
parents: 3342
diff changeset
   367
			case SLE_VAR_U16:
99e5e3634e9d (svn r4142) - Fix [FS#74]: Incorrectly loaded settings from the config file when the signed uint32 variable would be negative.
Darkvater
parents: 3342
diff changeset
   368
			case SLE_VAR_I32: {
99e5e3634e9d (svn r4142) - Fix [FS#74]: Incorrectly loaded settings from the config file when the signed uint32 variable would be negative.
Darkvater
parents: 3342
diff changeset
   369
				/* Override the minimum value. No value below sdb->min, except special value 0 */
99e5e3634e9d (svn r4142) - Fix [FS#74]: Incorrectly loaded settings from the config file when the signed uint32 variable would be negative.
Darkvater
parents: 3342
diff changeset
   370
				int32 min = ((sdb->flags & SGF_0ISDISABLED) && val <= sdb->min) ? 0 : sdb->min;
7922
a7e266f966d9 (svn r11475) -Codechange: rename clamp and clampu to Clamp and ClampU to fit with the coding style
skidd13
parents: 7901
diff changeset
   371
				val = Clamp(val, min, sdb->max);
3352
99e5e3634e9d (svn r4142) - Fix [FS#74]: Incorrectly loaded settings from the config file when the signed uint32 variable would be negative.
Darkvater
parents: 3342
diff changeset
   372
			} break;
99e5e3634e9d (svn r4142) - Fix [FS#74]: Incorrectly loaded settings from the config file when the signed uint32 variable would be negative.
Darkvater
parents: 3342
diff changeset
   373
			case SLE_VAR_U32: {
99e5e3634e9d (svn r4142) - Fix [FS#74]: Incorrectly loaded settings from the config file when the signed uint32 variable would be negative.
Darkvater
parents: 3342
diff changeset
   374
				/* Override the minimum value. No value below sdb->min, except special value 0 */
99e5e3634e9d (svn r4142) - Fix [FS#74]: Incorrectly loaded settings from the config file when the signed uint32 variable would be negative.
Darkvater
parents: 3342
diff changeset
   375
				uint min = ((sdb->flags & SGF_0ISDISABLED) && (uint)val <= (uint)sdb->min) ? 0 : sdb->min;
7922
a7e266f966d9 (svn r11475) -Codechange: rename clamp and clampu to Clamp and ClampU to fit with the coding style
skidd13
parents: 7901
diff changeset
   376
				WriteValue(ptr, SLE_VAR_U32, (int64)ClampU(val, min, sdb->max));
3352
99e5e3634e9d (svn r4142) - Fix [FS#74]: Incorrectly loaded settings from the config file when the signed uint32 variable would be negative.
Darkvater
parents: 3342
diff changeset
   377
				return;
99e5e3634e9d (svn r4142) - Fix [FS#74]: Incorrectly loaded settings from the config file when the signed uint32 variable would be negative.
Darkvater
parents: 3342
diff changeset
   378
			}
99e5e3634e9d (svn r4142) - Fix [FS#74]: Incorrectly loaded settings from the config file when the signed uint32 variable would be negative.
Darkvater
parents: 3342
diff changeset
   379
			case SLE_VAR_I64:
99e5e3634e9d (svn r4142) - Fix [FS#74]: Incorrectly loaded settings from the config file when the signed uint32 variable would be negative.
Darkvater
parents: 3342
diff changeset
   380
			case SLE_VAR_U64:
99e5e3634e9d (svn r4142) - Fix [FS#74]: Incorrectly loaded settings from the config file when the signed uint32 variable would be negative.
Darkvater
parents: 3342
diff changeset
   381
			default: NOT_REACHED(); break;
99e5e3634e9d (svn r4142) - Fix [FS#74]: Incorrectly loaded settings from the config file when the signed uint32 variable would be negative.
Darkvater
parents: 3342
diff changeset
   382
		}
99e5e3634e9d (svn r4142) - Fix [FS#74]: Incorrectly loaded settings from the config file when the signed uint32 variable would be negative.
Darkvater
parents: 3342
diff changeset
   383
	}
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   384
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   385
	WriteValue(ptr, sd->save.conv, (int64)val);
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   386
}
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   387
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   388
/** Load values from a group of an IniFile structure into the internal representation
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   389
 * @param ini pointer to IniFile structure that holds administrative information
3615
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   390
 * @param sd pointer to SettingDesc structure whose internally pointed variables will
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   391
 *        be given values
6483
ae78fc3c6b20 (svn r9664) -Documentation: Doxygen corrections,errors and omissions
belugas
parents: 6457
diff changeset
   392
 * @param grpname the group of the IniFile to search in for the new values
ae78fc3c6b20 (svn r9664) -Documentation: Doxygen corrections,errors and omissions
belugas
parents: 6457
diff changeset
   393
 * @param object pointer to the object been loaded */
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   394
static void ini_load_settings(IniFile *ini, const SettingDesc *sd, const char *grpname, void *object)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   395
{
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   396
	IniGroup *group;
9996
fceaf224b2f0 (svn r14153) -Codechange: split ini file reading/saving from settings.cpp.
rubidium
parents: 9906
diff changeset
   397
	IniGroup *group_def = ini->GetGroup(grpname);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   398
	IniItem *item;
222
b88456001397 (svn r223) -Fix: Const correctness and miscellaneous fixes. Thank you Tron for your diligent fixing of warnings (and some possibly bugs) (Tron)
darkvater
parents: 193
diff changeset
   399
	const void *p;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   400
	void *ptr;
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   401
	const char *s;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   402
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   403
	for (; sd->save.cmd != SL_END; sd++) {
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   404
		const SettingDescBase *sdb = &sd->desc;
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   405
		const SaveLoad        *sld = &sd->save;
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   406
3117
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
   407
		if (!SlIsObjectCurrentlyValid(sld->version_from, sld->version_to)) continue;
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
   408
9354
845e07db4549 (svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents: 9350
diff changeset
   409
		/* For patches.xx.yy load the settings from [xx] yy = ? */
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   410
		s = strchr(sdb->name, '.');
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   411
		if (s != NULL) {
9996
fceaf224b2f0 (svn r14153) -Codechange: split ini file reading/saving from settings.cpp.
rubidium
parents: 9906
diff changeset
   412
			group = ini->GetGroup(sdb->name, s - sdb->name);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   413
			s++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   414
		} else {
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   415
			s = sdb->name;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   416
			group = group_def;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   417
		}
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 188
diff changeset
   418
9996
fceaf224b2f0 (svn r14153) -Codechange: split ini file reading/saving from settings.cpp.
rubidium
parents: 9906
diff changeset
   419
		item = group->GetItem(s, false);
9354
845e07db4549 (svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents: 9350
diff changeset
   420
		if (item == NULL && group != group_def) {
845e07db4549 (svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents: 9350
diff changeset
   421
			/* For patches.xx.yy load the settings from [patches] yy = ? in case the previous
845e07db4549 (svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents: 9350
diff changeset
   422
			 * did not exist (e.g. loading old config files with a [patches] section */
9996
fceaf224b2f0 (svn r14153) -Codechange: split ini file reading/saving from settings.cpp.
rubidium
parents: 9906
diff changeset
   423
			item = group_def->GetItem(s, false);
9354
845e07db4549 (svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents: 9350
diff changeset
   424
		}
845e07db4549 (svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents: 9350
diff changeset
   425
		if (item == NULL) {
845e07db4549 (svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents: 9350
diff changeset
   426
			/* For patches.xx.zz.yy load the settings from [zz] yy = ? in case the previous
845e07db4549 (svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents: 9350
diff changeset
   427
			 * did not exist (e.g. loading old config files with a [yapf] section */
845e07db4549 (svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents: 9350
diff changeset
   428
			const char *sc = strchr(s, '.');
9996
fceaf224b2f0 (svn r14153) -Codechange: split ini file reading/saving from settings.cpp.
rubidium
parents: 9906
diff changeset
   429
			if (sc != NULL) item = ini->GetGroup(s, sc - s)->GetItem(sc + 1, false);
9354
845e07db4549 (svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents: 9350
diff changeset
   430
		}
845e07db4549 (svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents: 9350
diff changeset
   431
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   432
		p = (item == NULL) ? sdb->def : string_to_val(sdb, item->value);
9413
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
   433
		ptr = GetVariableAddress(object, sld);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 188
diff changeset
   434
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   435
		switch (sdb->cmd) {
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   436
		case SDT_BOOLX: /* All four are various types of (integer) numbers */
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   437
		case SDT_NUMX:
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   438
		case SDT_ONEOFMANY:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   439
		case SDT_MANYOFMANY:
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   440
			Write_ValidateSetting(ptr, sd, (unsigned long)p); break;
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   441
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   442
		case SDT_STRING:
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   443
			switch (GetVarMemType(sld->conv)) {
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   444
				case SLE_VAR_STRB:
4255
e550bf3de1c8 (svn r5871) -Feature: Add a possibility to handle pointer strings without a buffer from the configuration file. Handy for variables that will never be changed during runtime
Darkvater
parents: 4143
diff changeset
   445
				case SLE_VAR_STRBQ:
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
   446
					if (p != NULL) ttd_strlcpy((char*)ptr, (const char*)p, sld->length);
4255
e550bf3de1c8 (svn r5871) -Feature: Add a possibility to handle pointer strings without a buffer from the configuration file. Handy for variables that will never be changed during runtime
Darkvater
parents: 4143
diff changeset
   447
					break;
e550bf3de1c8 (svn r5871) -Feature: Add a possibility to handle pointer strings without a buffer from the configuration file. Handy for variables that will never be changed during runtime
Darkvater
parents: 4143
diff changeset
   448
				case SLE_VAR_STR:
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   449
				case SLE_VAR_STRQ:
4255
e550bf3de1c8 (svn r5871) -Feature: Add a possibility to handle pointer strings without a buffer from the configuration file. Handy for variables that will never be changed during runtime
Darkvater
parents: 4143
diff changeset
   450
					if (p != NULL) {
e550bf3de1c8 (svn r5871) -Feature: Add a possibility to handle pointer strings without a buffer from the configuration file. Handy for variables that will never be changed during runtime
Darkvater
parents: 4143
diff changeset
   451
						free(*(char**)ptr);
e550bf3de1c8 (svn r5871) -Feature: Add a possibility to handle pointer strings without a buffer from the configuration file. Handy for variables that will never be changed during runtime
Darkvater
parents: 4143
diff changeset
   452
						*(char**)ptr = strdup((const char*)p);
e550bf3de1c8 (svn r5871) -Feature: Add a possibility to handle pointer strings without a buffer from the configuration file. Handy for variables that will never be changed during runtime
Darkvater
parents: 4143
diff changeset
   453
					}
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   454
					break;
3192
ad4404f6d03d (svn r3852) - Revert r3733 which fixed the default value loading for char, but broke loading a set value. Added a better fix which needs a char value to be a string (eg enclosed in double-quotes)
Darkvater
parents: 3152
diff changeset
   455
				case SLE_VAR_CHAR: *(char*)ptr = *(char*)p; break;
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   456
				default: NOT_REACHED(); break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   457
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   458
			break;
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   459
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   460
		case SDT_INTLIST: {
9334
28ac6c8e0795 (svn r13226) -Feature: Allow to have more than only two airports per town. The number of airports is now controlled by the noise each of them generates, the distance from town's center and how tolerant the town is.
belugas
parents: 9194
diff changeset
   461
			if (!load_intlist((const char*)p, ptr, sld->length, GetVarMemType(sld->conv))) {
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   462
				ShowInfoF("ini: error in array '%s'", sdb->name);
9334
28ac6c8e0795 (svn r13226) -Feature: Allow to have more than only two airports per town. The number of airports is now controlled by the noise each of them generates, the distance from town's center and how tolerant the town is.
belugas
parents: 9194
diff changeset
   463
			} else if (sd->desc.proc_cnvt != NULL) {
28ac6c8e0795 (svn r13226) -Feature: Allow to have more than only two airports per town. The number of airports is now controlled by the noise each of them generates, the distance from town's center and how tolerant the town is.
belugas
parents: 9194
diff changeset
   464
				sd->desc.proc_cnvt((const char*)p);
28ac6c8e0795 (svn r13226) -Feature: Allow to have more than only two airports per town. The number of airports is now controlled by the noise each of them generates, the distance from town's center and how tolerant the town is.
belugas
parents: 9194
diff changeset
   465
			}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   466
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   467
		}
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   468
		default: NOT_REACHED(); break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   469
		}
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 188
diff changeset
   470
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   471
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   472
3615
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   473
/** Save the values of settings to the inifile.
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   474
 * @param ini pointer to IniFile structure
3615
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   475
 * @param sd read-only SettingDesc structure which contains the unmodified,
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   476
 *        loaded values of the configuration file and various information about it
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   477
 * @param grpname holds the name of the group (eg. [network]) where these will be saved
6483
ae78fc3c6b20 (svn r9664) -Documentation: Doxygen corrections,errors and omissions
belugas
parents: 6457
diff changeset
   478
 * @param object pointer to the object been saved
4000
4009d092b306 (svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents: 3982
diff changeset
   479
 * The function works as follows: for each item in the SettingDesc structure we
4009d092b306 (svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents: 3982
diff changeset
   480
 * have a look if the value has changed since we started the game (the original
4009d092b306 (svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents: 3982
diff changeset
   481
 * values are reloaded when saving). If settings indeed have changed, we get
4009d092b306 (svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents: 3982
diff changeset
   482
 * these and save them.
4009d092b306 (svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents: 3982
diff changeset
   483
 */
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   484
static void ini_save_settings(IniFile *ini, const SettingDesc *sd, const char *grpname, void *object)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   485
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   486
	IniGroup *group_def = NULL, *group;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   487
	IniItem *item;
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   488
	char buf[512];
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   489
	const char *s;
222
b88456001397 (svn r223) -Fix: Const correctness and miscellaneous fixes. Thank you Tron for your diligent fixing of warnings (and some possibly bugs) (Tron)
darkvater
parents: 193
diff changeset
   490
	void *ptr;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   491
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   492
	for (; sd->save.cmd != SL_END; sd++) {
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   493
		const SettingDescBase *sdb = &sd->desc;
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   494
		const SaveLoad        *sld = &sd->save;
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   495
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   496
		/* If the setting is not saved to the configuration
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   497
		 * file, just continue with the next setting */
3117
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
   498
		if (!SlIsObjectCurrentlyValid(sld->version_from, sld->version_to)) continue;
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   499
		if (sld->conv & SLF_CONFIG_NO) continue;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 188
diff changeset
   500
6420
456c275f3313 (svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents: 6380
diff changeset
   501
		/* XXX - wtf is this?? (group override?) */
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   502
		s = strchr(sdb->name, '.');
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   503
		if (s != NULL) {
9996
fceaf224b2f0 (svn r14153) -Codechange: split ini file reading/saving from settings.cpp.
rubidium
parents: 9906
diff changeset
   504
			group = ini->GetGroup(sdb->name, s - sdb->name);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   505
			s++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   506
		} else {
9996
fceaf224b2f0 (svn r14153) -Codechange: split ini file reading/saving from settings.cpp.
rubidium
parents: 9906
diff changeset
   507
			if (group_def == NULL) group_def = ini->GetGroup(grpname);
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   508
			s = sdb->name;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   509
			group = group_def;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   510
		}
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 188
diff changeset
   511
9996
fceaf224b2f0 (svn r14153) -Codechange: split ini file reading/saving from settings.cpp.
rubidium
parents: 9906
diff changeset
   512
		item = group->GetItem(s, true);
5141
63e24cb6f071 (svn r7231) -Codechange: rename ini_get_variable to GetVariableAddress for use both in settings.c
Darkvater
parents: 5116
diff changeset
   513
		ptr = GetVariableAddress(object, sld);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 188
diff changeset
   514
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   515
		if (item->value != NULL) {
6420
456c275f3313 (svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents: 6380
diff changeset
   516
			/* check if the value is the same as the old value */
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   517
			const void *p = string_to_val(sdb, item->value);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   518
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   519
			/* The main type of a variable/setting is in bytes 8-15
4549
106ed18a7675 (svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents: 4511
diff changeset
   520
			 * The subtype (what kind of numbers do we have there) is in 0-7 */
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   521
			switch (sdb->cmd) {
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   522
			case SDT_BOOLX:
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   523
			case SDT_NUMX:
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   524
			case SDT_ONEOFMANY:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   525
			case SDT_MANYOFMANY:
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   526
				switch (GetVarMemType(sld->conv)) {
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   527
				case SLE_VAR_BL:
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
   528
					if (*(bool*)ptr == (p != NULL)) continue;
5066
04e428f911be (svn r7124) -Fix (r37xx): sizeof(bool) = 4 for (certain) OSX do not assume it is 1. This would break
Darkvater
parents: 5052
diff changeset
   529
					break;
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   530
				case SLE_VAR_I8:
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   531
				case SLE_VAR_U8:
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   532
					if (*(byte*)ptr == (byte)(unsigned long)p) continue;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   533
					break;
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   534
				case SLE_VAR_I16:
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   535
				case SLE_VAR_U16:
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   536
					if (*(uint16*)ptr == (uint16)(unsigned long)p) continue;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   537
					break;
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   538
				case SLE_VAR_I32:
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   539
				case SLE_VAR_U32:
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   540
					if (*(uint32*)ptr == (uint32)(unsigned long)p) continue;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   541
					break;
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   542
				default: NOT_REACHED();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   543
				}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   544
				break;
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   545
			default: break; /* Assume the other types are always changed */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   546
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   547
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   548
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   549
		/* Value has changed, get the new value and put it into a buffer */
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   550
		switch (sdb->cmd) {
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   551
		case SDT_BOOLX:
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   552
		case SDT_NUMX:
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   553
		case SDT_ONEOFMANY:
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   554
		case SDT_MANYOFMANY: {
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   555
			uint32 i = (uint32)ReadValue(ptr, sld->conv);
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   556
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   557
			switch (sdb->cmd) {
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   558
			case SDT_BOOLX:      strcpy(buf, (i != 0) ? "true" : "false"); break;
3900
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3874
diff changeset
   559
			case SDT_NUMX:       sprintf(buf, IsSignedVarMemType(sld->conv) ? "%d" : "%u", i); break;
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   560
			case SDT_ONEOFMANY:  make_oneofmany(buf, sdb->many, i); break;
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   561
			case SDT_MANYOFMANY: make_manyofmany(buf, sdb->many, i); break;
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   562
			default: NOT_REACHED();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   563
			}
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   564
		} break;
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   565
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   566
		case SDT_STRING:
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   567
			switch (GetVarMemType(sld->conv)) {
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   568
			case SLE_VAR_STRB: strcpy(buf, (char*)ptr); break;
4255
e550bf3de1c8 (svn r5871) -Feature: Add a possibility to handle pointer strings without a buffer from the configuration file. Handy for variables that will never be changed during runtime
Darkvater
parents: 4143
diff changeset
   569
			case SLE_VAR_STRBQ:sprintf(buf, "\"%s\"", (char*)ptr); break;
e550bf3de1c8 (svn r5871) -Feature: Add a possibility to handle pointer strings without a buffer from the configuration file. Handy for variables that will never be changed during runtime
Darkvater
parents: 4143
diff changeset
   570
			case SLE_VAR_STR:  strcpy(buf, *(char**)ptr); break;
e550bf3de1c8 (svn r5871) -Feature: Add a possibility to handle pointer strings without a buffer from the configuration file. Handy for variables that will never be changed during runtime
Darkvater
parents: 4143
diff changeset
   571
			case SLE_VAR_STRQ: sprintf(buf, "\"%s\"", *(char**)ptr); break;
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   572
			case SLE_VAR_CHAR: sprintf(buf, "\"%c\"", *(char*)ptr); break;
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   573
			default: NOT_REACHED();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   574
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   575
			break;
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   576
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   577
		case SDT_INTLIST:
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   578
			make_intlist(buf, ptr, sld->length, GetVarMemType(sld->conv));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   579
			break;
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   580
		default: NOT_REACHED();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   581
		}
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   582
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   583
		/* The value is different, that means we have to write it to the ini */
9996
fceaf224b2f0 (svn r14153) -Codechange: split ini file reading/saving from settings.cpp.
rubidium
parents: 9906
diff changeset
   584
		free(item->value);
fceaf224b2f0 (svn r14153) -Codechange: split ini file reading/saving from settings.cpp.
rubidium
parents: 9906
diff changeset
   585
		item->value = strdup(buf);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 188
diff changeset
   586
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   587
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   588
3615
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   589
/** Loads all items from a 'grpname' section into a list
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   590
 * The list parameter can be a NULL pointer, in this case nothing will be
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   591
 * saved and a callback function should be defined that will take over the
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   592
 * list-handling and store the data itself somewhere.
6483
ae78fc3c6b20 (svn r9664) -Documentation: Doxygen corrections,errors and omissions
belugas
parents: 6457
diff changeset
   593
 * @param ini IniFile handle to the ini file with the source data
3615
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   594
 * @param grpname character string identifying the section-header of the ini
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   595
 * file that will be parsed
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   596
 * @param list pointer to an string(pointer) array that will store the parsed
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   597
 * entries of the given section
3628
69646d0924a5 (svn r4527) - Feature [NewGRF]: Add support for specifying parameters to GRF files. Usage: "mygrf = 1". You can pass up to 128 parameters, each one seperated by a comma or a space-character. Big thanks to peter1138 for the inspiration and examples.
Darkvater
parents: 3615
diff changeset
   598
 * @param len the maximum number of items available for the above list
69646d0924a5 (svn r4527) - Feature [NewGRF]: Add support for specifying parameters to GRF files. Usage: "mygrf = 1". You can pass up to 128 parameters, each one seperated by a comma or a space-character. Big thanks to peter1138 for the inspiration and examples.
Darkvater
parents: 3615
diff changeset
   599
 * @param proc callback function that can override how the values are stored
69646d0924a5 (svn r4527) - Feature [NewGRF]: Add support for specifying parameters to GRF files. Usage: "mygrf = 1". You can pass up to 128 parameters, each one seperated by a comma or a space-character. Big thanks to peter1138 for the inspiration and examples.
Darkvater
parents: 3615
diff changeset
   600
 * inside the list */
69646d0924a5 (svn r4527) - Feature [NewGRF]: Add support for specifying parameters to GRF files. Usage: "mygrf = 1". You can pass up to 128 parameters, each one seperated by a comma or a space-character. Big thanks to peter1138 for the inspiration and examples.
Darkvater
parents: 3615
diff changeset
   601
static void ini_load_setting_list(IniFile *ini, const char *grpname, char **list, uint len, SettingListCallbackProc proc)
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   602
{
9996
fceaf224b2f0 (svn r14153) -Codechange: split ini file reading/saving from settings.cpp.
rubidium
parents: 9906
diff changeset
   603
	IniGroup *group = ini->GetGroup(grpname);
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   604
	IniItem *item;
3628
69646d0924a5 (svn r4527) - Feature [NewGRF]: Add support for specifying parameters to GRF files. Usage: "mygrf = 1". You can pass up to 128 parameters, each one seperated by a comma or a space-character. Big thanks to peter1138 for the inspiration and examples.
Darkvater
parents: 3615
diff changeset
   605
	const char *entry;
69646d0924a5 (svn r4527) - Feature [NewGRF]: Add support for specifying parameters to GRF files. Usage: "mygrf = 1". You can pass up to 128 parameters, each one seperated by a comma or a space-character. Big thanks to peter1138 for the inspiration and examples.
Darkvater
parents: 3615
diff changeset
   606
	uint i, j;
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   607
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   608
	if (group == NULL) return;
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   609
3628
69646d0924a5 (svn r4527) - Feature [NewGRF]: Add support for specifying parameters to GRF files. Usage: "mygrf = 1". You can pass up to 128 parameters, each one seperated by a comma or a space-character. Big thanks to peter1138 for the inspiration and examples.
Darkvater
parents: 3615
diff changeset
   610
	for (i = j = 0, item = group->item; item != NULL; item = item->next) {
69646d0924a5 (svn r4527) - Feature [NewGRF]: Add support for specifying parameters to GRF files. Usage: "mygrf = 1". You can pass up to 128 parameters, each one seperated by a comma or a space-character. Big thanks to peter1138 for the inspiration and examples.
Darkvater
parents: 3615
diff changeset
   611
		entry = (proc != NULL) ? proc(item, i++) : item->name;
69646d0924a5 (svn r4527) - Feature [NewGRF]: Add support for specifying parameters to GRF files. Usage: "mygrf = 1". You can pass up to 128 parameters, each one seperated by a comma or a space-character. Big thanks to peter1138 for the inspiration and examples.
Darkvater
parents: 3615
diff changeset
   612
69646d0924a5 (svn r4527) - Feature [NewGRF]: Add support for specifying parameters to GRF files. Usage: "mygrf = 1". You can pass up to 128 parameters, each one seperated by a comma or a space-character. Big thanks to peter1138 for the inspiration and examples.
Darkvater
parents: 3615
diff changeset
   613
		if (entry == NULL || list == NULL) continue;
69646d0924a5 (svn r4527) - Feature [NewGRF]: Add support for specifying parameters to GRF files. Usage: "mygrf = 1". You can pass up to 128 parameters, each one seperated by a comma or a space-character. Big thanks to peter1138 for the inspiration and examples.
Darkvater
parents: 3615
diff changeset
   614
69646d0924a5 (svn r4527) - Feature [NewGRF]: Add support for specifying parameters to GRF files. Usage: "mygrf = 1". You can pass up to 128 parameters, each one seperated by a comma or a space-character. Big thanks to peter1138 for the inspiration and examples.
Darkvater
parents: 3615
diff changeset
   615
		if (j == len) break;
69646d0924a5 (svn r4527) - Feature [NewGRF]: Add support for specifying parameters to GRF files. Usage: "mygrf = 1". You can pass up to 128 parameters, each one seperated by a comma or a space-character. Big thanks to peter1138 for the inspiration and examples.
Darkvater
parents: 3615
diff changeset
   616
		list[j++] = strdup(entry);
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   617
	}
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   618
}
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   619
3615
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   620
/** Saves all items from a list into the 'grpname' section
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   621
 * The list parameter can be a NULL pointer, in this case a callback function
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   622
 * should be defined that will provide the source data to be saved.
6488
b6c42e91bb35 (svn r9669) -Documentation: some more doxygen fixes
belugas
parents: 6486
diff changeset
   623
 * @param ini IniFile handle to the ini file where the destination data is saved
3615
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   624
 * @param grpname character string identifying the section-header of the ini file
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   625
 * @param list pointer to an string(pointer) array that will be used as the
6488
b6c42e91bb35 (svn r9669) -Documentation: some more doxygen fixes
belugas
parents: 6486
diff changeset
   626
 *             source to be saved into the relevant ini section
3615
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   627
 * @param len the maximum number of items available for the above list
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   628
 * @param proc callback function that can will provide the source data if defined */
3628
69646d0924a5 (svn r4527) - Feature [NewGRF]: Add support for specifying parameters to GRF files. Usage: "mygrf = 1". You can pass up to 128 parameters, each one seperated by a comma or a space-character. Big thanks to peter1138 for the inspiration and examples.
Darkvater
parents: 3615
diff changeset
   629
static void ini_save_setting_list(IniFile *ini, const char *grpname, char **list, uint len, SettingListCallbackProc proc)
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   630
{
9996
fceaf224b2f0 (svn r14153) -Codechange: split ini file reading/saving from settings.cpp.
rubidium
parents: 9906
diff changeset
   631
	IniGroup *group = ini->GetGroup(grpname);
3628
69646d0924a5 (svn r4527) - Feature [NewGRF]: Add support for specifying parameters to GRF files. Usage: "mygrf = 1". You can pass up to 128 parameters, each one seperated by a comma or a space-character. Big thanks to peter1138 for the inspiration and examples.
Darkvater
parents: 3615
diff changeset
   632
	const char *entry;
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   633
	uint i;
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   634
3628
69646d0924a5 (svn r4527) - Feature [NewGRF]: Add support for specifying parameters to GRF files. Usage: "mygrf = 1". You can pass up to 128 parameters, each one seperated by a comma or a space-character. Big thanks to peter1138 for the inspiration and examples.
Darkvater
parents: 3615
diff changeset
   635
	if (proc == NULL && list == NULL) return;
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   636
	if (group == NULL) return;
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   637
	group->item = NULL;
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   638
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   639
	for (i = 0; i != len; i++) {
3628
69646d0924a5 (svn r4527) - Feature [NewGRF]: Add support for specifying parameters to GRF files. Usage: "mygrf = 1". You can pass up to 128 parameters, each one seperated by a comma or a space-character. Big thanks to peter1138 for the inspiration and examples.
Darkvater
parents: 3615
diff changeset
   640
		entry = (proc != NULL) ? proc(NULL, i) : list[i];
69646d0924a5 (svn r4527) - Feature [NewGRF]: Add support for specifying parameters to GRF files. Usage: "mygrf = 1". You can pass up to 128 parameters, each one seperated by a comma or a space-character. Big thanks to peter1138 for the inspiration and examples.
Darkvater
parents: 3615
diff changeset
   641
69646d0924a5 (svn r4527) - Feature [NewGRF]: Add support for specifying parameters to GRF files. Usage: "mygrf = 1". You can pass up to 128 parameters, each one seperated by a comma or a space-character. Big thanks to peter1138 for the inspiration and examples.
Darkvater
parents: 3615
diff changeset
   642
		if (entry == NULL || *entry == '\0') continue;
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   643
10008
fca6f9cf02ac (svn r14167) -Fix: items in some ini-groups got duplicated on save.
rubidium
parents: 10005
diff changeset
   644
		group->GetItem(entry, true)->SetValue("");
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   645
	}
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   646
}
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   647
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   648
//***************************
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   649
// OTTD specific INI stuff
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   650
//***************************
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   651
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   652
/** Settings-macro usage:
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   653
 * The list might look daunting at first, but is in general easy to understand.
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   654
 * We have two types of list:
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   655
 * 1. SDTG_something
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   656
 * 2. SDT_something
4000
4009d092b306 (svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents: 3982
diff changeset
   657
 * The 'G' stands for global, so this is the one you will use for a
4009d092b306 (svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents: 3982
diff changeset
   658
 * SettingDescGlobVarList section meaning global variables. The other uses a
6457
a1feef8a35b1 (svn r9616) -Cleanup: Remove the NS setting type since it causes desyncs in multiplayer mode and only serves to confuse patch authors.
maedhros
parents: 6454
diff changeset
   659
 * Base/Offset and runtime variable selection mechanism, known from the saveload
a1feef8a35b1 (svn r9616) -Cleanup: Remove the NS setting type since it causes desyncs in multiplayer mode and only serves to confuse patch authors.
maedhros
parents: 6454
diff changeset
   660
 * convention (it also has global so it should not be hard).
4000
4009d092b306 (svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents: 3982
diff changeset
   661
 * Of each type there are again two versions, the normal one and one prefixed
4009d092b306 (svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents: 3982
diff changeset
   662
 * with 'COND'.
4009d092b306 (svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents: 3982
diff changeset
   663
 * COND means that the setting is only valid in certain savegame versions
4009d092b306 (svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents: 3982
diff changeset
   664
 * (since patches are saved to the savegame, this bookkeeping is necessary.
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   665
 * Now there are a lot of types. Easy ones are:
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   666
 * - VAR:  any number type, 'type' field specifies what number. eg int8 or uint32
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   667
 * - BOOL: a boolean number type
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   668
 * - STR:  a string or character. 'type' field specifies what string. Normal, string, or quoted
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   669
 * A bit more difficult to use are MMANY (meaning ManyOfMany) and OMANY (OneOfMany)
4000
4009d092b306 (svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents: 3982
diff changeset
   670
 * These are actually normal numbers, only bitmasked. In MMANY several bits can
4009d092b306 (svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents: 3982
diff changeset
   671
 * be set, in the other only one.
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   672
 * The most complex type is INTLIST. This is basically an array of numbers. If
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   673
 * the intlist is only valid in certain savegame versions because for example
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   674
 * it has grown in size its length cannot be automatically be calculated so
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   675
 * use SDT(G)_CONDLISTO() meaning Old.
4000
4009d092b306 (svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents: 3982
diff changeset
   676
 * If nothing fits you, you can use the GENERAL macros, but it exposes the
4009d092b306 (svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents: 3982
diff changeset
   677
 * internal structure somewhat so it needs a little looking. There are _NULL()
4009d092b306 (svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents: 3982
diff changeset
   678
 * macros as well, these fill up space so you can add more patches there (in
6355
d1232b85d407 (svn r9398) -Feature: Allow for a conversion callback system while reading configuration file, in case of wrong value.
belugas
parents: 6338
diff changeset
   679
 * place) and you DON'T have to increase the savegame version.
d1232b85d407 (svn r9398) -Feature: Allow for a conversion callback system while reading configuration file, in case of wrong value.
belugas
parents: 6338
diff changeset
   680
 *
d1232b85d407 (svn r9398) -Feature: Allow for a conversion callback system while reading configuration file, in case of wrong value.
belugas
parents: 6338
diff changeset
   681
 * While reading values from openttd.cfg, some values may not be converted
d1232b85d407 (svn r9398) -Feature: Allow for a conversion callback system while reading configuration file, in case of wrong value.
belugas
parents: 6338
diff changeset
   682
 * properly, for any kind of reasons.  In order to allow a process of self-cleaning
d1232b85d407 (svn r9398) -Feature: Allow for a conversion callback system while reading configuration file, in case of wrong value.
belugas
parents: 6338
diff changeset
   683
 * mechanism, a callback procedure is made available.  You will have to supply the function, which
d1232b85d407 (svn r9398) -Feature: Allow for a conversion callback system while reading configuration file, in case of wrong value.
belugas
parents: 6338
diff changeset
   684
 * will work on a string, one function per patch.  And of course, enable the callback param
d1232b85d407 (svn r9398) -Feature: Allow for a conversion callback system while reading configuration file, in case of wrong value.
belugas
parents: 6338
diff changeset
   685
 * on the appropriate macro.
d1232b85d407 (svn r9398) -Feature: Allow for a conversion callback system while reading configuration file, in case of wrong value.
belugas
parents: 6338
diff changeset
   686
 */
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   687
6355
d1232b85d407 (svn r9398) -Feature: Allow for a conversion callback system while reading configuration file, in case of wrong value.
belugas
parents: 6338
diff changeset
   688
#define NSD_GENERAL(name, def, cmd, guiflags, min, max, interval, many, str, proc, load)\
d1232b85d407 (svn r9398) -Feature: Allow for a conversion callback system while reading configuration file, in case of wrong value.
belugas
parents: 6338
diff changeset
   689
	{name, (const void*)(def), {cmd}, {guiflags}, min, max, interval, many, str, proc, load}
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   690
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   691
/* Macros for various objects to go in the configuration file.
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   692
 * This section is for global variables */
4431
7ecf73508c31 (svn r6186) -Fix [FS#309]: add an override system to the dynamically determined size of steps for numeric patch settings in the 'Configure patches' GUI.
rubidium
parents: 4419
diff changeset
   693
#define SDTG_GENERAL(name, sdt_cmd, sle_cmd, type, flags, guiflags, var, length, def, min, max, interval, full, str, proc, from, to)\
6355
d1232b85d407 (svn r9398) -Feature: Allow for a conversion callback system while reading configuration file, in case of wrong value.
belugas
parents: 6338
diff changeset
   694
	{NSD_GENERAL(name, def, sdt_cmd, guiflags, min, max, interval, full, str, proc, NULL), SLEG_GENERAL(sle_cmd, var, type | flags, length, from, to)}
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   695
4431
7ecf73508c31 (svn r6186) -Fix [FS#309]: add an override system to the dynamically determined size of steps for numeric patch settings in the 'Configure patches' GUI.
rubidium
parents: 4419
diff changeset
   696
#define SDTG_CONDVAR(name, type, flags, guiflags, var, def, min, max, interval, str, proc, from, to)\
7ecf73508c31 (svn r6186) -Fix [FS#309]: add an override system to the dynamically determined size of steps for numeric patch settings in the 'Configure patches' GUI.
rubidium
parents: 4419
diff changeset
   697
	SDTG_GENERAL(name, SDT_NUMX, SL_VAR, type, flags, guiflags, var, 0, def, min, max, interval, NULL, str, proc, from, to)
7ecf73508c31 (svn r6186) -Fix [FS#309]: add an override system to the dynamically determined size of steps for numeric patch settings in the 'Configure patches' GUI.
rubidium
parents: 4419
diff changeset
   698
#define SDTG_VAR(name, type, flags, guiflags, var, def, min, max, interval, str, proc)\
7ecf73508c31 (svn r6186) -Fix [FS#309]: add an override system to the dynamically determined size of steps for numeric patch settings in the 'Configure patches' GUI.
rubidium
parents: 4419
diff changeset
   699
	SDTG_CONDVAR(name, type, flags, guiflags, var, def, min, max, interval, str, proc, 0, SL_MAX_VERSION)
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   700
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   701
#define SDTG_CONDBOOL(name, flags, guiflags, var, def, str, proc, from, to)\
5983
49d077336ca1 (svn r8684) -Fix [FS#483] (r3720): a bool (uint32 in PPC) was written to as a uint8. Later those bools are used as index into an array as they expect the value to be 0 or 1.
rubidium
parents: 5688
diff changeset
   702
	SDTG_GENERAL(name, SDT_BOOLX, SL_VAR, SLE_BOOL, flags, guiflags, var, 0, def, 0, 1, 0, NULL, str, proc, from, to)
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   703
#define SDTG_BOOL(name, flags, guiflags, var, def, str, proc)\
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   704
	SDTG_CONDBOOL(name, flags, guiflags, var, def, str, proc, 0, SL_MAX_VERSION)
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   705
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   706
#define SDTG_CONDLIST(name, type, length, flags, guiflags, var, def, str, proc, from, to)\
4431
7ecf73508c31 (svn r6186) -Fix [FS#309]: add an override system to the dynamically determined size of steps for numeric patch settings in the 'Configure patches' GUI.
rubidium
parents: 4419
diff changeset
   707
	SDTG_GENERAL(name, SDT_INTLIST, SL_ARR, type, flags, guiflags, var, length, def, 0, 0, 0, NULL, str, proc, from, to)
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   708
#define SDTG_LIST(name, type, flags, guiflags, var, def, str, proc)\
4431
7ecf73508c31 (svn r6186) -Fix [FS#309]: add an override system to the dynamically determined size of steps for numeric patch settings in the 'Configure patches' GUI.
rubidium
parents: 4419
diff changeset
   709
	SDTG_GENERAL(name, SDT_INTLIST, SL_ARR, type, flags, guiflags, var, lengthof(var), def, 0, 0, 0, NULL, str, proc, 0, SL_MAX_VERSION)
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   710
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   711
#define SDTG_CONDSTR(name, type, length, flags, guiflags, var, def, str, proc, from, to)\
4431
7ecf73508c31 (svn r6186) -Fix [FS#309]: add an override system to the dynamically determined size of steps for numeric patch settings in the 'Configure patches' GUI.
rubidium
parents: 4419
diff changeset
   712
	SDTG_GENERAL(name, SDT_STRING, SL_STR, type, flags, guiflags, var, length, def, 0, 0, 0, NULL, str, proc, from, to)
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   713
#define SDTG_STR(name, type, flags, guiflags, var, def, str, proc)\
4431
7ecf73508c31 (svn r6186) -Fix [FS#309]: add an override system to the dynamically determined size of steps for numeric patch settings in the 'Configure patches' GUI.
rubidium
parents: 4419
diff changeset
   714
	SDTG_GENERAL(name, SDT_STRING, SL_STR, type, flags, guiflags, var, lengthof(var), def, 0, 0, 0, NULL, str, proc, 0, SL_MAX_VERSION)
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   715
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   716
#define SDTG_CONDOMANY(name, type, flags, guiflags, var, def, max, full, str, proc, from, to)\
4431
7ecf73508c31 (svn r6186) -Fix [FS#309]: add an override system to the dynamically determined size of steps for numeric patch settings in the 'Configure patches' GUI.
rubidium
parents: 4419
diff changeset
   717
	SDTG_GENERAL(name, SDT_ONEOFMANY, SL_VAR, type, flags, guiflags, var, 0, def, 0, max, 0, full, str, proc, from, to)
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   718
#define SDTG_OMANY(name, type, flags, guiflags, var, def, max, full, str, proc)\
6528
3afd9c7a0a23 (svn r9716) -Add: server_lang in [network] section of openttd.cfg, so dedicated servers can have the little lang flag.
glx
parents: 6491
diff changeset
   719
	SDTG_CONDOMANY(name, type, flags, guiflags, var, def, max, full, str, proc, 0, SL_MAX_VERSION)
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   720
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   721
#define SDTG_CONDMMANY(name, type, flags, guiflags, var, def, full, str, proc, from, to)\
4431
7ecf73508c31 (svn r6186) -Fix [FS#309]: add an override system to the dynamically determined size of steps for numeric patch settings in the 'Configure patches' GUI.
rubidium
parents: 4419
diff changeset
   722
	SDTG_GENERAL(name, SDT_MANYOFMANY, SL_VAR, type, flags, guiflags, var, 0, def, 0, 0, 0, full, str, proc, from, to)
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   723
#define SDTG_MMANY(name, type, flags, guiflags, var, def, full, str, proc)\
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   724
	SDTG_CONDMMANY(name, type, flags, guiflags, var, def, full, str, proc, 0, SL_MAX_VERSION)
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   725
3222
6de22e06a1e9 (svn r3895) - Add proper SLE(G)_CONDNULL macros for the empty space reservation in savegames and update where used
Darkvater
parents: 3210
diff changeset
   726
#define SDTG_CONDNULL(length, from, to)\
6355
d1232b85d407 (svn r9398) -Feature: Allow for a conversion callback system while reading configuration file, in case of wrong value.
belugas
parents: 6338
diff changeset
   727
	{{"", NULL, {0}, {0}, 0, 0, 0, NULL, STR_NULL, NULL, NULL}, SLEG_CONDNULL(length, from, to)}
3222
6de22e06a1e9 (svn r3895) - Add proper SLE(G)_CONDNULL macros for the empty space reservation in savegames and update where used
Darkvater
parents: 3210
diff changeset
   728
6355
d1232b85d407 (svn r9398) -Feature: Allow for a conversion callback system while reading configuration file, in case of wrong value.
belugas
parents: 6338
diff changeset
   729
#define SDTG_END() {{NULL, NULL, {0}, {0}, 0, 0, 0, NULL, STR_NULL, NULL, NULL}, SLEG_END()}
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   730
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   731
/* Macros for various objects to go in the configuration file.
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   732
 * This section is for structures where their various members are saved */
6356
2f7f41367170 (svn r9399) -Feature: Openttd.cfg will now present landscape patch entry as been temperate, arctic, tropic or toyland.
belugas
parents: 6355
diff changeset
   733
#define SDT_GENERAL(name, sdt_cmd, sle_cmd, type, flags, guiflags, base, var, length, def, min, max, interval, full, str, proc, load, from, to)\
2f7f41367170 (svn r9399) -Feature: Openttd.cfg will now present landscape patch entry as been temperate, arctic, tropic or toyland.
belugas
parents: 6355
diff changeset
   734
	{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)}
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   735
4431
7ecf73508c31 (svn r6186) -Fix [FS#309]: add an override system to the dynamically determined size of steps for numeric patch settings in the 'Configure patches' GUI.
rubidium
parents: 4419
diff changeset
   736
#define SDT_CONDVAR(base, var, type, from, to, flags, guiflags, def, min, max, interval, str, proc)\
6356
2f7f41367170 (svn r9399) -Feature: Openttd.cfg will now present landscape patch entry as been temperate, arctic, tropic or toyland.
belugas
parents: 6355
diff changeset
   737
	SDT_GENERAL(#var, SDT_NUMX, SL_VAR, type, flags, guiflags, base, var, 1, def, min, max, interval, NULL, str, proc, NULL, from, to)
4431
7ecf73508c31 (svn r6186) -Fix [FS#309]: add an override system to the dynamically determined size of steps for numeric patch settings in the 'Configure patches' GUI.
rubidium
parents: 4419
diff changeset
   738
#define SDT_VAR(base, var, type, flags, guiflags, def, min, max, interval, str, proc)\
7ecf73508c31 (svn r6186) -Fix [FS#309]: add an override system to the dynamically determined size of steps for numeric patch settings in the 'Configure patches' GUI.
rubidium
parents: 4419
diff changeset
   739
	SDT_CONDVAR(base, var, type, 0, SL_MAX_VERSION, flags, guiflags, def, min, max, interval, str, proc)
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   740
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   741
#define SDT_CONDBOOL(base, var, from, to, flags, guiflags, def, str, proc)\
6356
2f7f41367170 (svn r9399) -Feature: Openttd.cfg will now present landscape patch entry as been temperate, arctic, tropic or toyland.
belugas
parents: 6355
diff changeset
   742
	SDT_GENERAL(#var, SDT_BOOLX, SL_VAR, SLE_BOOL, flags, guiflags, base, var, 1, def, 0, 1, 0, NULL, str, proc, NULL, from, to)
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   743
#define SDT_BOOL(base, var, flags, guiflags, def, str, proc)\
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   744
	SDT_CONDBOOL(base, var, 0, SL_MAX_VERSION, flags, guiflags, def, str, proc)
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   745
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   746
#define SDT_CONDLIST(base, var, type, from, to, flags, guiflags, def, str, proc)\
6356
2f7f41367170 (svn r9399) -Feature: Openttd.cfg will now present landscape patch entry as been temperate, arctic, tropic or toyland.
belugas
parents: 6355
diff changeset
   747
	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)
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   748
#define SDT_LIST(base, var, type, flags, guiflags, def, str, proc)\
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   749
	SDT_CONDLIST(base, var, type, 0, SL_MAX_VERSION, flags, guiflags, def, str, proc)
9334
28ac6c8e0795 (svn r13226) -Feature: Allow to have more than only two airports per town. The number of airports is now controlled by the noise each of them generates, the distance from town's center and how tolerant the town is.
belugas
parents: 9194
diff changeset
   750
#define SDT_CONDLISTO(base, var, length, type, from, to, flags, guiflags, def, str, proc, load)\
28ac6c8e0795 (svn r13226) -Feature: Allow to have more than only two airports per town. The number of airports is now controlled by the noise each of them generates, the distance from town's center and how tolerant the town is.
belugas
parents: 9194
diff changeset
   751
	SDT_GENERAL(#var, SDT_INTLIST, SL_ARR, type, flags, guiflags, base, var, length, def, 0, 0, 0, NULL, str, proc, load, from, to)
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   752
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   753
#define SDT_CONDSTR(base, var, type, from, to, flags, guiflags, def, str, proc)\
6356
2f7f41367170 (svn r9399) -Feature: Openttd.cfg will now present landscape patch entry as been temperate, arctic, tropic or toyland.
belugas
parents: 6355
diff changeset
   754
	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)
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   755
#define SDT_STR(base, var, type, flags, guiflags, def, str, proc)\
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   756
	SDT_CONDSTR(base, var, type, 0, SL_MAX_VERSION, flags, guiflags, def, str, proc)
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   757
#define SDT_CONDSTRO(base, var, length, type, from, to, flags, def, str, proc)\
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   758
	SDT_GENERAL(#var, SDT_STRING, SL_STR, type, flags, 0, base, var, length, def, 0, 0, NULL, str, proc, from, to)
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   759
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   760
#define SDT_CONDCHR(base, var, from, to, flags, guiflags, def, str, proc)\
6356
2f7f41367170 (svn r9399) -Feature: Openttd.cfg will now present landscape patch entry as been temperate, arctic, tropic or toyland.
belugas
parents: 6355
diff changeset
   761
	SDT_GENERAL(#var, SDT_STRING, SL_VAR, SLE_CHAR, flags, guiflags, base, var, 1, def, 0, 0, 0, NULL, str, proc, NULL, from, to)
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   762
#define SDT_CHR(base, var, flags, guiflags, def, str, proc)\
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   763
	SDT_CONDCHR(base, var, 0, SL_MAX_VERSION, flags, guiflags, def, str, proc)
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   764
6356
2f7f41367170 (svn r9399) -Feature: Openttd.cfg will now present landscape patch entry as been temperate, arctic, tropic or toyland.
belugas
parents: 6355
diff changeset
   765
#define SDT_CONDOMANY(base, var, type, from, to, flags, guiflags, def, max, full, str, proc, load)\
2f7f41367170 (svn r9399) -Feature: Openttd.cfg will now present landscape patch entry as been temperate, arctic, tropic or toyland.
belugas
parents: 6355
diff changeset
   766
	SDT_GENERAL(#var, SDT_ONEOFMANY, SL_VAR, type, flags, guiflags, base, var, 1, def, 0, max, 0, full, str, proc, load, from, to)
2f7f41367170 (svn r9399) -Feature: Openttd.cfg will now present landscape patch entry as been temperate, arctic, tropic or toyland.
belugas
parents: 6355
diff changeset
   767
#define SDT_OMANY(base, var, type, flags, guiflags, def, max, full, str, proc, load)\
2f7f41367170 (svn r9399) -Feature: Openttd.cfg will now present landscape patch entry as been temperate, arctic, tropic or toyland.
belugas
parents: 6355
diff changeset
   768
	SDT_CONDOMANY(base, var, type, 0, SL_MAX_VERSION, flags, guiflags, def, max, full, str, proc, load)
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   769
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   770
#define SDT_CONDMMANY(base, var, type, from, to, flags, guiflags, def, full, str, proc)\
6356
2f7f41367170 (svn r9399) -Feature: Openttd.cfg will now present landscape patch entry as been temperate, arctic, tropic or toyland.
belugas
parents: 6355
diff changeset
   771
	SDT_GENERAL(#var, SDT_MANYOFMANY, SL_VAR, type, flags, guiflags, base, var, 1, def, 0, 0, 0, full, str, proc, NULL, from, to)
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   772
#define SDT_MMANY(base, var, type, flags, guiflags, def, full, str, proc)\
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   773
	SDT_CONDMMANY(base, var, type, 0, SL_MAX_VERSION, flags, guiflags, def, full, str, proc)
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   774
3222
6de22e06a1e9 (svn r3895) - Add proper SLE(G)_CONDNULL macros for the empty space reservation in savegames and update where used
Darkvater
parents: 3210
diff changeset
   775
#define SDT_CONDNULL(length, from, to)\
6355
d1232b85d407 (svn r9398) -Feature: Allow for a conversion callback system while reading configuration file, in case of wrong value.
belugas
parents: 6338
diff changeset
   776
	{{"", NULL, {0}, {0}, 0, 0, 0, NULL, STR_NULL, NULL, NULL}, SLE_CONDNULL(length, from, to)}
3222
6de22e06a1e9 (svn r3895) - Add proper SLE(G)_CONDNULL macros for the empty space reservation in savegames and update where used
Darkvater
parents: 3210
diff changeset
   777
9413
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
   778
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
   779
#define SDTC_CONDVAR(var, type, from, to, flags, guiflags, def, min, max, interval, str, proc)\
9418
8093bfef9967 (svn r13332) -Fix (r13325): network games got somewhat broken.
rubidium
parents: 9413
diff changeset
   780
	SDTG_GENERAL(#var, SDT_NUMX, SL_VAR, type, flags, guiflags, _settings_client.var, 1, def, min, max, interval, NULL, str, proc, from, to)
9413
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
   781
#define SDTC_VAR(var, type, flags, guiflags, def, min, max, interval, str, proc)\
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
   782
	SDTC_CONDVAR(var, type, 0, SL_MAX_VERSION, flags, guiflags, def, min, max, interval, str, proc)
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
   783
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
   784
#define SDTC_CONDBOOL(var, from, to, flags, guiflags, def, str, proc)\
9418
8093bfef9967 (svn r13332) -Fix (r13325): network games got somewhat broken.
rubidium
parents: 9413
diff changeset
   785
	SDTG_GENERAL(#var, SDT_BOOLX, SL_VAR, SLE_BOOL, flags, guiflags, _settings_client.var, 1, def, 0, 1, 0, NULL, str, proc, from, to)
9413
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
   786
#define SDTC_BOOL(var, flags, guiflags, def, str, proc)\
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
   787
	SDTC_CONDBOOL(var, 0, SL_MAX_VERSION, flags, guiflags, def, str, proc)
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
   788
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
   789
#define SDTC_CONDLIST(var, type, length, flags, guiflags, def, str, proc, from, to)\
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
   790
	SDTG_GENERAL(#var, SDT_INTLIST, SL_ARR, type, flags, guiflags, _settings_client.var, length, def, 0, 0, 0, NULL, str, proc, from, to)
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
   791
#define SDTC_LIST(var, type, flags, guiflags, def, str, proc)\
9426
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
   792
	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)
9413
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
   793
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
   794
#define SDTC_CONDSTR(var, type, length, flags, guiflags, def, str, proc, from, to)\
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
   795
	SDTG_GENERAL(#var, SDT_STRING, SL_STR, type, flags, guiflags, _settings_client.var, length, def, 0, 0, 0, NULL, str, proc, from, to)
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
   796
#define SDTC_STR(var, type, flags, guiflags, def, str, proc)\
9426
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
   797
	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)
9413
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
   798
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
   799
#define SDTC_CONDOMANY(var, type, from, to, flags, guiflags, def, max, full, str, proc)\
9418
8093bfef9967 (svn r13332) -Fix (r13325): network games got somewhat broken.
rubidium
parents: 9413
diff changeset
   800
	SDTG_GENERAL(#var, SDT_ONEOFMANY, SL_VAR, type, flags, guiflags, _settings_client.var, 1, def, 0, max, 0, full, str, proc, from, to)
9413
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
   801
#define SDTC_OMANY(var, type, flags, guiflags, def, max, full, str, proc)\
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
   802
	SDTC_CONDOMANY(var, type, 0, SL_MAX_VERSION, flags, guiflags, def, max, full, str, proc)
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
   803
6355
d1232b85d407 (svn r9398) -Feature: Allow for a conversion callback system while reading configuration file, in case of wrong value.
belugas
parents: 6338
diff changeset
   804
#define SDT_END() {{NULL, NULL, {0}, {0}, 0, 0, 0, NULL, STR_NULL, NULL, NULL}, SLE_END()}
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   805
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   806
/* Shortcuts for macros below. Logically if we don't save the value
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   807
 * we also don't sync it in a network game */
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   808
#define S SLF_SAVE_NO | SLF_NETWORK_NO
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   809
#define C SLF_CONFIG_NO
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   810
#define N SLF_NETWORK_NO
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   811
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   812
#define D0 SGF_0ISDISABLED
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   813
#define NC SGF_NOCOMMA
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   814
#define MS SGF_MULTISTRING
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   815
#define NO SGF_NETWORK_ONLY
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   816
#define CR SGF_CURRENCY
7901
6e8ab6c5473d (svn r11452) -Change: do not allow configuration changes, that NewGRFs can directly use to change their behaviour, during network games as this can cause desyncs.
rubidium
parents: 7849
diff changeset
   817
#define NN SGF_NO_NETWORK
9359
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
   818
#define NG SGF_NEWGAME_ONLY
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   819
3131
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
   820
/* Begin - Callback Functions for the various settings */
6420
456c275f3313 (svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents: 6380
diff changeset
   821
/* virtual PositionMainToolbar function, calls the right one.*/
3131
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
   822
static int32 v_PositionMainToolbar(int32 p1)
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
   823
{
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
   824
	if (_game_mode != GM_MENU) PositionMainToolbar(NULL);
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
   825
	return 0;
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
   826
}
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
   827
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
   828
static int32 AiNew_PatchActive_Warning(int32 p1)
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
   829
{
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
   830
	if (p1 == 1) ShowErrorMessage(INVALID_STRING_ID, TEMP_AI_ACTIVATED, 0, 0);
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
   831
	return 0;
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
   832
}
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
   833
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
   834
static int32 Ai_In_Multiplayer_Warning(int32 p1)
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
   835
{
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
   836
	if (p1 == 1) {
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
   837
		ShowErrorMessage(INVALID_STRING_ID, TEMP_AI_MULTIPLAYER, 0, 0);
9413
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
   838
		_settings_game.ai.ainew_active = true;
3131
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
   839
	}
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
   840
	return 0;
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
   841
}
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
   842
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
   843
static int32 PopulationInLabelActive(int32 p1)
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
   844
{
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
   845
	Town* t;
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
   846
4346
66105d4f6e83 (svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents: 4344
diff changeset
   847
	FOR_ALL_TOWNS(t) UpdateTownVirtCoord(t);
66105d4f6e83 (svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents: 4344
diff changeset
   848
3131
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
   849
	return 0;
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
   850
}
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
   851
4082
6a21544873f0 (svn r5397) -Fix: Redraw the screen, when switching the signal side
tron
parents: 4077
diff changeset
   852
static int32 RedrawScreen(int32 p1)
3131
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
   853
{
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
   854
	MarkWholeScreenDirty();
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
   855
	return 0;
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
   856
}
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
   857
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
   858
static int32 InValidateDetailsWindow(int32 p1)
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
   859
{
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
   860
	InvalidateWindowClasses(WC_VEHICLE_DETAILS);
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
   861
	return 0;
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
   862
}
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
   863
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
   864
static int32 InvalidateStationBuildWindow(int32 p1)
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
   865
{
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
   866
	InvalidateWindow(WC_BUILD_STATION, 0);
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
   867
	return 0;
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
   868
}
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
   869
9194
2c9920f2c445 (svn r13060) -Codechange: update build industry window when raw_industry_construction setting is modified
glx
parents: 9175
diff changeset
   870
static int32 InvalidateBuildIndustryWindow(int32 p1)
2c9920f2c445 (svn r13060) -Codechange: update build industry window when raw_industry_construction setting is modified
glx
parents: 9175
diff changeset
   871
{
2c9920f2c445 (svn r13060) -Codechange: update build industry window when raw_industry_construction setting is modified
glx
parents: 9175
diff changeset
   872
	InvalidateWindowData(WC_BUILD_INDUSTRY, 0);
2c9920f2c445 (svn r13060) -Codechange: update build industry window when raw_industry_construction setting is modified
glx
parents: 9175
diff changeset
   873
	return 0;
2c9920f2c445 (svn r13060) -Codechange: update build industry window when raw_industry_construction setting is modified
glx
parents: 9175
diff changeset
   874
}
2c9920f2c445 (svn r13060) -Codechange: update build industry window when raw_industry_construction setting is modified
glx
parents: 9175
diff changeset
   875
9175
a8eb8c251cde (svn r13038) -Fix: When switching the signal gui patch to off, delete the signal window accordingly
belugas
parents: 9154
diff changeset
   876
static int32 CloseSignalGUI(int32 p1)
a8eb8c251cde (svn r13038) -Fix: When switching the signal gui patch to off, delete the signal window accordingly
belugas
parents: 9154
diff changeset
   877
{
a8eb8c251cde (svn r13038) -Fix: When switching the signal gui patch to off, delete the signal window accordingly
belugas
parents: 9154
diff changeset
   878
	if (p1 == 0) {
a8eb8c251cde (svn r13038) -Fix: When switching the signal gui patch to off, delete the signal window accordingly
belugas
parents: 9154
diff changeset
   879
		DeleteWindowByClass(WC_BUILD_SIGNAL);
a8eb8c251cde (svn r13038) -Fix: When switching the signal gui patch to off, delete the signal window accordingly
belugas
parents: 9154
diff changeset
   880
	}
a8eb8c251cde (svn r13038) -Fix: When switching the signal gui patch to off, delete the signal window accordingly
belugas
parents: 9154
diff changeset
   881
	return 0;
a8eb8c251cde (svn r13038) -Fix: When switching the signal gui patch to off, delete the signal window accordingly
belugas
parents: 9154
diff changeset
   882
}
a8eb8c251cde (svn r13038) -Fix: When switching the signal gui patch to off, delete the signal window accordingly
belugas
parents: 9154
diff changeset
   883
9334
28ac6c8e0795 (svn r13226) -Feature: Allow to have more than only two airports per town. The number of airports is now controlled by the noise each of them generates, the distance from town's center and how tolerant the town is.
belugas
parents: 9194
diff changeset
   884
static int32 InvalidateTownViewWindow(int32 p1)
28ac6c8e0795 (svn r13226) -Feature: Allow to have more than only two airports per town. The number of airports is now controlled by the noise each of them generates, the distance from town's center and how tolerant the town is.
belugas
parents: 9194
diff changeset
   885
{
28ac6c8e0795 (svn r13226) -Feature: Allow to have more than only two airports per town. The number of airports is now controlled by the noise each of them generates, the distance from town's center and how tolerant the town is.
belugas
parents: 9194
diff changeset
   886
	InvalidateWindowClassesData(WC_TOWN_VIEW, p1);
28ac6c8e0795 (svn r13226) -Feature: Allow to have more than only two airports per town. The number of airports is now controlled by the noise each of them generates, the distance from town's center and how tolerant the town is.
belugas
parents: 9194
diff changeset
   887
	return 0;
28ac6c8e0795 (svn r13226) -Feature: Allow to have more than only two airports per town. The number of airports is now controlled by the noise each of them generates, the distance from town's center and how tolerant the town is.
belugas
parents: 9194
diff changeset
   888
}
28ac6c8e0795 (svn r13226) -Feature: Allow to have more than only two airports per town. The number of airports is now controlled by the noise each of them generates, the distance from town's center and how tolerant the town is.
belugas
parents: 9194
diff changeset
   889
7753
ba9f36f97a33 (svn r11291) -Fix [FS#1345]: changing the wagon_speed_limits patch option caused desyncs.
rubidium
parents: 7742
diff changeset
   890
static int32 UpdateConsists(int32 p1)
ba9f36f97a33 (svn r11291) -Fix [FS#1345]: changing the wagon_speed_limits patch option caused desyncs.
rubidium
parents: 7742
diff changeset
   891
{
ba9f36f97a33 (svn r11291) -Fix [FS#1345]: changing the wagon_speed_limits patch option caused desyncs.
rubidium
parents: 7742
diff changeset
   892
	Vehicle *v;
ba9f36f97a33 (svn r11291) -Fix [FS#1345]: changing the wagon_speed_limits patch option caused desyncs.
rubidium
parents: 7742
diff changeset
   893
	FOR_ALL_VEHICLES(v) {
ba9f36f97a33 (svn r11291) -Fix [FS#1345]: changing the wagon_speed_limits patch option caused desyncs.
rubidium
parents: 7742
diff changeset
   894
		/* Update the consist of all trains so the maximum speed is set correctly. */
9704
54123af5f9a5 (svn r13816) -Fix [FS#2150]: check for vehicle length changes outside a depot (callback 0x11) and give a warning about that
smatz
parents: 9677
diff changeset
   895
		if (v->type == VEH_TRAIN && (IsFrontEngine(v) || IsFreeWagon(v))) TrainConsistChanged(v, true);
7753
ba9f36f97a33 (svn r11291) -Fix [FS#1345]: changing the wagon_speed_limits patch option caused desyncs.
rubidium
parents: 7742
diff changeset
   896
	}
ba9f36f97a33 (svn r11291) -Fix [FS#1345]: changing the wagon_speed_limits patch option caused desyncs.
rubidium
parents: 7742
diff changeset
   897
	return 0;
ba9f36f97a33 (svn r11291) -Fix [FS#1345]: changing the wagon_speed_limits patch option caused desyncs.
rubidium
parents: 7742
diff changeset
   898
}
ba9f36f97a33 (svn r11291) -Fix [FS#1345]: changing the wagon_speed_limits patch option caused desyncs.
rubidium
parents: 7742
diff changeset
   899
3131
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
   900
/* Check service intervals of vehicles, p1 is value of % or day based servicing */
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
   901
static int32 CheckInterval(int32 p1)
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
   902
{
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
   903
	bool warning;
9413
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
   904
	const VehicleSettings *ptc = (_game_mode == GM_MENU) ? &_settings_newgame.vehicle : &_settings_game.vehicle;
3131
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
   905
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
   906
	if (p1) {
7954
57b51c69c072 (svn r11510) -Codechange: merge the IS_*INSIDE* functions and rename them fitting to the naming style
skidd13
parents: 7931
diff changeset
   907
		warning = ( (IsInsideMM(ptc->servint_trains,   5, 90 + 1) || ptc->servint_trains   == 0) &&
57b51c69c072 (svn r11510) -Codechange: merge the IS_*INSIDE* functions and rename them fitting to the naming style
skidd13
parents: 7931
diff changeset
   908
								(IsInsideMM(ptc->servint_roadveh,  5, 90 + 1) || ptc->servint_roadveh  == 0) &&
57b51c69c072 (svn r11510) -Codechange: merge the IS_*INSIDE* functions and rename them fitting to the naming style
skidd13
parents: 7931
diff changeset
   909
								(IsInsideMM(ptc->servint_aircraft, 5, 90 + 1) || ptc->servint_aircraft == 0) &&
57b51c69c072 (svn r11510) -Codechange: merge the IS_*INSIDE* functions and rename them fitting to the naming style
skidd13
parents: 7931
diff changeset
   910
								(IsInsideMM(ptc->servint_ships,    5, 90 + 1) || ptc->servint_ships    == 0) );
3131
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
   911
	} else {
7954
57b51c69c072 (svn r11510) -Codechange: merge the IS_*INSIDE* functions and rename them fitting to the naming style
skidd13
parents: 7931
diff changeset
   912
		warning = ( (IsInsideMM(ptc->servint_trains,   30, 800 + 1) || ptc->servint_trains   == 0) &&
57b51c69c072 (svn r11510) -Codechange: merge the IS_*INSIDE* functions and rename them fitting to the naming style
skidd13
parents: 7931
diff changeset
   913
								(IsInsideMM(ptc->servint_roadveh,  30, 800 + 1) || ptc->servint_roadveh  == 0) &&
57b51c69c072 (svn r11510) -Codechange: merge the IS_*INSIDE* functions and rename them fitting to the naming style
skidd13
parents: 7931
diff changeset
   914
								(IsInsideMM(ptc->servint_aircraft, 30, 800 + 1) || ptc->servint_aircraft == 0) &&
57b51c69c072 (svn r11510) -Codechange: merge the IS_*INSIDE* functions and rename them fitting to the naming style
skidd13
parents: 7931
diff changeset
   915
								(IsInsideMM(ptc->servint_ships,    30, 800 + 1) || ptc->servint_ships    == 0) );
3131
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
   916
	}
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
   917
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
   918
	if (!warning)
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
   919
		ShowErrorMessage(INVALID_STRING_ID, STR_CONFIG_PATCHES_SERVICE_INTERVAL_INCOMPATIBLE, 0, 0);
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
   920
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
   921
	return InValidateDetailsWindow(0);
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
   922
}
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
   923
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
   924
static int32 EngineRenewUpdate(int32 p1)
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
   925
{
9413
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
   926
	DoCommandP(0, 0, _settings_client.gui.autorenew, NULL, CMD_SET_AUTOREPLACE);
3131
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
   927
	return 0;
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
   928
}
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
   929
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
   930
static int32 EngineRenewMonthsUpdate(int32 p1)
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
   931
{
9413
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
   932
	DoCommandP(0, 1, _settings_client.gui.autorenew_months, NULL, CMD_SET_AUTOREPLACE);
3131
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
   933
	return 0;
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
   934
}
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
   935
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
   936
static int32 EngineRenewMoneyUpdate(int32 p1)
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
   937
{
9413
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
   938
	DoCommandP(0, 2, _settings_client.gui.autorenew_money, NULL, CMD_SET_AUTOREPLACE);
3131
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
   939
	return 0;
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
   940
}
6571
6a8a1d0835d9 (svn r9779) -Feature: Add the possiblity to choose different road patterns for towns to use.
belugas
parents: 6543
diff changeset
   941
8696
3324a740fb1f (svn r12369) -Fix (r1681): reset train speed limits when _patches.realistic_acceleration changes
smatz
parents: 8695
diff changeset
   942
static int32 RealisticAccelerationChanged(int32 p1)
3324a740fb1f (svn r12369) -Fix (r1681): reset train speed limits when _patches.realistic_acceleration changes
smatz
parents: 8695
diff changeset
   943
{
3324a740fb1f (svn r12369) -Fix (r1681): reset train speed limits when _patches.realistic_acceleration changes
smatz
parents: 8695
diff changeset
   944
	Vehicle *v;
3324a740fb1f (svn r12369) -Fix (r1681): reset train speed limits when _patches.realistic_acceleration changes
smatz
parents: 8695
diff changeset
   945
3324a740fb1f (svn r12369) -Fix (r1681): reset train speed limits when _patches.realistic_acceleration changes
smatz
parents: 8695
diff changeset
   946
	FOR_ALL_VEHICLES(v) {
3324a740fb1f (svn r12369) -Fix (r1681): reset train speed limits when _patches.realistic_acceleration changes
smatz
parents: 8695
diff changeset
   947
		if (v->type == VEH_TRAIN && IsFrontEngine(v)) UpdateTrainAcceleration(v);
3324a740fb1f (svn r12369) -Fix (r1681): reset train speed limits when _patches.realistic_acceleration changes
smatz
parents: 8695
diff changeset
   948
	}
3324a740fb1f (svn r12369) -Fix (r1681): reset train speed limits when _patches.realistic_acceleration changes
smatz
parents: 8695
diff changeset
   949
3324a740fb1f (svn r12369) -Fix (r1681): reset train speed limits when _patches.realistic_acceleration changes
smatz
parents: 8695
diff changeset
   950
	return 0;
3324a740fb1f (svn r12369) -Fix (r1681): reset train speed limits when _patches.realistic_acceleration changes
smatz
parents: 8695
diff changeset
   951
}
3324a740fb1f (svn r12369) -Fix (r1681): reset train speed limits when _patches.realistic_acceleration changes
smatz
parents: 8695
diff changeset
   952
8810
33066120c736 (svn r12553) -Fix (r11547): redraw the signal GUI when the signal drag density changes in the patch settings and vice versa
smatz
parents: 8809
diff changeset
   953
static int32 DragSignalsDensityChanged(int32)
33066120c736 (svn r12553) -Fix (r11547): redraw the signal GUI when the signal drag density changes in the patch settings and vice versa
smatz
parents: 8809
diff changeset
   954
{
9116
f2491d3c321b (svn r12976) -Codechange: use w->SetDirty() instead of SetWindowDirty(w) when it's certain that w != NULL.
rubidium
parents: 9085
diff changeset
   955
	SetWindowDirty(FindWindowById(WC_BUILD_SIGNAL, 0));
8810
33066120c736 (svn r12553) -Fix (r11547): redraw the signal GUI when the signal drag density changes in the patch settings and vice versa
smatz
parents: 8809
diff changeset
   956
33066120c736 (svn r12553) -Fix (r11547): redraw the signal GUI when the signal drag density changes in the patch settings and vice versa
smatz
parents: 8809
diff changeset
   957
	return 0;
33066120c736 (svn r12553) -Fix (r11547): redraw the signal GUI when the signal drag density changes in the patch settings and vice versa
smatz
parents: 8809
diff changeset
   958
}
33066120c736 (svn r12553) -Fix (r11547): redraw the signal GUI when the signal drag density changes in the patch settings and vice versa
smatz
parents: 8809
diff changeset
   959
9359
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
   960
/*
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
   961
 * A: competitors
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
   962
 * B: start time in months / 3
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
   963
 * C: town count (3 = high, 0 = very low)
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
   964
 * D: industry count (4 = high, 0 = none)
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
   965
 * E: inital loan (in GBP)
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
   966
 * F: interest rate
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
   967
 * G: running costs (0 = low, 2 = high)
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
   968
 * H: construction speed of competitors (0 = very slow, 4 = very fast)
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
   969
 * I: intelligence (0-2)
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
   970
 * J: breakdowns (0 = off, 2 = normal)
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
   971
 * K: subsidy multiplier (0 = 1.5, 3 = 4.0)
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
   972
 * L: construction cost (0-2)
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
   973
 * M: terrain type (0 = very flat, 3 = mountainous)
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
   974
 * N: amount of water (0 = very low, 3 = high)
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
   975
 * O: economy (0 = steady, 1 = fluctuating)
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
   976
 * P: Train reversing (0 = end of line + stations, 1 = end of line)
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
   977
 * Q: disasters
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
   978
 * R: area restructuring (0 = permissive, 2 = hostile)
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
   979
 * S: the difficulty level
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
   980
 */
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
   981
static const DifficultySettings _default_game_diff[3] = { /*
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
   982
	 A, B, C, D,      E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S*/
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
   983
	{2, 2, 2, 4, 300000, 2, 0, 2, 0, 1, 2, 0, 1, 0, 0, 0, 0, 0, 0}, ///< easy
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
   984
	{4, 1, 2, 3, 150000, 3, 1, 3, 1, 2, 1, 1, 2, 1, 1, 1, 1, 1, 1}, ///< medium
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
   985
	{7, 0, 3, 3, 100000, 4, 1, 3, 2, 2, 0, 2, 3, 2, 1, 1, 1, 2, 2}, ///< hard
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
   986
};
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
   987
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
   988
void SetDifficultyLevel(int mode, DifficultySettings *gm_opt)
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
   989
{
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
   990
	assert(mode <= 3);
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
   991
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
   992
	if (mode != 3) {
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
   993
		*gm_opt = _default_game_diff[mode];
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
   994
	} else {
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
   995
		gm_opt->diff_level = 3;
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
   996
	}
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
   997
}
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
   998
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
   999
/**
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
  1000
 * Checks the difficulty levels read from the configuration and
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
  1001
 * forces them to be correct when invalid.
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
  1002
 */
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
  1003
void CheckDifficultyLevels()
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
  1004
{
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
  1005
	if (_settings_newgame.difficulty.diff_level != 3) {
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
  1006
		SetDifficultyLevel(_settings_newgame.difficulty.diff_level, &_settings_newgame.difficulty);
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
  1007
	}
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
  1008
}
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
  1009
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
  1010
static int32 DifficultyReset(int32 level)
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
  1011
{
9413
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1012
	SetDifficultyLevel(level, (_game_mode == GM_MENU) ? &_settings_newgame.difficulty : &_settings_game.difficulty);
9359
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
  1013
	return 0;
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
  1014
}
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
  1015
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
  1016
static int32 DifficultyChange(int32)
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
  1017
{
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
  1018
	if (_game_mode == GM_MENU) {
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
  1019
		_settings_newgame.difficulty.diff_level = 3;
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
  1020
	} else {
9413
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1021
		_settings_game.difficulty.diff_level = 3;
9359
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
  1022
	}
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
  1023
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
  1024
	/* If we are a network-client, update the difficult setting (if it is open).
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
  1025
	 * Use this instead of just dirtying the window because we need to load in
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
  1026
	 * the new difficulty settings */
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
  1027
	if (_networking && FindWindowById(WC_GAME_OPTIONS, 0) != NULL) {
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
  1028
		ShowGameDifficulty();
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
  1029
	}
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
  1030
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
  1031
	return 0;
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
  1032
}
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
  1033
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
  1034
static int32 DifficultyNoiseChange(int32 i)
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
  1035
{
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
  1036
	if (_game_mode == GM_NORMAL) {
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
  1037
		UpdateAirportsNoise();
9413
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1038
		if (_settings_game.economy.station_noise_level) {
9359
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
  1039
			InvalidateWindowClassesData(WC_TOWN_VIEW, 0);
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
  1040
		}
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
  1041
	}
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
  1042
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
  1043
	return DifficultyChange(i);
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
  1044
}
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
  1045
6571
6a8a1d0835d9 (svn r9779) -Feature: Add the possiblity to choose different road patterns for towns to use.
belugas
parents: 6543
diff changeset
  1046
/**
6a8a1d0835d9 (svn r9779) -Feature: Add the possiblity to choose different road patterns for towns to use.
belugas
parents: 6543
diff changeset
  1047
 * Check for right TownLayout usage in editor mode.
6a8a1d0835d9 (svn r9779) -Feature: Add the possiblity to choose different road patterns for towns to use.
belugas
parents: 6543
diff changeset
  1048
 * The No Road mode is not desirable since towns have to be
6a8a1d0835d9 (svn r9779) -Feature: Add the possiblity to choose different road patterns for towns to use.
belugas
parents: 6543
diff changeset
  1049
 * able to grow. If a user desires to have a town with no road,
6a8a1d0835d9 (svn r9779) -Feature: Add the possiblity to choose different road patterns for towns to use.
belugas
parents: 6543
diff changeset
  1050
 * he can easily remove them himself. This would create less confusion
6a8a1d0835d9 (svn r9779) -Feature: Add the possiblity to choose different road patterns for towns to use.
belugas
parents: 6543
diff changeset
  1051
 * @param p1 unused
6a8a1d0835d9 (svn r9779) -Feature: Add the possiblity to choose different road patterns for towns to use.
belugas
parents: 6543
diff changeset
  1052
 * @return always 0
6a8a1d0835d9 (svn r9779) -Feature: Add the possiblity to choose different road patterns for towns to use.
belugas
parents: 6543
diff changeset
  1053
 */
6a8a1d0835d9 (svn r9779) -Feature: Add the possiblity to choose different road patterns for towns to use.
belugas
parents: 6543
diff changeset
  1054
static int32 CheckTownLayout(int32 p1)
6a8a1d0835d9 (svn r9779) -Feature: Add the possiblity to choose different road patterns for towns to use.
belugas
parents: 6543
diff changeset
  1055
{
9413
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1056
	if (_settings_game.economy.town_layout == TL_NO_ROADS && _game_mode == GM_EDITOR) {
6571
6a8a1d0835d9 (svn r9779) -Feature: Add the possiblity to choose different road patterns for towns to use.
belugas
parents: 6543
diff changeset
  1057
		ShowErrorMessage(INVALID_STRING_ID, STR_CONFIG_PATCHES_TOWN_LAYOUT_INVALID, 0, 0);
9413
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1058
		_settings_game.economy.town_layout = TL_ORIGINAL;
6571
6a8a1d0835d9 (svn r9779) -Feature: Add the possiblity to choose different road patterns for towns to use.
belugas
parents: 6543
diff changeset
  1059
	}
6a8a1d0835d9 (svn r9779) -Feature: Add the possiblity to choose different road patterns for towns to use.
belugas
parents: 6543
diff changeset
  1060
	return 0;
6a8a1d0835d9 (svn r9779) -Feature: Add the possiblity to choose different road patterns for towns to use.
belugas
parents: 6543
diff changeset
  1061
}
6a8a1d0835d9 (svn r9779) -Feature: Add the possiblity to choose different road patterns for towns to use.
belugas
parents: 6543
diff changeset
  1062
9413
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1063
/** Conversion callback for _gameopt_settings_game.landscape
6356
2f7f41367170 (svn r9399) -Feature: Openttd.cfg will now present landscape patch entry as been temperate, arctic, tropic or toyland.
belugas
parents: 6355
diff changeset
  1064
 * It converts (or try) between old values and the new ones,
10015
2b721243365f (svn r14174) -Fix: since now, we are 'losing' things, not 'loosing'
smatz
parents: 10008
diff changeset
  1065
 * without losing initial setting of the user
6356
2f7f41367170 (svn r9399) -Feature: Openttd.cfg will now present landscape patch entry as been temperate, arctic, tropic or toyland.
belugas
parents: 6355
diff changeset
  1066
 * @param value that was read from config file
2f7f41367170 (svn r9399) -Feature: Openttd.cfg will now present landscape patch entry as been temperate, arctic, tropic or toyland.
belugas
parents: 6355
diff changeset
  1067
 * @return the "hopefully" converted value
2f7f41367170 (svn r9399) -Feature: Openttd.cfg will now present landscape patch entry as been temperate, arctic, tropic or toyland.
belugas
parents: 6355
diff changeset
  1068
 */
2f7f41367170 (svn r9399) -Feature: Openttd.cfg will now present landscape patch entry as been temperate, arctic, tropic or toyland.
belugas
parents: 6355
diff changeset
  1069
static int32 ConvertLandscape(const char *value)
2f7f41367170 (svn r9399) -Feature: Openttd.cfg will now present landscape patch entry as been temperate, arctic, tropic or toyland.
belugas
parents: 6355
diff changeset
  1070
{
2f7f41367170 (svn r9399) -Feature: Openttd.cfg will now present landscape patch entry as been temperate, arctic, tropic or toyland.
belugas
parents: 6355
diff changeset
  1071
	/* try with the old values */
9152
e5a0faf9018c (svn r13014) -Fix (r13008): mingw revealed some signed/unsigned warnings
glx
parents: 9146
diff changeset
  1072
	return lookup_oneofmany("normal|hilly|desert|candy", value);
6356
2f7f41367170 (svn r9399) -Feature: Openttd.cfg will now present landscape patch entry as been temperate, arctic, tropic or toyland.
belugas
parents: 6355
diff changeset
  1073
}
2f7f41367170 (svn r9399) -Feature: Openttd.cfg will now present landscape patch entry as been temperate, arctic, tropic or toyland.
belugas
parents: 6355
diff changeset
  1074
9334
28ac6c8e0795 (svn r13226) -Feature: Allow to have more than only two airports per town. The number of airports is now controlled by the noise each of them generates, the distance from town's center and how tolerant the town is.
belugas
parents: 9194
diff changeset
  1075
/**
28ac6c8e0795 (svn r13226) -Feature: Allow to have more than only two airports per town. The number of airports is now controlled by the noise each of them generates, the distance from town's center and how tolerant the town is.
belugas
parents: 9194
diff changeset
  1076
 * Check for decent values been supplied by the user for the noise tolerance setting.
28ac6c8e0795 (svn r13226) -Feature: Allow to have more than only two airports per town. The number of airports is now controlled by the noise each of them generates, the distance from town's center and how tolerant the town is.
belugas
parents: 9194
diff changeset
  1077
 * The primary idea is to avoid division by zero in game mode.
28ac6c8e0795 (svn r13226) -Feature: Allow to have more than only two airports per town. The number of airports is now controlled by the noise each of them generates, the distance from town's center and how tolerant the town is.
belugas
parents: 9194
diff changeset
  1078
 * The secondary idea is to make it so the values will be somewhat sane and that towns will
28ac6c8e0795 (svn r13226) -Feature: Allow to have more than only two airports per town. The number of airports is now controlled by the noise each of them generates, the distance from town's center and how tolerant the town is.
belugas
parents: 9194
diff changeset
  1079
 * not be overcrowed with airports.  It would be easy to abuse such a feature
28ac6c8e0795 (svn r13226) -Feature: Allow to have more than only two airports per town. The number of airports is now controlled by the noise each of them generates, the distance from town's center and how tolerant the town is.
belugas
parents: 9194
diff changeset
  1080
 * So basically, 200, 400, 800 are the lowest allowed values */
28ac6c8e0795 (svn r13226) -Feature: Allow to have more than only two airports per town. The number of airports is now controlled by the noise each of them generates, the distance from town's center and how tolerant the town is.
belugas
parents: 9194
diff changeset
  1081
static int32 CheckNoiseToleranceLevel(const char *value)
28ac6c8e0795 (svn r13226) -Feature: Allow to have more than only two airports per town. The number of airports is now controlled by the noise each of them generates, the distance from town's center and how tolerant the town is.
belugas
parents: 9194
diff changeset
  1082
{
9413
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1083
	GameSettings *s = (_game_mode == GM_MENU) ? &_settings_newgame : &_settings_game;
9354
845e07db4549 (svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents: 9350
diff changeset
  1084
	for (uint16 i = 0; i < lengthof(s->economy.town_noise_population); i++) {
845e07db4549 (svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents: 9350
diff changeset
  1085
		s->economy.town_noise_population[i] = max(uint16(200 * (i + 1)), s->economy.town_noise_population[i]);
9334
28ac6c8e0795 (svn r13226) -Feature: Allow to have more than only two airports per town. The number of airports is now controlled by the noise each of them generates, the distance from town's center and how tolerant the town is.
belugas
parents: 9194
diff changeset
  1086
	}
28ac6c8e0795 (svn r13226) -Feature: Allow to have more than only two airports per town. The number of airports is now controlled by the noise each of them generates, the distance from town's center and how tolerant the town is.
belugas
parents: 9194
diff changeset
  1087
	return 0;
28ac6c8e0795 (svn r13226) -Feature: Allow to have more than only two airports per town. The number of airports is now controlled by the noise each of them generates, the distance from town's center and how tolerant the town is.
belugas
parents: 9194
diff changeset
  1088
}
28ac6c8e0795 (svn r13226) -Feature: Allow to have more than only two airports per town. The number of airports is now controlled by the noise each of them generates, the distance from town's center and how tolerant the town is.
belugas
parents: 9194
diff changeset
  1089
9426
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1090
#ifdef ENABLE_NETWORK
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1091
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10199
diff changeset
  1092
static int32 UpdateMinActiveClients(int32 p1)
9426
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1093
{
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10199
diff changeset
  1094
	CheckMinActiveClients();
9426
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1095
	return 0;
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1096
}
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1097
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10199
diff changeset
  1098
static int32 UpdateClientName(int32 p1)
9426
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1099
{
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10199
diff changeset
  1100
	NetworkUpdateClientName();
9426
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1101
	return 0;
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1102
}
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1103
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1104
static int32 UpdateServerPassword(int32 p1)
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1105
{
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1106
	if (strcmp(_settings_client.network.server_password, "*") == 0) {
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1107
		_settings_client.network.server_password[0] = '\0';
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1108
	}
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1109
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1110
	return 0;
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1111
}
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1112
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1113
static int32 UpdateRconPassword(int32 p1)
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1114
{
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1115
	if (strcmp(_settings_client.network.rcon_password, "*") == 0) {
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1116
		_settings_client.network.rcon_password[0] = '\0';
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1117
	}
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1118
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1119
	return 0;
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1120
}
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1121
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1122
#endif /* ENABLE_NETWORK */
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1123
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1124
3131
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1125
/* End - Callback Functions */
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1126
1584
7122e759d56c (svn r2088) - Fix: [ 1155158 ] Make extmidi command a config option in addition to the compile-time MIDI switch. Patch by macbaine.
pasky
parents: 1500
diff changeset
  1127
#ifndef EXTERNAL_PLAYER
7122e759d56c (svn r2088) - Fix: [ 1155158 ] Make extmidi command a config option in addition to the compile-time MIDI switch. Patch by macbaine.
pasky
parents: 1500
diff changeset
  1128
#define EXTERNAL_PLAYER "timidity"
7122e759d56c (svn r2088) - Fix: [ 1155158 ] Make extmidi command a config option in addition to the compile-time MIDI switch. Patch by macbaine.
pasky
parents: 1500
diff changeset
  1129
#endif
7122e759d56c (svn r2088) - Fix: [ 1155158 ] Make extmidi command a config option in addition to the compile-time MIDI switch. Patch by macbaine.
pasky
parents: 1500
diff changeset
  1130
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1131
static const SettingDesc _music_settings[] = {
4431
7ecf73508c31 (svn r6186) -Fix [FS#309]: add an override system to the dynamically determined size of steps for numeric patch settings in the 'Configure patches' GUI.
rubidium
parents: 4419
diff changeset
  1132
	 SDT_VAR(MusicFileSettings, playlist,   SLE_UINT8, S, 0,   0, 0,   5, 1,  STR_NULL, NULL),
10105
3178d01c4369 (svn r14289) -Fix [FS#2286](r3720)(r1): sound effects an music volume should be in range 0-127, default value shouldn't be higher
smatz
parents: 10095
diff changeset
  1133
	 SDT_VAR(MusicFileSettings, music_vol,  SLE_UINT8, S, 0, 127, 0, 127, 1,  STR_NULL, NULL),
3178d01c4369 (svn r14289) -Fix [FS#2286](r3720)(r1): sound effects an music volume should be in range 0-127, default value shouldn't be higher
smatz
parents: 10095
diff changeset
  1134
	 SDT_VAR(MusicFileSettings, effect_vol, SLE_UINT8, S, 0, 127, 0, 127, 1,  STR_NULL, NULL),
4344
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
  1135
	SDT_LIST(MusicFileSettings, custom_1,   SLE_UINT8, S, 0, NULL,            STR_NULL, NULL),
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
  1136
	SDT_LIST(MusicFileSettings, custom_2,   SLE_UINT8, S, 0, NULL,            STR_NULL, NULL),
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
  1137
	SDT_BOOL(MusicFileSettings, playing,               S, 0, true,            STR_NULL, NULL),
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
  1138
	SDT_BOOL(MusicFileSettings, shuffle,               S, 0, false,           STR_NULL, NULL),
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
  1139
	 SDT_STR(MusicFileSettings, extmidi,     SLE_STRB, S, 0, EXTERNAL_PLAYER, STR_NULL, NULL),
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1140
	 SDT_END()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1141
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1142
3051
6a9ddcac6d56 (svn r3640) - Remove win32-only variables from variables.h and put them into win32_v.c. Also ifdef the win32 specific configuration file settings.
Darkvater
parents: 3042
diff changeset
  1143
/* win32_v.c only settings */
6a9ddcac6d56 (svn r3640) - Remove win32-only variables from variables.h and put them into win32_v.c. Also ifdef the win32 specific configuration file settings.
Darkvater
parents: 3042
diff changeset
  1144
#ifdef WIN32
6878
5cefd3ac59c7 (svn r10121) -Codechange: split renderer from rest of code; no longer any code directly accesses the video-buffer
truelight
parents: 6852
diff changeset
  1145
extern bool _force_full_redraw, _window_maximize;
3051
6a9ddcac6d56 (svn r3640) - Remove win32-only variables from variables.h and put them into win32_v.c. Also ifdef the win32 specific configuration file settings.
Darkvater
parents: 3042
diff changeset
  1146
extern uint _display_hz, _fullscreen_bpp;
6a9ddcac6d56 (svn r3640) - Remove win32-only variables from variables.h and put them into win32_v.c. Also ifdef the win32 specific configuration file settings.
Darkvater
parents: 3042
diff changeset
  1147
3124
cf624337b649 (svn r3732) - Fix two warnings. Stupid MSVC didn't even complain :s (Thank Tron and peter1138)
Darkvater
parents: 3121
diff changeset
  1148
static const SettingDescGlobVarList _win32_settings[] = {
4431
7ecf73508c31 (svn r6186) -Fix [FS#309]: add an override system to the dynamically determined size of steps for numeric patch settings in the 'Configure patches' GUI.
rubidium
parents: 4419
diff changeset
  1149
	 SDTG_VAR("display_hz",     SLE_UINT, S, 0, _display_hz,       0, 0, 120, 0, STR_NULL, NULL),
7ecf73508c31 (svn r6186) -Fix [FS#309]: add an override system to the dynamically determined size of steps for numeric patch settings in the 'Configure patches' GUI.
rubidium
parents: 4419
diff changeset
  1150
	SDTG_BOOL("force_full_redraw",        S, 0, _force_full_redraw,false,        STR_NULL, NULL),
7ecf73508c31 (svn r6186) -Fix [FS#309]: add an override system to the dynamically determined size of steps for numeric patch settings in the 'Configure patches' GUI.
rubidium
parents: 4419
diff changeset
  1151
	 SDTG_VAR("fullscreen_bpp", SLE_UINT, S, 0, _fullscreen_bpp,   8, 8,  32, 0, STR_NULL, NULL),
7ecf73508c31 (svn r6186) -Fix [FS#309]: add an override system to the dynamically determined size of steps for numeric patch settings in the 'Configure patches' GUI.
rubidium
parents: 4419
diff changeset
  1152
	SDTG_BOOL("window_maximize",          S, 0, _window_maximize,  false,        STR_NULL, NULL),
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1153
	 SDTG_END()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1154
};
3051
6a9ddcac6d56 (svn r3640) - Remove win32-only variables from variables.h and put them into win32_v.c. Also ifdef the win32 specific configuration file settings.
Darkvater
parents: 3042
diff changeset
  1155
#endif /* WIN32 */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1156
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1157
static const SettingDescGlobVarList _misc_settings[] = {
6696
c911b2ae7426 (svn r9928) -Fix (r9805): Default display options were not set correctly.
peter1138
parents: 6674
diff changeset
  1158
	SDTG_MMANY("display_opt",     SLE_UINT8, S, 0, _display_opt,       (1 << DO_SHOW_TOWN_NAMES | 1 << DO_SHOW_STATION_NAMES | 1 << DO_SHOW_SIGNS | 1 << DO_FULL_ANIMATION | 1 << DO_FULL_DETAIL | 1 << DO_WAYPOINTS), "SHOW_TOWN_NAMES|SHOW_STATION_NAMES|SHOW_SIGNS|FULL_ANIMATION||FULL_DETAIL|WAYPOINTS", STR_NULL, NULL),
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1159
	 SDTG_BOOL("news_ticker_sound",          S, 0, _news_ticker_sound,     true,    STR_NULL, NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1160
	 SDTG_BOOL("fullscreen",                 S, 0, _fullscreen,           false,    STR_NULL, NULL),
10037
a06670f961a8 (svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium
parents: 10026
diff changeset
  1161
	  SDTG_STR("graphicsset",      SLE_STRB,C|S,0, _ini_graphics_set,      NULL,    STR_NULL, NULL),
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1162
	  SDTG_STR("videodriver",      SLE_STRB,C|S,0, _ini_videodriver,       NULL,    STR_NULL, NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1163
	  SDTG_STR("musicdriver",      SLE_STRB,C|S,0, _ini_musicdriver,       NULL,    STR_NULL, NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1164
	  SDTG_STR("sounddriver",      SLE_STRB,C|S,0, _ini_sounddriver,       NULL,    STR_NULL, NULL),
7567
ab5661f127f8 (svn r11092) -Add: allow 'blitter=<value>' in openttd.cfg to set the blitter (so you don't have to keep on doing 'openttd -b 32bpp-optimized'..)
truelight
parents: 7547
diff changeset
  1165
	  SDTG_STR("blitter",          SLE_STRB,C|S,0, _ini_blitter,           NULL,    STR_NULL, NULL),
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1166
	  SDTG_STR("language",         SLE_STRB, S, 0, _dynlang.curr_file,     NULL,    STR_NULL, NULL),
9533
e8b86b70c5f6 (svn r13537) -Fix [FS#2090](r13523): QSortT won't work this way, use Dimension instead of uint16[2] for resolutions
smatz
parents: 9466
diff changeset
  1167
	SDTG_CONDLIST("resolution",  SLE_INT, 2, S, 0, _cur_resolution,   "640,480",    STR_NULL, NULL, 0, SL_MAX_VERSION), // workaround for implicit lengthof() in SDTG_LIST
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1168
	  SDTG_STR("screenshot_format",SLE_STRB, S, 0, _screenshot_format_name,NULL,    STR_NULL, NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1169
	  SDTG_STR("savegame_format",  SLE_STRB, S, 0, _savegame_format,       NULL,    STR_NULL, NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1170
	 SDTG_BOOL("rightclick_emulate",         S, 0, _rightclick_emulate,   false,    STR_NULL, NULL),
5108
aeaef6fe53b7 (svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents: 5107
diff changeset
  1171
#ifdef WITH_FREETYPE
aeaef6fe53b7 (svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents: 5107
diff changeset
  1172
	  SDTG_STR("small_font",       SLE_STRB, S, 0, _freetype.small_font,   NULL,    STR_NULL, NULL),
aeaef6fe53b7 (svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents: 5107
diff changeset
  1173
	  SDTG_STR("medium_font",      SLE_STRB, S, 0, _freetype.medium_font,  NULL,    STR_NULL, NULL),
aeaef6fe53b7 (svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents: 5107
diff changeset
  1174
	  SDTG_STR("large_font",       SLE_STRB, S, 0, _freetype.large_font,   NULL,    STR_NULL, NULL),
aeaef6fe53b7 (svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents: 5107
diff changeset
  1175
	  SDTG_VAR("small_size",       SLE_UINT, S, 0, _freetype.small_size,   6, 0, 72, 0, STR_NULL, NULL),
aeaef6fe53b7 (svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents: 5107
diff changeset
  1176
	  SDTG_VAR("medium_size",      SLE_UINT, S, 0, _freetype.medium_size, 10, 0, 72, 0, STR_NULL, NULL),
aeaef6fe53b7 (svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents: 5107
diff changeset
  1177
	  SDTG_VAR("large_size",       SLE_UINT, S, 0, _freetype.large_size,  16, 0, 72, 0, STR_NULL, NULL),
6913
ff5f8a9c1747 (svn r10166) -Feature(tte): Add support for antialiased typefaces via FreeType. This is configurable for each font size in the configuration settings and requires using the 32bpp blitter and suitable fonts.
peter1138
parents: 6878
diff changeset
  1178
	 SDTG_BOOL("small_aa",                   S, 0, _freetype.small_aa,    false,    STR_NULL, NULL),
ff5f8a9c1747 (svn r10166) -Feature(tte): Add support for antialiased typefaces via FreeType. This is configurable for each font size in the configuration settings and requires using the 32bpp blitter and suitable fonts.
peter1138
parents: 6878
diff changeset
  1179
	 SDTG_BOOL("medium_aa",                  S, 0, _freetype.medium_aa,   false,    STR_NULL, NULL),
ff5f8a9c1747 (svn r10166) -Feature(tte): Add support for antialiased typefaces via FreeType. This is configurable for each font size in the configuration settings and requires using the 32bpp blitter and suitable fonts.
peter1138
parents: 6878
diff changeset
  1180
	 SDTG_BOOL("large_aa",                   S, 0, _freetype.large_aa,    false,    STR_NULL, NULL),
5108
aeaef6fe53b7 (svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents: 5107
diff changeset
  1181
#endif
6852
439563b70fd3 (svn r10092) -Codechange: code-seperated the spriteloader and blitter from the rest of the code
truelight
parents: 6803
diff changeset
  1182
	  SDTG_VAR("sprite_cache_size",SLE_UINT, S, 0, _sprite_cache_size,     4, 1, 64, 0, STR_NULL, NULL),
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10199
diff changeset
  1183
	  SDTG_VAR("player_face",    SLE_UINT32, S, 0, _company_manager_face,0,0,0xFFFFFFFF,0, STR_NULL, NULL),
8529
93d4dea423e5 (svn r12104) -Fix (r12103): remember loading indicators transparency settings and make in switchable by Ctrl+9
smatz
parents: 8528
diff changeset
  1184
	  SDTG_VAR("transparency_options", SLE_UINT, S, 0, _transparency_opt,  0,0,0x1FF,0, STR_NULL, NULL),
93d4dea423e5 (svn r12104) -Fix (r12103): remember loading indicators transparency settings and make in switchable by Ctrl+9
smatz
parents: 8528
diff changeset
  1185
	  SDTG_VAR("transparency_locks", SLE_UINT, S, 0, _transparency_lock,   0,0,0x1FF,0, STR_NULL, NULL),
8806
4fe163e0b52a (svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents: 8763
diff changeset
  1186
	  SDTG_VAR("invisibility_options", SLE_UINT, S, 0, _invisibility_opt,  0,0, 0xFF,0, STR_NULL, NULL),
8737
4405e2e80db6 (svn r12425) -Feature [FS#1846]: On Screen Keyboard for input fields so someone without a keyboard can enter text too. Patch by Dominik.
rubidium
parents: 8730
diff changeset
  1187
	  SDTG_STR("keyboard",         SLE_STRB, S, 0, _keyboard_opt[0],       NULL,    STR_NULL, NULL),
4405e2e80db6 (svn r12425) -Feature [FS#1846]: On Screen Keyboard for input fields so someone without a keyboard can enter text too. Patch by Dominik.
rubidium
parents: 8730
diff changeset
  1188
	  SDTG_STR("keyboard_caps",    SLE_STRB, S, 0, _keyboard_opt[1],       NULL,    STR_NULL, NULL),
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1189
	  SDTG_END()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1190
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1191
9359
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
  1192
static const uint GAME_DIFFICULTY_NUM = 18;
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
  1193
uint16 _old_diff_custom[GAME_DIFFICULTY_NUM];
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
  1194
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1195
static const SettingDesc _gameopt_settings[] = {
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1196
	/* In version 4 a new difficulty setting has been added to the difficulty settings,
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1197
	 * town attitude towards demolishing. Needs special handling because some dimwit thought
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1198
	 * it funny to have the GameDifficulty struct be an array while it is a struct of
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1199
	 * same-sized members
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1200
	 * XXX - To save file-space and since values are never bigger than about 10? only
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1201
	 * save the first 16 bits in the savegame. Question is why the values are still int32
8382
c13cbd411724 (svn r11951) -Fix (r11279): loading of very old savegames was broken
smatz
parents: 8276
diff changeset
  1202
	 * and why not byte for example?
c13cbd411724 (svn r11951) -Fix (r11279): loading of very old savegames was broken
smatz
parents: 8276
diff changeset
  1203
	 * 'SLE_FILE_I16 | SLE_VAR_U16' in "diff_custom" is needed to get around SlArray() hack
c13cbd411724 (svn r11951) -Fix (r11279): loading of very old savegames was broken
smatz
parents: 8276
diff changeset
  1204
	 * for savegames version 0 - though it is an array, it has to go through the byteswap process */
9359
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
  1205
	 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),
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
  1206
	 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, 96),
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
  1207
9413
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1208
	      SDT_VAR(GameSettings, difficulty.diff_level,    SLE_UINT8,                     0, 0, 0, 0,  3, 0, STR_NULL, NULL),
9466
5a1d4eb2ae07 (svn r13386) -Fix: global currency/units setting being overriden when loading a savegame.
rubidium
parents: 9457
diff changeset
  1209
	    SDT_OMANY(GameSettings, locale.currency,          SLE_UINT8,                     N, 0, 0, CUSTOM_CURRENCY_ID, "GBP|USD|EUR|YEN|ATS|BEF|CHF|CZK|DEM|DKK|ESP|FIM|FRF|GRD|HUF|ISK|ITL|NLG|NOK|PLN|ROL|RUR|SIT|SEK|YTL|SKK|BRR|custom", STR_NULL, NULL, NULL),
5a1d4eb2ae07 (svn r13386) -Fix: global currency/units setting being overriden when loading a savegame.
rubidium
parents: 9457
diff changeset
  1210
	    SDT_OMANY(GameSettings, locale.units,             SLE_UINT8,                     N, 0, 1, 2, "imperial|metric|si", STR_NULL, NULL, NULL),
6956
3579bfc5157b (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents: 6950
diff changeset
  1211
	/* There are only 21 predefined town_name values (0-20), but you can have more with newgrf action F so allow these bigger values (21-255). Invalid values will fallback to english on use and (undefined string) in GUI. */
9413
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1212
	    SDT_OMANY(GameSettings, game_creation.town_name,  SLE_UINT8,                     0, 0, 0, 255, "english|french|german|american|latin|silly|swedish|dutch|finnish|polish|slovakish|norwegian|hungarian|austrian|romanian|czech|swiss|danish|turkish|italian|catalan", STR_NULL, NULL, NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1213
	    SDT_OMANY(GameSettings, game_creation.landscape,  SLE_UINT8,                     0, 0, 0, 3, "temperate|arctic|tropic|toyland", STR_NULL, NULL, ConvertLandscape),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1214
	      SDT_VAR(GameSettings, game_creation.snow_line,  SLE_UINT8,                     0, 0, 7 * TILE_HEIGHT, 2 * TILE_HEIGHT, 13 * TILE_HEIGHT, 0, STR_NULL, NULL),
9422
d6f782473011 (svn r13336) -Fix: loading old savegames, e.g. the intro game, would reset the autosave settings.
rubidium
parents: 9420
diff changeset
  1215
	 SDT_CONDNULL(                                                1,  0, 22),
9413
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1216
 SDTC_CONDOMANY(              gui.autosave,             SLE_UINT8, 23, SL_MAX_VERSION, S, 0, 1, 4, "off|monthly|quarterly|half year|yearly", STR_NULL, NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1217
	    SDT_OMANY(GameSettings, vehicle.road_side,        SLE_UINT8,                     0, 0, 1, 1, "left|right", STR_NULL, NULL, NULL),
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1218
	    SDT_END()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1219
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1220
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1221
/* Some patches do not need to be synchronised when playing in multiplayer.
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1222
 * These include for example the GUI settings and will not be saved with the
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1223
 * savegame.
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1224
 * It is also a bit tricky since you would think that service_interval
4000
4009d092b306 (svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents: 3982
diff changeset
  1225
 * for example doesn't need to be synched. Every client assigns the
4009d092b306 (svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents: 3982
diff changeset
  1226
 * service_interval value to the v->service_interval, meaning that every client
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10199
diff changeset
  1227
 * assigns his value. If the setting was company-based, that would mean that
4000
4009d092b306 (svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents: 3982
diff changeset
  1228
 * vehicles could decide on different moments that they are heading back to a
4009d092b306 (svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents: 3982
diff changeset
  1229
 * service depot, causing desyncs on a massive scale. */
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1230
const SettingDesc _patch_settings[] = {
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1231
	/***************************************************************************/
9354
845e07db4549 (svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents: 9350
diff changeset
  1232
	/* Saved patch variables. */
9359
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
  1233
	/* Do not ADD or REMOVE something in this "difficulty.XXX" table or before it. It breaks savegame compatability. */
9413
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1234
	 SDT_CONDVAR(GameSettings, difficulty.max_no_competitors,        SLE_UINT8, 97, SL_MAX_VERSION, 0, 0,     2,     0,      7,  1, STR_NULL,                                  DifficultyChange),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1235
	 SDT_CONDVAR(GameSettings, difficulty.competitor_start_time,     SLE_UINT8, 97, SL_MAX_VERSION, 0,NG,     2,     0,      3,  1, STR_6830_IMMEDIATE,                        DifficultyChange),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1236
	 SDT_CONDVAR(GameSettings, difficulty.number_towns,              SLE_UINT8, 97, SL_MAX_VERSION, 0,NG,     2,     0,      3,  1, STR_NUM_VERY_LOW,                          DifficultyChange),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1237
	 SDT_CONDVAR(GameSettings, difficulty.number_industries,         SLE_UINT8, 97, SL_MAX_VERSION, 0,NG,     4,     0,      4,  1, STR_NONE,                                  DifficultyChange),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1238
	 SDT_CONDVAR(GameSettings, difficulty.max_loan,                 SLE_UINT32, 97, SL_MAX_VERSION, 0,NG|CR,300000,100000,500000,50000,STR_NULL,                               DifficultyChange),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1239
	 SDT_CONDVAR(GameSettings, difficulty.initial_interest,          SLE_UINT8, 97, SL_MAX_VERSION, 0,NG,     2,     2,      4,  1, STR_NULL,                                  DifficultyChange),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1240
	 SDT_CONDVAR(GameSettings, difficulty.vehicle_costs,             SLE_UINT8, 97, SL_MAX_VERSION, 0, 0,     0,     0,      2,  1, STR_6820_LOW,                              DifficultyChange),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1241
	 SDT_CONDVAR(GameSettings, difficulty.competitor_speed,          SLE_UINT8, 97, SL_MAX_VERSION, 0, 0,     2,     0,      4,  1, STR_681B_VERY_SLOW,                        DifficultyChange),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1242
	 SDT_CONDVAR(GameSettings, difficulty.competitor_intelligence,   SLE_UINT8, 97, SL_MAX_VERSION, 0, 0,     0,     0,      2,  1, STR_6820_LOW,                              DifficultyChange),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1243
	 SDT_CONDVAR(GameSettings, difficulty.vehicle_breakdowns,        SLE_UINT8, 97, SL_MAX_VERSION, 0, 0,     1,     0,      2,  1, STR_6823_NONE,                             DifficultyChange),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1244
	 SDT_CONDVAR(GameSettings, difficulty.subsidy_multiplier,        SLE_UINT8, 97, SL_MAX_VERSION, 0, 0,     2,     0,      3,  1, STR_6826_X1_5,                             DifficultyChange),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1245
	 SDT_CONDVAR(GameSettings, difficulty.construction_cost,         SLE_UINT8, 97, SL_MAX_VERSION, 0,NG,     0,     0,      2,  1, STR_6820_LOW,                              DifficultyChange),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1246
	 SDT_CONDVAR(GameSettings, difficulty.terrain_type,              SLE_UINT8, 97, SL_MAX_VERSION, 0,NG,     1,     0,      3,  1, STR_682A_VERY_FLAT,                        DifficultyChange),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1247
	 SDT_CONDVAR(GameSettings, difficulty.quantity_sea_lakes,        SLE_UINT8, 97, SL_MAX_VERSION, 0,NG,     0,     0,      3,  1, STR_VERY_LOW,                              DifficultyChange),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1248
	 SDT_CONDVAR(GameSettings, difficulty.economy,                   SLE_UINT8, 97, SL_MAX_VERSION, 0, 0,     0,     0,      1,  1, STR_682E_STEADY,                           DifficultyChange),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1249
	 SDT_CONDVAR(GameSettings, difficulty.line_reverse_mode,         SLE_UINT8, 97, SL_MAX_VERSION, 0, 0,     0,     0,      1,  1, STR_6834_AT_END_OF_LINE_AND_AT_STATIONS,   DifficultyChange),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1250
	 SDT_CONDVAR(GameSettings, difficulty.disasters,                 SLE_UINT8, 97, SL_MAX_VERSION, 0, 0,     0,     0,      1,  1, STR_6836_OFF,                              DifficultyChange),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1251
	 SDT_CONDVAR(GameSettings, difficulty.town_council_tolerance,    SLE_UINT8, 97, SL_MAX_VERSION, 0, 0,     0,     0,      2,  1, STR_PERMISSIVE,                            DifficultyNoiseChange),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1252
	 SDT_CONDVAR(GameSettings, difficulty.diff_level,                SLE_UINT8, 97, SL_MAX_VERSION, 0,NG,     0,     0,      3,  0, STR_NULL,                                  DifficultyReset),
9359
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
  1253
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
  1254
	/* There are only 21 predefined town_name values (0-20), but you can have more with newgrf action F so allow these bigger values (21-255). Invalid values will fallback to english on use and (undefined string) in GUI. */
9413
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1255
 SDT_CONDOMANY(GameSettings, game_creation.town_name,              SLE_UINT8, 97, SL_MAX_VERSION, 0,NN, 0, 255, "english|french|german|american|latin|silly|swedish|dutch|finnish|polish|slovakish|norwegian|hungarian|austrian|romanian|czech|swiss|danish|turkish|italian|catalan", STR_NULL, NULL, NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1256
 SDT_CONDOMANY(GameSettings, game_creation.landscape,              SLE_UINT8, 97, SL_MAX_VERSION, 0,NN, 0,   3, "temperate|arctic|tropic|toyland", STR_NULL, NULL, ConvertLandscape),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1257
	 SDT_CONDVAR(GameSettings, game_creation.snow_line,              SLE_UINT8, 97, SL_MAX_VERSION, 0,NN, 7 * TILE_HEIGHT, 2 * TILE_HEIGHT, 13 * TILE_HEIGHT, 0, STR_NULL, NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1258
 SDT_CONDOMANY(GameSettings, vehicle.road_side,                    SLE_UINT8, 97, SL_MAX_VERSION, 0,NN, 1,   1, "left|right", STR_NULL, NULL, NULL),
9354
845e07db4549 (svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents: 9350
diff changeset
  1259
9413
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1260
	    SDT_BOOL(GameSettings, construction.build_on_slopes,                                        0,NN,  true,                    STR_CONFIG_PATCHES_BUILDONSLOPES,          NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1261
	SDT_CONDBOOL(GameSettings, construction.autoslope,                          75, SL_MAX_VERSION, 0, 0,  true,                    STR_CONFIG_PATCHES_AUTOSLOPE,              NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1262
	    SDT_BOOL(GameSettings, construction.extra_dynamite,                                         0, 0, false,                    STR_CONFIG_PATCHES_EXTRADYNAMITE,          NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1263
	    SDT_BOOL(GameSettings, construction.longbridges,                                            0,NN,  true,                    STR_CONFIG_PATCHES_LONGBRIDGES,            NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1264
	    SDT_BOOL(GameSettings, construction.signal_side,                                            N,NN,  true,                    STR_CONFIG_PATCHES_SIGNALSIDE,             RedrawScreen),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1265
	    SDT_BOOL(GameSettings, station.always_small_airport,                                        0,NN, false,                    STR_CONFIG_PATCHES_SMALL_AIRPORTS,         NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1266
	 SDT_CONDVAR(GameSettings, economy.town_layout,                  SLE_UINT8, 59, SL_MAX_VERSION, 0,MS,TL_ORIGINAL,TL_NO_ROADS,NUM_TLS-1,1, STR_CONFIG_PATCHES_TOWN_LAYOUT,  CheckTownLayout),
9354
845e07db4549 (svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents: 9350
diff changeset
  1267
9413
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1268
	    SDT_BOOL(GameSettings, vehicle.realistic_acceleration,                                      0, 0, false,                    STR_CONFIG_PATCHES_REALISTICACCEL,         RealisticAccelerationChanged),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1269
	    SDT_BOOL(GameSettings, pf.forbid_90_deg,                                                    0, 0, false,                    STR_CONFIG_PATCHES_FORBID_90_DEG,          NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1270
	    SDT_BOOL(GameSettings, vehicle.mammoth_trains,                                              0,NN,  true,                    STR_CONFIG_PATCHES_MAMMOTHTRAINS,          NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1271
	    SDT_BOOL(GameSettings, order.gotodepot,                                                     0, 0,  true,                    STR_CONFIG_PATCHES_GOTODEPOT,              NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1272
	    SDT_BOOL(GameSettings, pf.roadveh_queue,                                                    0, 0,  true,                    STR_CONFIG_PATCHES_ROADVEH_QUEUE,          NULL),
9354
845e07db4549 (svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents: 9350
diff changeset
  1273
9413
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1274
	SDT_CONDBOOL(GameSettings, pf.new_pathfinding_all,                           0,             86, 0, 0, false,                    STR_NULL,                                  NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1275
	SDT_CONDBOOL(GameSettings, pf.yapf.ship_use_yapf,                           28,             86, 0, 0, false,                    STR_NULL,                                  NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1276
	SDT_CONDBOOL(GameSettings, pf.yapf.road_use_yapf,                           28,             86, 0, 0,  true,                    STR_NULL,                                  NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1277
	SDT_CONDBOOL(GameSettings, pf.yapf.rail_use_yapf,                           28,             86, 0, 0,  true,                    STR_NULL,                                  NULL),
9354
845e07db4549 (svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents: 9350
diff changeset
  1278
9413
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1279
	 SDT_CONDVAR(GameSettings, pf.pathfinder_for_trains,             SLE_UINT8, 87, SL_MAX_VERSION, 0, MS,    2,     0,       2, 1, STR_CONFIG_PATCHES_PATHFINDER_FOR_TRAINS,  NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1280
	 SDT_CONDVAR(GameSettings, pf.pathfinder_for_roadvehs,           SLE_UINT8, 87, SL_MAX_VERSION, 0, MS,    2,     0,       2, 1, STR_CONFIG_PATCHES_PATHFINDER_FOR_ROADVEH, NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1281
	 SDT_CONDVAR(GameSettings, pf.pathfinder_for_ships,              SLE_UINT8, 87, SL_MAX_VERSION, 0, MS,    0,     0,       2, 1, STR_CONFIG_PATCHES_PATHFINDER_FOR_SHIPS,   NULL),
9354
845e07db4549 (svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents: 9350
diff changeset
  1282
9413
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1283
	    SDT_BOOL(GameSettings, vehicle.never_expire_vehicles,                                       0,NN, false,                    STR_CONFIG_PATCHES_NEVER_EXPIRE_VEHICLES,  NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1284
	     SDT_VAR(GameSettings, vehicle.max_trains,                  SLE_UINT16,                     0, 0,   500,     0,    5000, 0, STR_CONFIG_PATCHES_MAX_TRAINS,             RedrawScreen),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1285
	     SDT_VAR(GameSettings, vehicle.max_roadveh,                 SLE_UINT16,                     0, 0,   500,     0,    5000, 0, STR_CONFIG_PATCHES_MAX_ROADVEH,            RedrawScreen),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1286
	     SDT_VAR(GameSettings, vehicle.max_aircraft,                SLE_UINT16,                     0, 0,   200,     0,    5000, 0, STR_CONFIG_PATCHES_MAX_AIRCRAFT,           RedrawScreen),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1287
	     SDT_VAR(GameSettings, vehicle.max_ships,                   SLE_UINT16,                     0, 0,   300,     0,    5000, 0, STR_CONFIG_PATCHES_MAX_SHIPS,              RedrawScreen),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1288
	    SDT_BOOL(GameSettings, vehicle.servint_ispercent,                                           0, 0, false,                    STR_CONFIG_PATCHES_SERVINT_ISPERCENT,      CheckInterval),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1289
	     SDT_VAR(GameSettings, vehicle.servint_trains,              SLE_UINT16,                     0,D0,   150,     5,     800, 0, STR_CONFIG_PATCHES_SERVINT_TRAINS,         InValidateDetailsWindow),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1290
	     SDT_VAR(GameSettings, vehicle.servint_roadveh,             SLE_UINT16,                     0,D0,   150,     5,     800, 0, STR_CONFIG_PATCHES_SERVINT_ROADVEH,        InValidateDetailsWindow),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1291
	     SDT_VAR(GameSettings, vehicle.servint_ships,               SLE_UINT16,                     0,D0,   360,     5,     800, 0, STR_CONFIG_PATCHES_SERVINT_SHIPS,          InValidateDetailsWindow),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1292
	     SDT_VAR(GameSettings, vehicle.servint_aircraft,            SLE_UINT16,                     0,D0,   100,     5,     800, 0, STR_CONFIG_PATCHES_SERVINT_AIRCRAFT,       InValidateDetailsWindow),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1293
	    SDT_BOOL(GameSettings, order.no_servicing_if_no_breakdowns,                                 0, 0, false,                    STR_CONFIG_PATCHES_NOSERVICE,              NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1294
	    SDT_BOOL(GameSettings, vehicle.wagon_speed_limits,                                          0,NN,  true,                    STR_CONFIG_PATCHES_WAGONSPEEDLIMITS,       UpdateConsists),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1295
	SDT_CONDBOOL(GameSettings, vehicle.disable_elrails,                         38, SL_MAX_VERSION, 0,NN, false,                    STR_CONFIG_PATCHES_DISABLE_ELRAILS,        SettingsDisableElrail),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1296
	 SDT_CONDVAR(GameSettings, vehicle.freight_trains,               SLE_UINT8, 39, SL_MAX_VERSION, 0,NN,     1,     1,     255, 1, STR_CONFIG_PATCHES_FREIGHT_TRAINS,         NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1297
	SDT_CONDBOOL(GameSettings, order.timetabling,                               67, SL_MAX_VERSION, 0, 0,  true,                    STR_CONFIG_PATCHES_TIMETABLE_ALLOW,        NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1298
	 SDT_CONDVAR(GameSettings, vehicle.plane_speed,                  SLE_UINT8, 90, SL_MAX_VERSION, 0, 0,     4,     1,       4, 0, STR_CONFIG_PATCHES_PLANE_SPEED,            NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1299
	SDT_CONDBOOL(GameSettings, vehicle.dynamic_engines,                         95, SL_MAX_VERSION, 0,NN, false,                    STR_CONFIG_PATCHES_DYNAMIC_ENGINES,        NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1300
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1301
	    SDT_BOOL(GameSettings, station.join_stations,                                               0, 0,  true,                    STR_CONFIG_PATCHES_JOINSTATIONS,           NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1302
 SDTC_CONDBOOL(              gui.sg_full_load_any,                             0,             92, 0, 0 , true,                    STR_NULL,                                  NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1303
	    SDT_BOOL(GameSettings, order.improved_load,                                                 0,NN,  true,                    STR_CONFIG_PATCHES_IMPROVEDLOAD,           NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1304
	    SDT_BOOL(GameSettings, order.selectgoods,                                                   0, 0,  true,                    STR_CONFIG_PATCHES_SELECTGOODS,            NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1305
 SDTC_CONDBOOL(              gui.sg_new_nonstop,                               0,             92, 0, 0, false,                    STR_NULL,                                  NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1306
	    SDT_BOOL(GameSettings, station.nonuniform_stations,                                         0,NN,  true,                    STR_CONFIG_PATCHES_NONUNIFORM_STATIONS,    NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1307
	     SDT_VAR(GameSettings, station.station_spread,               SLE_UINT8,                     0, 0,    12,     4,      64, 0, STR_CONFIG_PATCHES_STATION_SPREAD,         InvalidateStationBuildWindow),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1308
	    SDT_BOOL(GameSettings, order.serviceathelipad,                                              0, 0,  true,                    STR_CONFIG_PATCHES_SERVICEATHELIPAD,       NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1309
	    SDT_BOOL(GameSettings, station.modified_catchment,                                          0, 0,  true,                    STR_CONFIG_PATCHES_CATCHMENT,              NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1310
	SDT_CONDBOOL(GameSettings, order.gradual_loading,                           40, SL_MAX_VERSION, 0, 0,  true,                    STR_CONFIG_PATCHES_GRADUAL_LOADING,        NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1311
	SDT_CONDBOOL(GameSettings, construction.road_stop_on_town_road,             47, SL_MAX_VERSION, 0, 0,  true,                    STR_CONFIG_PATCHES_STOP_ON_TOWN_ROAD,      NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1312
	SDT_CONDBOOL(GameSettings, station.adjacent_stations,                       62, SL_MAX_VERSION, 0, 0,  true,                    STR_CONFIG_PATCHES_ADJACENT_STATIONS,      NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1313
	SDT_CONDBOOL(GameSettings, economy.station_noise_level,                     96, SL_MAX_VERSION, 0, 0, false,                    STR_CONFIG_PATCHES_NOISE_LEVEL,            InvalidateTownViewWindow),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1314
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1315
	    SDT_BOOL(GameSettings, economy.inflation,                                                   0, 0,  true,                    STR_CONFIG_PATCHES_INFLATION,              NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1316
	     SDT_VAR(GameSettings, construction.raw_industry_construction, SLE_UINT8,                   0,MS,     0,     0,       2, 0, STR_CONFIG_PATCHES_RAW_INDUSTRY_CONSTRUCTION_METHOD, InvalidateBuildIndustryWindow),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1317
	    SDT_BOOL(GameSettings, economy.multiple_industry_per_town,                                  0, 0, false,                    STR_CONFIG_PATCHES_MULTIPINDTOWN,          NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1318
	    SDT_BOOL(GameSettings, economy.same_industry_close,                                         0, 0, false,                    STR_CONFIG_PATCHES_SAMEINDCLOSE,           NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1319
	    SDT_BOOL(GameSettings, economy.bribe,                                                       0, 0,  true,                    STR_CONFIG_PATCHES_BRIBE,                  NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1320
	SDT_CONDBOOL(GameSettings, economy.exclusive_rights,                        79, SL_MAX_VERSION, 0, 0,  true,                    STR_CONFIG_PATCHES_ALLOW_EXCLUSIVE,        NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1321
	SDT_CONDBOOL(GameSettings, economy.give_money,                              79, SL_MAX_VERSION, 0, 0,  true,                    STR_CONFIG_PATCHES_ALLOW_GIVE_MONEY,       NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1322
	     SDT_VAR(GameSettings, game_creation.snow_line_height,       SLE_UINT8,                     0, 0,     7,     2,      13, 0, STR_CONFIG_PATCHES_SNOWLINE_HEIGHT,        NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1323
	    SDTC_VAR(              gui.colored_news_year,                SLE_INT32,                     0,NC,  2000,MIN_YEAR,MAX_YEAR,1,STR_CONFIG_PATCHES_COLORED_NEWS_YEAR,      NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1324
	     SDT_VAR(GameSettings, game_creation.starting_year,          SLE_INT32,                     0,NC,  1950,MIN_YEAR,MAX_YEAR,1,STR_CONFIG_PATCHES_STARTING_YEAR,          NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1325
	    SDTC_VAR(              gui.ending_year,                      SLE_INT32,                    0,NC|NO,2051,MIN_YEAR,MAX_YEAR,1,STR_CONFIG_PATCHES_ENDING_YEAR,            NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1326
	    SDT_BOOL(GameSettings, economy.smooth_economy,                                              0, 0,  true,                    STR_CONFIG_PATCHES_SMOOTH_ECONOMY,         NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1327
	    SDT_BOOL(GameSettings, economy.allow_shares,                                                0, 0, false,                    STR_CONFIG_PATCHES_ALLOW_SHARES,           NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1328
	 SDT_CONDVAR(GameSettings, economy.town_growth_rate,             SLE_UINT8, 54, SL_MAX_VERSION, 0, MS,    2,     0,       4, 0, STR_CONFIG_PATCHES_TOWN_GROWTH,            NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1329
	 SDT_CONDVAR(GameSettings, economy.larger_towns,                 SLE_UINT8, 54, SL_MAX_VERSION, 0, D0,    4,     0,     255, 1, STR_CONFIG_PATCHES_LARGER_TOWNS,           NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1330
	 SDT_CONDVAR(GameSettings, economy.initial_city_size,            SLE_UINT8, 56, SL_MAX_VERSION, 0, 0,     2,     1,      10, 1, STR_CONFIG_PATCHES_CITY_SIZE_MULTIPLIER,   NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1331
	SDT_CONDBOOL(GameSettings, economy.mod_road_rebuild,                        77, SL_MAX_VERSION, 0, 0, false,                    STR_CONFIG_MODIFIED_ROAD_REBUILD,          NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1332
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1333
	    SDT_BOOL(GameSettings, ai.ainew_active,                                                     0, 0, false,                    STR_CONFIG_PATCHES_AINEW_ACTIVE,           AiNew_PatchActive_Warning),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1334
	    SDT_BOOL(GameSettings, ai.ai_in_multiplayer,                                                0, 0, false,                    STR_CONFIG_PATCHES_AI_IN_MULTIPLAYER,      Ai_In_Multiplayer_Warning),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1335
	    SDT_BOOL(GameSettings, ai.ai_disable_veh_train,                                             0, 0, false,                    STR_CONFIG_PATCHES_AI_BUILDS_TRAINS,       NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1336
	    SDT_BOOL(GameSettings, ai.ai_disable_veh_roadveh,                                           0, 0, false,                    STR_CONFIG_PATCHES_AI_BUILDS_ROADVEH,      NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1337
	    SDT_BOOL(GameSettings, ai.ai_disable_veh_aircraft,                                          0, 0, false,                    STR_CONFIG_PATCHES_AI_BUILDS_AIRCRAFT,     NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1338
	    SDT_BOOL(GameSettings, ai.ai_disable_veh_ship,                                              0, 0, false,                    STR_CONFIG_PATCHES_AI_BUILDS_SHIPS,        NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1339
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1340
	     SDT_VAR(GameSettings, vehicle.extend_vehicle_life,          SLE_UINT8,                     0, 0,     0,     0,     100, 0, STR_NULL,                                  NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1341
	     SDT_VAR(GameSettings, economy.dist_local_authority,         SLE_UINT8,                     0, 0,    20,     5,      60, 0, STR_NULL,                                  NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1342
	     SDT_VAR(GameSettings, pf.wait_oneway_signal,                SLE_UINT8,                     0, 0,    15,     2,     100, 0, STR_NULL,                                  NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1343
	     SDT_VAR(GameSettings, pf.wait_twoway_signal,                SLE_UINT8,                     0, 0,    41,     2,     100, 0, STR_NULL,                                  NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1344
	SDT_CONDLISTO(GameSettings, economy.town_noise_population, 3,   SLE_UINT16, 96, SL_MAX_VERSION, 0,D0, "800,2000,4000",          STR_NULL,                                  NULL, CheckNoiseToleranceLevel),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1345
9810
c82ec2332a1b (svn r13952) -Add [YAPP]: Trains now reserve paths trough PBS signals. Bump savegame version. (michi_cc)
rubidium
parents: 9805
diff changeset
  1346
	 SDT_CONDVAR(GameSettings, pf.wait_for_pbs_path,                 SLE_UINT8,100, SL_MAX_VERSION, 0, 0,    30,     2,     255, 0, STR_NULL,                                  NULL),
c82ec2332a1b (svn r13952) -Add [YAPP]: Trains now reserve paths trough PBS signals. Bump savegame version. (michi_cc)
rubidium
parents: 9805
diff changeset
  1347
	SDT_CONDBOOL(GameSettings, pf.reserve_paths,                               100, SL_MAX_VERSION, 0, 0, false,                    STR_NULL,                                  NULL),
c82ec2332a1b (svn r13952) -Add [YAPP]: Trains now reserve paths trough PBS signals. Bump savegame version. (michi_cc)
rubidium
parents: 9805
diff changeset
  1348
	 SDT_CONDVAR(GameSettings, pf.path_backoff_interval,             SLE_UINT8,100, SL_MAX_VERSION, 0, 0,    20,     1,     255, 0, STR_NULL,                                  NULL),
c82ec2332a1b (svn r13952) -Add [YAPP]: Trains now reserve paths trough PBS signals. Bump savegame version. (michi_cc)
rubidium
parents: 9805
diff changeset
  1349
9413
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1350
	     SDT_VAR(GameSettings, pf.opf.pf_maxlength,                          SLE_UINT16,                     0, 0,  4096,                    64,   65535, 0, STR_NULL,         NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1351
	     SDT_VAR(GameSettings, pf.opf.pf_maxdepth,                            SLE_UINT8,                     0, 0,    48,                     4,     255, 0, STR_NULL,         NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1352
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1353
	     SDT_VAR(GameSettings, pf.npf.npf_max_search_nodes,                    SLE_UINT,                     0, 0, 10000,                   500,  100000, 0, STR_NULL,         NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1354
	     SDT_VAR(GameSettings, pf.npf.npf_rail_firstred_penalty,               SLE_UINT,                     0, 0, ( 10 * NPF_TILE_LENGTH),   0,  100000, 0, STR_NULL,         NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1355
	     SDT_VAR(GameSettings, pf.npf.npf_rail_firstred_exit_penalty,          SLE_UINT,                     0, 0, (100 * NPF_TILE_LENGTH),   0,  100000, 0, STR_NULL,         NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1356
	     SDT_VAR(GameSettings, pf.npf.npf_rail_lastred_penalty,                SLE_UINT,                     0, 0, ( 10 * NPF_TILE_LENGTH),   0,  100000, 0, STR_NULL,         NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1357
	     SDT_VAR(GameSettings, pf.npf.npf_rail_station_penalty,                SLE_UINT,                     0, 0, (  1 * NPF_TILE_LENGTH),   0,  100000, 0, STR_NULL,         NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1358
	     SDT_VAR(GameSettings, pf.npf.npf_rail_slope_penalty,                  SLE_UINT,                     0, 0, (  1 * NPF_TILE_LENGTH),   0,  100000, 0, STR_NULL,         NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1359
	     SDT_VAR(GameSettings, pf.npf.npf_rail_curve_penalty,                  SLE_UINT,                     0, 0, 1,                         0,  100000, 0, STR_NULL,         NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1360
	     SDT_VAR(GameSettings, pf.npf.npf_rail_depot_reverse_penalty,          SLE_UINT,                     0, 0, ( 50 * NPF_TILE_LENGTH),   0,  100000, 0, STR_NULL,         NULL),
9805
c6e69a451215 (svn r13947) -Codechange [YAPP]: Added YAPP-related penalties to NPF. (michi_cc)
rubidium
parents: 9801
diff changeset
  1361
	 SDT_CONDVAR(GameSettings, pf.npf.npf_rail_pbs_cross_penalty,              SLE_UINT,100, SL_MAX_VERSION, 0, 0, (  3 * NPF_TILE_LENGTH),   0,  100000, 0, STR_NULL,         NULL),
c6e69a451215 (svn r13947) -Codechange [YAPP]: Added YAPP-related penalties to NPF. (michi_cc)
rubidium
parents: 9801
diff changeset
  1362
	 SDT_CONDVAR(GameSettings, pf.npf.npf_rail_pbs_signal_back_penalty,        SLE_UINT,100, SL_MAX_VERSION, 0, 0, ( 15 * NPF_TILE_LENGTH),   0,  100000, 0, STR_NULL,         NULL),
9413
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1363
	     SDT_VAR(GameSettings, pf.npf.npf_buoy_penalty,                        SLE_UINT,                     0, 0, (  2 * NPF_TILE_LENGTH),   0,  100000, 0, STR_NULL,         NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1364
	     SDT_VAR(GameSettings, pf.npf.npf_water_curve_penalty,                 SLE_UINT,                     0, 0, (NPF_TILE_LENGTH / 4),     0,  100000, 0, STR_NULL,         NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1365
	     SDT_VAR(GameSettings, pf.npf.npf_road_curve_penalty,                  SLE_UINT,                     0, 0, 1,                         0,  100000, 0, STR_NULL,         NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1366
	     SDT_VAR(GameSettings, pf.npf.npf_crossing_penalty,                    SLE_UINT,                     0, 0, (  3 * NPF_TILE_LENGTH),   0,  100000, 0, STR_NULL,         NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1367
	 SDT_CONDVAR(GameSettings, pf.npf.npf_road_drive_through_penalty,          SLE_UINT, 47, SL_MAX_VERSION, 0, 0, (  8 * NPF_TILE_LENGTH),   0,  100000, 0, STR_NULL,         NULL),
9354
845e07db4549 (svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents: 9350
diff changeset
  1368
845e07db4549 (svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents: 9350
diff changeset
  1369
9413
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1370
	SDT_CONDBOOL(GameSettings, pf.yapf.disable_node_optimization,                        28, SL_MAX_VERSION, 0, 0, false,                                    STR_NULL,         NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1371
	 SDT_CONDVAR(GameSettings, pf.yapf.max_search_nodes,                       SLE_UINT, 28, SL_MAX_VERSION, 0, 0, 10000,                   500, 1000000, 0, STR_NULL,         NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1372
	SDT_CONDBOOL(GameSettings, pf.yapf.rail_firstred_twoway_eol,                         28, SL_MAX_VERSION, 0, 0,  true,                                    STR_NULL,         NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1373
	 SDT_CONDVAR(GameSettings, pf.yapf.rail_firstred_penalty,                  SLE_UINT, 28, SL_MAX_VERSION, 0, 0,    10 * YAPF_TILE_LENGTH,  0, 1000000, 0, STR_NULL,         NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1374
	 SDT_CONDVAR(GameSettings, pf.yapf.rail_firstred_exit_penalty,             SLE_UINT, 28, SL_MAX_VERSION, 0, 0,   100 * YAPF_TILE_LENGTH,  0, 1000000, 0, STR_NULL,         NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1375
	 SDT_CONDVAR(GameSettings, pf.yapf.rail_lastred_penalty,                   SLE_UINT, 28, SL_MAX_VERSION, 0, 0,    10 * YAPF_TILE_LENGTH,  0, 1000000, 0, STR_NULL,         NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1376
	 SDT_CONDVAR(GameSettings, pf.yapf.rail_lastred_exit_penalty,              SLE_UINT, 28, SL_MAX_VERSION, 0, 0,   100 * YAPF_TILE_LENGTH,  0, 1000000, 0, STR_NULL,         NULL),
9825
885c1aeb56a9 (svn r13967) -Codechange [YAPP]: Tweak pathfinder penalties a bit. (michi_cc)
rubidium
parents: 9810
diff changeset
  1377
	 SDT_CONDVAR(GameSettings, pf.yapf.rail_station_penalty,                   SLE_UINT, 28, SL_MAX_VERSION, 0, 0,    10 * YAPF_TILE_LENGTH,  0, 1000000, 0, STR_NULL,         NULL),
9413
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1378
	 SDT_CONDVAR(GameSettings, pf.yapf.rail_slope_penalty,                     SLE_UINT, 28, SL_MAX_VERSION, 0, 0,     2 * YAPF_TILE_LENGTH,  0, 1000000, 0, STR_NULL,         NULL),
9825
885c1aeb56a9 (svn r13967) -Codechange [YAPP]: Tweak pathfinder penalties a bit. (michi_cc)
rubidium
parents: 9810
diff changeset
  1379
	 SDT_CONDVAR(GameSettings, pf.yapf.rail_curve45_penalty,                   SLE_UINT, 28, SL_MAX_VERSION, 0, 0,     3 * YAPF_TILE_LENGTH,  0, 1000000, 0, STR_NULL,         NULL),
9413
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1380
	 SDT_CONDVAR(GameSettings, pf.yapf.rail_curve90_penalty,                   SLE_UINT, 28, SL_MAX_VERSION, 0, 0,     6 * YAPF_TILE_LENGTH,  0, 1000000, 0, STR_NULL,         NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1381
	 SDT_CONDVAR(GameSettings, pf.yapf.rail_depot_reverse_penalty,             SLE_UINT, 28, SL_MAX_VERSION, 0, 0,    50 * YAPF_TILE_LENGTH,  0, 1000000, 0, STR_NULL,         NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1382
	 SDT_CONDVAR(GameSettings, pf.yapf.rail_crossing_penalty,                  SLE_UINT, 28, SL_MAX_VERSION, 0, 0,     3 * YAPF_TILE_LENGTH,  0, 1000000, 0, STR_NULL,         NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1383
	 SDT_CONDVAR(GameSettings, pf.yapf.rail_look_ahead_max_signals,            SLE_UINT, 28, SL_MAX_VERSION, 0, 0,    10,                     1,     100, 0, STR_NULL,         NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1384
	 SDT_CONDVAR(GameSettings, pf.yapf.rail_look_ahead_signal_p0,               SLE_INT, 28, SL_MAX_VERSION, 0, 0,   500,              -1000000, 1000000, 0, STR_NULL,         NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1385
	 SDT_CONDVAR(GameSettings, pf.yapf.rail_look_ahead_signal_p1,               SLE_INT, 28, SL_MAX_VERSION, 0, 0,  -100,              -1000000, 1000000, 0, STR_NULL,         NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1386
	 SDT_CONDVAR(GameSettings, pf.yapf.rail_look_ahead_signal_p2,               SLE_INT, 28, SL_MAX_VERSION, 0, 0,     5,              -1000000, 1000000, 0, STR_NULL,         NULL),
9799
c91afc4512fe (svn r13941) -Codechange [YAPP]: Added YAPP-related penalties to YAPF. (michi_cc)
rubidium
parents: 9793
diff changeset
  1387
	 SDT_CONDVAR(GameSettings, pf.yapf.rail_pbs_cross_penalty,                 SLE_UINT,100, SL_MAX_VERSION, 0, 0,     3 * YAPF_TILE_LENGTH,  0, 1000000, 0, STR_NULL,         NULL),
9801
a6564ba05558 (svn r13943) -Codechange [YAPP]: Reserved station tiles can now be penalized more in YAPF. This should help with spread out stations. (michi_cc)
rubidium
parents: 9800
diff changeset
  1388
	 SDT_CONDVAR(GameSettings, pf.yapf.rail_pbs_station_penalty,               SLE_UINT,100, SL_MAX_VERSION, 0, 0,     8 * YAPF_TILE_LENGTH,  0, 1000000, 0, STR_NULL,         NULL),
9799
c91afc4512fe (svn r13941) -Codechange [YAPP]: Added YAPP-related penalties to YAPF. (michi_cc)
rubidium
parents: 9793
diff changeset
  1389
	 SDT_CONDVAR(GameSettings, pf.yapf.rail_pbs_signal_back_penalty,           SLE_UINT,100, SL_MAX_VERSION, 0, 0,    15 * YAPF_TILE_LENGTH,  0, 1000000, 0, STR_NULL,         NULL),
9800
a8cbb9206502 (svn r13942) -Codechange [YAPP]: Add a penalty for double slips to YAPF. (michi_cc)
rubidium
parents: 9799
diff changeset
  1390
	 SDT_CONDVAR(GameSettings, pf.yapf.rail_doubleslip_penalty,                SLE_UINT,100, SL_MAX_VERSION, 0, 0,     1 * YAPF_TILE_LENGTH,  0, 1000000, 0, STR_NULL,         NULL),
9413
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1391
	 SDT_CONDVAR(GameSettings, pf.yapf.rail_longer_platform_penalty,           SLE_UINT, 33, SL_MAX_VERSION, 0, 0,     8 * YAPF_TILE_LENGTH,  0,   20000, 0, STR_NULL,         NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1392
	 SDT_CONDVAR(GameSettings, pf.yapf.rail_longer_platform_per_tile_penalty,  SLE_UINT, 33, SL_MAX_VERSION, 0, 0,     0 * YAPF_TILE_LENGTH,  0,   20000, 0, STR_NULL,         NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1393
	 SDT_CONDVAR(GameSettings, pf.yapf.rail_shorter_platform_penalty,          SLE_UINT, 33, SL_MAX_VERSION, 0, 0,    40 * YAPF_TILE_LENGTH,  0,   20000, 0, STR_NULL,         NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1394
	 SDT_CONDVAR(GameSettings, pf.yapf.rail_shorter_platform_per_tile_penalty, SLE_UINT, 33, SL_MAX_VERSION, 0, 0,     0 * YAPF_TILE_LENGTH,  0,   20000, 0, STR_NULL,         NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1395
	 SDT_CONDVAR(GameSettings, pf.yapf.road_slope_penalty,                     SLE_UINT, 33, SL_MAX_VERSION, 0, 0,     2 * YAPF_TILE_LENGTH,  0, 1000000, 0, STR_NULL,         NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1396
	 SDT_CONDVAR(GameSettings, pf.yapf.road_curve_penalty,                     SLE_UINT, 33, SL_MAX_VERSION, 0, 0,     1 * YAPF_TILE_LENGTH,  0, 1000000, 0, STR_NULL,         NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1397
	 SDT_CONDVAR(GameSettings, pf.yapf.road_crossing_penalty,                  SLE_UINT, 33, SL_MAX_VERSION, 0, 0,     3 * YAPF_TILE_LENGTH,  0, 1000000, 0, STR_NULL,         NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1398
	 SDT_CONDVAR(GameSettings, pf.yapf.road_stop_penalty,                      SLE_UINT, 47, SL_MAX_VERSION, 0, 0,     8 * YAPF_TILE_LENGTH,  0, 1000000, 0, STR_NULL,         NULL),
9354
845e07db4549 (svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents: 9350
diff changeset
  1399
9413
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1400
	 SDT_CONDVAR(GameSettings, game_creation.land_generator,                  SLE_UINT8, 30, SL_MAX_VERSION, 0,MS,     1,                     0,       1, 0, STR_CONFIG_PATCHES_LAND_GENERATOR,        NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1401
	 SDT_CONDVAR(GameSettings, game_creation.oil_refinery_limit,              SLE_UINT8, 30, SL_MAX_VERSION, 0, 0,    32,                    12,      48, 0, STR_CONFIG_PATCHES_OIL_REF_EDGE_DISTANCE, NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1402
	 SDT_CONDVAR(GameSettings, game_creation.tgen_smoothness,                 SLE_UINT8, 30, SL_MAX_VERSION, 0,MS,     1,                     0,       3, 0, STR_CONFIG_PATCHES_ROUGHNESS_OF_TERRAIN,  NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1403
	 SDT_CONDVAR(GameSettings, game_creation.generation_seed,                SLE_UINT32, 30, SL_MAX_VERSION, 0, 0,      GENERATE_NEW_SEED, 0, UINT32_MAX, 0, STR_NULL,                                 NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1404
	 SDT_CONDVAR(GameSettings, game_creation.tree_placer,                     SLE_UINT8, 30, SL_MAX_VERSION, 0,MS,     2,                     0,       2, 0, STR_CONFIG_PATCHES_TREE_PLACER,           NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1405
	     SDT_VAR(GameSettings, game_creation.heightmap_rotation,              SLE_UINT8,                     S,MS,     0,                     0,       1, 0, STR_CONFIG_PATCHES_HEIGHTMAP_ROTATION,    NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1406
	     SDT_VAR(GameSettings, game_creation.se_flat_world_height,            SLE_UINT8,                     S, 0,     0,                     0,      15, 0, STR_CONFIG_PATCHES_SE_FLAT_WORLD_HEIGHT,  NULL),
1218
c6a624956ac6 (svn r1722) -Feature: Bigger maps - anyone?
tron
parents: 1104
diff changeset
  1407
9413
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1408
	     SDT_VAR(GameSettings, game_creation.map_x,                           SLE_UINT8,                     S, 0,     8,                     6,      11, 0, STR_CONFIG_PATCHES_MAP_X,                 NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1409
	     SDT_VAR(GameSettings, game_creation.map_y,                           SLE_UINT8,                     S, 0,     8,                     6,      11, 0, STR_CONFIG_PATCHES_MAP_Y,                 NULL),
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1410
9466
5a1d4eb2ae07 (svn r13386) -Fix: global currency/units setting being overriden when loading a savegame.
rubidium
parents: 9457
diff changeset
  1411
 SDT_CONDOMANY(GameSettings, locale.currency,                               SLE_UINT8, 97, SL_MAX_VERSION, N, 0, 0, CUSTOM_CURRENCY_ID, "GBP|USD|EUR|YEN|ATS|BEF|CHF|CZK|DEM|DKK|ESP|FIM|FRF|GRD|HUF|ISK|ITL|NLG|NOK|PLN|ROL|RUR|SIT|SEK|YTL|SKK|BRR|custom", STR_NULL, NULL, NULL),
5a1d4eb2ae07 (svn r13386) -Fix: global currency/units setting being overriden when loading a savegame.
rubidium
parents: 9457
diff changeset
  1412
 SDT_CONDOMANY(GameSettings, locale.units,                                  SLE_UINT8, 97, SL_MAX_VERSION, N, 0, 1, 2, "imperial|metric|si", STR_NULL, NULL, NULL),
9359
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
  1413
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1414
	/***************************************************************************/
9354
845e07db4549 (svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents: 9350
diff changeset
  1415
	/* Unsaved patch variables. */
9426
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1416
	SDTC_OMANY(gui.autosave,                  SLE_UINT8, S,  0, 1, 4, "off|monthly|quarterly|half year|yearly", STR_NULL,                     NULL),
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1417
	 SDTC_BOOL(gui.vehicle_speed,                        S,  0,  true,                        STR_CONFIG_PATCHES_VEHICLESPEED,                NULL),
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1418
	 SDTC_BOOL(gui.status_long_date,                     S,  0,  true,                        STR_CONFIG_PATCHES_LONGDATE,                    NULL),
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1419
	 SDTC_BOOL(gui.show_finances,                        S,  0,  true,                        STR_CONFIG_PATCHES_SHOWFINANCES,                NULL),
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1420
	 SDTC_BOOL(gui.autoscroll,                           S,  0, false,                        STR_CONFIG_PATCHES_AUTOSCROLL,                  NULL),
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1421
	 SDTC_BOOL(gui.reverse_scroll,                       S,  0, false,                        STR_CONFIG_PATCHES_REVERSE_SCROLLING,           NULL),
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1422
	 SDTC_BOOL(gui.smooth_scroll,                        S,  0, false,                        STR_CONFIG_PATCHES_SMOOTH_SCROLLING,            NULL),
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1423
	 SDTC_BOOL(gui.measure_tooltip,                      S,  0, false,                        STR_CONFIG_PATCHES_MEASURE_TOOLTIP,             NULL),
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1424
	  SDTC_VAR(gui.errmsg_duration,           SLE_UINT8, S,  0,     5,        0,       20, 0, STR_CONFIG_PATCHES_ERRMSG_DURATION,             NULL),
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1425
	  SDTC_VAR(gui.toolbar_pos,               SLE_UINT8, S, MS,     0,        0,        2, 0, STR_CONFIG_PATCHES_TOOLBAR_POS,                 v_PositionMainToolbar),
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1426
	  SDTC_VAR(gui.window_snap_radius,        SLE_UINT8, S, D0,    10,        1,       32, 0, STR_CONFIG_PATCHES_SNAP_RADIUS,                 NULL),
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1427
	 SDTC_BOOL(gui.population_in_label,                  S,  0,  true,                        STR_CONFIG_PATCHES_POPULATION_IN_LABEL,         PopulationInLabelActive),
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1428
	 SDTC_BOOL(gui.link_terraform_toolbar,               S,  0, false,                        STR_CONFIG_PATCHES_LINK_TERRAFORM_TOOLBAR,      NULL),
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1429
	  SDTC_VAR(gui.liveries,                  SLE_UINT8, S, MS,     2,        0,        2, 0, STR_CONFIG_PATCHES_LIVERIES,                    RedrawScreen),
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1430
	 SDTC_BOOL(gui.prefer_teamchat,                      S,  0, false,                        STR_CONFIG_PATCHES_PREFER_TEAMCHAT,             NULL),
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1431
	  SDTC_VAR(gui.scrollwheel_scrolling,     SLE_UINT8, S, MS,     0,        0,        2, 0, STR_CONFIG_PATCHES_SCROLLWHEEL_SCROLLING,       NULL),
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1432
	  SDTC_VAR(gui.scrollwheel_multiplier,    SLE_UINT8, S,  0,     5,        1,       15, 1, STR_CONFIG_PATCHES_SCROLLWHEEL_MULTIPLIER,      NULL),
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1433
	 SDTC_BOOL(gui.pause_on_newgame,                     S,  0, false,                        STR_CONFIG_PATCHES_PAUSE_ON_NEW_GAME,           NULL),
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1434
	  SDTC_VAR(gui.advanced_vehicle_list,     SLE_UINT8, S, MS,     1,        0,        2, 0, STR_CONFIG_PATCHES_ADVANCED_VEHICLE_LISTS,      NULL),
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1435
	 SDTC_BOOL(gui.timetable_in_ticks,                   S,  0, false,                        STR_CONFIG_PATCHES_TIMETABLE_IN_TICKS,          NULL),
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1436
	  SDTC_VAR(gui.loading_indicators,        SLE_UINT8, S, MS,     1,        0,        2, 0, STR_CONFIG_PATCHES_LOADING_INDICATORS,          RedrawScreen),
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1437
	  SDTC_VAR(gui.default_rail_type,         SLE_UINT8, S, MS,     4,        0,        6, 0, STR_CONFIG_PATCHES_DEFAULT_RAIL_TYPE,           NULL),
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1438
	 SDTC_BOOL(gui.enable_signal_gui,                    S,  0, false,                        STR_CONFIG_PATCHES_ENABLE_SIGNAL_GUI,           CloseSignalGUI),
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1439
	  SDTC_VAR(gui.drag_signals_density,      SLE_UINT8, S,  0,     4,        1,       20, 0, STR_CONFIG_PATCHES_DRAG_SIGNALS_DENSITY,        DragSignalsDensityChanged),
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1440
	  SDTC_VAR(gui.semaphore_build_before,    SLE_INT32, S, NC,  1975, MIN_YEAR, MAX_YEAR, 1, STR_CONFIG_PATCHES_SEMAPHORE_BUILD_BEFORE_DATE, ResetSignalVariant),
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1441
	 SDTC_BOOL(gui.train_income_warn,                    S,  0,  true,                        STR_CONFIG_PATCHES_WARN_INCOME_LESS,            NULL),
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1442
	  SDTC_VAR(gui.order_review_system,       SLE_UINT8, S, MS,     2,        0,        2, 0, STR_CONFIG_PATCHES_ORDER_REVIEW,                NULL),
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1443
	 SDTC_BOOL(gui.lost_train_warn,                      S,  0,  true,                        STR_CONFIG_PATCHES_WARN_LOST_TRAIN,             NULL),
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1444
	 SDTC_BOOL(gui.autorenew,                            S,  0, false,                        STR_CONFIG_PATCHES_AUTORENEW_VEHICLE,           EngineRenewUpdate),
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1445
	  SDTC_VAR(gui.autorenew_months,          SLE_INT16, S,  0,     6,      -12,       12, 0, STR_CONFIG_PATCHES_AUTORENEW_MONTHS,            EngineRenewMonthsUpdate),
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1446
	  SDTC_VAR(gui.autorenew_money,            SLE_UINT, S, CR,100000,        0,  2000000, 0, STR_CONFIG_PATCHES_AUTORENEW_MONEY,             EngineRenewMoneyUpdate),
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1447
	 SDTC_BOOL(gui.always_build_infrastructure,          S,  0, false,                        STR_CONFIG_PATCHES_ALWAYS_BUILD_INFRASTRUCTURE, RedrawScreen),
10095
e9b9244afcd7 (svn r14276) -Fix: Rename one of the advanced settings, as 'TTDPatch compatible nonstop handling' wasn't a correct description anymore.
frosch
parents: 10037
diff changeset
  1448
	 SDTC_BOOL(gui.new_nonstop,                          S,  0, false,                        STR_CONFIG_PATCHES_NONSTOP_BY_DEFAULT,          NULL),
9426
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1449
	 SDTC_BOOL(gui.keep_all_autosave,                    S,  0, false,                        STR_NULL,                                       NULL),
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1450
	 SDTC_BOOL(gui.autosave_on_exit,                     S,  0, false,                        STR_NULL,                                       NULL),
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1451
	  SDTC_VAR(gui.max_num_autosaves,         SLE_UINT8, S,  0,    16,        0,      255, 0, STR_NULL,                                       NULL),
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1452
	 SDTC_BOOL(gui.bridge_pillars,                       S,  0,  true,                        STR_NULL,                                       NULL),
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1453
	 SDTC_BOOL(gui.auto_euro,                            S,  0,  true,                        STR_NULL,                                       NULL),
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1454
	  SDTC_VAR(gui.news_message_timeout,      SLE_UINT8, S,  0,     2,        1,      255, 0, STR_NULL,                                       NULL),
9785
2005c34d0811 (svn r13927) -Add [YAPP]: Draw reserved tracks darker, toggeld by a patch setting. (michi_cc)
rubidium
parents: 9739
diff changeset
  1455
	 SDTC_BOOL(gui.show_track_reservation,               S,  0, false,                        STR_CONFIG_PATCHES_SHOW_TRACK_RESERVATION,      RedrawScreen),
9793
359d2460833b (svn r13935) -Codechange [YAPP]: PBS signals can now be built with the normal signal tools. (michi_cc)
rubidium
parents: 9785
diff changeset
  1456
	  SDTC_VAR(gui.default_signal_type,       SLE_UINT8, S, MS,     0,        0,        2, 1, STR_CONFIG_PATCHES_DEFAULT_SIGNAL_TYPE,         NULL),
359d2460833b (svn r13935) -Codechange [YAPP]: PBS signals can now be built with the normal signal tools. (michi_cc)
rubidium
parents: 9785
diff changeset
  1457
	  SDTC_VAR(gui.cycle_signal_types,        SLE_UINT8, S, MS,     0,        0,        2, 1, STR_CONFIG_PATCHES_CYCLE_SIGNAL_TYPES,          NULL),
9426
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1458
9906
9c0a829bf58e (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium
parents: 9902
diff changeset
  1459
	  SDTC_VAR(gui.console_backlog_timeout,  SLE_UINT16, S,  0,   100,       10,    65500, 0, STR_NULL,                                       NULL),
9c0a829bf58e (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium
parents: 9902
diff changeset
  1460
	  SDTC_VAR(gui.console_backlog_length,   SLE_UINT16, S,  0,   100,       10,    65500, 0, STR_NULL,                                       NULL),
9426
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1461
#ifdef ENABLE_NETWORK
9902
035856ac432b (svn r14052) -Codechange: make the size of the chat message "box" configurable and increase the default size slightly so it can hold the longest chat messages.
rubidium
parents: 9893
diff changeset
  1462
	  SDTC_VAR(gui.network_chat_box_width,   SLE_UINT16, S,  0,   700,      200,    65535, 0, STR_NULL,                                       NULL),
035856ac432b (svn r14052) -Codechange: make the size of the chat message "box" configurable and increase the default size slightly so it can hold the longest chat messages.
rubidium
parents: 9893
diff changeset
  1463
	  SDTC_VAR(gui.network_chat_box_height,   SLE_UINT8, S,  0,    25,        5,      255, 0, STR_NULL,                                       NULL),
035856ac432b (svn r14052) -Codechange: make the size of the chat message "box" configurable and increase the default size slightly so it can hold the longest chat messages.
rubidium
parents: 9893
diff changeset
  1464
9426
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1465
	  SDTC_VAR(network.sync_freq,            SLE_UINT16,C|S,NO,   100,        0,      100, 0, STR_NULL,                                       NULL),
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1466
	  SDTC_VAR(network.frame_freq,            SLE_UINT8,C|S,NO,     0,        0,      100, 0, STR_NULL,                                       NULL),
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1467
	  SDTC_VAR(network.max_join_time,        SLE_UINT16, S, NO,   500,        0,    32000, 0, STR_NULL,                                       NULL),
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1468
	 SDTC_BOOL(network.pause_on_join,                    S, NO,  true,                        STR_NULL,                                       NULL),
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1469
	  SDTC_STR(network.server_bind_ip,         SLE_STRB, S, NO, "0.0.0.0",                    STR_NULL,                                       NULL),
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1470
	  SDTC_VAR(network.server_port,          SLE_UINT16, S, NO,NETWORK_DEFAULT_PORT,0,65535,0,STR_NULL,                                       NULL),
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1471
	 SDTC_BOOL(network.server_advertise,                 S, NO, false,                        STR_NULL,                                       NULL),
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1472
	  SDTC_VAR(network.lan_internet,          SLE_UINT8, S, NO,     0,        0,        1, 0, STR_NULL,                                       NULL),
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10199
diff changeset
  1473
	  SDTC_STR(network.client_name,            SLE_STRB, S,  0,  NULL,                        STR_NULL,                                       UpdateClientName),
9426
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1474
	  SDTC_STR(network.server_password,        SLE_STRB, S, NO,  NULL,                        STR_NULL,                                       UpdateServerPassword),
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1475
	  SDTC_STR(network.rcon_password,          SLE_STRB, S, NO,  NULL,                        STR_NULL,                                       UpdateRconPassword),
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1476
	  SDTC_STR(network.default_company_pass,   SLE_STRB, S,  0,  NULL,                        STR_NULL,                                       NULL),
9451
0d6806ba5504 (svn r13369) -Codechange: remove duplication of network configuration settings between NetworkSettings and NetworkGameInfo.
rubidium
parents: 9447
diff changeset
  1477
	  SDTC_STR(network.server_name,            SLE_STRB, S, NO,  NULL,                        STR_NULL,                                       NULL),
9426
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1478
	  SDTC_STR(network.connect_to_ip,          SLE_STRB, S,  0,  NULL,                        STR_NULL,                                       NULL),
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1479
	  SDTC_STR(network.network_id,             SLE_STRB, S, NO,  NULL,                        STR_NULL,                                       NULL),
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1480
	 SDTC_BOOL(network.autoclean_companies,              S, NO, false,                        STR_NULL,                                       NULL),
9673
5814cb26cc6c (svn r13773) -Codechange: disable autoclean for protected/unprotected companies when the timeout is set to 0. Based on an idea by Thomas.
rubidium
parents: 9533
diff changeset
  1481
	  SDTC_VAR(network.autoclean_unprotected, SLE_UINT8, S,D0|NO,  12,     0,         240, 0, STR_NULL,                                       NULL),
5814cb26cc6c (svn r13773) -Codechange: disable autoclean for protected/unprotected companies when the timeout is set to 0. Based on an idea by Thomas.
rubidium
parents: 9533
diff changeset
  1482
	  SDTC_VAR(network.autoclean_protected,   SLE_UINT8, S,D0|NO,  36,     0,         240, 0, STR_NULL,                                       NULL),
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10199
diff changeset
  1483
	  SDTC_VAR(network.max_companies,         SLE_UINT8, S, NO,     8,     1,MAX_COMPANIES,0, STR_NULL,                                       NULL),
9426
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1484
	  SDTC_VAR(network.max_clients,           SLE_UINT8, S, NO,    10,     2, MAX_CLIENTS, 0, STR_NULL,                                       NULL),
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1485
	  SDTC_VAR(network.max_spectators,        SLE_UINT8, S, NO,    10,     0, MAX_CLIENTS, 0, STR_NULL,                                       NULL),
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1486
	  SDTC_VAR(network.restart_game_year,     SLE_INT32, S,D0|NO|NC,0, MIN_YEAR, MAX_YEAR, 1, STR_NULL,                                       NULL),
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10199
diff changeset
  1487
	  SDTC_VAR(network.min_active_clients,    SLE_UINT8, S, NO,     0,     0,        10,   0, STR_NULL,                                       UpdateMinActiveClients),
9426
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1488
	SDTC_OMANY(network.server_lang,           SLE_UINT8, S, NO,     0,    35, "ANY|ENGLISH|GERMAN|FRENCH|BRAZILIAN|BULGARIAN|CHINESE|CZECH|DANISH|DUTCH|ESPERANTO|FINNISH|HUNGARIAN|ICELANDIC|ITALIAN|JAPANESE|KOREAN|LITHUANIAN|NORWEGIAN|POLISH|PORTUGUESE|ROMANIAN|RUSSIAN|SLOVAK|SLOVENIAN|SPANISH|SWEDISH|TURKISH|UKRAINIAN|AFRIKAANS|CROATIAN|CATALAN|ESTONIAN|GALICIAN|GREEK|LATVIAN", STR_NULL, NULL),
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1489
	 SDTC_BOOL(network.reload_cfg,                       S, NO, false,                        STR_NULL,                                       NULL),
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1490
	  SDTC_STR(network.last_host,              SLE_STRB, S,  0, "0.0.0.0",                    STR_NULL,                                       NULL),
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1491
	  SDTC_VAR(network.last_port,            SLE_UINT16, S,  0,     0,     0,  UINT16_MAX, 0, STR_NULL,                                       NULL),
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1492
#endif /* ENABLE_NETWORK */
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4293
diff changeset
  1493
8129
e6732d9340e9 (svn r11690) -Fix: Since indices into the patch array is sent over the network having conditionally compiled entries in the table can cause desyncs. Moving them to the end will hide this issue, but it should really be solved in a better way.
egladil
parents: 8121
diff changeset
  1494
	/*
e6732d9340e9 (svn r11690) -Fix: Since indices into the patch array is sent over the network having conditionally compiled entries in the table can cause desyncs. Moving them to the end will hide this issue, but it should really be solved in a better way.
egladil
parents: 8121
diff changeset
  1495
	 * Since the network code (CmdChangePatchSetting and friends) use the index in this array to decide
e6732d9340e9 (svn r11690) -Fix: Since indices into the patch array is sent over the network having conditionally compiled entries in the table can cause desyncs. Moving them to the end will hide this issue, but it should really be solved in a better way.
egladil
parents: 8121
diff changeset
  1496
	 * which patch the server is talking about all conditional compilation of this array must be at the
e6732d9340e9 (svn r11690) -Fix: Since indices into the patch array is sent over the network having conditionally compiled entries in the table can cause desyncs. Moving them to the end will hide this issue, but it should really be solved in a better way.
egladil
parents: 8121
diff changeset
  1497
	 * end. This isn't really the best solution, the patches the server can tell the client about should
e6732d9340e9 (svn r11690) -Fix: Since indices into the patch array is sent over the network having conditionally compiled entries in the table can cause desyncs. Moving them to the end will hide this issue, but it should really be solved in a better way.
egladil
parents: 8121
diff changeset
  1498
	 * either use a seperate array or some other form of identifier.
e6732d9340e9 (svn r11690) -Fix: Since indices into the patch array is sent over the network having conditionally compiled entries in the table can cause desyncs. Moving them to the end will hide this issue, but it should really be solved in a better way.
egladil
parents: 8121
diff changeset
  1499
	 */
e6732d9340e9 (svn r11690) -Fix: Since indices into the patch array is sent over the network having conditionally compiled entries in the table can cause desyncs. Moving them to the end will hide this issue, but it should really be solved in a better way.
egladil
parents: 8121
diff changeset
  1500
e6732d9340e9 (svn r11690) -Fix: Since indices into the patch array is sent over the network having conditionally compiled entries in the table can cause desyncs. Moving them to the end will hide this issue, but it should really be solved in a better way.
egladil
parents: 8121
diff changeset
  1501
#ifdef __APPLE__
e6732d9340e9 (svn r11690) -Fix: Since indices into the patch array is sent over the network having conditionally compiled entries in the table can cause desyncs. Moving them to the end will hide this issue, but it should really be solved in a better way.
egladil
parents: 8121
diff changeset
  1502
	/* We might need to emulate a right mouse button on mac */
9413
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1503
	 SDTC_VAR(gui.right_mouse_btn_emulation, SLE_UINT8, S, MS, 0, 0, 2, 0, STR_CONFIG_PATCHES_RIGHT_MOUSE_BTN_EMU, NULL),
8129
e6732d9340e9 (svn r11690) -Fix: Since indices into the patch array is sent over the network having conditionally compiled entries in the table can cause desyncs. Moving them to the end will hide this issue, but it should really be solved in a better way.
egladil
parents: 8121
diff changeset
  1504
#endif
e6732d9340e9 (svn r11690) -Fix: Since indices into the patch array is sent over the network having conditionally compiled entries in the table can cause desyncs. Moving them to the end will hide this issue, but it should really be solved in a better way.
egladil
parents: 8121
diff changeset
  1505
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1506
	SDT_END()
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
  1507
};
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
  1508
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1509
static const SettingDesc _currency_settings[] = {
4431
7ecf73508c31 (svn r6186) -Fix [FS#309]: add an override system to the dynamically determined size of steps for numeric patch settings in the 'Configure patches' GUI.
rubidium
parents: 4419
diff changeset
  1510
	SDT_VAR(CurrencySpec, rate,    SLE_UINT16, S, 0,  1, 0, 100, 0, STR_NULL, NULL),
7ecf73508c31 (svn r6186) -Fix [FS#309]: add an override system to the dynamically determined size of steps for numeric patch settings in the 'Configure patches' GUI.
rubidium
parents: 4419
diff changeset
  1511
	SDT_CHR(CurrencySpec, separator,           S, 0,        ".",    STR_NULL, NULL),
6491
00dc414c909d (svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents: 6488
diff changeset
  1512
	SDT_VAR(CurrencySpec, to_euro,  SLE_INT32, S, 0,  0, 0, 3000, 0, STR_NULL, NULL),
4431
7ecf73508c31 (svn r6186) -Fix [FS#309]: add an override system to the dynamically determined size of steps for numeric patch settings in the 'Configure patches' GUI.
rubidium
parents: 4419
diff changeset
  1513
	SDT_STR(CurrencySpec, prefix,   SLE_STRBQ, S, 0,       NULL,    STR_NULL, NULL),
7ecf73508c31 (svn r6186) -Fix [FS#309]: add an override system to the dynamically determined size of steps for numeric patch settings in the 'Configure patches' GUI.
rubidium
parents: 4419
diff changeset
  1514
	SDT_STR(CurrencySpec, suffix,   SLE_STRBQ, S, 0, " credits",    STR_NULL, NULL),
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1515
	SDT_END()
759
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 738
diff changeset
  1516
};
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 738
diff changeset
  1517
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1518
/* Undefine for the shortcut macros above */
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1519
#undef S
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1520
#undef C
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1521
#undef N
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1522
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1523
#undef D0
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1524
#undef NC
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1525
#undef MS
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1526
#undef NO
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1527
#undef CR
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1528
9398
d60d75cb053d (svn r13309) -Fix: the difficulty settings from the savegame would be reset by the ones of the intro game.
rubidium
parents: 9373
diff changeset
  1529
/**
d60d75cb053d (svn r13309) -Fix: the difficulty settings from the savegame would be reset by the ones of the intro game.
rubidium
parents: 9373
diff changeset
  1530
 * Prepare for reading and old diff_custom by zero-ing the memory.
d60d75cb053d (svn r13309) -Fix: the difficulty settings from the savegame would be reset by the ones of the intro game.
rubidium
parents: 9373
diff changeset
  1531
 */
9359
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
  1532
static void PrepareOldDiffCustom()
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
  1533
{
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
  1534
	memset(_old_diff_custom, 0, sizeof(_old_diff_custom));
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
  1535
}
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
  1536
9398
d60d75cb053d (svn r13309) -Fix: the difficulty settings from the savegame would be reset by the ones of the intro game.
rubidium
parents: 9373
diff changeset
  1537
/**
d60d75cb053d (svn r13309) -Fix: the difficulty settings from the savegame would be reset by the ones of the intro game.
rubidium
parents: 9373
diff changeset
  1538
 * Reading of the old diff_custom array and transforming it to the new format.
d60d75cb053d (svn r13309) -Fix: the difficulty settings from the savegame would be reset by the ones of the intro game.
rubidium
parents: 9373
diff changeset
  1539
 * @param savegame is it read from the config or savegame. In the latter case
d60d75cb053d (svn r13309) -Fix: the difficulty settings from the savegame would be reset by the ones of the intro game.
rubidium
parents: 9373
diff changeset
  1540
 *                 we are sure there is an array; in the former case we have
d60d75cb053d (svn r13309) -Fix: the difficulty settings from the savegame would be reset by the ones of the intro game.
rubidium
parents: 9373
diff changeset
  1541
 *                 to check that.
d60d75cb053d (svn r13309) -Fix: the difficulty settings from the savegame would be reset by the ones of the intro game.
rubidium
parents: 9373
diff changeset
  1542
 */
d60d75cb053d (svn r13309) -Fix: the difficulty settings from the savegame would be reset by the ones of the intro game.
rubidium
parents: 9373
diff changeset
  1543
static void HandleOldDiffCustom(bool savegame)
9359
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
  1544
{
9398
d60d75cb053d (svn r13309) -Fix: the difficulty settings from the savegame would be reset by the ones of the intro game.
rubidium
parents: 9373
diff changeset
  1545
	uint options_to_load = GAME_DIFFICULTY_NUM - ((savegame && CheckSavegameVersion(4)) ? 1 : 0);
9359
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
  1546
9398
d60d75cb053d (svn r13309) -Fix: the difficulty settings from the savegame would be reset by the ones of the intro game.
rubidium
parents: 9373
diff changeset
  1547
	if (!savegame) {
d60d75cb053d (svn r13309) -Fix: the difficulty settings from the savegame would be reset by the ones of the intro game.
rubidium
parents: 9373
diff changeset
  1548
		/* If we did read to old_diff_custom, then at least one value must be non 0. */
d60d75cb053d (svn r13309) -Fix: the difficulty settings from the savegame would be reset by the ones of the intro game.
rubidium
parents: 9373
diff changeset
  1549
		bool old_diff_custom_used = false;
d60d75cb053d (svn r13309) -Fix: the difficulty settings from the savegame would be reset by the ones of the intro game.
rubidium
parents: 9373
diff changeset
  1550
		for (uint i = 0; i < options_to_load && !old_diff_custom_used; i++) {
d60d75cb053d (svn r13309) -Fix: the difficulty settings from the savegame would be reset by the ones of the intro game.
rubidium
parents: 9373
diff changeset
  1551
			old_diff_custom_used = (_old_diff_custom[i] != 0);
d60d75cb053d (svn r13309) -Fix: the difficulty settings from the savegame would be reset by the ones of the intro game.
rubidium
parents: 9373
diff changeset
  1552
		}
d60d75cb053d (svn r13309) -Fix: the difficulty settings from the savegame would be reset by the ones of the intro game.
rubidium
parents: 9373
diff changeset
  1553
d60d75cb053d (svn r13309) -Fix: the difficulty settings from the savegame would be reset by the ones of the intro game.
rubidium
parents: 9373
diff changeset
  1554
		if (!old_diff_custom_used) return;
9359
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
  1555
	}
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
  1556
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
  1557
	for (uint i = 0; i < options_to_load; i++) {
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
  1558
		const SettingDesc *sd = &_patch_settings[i];
9413
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1559
		void *var = GetVariableAddress(savegame ? &_settings_game : &_settings_newgame, &sd->save);
9359
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
  1560
		Write_ValidateSetting(var, sd, (int32)((i == 4 ? 1000 : 1) * _old_diff_custom[i]));
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
  1561
	}
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
  1562
}
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
  1563
9739
9cf125da8789 (svn r13872) -Feature: Split the news message announcing opening and closure of industries into two news of their own
belugas
parents: 9704
diff changeset
  1564
/** tries to convert newly introduced news settings based on old ones
9cf125da8789 (svn r13872) -Feature: Split the news message announcing opening and closure of industries into two news of their own
belugas
parents: 9704
diff changeset
  1565
 * @param name pointer to the string defining name of the old news config
9cf125da8789 (svn r13872) -Feature: Split the news message announcing opening and closure of industries into two news of their own
belugas
parents: 9704
diff changeset
  1566
 * @param value pointer to the string defining value of the old news config
9cf125da8789 (svn r13872) -Feature: Split the news message announcing opening and closure of industries into two news of their own
belugas
parents: 9704
diff changeset
  1567
 * @returns true if conversion could have been made */
9cf125da8789 (svn r13872) -Feature: Split the news message announcing opening and closure of industries into two news of their own
belugas
parents: 9704
diff changeset
  1568
bool ConvertOldNewsSetting(const char *name, const char *value)
9cf125da8789 (svn r13872) -Feature: Split the news message announcing opening and closure of industries into two news of their own
belugas
parents: 9704
diff changeset
  1569
{
9cf125da8789 (svn r13872) -Feature: Split the news message announcing opening and closure of industries into two news of their own
belugas
parents: 9704
diff changeset
  1570
	if (strcasecmp(name, "openclose") == 0) {
9cf125da8789 (svn r13872) -Feature: Split the news message announcing opening and closure of industries into two news of their own
belugas
parents: 9704
diff changeset
  1571
		/* openclose has been split in "open" and "close".
9cf125da8789 (svn r13872) -Feature: Split the news message announcing opening and closure of industries into two news of their own
belugas
parents: 9704
diff changeset
  1572
		 * So the job is now to decrypt the value of the old news config
9cf125da8789 (svn r13872) -Feature: Split the news message announcing opening and closure of industries into two news of their own
belugas
parents: 9704
diff changeset
  1573
		 * and give it to the two newly introduced ones*/
9cf125da8789 (svn r13872) -Feature: Split the news message announcing opening and closure of industries into two news of their own
belugas
parents: 9704
diff changeset
  1574
9cf125da8789 (svn r13872) -Feature: Split the news message announcing opening and closure of industries into two news of their own
belugas
parents: 9704
diff changeset
  1575
		NewsDisplay display = ND_OFF;  //default
9cf125da8789 (svn r13872) -Feature: Split the news message announcing opening and closure of industries into two news of their own
belugas
parents: 9704
diff changeset
  1576
		if (strcasecmp(value, "full") == 0) {
9cf125da8789 (svn r13872) -Feature: Split the news message announcing opening and closure of industries into two news of their own
belugas
parents: 9704
diff changeset
  1577
			display = ND_FULL;
9cf125da8789 (svn r13872) -Feature: Split the news message announcing opening and closure of industries into two news of their own
belugas
parents: 9704
diff changeset
  1578
		} else if (strcasecmp(value, "summarized") == 0) {
9cf125da8789 (svn r13872) -Feature: Split the news message announcing opening and closure of industries into two news of their own
belugas
parents: 9704
diff changeset
  1579
			display = ND_SUMMARY;
9cf125da8789 (svn r13872) -Feature: Split the news message announcing opening and closure of industries into two news of their own
belugas
parents: 9704
diff changeset
  1580
		}
9cf125da8789 (svn r13872) -Feature: Split the news message announcing opening and closure of industries into two news of their own
belugas
parents: 9704
diff changeset
  1581
		/* tranfert of values */
9cf125da8789 (svn r13872) -Feature: Split the news message announcing opening and closure of industries into two news of their own
belugas
parents: 9704
diff changeset
  1582
		_news_type_data[NT_INDUSTRY_OPEN].display = display;
9cf125da8789 (svn r13872) -Feature: Split the news message announcing opening and closure of industries into two news of their own
belugas
parents: 9704
diff changeset
  1583
		_news_type_data[NT_INDUSTRY_CLOSE].display = display;
9cf125da8789 (svn r13872) -Feature: Split the news message announcing opening and closure of industries into two news of their own
belugas
parents: 9704
diff changeset
  1584
		return true;
9cf125da8789 (svn r13872) -Feature: Split the news message announcing opening and closure of industries into two news of their own
belugas
parents: 9704
diff changeset
  1585
	}
9cf125da8789 (svn r13872) -Feature: Split the news message announcing opening and closure of industries into two news of their own
belugas
parents: 9704
diff changeset
  1586
	return false;
9cf125da8789 (svn r13872) -Feature: Split the news message announcing opening and closure of industries into two news of their own
belugas
parents: 9704
diff changeset
  1587
}
9359
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
  1588
9010
fa1aa6008a59 (svn r12805) -Codechange: remove some bit magic related to the news display states. Patch by cirdan.
rubidium
parents: 8990
diff changeset
  1589
static void NewsDisplayLoadConfig(IniFile *ini, const char *grpname)
6283
f9d97d412b0f (svn r9097) -Fix [FS#525]: open and close messages now have their own setting, so you can hide economy changes, but do show open/close of industries
truelight
parents: 6248
diff changeset
  1590
{
9996
fceaf224b2f0 (svn r14153) -Codechange: split ini file reading/saving from settings.cpp.
rubidium
parents: 9906
diff changeset
  1591
	IniGroup *group = ini->GetGroup(grpname);
6283
f9d97d412b0f (svn r9097) -Fix [FS#525]: open and close messages now have their own setting, so you can hide economy changes, but do show open/close of industries
truelight
parents: 6248
diff changeset
  1592
	IniItem *item;
f9d97d412b0f (svn r9097) -Fix [FS#525]: open and close messages now have their own setting, so you can hide economy changes, but do show open/close of industries
truelight
parents: 6248
diff changeset
  1593
9010
fa1aa6008a59 (svn r12805) -Codechange: remove some bit magic related to the news display states. Patch by cirdan.
rubidium
parents: 8990
diff changeset
  1594
	/* If no group exists, return */
fa1aa6008a59 (svn r12805) -Codechange: remove some bit magic related to the news display states. Patch by cirdan.
rubidium
parents: 8990
diff changeset
  1595
	if (group == NULL) return;
6283
f9d97d412b0f (svn r9097) -Fix [FS#525]: open and close messages now have their own setting, so you can hide economy changes, but do show open/close of industries
truelight
parents: 6248
diff changeset
  1596
f9d97d412b0f (svn r9097) -Fix [FS#525]: open and close messages now have their own setting, so you can hide economy changes, but do show open/close of industries
truelight
parents: 6248
diff changeset
  1597
	for (item = group->item; item != NULL; item = item->next) {
f9d97d412b0f (svn r9097) -Fix [FS#525]: open and close messages now have their own setting, so you can hide economy changes, but do show open/close of industries
truelight
parents: 6248
diff changeset
  1598
		int news_item = -1;
f9d97d412b0f (svn r9097) -Fix [FS#525]: open and close messages now have their own setting, so you can hide economy changes, but do show open/close of industries
truelight
parents: 6248
diff changeset
  1599
		for (int i = 0; i < NT_END; i++) {
8990
0d5bb1c2a4a6 (svn r12785) -Codechange: put all news-type related constants in the same array. Patch by cirdan.
rubidium
parents: 8969
diff changeset
  1600
			if (strcasecmp(item->name, _news_type_data[i].name) == 0) {
6283
f9d97d412b0f (svn r9097) -Fix [FS#525]: open and close messages now have their own setting, so you can hide economy changes, but do show open/close of industries
truelight
parents: 6248
diff changeset
  1601
				news_item = i;
f9d97d412b0f (svn r9097) -Fix [FS#525]: open and close messages now have their own setting, so you can hide economy changes, but do show open/close of industries
truelight
parents: 6248
diff changeset
  1602
				break;
f9d97d412b0f (svn r9097) -Fix [FS#525]: open and close messages now have their own setting, so you can hide economy changes, but do show open/close of industries
truelight
parents: 6248
diff changeset
  1603
			}
f9d97d412b0f (svn r9097) -Fix [FS#525]: open and close messages now have their own setting, so you can hide economy changes, but do show open/close of industries
truelight
parents: 6248
diff changeset
  1604
		}
9739
9cf125da8789 (svn r13872) -Feature: Split the news message announcing opening and closure of industries into two news of their own
belugas
parents: 9704
diff changeset
  1605
9cf125da8789 (svn r13872) -Feature: Split the news message announcing opening and closure of industries into two news of their own
belugas
parents: 9704
diff changeset
  1606
		/* the config been read is not within current aceptable config */
6283
f9d97d412b0f (svn r9097) -Fix [FS#525]: open and close messages now have their own setting, so you can hide economy changes, but do show open/close of industries
truelight
parents: 6248
diff changeset
  1607
		if (news_item == -1) {
9739
9cf125da8789 (svn r13872) -Feature: Split the news message announcing opening and closure of industries into two news of their own
belugas
parents: 9704
diff changeset
  1608
			/* if the conversion function cannot process it, advice by a debug warning*/
9cf125da8789 (svn r13872) -Feature: Split the news message announcing opening and closure of industries into two news of their own
belugas
parents: 9704
diff changeset
  1609
			if (!ConvertOldNewsSetting(item->name, item->value)) {
9cf125da8789 (svn r13872) -Feature: Split the news message announcing opening and closure of industries into two news of their own
belugas
parents: 9704
diff changeset
  1610
				DEBUG(misc, 0, "Invalid display option: %s", item->name);
9cf125da8789 (svn r13872) -Feature: Split the news message announcing opening and closure of industries into two news of their own
belugas
parents: 9704
diff changeset
  1611
			}
9cf125da8789 (svn r13872) -Feature: Split the news message announcing opening and closure of industries into two news of their own
belugas
parents: 9704
diff changeset
  1612
			/* in all cases, there is nothing left to do */
6283
f9d97d412b0f (svn r9097) -Fix [FS#525]: open and close messages now have their own setting, so you can hide economy changes, but do show open/close of industries
truelight
parents: 6248
diff changeset
  1613
			continue;
f9d97d412b0f (svn r9097) -Fix [FS#525]: open and close messages now have their own setting, so you can hide economy changes, but do show open/close of industries
truelight
parents: 6248
diff changeset
  1614
		}
f9d97d412b0f (svn r9097) -Fix [FS#525]: open and close messages now have their own setting, so you can hide economy changes, but do show open/close of industries
truelight
parents: 6248
diff changeset
  1615
f9d97d412b0f (svn r9097) -Fix [FS#525]: open and close messages now have their own setting, so you can hide economy changes, but do show open/close of industries
truelight
parents: 6248
diff changeset
  1616
		if (strcasecmp(item->value, "full") == 0) {
9010
fa1aa6008a59 (svn r12805) -Codechange: remove some bit magic related to the news display states. Patch by cirdan.
rubidium
parents: 8990
diff changeset
  1617
			_news_type_data[news_item].display = ND_FULL;
6283
f9d97d412b0f (svn r9097) -Fix [FS#525]: open and close messages now have their own setting, so you can hide economy changes, but do show open/close of industries
truelight
parents: 6248
diff changeset
  1618
		} else if (strcasecmp(item->value, "off") == 0) {
9010
fa1aa6008a59 (svn r12805) -Codechange: remove some bit magic related to the news display states. Patch by cirdan.
rubidium
parents: 8990
diff changeset
  1619
			_news_type_data[news_item].display = ND_OFF;
6283
f9d97d412b0f (svn r9097) -Fix [FS#525]: open and close messages now have their own setting, so you can hide economy changes, but do show open/close of industries
truelight
parents: 6248
diff changeset
  1620
		} else if (strcasecmp(item->value, "summarized") == 0) {
9010
fa1aa6008a59 (svn r12805) -Codechange: remove some bit magic related to the news display states. Patch by cirdan.
rubidium
parents: 8990
diff changeset
  1621
			_news_type_data[news_item].display = ND_SUMMARY;
6283
f9d97d412b0f (svn r9097) -Fix [FS#525]: open and close messages now have their own setting, so you can hide economy changes, but do show open/close of industries
truelight
parents: 6248
diff changeset
  1622
		} else {
f9d97d412b0f (svn r9097) -Fix [FS#525]: open and close messages now have their own setting, so you can hide economy changes, but do show open/close of industries
truelight
parents: 6248
diff changeset
  1623
			DEBUG(misc, 0, "Invalid display value: %s", item->value);
f9d97d412b0f (svn r9097) -Fix [FS#525]: open and close messages now have their own setting, so you can hide economy changes, but do show open/close of industries
truelight
parents: 6248
diff changeset
  1624
			continue;
f9d97d412b0f (svn r9097) -Fix [FS#525]: open and close messages now have their own setting, so you can hide economy changes, but do show open/close of industries
truelight
parents: 6248
diff changeset
  1625
		}
f9d97d412b0f (svn r9097) -Fix [FS#525]: open and close messages now have their own setting, so you can hide economy changes, but do show open/close of industries
truelight
parents: 6248
diff changeset
  1626
	}
f9d97d412b0f (svn r9097) -Fix [FS#525]: open and close messages now have their own setting, so you can hide economy changes, but do show open/close of industries
truelight
parents: 6248
diff changeset
  1627
}
3628
69646d0924a5 (svn r4527) - Feature [NewGRF]: Add support for specifying parameters to GRF files. Usage: "mygrf = 1". You can pass up to 128 parameters, each one seperated by a comma or a space-character. Big thanks to peter1138 for the inspiration and examples.
Darkvater
parents: 3615
diff changeset
  1628
5329
9c5e8061ea0f (svn r7490) -Feature: Load a list of NewGRFs from the config (in the [newgrf-static] section) that should always be loaded. These will also be active during the intro screen, and in multiplayer games. Only "network-safe" NewGRFs are permitted, such as fonts and sprite replacement sets.
peter1138
parents: 5309
diff changeset
  1629
/* Load a GRF configuration from the given group name */
9c5e8061ea0f (svn r7490) -Feature: Load a list of NewGRFs from the config (in the [newgrf-static] section) that should always be loaded. These will also be active during the intro screen, and in multiplayer games. Only "network-safe" NewGRFs are permitted, such as fonts and sprite replacement sets.
peter1138
parents: 5309
diff changeset
  1630
static GRFConfig *GRFLoadConfig(IniFile *ini, const char *grpname, bool is_static)
9c5e8061ea0f (svn r7490) -Feature: Load a list of NewGRFs from the config (in the [newgrf-static] section) that should always be loaded. These will also be active during the intro screen, and in multiplayer games. Only "network-safe" NewGRFs are permitted, such as fonts and sprite replacement sets.
peter1138
parents: 5309
diff changeset
  1631
{
9996
fceaf224b2f0 (svn r14153) -Codechange: split ini file reading/saving from settings.cpp.
rubidium
parents: 9906
diff changeset
  1632
	IniGroup *group = ini->GetGroup(grpname);
5329
9c5e8061ea0f (svn r7490) -Feature: Load a list of NewGRFs from the config (in the [newgrf-static] section) that should always be loaded. These will also be active during the intro screen, and in multiplayer games. Only "network-safe" NewGRFs are permitted, such as fonts and sprite replacement sets.
peter1138
parents: 5309
diff changeset
  1633
	IniItem *item;
9c5e8061ea0f (svn r7490) -Feature: Load a list of NewGRFs from the config (in the [newgrf-static] section) that should always be loaded. These will also be active during the intro screen, and in multiplayer games. Only "network-safe" NewGRFs are permitted, such as fonts and sprite replacement sets.
peter1138
parents: 5309
diff changeset
  1634
	GRFConfig *first = NULL;
9c5e8061ea0f (svn r7490) -Feature: Load a list of NewGRFs from the config (in the [newgrf-static] section) that should always be loaded. These will also be active during the intro screen, and in multiplayer games. Only "network-safe" NewGRFs are permitted, such as fonts and sprite replacement sets.
peter1138
parents: 5309
diff changeset
  1635
	GRFConfig **curr = &first;
3628
69646d0924a5 (svn r4527) - Feature [NewGRF]: Add support for specifying parameters to GRF files. Usage: "mygrf = 1". You can pass up to 128 parameters, each one seperated by a comma or a space-character. Big thanks to peter1138 for the inspiration and examples.
Darkvater
parents: 3615
diff changeset
  1636
5329
9c5e8061ea0f (svn r7490) -Feature: Load a list of NewGRFs from the config (in the [newgrf-static] section) that should always be loaded. These will also be active during the intro screen, and in multiplayer games. Only "network-safe" NewGRFs are permitted, such as fonts and sprite replacement sets.
peter1138
parents: 5309
diff changeset
  1637
	if (group == NULL) return NULL;
9c5e8061ea0f (svn r7490) -Feature: Load a list of NewGRFs from the config (in the [newgrf-static] section) that should always be loaded. These will also be active during the intro screen, and in multiplayer games. Only "network-safe" NewGRFs are permitted, such as fonts and sprite replacement sets.
peter1138
parents: 5309
diff changeset
  1638
9c5e8061ea0f (svn r7490) -Feature: Load a list of NewGRFs from the config (in the [newgrf-static] section) that should always be loaded. These will also be active during the intro screen, and in multiplayer games. Only "network-safe" NewGRFs are permitted, such as fonts and sprite replacement sets.
peter1138
parents: 5309
diff changeset
  1639
	for (item = group->item; item != NULL; item = item->next) {
5609
dc6a58930ba4 (svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents: 5601
diff changeset
  1640
		GRFConfig *c = CallocT<GRFConfig>(1);
7034
e2d80a01d9c1 (svn r10298) -Fix [FS#903]: show the subdirectory below the default data directory in this filename in the newgrf list. The directory was removed in r9560 because then it used to full path instead of the path relative to the data directory, but since the inclusion of "search paths" that is not necessary anymore.
rubidium
parents: 6998
diff changeset
  1641
		c->filename = strdup(item->name);
5329
9c5e8061ea0f (svn r7490) -Feature: Load a list of NewGRFs from the config (in the [newgrf-static] section) that should always be loaded. These will also be active during the intro screen, and in multiplayer games. Only "network-safe" NewGRFs are permitted, such as fonts and sprite replacement sets.
peter1138
parents: 5309
diff changeset
  1642
9c5e8061ea0f (svn r7490) -Feature: Load a list of NewGRFs from the config (in the [newgrf-static] section) that should always be loaded. These will also be active during the intro screen, and in multiplayer games. Only "network-safe" NewGRFs are permitted, such as fonts and sprite replacement sets.
peter1138
parents: 5309
diff changeset
  1643
		/* Parse parameters */
9996
fceaf224b2f0 (svn r14153) -Codechange: split ini file reading/saving from settings.cpp.
rubidium
parents: 9906
diff changeset
  1644
		if (!StrEmpty(item->value)) {
5329
9c5e8061ea0f (svn r7490) -Feature: Load a list of NewGRFs from the config (in the [newgrf-static] section) that should always be loaded. These will also be active during the intro screen, and in multiplayer games. Only "network-safe" NewGRFs are permitted, such as fonts and sprite replacement sets.
peter1138
parents: 5309
diff changeset
  1645
			c->num_params = parse_intlist(item->value, (int*)c->param, lengthof(c->param));
9c5e8061ea0f (svn r7490) -Feature: Load a list of NewGRFs from the config (in the [newgrf-static] section) that should always be loaded. These will also be active during the intro screen, and in multiplayer games. Only "network-safe" NewGRFs are permitted, such as fonts and sprite replacement sets.
peter1138
parents: 5309
diff changeset
  1646
			if (c->num_params == (byte)-1) {
9c5e8061ea0f (svn r7490) -Feature: Load a list of NewGRFs from the config (in the [newgrf-static] section) that should always be loaded. These will also be active during the intro screen, and in multiplayer games. Only "network-safe" NewGRFs are permitted, such as fonts and sprite replacement sets.
peter1138
parents: 5309
diff changeset
  1647
				ShowInfoF("ini: error in array '%s'", item->name);
9c5e8061ea0f (svn r7490) -Feature: Load a list of NewGRFs from the config (in the [newgrf-static] section) that should always be loaded. These will also be active during the intro screen, and in multiplayer games. Only "network-safe" NewGRFs are permitted, such as fonts and sprite replacement sets.
peter1138
parents: 5309
diff changeset
  1648
				c->num_params = 0;
9c5e8061ea0f (svn r7490) -Feature: Load a list of NewGRFs from the config (in the [newgrf-static] section) that should always be loaded. These will also be active during the intro screen, and in multiplayer games. Only "network-safe" NewGRFs are permitted, such as fonts and sprite replacement sets.
peter1138
parents: 5309
diff changeset
  1649
			}
9c5e8061ea0f (svn r7490) -Feature: Load a list of NewGRFs from the config (in the [newgrf-static] section) that should always be loaded. These will also be active during the intro screen, and in multiplayer games. Only "network-safe" NewGRFs are permitted, such as fonts and sprite replacement sets.
peter1138
parents: 5309
diff changeset
  1650
		}
9c5e8061ea0f (svn r7490) -Feature: Load a list of NewGRFs from the config (in the [newgrf-static] section) that should always be loaded. These will also be active during the intro screen, and in multiplayer games. Only "network-safe" NewGRFs are permitted, such as fonts and sprite replacement sets.
peter1138
parents: 5309
diff changeset
  1651
9c5e8061ea0f (svn r7490) -Feature: Load a list of NewGRFs from the config (in the [newgrf-static] section) that should always be loaded. These will also be active during the intro screen, and in multiplayer games. Only "network-safe" NewGRFs are permitted, such as fonts and sprite replacement sets.
peter1138
parents: 5309
diff changeset
  1652
		/* Check if item is valid */
9c5e8061ea0f (svn r7490) -Feature: Load a list of NewGRFs from the config (in the [newgrf-static] section) that should always be loaded. These will also be active during the intro screen, and in multiplayer games. Only "network-safe" NewGRFs are permitted, such as fonts and sprite replacement sets.
peter1138
parents: 5309
diff changeset
  1653
		if (!FillGRFDetails(c, is_static)) {
9c5e8061ea0f (svn r7490) -Feature: Load a list of NewGRFs from the config (in the [newgrf-static] section) that should always be loaded. These will also be active during the intro screen, and in multiplayer games. Only "network-safe" NewGRFs are permitted, such as fonts and sprite replacement sets.
peter1138
parents: 5309
diff changeset
  1654
			const char *msg;
9c5e8061ea0f (svn r7490) -Feature: Load a list of NewGRFs from the config (in the [newgrf-static] section) that should always be loaded. These will also be active during the intro screen, and in multiplayer games. Only "network-safe" NewGRFs are permitted, such as fonts and sprite replacement sets.
peter1138
parents: 5309
diff changeset
  1655
6229
695400602ab0 (svn r9031) -Codechange: Introduce grfconfig->status, and use it for states that are
maedhros
parents: 6012
diff changeset
  1656
			if (c->status == GCS_NOT_FOUND) {
5329
9c5e8061ea0f (svn r7490) -Feature: Load a list of NewGRFs from the config (in the [newgrf-static] section) that should always be loaded. These will also be active during the intro screen, and in multiplayer games. Only "network-safe" NewGRFs are permitted, such as fonts and sprite replacement sets.
peter1138
parents: 5309
diff changeset
  1657
				msg = "not found";
7928
63e18de69e50 (svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents: 7927
diff changeset
  1658
			} else if (HasBit(c->flags, GCF_UNSAFE)) {
5329
9c5e8061ea0f (svn r7490) -Feature: Load a list of NewGRFs from the config (in the [newgrf-static] section) that should always be loaded. These will also be active during the intro screen, and in multiplayer games. Only "network-safe" NewGRFs are permitted, such as fonts and sprite replacement sets.
peter1138
parents: 5309
diff changeset
  1659
				msg = "unsafe for static use";
7928
63e18de69e50 (svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents: 7927
diff changeset
  1660
			} else if (HasBit(c->flags, GCF_SYSTEM)) {
5329
9c5e8061ea0f (svn r7490) -Feature: Load a list of NewGRFs from the config (in the [newgrf-static] section) that should always be loaded. These will also be active during the intro screen, and in multiplayer games. Only "network-safe" NewGRFs are permitted, such as fonts and sprite replacement sets.
peter1138
parents: 5309
diff changeset
  1661
				msg = "system NewGRF";
9c5e8061ea0f (svn r7490) -Feature: Load a list of NewGRFs from the config (in the [newgrf-static] section) that should always be loaded. These will also be active during the intro screen, and in multiplayer games. Only "network-safe" NewGRFs are permitted, such as fonts and sprite replacement sets.
peter1138
parents: 5309
diff changeset
  1662
			} else {
9c5e8061ea0f (svn r7490) -Feature: Load a list of NewGRFs from the config (in the [newgrf-static] section) that should always be loaded. These will also be active during the intro screen, and in multiplayer games. Only "network-safe" NewGRFs are permitted, such as fonts and sprite replacement sets.
peter1138
parents: 5309
diff changeset
  1663
				msg = "unknown";
9c5e8061ea0f (svn r7490) -Feature: Load a list of NewGRFs from the config (in the [newgrf-static] section) that should always be loaded. These will also be active during the intro screen, and in multiplayer games. Only "network-safe" NewGRFs are permitted, such as fonts and sprite replacement sets.
peter1138
parents: 5309
diff changeset
  1664
			}
9c5e8061ea0f (svn r7490) -Feature: Load a list of NewGRFs from the config (in the [newgrf-static] section) that should always be loaded. These will also be active during the intro screen, and in multiplayer games. Only "network-safe" NewGRFs are permitted, such as fonts and sprite replacement sets.
peter1138
parents: 5309
diff changeset
  1665
9c5e8061ea0f (svn r7490) -Feature: Load a list of NewGRFs from the config (in the [newgrf-static] section) that should always be loaded. These will also be active during the intro screen, and in multiplayer games. Only "network-safe" NewGRFs are permitted, such as fonts and sprite replacement sets.
peter1138
parents: 5309
diff changeset
  1666
			ShowInfoF("ini: ignoring invalid NewGRF '%s': %s", item->name, msg);
5346
3687c73bc65b (svn r7517) -Codechange: Set pointers to NULL when freeing the newgrf config variables and add the proper const to CopyGRFConfigList
Darkvater
parents: 5329
diff changeset
  1667
			ClearGRFConfig(&c);
5329
9c5e8061ea0f (svn r7490) -Feature: Load a list of NewGRFs from the config (in the [newgrf-static] section) that should always be loaded. These will also be active during the intro screen, and in multiplayer games. Only "network-safe" NewGRFs are permitted, such as fonts and sprite replacement sets.
peter1138
parents: 5309
diff changeset
  1668
			continue;
9c5e8061ea0f (svn r7490) -Feature: Load a list of NewGRFs from the config (in the [newgrf-static] section) that should always be loaded. These will also be active during the intro screen, and in multiplayer games. Only "network-safe" NewGRFs are permitted, such as fonts and sprite replacement sets.
peter1138
parents: 5309
diff changeset
  1669
		}
9c5e8061ea0f (svn r7490) -Feature: Load a list of NewGRFs from the config (in the [newgrf-static] section) that should always be loaded. These will also be active during the intro screen, and in multiplayer games. Only "network-safe" NewGRFs are permitted, such as fonts and sprite replacement sets.
peter1138
parents: 5309
diff changeset
  1670
9c5e8061ea0f (svn r7490) -Feature: Load a list of NewGRFs from the config (in the [newgrf-static] section) that should always be loaded. These will also be active during the intro screen, and in multiplayer games. Only "network-safe" NewGRFs are permitted, such as fonts and sprite replacement sets.
peter1138
parents: 5309
diff changeset
  1671
		/* Mark file as static to avoid saving in savegame. */
7931
b0a46cd92225 (svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13
parents: 7928
diff changeset
  1672
		if (is_static) SetBit(c->flags, GCF_STATIC);
5329
9c5e8061ea0f (svn r7490) -Feature: Load a list of NewGRFs from the config (in the [newgrf-static] section) that should always be loaded. These will also be active during the intro screen, and in multiplayer games. Only "network-safe" NewGRFs are permitted, such as fonts and sprite replacement sets.
peter1138
parents: 5309
diff changeset
  1673
9c5e8061ea0f (svn r7490) -Feature: Load a list of NewGRFs from the config (in the [newgrf-static] section) that should always be loaded. These will also be active during the intro screen, and in multiplayer games. Only "network-safe" NewGRFs are permitted, such as fonts and sprite replacement sets.
peter1138
parents: 5309
diff changeset
  1674
		/* Add item to list */
9c5e8061ea0f (svn r7490) -Feature: Load a list of NewGRFs from the config (in the [newgrf-static] section) that should always be loaded. These will also be active during the intro screen, and in multiplayer games. Only "network-safe" NewGRFs are permitted, such as fonts and sprite replacement sets.
peter1138
parents: 5309
diff changeset
  1675
		*curr = c;
9c5e8061ea0f (svn r7490) -Feature: Load a list of NewGRFs from the config (in the [newgrf-static] section) that should always be loaded. These will also be active during the intro screen, and in multiplayer games. Only "network-safe" NewGRFs are permitted, such as fonts and sprite replacement sets.
peter1138
parents: 5309
diff changeset
  1676
		curr = &c->next;
5307
1d3295f87e8d (svn r7463) -Codechange: Don't load invalid NewGRF files from the configuration file; instead show a warning.
peter1138
parents: 5228
diff changeset
  1677
	}
3631
c6a094f0c14e (svn r4530) - Fix [NewGRF]: don't spew a warning when a grf file has no parameters.
Darkvater
parents: 3628
diff changeset
  1678
5329
9c5e8061ea0f (svn r7490) -Feature: Load a list of NewGRFs from the config (in the [newgrf-static] section) that should always be loaded. These will also be active during the intro screen, and in multiplayer games. Only "network-safe" NewGRFs are permitted, such as fonts and sprite replacement sets.
peter1138
parents: 5309
diff changeset
  1679
	return first;
3628
69646d0924a5 (svn r4527) - Feature [NewGRF]: Add support for specifying parameters to GRF files. Usage: "mygrf = 1". You can pass up to 128 parameters, each one seperated by a comma or a space-character. Big thanks to peter1138 for the inspiration and examples.
Darkvater
parents: 3615
diff changeset
  1680
}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1681
9010
fa1aa6008a59 (svn r12805) -Codechange: remove some bit magic related to the news display states. Patch by cirdan.
rubidium
parents: 8990
diff changeset
  1682
static void NewsDisplaySaveConfig(IniFile *ini, const char *grpname)
6283
f9d97d412b0f (svn r9097) -Fix [FS#525]: open and close messages now have their own setting, so you can hide economy changes, but do show open/close of industries
truelight
parents: 6248
diff changeset
  1683
{
9996
fceaf224b2f0 (svn r14153) -Codechange: split ini file reading/saving from settings.cpp.
rubidium
parents: 9906
diff changeset
  1684
	IniGroup *group = ini->GetGroup(grpname);
6283
f9d97d412b0f (svn r9097) -Fix [FS#525]: open and close messages now have their own setting, so you can hide economy changes, but do show open/close of industries
truelight
parents: 6248
diff changeset
  1685
f9d97d412b0f (svn r9097) -Fix [FS#525]: open and close messages now have their own setting, so you can hide economy changes, but do show open/close of industries
truelight
parents: 6248
diff changeset
  1686
	for (int i = 0; i < NT_END; i++) {
f9d97d412b0f (svn r9097) -Fix [FS#525]: open and close messages now have their own setting, so you can hide economy changes, but do show open/close of industries
truelight
parents: 6248
diff changeset
  1687
		const char *value;
9010
fa1aa6008a59 (svn r12805) -Codechange: remove some bit magic related to the news display states. Patch by cirdan.
rubidium
parents: 8990
diff changeset
  1688
		int v = _news_type_data[i].display;
6283
f9d97d412b0f (svn r9097) -Fix [FS#525]: open and close messages now have their own setting, so you can hide economy changes, but do show open/close of industries
truelight
parents: 6248
diff changeset
  1689
9010
fa1aa6008a59 (svn r12805) -Codechange: remove some bit magic related to the news display states. Patch by cirdan.
rubidium
parents: 8990
diff changeset
  1690
		value = (v == ND_OFF ? "off" : (v == ND_SUMMARY ? "summarized" : "full"));
6283
f9d97d412b0f (svn r9097) -Fix [FS#525]: open and close messages now have their own setting, so you can hide economy changes, but do show open/close of industries
truelight
parents: 6248
diff changeset
  1691
10008
fca6f9cf02ac (svn r14167) -Fix: items in some ini-groups got duplicated on save.
rubidium
parents: 10005
diff changeset
  1692
		group->GetItem(_news_type_data[i].name, true)->SetValue(value);
6283
f9d97d412b0f (svn r9097) -Fix [FS#525]: open and close messages now have their own setting, so you can hide economy changes, but do show open/close of industries
truelight
parents: 6248
diff changeset
  1693
	}
f9d97d412b0f (svn r9097) -Fix [FS#525]: open and close messages now have their own setting, so you can hide economy changes, but do show open/close of industries
truelight
parents: 6248
diff changeset
  1694
}
5329
9c5e8061ea0f (svn r7490) -Feature: Load a list of NewGRFs from the config (in the [newgrf-static] section) that should always be loaded. These will also be active during the intro screen, and in multiplayer games. Only "network-safe" NewGRFs are permitted, such as fonts and sprite replacement sets.
peter1138
parents: 5309
diff changeset
  1695
8747
d6c53cb184f3 (svn r12443) -Add: OpenTTDs version to openttd.cfg, just so we do not need to keep to ask people for their version number because it's likely they give you the wrong answer anyway.
rubidium
parents: 8737
diff changeset
  1696
/**
d6c53cb184f3 (svn r12443) -Add: OpenTTDs version to openttd.cfg, just so we do not need to keep to ask people for their version number because it's likely they give you the wrong answer anyway.
rubidium
parents: 8737
diff changeset
  1697
 * Save the version of OpenTTD to the ini file.
d6c53cb184f3 (svn r12443) -Add: OpenTTDs version to openttd.cfg, just so we do not need to keep to ask people for their version number because it's likely they give you the wrong answer anyway.
rubidium
parents: 8737
diff changeset
  1698
 * @param ini the ini to write to
d6c53cb184f3 (svn r12443) -Add: OpenTTDs version to openttd.cfg, just so we do not need to keep to ask people for their version number because it's likely they give you the wrong answer anyway.
rubidium
parents: 8737
diff changeset
  1699
 */
d6c53cb184f3 (svn r12443) -Add: OpenTTDs version to openttd.cfg, just so we do not need to keep to ask people for their version number because it's likely they give you the wrong answer anyway.
rubidium
parents: 8737
diff changeset
  1700
static void SaveVersionInConfig(IniFile *ini)
d6c53cb184f3 (svn r12443) -Add: OpenTTDs version to openttd.cfg, just so we do not need to keep to ask people for their version number because it's likely they give you the wrong answer anyway.
rubidium
parents: 8737
diff changeset
  1701
{
9996
fceaf224b2f0 (svn r14153) -Codechange: split ini file reading/saving from settings.cpp.
rubidium
parents: 9906
diff changeset
  1702
	IniGroup *group = ini->GetGroup("version");
8747
d6c53cb184f3 (svn r12443) -Add: OpenTTDs version to openttd.cfg, just so we do not need to keep to ask people for their version number because it's likely they give you the wrong answer anyway.
rubidium
parents: 8737
diff changeset
  1703
d6c53cb184f3 (svn r12443) -Add: OpenTTDs version to openttd.cfg, just so we do not need to keep to ask people for their version number because it's likely they give you the wrong answer anyway.
rubidium
parents: 8737
diff changeset
  1704
	char version[9];
d6c53cb184f3 (svn r12443) -Add: OpenTTDs version to openttd.cfg, just so we do not need to keep to ask people for their version number because it's likely they give you the wrong answer anyway.
rubidium
parents: 8737
diff changeset
  1705
	snprintf(version, lengthof(version), "%08X", _openttd_newgrf_version);
d6c53cb184f3 (svn r12443) -Add: OpenTTDs version to openttd.cfg, just so we do not need to keep to ask people for their version number because it's likely they give you the wrong answer anyway.
rubidium
parents: 8737
diff changeset
  1706
d6c53cb184f3 (svn r12443) -Add: OpenTTDs version to openttd.cfg, just so we do not need to keep to ask people for their version number because it's likely they give you the wrong answer anyway.
rubidium
parents: 8737
diff changeset
  1707
	const char *versions[][2] = {
d6c53cb184f3 (svn r12443) -Add: OpenTTDs version to openttd.cfg, just so we do not need to keep to ask people for their version number because it's likely they give you the wrong answer anyway.
rubidium
parents: 8737
diff changeset
  1708
		{ "version_string", _openttd_revision },
d6c53cb184f3 (svn r12443) -Add: OpenTTDs version to openttd.cfg, just so we do not need to keep to ask people for their version number because it's likely they give you the wrong answer anyway.
rubidium
parents: 8737
diff changeset
  1709
		{ "version_number", version }
d6c53cb184f3 (svn r12443) -Add: OpenTTDs version to openttd.cfg, just so we do not need to keep to ask people for their version number because it's likely they give you the wrong answer anyway.
rubidium
parents: 8737
diff changeset
  1710
	};
d6c53cb184f3 (svn r12443) -Add: OpenTTDs version to openttd.cfg, just so we do not need to keep to ask people for their version number because it's likely they give you the wrong answer anyway.
rubidium
parents: 8737
diff changeset
  1711
d6c53cb184f3 (svn r12443) -Add: OpenTTDs version to openttd.cfg, just so we do not need to keep to ask people for their version number because it's likely they give you the wrong answer anyway.
rubidium
parents: 8737
diff changeset
  1712
	for (uint i = 0; i < lengthof(versions); i++) {
10008
fca6f9cf02ac (svn r14167) -Fix: items in some ini-groups got duplicated on save.
rubidium
parents: 10005
diff changeset
  1713
		group->GetItem(versions[i][0], true)->SetValue(versions[i][1]);
8747
d6c53cb184f3 (svn r12443) -Add: OpenTTDs version to openttd.cfg, just so we do not need to keep to ask people for their version number because it's likely they give you the wrong answer anyway.
rubidium
parents: 8737
diff changeset
  1714
	}
d6c53cb184f3 (svn r12443) -Add: OpenTTDs version to openttd.cfg, just so we do not need to keep to ask people for their version number because it's likely they give you the wrong answer anyway.
rubidium
parents: 8737
diff changeset
  1715
}
d6c53cb184f3 (svn r12443) -Add: OpenTTDs version to openttd.cfg, just so we do not need to keep to ask people for their version number because it's likely they give you the wrong answer anyway.
rubidium
parents: 8737
diff changeset
  1716
5329
9c5e8061ea0f (svn r7490) -Feature: Load a list of NewGRFs from the config (in the [newgrf-static] section) that should always be loaded. These will also be active during the intro screen, and in multiplayer games. Only "network-safe" NewGRFs are permitted, such as fonts and sprite replacement sets.
peter1138
parents: 5309
diff changeset
  1717
/* Save a GRF configuration to the given group name */
5309
3e7883483280 (svn r7465) -Codechange: Save the default GRF configuration.
peter1138
parents: 5307
diff changeset
  1718
static void GRFSaveConfig(IniFile *ini, const char *grpname, const GRFConfig *list)
3e7883483280 (svn r7465) -Codechange: Save the default GRF configuration.
peter1138
parents: 5307
diff changeset
  1719
{
10026
ed381cc06495 (svn r14185) -Fix (r14153): removing NewGRFs from the config file was impossible.
rubidium
parents: 10015
diff changeset
  1720
	ini->RemoveGroup(grpname);
9996
fceaf224b2f0 (svn r14153) -Codechange: split ini file reading/saving from settings.cpp.
rubidium
parents: 9906
diff changeset
  1721
	IniGroup *group = ini->GetGroup(grpname);
5309
3e7883483280 (svn r7465) -Codechange: Save the default GRF configuration.
peter1138
parents: 5307
diff changeset
  1722
	const GRFConfig *c;
3e7883483280 (svn r7465) -Codechange: Save the default GRF configuration.
peter1138
parents: 5307
diff changeset
  1723
3e7883483280 (svn r7465) -Codechange: Save the default GRF configuration.
peter1138
parents: 5307
diff changeset
  1724
	for (c = list; c != NULL; c = c->next) {
3e7883483280 (svn r7465) -Codechange: Save the default GRF configuration.
peter1138
parents: 5307
diff changeset
  1725
		char params[512];
3e7883483280 (svn r7465) -Codechange: Save the default GRF configuration.
peter1138
parents: 5307
diff changeset
  1726
		GRFBuildParamList(params, c, lastof(params));
3e7883483280 (svn r7465) -Codechange: Save the default GRF configuration.
peter1138
parents: 5307
diff changeset
  1727
10008
fca6f9cf02ac (svn r14167) -Fix: items in some ini-groups got duplicated on save.
rubidium
parents: 10005
diff changeset
  1728
		group->GetItem(c->filename, true)->SetValue(params);
5309
3e7883483280 (svn r7465) -Codechange: Save the default GRF configuration.
peter1138
parents: 5307
diff changeset
  1729
	}
3e7883483280 (svn r7465) -Codechange: Save the default GRF configuration.
peter1138
parents: 5307
diff changeset
  1730
}
3e7883483280 (svn r7465) -Codechange: Save the default GRF configuration.
peter1138
parents: 5307
diff changeset
  1731
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1732
/* Common handler for saving/loading variables to the configuration file */
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1733
static void HandleSettingDescs(IniFile *ini, SettingDescProc *proc, SettingDescProcList *proc_list)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1734
{
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1735
	proc(ini, (const SettingDesc*)_misc_settings,    "misc",  NULL);
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1736
	proc(ini, (const SettingDesc*)_music_settings,   "music", &msf);
3051
6a9ddcac6d56 (svn r3640) - Remove win32-only variables from variables.h and put them into win32_v.c. Also ifdef the win32 specific configuration file settings.
Darkvater
parents: 3042
diff changeset
  1737
#ifdef WIN32
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1738
	proc(ini, (const SettingDesc*)_win32_settings,   "win32", NULL);
3051
6a9ddcac6d56 (svn r3640) - Remove win32-only variables from variables.h and put them into win32_v.c. Also ifdef the win32 specific configuration file settings.
Darkvater
parents: 3042
diff changeset
  1739
#endif /* WIN32 */
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1740
9354
845e07db4549 (svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents: 9350
diff changeset
  1741
	proc(ini, _patch_settings,   "patches",  &_settings_newgame);
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1742
	proc(ini, _currency_settings,"currency", &_custom_currency);
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1743
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
  1744
#ifdef ENABLE_NETWORK
3628
69646d0924a5 (svn r4527) - Feature [NewGRF]: Add support for specifying parameters to GRF files. Usage: "mygrf = 1". You can pass up to 128 parameters, each one seperated by a comma or a space-character. Big thanks to peter1138 for the inspiration and examples.
Darkvater
parents: 3615
diff changeset
  1745
	proc_list(ini, "servers", _network_host_list, lengthof(_network_host_list), NULL);
69646d0924a5 (svn r4527) - Feature [NewGRF]: Add support for specifying parameters to GRF files. Usage: "mygrf = 1". You can pass up to 128 parameters, each one seperated by a comma or a space-character. Big thanks to peter1138 for the inspiration and examples.
Darkvater
parents: 3615
diff changeset
  1746
	proc_list(ini, "bans",    _network_ban_list,  lengthof(_network_ban_list), NULL);
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
  1747
#endif /* ENABLE_NETWORK */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1748
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1749
9996
fceaf224b2f0 (svn r14153) -Codechange: split ini file reading/saving from settings.cpp.
rubidium
parents: 9906
diff changeset
  1750
static IniFile *IniLoadConfig()
fceaf224b2f0 (svn r14153) -Codechange: split ini file reading/saving from settings.cpp.
rubidium
parents: 9906
diff changeset
  1751
{
fceaf224b2f0 (svn r14153) -Codechange: split ini file reading/saving from settings.cpp.
rubidium
parents: 9906
diff changeset
  1752
	IniFile *ini = new IniFile(_list_group_names);
fceaf224b2f0 (svn r14153) -Codechange: split ini file reading/saving from settings.cpp.
rubidium
parents: 9906
diff changeset
  1753
	ini->LoadFromDisk(_config_file);
fceaf224b2f0 (svn r14153) -Codechange: split ini file reading/saving from settings.cpp.
rubidium
parents: 9906
diff changeset
  1754
	return ini;
fceaf224b2f0 (svn r14153) -Codechange: split ini file reading/saving from settings.cpp.
rubidium
parents: 9906
diff changeset
  1755
}
fceaf224b2f0 (svn r14153) -Codechange: split ini file reading/saving from settings.cpp.
rubidium
parents: 9906
diff changeset
  1756
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1757
/** Load the values from the configuration files */
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6229
diff changeset
  1758
void LoadFromConfig()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1759
{
9996
fceaf224b2f0 (svn r14153) -Codechange: split ini file reading/saving from settings.cpp.
rubidium
parents: 9906
diff changeset
  1760
	IniFile *ini = IniLoadConfig();
6379
e3cb84b60342 (svn r9467) -Fix(FS#703,6108): When resetting the array of currencies, the custom currency was reset too, thus loosing the setting a user could have used for it.(glx)
belugas
parents: 6378
diff changeset
  1761
	ResetCurrencies(false); // Initialize the array of curencies, without preserving the custom one
9398
d60d75cb053d (svn r13309) -Fix: the difficulty settings from the savegame would be reset by the ones of the intro game.
rubidium
parents: 9373
diff changeset
  1762
d60d75cb053d (svn r13309) -Fix: the difficulty settings from the savegame would be reset by the ones of the intro game.
rubidium
parents: 9373
diff changeset
  1763
	PrepareOldDiffCustom();
d60d75cb053d (svn r13309) -Fix: the difficulty settings from the savegame would be reset by the ones of the intro game.
rubidium
parents: 9373
diff changeset
  1764
	ini_load_settings(ini, _gameopt_settings, "gameopt",  &_settings_newgame);
d60d75cb053d (svn r13309) -Fix: the difficulty settings from the savegame would be reset by the ones of the intro game.
rubidium
parents: 9373
diff changeset
  1765
	HandleOldDiffCustom(false);
d60d75cb053d (svn r13309) -Fix: the difficulty settings from the savegame would be reset by the ones of the intro game.
rubidium
parents: 9373
diff changeset
  1766
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1767
	HandleSettingDescs(ini, ini_load_settings, ini_load_setting_list);
5329
9c5e8061ea0f (svn r7490) -Feature: Load a list of NewGRFs from the config (in the [newgrf-static] section) that should always be loaded. These will also be active during the intro screen, and in multiplayer games. Only "network-safe" NewGRFs are permitted, such as fonts and sprite replacement sets.
peter1138
parents: 5309
diff changeset
  1768
	_grfconfig_newgame = GRFLoadConfig(ini, "newgrf", false);
9c5e8061ea0f (svn r7490) -Feature: Load a list of NewGRFs from the config (in the [newgrf-static] section) that should always be loaded. These will also be active during the intro screen, and in multiplayer games. Only "network-safe" NewGRFs are permitted, such as fonts and sprite replacement sets.
peter1138
parents: 5309
diff changeset
  1769
	_grfconfig_static  = GRFLoadConfig(ini, "newgrf-static", true);
9010
fa1aa6008a59 (svn r12805) -Codechange: remove some bit magic related to the news display states. Patch by cirdan.
rubidium
parents: 8990
diff changeset
  1770
	NewsDisplayLoadConfig(ini, "news_display");
6378
817e6cb0b95b (svn r9455) -Fix: the values for diff_custom, diff_level and snow_line in the .cfg were not properly checked.
rubidium
parents: 6356
diff changeset
  1771
	CheckDifficultyLevels();
9996
fceaf224b2f0 (svn r14153) -Codechange: split ini file reading/saving from settings.cpp.
rubidium
parents: 9906
diff changeset
  1772
	delete ini;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1773
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1774
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1775
/** Save the values to the configuration file */
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6229
diff changeset
  1776
void SaveToConfig()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1777
{
9996
fceaf224b2f0 (svn r14153) -Codechange: split ini file reading/saving from settings.cpp.
rubidium
parents: 9906
diff changeset
  1778
	IniFile *ini = IniLoadConfig();
9354
845e07db4549 (svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents: 9350
diff changeset
  1779
845e07db4549 (svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents: 9350
diff changeset
  1780
	/* Remove some obsolete groups. These have all been loaded into other groups. */
9996
fceaf224b2f0 (svn r14153) -Codechange: split ini file reading/saving from settings.cpp.
rubidium
parents: 9906
diff changeset
  1781
	ini->RemoveGroup("patches");
fceaf224b2f0 (svn r14153) -Codechange: split ini file reading/saving from settings.cpp.
rubidium
parents: 9906
diff changeset
  1782
	ini->RemoveGroup("yapf");
fceaf224b2f0 (svn r14153) -Codechange: split ini file reading/saving from settings.cpp.
rubidium
parents: 9906
diff changeset
  1783
	ini->RemoveGroup("gameopt");
9354
845e07db4549 (svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents: 9350
diff changeset
  1784
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1785
	HandleSettingDescs(ini, ini_save_settings, ini_save_setting_list);
5309
3e7883483280 (svn r7465) -Codechange: Save the default GRF configuration.
peter1138
parents: 5307
diff changeset
  1786
	GRFSaveConfig(ini, "newgrf", _grfconfig_newgame);
5329
9c5e8061ea0f (svn r7490) -Feature: Load a list of NewGRFs from the config (in the [newgrf-static] section) that should always be loaded. These will also be active during the intro screen, and in multiplayer games. Only "network-safe" NewGRFs are permitted, such as fonts and sprite replacement sets.
peter1138
parents: 5309
diff changeset
  1787
	GRFSaveConfig(ini, "newgrf-static", _grfconfig_static);
9010
fa1aa6008a59 (svn r12805) -Codechange: remove some bit magic related to the news display states. Patch by cirdan.
rubidium
parents: 8990
diff changeset
  1788
	NewsDisplaySaveConfig(ini, "news_display");
8747
d6c53cb184f3 (svn r12443) -Add: OpenTTDs version to openttd.cfg, just so we do not need to keep to ask people for their version number because it's likely they give you the wrong answer anyway.
rubidium
parents: 8737
diff changeset
  1789
	SaveVersionInConfig(ini);
9996
fceaf224b2f0 (svn r14153) -Codechange: split ini file reading/saving from settings.cpp.
rubidium
parents: 9906
diff changeset
  1790
	ini->SaveToDisk(_config_file);
fceaf224b2f0 (svn r14153) -Codechange: split ini file reading/saving from settings.cpp.
rubidium
parents: 9906
diff changeset
  1791
	delete ini;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1792
}
1688
af2bb9bcb2ed (svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents: 1643
diff changeset
  1793
9677
4767b9937c04 (svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138
parents: 9673
diff changeset
  1794
void GetGRFPresetList(GRFPresetList *list)
4767b9937c04 (svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138
parents: 9673
diff changeset
  1795
{
4767b9937c04 (svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138
parents: 9673
diff changeset
  1796
	list->Clear();
4767b9937c04 (svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138
parents: 9673
diff changeset
  1797
9996
fceaf224b2f0 (svn r14153) -Codechange: split ini file reading/saving from settings.cpp.
rubidium
parents: 9906
diff changeset
  1798
	IniFile *ini = IniLoadConfig();
9677
4767b9937c04 (svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138
parents: 9673
diff changeset
  1799
	IniGroup *group;
4767b9937c04 (svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138
parents: 9673
diff changeset
  1800
	for (group = ini->group; group != NULL; group = group->next) {
4767b9937c04 (svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138
parents: 9673
diff changeset
  1801
		if (strncmp(group->name, "preset-", 7) == 0) {
4767b9937c04 (svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138
parents: 9673
diff changeset
  1802
			*list->Append() = strdup(group->name + 7);
4767b9937c04 (svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138
parents: 9673
diff changeset
  1803
		}
4767b9937c04 (svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138
parents: 9673
diff changeset
  1804
	}
4767b9937c04 (svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138
parents: 9673
diff changeset
  1805
9996
fceaf224b2f0 (svn r14153) -Codechange: split ini file reading/saving from settings.cpp.
rubidium
parents: 9906
diff changeset
  1806
	delete ini;
9677
4767b9937c04 (svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138
parents: 9673
diff changeset
  1807
}
4767b9937c04 (svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138
parents: 9673
diff changeset
  1808
4767b9937c04 (svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138
parents: 9673
diff changeset
  1809
GRFConfig *LoadGRFPresetFromConfig(const char *config_name)
4767b9937c04 (svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138
parents: 9673
diff changeset
  1810
{
4767b9937c04 (svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138
parents: 9673
diff changeset
  1811
	char *section = (char*)alloca(strlen(config_name) + 8);
4767b9937c04 (svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138
parents: 9673
diff changeset
  1812
	sprintf(section, "preset-%s", config_name);
4767b9937c04 (svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138
parents: 9673
diff changeset
  1813
9996
fceaf224b2f0 (svn r14153) -Codechange: split ini file reading/saving from settings.cpp.
rubidium
parents: 9906
diff changeset
  1814
	IniFile *ini = IniLoadConfig();
9677
4767b9937c04 (svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138
parents: 9673
diff changeset
  1815
	GRFConfig *config = GRFLoadConfig(ini, section, false);
9996
fceaf224b2f0 (svn r14153) -Codechange: split ini file reading/saving from settings.cpp.
rubidium
parents: 9906
diff changeset
  1816
	delete ini;
9677
4767b9937c04 (svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138
parents: 9673
diff changeset
  1817
4767b9937c04 (svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138
parents: 9673
diff changeset
  1818
	return config;
4767b9937c04 (svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138
parents: 9673
diff changeset
  1819
}
4767b9937c04 (svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138
parents: 9673
diff changeset
  1820
4767b9937c04 (svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138
parents: 9673
diff changeset
  1821
void SaveGRFPresetToConfig(const char *config_name, GRFConfig *config)
4767b9937c04 (svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138
parents: 9673
diff changeset
  1822
{
4767b9937c04 (svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138
parents: 9673
diff changeset
  1823
	char *section = (char*)alloca(strlen(config_name) + 8);
4767b9937c04 (svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138
parents: 9673
diff changeset
  1824
	sprintf(section, "preset-%s", config_name);
4767b9937c04 (svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138
parents: 9673
diff changeset
  1825
9996
fceaf224b2f0 (svn r14153) -Codechange: split ini file reading/saving from settings.cpp.
rubidium
parents: 9906
diff changeset
  1826
	IniFile *ini = IniLoadConfig();
9677
4767b9937c04 (svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138
parents: 9673
diff changeset
  1827
	GRFSaveConfig(ini, section, config);
9996
fceaf224b2f0 (svn r14153) -Codechange: split ini file reading/saving from settings.cpp.
rubidium
parents: 9906
diff changeset
  1828
	ini->SaveToDisk(_config_file);
fceaf224b2f0 (svn r14153) -Codechange: split ini file reading/saving from settings.cpp.
rubidium
parents: 9906
diff changeset
  1829
	delete ini;
9677
4767b9937c04 (svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138
parents: 9673
diff changeset
  1830
}
4767b9937c04 (svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138
parents: 9673
diff changeset
  1831
4767b9937c04 (svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138
parents: 9673
diff changeset
  1832
void DeleteGRFPresetFromConfig(const char *config_name)
4767b9937c04 (svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138
parents: 9673
diff changeset
  1833
{
4767b9937c04 (svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138
parents: 9673
diff changeset
  1834
	char *section = (char*)alloca(strlen(config_name) + 8);
4767b9937c04 (svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138
parents: 9673
diff changeset
  1835
	sprintf(section, "preset-%s", config_name);
4767b9937c04 (svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138
parents: 9673
diff changeset
  1836
9996
fceaf224b2f0 (svn r14153) -Codechange: split ini file reading/saving from settings.cpp.
rubidium
parents: 9906
diff changeset
  1837
	IniFile *ini = IniLoadConfig();
fceaf224b2f0 (svn r14153) -Codechange: split ini file reading/saving from settings.cpp.
rubidium
parents: 9906
diff changeset
  1838
	ini->RemoveGroup(section);
fceaf224b2f0 (svn r14153) -Codechange: split ini file reading/saving from settings.cpp.
rubidium
parents: 9906
diff changeset
  1839
	ini->SaveToDisk(_config_file);
fceaf224b2f0 (svn r14153) -Codechange: split ini file reading/saving from settings.cpp.
rubidium
parents: 9906
diff changeset
  1840
	delete ini;
9677
4767b9937c04 (svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138
parents: 9673
diff changeset
  1841
}
4767b9937c04 (svn r13781) -Feature: NewGRF presets, selected by a drop down list in the NewGRF window. Presets are saved in the config file.
peter1138
parents: 9673
diff changeset
  1842
3247
ede7a53941b2 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3246
diff changeset
  1843
static const SettingDesc *GetSettingDescription(uint index)
3118
adc86793eee1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3117
diff changeset
  1844
{
adc86793eee1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3117
diff changeset
  1845
	if (index >= lengthof(_patch_settings)) return NULL;
adc86793eee1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3117
diff changeset
  1846
	return &_patch_settings[index];
adc86793eee1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3117
diff changeset
  1847
}
adc86793eee1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3117
diff changeset
  1848
3119
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1849
/** Network-safe changing of patch-settings (server-only).
6483
ae78fc3c6b20 (svn r9664) -Documentation: Doxygen corrections,errors and omissions
belugas
parents: 6457
diff changeset
  1850
 * @param tile unused
ae78fc3c6b20 (svn r9664) -Documentation: Doxygen corrections,errors and omissions
belugas
parents: 6457
diff changeset
  1851
 * @param flags operation to perform
3119
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1852
 * @param p1 the index of the patch in the SettingDesc array which identifies it
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1853
 * @param p2 the new value for the patch
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1854
 * The new value is properly clamped to its minimum/maximum when setting
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1855
 * @see _patch_settings
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1856
 */
6943
1914f26aee04 (svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium
parents: 6913
diff changeset
  1857
CommandCost CmdChangePatchSetting(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
3119
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1858
{
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1859
	const SettingDesc *sd = GetSettingDescription(p1);
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1860
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1861
	if (sd == NULL) return CMD_ERROR;
3223
eed8c6a62ec2 (svn r3896) - [Patches] Fix: Honour any conditional settings when retrieving the setting entries.
Darkvater
parents: 3222
diff changeset
  1862
	if (!SlIsObjectCurrentlyValid(sd->save.version_from, sd->save.version_to)) return CMD_ERROR;
3119
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1863
9426
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1864
	if ((sd->desc.flags & SGF_NETWORK_ONLY) && !_networking && _game_mode != GM_MENU) return CMD_ERROR;
7901
6e8ab6c5473d (svn r11452) -Change: do not allow configuration changes, that NewGRFs can directly use to change their behaviour, during network games as this can cause desyncs.
rubidium
parents: 7849
diff changeset
  1865
	if ((sd->desc.flags & SGF_NO_NETWORK) && _networking) return CMD_ERROR;
9359
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
  1866
	if ((sd->desc.flags & SGF_NEWGAME_ONLY) && _game_mode != GM_MENU) return CMD_ERROR;
7901
6e8ab6c5473d (svn r11452) -Change: do not allow configuration changes, that NewGRFs can directly use to change their behaviour, during network games as this can cause desyncs.
rubidium
parents: 7849
diff changeset
  1867
3119
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1868
	if (flags & DC_EXEC) {
9413
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1869
		GameSettings *s = (_game_mode == GM_MENU) ? &_settings_newgame : &_settings_game;
9354
845e07db4549 (svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents: 9350
diff changeset
  1870
		void *var = GetVariableAddress(s, &sd->save);
9457
75f11a6caef8 (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents: 9451
diff changeset
  1871
75f11a6caef8 (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents: 9451
diff changeset
  1872
		int32 oldval = (int32)ReadValue(var, sd->save.conv);
75f11a6caef8 (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents: 9451
diff changeset
  1873
		int32 newval = (int32)p2;
75f11a6caef8 (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents: 9451
diff changeset
  1874
75f11a6caef8 (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents: 9451
diff changeset
  1875
		Write_ValidateSetting(var, sd, newval);
75f11a6caef8 (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents: 9451
diff changeset
  1876
		newval = (int32)ReadValue(var, sd->save.conv);
75f11a6caef8 (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents: 9451
diff changeset
  1877
75f11a6caef8 (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents: 9451
diff changeset
  1878
		if (sd->desc.proc != NULL) sd->desc.proc(newval);
75f11a6caef8 (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents: 9451
diff changeset
  1879
75f11a6caef8 (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents: 9451
diff changeset
  1880
		if ((sd->desc.flags & SGF_NO_NETWORK) && oldval != newval) {
75f11a6caef8 (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents: 9451
diff changeset
  1881
			GamelogStartAction(GLAT_PATCH);
75f11a6caef8 (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents: 9451
diff changeset
  1882
			GamelogPatch(sd->desc.name, oldval, newval);
75f11a6caef8 (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents: 9451
diff changeset
  1883
			GamelogStopAction();
75f11a6caef8 (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents: 9451
diff changeset
  1884
		}
3119
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1885
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1886
		InvalidateWindow(WC_GAME_OPTIONS, 0);
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1887
	}
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1888
6950
14ecb0acdfb4 (svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents: 6943
diff changeset
  1889
	return CommandCost();
3119
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1890
}
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1891
3615
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
  1892
/** Top function to save the new value of an element of the Patches struct
3118
adc86793eee1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3117
diff changeset
  1893
 * @param index offset in the SettingDesc array of the Patches struct which
adc86793eee1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3117
diff changeset
  1894
 * identifies the patch member we want to change
adc86793eee1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3117
diff changeset
  1895
 * @param object pointer to a valid patches struct that has its settings change.
adc86793eee1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3117
diff changeset
  1896
 * This only affects patch-members that are not needed to be the same on all
adc86793eee1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3117
diff changeset
  1897
 * clients in a network game.
adc86793eee1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3117
diff changeset
  1898
 * @param value new value of the patch */
9413
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1899
bool SetPatchValue(uint index, int32 value)
3118
adc86793eee1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3117
diff changeset
  1900
{
adc86793eee1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3117
diff changeset
  1901
	const SettingDesc *sd = &_patch_settings[index];
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10199
diff changeset
  1902
	/* If an item is company-based, we do not send it over the network
3118
adc86793eee1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3117
diff changeset
  1903
	 * (if any) to change. Also *hack*hack* we update the _newgame version
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10199
diff changeset
  1904
	 * of patches because changing a company-based setting in a game also
3118
adc86793eee1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3117
diff changeset
  1905
	 * changes its defaults. At least that is the convention we have chosen */
adc86793eee1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3117
diff changeset
  1906
	if (sd->save.conv & SLF_NETWORK_NO) {
9413
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  1907
		void *var = GetVariableAddress((_game_mode == GM_MENU) ? &_settings_newgame : &_settings_game, &sd->save);
3118
adc86793eee1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3117
diff changeset
  1908
		Write_ValidateSetting(var, sd, value);
3121
72fb0554f9f1 (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
  1909
72fb0554f9f1 (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
  1910
		if (_game_mode != GM_MENU) {
9354
845e07db4549 (svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents: 9350
diff changeset
  1911
			void *var2 = GetVariableAddress(&_settings_newgame, &sd->save);
4077
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4065
diff changeset
  1912
			Write_ValidateSetting(var2, sd, value);
3121
72fb0554f9f1 (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
  1913
		}
5113
84cabfb98a67 (svn r7190) -Fix: If the non-player-based _patches setting was changed on the server during MP game, the callback function was:
KUDr
parents: 5108
diff changeset
  1914
		if (sd->desc.proc != NULL) sd->desc.proc((int32)ReadValue(var, sd->save.conv));
4600
8215dd63a2a3 (svn r6450) -Feature: Make the 'patch' console command available for offline use and for
Darkvater
parents: 4590
diff changeset
  1915
		InvalidateWindow(WC_GAME_OPTIONS, 0);
8215dd63a2a3 (svn r6450) -Feature: Make the 'patch' console command available for offline use and for
Darkvater
parents: 4590
diff changeset
  1916
		return true;
3118
adc86793eee1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3117
diff changeset
  1917
	}
4600
8215dd63a2a3 (svn r6450) -Feature: Make the 'patch' console command available for offline use and for
Darkvater
parents: 4590
diff changeset
  1918
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10199
diff changeset
  1919
	/* send non-company-based settings over the network */
4600
8215dd63a2a3 (svn r6450) -Feature: Make the 'patch' console command available for offline use and for
Darkvater
parents: 4590
diff changeset
  1920
	if (!_networking || (_networking && _network_server)) {
8215dd63a2a3 (svn r6450) -Feature: Make the 'patch' console command available for offline use and for
Darkvater
parents: 4590
diff changeset
  1921
		return DoCommandP(0, index, value, NULL, CMD_CHANGE_PATCH_SETTING);
8215dd63a2a3 (svn r6450) -Feature: Make the 'patch' console command available for offline use and for
Darkvater
parents: 4590
diff changeset
  1922
	}
8215dd63a2a3 (svn r6450) -Feature: Make the 'patch' console command available for offline use and for
Darkvater
parents: 4590
diff changeset
  1923
	return false;
3118
adc86793eee1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3117
diff changeset
  1924
}
adc86793eee1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3117
diff changeset
  1925
9426
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1926
/**
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1927
 * Set a patch value with a string.
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1928
 * @param index the patch settings index.
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1929
 * @param value the value to write
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1930
 * @note CANNOT BE SAVED IN THE SAVEGAME.
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1931
 */
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1932
bool SetPatchValue(uint index, const char *value)
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1933
{
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1934
	const SettingDesc *sd = &_patch_settings[index];
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1935
	assert(sd->save.conv & SLF_NETWORK_NO);
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1936
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1937
	char *var = (char*)GetVariableAddress(NULL, &sd->save);
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1938
	ttd_strlcpy(var, value, sd->save.length);
9451
0d6806ba5504 (svn r13369) -Codechange: remove duplication of network configuration settings between NetworkSettings and NetworkGameInfo.
rubidium
parents: 9447
diff changeset
  1939
	if (sd->desc.proc != NULL) sd->desc.proc(0);
9426
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1940
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1941
	return true;
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1942
}
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1943
10199
3bb560dd3cf6 (svn r14412) -Documentation: Comment some functions related to the advanced settings. Patch by Alberth, but with less excessive use of 'at'.
frosch
parents: 10105
diff changeset
  1944
/**
3bb560dd3cf6 (svn r14412) -Documentation: Comment some functions related to the advanced settings. Patch by Alberth, but with less excessive use of 'at'.
frosch
parents: 10105
diff changeset
  1945
 * Given a name of patch, return a setting description of it.
3bb560dd3cf6 (svn r14412) -Documentation: Comment some functions related to the advanced settings. Patch by Alberth, but with less excessive use of 'at'.
frosch
parents: 10105
diff changeset
  1946
 * @param name  Name of the patch to return a setting description of
3bb560dd3cf6 (svn r14412) -Documentation: Comment some functions related to the advanced settings. Patch by Alberth, but with less excessive use of 'at'.
frosch
parents: 10105
diff changeset
  1947
 * @param i     Pointer to an integer that will contain the index of the setting after the call, if it is successful.
3bb560dd3cf6 (svn r14412) -Documentation: Comment some functions related to the advanced settings. Patch by Alberth, but with less excessive use of 'at'.
frosch
parents: 10105
diff changeset
  1948
 * @return Pointer to the setting description of patch \a name if it can be found,
3bb560dd3cf6 (svn r14412) -Documentation: Comment some functions related to the advanced settings. Patch by Alberth, but with less excessive use of 'at'.
frosch
parents: 10105
diff changeset
  1949
 *         \c NULL indicates failure to obtain the description
3bb560dd3cf6 (svn r14412) -Documentation: Comment some functions related to the advanced settings. Patch by Alberth, but with less excessive use of 'at'.
frosch
parents: 10105
diff changeset
  1950
 */
3247
ede7a53941b2 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3246
diff changeset
  1951
const SettingDesc *GetPatchFromName(const char *name, uint *i)
3119
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1952
{
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1953
	const SettingDesc *sd;
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1954
9361
7a213ee7ee5b (svn r13258) -Codechange: add support for using (most) of the old patch names in the console.
rubidium
parents: 9359
diff changeset
  1955
	/* First check all full names */
3131
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1956
	for (*i = 0, sd = _patch_settings; sd->save.cmd != SL_END; sd++, (*i)++) {
3223
eed8c6a62ec2 (svn r3896) - [Patches] Fix: Honour any conditional settings when retrieving the setting entries.
Darkvater
parents: 3222
diff changeset
  1957
		if (!SlIsObjectCurrentlyValid(sd->save.version_from, sd->save.version_to)) continue;
3210
2c3f6ea896f4 (svn r3880) - just do a string compare without length restrictions; followup for r3875
Darkvater
parents: 3207
diff changeset
  1958
		if (strcmp(sd->desc.name, name) == 0) return sd;
3119
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1959
	}
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1960
9361
7a213ee7ee5b (svn r13258) -Codechange: add support for using (most) of the old patch names in the console.
rubidium
parents: 9359
diff changeset
  1961
	/* Then check the shortcut variant of the name. */
7a213ee7ee5b (svn r13258) -Codechange: add support for using (most) of the old patch names in the console.
rubidium
parents: 9359
diff changeset
  1962
	for (*i = 0, sd = _patch_settings; sd->save.cmd != SL_END; sd++, (*i)++) {
7a213ee7ee5b (svn r13258) -Codechange: add support for using (most) of the old patch names in the console.
rubidium
parents: 9359
diff changeset
  1963
		if (!SlIsObjectCurrentlyValid(sd->save.version_from, sd->save.version_to)) continue;
7a213ee7ee5b (svn r13258) -Codechange: add support for using (most) of the old patch names in the console.
rubidium
parents: 9359
diff changeset
  1964
		const char *short_name = strchr(sd->desc.name, '.');
7a213ee7ee5b (svn r13258) -Codechange: add support for using (most) of the old patch names in the console.
rubidium
parents: 9359
diff changeset
  1965
		if (short_name != NULL) {
7a213ee7ee5b (svn r13258) -Codechange: add support for using (most) of the old patch names in the console.
rubidium
parents: 9359
diff changeset
  1966
			short_name++;
7a213ee7ee5b (svn r13258) -Codechange: add support for using (most) of the old patch names in the console.
rubidium
parents: 9359
diff changeset
  1967
			if (strcmp(short_name, name) == 0) return sd;
7a213ee7ee5b (svn r13258) -Codechange: add support for using (most) of the old patch names in the console.
rubidium
parents: 9359
diff changeset
  1968
		}
7a213ee7ee5b (svn r13258) -Codechange: add support for using (most) of the old patch names in the console.
rubidium
parents: 9359
diff changeset
  1969
	}
7a213ee7ee5b (svn r13258) -Codechange: add support for using (most) of the old patch names in the console.
rubidium
parents: 9359
diff changeset
  1970
3119
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1971
	return NULL;
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1972
}
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1973
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1974
/* Those 2 functions need to be here, else we have to make some stuff non-static
4278
761e05083f9c (svn r5908) - Codechange (r5903): Move the retrieval of the new value of a patch to console_cmds.c, so there is no need for that function in settings.c
Darkvater
parents: 4275
diff changeset
  1975
 * and besides, it is also better to keep stuff like this at the same place */
9426
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1976
void IConsoleSetPatchSetting(const char *name, const char *value)
3119
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1977
{
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1978
	uint index;
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1979
	const SettingDesc *sd = GetPatchFromName(name, &index);
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1980
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1981
	if (sd == NULL) {
9337
ab6e0234bacc (svn r13229) -Codechange: replace some global variables that are only initialised once and always with the same value with enums.
rubidium
parents: 9336
diff changeset
  1982
		IConsolePrintF(CC_WARNING, "'%s' is an unknown patch setting.", name);
9447
d5d0e9d2c1ee (svn r13365) -Fix: don't segfault on trying to set a non-existing patch setting.
rubidium
parents: 9428
diff changeset
  1983
		return;
3119
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1984
	}
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1985
9426
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1986
	bool success;
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1987
	if (sd->desc.cmd == SDT_STRING) {
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1988
		success = SetPatchValue(index, value);
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1989
	} else {
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1990
		uint32 val;
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1991
		extern bool GetArgumentInteger(uint32 *value, const char *arg);
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1992
		success = GetArgumentInteger(&val, value);
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1993
		if (success) success = SetPatchValue(index, val);
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1994
	}
3119
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1995
9426
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1996
	if (!success) {
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1997
		if (_network_server) {
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1998
			IConsoleError("This command/variable is not available during network games.");
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  1999
		} else {
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  2000
			IConsoleError("This command/variable is only available to a network server.");
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  2001
		}
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  2002
	}
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  2003
}
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  2004
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  2005
void IConsoleSetPatchSetting(const char *name, int value)
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  2006
{
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  2007
	uint index;
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  2008
	const SettingDesc *sd = GetPatchFromName(name, &index);
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  2009
	assert(sd != NULL);
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  2010
	SetPatchValue(index, value);
3119
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  2011
}
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  2012
10199
3bb560dd3cf6 (svn r14412) -Documentation: Comment some functions related to the advanced settings. Patch by Alberth, but with less excessive use of 'at'.
frosch
parents: 10105
diff changeset
  2013
/**
3bb560dd3cf6 (svn r14412) -Documentation: Comment some functions related to the advanced settings. Patch by Alberth, but with less excessive use of 'at'.
frosch
parents: 10105
diff changeset
  2014
 * Output value of a specific patch to the console
3bb560dd3cf6 (svn r14412) -Documentation: Comment some functions related to the advanced settings. Patch by Alberth, but with less excessive use of 'at'.
frosch
parents: 10105
diff changeset
  2015
 * @param name  Name of the patch to output its value
3bb560dd3cf6 (svn r14412) -Documentation: Comment some functions related to the advanced settings. Patch by Alberth, but with less excessive use of 'at'.
frosch
parents: 10105
diff changeset
  2016
 */
3119
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  2017
void IConsoleGetPatchSetting(const char *name)
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  2018
{
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  2019
	char value[20];
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  2020
	uint index;
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  2021
	const SettingDesc *sd = GetPatchFromName(name, &index);
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  2022
	const void *ptr;
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  2023
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  2024
	if (sd == NULL) {
9337
ab6e0234bacc (svn r13229) -Codechange: replace some global variables that are only initialised once and always with the same value with enums.
rubidium
parents: 9336
diff changeset
  2025
		IConsolePrintF(CC_WARNING, "'%s' is an unknown patch setting.", name);
3119
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  2026
		return;
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  2027
	}
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  2028
9413
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  2029
	ptr = GetVariableAddress((_game_mode == GM_MENU) ? &_settings_newgame : &_settings_game, &sd->save);
3119
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  2030
9426
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  2031
	if (sd->desc.cmd == SDT_STRING) {
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  2032
		IConsolePrintF(CC_WARNING, "Current value for '%s' is: '%s'", name, (const char *)ptr);
3119
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  2033
	} else {
9426
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  2034
		if (sd->desc.cmd == SDT_BOOLX) {
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  2035
			snprintf(value, sizeof(value), (*(bool*)ptr == 1) ? "on" : "off");
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  2036
		} else {
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  2037
			snprintf(value, sizeof(value), "%d", (int32)ReadValue(ptr, sd->save.conv));
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  2038
		}
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  2039
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  2040
		IConsolePrintF(CC_WARNING, "Current value for '%s' is: '%s' (min: %s%d, max: %d)",
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  2041
			name, value, (sd->desc.flags & SGF_0ISDISABLED) ? "(0) " : "", sd->desc.min, sd->desc.max);
3119
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  2042
	}
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  2043
}
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  2044
10199
3bb560dd3cf6 (svn r14412) -Documentation: Comment some functions related to the advanced settings. Patch by Alberth, but with less excessive use of 'at'.
frosch
parents: 10105
diff changeset
  2045
/**
3bb560dd3cf6 (svn r14412) -Documentation: Comment some functions related to the advanced settings. Patch by Alberth, but with less excessive use of 'at'.
frosch
parents: 10105
diff changeset
  2046
 * List all patches and their value to the console
3bb560dd3cf6 (svn r14412) -Documentation: Comment some functions related to the advanced settings. Patch by Alberth, but with less excessive use of 'at'.
frosch
parents: 10105
diff changeset
  2047
 *
3bb560dd3cf6 (svn r14412) -Documentation: Comment some functions related to the advanced settings. Patch by Alberth, but with less excessive use of 'at'.
frosch
parents: 10105
diff changeset
  2048
 * @param prefilter  If not \c NULL, only list patches with names that begin with \a prefilter prefix
3bb560dd3cf6 (svn r14412) -Documentation: Comment some functions related to the advanced settings. Patch by Alberth, but with less excessive use of 'at'.
frosch
parents: 10105
diff changeset
  2049
 */
9893
bd16f5239fa4 (svn r14041) -Feature(tte): make it possible to filter list_patches output like it's done for other list_* console commands
glx
parents: 9825
diff changeset
  2050
void IConsoleListPatches(const char *prefilter)
6429
3512a65a7cfe (svn r9565) -Feature: Add list_patches console command. This shows all patches along with their current values. Based on patch by madman2003/GrimRC.
peter1138
parents: 6427
diff changeset
  2051
{
9337
ab6e0234bacc (svn r13229) -Codechange: replace some global variables that are only initialised once and always with the same value with enums.
rubidium
parents: 9336
diff changeset
  2052
	IConsolePrintF(CC_WARNING, "All patches with their current value:");
6429
3512a65a7cfe (svn r9565) -Feature: Add list_patches console command. This shows all patches along with their current values. Based on patch by madman2003/GrimRC.
peter1138
parents: 6427
diff changeset
  2053
3512a65a7cfe (svn r9565) -Feature: Add list_patches console command. This shows all patches along with their current values. Based on patch by madman2003/GrimRC.
peter1138
parents: 6427
diff changeset
  2054
	for (const SettingDesc *sd = _patch_settings; sd->save.cmd != SL_END; sd++) {
9893
bd16f5239fa4 (svn r14041) -Feature(tte): make it possible to filter list_patches output like it's done for other list_* console commands
glx
parents: 9825
diff changeset
  2055
		if (prefilter != NULL) {
bd16f5239fa4 (svn r14041) -Feature(tte): make it possible to filter list_patches output like it's done for other list_* console commands
glx
parents: 9825
diff changeset
  2056
			if (strncmp(sd->desc.name, prefilter, min(strlen(sd->desc.name), strlen(prefilter))) != 0) continue;
bd16f5239fa4 (svn r14041) -Feature(tte): make it possible to filter list_patches output like it's done for other list_* console commands
glx
parents: 9825
diff changeset
  2057
		}
6429
3512a65a7cfe (svn r9565) -Feature: Add list_patches console command. This shows all patches along with their current values. Based on patch by madman2003/GrimRC.
peter1138
parents: 6427
diff changeset
  2058
		char value[80];
9413
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  2059
		const void *ptr = GetVariableAddress((_game_mode == GM_MENU) ? &_settings_newgame : &_settings_game, &sd->save);
6429
3512a65a7cfe (svn r9565) -Feature: Add list_patches console command. This shows all patches along with their current values. Based on patch by madman2003/GrimRC.
peter1138
parents: 6427
diff changeset
  2060
3512a65a7cfe (svn r9565) -Feature: Add list_patches console command. This shows all patches along with their current values. Based on patch by madman2003/GrimRC.
peter1138
parents: 6427
diff changeset
  2061
		if (sd->desc.cmd == SDT_BOOLX) {
3512a65a7cfe (svn r9565) -Feature: Add list_patches console command. This shows all patches along with their current values. Based on patch by madman2003/GrimRC.
peter1138
parents: 6427
diff changeset
  2062
			snprintf(value, lengthof(value), (*(bool*)ptr == 1) ? "on" : "off");
9426
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  2063
		} else if (sd->desc.cmd == SDT_STRING) {
a77c8a4abcf5 (svn r13341) -Codechange: make most of the network settings configurable via the patch command.
rubidium
parents: 9422
diff changeset
  2064
			snprintf(value, sizeof(value), "%s", (const char *)ptr);
6429
3512a65a7cfe (svn r9565) -Feature: Add list_patches console command. This shows all patches along with their current values. Based on patch by madman2003/GrimRC.
peter1138
parents: 6427
diff changeset
  2065
		} else {
3512a65a7cfe (svn r9565) -Feature: Add list_patches console command. This shows all patches along with their current values. Based on patch by madman2003/GrimRC.
peter1138
parents: 6427
diff changeset
  2066
			snprintf(value, lengthof(value), "%d", (uint32)ReadValue(ptr, sd->save.conv));
3512a65a7cfe (svn r9565) -Feature: Add list_patches console command. This shows all patches along with their current values. Based on patch by madman2003/GrimRC.
peter1138
parents: 6427
diff changeset
  2067
		}
9337
ab6e0234bacc (svn r13229) -Codechange: replace some global variables that are only initialised once and always with the same value with enums.
rubidium
parents: 9336
diff changeset
  2068
		IConsolePrintF(CC_DEFAULT, "%s = %s", sd->desc.name, value);
6429
3512a65a7cfe (svn r9565) -Feature: Add list_patches console command. This shows all patches along with their current values. Based on patch by madman2003/GrimRC.
peter1138
parents: 6427
diff changeset
  2069
	}
3512a65a7cfe (svn r9565) -Feature: Add list_patches console command. This shows all patches along with their current values. Based on patch by madman2003/GrimRC.
peter1138
parents: 6427
diff changeset
  2070
9337
ab6e0234bacc (svn r13229) -Codechange: replace some global variables that are only initialised once and always with the same value with enums.
rubidium
parents: 9336
diff changeset
  2071
	IConsolePrintF(CC_WARNING, "Use 'patch' command to change a value");
6429
3512a65a7cfe (svn r9565) -Feature: Add list_patches console command. This shows all patches along with their current values. Based on patch by madman2003/GrimRC.
peter1138
parents: 6427
diff changeset
  2072
}
3512a65a7cfe (svn r9565) -Feature: Add list_patches console command. This shows all patches along with their current values. Based on patch by madman2003/GrimRC.
peter1138
parents: 6427
diff changeset
  2073
3117
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  2074
/** Save and load handler for patches/settings
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  2075
 * @param osd SettingDesc struct containing all information
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  2076
 * @param object can be either NULL in which case we load global variables or
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  2077
 * a pointer to a struct which is getting saved */
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  2078
static void LoadSettings(const SettingDesc *osd, void *object)
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  2079
{
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  2080
	for (; osd->save.cmd != SL_END; osd++) {
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  2081
		const SaveLoad *sld = &osd->save;
9413
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  2082
		void *ptr = GetVariableAddress(object, sld);
3117
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  2083
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  2084
		if (!SlObjectMember(ptr, sld)) continue;
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  2085
	}
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  2086
}
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  2087
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  2088
/** Loadhandler for a list of global variables
6483
ae78fc3c6b20 (svn r9664) -Documentation: Doxygen corrections,errors and omissions
belugas
parents: 6457
diff changeset
  2089
 * @param sdg pointer for the global variable list SettingDescGlobVarList
3117
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  2090
 * @note this is actually a stub for LoadSettings with the
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  2091
 * object pointer set to NULL */
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  2092
static inline void LoadSettingsGlobList(const SettingDescGlobVarList *sdg)
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  2093
{
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  2094
	LoadSettings((const SettingDesc*)sdg, NULL);
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  2095
}
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  2096
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  2097
/** Save and load handler for patches/settings
6483
ae78fc3c6b20 (svn r9664) -Documentation: Doxygen corrections,errors and omissions
belugas
parents: 6457
diff changeset
  2098
 * @param sd SettingDesc struct containing all information
3117
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  2099
 * @param object can be either NULL in which case we load global variables or
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  2100
 * a pointer to a struct which is getting saved */
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  2101
static void SaveSettings(const SettingDesc *sd, void *object)
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  2102
{
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  2103
	/* We need to write the CH_RIFF header, but unfortunately can't call
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  2104
	 * SlCalcLength() because we have a different format. So do this manually */
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  2105
	const SettingDesc *i;
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  2106
	size_t length = 0;
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  2107
	for (i = sd; i->save.cmd != SL_END; i++) {
5142
ee34e9968a62 (svn r7232) -Codechange: Also allow for the save/load of non pre-allocated strings inside structs.
Darkvater
parents: 5141
diff changeset
  2108
		const void *ptr = GetVariableAddress(object, &i->save);
ee34e9968a62 (svn r7232) -Codechange: Also allow for the save/load of non pre-allocated strings inside structs.
Darkvater
parents: 5141
diff changeset
  2109
		length += SlCalcObjMemberLength(ptr, &i->save);
3117
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  2110
	}
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  2111
	SlSetLength(length);
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  2112
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  2113
	for (i = sd; i->save.cmd != SL_END; i++) {
5141
63e24cb6f071 (svn r7231) -Codechange: rename ini_get_variable to GetVariableAddress for use both in settings.c
Darkvater
parents: 5116
diff changeset
  2114
		void *ptr = GetVariableAddress(object, &i->save);
3117
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  2115
		SlObjectMember(ptr, &i->save);
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  2116
	}
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  2117
}
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  2118
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  2119
/** Savehandler for a list of global variables
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  2120
 * @note this is actually a stub for SaveSettings with the
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  2121
 * object pointer set to NULL */
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  2122
static inline void SaveSettingsGlobList(const SettingDescGlobVarList *sdg)
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  2123
{
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  2124
	SaveSettings((const SettingDesc*)sdg, NULL);
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  2125
}
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  2126
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6229
diff changeset
  2127
static void Load_OPTS()
3117
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  2128
{
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  2129
	/* Copy over default setting since some might not get loaded in
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  2130
	 * a networking environment. This ensures for example that the local
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  2131
	 * autosave-frequency stays when joining a network-server */
9359
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
  2132
	PrepareOldDiffCustom();
9413
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  2133
	LoadSettings(_gameopt_settings, &_settings_game);
9398
d60d75cb053d (svn r13309) -Fix: the difficulty settings from the savegame would be reset by the ones of the intro game.
rubidium
parents: 9373
diff changeset
  2134
	HandleOldDiffCustom(true);
3117
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  2135
}
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  2136
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6229
diff changeset
  2137
static void Load_PATS()
3121
72fb0554f9f1 (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
  2138
{
72fb0554f9f1 (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
  2139
	/* Copy over default setting since some might not get loaded in
72fb0554f9f1 (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
  2140
	 * a networking environment. This ensures for example that the local
72fb0554f9f1 (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
  2141
	 * signal_side stays when joining a network-server */
9413
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  2142
	LoadSettings(_patch_settings, &_settings_game);
3121
72fb0554f9f1 (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
  2143
}
72fb0554f9f1 (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
  2144
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6229
diff changeset
  2145
static void Save_PATS()
3121
72fb0554f9f1 (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
  2146
{
9413
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9406
diff changeset
  2147
	SaveSettings(_patch_settings, &_settings_game);
3121
72fb0554f9f1 (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
  2148
}
72fb0554f9f1 (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
  2149
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6229
diff changeset
  2150
void CheckConfig()
1688
af2bb9bcb2ed (svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents: 1643
diff changeset
  2151
{
9373
05d1da601ff7 (svn r13277) -Fix: opntitle 'jumping' to the temperate climate when closing the NewGRF settings window.
rubidium
parents: 9361
diff changeset
  2152
	/*
05d1da601ff7 (svn r13277) -Fix: opntitle 'jumping' to the temperate climate when closing the NewGRF settings window.
rubidium
parents: 9361
diff changeset
  2153
	 * Increase old default values for pf_maxdepth and pf_maxlength
05d1da601ff7 (svn r13277) -Fix: opntitle 'jumping' to the temperate climate when closing the NewGRF settings window.
rubidium
parents: 9361
diff changeset
  2154
	 * to support big networks.
05d1da601ff7 (svn r13277) -Fix: opntitle 'jumping' to the temperate climate when closing the NewGRF settings window.
rubidium
parents: 9361
diff changeset
  2155
	 */
9354
845e07db4549 (svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents: 9350
diff changeset
  2156
	if (_settings_newgame.pf.opf.pf_maxdepth == 16 && _settings_newgame.pf.opf.pf_maxlength == 512) {
845e07db4549 (svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents: 9350
diff changeset
  2157
		_settings_newgame.pf.opf.pf_maxdepth = 48;
845e07db4549 (svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents: 9350
diff changeset
  2158
		_settings_newgame.pf.opf.pf_maxlength = 4096;
2044
df63b9a7dec3 (svn r2553) - Fix: [pathfinding] Remove old-old train pathfinder. Enhanced old pathfinder.
ludde
parents: 2008
diff changeset
  2159
	}
1688
af2bb9bcb2ed (svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents: 1643
diff changeset
  2160
}
3112
a6fda4d4c7ca (svn r3716) - Move the option settings (_game_opt_desc) from misc.c into settings.c. This will be merged with SettingDesc misc_settings above as they are actually the same. No functionality has changed beside the fact that the settings are now in a different Chunkhandler.
Darkvater
parents: 3052
diff changeset
  2161
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
  2162
extern const ChunkHandler _setting_chunk_handlers[] = {
9359
3a8554ac1cb8 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium
parents: 9358
diff changeset
  2163
	{ 'OPTS', NULL,      Load_OPTS, CH_RIFF},
3121
72fb0554f9f1 (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
  2164
	{ 'PATS', Save_PATS, Load_PATS, CH_RIFF | CH_LAST},
3112
a6fda4d4c7ca (svn r3716) - Move the option settings (_game_opt_desc) from misc.c into settings.c. This will be merged with SettingDesc misc_settings above as they are actually the same. No functionality has changed beside the fact that the settings are now in a different Chunkhandler.
Darkvater
parents: 3052
diff changeset
  2165
};
3900
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3874
diff changeset
  2166
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3874
diff changeset
  2167
static bool IsSignedVarMemType(VarType vt)
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3874
diff changeset
  2168
{
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3874
diff changeset
  2169
	switch (GetVarMemType(vt)) {
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3874
diff changeset
  2170
		case SLE_VAR_I8:
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3874
diff changeset
  2171
		case SLE_VAR_I16:
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3874
diff changeset
  2172
		case SLE_VAR_I32:
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3874
diff changeset
  2173
		case SLE_VAR_I64:
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3874
diff changeset
  2174
			return true;
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3874
diff changeset
  2175
	}
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3874
diff changeset
  2176
	return false;
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3874
diff changeset
  2177
}