src/settings.cpp
author celestar
Tue, 19 Jun 2007 07:21:01 +0000
branchgamebalance
changeset 9913 e79cd19772dd
parent 9912 1ac8aac92385
permissions -rw-r--r--
(svn r10213) [gamebalance] -Sync: r10100:10200 from trunk
2186
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     1
/* $Id$ */
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     2
9908
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
     3
/** @file settings.cpp
3615
59b36aaa050a (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.
59b36aaa050a (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
     5
 * The file consists of four parts:
59b36aaa050a (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
     6
 * <ol>
59b36aaa050a (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
59b36aaa050a (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
59b36aaa050a (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
     9
 *     lists, strings, integers, 'bit'-masks and element selections.
59b36aaa050a (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
59b36aaa050a (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
59b36aaa050a (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
59b36aaa050a (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
    13
 *     in a savegame is handled inside these structures.
59b36aaa050a (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
59b36aaa050a (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.
59b36aaa050a (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.
59b36aaa050a (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
    17
 * </ol>
59b36aaa050a (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
    18
 * @see SettingDesc
59b36aaa050a (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
    19
 * @see SaveLoad
59b36aaa050a (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
    20
 */
59b36aaa050a (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
92a3b0aa0946 (svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents: 1777
diff changeset
    23
#include "openttd.h"
2291
2b064aa97f91 (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"
2163
637ec3c361f5 (svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents: 2153
diff changeset
    25
#include "functions.h"
2191
cb4985f271ae (svn r2706) Fix !WITH_NETWORK build
tron
parents: 2186
diff changeset
    26
#include "macros.h"
2121
c86a863485ee (svn r2631) Move screenshot related variables from variables.h to screenshot.[ch]
tron
parents: 2044
diff changeset
    27
#include "screenshot.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    28
#include "sound.h"
1317
f382f1b439c7 (svn r1821) Move generic string handling functions to string.[ch] and introduce stre{cpy,cat}, see string.h for their semantics
tron
parents: 1282
diff changeset
    29
#include "string.h"
2153
91e89aa8c299 (svn r2663) Include variables.h only in these files which need it, not globally via openttd.h
tron
parents: 2125
diff changeset
    30
#include "variables.h"
5720
cc0ceeafaa55 (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
    31
#include "network/network.h"
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
    32
#include "settings.h"
3119
08471cfc4ef8 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
    33
#include "command.h"
08471cfc4ef8 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
    34
#include "console.h"
3112
05a599216d83 (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
    35
#include "saveload.h"
3358
798877df0899 (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
    36
#include "npf.h"
3900
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3874
diff changeset
    37
#include "yapf/yapf.h"
3628
bd4a6601e5a2 (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
    38
#include "newgrf.h"
5228
c4a780348f66 (svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents: 5211
diff changeset
    39
#include "newgrf_config.h"
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4293
diff changeset
    40
#include "genworld.h"
4261
2ec8f5a9747b (svn r5887) -Cleanup: move date related functions, defines and variables to date.[ch]
rubidium
parents: 4258
diff changeset
    41
#include "date.h"
5116
2a33a74925c5 (svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents: 5113
diff changeset
    42
#include "rail.h"
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5835
diff changeset
    43
#include "helpers.hpp"
9895
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6338
diff changeset
    44
#include "news.h"
5108
dc67d70b5a45 (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
    45
#ifdef WITH_FREETYPE
dc67d70b5a45 (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
    46
#include "gfx.h"
dc67d70b5a45 (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
    47
#include "fontcache.h"
dc67d70b5a45 (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
#endif
9912
1ac8aac92385 (svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents: 9911
diff changeset
    49
#include "spritecache.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    50
3121
2e50f731567a (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
    51
/** The patch values that are used for new games and/or modified in config file */
2e50f731567a (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
    52
Patches _patches_newgame;
2e50f731567a (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
    53
9895
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6338
diff changeset
    54
struct IniFile;
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6338
diff changeset
    55
struct IniItem;
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6338
diff changeset
    56
struct IniGroup;
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6338
diff changeset
    57
struct SettingsMemoryPool;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    58
3628
bd4a6601e5a2 (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
    59
typedef const char *SettingListCallbackProc(const IniItem *item, uint index);
bd4a6601e5a2 (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
    60
typedef void SettingDescProc(IniFile *ini, const SettingDesc *desc, const char *grpname, void *object);
bd4a6601e5a2 (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
    61
typedef void SettingDescProcList(IniFile *ini, const char *grpname, char **list, uint len, SettingListCallbackProc proc);
bd4a6601e5a2 (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
    62
1258
7b078174f796 (svn r1762) -Codechange: renamed 'MemoryPool' to 'SettingsMemoryPool' (we need
truelight
parents: 1247
diff changeset
    63
static void pool_init(SettingsMemoryPool **pool);
7b078174f796 (svn r1762) -Codechange: renamed 'MemoryPool' to 'SettingsMemoryPool' (we need
truelight
parents: 1247
diff changeset
    64
static void *pool_alloc(SettingsMemoryPool **pool, uint size);
7b078174f796 (svn r1762) -Codechange: renamed 'MemoryPool' to 'SettingsMemoryPool' (we need
truelight
parents: 1247
diff changeset
    65
static void *pool_strdup(SettingsMemoryPool **pool, const char *mem, uint size);
7b078174f796 (svn r1762) -Codechange: renamed 'MemoryPool' to 'SettingsMemoryPool' (we need
truelight
parents: 1247
diff changeset
    66
static void pool_free(SettingsMemoryPool **pool);
3900
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3874
diff changeset
    67
static bool IsSignedVarMemType(VarType vt);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    68
1258
7b078174f796 (svn r1762) -Codechange: renamed 'MemoryPool' to 'SettingsMemoryPool' (we need
truelight
parents: 1247
diff changeset
    69
struct SettingsMemoryPool {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    70
	uint pos,size;
1258
7b078174f796 (svn r1762) -Codechange: renamed 'MemoryPool' to 'SettingsMemoryPool' (we need
truelight
parents: 1247
diff changeset
    71
	SettingsMemoryPool *next;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    72
	byte mem[1];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    73
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    74
1258
7b078174f796 (svn r1762) -Codechange: renamed 'MemoryPool' to 'SettingsMemoryPool' (we need
truelight
parents: 1247
diff changeset
    75
static SettingsMemoryPool *pool_new(uint minsize)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    76
{
1258
7b078174f796 (svn r1762) -Codechange: renamed 'MemoryPool' to 'SettingsMemoryPool' (we need
truelight
parents: 1247
diff changeset
    77
	SettingsMemoryPool *p;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    78
	if (minsize < 4096 - 12) minsize = 4096 - 12;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 188
diff changeset
    79
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5835
diff changeset
    80
	p = (SettingsMemoryPool*)malloc(sizeof(SettingsMemoryPool) - 1 + minsize);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    81
	p->pos = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    82
	p->size = minsize;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    83
	p->next = NULL;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    84
	return p;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    85
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    86
1258
7b078174f796 (svn r1762) -Codechange: renamed 'MemoryPool' to 'SettingsMemoryPool' (we need
truelight
parents: 1247
diff changeset
    87
static void pool_init(SettingsMemoryPool **pool)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    88
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    89
	*pool = pool_new(0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    90
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    91
1258
7b078174f796 (svn r1762) -Codechange: renamed 'MemoryPool' to 'SettingsMemoryPool' (we need
truelight
parents: 1247
diff changeset
    92
static void *pool_alloc(SettingsMemoryPool **pool, uint size)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    93
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    94
	uint pos;
1258
7b078174f796 (svn r1762) -Codechange: renamed 'MemoryPool' to 'SettingsMemoryPool' (we need
truelight
parents: 1247
diff changeset
    95
	SettingsMemoryPool *p = *pool;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    96
2450
44dc366c480e (svn r2976) -Fix: Align settings pool items to the size of void* to fix bus errors on 64bit architectures which require aligned variables
tron
parents: 2398
diff changeset
    97
	size = ALIGN(size, sizeof(void*));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    98
9908
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
    99
	/* first check if there's memory in the next pool */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   100
	if (p->next && p->next->pos + size <= p->next->size) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   101
		p = p->next;
9908
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
   102
	/* then check if there's not memory in the cur pool */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   103
	} else if (p->pos + size > p->size) {
1258
7b078174f796 (svn r1762) -Codechange: renamed 'MemoryPool' to 'SettingsMemoryPool' (we need
truelight
parents: 1247
diff changeset
   104
		SettingsMemoryPool *n = pool_new(size);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   105
		*pool = n;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   106
		n->next = p;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 188
diff changeset
   107
		p = n;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   108
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   109
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   110
	pos = p->pos;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   111
	p->pos += size;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   112
	return p->mem + pos;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   113
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   114
1258
7b078174f796 (svn r1762) -Codechange: renamed 'MemoryPool' to 'SettingsMemoryPool' (we need
truelight
parents: 1247
diff changeset
   115
static void *pool_strdup(SettingsMemoryPool **pool, const char *mem, uint size)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   116
{
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5835
diff changeset
   117
	byte *p = (byte*)pool_alloc(pool, size + 1);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   118
	p[size] = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   119
	memcpy(p, mem, size);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   120
	return p;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   121
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   122
1258
7b078174f796 (svn r1762) -Codechange: renamed 'MemoryPool' to 'SettingsMemoryPool' (we need
truelight
parents: 1247
diff changeset
   123
static void pool_free(SettingsMemoryPool **pool)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   124
{
1258
7b078174f796 (svn r1762) -Codechange: renamed 'MemoryPool' to 'SettingsMemoryPool' (we need
truelight
parents: 1247
diff changeset
   125
	SettingsMemoryPool *p = *pool, *n;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   126
	*pool = NULL;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   127
	while (p) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   128
		n = p->next;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   129
		free(p);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   130
		p = n;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   131
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   132
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   133
9908
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
   134
/** structs describing the ini format. */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   135
struct IniItem {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   136
	char *name;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   137
	char *value;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   138
	char *comment;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   139
	IniItem *next;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   140
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   141
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   142
struct IniGroup {
9908
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
   143
	char *name;        ///< name of group
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
   144
	char *comment;     ///<comment for group
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   145
	IniItem *item, **last_item;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   146
	IniGroup *next;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   147
	IniFile *ini;
9908
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
   148
	IniGroupType type; ///< type of group
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   149
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   150
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   151
struct IniFile {
1258
7b078174f796 (svn r1762) -Codechange: renamed 'MemoryPool' to 'SettingsMemoryPool' (we need
truelight
parents: 1247
diff changeset
   152
	SettingsMemoryPool *pool;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   153
	IniGroup *group, **last_group;
9908
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
   154
	char *comment;     ///< last comment in file
0
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
9908
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
   157
/** allocate an inifile object */
9895
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6338
diff changeset
   158
static IniFile *ini_alloc()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   159
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   160
	IniFile *ini;
1258
7b078174f796 (svn r1762) -Codechange: renamed 'MemoryPool' to 'SettingsMemoryPool' (we need
truelight
parents: 1247
diff changeset
   161
	SettingsMemoryPool *pool;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   162
	pool_init(&pool);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   163
	ini = (IniFile*)pool_alloc(&pool, sizeof(IniFile));
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   164
	ini->pool = pool;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   165
	ini->group = NULL;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   166
	ini->last_group = &ini->group;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   167
	ini->comment = NULL;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   168
	return ini;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   169
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   170
9908
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
   171
/** allocate an ini group object */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   172
static IniGroup *ini_group_alloc(IniFile *ini, const char *grpt, int len)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   173
{
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5835
diff changeset
   174
	IniGroup *grp = (IniGroup*)pool_alloc(&ini->pool, sizeof(IniGroup));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   175
	grp->ini = ini;
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5835
diff changeset
   176
	grp->name = (char*)pool_strdup(&ini->pool, grpt, len);
2953
310f58987d7b (svn r3512) Yet more whitespace fixes (mostly by Rubidium)
peter1138
parents: 2952
diff changeset
   177
	if (!strcmp(grp->name, "newgrf") || !strcmp(grp->name, "servers") || !strcmp(grp->name, "bans")) {
705
e213445d82ec (svn r1157) Enhanced the config file (openttd.cfg) to use another section type. "List sections" as opposed to "variable sections" contain a list of values, separated by a new line. This is now used for the [newgrf] group. You have to edit each line in this section from e.g. "0 = firstset.grf" to only "firstset.grf".
dominik
parents: 690
diff changeset
   178
		grp->type = IGT_LIST;
2953
310f58987d7b (svn r3512) Yet more whitespace fixes (mostly by Rubidium)
peter1138
parents: 2952
diff changeset
   179
	} else {
705
e213445d82ec (svn r1157) Enhanced the config file (openttd.cfg) to use another section type. "List sections" as opposed to "variable sections" contain a list of values, separated by a new line. This is now used for the [newgrf] group. You have to edit each line in this section from e.g. "0 = firstset.grf" to only "firstset.grf".
dominik
parents: 690
diff changeset
   180
		grp->type = IGT_VARIABLES;
2953
310f58987d7b (svn r3512) Yet more whitespace fixes (mostly by Rubidium)
peter1138
parents: 2952
diff changeset
   181
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   182
	grp->next = NULL;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   183
	grp->item = NULL;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   184
	grp->comment = NULL;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   185
	grp->last_item = &grp->item;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   186
	*ini->last_group = grp;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   187
	ini->last_group = &grp->next;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   188
	return grp;
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
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   191
static IniItem *ini_item_alloc(IniGroup *group, const char *name, int len)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   192
{
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5835
diff changeset
   193
	IniItem *item = (IniItem*)pool_alloc(&group->ini->pool, sizeof(IniItem));
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5835
diff changeset
   194
	item->name = (char*)pool_strdup(&group->ini->pool, name, len);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   195
	item->next = NULL;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   196
	item->comment = NULL;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   197
	item->value = NULL;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   198
	*group->last_item = item;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   199
	group->last_item = &item->next;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   200
	return item;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   201
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   202
9908
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
   203
/** load an ini file into the "abstract" format */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   204
static IniFile *ini_load(const char *filename)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   205
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   206
	char buffer[1024], c, *s, *t, *e;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   207
	FILE *in;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   208
	IniFile *ini;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   209
	IniGroup *group = NULL;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   210
	IniItem *item;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   211
1329
a8a0d60b0a8e (svn r1833) byte -> char transition: the rest
tron
parents: 1317
diff changeset
   212
	char *comment = NULL;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   213
	uint comment_size = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   214
	uint comment_alloc = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   215
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   216
	ini = ini_alloc();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   217
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   218
	in = fopen(filename, "r");
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   219
	if (in == NULL) return ini;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   220
9908
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
   221
	/* for each line in the file */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   222
	while (fgets(buffer, sizeof(buffer), in)) {
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 188
diff changeset
   223
9908
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
   224
		/* trim whitespace from the left side */
3598
0cf4d5726bf8 (svn r4489) - Codechange: some small cleanups in the settings-parser code, mainly substituting terminating 0 characters with '\0'.
Darkvater
parents: 3596
diff changeset
   225
		for (s = buffer; *s == ' ' || *s == '\t'; s++);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   226
9908
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
   227
		/* trim whitespace from right side. */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   228
		e = s + strlen(s);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   229
		while (e > s && ((c=e[-1]) == '\n' || c == '\r' || c == ' ' || c == '\t')) e--;
3598
0cf4d5726bf8 (svn r4489) - Codechange: some small cleanups in the settings-parser code, mainly substituting terminating 0 characters with '\0'.
Darkvater
parents: 3596
diff changeset
   230
		*e = '\0';
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   231
9908
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
   232
		/* skip comments and empty lines */
4969
e68b7e0b27e3 (svn r6972) - Codechange: Allow standard ini-file style comments
peter1138
parents: 4870
diff changeset
   233
		if (*s == '#' || *s == ';' || *s == '\0') {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   234
			uint ns = comment_size + (e - s + 1);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   235
			uint a = comment_alloc;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   236
			uint pos;
9908
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
   237
			/* add to comment */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   238
			if (ns > a) {
5852
cb3f71b16e1a (svn r8055) -Codechange: Replace the different max, dmax, maxu whatever macros by a simple template function max(), that requires two arguments of the same type. While I'm at it change a variable called "max" to "maxval" in a function that calls max().
celestar
parents: 5838
diff changeset
   239
				a = max(a, 128U);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   240
				do a*=2; while (a < ns);
5860
7fdc9b423ba1 (svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents: 5852
diff changeset
   241
				comment = ReallocT(comment, comment_alloc = a);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   242
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   243
			pos = comment_size;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   244
			comment_size += (e - s + 1);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   245
			comment[pos + e - s] = '\n'; // comment newline
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   246
			memcpy(comment + pos, s, e - s); // copy comment contents
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   247
			continue;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   248
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   249
9908
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
   250
		/* it's a group? */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   251
		if (s[0] == '[') {
4077
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4065
diff changeset
   252
			if (e[-1] != ']') {
5827
20879afb77f6 (svn r8013) -Codechange (r6921, rUnknown): Show the error message of corrupt or missing (own) files
Darkvater
parents: 5726
diff changeset
   253
				ShowInfoF("ini: invalid group name '%s'", buffer);
4077
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4065
diff changeset
   254
			} else {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   255
				e--;
4077
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4065
diff changeset
   256
			}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   257
			s++; // skip [
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   258
			group = ini_group_alloc(ini, s, e - s);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   259
			if (comment_size) {
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5835
diff changeset
   260
				group->comment = (char*)pool_strdup(&ini->pool, comment, comment_size);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   261
				comment_size = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   262
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   263
		} else if (group) {
9908
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
   264
			/* find end of keyname */
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
   265
			if (*s == '\"') {
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
   266
				s++;
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
   267
				for (t = s; *t != '\0' && *t != '\"'; t++);
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
   268
				if (*t == '\"') *t = ' ';
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
   269
			} else {
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
   270
				for (t = s; *t != '\0' && *t != '=' && *t != '\t' && *t != ' '; t++);
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
   271
			}
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 188
diff changeset
   272
9908
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
   273
			/* it's an item in an existing group */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   274
			item = ini_item_alloc(group, s, t-s);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   275
			if (comment_size) {
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5835
diff changeset
   276
				item->comment = (char*)pool_strdup(&ini->pool, comment, comment_size);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   277
				comment_size = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   278
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   279
9908
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
   280
			/* find start of parameter */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   281
			while (*t == '=' || *t == ' ' || *t == '\t') t++;
759
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 738
diff changeset
   282
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 738
diff changeset
   283
9908
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
   284
			/* remove starting quotation marks */
2952
6a26eeda9679 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2923
diff changeset
   285
			if (*t == '\"') t++;
9908
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
   286
			/* remove ending quotation marks */
759
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 738
diff changeset
   287
			e = t + strlen(t);
3598
0cf4d5726bf8 (svn r4489) - Codechange: some small cleanups in the settings-parser code, mainly substituting terminating 0 characters with '\0'.
Darkvater
parents: 3596
diff changeset
   288
			if (e > t && e[-1] == '\"') e--;
0cf4d5726bf8 (svn r4489) - Codechange: some small cleanups in the settings-parser code, mainly substituting terminating 0 characters with '\0'.
Darkvater
parents: 3596
diff changeset
   289
			*e = '\0';
759
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 738
diff changeset
   290
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5835
diff changeset
   291
			item->value = (char*)pool_strdup(&ini->pool, t, e - t);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   292
		} else {
9908
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
   293
			/* it's an orphan item */
5827
20879afb77f6 (svn r8013) -Codechange (r6921, rUnknown): Show the error message of corrupt or missing (own) files
Darkvater
parents: 5726
diff changeset
   294
			ShowInfoF("ini: '%s' outside of group", buffer);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   295
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   296
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   297
3615
59b36aaa050a (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   298
	if (comment_size > 0) {
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5835
diff changeset
   299
		ini->comment = (char*)pool_strdup(&ini->pool, comment, comment_size);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   300
		comment_size = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   301
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   302
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   303
	free(comment);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   304
	fclose(in);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   305
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   306
	return ini;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   307
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   308
9908
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
   309
/** lookup a group or make a new one */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   310
static IniGroup *ini_getgroup(IniFile *ini, const char *name, int len)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   311
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   312
	IniGroup *group;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   313
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   314
	if (len == -1) len = strlen(name);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   315
9908
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
   316
	/* does it exist already? */
2952
6a26eeda9679 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2923
diff changeset
   317
	for (group = ini->group; group; group = group->next)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   318
		if (!memcmp(group->name, name, len) && group->name[len] == 0)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   319
			return group;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   320
9908
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
   321
	/* otherwise make a new one */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   322
	group = ini_group_alloc(ini, name, len);
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5835
diff changeset
   323
	group->comment = (char*)pool_strdup(&ini->pool, "\n", 1);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   324
	return group;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   325
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   326
9908
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
   327
/** lookup an item or make a new one */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   328
static IniItem *ini_getitem(IniGroup *group, const char *name, bool create)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   329
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   330
	IniItem *item;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   331
	uint len = strlen(name);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   332
2952
6a26eeda9679 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2923
diff changeset
   333
	for (item = group->item; item; item = item->next)
2972
f9fcee7f3815 (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
   334
		if (strcmp(item->name, name) == 0) return item;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 188
diff changeset
   335
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   336
	if (!create) return NULL;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   337
9908
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
   338
	/* otherwise make a new one */
2972
f9fcee7f3815 (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
   339
	return ini_item_alloc(group, name, len);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   340
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   341
9908
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
   342
/** save ini file from the "abstract" format. */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   343
static bool ini_save(const char *filename, IniFile *ini)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   344
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   345
	FILE *f;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   346
	IniGroup *group;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   347
	IniItem *item;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 188
diff changeset
   348
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   349
	f = fopen(filename, "w");
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   350
	if (f == NULL) return false;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   351
2919
5a867896b255 (svn r3475) - Fix: you couldn't remove an item from a list-type of config ingame from the configuration file. Whatever you did, upon restart of OpenTTD those items were still there. To fix this we initialize the first item to NULL in SaveList as it is rebuilt anyways fully.
Darkvater
parents: 2916
diff changeset
   352
	for (group = ini->group; group != NULL; group = group->next) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   353
		if (group->comment) fputs(group->comment, f);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   354
		fprintf(f, "[%s]\n", group->name);
2919
5a867896b255 (svn r3475) - Fix: you couldn't remove an item from a list-type of config ingame from the configuration file. Whatever you did, upon restart of OpenTTD those items were still there. To fix this we initialize the first item to NULL in SaveList as it is rebuilt anyways fully.
Darkvater
parents: 2916
diff changeset
   355
		for (item = group->item; item != NULL; item = item->next) {
3600
8ac0930f937a (svn r4491) - Codechange: handle IGT_LIST types just as the other types with a proper name and value setting (for example for newgrf parameters).
Darkvater
parents: 3599
diff changeset
   356
			assert(item->value != NULL);
8ac0930f937a (svn r4491) - Codechange: handle IGT_LIST types just as the other types with a proper name and value setting (for example for newgrf parameters).
Darkvater
parents: 3599
diff changeset
   357
			if (item->comment != NULL) fputs(item->comment, f);
8ac0930f937a (svn r4491) - Codechange: handle IGT_LIST types just as the other types with a proper name and value setting (for example for newgrf parameters).
Darkvater
parents: 3599
diff changeset
   358
9908
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
   359
			/* protect item->name with quotes if needed */
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
   360
			if (strchr(item->name, ' ') != NULL) {
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
   361
				fprintf(f, "\"%s\"", item->name);
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
   362
			} else {
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
   363
				fprintf(f, "%s", item->name);
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
   364
			}
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
   365
4434
4175805666a5 (svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents: 4431
diff changeset
   366
			/* Don't give an equal sign to list items that don't have a parameter */
3600
8ac0930f937a (svn r4491) - Codechange: handle IGT_LIST types just as the other types with a proper name and value setting (for example for newgrf parameters).
Darkvater
parents: 3599
diff changeset
   367
			if (group->type == IGT_LIST && *item->value == '\0') {
9908
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
   368
				fprintf(f, "\n");
4077
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4065
diff changeset
   369
			} else {
9908
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
   370
				fprintf(f, " = %s\n", item->value);
4077
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4065
diff changeset
   371
			}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   372
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   373
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   374
	if (ini->comment) fputs(ini->comment, f);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   375
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   376
	fclose(f);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   377
	return true;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   378
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   379
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   380
static void ini_free(IniFile *ini)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   381
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   382
	pool_free(&ini->pool);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   383
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   384
3615
59b36aaa050a (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   385
/** Find the index value of a ONEofMANY type in a string seperated by |
2972
f9fcee7f3815 (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
   386
 * @param many full domain of values the ONEofMANY setting can have
f9fcee7f3815 (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
   387
 * @param one the current value of the setting for which a value needs found
f9fcee7f3815 (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
 * @param onelen force calculation of the *one parameter
f9fcee7f3815 (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
 * @return the integer index of the full-list, or -1 if not found */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   390
static int lookup_oneofmany(const char *many, const char *one, int onelen)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   391
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   392
	const char *s;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   393
	int idx;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   394
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   395
	if (onelen == -1) onelen = strlen(one);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   396
9908
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
   397
	/* check if it's an integer */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   398
	if (*one >= '0' && *one <= '9')
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   399
		return strtoul(one, NULL, 0);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 188
diff changeset
   400
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   401
	idx = 0;
2952
6a26eeda9679 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2923
diff changeset
   402
	for (;;) {
9908
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
   403
		/* find end of item */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   404
		s = many;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   405
		while (*s != '|' && *s != 0) s++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   406
		if (s - many == onelen && !memcmp(one, many, onelen)) return idx;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   407
		if (*s == 0) return -1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   408
		many = s + 1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   409
		idx++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   410
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   411
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   412
3615
59b36aaa050a (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   413
/** Find the set-integer value MANYofMANY type in a string
2972
f9fcee7f3815 (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
   414
 * @param many full domain of values the MANYofMANY setting can have
f9fcee7f3815 (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
   415
 * @param str the current string value of the setting, each individual
9909
dce9a6923bb7 (svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents: 9908
diff changeset
   416
 * of seperated by a whitespace,tab or | character
2972
f9fcee7f3815 (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
   417
 * @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
   418
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
   419
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   420
	const char *s;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   421
	int r;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   422
	uint32 res = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   423
2952
6a26eeda9679 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2923
diff changeset
   424
	for (;;) {
9908
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
   425
		/* skip "whitespace" */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   426
		while (*str == ' ' || *str == '\t' || *str == '|') str++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   427
		if (*str == 0) break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   428
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   429
		s = str;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   430
		while (*s != 0 && *s != ' ' && *s != '\t' && *s != '|') s++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   431
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   432
		r = lookup_oneofmany(many, str, s - str);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   433
		if (r == -1) return (uint32)-1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   434
2972
f9fcee7f3815 (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
   435
		SETBIT(res, r); // value found, set it
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   436
		if (*s == 0) break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   437
		str = s + 1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   438
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   439
	return res;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   440
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   441
2972
f9fcee7f3815 (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
   442
/** Parse an integerlist string and set each found value
3615
59b36aaa050a (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   443
 * @param p the string to be parsed. Each element in the list is seperated by a
59b36aaa050a (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   444
 * comma or a space character
2972
f9fcee7f3815 (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
   445
 * @param items pointer to the integerlist-array that will be filled with values
f9fcee7f3815 (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
   446
 * @param maxitems the maximum number of elements the integerlist-array has
f9fcee7f3815 (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
   447
 * @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
   448
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
   449
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   450
	int n = 0, v;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   451
	char *end;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   452
2952
6a26eeda9679 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2923
diff changeset
   453
	for (;;) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   454
		v = strtol(p, &end, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   455
		if (p == end || n == maxitems) return -1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   456
		p = end;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   457
		items[n++] = v;
3598
0cf4d5726bf8 (svn r4489) - Codechange: some small cleanups in the settings-parser code, mainly substituting terminating 0 characters with '\0'.
Darkvater
parents: 3596
diff changeset
   458
		if (*p == '\0') break;
3599
c24dba47af62 (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
   459
		if (*p != ',' && *p != ' ') return -1;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   460
		p++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   461
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   462
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   463
	return n;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   464
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   465
3615
59b36aaa050a (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   466
/** Load parsed string-values into an integer-array (intlist)
2972
f9fcee7f3815 (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
   467
 * @param str the string that contains the values (and will be parsed)
f9fcee7f3815 (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
 * @param array pointer to the integer-arrays that will be filled
f9fcee7f3815 (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
   469
 * @param nelems the number of elements the array holds. Maximum is 64 elements
f9fcee7f3815 (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
   470
 * @param type the type of elements the array holds (eg INT8, UINT16, etc.)
f9fcee7f3815 (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
   471
 * @return return true on success and false on error */
3115
1f4949f5dc5d (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
   472
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
   473
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   474
	int items[64];
2972
f9fcee7f3815 (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
   475
	int i, nitems;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 188
diff changeset
   476
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   477
	if (str == NULL) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   478
		memset(items, 0, sizeof(items));
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   479
		nitems = nelems;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   480
	} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   481
		nitems = parse_intlist(str, items, lengthof(items));
2972
f9fcee7f3815 (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
   482
		if (nitems != nelems) return false;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   483
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   484
2952
6a26eeda9679 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2923
diff changeset
   485
	switch (type) {
3115
1f4949f5dc5d (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
   486
	case SLE_VAR_BL:
1f4949f5dc5d (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
   487
	case SLE_VAR_I8:
1f4949f5dc5d (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
	case SLE_VAR_U8:
2952
6a26eeda9679 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2923
diff changeset
   489
		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
   490
		break;
3115
1f4949f5dc5d (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
   491
	case SLE_VAR_I16:
1f4949f5dc5d (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
	case SLE_VAR_U16:
2952
6a26eeda9679 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2923
diff changeset
   493
		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
   494
		break;
3115
1f4949f5dc5d (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
	case SLE_VAR_I32:
1f4949f5dc5d (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
	case SLE_VAR_U32:
2952
6a26eeda9679 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2923
diff changeset
   497
		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
   498
		break;
2972
f9fcee7f3815 (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
   499
	default: NOT_REACHED();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   500
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   501
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   502
	return true;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   503
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   504
3615
59b36aaa050a (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   505
/** Convert an integer-array (intlist) to a string representation. Each value
59b36aaa050a (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   506
 * is seperated by a comma or a space character
2972
f9fcee7f3815 (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
   507
 * @param buf output buffer where the string-representation will be stored
f9fcee7f3815 (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
   508
 * @param array pointer to the integer-arrays that is read from
f9fcee7f3815 (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
   509
 * @param nelems the number of elements the array holds.
f9fcee7f3815 (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
   510
 * @param type the type of elements the array holds (eg INT8, UINT16, etc.) */
3115
1f4949f5dc5d (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
   511
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
   512
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   513
	int i, v = 0;
2972
f9fcee7f3815 (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
   514
	const byte *p = (const byte*)array;
2952
6a26eeda9679 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2923
diff changeset
   515
6a26eeda9679 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2923
diff changeset
   516
	for (i = 0; i != nelems; i++) {
6a26eeda9679 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2923
diff changeset
   517
		switch (type) {
3115
1f4949f5dc5d (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
   518
		case SLE_VAR_BL:
1f4949f5dc5d (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
   519
		case SLE_VAR_I8:  v = *(int8*)p;   p += 1; break;
1f4949f5dc5d (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
   520
		case SLE_VAR_U8:  v = *(byte*)p;   p += 1; break;
1f4949f5dc5d (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
		case SLE_VAR_I16: v = *(int16*)p;  p += 2; break;
1f4949f5dc5d (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
   522
		case SLE_VAR_U16: v = *(uint16*)p; p += 2; break;
1f4949f5dc5d (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
   523
		case SLE_VAR_I32: v = *(int32*)p;  p += 4; break;
1f4949f5dc5d (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
   524
		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
   525
		default: NOT_REACHED();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   526
		}
2972
f9fcee7f3815 (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
   527
		buf += sprintf(buf, (i == 0) ? "%d" : ",%d", v);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   528
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   529
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   530
3615
59b36aaa050a (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   531
/** Convert a ONEofMANY structure to a string representation.
2972
f9fcee7f3815 (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
 * @param buf output buffer where the string-representation will be stored
f9fcee7f3815 (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
   533
 * @param many the full-domain string of possible values
f9fcee7f3815 (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
   534
 * @param id the value of the variable and whose string-representation must be found */
2973
350705be2913 (svn r3548) - [Patches]: rework two loops in make_oneofmany() and make_manyofmany()
Darkvater
parents: 2972
diff changeset
   535
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
   536
{
2973
350705be2913 (svn r3548) - [Patches]: rework two loops in make_oneofmany() and make_manyofmany()
Darkvater
parents: 2972
diff changeset
   537
	int orig_id = id;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   538
9908
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
   539
	/* Look for the id'th element */
2973
350705be2913 (svn r3548) - [Patches]: rework two loops in make_oneofmany() and make_manyofmany()
Darkvater
parents: 2972
diff changeset
   540
	while (--id >= 0) {
350705be2913 (svn r3548) - [Patches]: rework two loops in make_oneofmany() and make_manyofmany()
Darkvater
parents: 2972
diff changeset
   541
		for (; *many != '|'; many++) {
350705be2913 (svn r3548) - [Patches]: rework two loops in make_oneofmany() and make_manyofmany()
Darkvater
parents: 2972
diff changeset
   542
			if (*many == '\0') { // not found
350705be2913 (svn r3548) - [Patches]: rework two loops in make_oneofmany() and make_manyofmany()
Darkvater
parents: 2972
diff changeset
   543
				sprintf(buf, "%d", orig_id);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   544
				return;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   545
			}
2973
350705be2913 (svn r3548) - [Patches]: rework two loops in make_oneofmany() and make_manyofmany()
Darkvater
parents: 2972
diff changeset
   546
		}
350705be2913 (svn r3548) - [Patches]: rework two loops in make_oneofmany() and make_manyofmany()
Darkvater
parents: 2972
diff changeset
   547
		many++; // pass the |-character
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   548
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   549
9908
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
   550
	/* copy string until next item (|) or the end of the list if this is the last one */
2973
350705be2913 (svn r3548) - [Patches]: rework two loops in make_oneofmany() and make_manyofmany()
Darkvater
parents: 2972
diff changeset
   551
	while (*many != '\0' && *many != '|') *buf++ = *many++;
350705be2913 (svn r3548) - [Patches]: rework two loops in make_oneofmany() and make_manyofmany()
Darkvater
parents: 2972
diff changeset
   552
	*buf = '\0';
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   553
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   554
3615
59b36aaa050a (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   555
/** Convert a MANYofMANY structure to a string representation.
2972
f9fcee7f3815 (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
   556
 * @param buf output buffer where the string-representation will be stored
f9fcee7f3815 (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
   557
 * @param many the full-domain string of possible values
f9fcee7f3815 (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
   558
 * @param x the value of the variable and whose string-representation must
f9fcee7f3815 (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
   559
 *        be found in the bitmasked many string */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   560
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
   561
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   562
	const char *start;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   563
	int i = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   564
	bool init = true;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   565
2973
350705be2913 (svn r3548) - [Patches]: rework two loops in make_oneofmany() and make_manyofmany()
Darkvater
parents: 2972
diff changeset
   566
	for (; x != 0; x >>= 1, i++) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   567
		start = many;
2973
350705be2913 (svn r3548) - [Patches]: rework two loops in make_oneofmany() and make_manyofmany()
Darkvater
parents: 2972
diff changeset
   568
		while (*many != 0 && *many != '|') many++; // advance to the next element
350705be2913 (svn r3548) - [Patches]: rework two loops in make_oneofmany() and make_manyofmany()
Darkvater
parents: 2972
diff changeset
   569
350705be2913 (svn r3548) - [Patches]: rework two loops in make_oneofmany() and make_manyofmany()
Darkvater
parents: 2972
diff changeset
   570
		if (HASBIT(x, 0)) { // item found, copy it
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   571
			if (!init) *buf++ = '|';
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   572
			init = false;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   573
			if (start == many) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   574
				buf += sprintf(buf, "%d", i);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   575
			} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   576
				memcpy(buf, start, many - start);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   577
				buf += many - start;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   578
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   579
		}
2973
350705be2913 (svn r3548) - [Patches]: rework two loops in make_oneofmany() and make_manyofmany()
Darkvater
parents: 2972
diff changeset
   580
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   581
		if (*many == '|') many++;
2973
350705be2913 (svn r3548) - [Patches]: rework two loops in make_oneofmany() and make_manyofmany()
Darkvater
parents: 2972
diff changeset
   582
	}
350705be2913 (svn r3548) - [Patches]: rework two loops in make_oneofmany() and make_manyofmany()
Darkvater
parents: 2972
diff changeset
   583
350705be2913 (svn r3548) - [Patches]: rework two loops in make_oneofmany() and make_manyofmany()
Darkvater
parents: 2972
diff changeset
   584
	*buf = '\0';
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   585
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   586
2972
f9fcee7f3815 (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
   587
/** Convert a string representation (external) of a setting to the internal rep.
f9fcee7f3815 (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
   588
 * @param desc SettingDesc struct that holds all information about the variable
f9fcee7f3815 (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
   589
 * @param str input string that will be parsed based on the type of desc
f9fcee7f3815 (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
   590
 * @return return the parsed value of the setting */
3115
1f4949f5dc5d (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
   591
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
   592
{
3115
1f4949f5dc5d (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
   593
	switch (desc->cmd) {
2972
f9fcee7f3815 (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
   594
	case SDT_NUMX: {
f9fcee7f3815 (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
   595
		char *end;
2991
4582583fba15 (svn r3567) -Fix: for once and for all, use 'unsigned long' if you want to cast something
truelight
parents: 2975
diff changeset
   596
		unsigned long val = strtoul(str, &end, 0);
2972
f9fcee7f3815 (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
   597
		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
   598
		return (void*)val;
2972
f9fcee7f3815 (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
   599
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   600
	case SDT_ONEOFMANY: {
2972
f9fcee7f3815 (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
   601
		long r = lookup_oneofmany(desc->many, str, -1);
9906
6f41b8713b65 (svn r9674) [gamebalance] -Sync: r9322:9420 from trunk
celestar
parents: 9904
diff changeset
   602
		/* if the first attempt of conversion from string to the appropriate value fails,
6f41b8713b65 (svn r9674) [gamebalance] -Sync: r9322:9420 from trunk
celestar
parents: 9904
diff changeset
   603
		 * look if we have defined a converter from old value to new value. */
6f41b8713b65 (svn r9674) [gamebalance] -Sync: r9322:9420 from trunk
celestar
parents: 9904
diff changeset
   604
		if (r == -1 && desc->proc_cnvt != NULL) r = desc->proc_cnvt(str);
6f41b8713b65 (svn r9674) [gamebalance] -Sync: r9322:9420 from trunk
celestar
parents: 9904
diff changeset
   605
		if (r != -1) return (void*)r; //and here goes converted value
6f41b8713b65 (svn r9674) [gamebalance] -Sync: r9322:9420 from trunk
celestar
parents: 9904
diff changeset
   606
		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
   607
		return 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   608
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   609
	case SDT_MANYOFMANY: {
2972
f9fcee7f3815 (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
   610
		unsigned long r = lookup_manyofmany(desc->many, str);
2923
272d1b0962bc (svn r3479) -Fix: fixed warnings on 64bit platforms (anyway, most 64bit platforms)
truelight
parents: 2919
diff changeset
   611
		if (r != (unsigned long)-1) return (void*)r;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   612
		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
   613
		return 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   614
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   615
	case SDT_BOOLX:
2972
f9fcee7f3815 (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
   616
		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
   617
			return (void*)true;
2972
f9fcee7f3815 (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
   618
		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
   619
			return (void*)false;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   620
		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
   621
		break;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 188
diff changeset
   622
3115
1f4949f5dc5d (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
   623
	case SDT_STRING:
1f4949f5dc5d (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
   624
	case SDT_INTLIST: return str;
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5835
diff changeset
   625
	default: break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   626
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   627
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   628
	return NULL;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   629
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   630
3115
1f4949f5dc5d (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
   631
/** Set the value of a setting and if needed clamp the value to
1f4949f5dc5d (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
   632
 * the preset minimum and maximum.
1f4949f5dc5d (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
 * @param ptr the variable itself
1f4949f5dc5d (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
 * @param sd pointer to the 'information'-database of the variable
1f4949f5dc5d (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
   635
 * @param val signed long version of the new value
1f4949f5dc5d (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
 * @pre SettingDesc is of type SDT_BOOLX, SDT_NUMX,
1f4949f5dc5d (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
 * SDT_ONEOFMANY or SDT_MANYOFMANY. Other types are not supported as of now */
1f4949f5dc5d (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
static void Write_ValidateSetting(void *ptr, const SettingDesc *sd, int32 val)
1f4949f5dc5d (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
{
1f4949f5dc5d (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
   640
	const SettingDescBase *sdb = &sd->desc;
1f4949f5dc5d (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
   641
4077
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4065
diff changeset
   642
	if (sdb->cmd != SDT_BOOLX &&
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4065
diff changeset
   643
			sdb->cmd != SDT_NUMX &&
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4065
diff changeset
   644
			sdb->cmd != SDT_ONEOFMANY &&
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4065
diff changeset
   645
			sdb->cmd != SDT_MANYOFMANY) {
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4065
diff changeset
   646
		return;
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4065
diff changeset
   647
	}
3115
1f4949f5dc5d (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
   648
1f4949f5dc5d (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
   649
	/* We cannot know the maximum value of a bitset variable, so just have faith */
3352
49d580a11385 (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
   650
	if (sdb->cmd != SDT_MANYOFMANY) {
49d580a11385 (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
   651
		/* We need to take special care of the uint32 type as we receive from the function
49d580a11385 (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
   652
		 * a signed integer. While here also bail out on 64-bit settings as those are not
49d580a11385 (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
   653
		 * supported. Unsigned 8 and 16-bit variables are safe since they fit into a signed
49d580a11385 (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
   654
		 * 32-bit variable
49d580a11385 (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
   655
		 * TODO: Support 64-bit settings/variables */
49d580a11385 (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
   656
		switch (GetVarMemType(sd->save.conv)) {
49d580a11385 (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
   657
			case SLE_VAR_BL:
49d580a11385 (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
   658
			case SLE_VAR_I8:
49d580a11385 (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
   659
			case SLE_VAR_U8:
49d580a11385 (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
   660
			case SLE_VAR_I16:
49d580a11385 (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
   661
			case SLE_VAR_U16:
49d580a11385 (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
   662
			case SLE_VAR_I32: {
49d580a11385 (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
   663
				/* Override the minimum value. No value below sdb->min, except special value 0 */
49d580a11385 (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
   664
				int32 min = ((sdb->flags & SGF_0ISDISABLED) && val <= sdb->min) ? 0 : sdb->min;
49d580a11385 (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
   665
				val = clamp(val, min, sdb->max);
49d580a11385 (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
   666
			} break;
49d580a11385 (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
   667
			case SLE_VAR_U32: {
49d580a11385 (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
   668
				/* Override the minimum value. No value below sdb->min, except special value 0 */
49d580a11385 (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
   669
				uint min = ((sdb->flags & SGF_0ISDISABLED) && (uint)val <= (uint)sdb->min) ? 0 : sdb->min;
49d580a11385 (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
   670
				WriteValue(ptr, SLE_VAR_U32, (int64)clampu(val, min, sdb->max));
49d580a11385 (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
   671
				return;
49d580a11385 (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
   672
			}
49d580a11385 (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
   673
			case SLE_VAR_I64:
49d580a11385 (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
   674
			case SLE_VAR_U64:
49d580a11385 (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
   675
			default: NOT_REACHED(); break;
49d580a11385 (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
   676
		}
49d580a11385 (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
   677
	}
3115
1f4949f5dc5d (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
   678
1f4949f5dc5d (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
   679
	WriteValue(ptr, sd->save.conv, (int64)val);
1f4949f5dc5d (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
   680
}
1f4949f5dc5d (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
   681
2972
f9fcee7f3815 (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
   682
/** Load values from a group of an IniFile structure into the internal representation
f9fcee7f3815 (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
   683
 * @param ini pointer to IniFile structure that holds administrative information
3615
59b36aaa050a (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   684
 * @param sd pointer to SettingDesc structure whose internally pointed variables will
2972
f9fcee7f3815 (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
   685
 *        be given values
9909
dce9a6923bb7 (svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents: 9908
diff changeset
   686
 * @param grpname the group of the IniFile to search in for the new values
dce9a6923bb7 (svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents: 9908
diff changeset
   687
 * @param object pointer to the object been loaded */
3115
1f4949f5dc5d (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
   688
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
   689
{
3115
1f4949f5dc5d (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
   690
	IniGroup *group;
1f4949f5dc5d (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
   691
	IniGroup *group_def = ini_getgroup(ini, grpname, -1);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   692
	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
   693
	const void *p;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   694
	void *ptr;
3115
1f4949f5dc5d (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
   695
	const char *s;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   696
3115
1f4949f5dc5d (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
   697
	for (; sd->save.cmd != SL_END; sd++) {
1f4949f5dc5d (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
   698
		const SettingDescBase *sdb = &sd->desc;
1f4949f5dc5d (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
   699
		const SaveLoad        *sld = &sd->save;
1f4949f5dc5d (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
   700
3117
8066b8d0802b (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
   701
		if (!SlIsObjectCurrentlyValid(sld->version_from, sld->version_to)) continue;
8066b8d0802b (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
   702
9908
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
   703
		/* XXX - wtf is this?? (group override?) */
3115
1f4949f5dc5d (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
   704
		s = strchr(sdb->name, '.');
2972
f9fcee7f3815 (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
   705
		if (s != NULL) {
3115
1f4949f5dc5d (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
   706
			group = ini_getgroup(ini, sdb->name, s - sdb->name);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   707
			s++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   708
		} else {
3115
1f4949f5dc5d (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
   709
			s = sdb->name;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   710
			group = group_def;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   711
		}
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 188
diff changeset
   712
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   713
		item = ini_getitem(group, s, false);
3115
1f4949f5dc5d (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
   714
		p = (item == NULL) ? sdb->def : string_to_val(sdb, item->value);
5141
05a806850445 (svn r7231) -Codechange: rename ini_get_variable to GetVariableAddress for use both in settings.c
Darkvater
parents: 5116
diff changeset
   715
		ptr = GetVariableAddress(object, sld);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 188
diff changeset
   716
3115
1f4949f5dc5d (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
   717
		switch (sdb->cmd) {
2972
f9fcee7f3815 (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
   718
		case SDT_BOOLX: /* All four are various types of (integer) numbers */
f9fcee7f3815 (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
   719
		case SDT_NUMX:
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   720
		case SDT_ONEOFMANY:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   721
		case SDT_MANYOFMANY:
3115
1f4949f5dc5d (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
   722
			Write_ValidateSetting(ptr, sd, (unsigned long)p); break;
1f4949f5dc5d (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
   723
1f4949f5dc5d (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
   724
		case SDT_STRING:
1f4949f5dc5d (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
   725
			switch (GetVarMemType(sld->conv)) {
1f4949f5dc5d (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
   726
				case SLE_VAR_STRB:
4255
5cb4bcf7c83f (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
   727
				case SLE_VAR_STRBQ:
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5835
diff changeset
   728
					if (p != NULL) ttd_strlcpy((char*)ptr, (const char*)p, sld->length);
4255
5cb4bcf7c83f (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
   729
					break;
5cb4bcf7c83f (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
   730
				case SLE_VAR_STR:
3115
1f4949f5dc5d (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
   731
				case SLE_VAR_STRQ:
4255
5cb4bcf7c83f (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
   732
					if (p != NULL) {
5cb4bcf7c83f (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
   733
						free(*(char**)ptr);
5cb4bcf7c83f (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
   734
						*(char**)ptr = strdup((const char*)p);
5cb4bcf7c83f (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
   735
					}
3115
1f4949f5dc5d (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
   736
					break;
3192
5ac5072bf4b6 (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
   737
				case SLE_VAR_CHAR: *(char*)ptr = *(char*)p; break;
3115
1f4949f5dc5d (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
   738
				default: NOT_REACHED(); break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   739
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   740
			break;
2972
f9fcee7f3815 (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
   741
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   742
		case SDT_INTLIST: {
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5835
diff changeset
   743
			if (!load_intlist((const char*)p, ptr, sld->length, GetVarMemType(sld->conv)))
3115
1f4949f5dc5d (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
   744
				ShowInfoF("ini: error in array '%s'", sdb->name);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   745
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   746
		}
2972
f9fcee7f3815 (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
   747
		default: NOT_REACHED(); break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   748
		}
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 188
diff changeset
   749
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   750
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   751
3615
59b36aaa050a (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   752
/** Save the values of settings to the inifile.
2972
f9fcee7f3815 (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
   753
 * @param ini pointer to IniFile structure
3615
59b36aaa050a (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   754
 * @param sd read-only SettingDesc structure which contains the unmodified,
2972
f9fcee7f3815 (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
   755
 *        loaded values of the configuration file and various information about it
f9fcee7f3815 (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
   756
 * @param grpname holds the name of the group (eg. [network]) where these will be saved
9909
dce9a6923bb7 (svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents: 9908
diff changeset
   757
 * @param object pointer to the object been saved
4000
bab1ebc37da0 (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
   758
 * The function works as follows: for each item in the SettingDesc structure we
bab1ebc37da0 (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
   759
 * have a look if the value has changed since we started the game (the original
bab1ebc37da0 (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
   760
 * values are reloaded when saving). If settings indeed have changed, we get
bab1ebc37da0 (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
   761
 * these and save them.
bab1ebc37da0 (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
   762
 */
3115
1f4949f5dc5d (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
   763
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
   764
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   765
	IniGroup *group_def = NULL, *group;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   766
	IniItem *item;
3115
1f4949f5dc5d (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
   767
	char buf[512];
1f4949f5dc5d (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
   768
	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
   769
	void *ptr;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   770
3115
1f4949f5dc5d (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
   771
	for (; sd->save.cmd != SL_END; sd++) {
1f4949f5dc5d (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
   772
		const SettingDescBase *sdb = &sd->desc;
1f4949f5dc5d (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
   773
		const SaveLoad        *sld = &sd->save;
1f4949f5dc5d (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
   774
1f4949f5dc5d (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
   775
		/* If the setting is not saved to the configuration
1f4949f5dc5d (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
   776
		 * file, just continue with the next setting */
3117
8066b8d0802b (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
   777
		if (!SlIsObjectCurrentlyValid(sld->version_from, sld->version_to)) continue;
3115
1f4949f5dc5d (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
   778
		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
   779
9908
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
   780
		/* XXX - wtf is this?? (group override?) */
3115
1f4949f5dc5d (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
   781
		s = strchr(sdb->name, '.');
2972
f9fcee7f3815 (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
   782
		if (s != NULL) {
3115
1f4949f5dc5d (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
   783
			group = ini_getgroup(ini, sdb->name, s - sdb->name);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   784
			s++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   785
		} else {
2972
f9fcee7f3815 (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
   786
			if (group_def == NULL) group_def = ini_getgroup(ini, grpname, -1);
3115
1f4949f5dc5d (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
   787
			s = sdb->name;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   788
			group = group_def;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   789
		}
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 188
diff changeset
   790
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   791
		item = ini_getitem(group, s, true);
5141
05a806850445 (svn r7231) -Codechange: rename ini_get_variable to GetVariableAddress for use both in settings.c
Darkvater
parents: 5116
diff changeset
   792
		ptr = GetVariableAddress(object, sld);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 188
diff changeset
   793
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   794
		if (item->value != NULL) {
9908
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
   795
			/* check if the value is the same as the old value */
3115
1f4949f5dc5d (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
   796
			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
   797
2972
f9fcee7f3815 (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
   798
			/* The main type of a variable/setting is in bytes 8-15
4549
60410aa1aa88 (svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents: 4511
diff changeset
   799
			 * The subtype (what kind of numbers do we have there) is in 0-7 */
3115
1f4949f5dc5d (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
   800
			switch (sdb->cmd) {
2972
f9fcee7f3815 (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
   801
			case SDT_BOOLX:
f9fcee7f3815 (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
   802
			case SDT_NUMX:
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   803
			case SDT_ONEOFMANY:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   804
			case SDT_MANYOFMANY:
3115
1f4949f5dc5d (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
   805
				switch (GetVarMemType(sld->conv)) {
1f4949f5dc5d (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
   806
				case SLE_VAR_BL:
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5835
diff changeset
   807
					if (*(bool*)ptr == (p != NULL)) continue;
5066
72aa68614963 (svn r7124) -Fix (r37xx): sizeof(bool) = 4 for (certain) OSX do not assume it is 1. This would break
Darkvater
parents: 5052
diff changeset
   808
					break;
3115
1f4949f5dc5d (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
   809
				case SLE_VAR_I8:
1f4949f5dc5d (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
   810
				case SLE_VAR_U8:
2972
f9fcee7f3815 (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
   811
					if (*(byte*)ptr == (byte)(unsigned long)p) continue;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   812
					break;
3115
1f4949f5dc5d (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
   813
				case SLE_VAR_I16:
1f4949f5dc5d (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
   814
				case SLE_VAR_U16:
2972
f9fcee7f3815 (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
   815
					if (*(uint16*)ptr == (uint16)(unsigned long)p) continue;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   816
					break;
3115
1f4949f5dc5d (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
   817
				case SLE_VAR_I32:
1f4949f5dc5d (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
   818
				case SLE_VAR_U32:
2972
f9fcee7f3815 (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
   819
					if (*(uint32*)ptr == (uint32)(unsigned long)p) continue;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   820
					break;
2972
f9fcee7f3815 (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
   821
				default: NOT_REACHED();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   822
				}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   823
				break;
2972
f9fcee7f3815 (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
   824
			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
   825
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   826
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   827
2972
f9fcee7f3815 (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
   828
		/* Value has changed, get the new value and put it into a buffer */
3115
1f4949f5dc5d (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
   829
		switch (sdb->cmd) {
2972
f9fcee7f3815 (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
   830
		case SDT_BOOLX:
f9fcee7f3815 (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
   831
		case SDT_NUMX:
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   832
		case SDT_ONEOFMANY:
3115
1f4949f5dc5d (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
   833
		case SDT_MANYOFMANY: {
1f4949f5dc5d (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
   834
			uint32 i = (uint32)ReadValue(ptr, sld->conv);
1f4949f5dc5d (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
   835
1f4949f5dc5d (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
   836
			switch (sdb->cmd) {
1f4949f5dc5d (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
   837
			case SDT_BOOLX:      strcpy(buf, (i != 0) ? "true" : "false"); break;
3900
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3874
diff changeset
   838
			case SDT_NUMX:       sprintf(buf, IsSignedVarMemType(sld->conv) ? "%d" : "%u", i); break;
3115
1f4949f5dc5d (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
   839
			case SDT_ONEOFMANY:  make_oneofmany(buf, sdb->many, i); break;
1f4949f5dc5d (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
   840
			case SDT_MANYOFMANY: make_manyofmany(buf, sdb->many, i); break;
2972
f9fcee7f3815 (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
   841
			default: NOT_REACHED();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   842
			}
3115
1f4949f5dc5d (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
   843
		} break;
2972
f9fcee7f3815 (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
   844
3115
1f4949f5dc5d (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
   845
		case SDT_STRING:
1f4949f5dc5d (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
   846
			switch (GetVarMemType(sld->conv)) {
1f4949f5dc5d (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
   847
			case SLE_VAR_STRB: strcpy(buf, (char*)ptr); break;
4255
5cb4bcf7c83f (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
   848
			case SLE_VAR_STRBQ:sprintf(buf, "\"%s\"", (char*)ptr); break;
5cb4bcf7c83f (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
   849
			case SLE_VAR_STR:  strcpy(buf, *(char**)ptr); break;
5cb4bcf7c83f (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
   850
			case SLE_VAR_STRQ: sprintf(buf, "\"%s\"", *(char**)ptr); break;
3115
1f4949f5dc5d (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
   851
			case SLE_VAR_CHAR: sprintf(buf, "\"%c\"", *(char*)ptr); break;
2972
f9fcee7f3815 (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
   852
			default: NOT_REACHED();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   853
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   854
			break;
2972
f9fcee7f3815 (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
   855
3115
1f4949f5dc5d (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
   856
		case SDT_INTLIST:
1f4949f5dc5d (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
   857
			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
   858
			break;
3115
1f4949f5dc5d (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
   859
		default: NOT_REACHED();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   860
		}
2972
f9fcee7f3815 (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
   861
f9fcee7f3815 (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
   862
		/* The value is different, that means we have to write it to the ini */
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5835
diff changeset
   863
		item->value = (char*)pool_strdup(&ini->pool, buf, strlen(buf));
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 188
diff changeset
   864
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   865
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   866
3615
59b36aaa050a (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   867
/** Loads all items from a 'grpname' section into a list
59b36aaa050a (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   868
 * The list parameter can be a NULL pointer, in this case nothing will be
59b36aaa050a (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   869
 * saved and a callback function should be defined that will take over the
59b36aaa050a (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   870
 * list-handling and store the data itself somewhere.
9909
dce9a6923bb7 (svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents: 9908
diff changeset
   871
 * @param ini IniFile handle to the ini file with the source data
3615
59b36aaa050a (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   872
 * @param grpname character string identifying the section-header of the ini
59b36aaa050a (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   873
 * file that will be parsed
59b36aaa050a (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   874
 * @param list pointer to an string(pointer) array that will store the parsed
59b36aaa050a (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   875
 * entries of the given section
3628
bd4a6601e5a2 (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
   876
 * @param len the maximum number of items available for the above list
bd4a6601e5a2 (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
   877
 * @param proc callback function that can override how the values are stored
bd4a6601e5a2 (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
   878
 * inside the list */
bd4a6601e5a2 (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
   879
static void ini_load_setting_list(IniFile *ini, const char *grpname, char **list, uint len, SettingListCallbackProc proc)
3115
1f4949f5dc5d (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
   880
{
1f4949f5dc5d (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
   881
	IniGroup *group = ini_getgroup(ini, grpname, -1);
1f4949f5dc5d (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
   882
	IniItem *item;
3628
bd4a6601e5a2 (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
   883
	const char *entry;
bd4a6601e5a2 (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
   884
	uint i, j;
3115
1f4949f5dc5d (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
   885
1f4949f5dc5d (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
   886
	if (group == NULL) return;
1f4949f5dc5d (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
   887
3628
bd4a6601e5a2 (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
   888
	for (i = j = 0, item = group->item; item != NULL; item = item->next) {
bd4a6601e5a2 (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
   889
		entry = (proc != NULL) ? proc(item, i++) : item->name;
bd4a6601e5a2 (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
   890
bd4a6601e5a2 (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
   891
		if (entry == NULL || list == NULL) continue;
bd4a6601e5a2 (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
   892
bd4a6601e5a2 (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
   893
		if (j == len) break;
bd4a6601e5a2 (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
   894
		list[j++] = strdup(entry);
3115
1f4949f5dc5d (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
   895
	}
1f4949f5dc5d (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
   896
}
1f4949f5dc5d (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
   897
3615
59b36aaa050a (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   898
/** Saves all items from a list into the 'grpname' section
59b36aaa050a (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   899
 * The list parameter can be a NULL pointer, in this case a callback function
59b36aaa050a (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   900
 * should be defined that will provide the source data to be saved.
9909
dce9a6923bb7 (svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents: 9908
diff changeset
   901
 * @param ini IniFile handle to the ini file where the destination data is saved
3615
59b36aaa050a (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   902
 * @param grpname character string identifying the section-header of the ini file
59b36aaa050a (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   903
 * @param list pointer to an string(pointer) array that will be used as the
9909
dce9a6923bb7 (svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents: 9908
diff changeset
   904
 *             source to be saved into the relevant ini section
3615
59b36aaa050a (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   905
 * @param len the maximum number of items available for the above list
59b36aaa050a (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   906
 * @param proc callback function that can will provide the source data if defined */
3628
bd4a6601e5a2 (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
   907
static void ini_save_setting_list(IniFile *ini, const char *grpname, char **list, uint len, SettingListCallbackProc proc)
3115
1f4949f5dc5d (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
   908
{
1f4949f5dc5d (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
   909
	IniGroup *group = ini_getgroup(ini, grpname, -1);
1f4949f5dc5d (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
   910
	IniItem *item = NULL;
3628
bd4a6601e5a2 (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
   911
	const char *entry;
3115
1f4949f5dc5d (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
   912
	uint i;
1f4949f5dc5d (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
   913
	bool first = true;
1f4949f5dc5d (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
   914
3628
bd4a6601e5a2 (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
   915
	if (proc == NULL && list == NULL) return;
3115
1f4949f5dc5d (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
   916
	if (group == NULL) return;
1f4949f5dc5d (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
   917
	group->item = NULL;
1f4949f5dc5d (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
   918
1f4949f5dc5d (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
   919
	for (i = 0; i != len; i++) {
3628
bd4a6601e5a2 (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
   920
		entry = (proc != NULL) ? proc(NULL, i) : list[i];
bd4a6601e5a2 (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
   921
bd4a6601e5a2 (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
   922
		if (entry == NULL || *entry == '\0') continue;
3115
1f4949f5dc5d (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
   923
1f4949f5dc5d (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
   924
		if (first) { // add first item to the head of the group
3628
bd4a6601e5a2 (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
   925
			item = ini_item_alloc(group, entry, strlen(entry));
3115
1f4949f5dc5d (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
   926
			item->value = item->name;
1f4949f5dc5d (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
   927
			group->item = item;
1f4949f5dc5d (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
   928
			first = false;
1f4949f5dc5d (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
   929
		} else { // all other items are attached to the previous one
3628
bd4a6601e5a2 (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
   930
			item->next = ini_item_alloc(group, entry, strlen(entry));
3115
1f4949f5dc5d (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
   931
			item = item->next;
1f4949f5dc5d (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
   932
			item->value = item->name;
1f4949f5dc5d (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
   933
		}
1f4949f5dc5d (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
   934
	}
1f4949f5dc5d (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
   935
}
1f4949f5dc5d (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
   936
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   937
//***************************
2972
f9fcee7f3815 (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
   938
// OTTD specific INI stuff
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   939
//***************************
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   940
3116
031230112b25 (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
   941
/** Settings-macro usage:
031230112b25 (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
   942
 * The list might look daunting at first, but is in general easy to understand.
031230112b25 (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
   943
 * We have two types of list:
031230112b25 (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
   944
 * 1. SDTG_something
031230112b25 (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
   945
 * 2. SDT_something
4000
bab1ebc37da0 (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
   946
 * The 'G' stands for global, so this is the one you will use for a
bab1ebc37da0 (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
   947
 * SettingDescGlobVarList section meaning global variables. The other uses a
9908
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
   948
 * Base/Offset and runtime variable selection mechanism, known from the saveload
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
   949
 * convention (it also has global so it should not be hard).
4000
bab1ebc37da0 (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
   950
 * Of each type there are again two versions, the normal one and one prefixed
bab1ebc37da0 (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
   951
 * with 'COND'.
bab1ebc37da0 (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
   952
 * COND means that the setting is only valid in certain savegame versions
bab1ebc37da0 (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
   953
 * (since patches are saved to the savegame, this bookkeeping is necessary.
3116
031230112b25 (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
   954
 * Now there are a lot of types. Easy ones are:
031230112b25 (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
   955
 * - VAR:  any number type, 'type' field specifies what number. eg int8 or uint32
031230112b25 (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
   956
 * - BOOL: a boolean number type
031230112b25 (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
   957
 * - STR:  a string or character. 'type' field specifies what string. Normal, string, or quoted
031230112b25 (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
   958
 * A bit more difficult to use are MMANY (meaning ManyOfMany) and OMANY (OneOfMany)
4000
bab1ebc37da0 (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
   959
 * These are actually normal numbers, only bitmasked. In MMANY several bits can
bab1ebc37da0 (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
   960
 * be set, in the other only one.
3116
031230112b25 (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
   961
 * The most complex type is INTLIST. This is basically an array of numbers. If
031230112b25 (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
   962
 * the intlist is only valid in certain savegame versions because for example
031230112b25 (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
   963
 * it has grown in size its length cannot be automatically be calculated so
031230112b25 (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
   964
 * use SDT(G)_CONDLISTO() meaning Old.
4000
bab1ebc37da0 (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
   965
 * If nothing fits you, you can use the GENERAL macros, but it exposes the
bab1ebc37da0 (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
   966
 * internal structure somewhat so it needs a little looking. There are _NULL()
bab1ebc37da0 (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
   967
 * macros as well, these fill up space so you can add more patches there (in
9906
6f41b8713b65 (svn r9674) [gamebalance] -Sync: r9322:9420 from trunk
celestar
parents: 9904
diff changeset
   968
 * place) and you DON'T have to increase the savegame version.
6f41b8713b65 (svn r9674) [gamebalance] -Sync: r9322:9420 from trunk
celestar
parents: 9904
diff changeset
   969
 *
6f41b8713b65 (svn r9674) [gamebalance] -Sync: r9322:9420 from trunk
celestar
parents: 9904
diff changeset
   970
 * While reading values from openttd.cfg, some values may not be converted
6f41b8713b65 (svn r9674) [gamebalance] -Sync: r9322:9420 from trunk
celestar
parents: 9904
diff changeset
   971
 * properly, for any kind of reasons.  In order to allow a process of self-cleaning
6f41b8713b65 (svn r9674) [gamebalance] -Sync: r9322:9420 from trunk
celestar
parents: 9904
diff changeset
   972
 * mechanism, a callback procedure is made available.  You will have to supply the function, which
6f41b8713b65 (svn r9674) [gamebalance] -Sync: r9322:9420 from trunk
celestar
parents: 9904
diff changeset
   973
 * will work on a string, one function per patch.  And of course, enable the callback param
6f41b8713b65 (svn r9674) [gamebalance] -Sync: r9322:9420 from trunk
celestar
parents: 9904
diff changeset
   974
 * on the appropriate macro.
6f41b8713b65 (svn r9674) [gamebalance] -Sync: r9322:9420 from trunk
celestar
parents: 9904
diff changeset
   975
 */
3116
031230112b25 (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
   976
9906
6f41b8713b65 (svn r9674) [gamebalance] -Sync: r9322:9420 from trunk
celestar
parents: 9904
diff changeset
   977
#define NSD_GENERAL(name, def, cmd, guiflags, min, max, interval, many, str, proc, load)\
6f41b8713b65 (svn r9674) [gamebalance] -Sync: r9322:9420 from trunk
celestar
parents: 9904
diff changeset
   978
	{name, (const void*)(def), {cmd}, {guiflags}, min, max, interval, many, str, proc, load}
3116
031230112b25 (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
   979
031230112b25 (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
   980
/* Macros for various objects to go in the configuration file.
031230112b25 (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
   981
 * This section is for global variables */
4431
7468c1484d20 (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
   982
#define SDTG_GENERAL(name, sdt_cmd, sle_cmd, type, flags, guiflags, var, length, def, min, max, interval, full, str, proc, from, to)\
9906
6f41b8713b65 (svn r9674) [gamebalance] -Sync: r9322:9420 from trunk
celestar
parents: 9904
diff changeset
   983
	{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
031230112b25 (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
   984
4431
7468c1484d20 (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
   985
#define SDTG_CONDVAR(name, type, flags, guiflags, var, def, min, max, interval, str, proc, from, to)\
7468c1484d20 (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
   986
	SDTG_GENERAL(name, SDT_NUMX, SL_VAR, type, flags, guiflags, var, 0, def, min, max, interval, NULL, str, proc, from, to)
7468c1484d20 (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
   987
#define SDTG_VAR(name, type, flags, guiflags, var, def, min, max, interval, str, proc)\
7468c1484d20 (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
   988
	SDTG_CONDVAR(name, type, flags, guiflags, var, def, min, max, interval, str, proc, 0, SL_MAX_VERSION)
3116
031230112b25 (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
   989
031230112b25 (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
   990
#define SDTG_CONDBOOL(name, flags, guiflags, var, def, str, proc, from, to)\
6309
8b9b549655dc (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: 5939
diff changeset
   991
	SDTG_GENERAL(name, SDT_BOOLX, SL_VAR, SLE_BOOL, flags, guiflags, var, 0, def, 0, 1, 0, NULL, str, proc, from, to)
3116
031230112b25 (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
   992
#define SDTG_BOOL(name, flags, guiflags, var, def, str, proc)\
031230112b25 (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
   993
	SDTG_CONDBOOL(name, flags, guiflags, var, def, str, proc, 0, SL_MAX_VERSION)
031230112b25 (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
   994
031230112b25 (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
   995
#define SDTG_CONDLIST(name, type, length, flags, guiflags, var, def, str, proc, from, to)\
4431
7468c1484d20 (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
   996
	SDTG_GENERAL(name, SDT_INTLIST, SL_ARR, type, flags, guiflags, var, length, def, 0, 0, 0, NULL, str, proc, from, to)
3116
031230112b25 (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
   997
#define SDTG_LIST(name, type, flags, guiflags, var, def, str, proc)\
4431
7468c1484d20 (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
   998
	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
031230112b25 (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
   999
031230112b25 (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
  1000
#define SDTG_CONDSTR(name, type, length, flags, guiflags, var, def, str, proc, from, to)\
4431
7468c1484d20 (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
  1001
	SDTG_GENERAL(name, SDT_STRING, SL_STR, type, flags, guiflags, var, length, def, 0, 0, 0, NULL, str, proc, from, to)
3116
031230112b25 (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
  1002
#define SDTG_STR(name, type, flags, guiflags, var, def, str, proc)\
4431
7468c1484d20 (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
  1003
	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
031230112b25 (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
  1004
031230112b25 (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
  1005
#define SDTG_CONDOMANY(name, type, flags, guiflags, var, def, max, full, str, proc, from, to)\
4431
7468c1484d20 (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
  1006
	SDTG_GENERAL(name, SDT_ONEOFMANY, SL_VAR, type, flags, guiflags, var, 0, def, 0, max, 0, full, str, proc, from, to)
3116
031230112b25 (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
  1007
#define SDTG_OMANY(name, type, flags, guiflags, var, def, max, full, str, proc)\
9911
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9910
diff changeset
  1008
	SDTG_CONDOMANY(name, type, flags, guiflags, var, def, max, full, str, proc, 0, SL_MAX_VERSION)
3116
031230112b25 (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
  1009
031230112b25 (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
  1010
#define SDTG_CONDMMANY(name, type, flags, guiflags, var, def, full, str, proc, from, to)\
4431
7468c1484d20 (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
  1011
	SDTG_GENERAL(name, SDT_MANYOFMANY, SL_VAR, type, flags, guiflags, var, 0, def, 0, 0, 0, full, str, proc, from, to)
3116
031230112b25 (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
  1012
#define SDTG_MMANY(name, type, flags, guiflags, var, def, full, str, proc)\
031230112b25 (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
  1013
	SDTG_CONDMMANY(name, type, flags, guiflags, var, def, full, str, proc, 0, SL_MAX_VERSION)
031230112b25 (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
  1014
3222
8bfed4267cba (svn r3895) - Add proper SLE(G)_CONDNULL macros for the empty space reservation in savegames and update where used
Darkvater
parents: 3210
diff changeset
  1015
#define SDTG_CONDNULL(length, from, to)\
9906
6f41b8713b65 (svn r9674) [gamebalance] -Sync: r9322:9420 from trunk
celestar
parents: 9904
diff changeset
  1016
	{{"", NULL, {0}, {0}, 0, 0, 0, NULL, STR_NULL, NULL, NULL}, SLEG_CONDNULL(length, from, to)}
3222
8bfed4267cba (svn r3895) - Add proper SLE(G)_CONDNULL macros for the empty space reservation in savegames and update where used
Darkvater
parents: 3210
diff changeset
  1017
9906
6f41b8713b65 (svn r9674) [gamebalance] -Sync: r9322:9420 from trunk
celestar
parents: 9904
diff changeset
  1018
#define SDTG_END() {{NULL, NULL, {0}, {0}, 0, 0, 0, NULL, STR_NULL, NULL, NULL}, SLEG_END()}
3116
031230112b25 (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
  1019
031230112b25 (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
  1020
/* Macros for various objects to go in the configuration file.
031230112b25 (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
  1021
 * This section is for structures where their various members are saved */
9906
6f41b8713b65 (svn r9674) [gamebalance] -Sync: r9322:9420 from trunk
celestar
parents: 9904
diff changeset
  1022
#define SDT_GENERAL(name, sdt_cmd, sle_cmd, type, flags, guiflags, base, var, length, def, min, max, interval, full, str, proc, load, from, to)\
6f41b8713b65 (svn r9674) [gamebalance] -Sync: r9322:9420 from trunk
celestar
parents: 9904
diff changeset
  1023
	{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
031230112b25 (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
  1024
4431
7468c1484d20 (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
  1025
#define SDT_CONDVAR(base, var, type, from, to, flags, guiflags, def, min, max, interval, str, proc)\
9906
6f41b8713b65 (svn r9674) [gamebalance] -Sync: r9322:9420 from trunk
celestar
parents: 9904
diff changeset
  1026
	SDT_GENERAL(#var, SDT_NUMX, SL_VAR, type, flags, guiflags, base, var, 1, def, min, max, interval, NULL, str, proc, NULL, from, to)
4431
7468c1484d20 (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
  1027
#define SDT_VAR(base, var, type, flags, guiflags, def, min, max, interval, str, proc)\
7468c1484d20 (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
  1028
	SDT_CONDVAR(base, var, type, 0, SL_MAX_VERSION, flags, guiflags, def, min, max, interval, str, proc)
3116
031230112b25 (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
  1029
031230112b25 (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
  1030
#define SDT_CONDBOOL(base, var, from, to, flags, guiflags, def, str, proc)\
9906
6f41b8713b65 (svn r9674) [gamebalance] -Sync: r9322:9420 from trunk
celestar
parents: 9904
diff changeset
  1031
	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
031230112b25 (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
  1032
#define SDT_BOOL(base, var, flags, guiflags, def, str, proc)\
031230112b25 (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
  1033
	SDT_CONDBOOL(base, var, 0, SL_MAX_VERSION, flags, guiflags, def, str, proc)
031230112b25 (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
  1034
031230112b25 (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
  1035
#define SDT_CONDLIST(base, var, type, from, to, flags, guiflags, def, str, proc)\
9906
6f41b8713b65 (svn r9674) [gamebalance] -Sync: r9322:9420 from trunk
celestar
parents: 9904
diff changeset
  1036
	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
031230112b25 (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
  1037
#define SDT_LIST(base, var, type, flags, guiflags, def, str, proc)\
031230112b25 (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
  1038
	SDT_CONDLIST(base, var, type, 0, SL_MAX_VERSION, flags, guiflags, def, str, proc)
031230112b25 (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
  1039
#define SDT_CONDLISTO(base, var, length, type, from, to, flags, guiflags, def, str, proc)\
9906
6f41b8713b65 (svn r9674) [gamebalance] -Sync: r9322:9420 from trunk
celestar
parents: 9904
diff changeset
  1040
	SDT_GENERAL(#var, SDT_INTLIST, SL_ARR, type, flags, guiflags, base, var, length, def, 0, 0, 0, NULL, str, proc, NULL, from, to)
3116
031230112b25 (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
  1041
031230112b25 (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
  1042
#define SDT_CONDSTR(base, var, type, from, to, flags, guiflags, def, str, proc)\
9906
6f41b8713b65 (svn r9674) [gamebalance] -Sync: r9322:9420 from trunk
celestar
parents: 9904
diff changeset
  1043
	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
031230112b25 (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
  1044
#define SDT_STR(base, var, type, flags, guiflags, def, str, proc)\
031230112b25 (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
  1045
	SDT_CONDSTR(base, var, type, 0, SL_MAX_VERSION, flags, guiflags, def, str, proc)
031230112b25 (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
  1046
#define SDT_CONDSTRO(base, var, length, type, from, to, flags, def, str, proc)\
031230112b25 (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
  1047
	SDT_GENERAL(#var, SDT_STRING, SL_STR, type, flags, 0, base, var, length, def, 0, 0, NULL, str, proc, from, to)
031230112b25 (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
  1048
031230112b25 (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
  1049
#define SDT_CONDCHR(base, var, from, to, flags, guiflags, def, str, proc)\
9906
6f41b8713b65 (svn r9674) [gamebalance] -Sync: r9322:9420 from trunk
celestar
parents: 9904
diff changeset
  1050
	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
031230112b25 (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
  1051
#define SDT_CHR(base, var, flags, guiflags, def, str, proc)\
031230112b25 (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
  1052
	SDT_CONDCHR(base, var, 0, SL_MAX_VERSION, flags, guiflags, def, str, proc)
031230112b25 (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
  1053
9906
6f41b8713b65 (svn r9674) [gamebalance] -Sync: r9322:9420 from trunk
celestar
parents: 9904
diff changeset
  1054
#define SDT_CONDOMANY(base, var, type, from, to, flags, guiflags, def, max, full, str, proc, load)\
6f41b8713b65 (svn r9674) [gamebalance] -Sync: r9322:9420 from trunk
celestar
parents: 9904
diff changeset
  1055
	SDT_GENERAL(#var, SDT_ONEOFMANY, SL_VAR, type, flags, guiflags, base, var, 1, def, 0, max, 0, full, str, proc, load, from, to)
6f41b8713b65 (svn r9674) [gamebalance] -Sync: r9322:9420 from trunk
celestar
parents: 9904
diff changeset
  1056
#define SDT_OMANY(base, var, type, flags, guiflags, def, max, full, str, proc, load)\
6f41b8713b65 (svn r9674) [gamebalance] -Sync: r9322:9420 from trunk
celestar
parents: 9904
diff changeset
  1057
	SDT_CONDOMANY(base, var, type, 0, SL_MAX_VERSION, flags, guiflags, def, max, full, str, proc, load)
3116
031230112b25 (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
  1058
031230112b25 (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
  1059
#define SDT_CONDMMANY(base, var, type, from, to, flags, guiflags, def, full, str, proc)\
9906
6f41b8713b65 (svn r9674) [gamebalance] -Sync: r9322:9420 from trunk
celestar
parents: 9904
diff changeset
  1060
	SDT_GENERAL(#var, SDT_MANYOFMANY, SL_VAR, type, flags, guiflags, base, var, 1, def, 0, 0, 0, full, str, proc, NULL, from, to)
3116
031230112b25 (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
  1061
#define SDT_MMANY(base, var, type, flags, guiflags, def, full, str, proc)\
031230112b25 (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
  1062
	SDT_CONDMMANY(base, var, type, 0, SL_MAX_VERSION, flags, guiflags, def, full, str, proc)
031230112b25 (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
  1063
3222
8bfed4267cba (svn r3895) - Add proper SLE(G)_CONDNULL macros for the empty space reservation in savegames and update where used
Darkvater
parents: 3210
diff changeset
  1064
#define SDT_CONDNULL(length, from, to)\
9906
6f41b8713b65 (svn r9674) [gamebalance] -Sync: r9322:9420 from trunk
celestar
parents: 9904
diff changeset
  1065
	{{"", NULL, {0}, {0}, 0, 0, 0, NULL, STR_NULL, NULL, NULL}, SLE_CONDNULL(length, from, to)}
3222
8bfed4267cba (svn r3895) - Add proper SLE(G)_CONDNULL macros for the empty space reservation in savegames and update where used
Darkvater
parents: 3210
diff changeset
  1066
9906
6f41b8713b65 (svn r9674) [gamebalance] -Sync: r9322:9420 from trunk
celestar
parents: 9904
diff changeset
  1067
#define SDT_END() {{NULL, NULL, {0}, {0}, 0, 0, 0, NULL, STR_NULL, NULL, NULL}, SLE_END()}
3116
031230112b25 (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
  1068
031230112b25 (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
  1069
/* Shortcuts for macros below. Logically if we don't save the value
031230112b25 (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
  1070
 * we also don't sync it in a network game */
031230112b25 (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
  1071
#define S SLF_SAVE_NO | SLF_NETWORK_NO
031230112b25 (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
  1072
#define C SLF_CONFIG_NO
031230112b25 (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
  1073
#define N SLF_NETWORK_NO
031230112b25 (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
  1074
031230112b25 (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
  1075
#define D0 SGF_0ISDISABLED
031230112b25 (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
  1076
#define NC SGF_NOCOMMA
031230112b25 (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
  1077
#define MS SGF_MULTISTRING
031230112b25 (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
  1078
#define NO SGF_NETWORK_ONLY
031230112b25 (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
  1079
#define CR SGF_CURRENCY
031230112b25 (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
  1080
031230112b25 (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
  1081
#include "table/strings.h"
3131
e856656f99a9 (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
  1082
e856656f99a9 (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
  1083
/* Begin - Callback Functions for the various settings */
e856656f99a9 (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
  1084
#include "window.h"
e856656f99a9 (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
  1085
#include "gui.h"
e856656f99a9 (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
  1086
#include "town.h"
e856656f99a9 (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
  1087
#include "gfx.h"
9908
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
  1088
/* virtual PositionMainToolbar function, calls the right one.*/
3131
e856656f99a9 (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
  1089
static int32 v_PositionMainToolbar(int32 p1)
e856656f99a9 (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
  1090
{
e856656f99a9 (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
  1091
	if (_game_mode != GM_MENU) PositionMainToolbar(NULL);
e856656f99a9 (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
  1092
	return 0;
e856656f99a9 (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
  1093
}
e856656f99a9 (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
  1094
e856656f99a9 (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
  1095
static int32 AiNew_PatchActive_Warning(int32 p1)
e856656f99a9 (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
  1096
{
e856656f99a9 (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
  1097
	if (p1 == 1) ShowErrorMessage(INVALID_STRING_ID, TEMP_AI_ACTIVATED, 0, 0);
e856656f99a9 (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
  1098
	return 0;
e856656f99a9 (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
  1099
}
e856656f99a9 (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
  1100
e856656f99a9 (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
  1101
static int32 Ai_In_Multiplayer_Warning(int32 p1)
e856656f99a9 (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
  1102
{
e856656f99a9 (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
  1103
	if (p1 == 1) {
e856656f99a9 (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
  1104
		ShowErrorMessage(INVALID_STRING_ID, TEMP_AI_MULTIPLAYER, 0, 0);
e856656f99a9 (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
  1105
		_patches.ainew_active = true;
e856656f99a9 (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
  1106
	}
e856656f99a9 (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
  1107
	return 0;
e856656f99a9 (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
  1108
}
e856656f99a9 (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
  1109
e856656f99a9 (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
  1110
static int32 PopulationInLabelActive(int32 p1)
e856656f99a9 (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
  1111
{
e856656f99a9 (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
  1112
	Town* t;
e856656f99a9 (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
  1113
4346
3f00094f2670 (svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents: 4344
diff changeset
  1114
	FOR_ALL_TOWNS(t) UpdateTownVirtCoord(t);
3f00094f2670 (svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents: 4344
diff changeset
  1115
3131
e856656f99a9 (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
  1116
	return 0;
e856656f99a9 (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
  1117
}
e856656f99a9 (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
  1118
4082
172b5f3598fa (svn r5397) -Fix: Redraw the screen, when switching the signal side
tron
parents: 4077
diff changeset
  1119
static int32 RedrawScreen(int32 p1)
3131
e856656f99a9 (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
  1120
{
e856656f99a9 (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
  1121
	MarkWholeScreenDirty();
e856656f99a9 (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
  1122
	return 0;
e856656f99a9 (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
  1123
}
e856656f99a9 (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
  1124
e856656f99a9 (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
static int32 InValidateDetailsWindow(int32 p1)
e856656f99a9 (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
{
e856656f99a9 (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
  1127
	InvalidateWindowClasses(WC_VEHICLE_DETAILS);
e856656f99a9 (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
  1128
	return 0;
e856656f99a9 (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
  1129
}
e856656f99a9 (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
  1130
e856656f99a9 (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
  1131
static int32 InvalidateStationBuildWindow(int32 p1)
e856656f99a9 (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
  1132
{
e856656f99a9 (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
  1133
	InvalidateWindow(WC_BUILD_STATION, 0);
e856656f99a9 (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
  1134
	return 0;
e856656f99a9 (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
  1135
}
e856656f99a9 (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
  1136
e856656f99a9 (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
  1137
/* Check service intervals of vehicles, p1 is value of % or day based servicing */
e856656f99a9 (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
  1138
static int32 CheckInterval(int32 p1)
e856656f99a9 (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
  1139
{
e856656f99a9 (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
  1140
	bool warning;
e856656f99a9 (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
  1141
	const Patches *ptc = (_game_mode == GM_MENU) ? &_patches_newgame : &_patches;
e856656f99a9 (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
  1142
e856656f99a9 (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
  1143
	if (p1) {
9910
0b2aebc8283e (svn r10134) [gamebalance] -Sync: r9670:9700 from trunk
celestar
parents: 9909
diff changeset
  1144
		warning = ( (IS_INT_INSIDE(ptc->servint_trains,   5, 90 + 1) || ptc->servint_trains   == 0) &&
0b2aebc8283e (svn r10134) [gamebalance] -Sync: r9670:9700 from trunk
celestar
parents: 9909
diff changeset
  1145
								(IS_INT_INSIDE(ptc->servint_roadveh,  5, 90 + 1) || ptc->servint_roadveh  == 0) &&
0b2aebc8283e (svn r10134) [gamebalance] -Sync: r9670:9700 from trunk
celestar
parents: 9909
diff changeset
  1146
								(IS_INT_INSIDE(ptc->servint_aircraft, 5, 90 + 1) || ptc->servint_aircraft == 0) &&
0b2aebc8283e (svn r10134) [gamebalance] -Sync: r9670:9700 from trunk
celestar
parents: 9909
diff changeset
  1147
								(IS_INT_INSIDE(ptc->servint_ships,    5, 90 + 1) || ptc->servint_ships    == 0) );
3131
e856656f99a9 (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
  1148
	} else {
9910
0b2aebc8283e (svn r10134) [gamebalance] -Sync: r9670:9700 from trunk
celestar
parents: 9909
diff changeset
  1149
		warning = ( (IS_INT_INSIDE(ptc->servint_trains,   30, 800 + 1) || ptc->servint_trains   == 0) &&
0b2aebc8283e (svn r10134) [gamebalance] -Sync: r9670:9700 from trunk
celestar
parents: 9909
diff changeset
  1150
								(IS_INT_INSIDE(ptc->servint_roadveh,  30, 800 + 1) || ptc->servint_roadveh  == 0) &&
0b2aebc8283e (svn r10134) [gamebalance] -Sync: r9670:9700 from trunk
celestar
parents: 9909
diff changeset
  1151
								(IS_INT_INSIDE(ptc->servint_aircraft, 30, 800 + 1) || ptc->servint_aircraft == 0) &&
0b2aebc8283e (svn r10134) [gamebalance] -Sync: r9670:9700 from trunk
celestar
parents: 9909
diff changeset
  1152
								(IS_INT_INSIDE(ptc->servint_ships,    30, 800 + 1) || ptc->servint_ships    == 0) );
3131
e856656f99a9 (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
  1153
	}
e856656f99a9 (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
  1154
e856656f99a9 (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
  1155
	if (!warning)
e856656f99a9 (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
  1156
		ShowErrorMessage(INVALID_STRING_ID, STR_CONFIG_PATCHES_SERVICE_INTERVAL_INCOMPATIBLE, 0, 0);
e856656f99a9 (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
  1157
e856656f99a9 (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
  1158
	return InValidateDetailsWindow(0);
e856656f99a9 (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
  1159
}
e856656f99a9 (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
  1160
e856656f99a9 (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
  1161
static int32 EngineRenewUpdate(int32 p1)
e856656f99a9 (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
  1162
{
4661
59492734db06 (svn r6544) - Codechange: Rename CmdReplaceVehicle to CmdSetAutoReplace, to reflect what it does.
peter1138
parents: 4616
diff changeset
  1163
	DoCommandP(0, 0, _patches.autorenew, NULL, CMD_SET_AUTOREPLACE);
3131
e856656f99a9 (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
  1164
	return 0;
e856656f99a9 (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
  1165
}
e856656f99a9 (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
  1166
e856656f99a9 (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
  1167
static int32 EngineRenewMonthsUpdate(int32 p1)
e856656f99a9 (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
  1168
{
4661
59492734db06 (svn r6544) - Codechange: Rename CmdReplaceVehicle to CmdSetAutoReplace, to reflect what it does.
peter1138
parents: 4616
diff changeset
  1169
	DoCommandP(0, 1, _patches.autorenew_months, NULL, CMD_SET_AUTOREPLACE);
3131
e856656f99a9 (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
  1170
	return 0;
e856656f99a9 (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
  1171
}
e856656f99a9 (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
  1172
e856656f99a9 (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
  1173
static int32 EngineRenewMoneyUpdate(int32 p1)
e856656f99a9 (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
  1174
{
4661
59492734db06 (svn r6544) - Codechange: Rename CmdReplaceVehicle to CmdSetAutoReplace, to reflect what it does.
peter1138
parents: 4616
diff changeset
  1175
	DoCommandP(0, 2, _patches.autorenew_money, NULL, CMD_SET_AUTOREPLACE);
3131
e856656f99a9 (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
  1176
	return 0;
e856656f99a9 (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
  1177
}
9911
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9910
diff changeset
  1178
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9910
diff changeset
  1179
/**
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9910
diff changeset
  1180
 * Check for right TownLayout usage in editor mode.
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9910
diff changeset
  1181
 * The No Road mode is not desirable since towns have to be
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9910
diff changeset
  1182
 * able to grow. If a user desires to have a town with no road,
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9910
diff changeset
  1183
 * he can easily remove them himself. This would create less confusion
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9910
diff changeset
  1184
 * @param p1 unused
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9910
diff changeset
  1185
 * @return always 0
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9910
diff changeset
  1186
 */
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9910
diff changeset
  1187
static int32 CheckTownLayout(int32 p1)
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9910
diff changeset
  1188
{
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9910
diff changeset
  1189
	if (_patches.town_layout == TL_NO_ROADS && _game_mode == GM_EDITOR) {
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9910
diff changeset
  1190
		ShowErrorMessage(INVALID_STRING_ID, STR_CONFIG_PATCHES_TOWN_LAYOUT_INVALID, 0, 0);
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9910
diff changeset
  1191
		_patches.town_layout = TL_ORIGINAL;
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9910
diff changeset
  1192
	}
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9910
diff changeset
  1193
	return 0;
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9910
diff changeset
  1194
}
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9910
diff changeset
  1195
9906
6f41b8713b65 (svn r9674) [gamebalance] -Sync: r9322:9420 from trunk
celestar
parents: 9904
diff changeset
  1196
/** Conversion callback for _gameopt_settings.landscape
6f41b8713b65 (svn r9674) [gamebalance] -Sync: r9322:9420 from trunk
celestar
parents: 9904
diff changeset
  1197
 * It converts (or try) between old values and the new ones,
6f41b8713b65 (svn r9674) [gamebalance] -Sync: r9322:9420 from trunk
celestar
parents: 9904
diff changeset
  1198
 * without loosing initial setting  of the user
6f41b8713b65 (svn r9674) [gamebalance] -Sync: r9322:9420 from trunk
celestar
parents: 9904
diff changeset
  1199
 * @param value that was read from config file
6f41b8713b65 (svn r9674) [gamebalance] -Sync: r9322:9420 from trunk
celestar
parents: 9904
diff changeset
  1200
 * @return the "hopefully" converted value
6f41b8713b65 (svn r9674) [gamebalance] -Sync: r9322:9420 from trunk
celestar
parents: 9904
diff changeset
  1201
 */
6f41b8713b65 (svn r9674) [gamebalance] -Sync: r9322:9420 from trunk
celestar
parents: 9904
diff changeset
  1202
static int32 ConvertLandscape(const char *value)
6f41b8713b65 (svn r9674) [gamebalance] -Sync: r9322:9420 from trunk
celestar
parents: 9904
diff changeset
  1203
{
6f41b8713b65 (svn r9674) [gamebalance] -Sync: r9322:9420 from trunk
celestar
parents: 9904
diff changeset
  1204
	/* try with the old values */
6f41b8713b65 (svn r9674) [gamebalance] -Sync: r9322:9420 from trunk
celestar
parents: 9904
diff changeset
  1205
	return lookup_oneofmany("normal|hilly|desert|candy", value, -1);
6f41b8713b65 (svn r9674) [gamebalance] -Sync: r9322:9420 from trunk
celestar
parents: 9904
diff changeset
  1206
}
6f41b8713b65 (svn r9674) [gamebalance] -Sync: r9322:9420 from trunk
celestar
parents: 9904
diff changeset
  1207
3131
e856656f99a9 (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
  1208
/* End - Callback Functions */
e856656f99a9 (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
  1209
1584
aa7fe51c4368 (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
  1210
#ifndef EXTERNAL_PLAYER
aa7fe51c4368 (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
  1211
#define EXTERNAL_PLAYER "timidity"
aa7fe51c4368 (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
  1212
#endif
aa7fe51c4368 (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
  1213
3116
031230112b25 (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
  1214
static const SettingDesc _music_settings[] = {
4431
7468c1484d20 (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
  1215
	 SDT_VAR(MusicFileSettings, playlist,   SLE_UINT8, S, 0,   0, 0,   5, 1,  STR_NULL, NULL),
7468c1484d20 (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
  1216
	 SDT_VAR(MusicFileSettings, music_vol,  SLE_UINT8, S, 0, 128, 0, 100, 1,  STR_NULL, NULL),
7468c1484d20 (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
  1217
	 SDT_VAR(MusicFileSettings, effect_vol, SLE_UINT8, S, 0, 128, 0, 100, 1,  STR_NULL, NULL),
4344
5d0e40cd67b9 (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
  1218
	SDT_LIST(MusicFileSettings, custom_1,   SLE_UINT8, S, 0, NULL,            STR_NULL, NULL),
5d0e40cd67b9 (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
  1219
	SDT_LIST(MusicFileSettings, custom_2,   SLE_UINT8, S, 0, NULL,            STR_NULL, NULL),
5d0e40cd67b9 (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
  1220
	SDT_BOOL(MusicFileSettings, playing,               S, 0, true,            STR_NULL, NULL),
5d0e40cd67b9 (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
  1221
	SDT_BOOL(MusicFileSettings, shuffle,               S, 0, false,           STR_NULL, NULL),
5d0e40cd67b9 (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
  1222
	 SDT_STR(MusicFileSettings, extmidi,     SLE_STRB, S, 0, EXTERNAL_PLAYER, STR_NULL, NULL),
3116
031230112b25 (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
	 SDT_END()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1224
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1225
3051
16f6e40c67eb (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
  1226
/* win32_v.c only settings */
16f6e40c67eb (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
  1227
#ifdef WIN32
9913
e79cd19772dd (svn r10213) [gamebalance] -Sync: r10100:10200 from trunk
celestar
parents: 9912
diff changeset
  1228
extern bool _force_full_redraw, _window_maximize;
3051
16f6e40c67eb (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
  1229
extern uint _display_hz, _fullscreen_bpp;
16f6e40c67eb (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
  1230
3124
60f74c9c90e3 (svn r3732) - Fix two warnings. Stupid MSVC didn't even complain :s (Thank Tron and peter1138)
Darkvater
parents: 3121
diff changeset
  1231
static const SettingDescGlobVarList _win32_settings[] = {
4431
7468c1484d20 (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
  1232
	 SDTG_VAR("display_hz",     SLE_UINT, S, 0, _display_hz,       0, 0, 120, 0, STR_NULL, NULL),
7468c1484d20 (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
  1233
	SDTG_BOOL("force_full_redraw",        S, 0, _force_full_redraw,false,        STR_NULL, NULL),
7468c1484d20 (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
  1234
	 SDTG_VAR("fullscreen_bpp", SLE_UINT, S, 0, _fullscreen_bpp,   8, 8,  32, 0, STR_NULL, NULL),
7468c1484d20 (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
  1235
	SDTG_BOOL("window_maximize",          S, 0, _window_maximize,  false,        STR_NULL, NULL),
3116
031230112b25 (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
  1236
	 SDTG_END()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1237
};
3051
16f6e40c67eb (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
  1238
#endif /* WIN32 */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1239
3116
031230112b25 (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
  1240
static const SettingDescGlobVarList _misc_settings[] = {
9912
1ac8aac92385 (svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents: 9911
diff changeset
  1241
	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
031230112b25 (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
  1242
	 SDTG_BOOL("news_ticker_sound",          S, 0, _news_ticker_sound,     true,    STR_NULL, NULL),
031230112b25 (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
  1243
	 SDTG_BOOL("fullscreen",                 S, 0, _fullscreen,           false,    STR_NULL, NULL),
031230112b25 (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
  1244
	  SDTG_STR("videodriver",      SLE_STRB,C|S,0, _ini_videodriver,       NULL,    STR_NULL, NULL),
031230112b25 (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
  1245
	  SDTG_STR("musicdriver",      SLE_STRB,C|S,0, _ini_musicdriver,       NULL,    STR_NULL, NULL),
031230112b25 (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
  1246
	  SDTG_STR("sounddriver",      SLE_STRB,C|S,0, _ini_sounddriver,       NULL,    STR_NULL, NULL),
031230112b25 (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
  1247
	  SDTG_STR("language",         SLE_STRB, S, 0, _dynlang.curr_file,     NULL,    STR_NULL, NULL),
031230112b25 (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
  1248
	 SDTG_LIST("resolution",     SLE_UINT16, S, 0, _cur_resolution,   "640,480",    STR_NULL, NULL),
031230112b25 (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
  1249
	  SDTG_STR("screenshot_format",SLE_STRB, S, 0, _screenshot_format_name,NULL,    STR_NULL, NULL),
031230112b25 (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
  1250
	  SDTG_STR("savegame_format",  SLE_STRB, S, 0, _savegame_format,       NULL,    STR_NULL, NULL),
031230112b25 (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
  1251
	 SDTG_BOOL("rightclick_emulate",         S, 0, _rightclick_emulate,   false,    STR_NULL, NULL),
5108
dc67d70b5a45 (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
  1252
#ifdef WITH_FREETYPE
dc67d70b5a45 (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
  1253
	  SDTG_STR("small_font",       SLE_STRB, S, 0, _freetype.small_font,   NULL,    STR_NULL, NULL),
dc67d70b5a45 (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
  1254
	  SDTG_STR("medium_font",      SLE_STRB, S, 0, _freetype.medium_font,  NULL,    STR_NULL, NULL),
dc67d70b5a45 (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
  1255
	  SDTG_STR("large_font",       SLE_STRB, S, 0, _freetype.large_font,   NULL,    STR_NULL, NULL),
dc67d70b5a45 (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
  1256
	  SDTG_VAR("small_size",       SLE_UINT, S, 0, _freetype.small_size,   6, 0, 72, 0, STR_NULL, NULL),
dc67d70b5a45 (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
  1257
	  SDTG_VAR("medium_size",      SLE_UINT, S, 0, _freetype.medium_size, 10, 0, 72, 0, STR_NULL, NULL),
dc67d70b5a45 (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
  1258
	  SDTG_VAR("large_size",       SLE_UINT, S, 0, _freetype.large_size,  16, 0, 72, 0, STR_NULL, NULL),
9913
e79cd19772dd (svn r10213) [gamebalance] -Sync: r10100:10200 from trunk
celestar
parents: 9912
diff changeset
  1259
	 SDTG_BOOL("small_aa",                   S, 0, _freetype.small_aa,    false,    STR_NULL, NULL),
e79cd19772dd (svn r10213) [gamebalance] -Sync: r10100:10200 from trunk
celestar
parents: 9912
diff changeset
  1260
	 SDTG_BOOL("medium_aa",                  S, 0, _freetype.medium_aa,   false,    STR_NULL, NULL),
e79cd19772dd (svn r10213) [gamebalance] -Sync: r10100:10200 from trunk
celestar
parents: 9912
diff changeset
  1261
	 SDTG_BOOL("large_aa",                   S, 0, _freetype.large_aa,    false,    STR_NULL, NULL),
5108
dc67d70b5a45 (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
  1262
#endif
9912
1ac8aac92385 (svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents: 9911
diff changeset
  1263
	  SDTG_VAR("sprite_cache_size",SLE_UINT, S, 0, _sprite_cache_size,     4, 1, 64, 0, STR_NULL, NULL),
3116
031230112b25 (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
  1264
	  SDTG_END()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1265
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1266
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
  1267
#ifdef ENABLE_NETWORK
3116
031230112b25 (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
  1268
static const SettingDescGlobVarList _network_settings[] = {
9911
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9910
diff changeset
  1269
	  SDTG_VAR("sync_freq",           SLE_UINT16,C|S,0, _network_sync_freq,            100, 0,   100,   0, STR_NULL, NULL),
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9910
diff changeset
  1270
	  SDTG_VAR("frame_freq",           SLE_UINT8,C|S,0, _network_frame_freq,             0, 0,   100,   0, STR_NULL, NULL),
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9910
diff changeset
  1271
	  SDTG_VAR("max_join_time",       SLE_UINT16, S, 0, _network_max_join_time,        500, 0, 32000,   0, STR_NULL, NULL),
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9910
diff changeset
  1272
	 SDTG_BOOL("pause_on_join",                   S, 0, _network_pause_on_join,        true,               STR_NULL, NULL),
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9910
diff changeset
  1273
	  SDTG_STR("server_bind_ip",        SLE_STRB, S, 0, _network_server_bind_ip_host,  "0.0.0.0",          STR_NULL, NULL),
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9910
diff changeset
  1274
	  SDTG_VAR("server_port",         SLE_UINT16, S, 0, _network_server_port,          NETWORK_DEFAULT_PORT, 0, 65535, 0, STR_NULL, NULL),
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9910
diff changeset
  1275
	 SDTG_BOOL("server_advertise",                S, 0, _network_advertise,            false,              STR_NULL, NULL),
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9910
diff changeset
  1276
	  SDTG_VAR("lan_internet",         SLE_UINT8, S, 0, _network_lan_internet,           0, 0,     1,   0, STR_NULL, NULL),
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9910
diff changeset
  1277
	  SDTG_STR("player_name",           SLE_STRB, S, 0, _network_player_name,          NULL,               STR_NULL, NULL),
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9910
diff changeset
  1278
	  SDTG_STR("server_password",       SLE_STRB, S, 0, _network_server_password,      NULL,               STR_NULL, NULL),
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9910
diff changeset
  1279
	  SDTG_STR("rcon_password",         SLE_STRB, S, 0, _network_rcon_password,        NULL,               STR_NULL, NULL),
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9910
diff changeset
  1280
	  SDTG_STR("server_name",           SLE_STRB, S, 0, _network_server_name,          NULL,               STR_NULL, NULL),
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9910
diff changeset
  1281
	  SDTG_STR("connect_to_ip",         SLE_STRB, S, 0, _network_default_ip,           NULL,               STR_NULL, NULL),
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9910
diff changeset
  1282
	  SDTG_STR("network_id",            SLE_STRB, S, 0, _network_unique_id,            NULL,               STR_NULL, NULL),
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9910
diff changeset
  1283
	 SDTG_BOOL("autoclean_companies",             S, 0, _network_autoclean_companies,  false,              STR_NULL, NULL),
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9910
diff changeset
  1284
	  SDTG_VAR("autoclean_unprotected",SLE_UINT8, S, 0, _network_autoclean_unprotected,12, 0,     60,   0, STR_NULL, NULL),
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9910
diff changeset
  1285
	  SDTG_VAR("autoclean_protected",  SLE_UINT8, S, 0, _network_autoclean_protected,  36, 0,    180,   0, STR_NULL, NULL),
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9910
diff changeset
  1286
	  SDTG_VAR("max_companies",        SLE_UINT8, S, 0, _network_game_info.companies_max,   8, 0,  8,   0, STR_NULL, NULL),
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9910
diff changeset
  1287
	  SDTG_VAR("max_clients",          SLE_UINT8, S, 0, _network_game_info.clients_max,    10, 0, 10,   0, STR_NULL, NULL),
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9910
diff changeset
  1288
	  SDTG_VAR("max_spectators",       SLE_UINT8, S, 0, _network_game_info.spectators_max, 10, 0, 10,   0, STR_NULL, NULL),
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9910
diff changeset
  1289
	  SDTG_VAR("restart_game_year",    SLE_INT32, S,D0, _network_restart_game_year,    0, MIN_YEAR, MAX_YEAR, 1, STR_NULL, NULL),
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9910
diff changeset
  1290
	  SDTG_VAR("min_players",          SLE_UINT8, S, 0, _network_min_players,               0, 0, 10,   0, STR_NULL, NULL),
9912
1ac8aac92385 (svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents: 9911
diff changeset
  1291
	SDTG_OMANY("server_lang",          SLE_UINT8, S, 0, _network_game_info.server_lang,     0, 28, "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", STR_NULL, NULL),
9911
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9910
diff changeset
  1292
	  SDTG_END()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1293
};
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
  1294
#endif /* ENABLE_NETWORK */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1295
3116
031230112b25 (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
  1296
static const SettingDesc _gameopt_settings[] = {
031230112b25 (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
  1297
	/* In version 4 a new difficulty setting has been added to the difficulty settings,
031230112b25 (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
  1298
	 * town attitude towards demolishing. Needs special handling because some dimwit thought
031230112b25 (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
  1299
	 * it funny to have the GameDifficulty struct be an array while it is a struct of
031230112b25 (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
  1300
	 * same-sized members
031230112b25 (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
  1301
	 * XXX - To save file-space and since values are never bigger than about 10? only
031230112b25 (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
  1302
	 * save the first 16 bits in the savegame. Question is why the values are still int32
031230112b25 (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
  1303
	 * and why not byte for example? */
9906
6f41b8713b65 (svn r9674) [gamebalance] -Sync: r9322:9420 from trunk
celestar
parents: 9904
diff changeset
  1304
	SDT_GENERAL("diff_custom", SDT_INTLIST, SL_ARR, (SLE_FILE_I16 | SLE_VAR_I32), 0, 0, GameOptions, diff, 17, 0, 0, 0, 0, NULL, STR_NULL, NULL, NULL,  0, 3),
6f41b8713b65 (svn r9674) [gamebalance] -Sync: r9322:9420 from trunk
celestar
parents: 9904
diff changeset
  1305
	SDT_GENERAL("diff_custom", SDT_INTLIST, SL_ARR, (SLE_FILE_I16 | SLE_VAR_I32), 0, 0, GameOptions, diff, 18, 0, 0, 0, 0, NULL, STR_NULL, NULL, NULL,  4, 53),
6f41b8713b65 (svn r9674) [gamebalance] -Sync: r9322:9420 from trunk
celestar
parents: 9904
diff changeset
  1306
	SDT_GENERAL("diff_custom", SDT_INTLIST, SL_ARR, (SLE_FILE_I16 | SLE_VAR_I32), 0, 0, GameOptions, diff, 20, 0, 0, 0, 0, NULL, STR_NULL, NULL, NULL, 54, SL_MAX_VERSION),
9910
0b2aebc8283e (svn r10134) [gamebalance] -Sync: r9670:9700 from trunk
celestar
parents: 9909
diff changeset
  1307
	    SDT_VAR(GameOptions, diff_level, SLE_UINT8, 0, 0, 0, 0,  3, 0, STR_NULL, NULL),
9906
6f41b8713b65 (svn r9674) [gamebalance] -Sync: r9322:9420 from trunk
celestar
parents: 9904
diff changeset
  1308
	  SDT_OMANY(GameOptions, 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),
6f41b8713b65 (svn r9674) [gamebalance] -Sync: r9322:9420 from trunk
celestar
parents: 9904
diff changeset
  1309
	  SDT_OMANY(GameOptions, units,     SLE_UINT8, N, 0, 1,     2, "imperial|metric|si", STR_NULL, NULL, NULL),
6f41b8713b65 (svn r9674) [gamebalance] -Sync: r9322:9420 from trunk
celestar
parents: 9904
diff changeset
  1310
	  SDT_OMANY(GameOptions, town_name, SLE_UINT8, 0, 0, 0,    20, "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),
6f41b8713b65 (svn r9674) [gamebalance] -Sync: r9322:9420 from trunk
celestar
parents: 9904
diff changeset
  1311
	  SDT_OMANY(GameOptions, landscape, SLE_UINT8, 0, 0, 0,     3, "temperate|arctic|tropic|toyland", STR_NULL, NULL, ConvertLandscape),
9907
3b068c3a1c74 (svn r9675) [gamebalance] -Sync: r9420:9520 from trunk
celestar
parents: 9906
diff changeset
  1312
	    SDT_VAR(GameOptions, snow_line, SLE_UINT8, 0, 0, 7 * TILE_HEIGHT, 2 * TILE_HEIGHT, 13 * TILE_HEIGHT, 0, STR_NULL, NULL),
9906
6f41b8713b65 (svn r9674) [gamebalance] -Sync: r9322:9420 from trunk
celestar
parents: 9904
diff changeset
  1313
	SDT_CONDOMANY(GameOptions,autosave, SLE_UINT8, 0, 22,             N, 0, 0, 0, "", STR_NULL, NULL, NULL),
6f41b8713b65 (svn r9674) [gamebalance] -Sync: r9322:9420 from trunk
celestar
parents: 9904
diff changeset
  1314
	SDT_CONDOMANY(GameOptions,autosave, SLE_UINT8,23, SL_MAX_VERSION, S, 0, 1, 4, "off|monthly|quarterly|half year|yearly", STR_NULL, NULL, NULL),
6f41b8713b65 (svn r9674) [gamebalance] -Sync: r9322:9420 from trunk
celestar
parents: 9904
diff changeset
  1315
	  SDT_OMANY(GameOptions, road_side, SLE_UINT8, 0, 0, 1,   1, "left|right", STR_NULL, NULL, NULL),
3116
031230112b25 (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
  1316
	    SDT_END()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1317
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1318
3116
031230112b25 (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
  1319
/* Some patches do not need to be synchronised when playing in multiplayer.
031230112b25 (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
  1320
 * These include for example the GUI settings and will not be saved with the
031230112b25 (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
  1321
 * savegame.
031230112b25 (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
  1322
 * It is also a bit tricky since you would think that service_interval
4000
bab1ebc37da0 (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
  1323
 * for example doesn't need to be synched. Every client assigns the
bab1ebc37da0 (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
  1324
 * service_interval value to the v->service_interval, meaning that every client
bab1ebc37da0 (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
  1325
 * assigns his value. If the setting was player-based, that would mean that
bab1ebc37da0 (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
  1326
 * vehicles could decide on different moments that they are heading back to a
bab1ebc37da0 (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
  1327
 * service depot, causing desyncs on a massive scale. */
3116
031230112b25 (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
  1328
const SettingDesc _patch_settings[] = {
031230112b25 (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
  1329
	/***************************************************************************/
3247
4e70e64adbb8 (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
  1330
	/* User-interface section of the GUI-configure patches window */
4431
7468c1484d20 (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
  1331
	SDT_BOOL(Patches, vehicle_speed,                 S, 0,  true,        STR_CONFIG_PATCHES_VEHICLESPEED,          NULL),
7468c1484d20 (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
  1332
	SDT_BOOL(Patches, status_long_date,              S, 0,  true,        STR_CONFIG_PATCHES_LONGDATE,              NULL),
7468c1484d20 (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
  1333
	SDT_BOOL(Patches, show_finances,                 S, 0,  true,        STR_CONFIG_PATCHES_SHOWFINANCES,          NULL),
7468c1484d20 (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
  1334
	SDT_BOOL(Patches, autoscroll,                    S, 0, false,        STR_CONFIG_PATCHES_AUTOSCROLL,            NULL),
7468c1484d20 (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
  1335
	SDT_BOOL(Patches, reverse_scroll,                S, 0, false,        STR_CONFIG_PATCHES_REVERSE_SCROLLING,     NULL),
9912
1ac8aac92385 (svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents: 9911
diff changeset
  1336
	SDT_BOOL(Patches, smooth_scroll,                 S, 0, false,        STR_CONFIG_PATCHES_SMOOTH_SCROLLING,      NULL),
4834
ddcf440d0ffd (svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents: 4716
diff changeset
  1337
	SDT_BOOL(Patches, measure_tooltip,               S, 0, false,        STR_CONFIG_PATCHES_MEASURE_TOOLTIP,       NULL),
4431
7468c1484d20 (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
  1338
	 SDT_VAR(Patches, errmsg_duration,    SLE_UINT8, S, 0,  5, 0, 20, 0, STR_CONFIG_PATCHES_ERRMSG_DURATION,       NULL),
7468c1484d20 (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
  1339
	 SDT_VAR(Patches, toolbar_pos,        SLE_UINT8, S,MS,  0, 0,  2, 0, STR_CONFIG_PATCHES_TOOLBAR_POS,           v_PositionMainToolbar),
7468c1484d20 (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
  1340
	 SDT_VAR(Patches, window_snap_radius, SLE_UINT8, S,D0, 10, 1, 32, 0, STR_CONFIG_PATCHES_SNAP_RADIUS,           NULL),
7468c1484d20 (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
  1341
	SDT_BOOL(Patches, invisible_trees,               S, 0, false,        STR_CONFIG_PATCHES_INVISIBLE_TREES,       RedrawScreen),
7468c1484d20 (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
  1342
	SDT_BOOL(Patches, population_in_label,           S, 0,  true,        STR_CONFIG_PATCHES_POPULATION_IN_LABEL,   PopulationInLabelActive),
7468c1484d20 (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
  1343
	 SDT_VAR(Patches, map_x,              SLE_UINT8, S, 0,  8, 6, 11, 0, STR_CONFIG_PATCHES_MAP_X,                 NULL),
7468c1484d20 (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
  1344
	 SDT_VAR(Patches, map_y,              SLE_UINT8, S, 0,  8, 6, 11, 0, STR_CONFIG_PATCHES_MAP_Y,                 NULL),
7468c1484d20 (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
  1345
	SDT_BOOL(Patches, link_terraform_toolbar,        S, 0, false,        STR_CONFIG_PATCHES_LINK_TERRAFORM_TOOLBAR,NULL),
4616
baa9d4436b9e (svn r6474) - Add a patch option to control display of liveries, allowing none, your
peter1138
parents: 4601
diff changeset
  1346
	 SDT_VAR(Patches, liveries,           SLE_UINT8, S,MS,  2, 0,  2, 0, STR_CONFIG_PATCHES_LIVERIES,              RedrawScreen),
5107
8791beb0ae51 (svn r7179) -Codechange (r7173): Actually "prefer" team chat through the patch setting instead of
Darkvater
parents: 5102
diff changeset
  1347
	SDT_BOOL(Patches, prefer_teamchat,               S, 0, false,        STR_CONFIG_PATCHES_PREFER_TEAMCHAT,       NULL),
9895
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6338
diff changeset
  1348
	SDT_VAR(Patches, scrollwheel_scrolling,SLE_UINT8,S,MS, 0,  0,  2, 0, STR_CONFIG_PATCHES_SCROLLWHEEL_SCROLLING, NULL),
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6338
diff changeset
  1349
	SDT_VAR(Patches,scrollwheel_multiplier,SLE_UINT8,S, 0, 5,  1, 15, 1, STR_CONFIG_PATCHES_SCROLLWHEEL_MULTIPLIER,NULL),
9911
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9910
diff changeset
  1350
	SDT_BOOL(Patches, pause_on_newgame,              S, 0, false,        STR_CONFIG_PATCHES_PAUSE_ON_NEW_GAME,     NULL),
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9910
diff changeset
  1351
	SDT_BOOL(Patches, advanced_vehicle_list,         S, 0, true,        STR_CONFIG_PATCHES_ADVANCED_VEHICLE_LISTS,     NULL),
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
  1352
3116
031230112b25 (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
  1353
	/***************************************************************************/
3247
4e70e64adbb8 (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
  1354
	/* Construction section of the GUI-configure patches window */
4431
7468c1484d20 (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
  1355
	SDT_BOOL(Patches, build_on_slopes,               0, 0,  true,        STR_CONFIG_PATCHES_BUILDONSLOPES,       NULL),
7468c1484d20 (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
  1356
	SDT_BOOL(Patches, extra_dynamite,                0, 0, false,        STR_CONFIG_PATCHES_EXTRADYNAMITE,       NULL),
7468c1484d20 (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
  1357
	SDT_BOOL(Patches, longbridges,                   0, 0,  true,        STR_CONFIG_PATCHES_LONGBRIDGES,         NULL),
7468c1484d20 (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
  1358
	SDT_BOOL(Patches, signal_side,                   N, 0,  true,        STR_CONFIG_PATCHES_SIGNALSIDE,          RedrawScreen),
7468c1484d20 (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
  1359
	SDT_BOOL(Patches, always_small_airport,          0, 0, false,        STR_CONFIG_PATCHES_SMALL_AIRPORTS,      NULL),
7468c1484d20 (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
  1360
	 SDT_VAR(Patches, drag_signals_density,SLE_UINT8,S, 0,  4, 1, 20, 0, STR_CONFIG_PATCHES_DRAG_SIGNALS_DENSITY,NULL),
5939
77530457a36b (svn r8151) -Feature: Automatically build semaphores before a configurable date, which can be set by each network player seperately.
maedhros
parents: 5860
diff changeset
  1361
	 SDT_VAR(Patches, semaphore_build_before,SLE_INT32, S, NC, 1975, MIN_YEAR, MAX_YEAR, 1, STR_CONFIG_PATCHES_SEMAPHORE_BUILD_BEFORE_DATE, NULL),
9911
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9910
diff changeset
  1362
	SDT_CONDVAR(Patches, 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),
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
  1363
3116
031230112b25 (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
  1364
	/***************************************************************************/
3247
4e70e64adbb8 (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
  1365
	/* Vehicle section of the GUI-configure patches window */
4431
7468c1484d20 (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
  1366
	SDT_BOOL(Patches, realistic_acceleration,        0, 0, false,                    STR_CONFIG_PATCHES_REALISTICACCEL,       NULL),
7468c1484d20 (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
  1367
	SDT_BOOL(Patches, forbid_90_deg,                 0, 0, false,                    STR_CONFIG_PATCHES_FORBID_90_DEG,        NULL),
7468c1484d20 (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
  1368
	SDT_BOOL(Patches, mammoth_trains,                0, 0,  true,                    STR_CONFIG_PATCHES_MAMMOTHTRAINS,        NULL),
7468c1484d20 (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
  1369
	SDT_BOOL(Patches, gotodepot,                     0, 0,  true,                    STR_CONFIG_PATCHES_GOTODEPOT,            NULL),
7468c1484d20 (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
  1370
	SDT_BOOL(Patches, roadveh_queue,                 0, 0,  true,                    STR_CONFIG_PATCHES_ROADVEH_QUEUE,        NULL),
7468c1484d20 (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
  1371
	SDT_BOOL(Patches, new_pathfinding_all,           0, 0, false,                    STR_CONFIG_PATCHES_NEW_PATHFINDING_ALL,  NULL),
3900
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3874
diff changeset
  1372
4431
7468c1484d20 (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
  1373
	SDT_CONDBOOL(Patches, yapf.ship_use_yapf,      28, SL_MAX_VERSION, 0, 0, false,  STR_CONFIG_PATCHES_YAPF_SHIPS,      NULL),
7468c1484d20 (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
  1374
	SDT_CONDBOOL(Patches, yapf.road_use_yapf,      28, SL_MAX_VERSION, 0, 0,  true,  STR_CONFIG_PATCHES_YAPF_ROAD,       NULL),
7468c1484d20 (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
  1375
	SDT_CONDBOOL(Patches, yapf.rail_use_yapf,      28, SL_MAX_VERSION, 0, 0,  true,  STR_CONFIG_PATCHES_YAPF_RAIL,       NULL),
7468c1484d20 (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
  1376
7468c1484d20 (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
  1377
	SDT_BOOL(Patches, train_income_warn,             S, 0,  true,                    STR_CONFIG_PATCHES_WARN_INCOME_LESS,     NULL),
7468c1484d20 (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
  1378
	 SDT_VAR(Patches, order_review_system,SLE_UINT8, S,MS,     2,     0,       2, 0, STR_CONFIG_PATCHES_ORDER_REVIEW,         NULL),
7468c1484d20 (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
  1379
	SDT_BOOL(Patches, never_expire_vehicles,         0, 0, false,                    STR_CONFIG_PATCHES_NEVER_EXPIRE_VEHICLES,NULL),
4870
0ee22ed51ada (svn r6800) -Feature change: [train is lost] message is now generated immediately when pathfinder can't find the path. (thanks MeusH, peter1138 and Brianetta for ideas and help).
KUDr
parents: 4834
diff changeset
  1380
	SDT_BOOL(Patches, lost_train_warn,               S, 0,  true,                    STR_CONFIG_PATCHES_WARN_LOST_TRAIN,      NULL),
4431
7468c1484d20 (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
  1381
	SDT_BOOL(Patches, autorenew,                     S, 0, false,                    STR_CONFIG_PATCHES_AUTORENEW_VEHICLE,    EngineRenewUpdate),
7468c1484d20 (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
  1382
	 SDT_VAR(Patches, autorenew_months,   SLE_INT16, S, 0,     6,   -12,      12, 0, STR_CONFIG_PATCHES_AUTORENEW_MONTHS,     EngineRenewMonthsUpdate),
7468c1484d20 (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
  1383
	 SDT_VAR(Patches, autorenew_money,     SLE_UINT, S,CR,100000,     0, 2000000, 0, STR_CONFIG_PATCHES_AUTORENEW_MONEY,      EngineRenewMoneyUpdate),
7468c1484d20 (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
  1384
	 SDT_VAR(Patches, max_trains,        SLE_UINT16, 0, 0,   500,     0,    5000, 0, STR_CONFIG_PATCHES_MAX_TRAINS,           NULL),
7468c1484d20 (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
  1385
	 SDT_VAR(Patches, max_roadveh,       SLE_UINT16, 0, 0,   500,     0,    5000, 0, STR_CONFIG_PATCHES_MAX_ROADVEH,          NULL),
7468c1484d20 (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
  1386
	 SDT_VAR(Patches, max_aircraft,      SLE_UINT16, 0, 0,   200,     0,    5000, 0, STR_CONFIG_PATCHES_MAX_AIRCRAFT,         NULL),
7468c1484d20 (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
  1387
	 SDT_VAR(Patches, max_ships,         SLE_UINT16, 0, 0,   300,     0,    5000, 0, STR_CONFIG_PATCHES_MAX_SHIPS,            NULL),
7468c1484d20 (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
  1388
	SDT_BOOL(Patches, servint_ispercent,             0, 0, false,                    STR_CONFIG_PATCHES_SERVINT_ISPERCENT,    CheckInterval),
7468c1484d20 (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
  1389
	 SDT_VAR(Patches, servint_trains,    SLE_UINT16, 0,D0,   150,     5,     800, 0, STR_CONFIG_PATCHES_SERVINT_TRAINS,       InValidateDetailsWindow),
7468c1484d20 (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
  1390
	 SDT_VAR(Patches, servint_roadveh,   SLE_UINT16, 0,D0,   150,     5,     800, 0, STR_CONFIG_PATCHES_SERVINT_ROADVEH,      InValidateDetailsWindow),
7468c1484d20 (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
  1391
	 SDT_VAR(Patches, servint_ships,     SLE_UINT16, 0,D0,   360,     5,     800, 0, STR_CONFIG_PATCHES_SERVINT_SHIPS,        InValidateDetailsWindow),
7468c1484d20 (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
  1392
	 SDT_VAR(Patches, servint_aircraft,  SLE_UINT16, 0,D0,   100,     5,     800, 0, STR_CONFIG_PATCHES_SERVINT_AIRCRAFT,     InValidateDetailsWindow),
7468c1484d20 (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
  1393
	SDT_BOOL(Patches, no_servicing_if_no_breakdowns, 0, 0, false,                    STR_CONFIG_PATCHES_NOSERVICE,            NULL),
7468c1484d20 (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
  1394
	SDT_BOOL(Patches, wagon_speed_limits,            0, 0,  true,                    STR_CONFIG_PATCHES_WAGONSPEEDLIMITS,     NULL),
5116
2a33a74925c5 (svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents: 5113
diff changeset
  1395
	SDT_CONDBOOL(Patches, disable_elrails, 38, SL_MAX_VERSION, 0, 0, false,          STR_CONFIG_PATCHES_DISABLE_ELRAILS,      SettingsDisableElrail),
5163
83acad83bbdd (svn r7269) -Feature: Add freight trains patch option. This option is a multiplier for the weight of cargo on freight trains, to simulate longer heavier trains. The default value of 1 behaves as before.
peter1138
parents: 5142
diff changeset
  1396
	SDT_CONDVAR(Patches, freight_trains, SLE_UINT8, 39, SL_MAX_VERSION, 0, 0, 1, 1, 255, 1, STR_CONFIG_PATCHES_FREIGHT_TRAINS, NULL),
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
  1397
3116
031230112b25 (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
  1398
	/***************************************************************************/
3247
4e70e64adbb8 (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
  1399
	/* Station section of the GUI-configure patches window */
4431
7468c1484d20 (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
  1400
	SDT_BOOL(Patches, join_stations,           0, 0,  true,        STR_CONFIG_PATCHES_JOINSTATIONS,       NULL),
7468c1484d20 (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
  1401
	SDT_BOOL(Patches, full_load_any,           0, 0,  true,        STR_CONFIG_PATCHES_FULLLOADANY,        NULL),
7468c1484d20 (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
  1402
	SDT_BOOL(Patches, improved_load,           0, 0, false,        STR_CONFIG_PATCHES_IMPROVEDLOAD,       NULL),
7468c1484d20 (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
  1403
	SDT_BOOL(Patches, selectgoods,             0, 0,  true,        STR_CONFIG_PATCHES_SELECTGOODS,        NULL),
7468c1484d20 (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
  1404
	SDT_BOOL(Patches, new_nonstop,             0, 0, false,        STR_CONFIG_PATCHES_NEW_NONSTOP,        NULL),
7468c1484d20 (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
  1405
	SDT_BOOL(Patches, nonuniform_stations,     0, 0,  true,        STR_CONFIG_PATCHES_NONUNIFORM_STATIONS,NULL),
7468c1484d20 (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
  1406
	 SDT_VAR(Patches, station_spread,SLE_UINT8,0, 0, 12, 4, 64, 0, STR_CONFIG_PATCHES_STATION_SPREAD,     InvalidateStationBuildWindow),
7468c1484d20 (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
  1407
	SDT_BOOL(Patches, serviceathelipad,        0, 0,  true,        STR_CONFIG_PATCHES_SERVICEATHELIPAD,   NULL),
7468c1484d20 (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
  1408
	SDT_BOOL(Patches, modified_catchment,      0, 0,  true,        STR_CONFIG_PATCHES_CATCHMENT,          NULL),
5211
651c9272ad22 (svn r7326) -Feature: Add support for gradual (un)loading of vehicles (Maedhros)
peter1138
parents: 5186
diff changeset
  1409
	SDT_CONDBOOL(Patches, gradual_loading, 40, SL_MAX_VERSION, 0, 0,  true, STR_CONFIG_PATCHES_GRADUAL_LOADING,    NULL),
6338
0fb4f452873c (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 6309
diff changeset
  1410
	SDT_CONDBOOL(Patches, road_stop_on_town_road, 47, SL_MAX_VERSION, 0, 0, false, STR_CONFIG_PATCHES_STOP_ON_TOWN_ROAD, NULL),
9912
1ac8aac92385 (svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents: 9911
diff changeset
  1411
	SDT_CONDBOOL(Patches, adjacent_stations,      62, SL_MAX_VERSION, 0, 0, true,  STR_CONFIG_PATCHES_ADJACENT_STATIONS, NULL),
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
  1412
3116
031230112b25 (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
  1413
	/***************************************************************************/
3247
4e70e64adbb8 (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
  1414
	/* Economy section of the GUI-configure patches window */
3116
031230112b25 (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
  1415
	SDT_BOOL(Patches, inflation,                  0, 0,  true,            STR_CONFIG_PATCHES_INFLATION,        NULL),
031230112b25 (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
  1416
	SDT_BOOL(Patches, build_rawmaterial_ind,      0, 0, false,            STR_CONFIG_PATCHES_BUILDXTRAIND,     NULL),
031230112b25 (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
  1417
	SDT_BOOL(Patches, multiple_industry_per_town, 0, 0, false,            STR_CONFIG_PATCHES_MULTIPINDTOWN,    NULL),
031230112b25 (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
  1418
	SDT_BOOL(Patches, same_industry_close,        0, 0, false,            STR_CONFIG_PATCHES_SAMEINDCLOSE,     NULL),
031230112b25 (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
  1419
	SDT_BOOL(Patches, bribe,                      0, 0,  true,            STR_CONFIG_PATCHES_BRIBE,            NULL),
4431
7468c1484d20 (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
  1420
	 SDT_VAR(Patches, snow_line_height,SLE_UINT8, 0, 0,     7,  2, 13, 0, STR_CONFIG_PATCHES_SNOWLINE_HEIGHT,  NULL),
7468c1484d20 (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
  1421
	 SDT_VAR(Patches, colored_news_year,SLE_INT32, 0,NC,  2000, MIN_YEAR, MAX_YEAR, 1, STR_CONFIG_PATCHES_COLORED_NEWS_YEAR,NULL),
7468c1484d20 (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
  1422
	 SDT_VAR(Patches, starting_year,    SLE_INT32, 0,NC,  1950, MIN_YEAR, MAX_YEAR, 1, STR_CONFIG_PATCHES_STARTING_YEAR,NULL),
7468c1484d20 (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
  1423
	 SDT_VAR(Patches, ending_year,      SLE_INT32,0,NC|NO,2051, MIN_YEAR, MAX_YEAR, 1, STR_CONFIG_PATCHES_ENDING_YEAR,  NULL),
3116
031230112b25 (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
  1424
	SDT_BOOL(Patches, smooth_economy,             0, 0,  true,            STR_CONFIG_PATCHES_SMOOTH_ECONOMY,   NULL),
9906
6f41b8713b65 (svn r9674) [gamebalance] -Sync: r9322:9420 from trunk
celestar
parents: 9904
diff changeset
  1425
	SDT_BOOL(Patches, allow_shares,               0, 0, false,            STR_CONFIG_PATCHES_ALLOW_SHARES,     NULL),
9909
dce9a6923bb7 (svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents: 9908
diff changeset
  1426
	SDT_CONDVAR(Patches, town_growth_rate,  SLE_UINT8, 54, SL_MAX_VERSION, 0, MS, 2, 0,   4, 0, STR_CONFIG_PATCHES_TOWN_GROWTH,          NULL),
dce9a6923bb7 (svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents: 9908
diff changeset
  1427
	SDT_CONDVAR(Patches, larger_towns,      SLE_UINT8, 54, SL_MAX_VERSION, 0, D0, 4, 0, 255, 1, STR_CONFIG_PATCHES_LARGER_TOWNS,         NULL),
dce9a6923bb7 (svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents: 9908
diff changeset
  1428
	SDT_CONDVAR(Patches, initial_city_size, SLE_UINT8, 56, SL_MAX_VERSION, 0, 0,  2, 1,  10, 1, STR_CONFIG_PATCHES_CITY_SIZE_MULTIPLIER, NULL),
1218
353a7773bc3c (svn r1722) -Feature: Bigger maps - anyone?
tron
parents: 1104
diff changeset
  1429
3116
031230112b25 (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
  1430
	/***************************************************************************/
3247
4e70e64adbb8 (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
  1431
	/* AI section of the GUI-configure patches window */
3131
e856656f99a9 (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
  1432
	SDT_BOOL(Patches, ainew_active,           0, 0, false, STR_CONFIG_PATCHES_AINEW_ACTIVE,      AiNew_PatchActive_Warning),
e856656f99a9 (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
  1433
	SDT_BOOL(Patches, ai_in_multiplayer,      0, 0, false, STR_CONFIG_PATCHES_AI_IN_MULTIPLAYER, Ai_In_Multiplayer_Warning),
3116
031230112b25 (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
  1434
	SDT_BOOL(Patches, ai_disable_veh_train,   0, 0, false, STR_CONFIG_PATCHES_AI_BUILDS_TRAINS,  NULL),
031230112b25 (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
  1435
	SDT_BOOL(Patches, ai_disable_veh_roadveh, 0, 0, false, STR_CONFIG_PATCHES_AI_BUILDS_ROADVEH, NULL),
031230112b25 (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
  1436
	SDT_BOOL(Patches, ai_disable_veh_aircraft,0, 0, false, STR_CONFIG_PATCHES_AI_BUILDS_AIRCRAFT,NULL),
031230112b25 (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
  1437
	SDT_BOOL(Patches, ai_disable_veh_ship,    0, 0, false, STR_CONFIG_PATCHES_AI_BUILDS_SHIPS,   NULL),
1271
2b8bfb61ce90 (svn r1775) -Fix: The NPF patch setting was not synced in network.
truelight
parents: 1258
diff changeset
  1438
3116
031230112b25 (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
  1439
	/***************************************************************************/
3247
4e70e64adbb8 (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
  1440
	/* Patches without any GUI representation */
4431
7468c1484d20 (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
  1441
	SDT_BOOL(Patches, keep_all_autosave,              S, 0, false,         STR_NULL, NULL),
7468c1484d20 (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
  1442
	SDT_BOOL(Patches, autosave_on_exit,               S, 0, false,         STR_NULL, NULL),
7468c1484d20 (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
  1443
	 SDT_VAR(Patches, max_num_autosaves,   SLE_UINT8, S, 0, 16, 0, 255, 0, STR_NULL, NULL),
7468c1484d20 (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
  1444
	SDT_BOOL(Patches, bridge_pillars,                 S, 0,  true,         STR_NULL, NULL),
7468c1484d20 (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
  1445
	 SDT_VAR(Patches, extend_vehicle_life, SLE_UINT8, 0, 0,  0, 0, 100, 0, STR_NULL, NULL),
7468c1484d20 (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
  1446
	SDT_BOOL(Patches, auto_euro,                      S, 0,  true,         STR_NULL, NULL),
7468c1484d20 (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
  1447
	 SDT_VAR(Patches, dist_local_authority,SLE_UINT8, 0, 0, 20, 5,  60, 0, STR_NULL, NULL),
7468c1484d20 (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
  1448
	 SDT_VAR(Patches, wait_oneway_signal,  SLE_UINT8, 0, 0, 15, 2, 100, 0, STR_NULL, NULL),
7468c1484d20 (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
  1449
	 SDT_VAR(Patches, wait_twoway_signal,  SLE_UINT8, 0, 0, 41, 2, 100, 0, STR_NULL, NULL),
3116
031230112b25 (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
  1450
031230112b25 (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
  1451
	/***************************************************************************/
3247
4e70e64adbb8 (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
  1452
	/* New Pathfinding patch settings */
4431
7468c1484d20 (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
  1453
	SDT_VAR(Patches, pf_maxlength,      SLE_UINT16, 0, 0,  4096,  64,  65535, 0, STR_NULL, NULL),
7468c1484d20 (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
  1454
	SDT_VAR(Patches, pf_maxdepth,        SLE_UINT8, 0, 0,    48,   4,    255, 0, STR_NULL, NULL),
1700
b8ecf0494fdd (svn r2204) - Add: [NPF] NPF now has a maximum number of nodes it will search. The default value is 5000 for now, which is an educated guess. Probably needs some finetuning. Hopefully this "feature" can be removed later on, when more sophisticated means of limiting the pathfinder have been implemented. This should make ships and larger networks playable for now, though.
matthijs
parents: 1688
diff changeset
  1455
	/* The maximum number of nodes to search */
4431
7468c1484d20 (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
  1456
	SDT_VAR(Patches, npf_max_search_nodes,SLE_UINT, 0, 0, 10000, 500, 100000, 0, STR_NULL, NULL),
1700
b8ecf0494fdd (svn r2204) - Add: [NPF] NPF now has a maximum number of nodes it will search. The default value is 5000 for now, which is an educated guess. Probably needs some finetuning. Hopefully this "feature" can be removed later on, when more sophisticated means of limiting the pathfinder have been implemented. This should make ships and larger networks playable for now, though.
matthijs
parents: 1688
diff changeset
  1457
1271
2b8bfb61ce90 (svn r1775) -Fix: The NPF patch setting was not synced in network.
truelight
parents: 1258
diff changeset
  1458
	/* When a red signal is encountered, a small detour can be made around
4000
bab1ebc37da0 (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
  1459
	 * it. This specifically occurs when a track is doubled, in which case
bab1ebc37da0 (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
  1460
	 * the detour is typically 2 tiles. It is also often used at station
bab1ebc37da0 (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
  1461
	 * entrances, when there is a choice of multiple platforms. If we take
bab1ebc37da0 (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
  1462
	 * a typical 4 platform station, the detour is 4 tiles. To properly
bab1ebc37da0 (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
  1463
	 * support larger stations we increase this value.
bab1ebc37da0 (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
  1464
	 * We want to prevent that trains that want to leave at one side of a
bab1ebc37da0 (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
  1465
	 * station, leave through the other side, turn around, enter the
bab1ebc37da0 (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
  1466
	 * station on another platform and exit the station on the right side
bab1ebc37da0 (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
  1467
	 * again, just because the sign at the right side was red. If we take
bab1ebc37da0 (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
  1468
	 * a typical 5 length station, this detour is 10 or 11 tiles (not
bab1ebc37da0 (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
  1469
	 * sure), so we set the default penalty at 10 (the station tile
bab1ebc37da0 (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
  1470
	 * penalty will further prevent this.
bab1ebc37da0 (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
  1471
	 * We give presignal exits (and combo's) a different (larger) penalty, because
bab1ebc37da0 (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
  1472
	 * we really don't want trains waiting in front of a presignal exit. */
4431
7468c1484d20 (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
  1473
	SDT_VAR(Patches, npf_rail_firstred_penalty,     SLE_UINT, 0, 0, (10 * NPF_TILE_LENGTH), 0, 100000, 0, STR_NULL, NULL),
7468c1484d20 (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
  1474
	SDT_VAR(Patches, npf_rail_firstred_exit_penalty,SLE_UINT, 0, 0, (100 * NPF_TILE_LENGTH),0, 100000, 0, STR_NULL, NULL),
1459
6c1f01803928 (svn r1963) - Add: [NPF] Penalty for a red signal that is the last signal on the path.
matthijs
parents: 1422
diff changeset
  1475
	/* This penalty is for when the last signal before the target is red.
6c1f01803928 (svn r1963) - Add: [NPF] Penalty for a red signal that is the last signal on the path.
matthijs
parents: 1422
diff changeset
  1476
	 * This is useful for train stations, where there are multiple
6c1f01803928 (svn r1963) - Add: [NPF] Penalty for a red signal that is the last signal on the path.
matthijs
parents: 1422
diff changeset
  1477
	 * platforms to choose from, which lie in different signal blocks.
6c1f01803928 (svn r1963) - Add: [NPF] Penalty for a red signal that is the last signal on the path.
matthijs
parents: 1422
diff changeset
  1478
	 * Every target in a occupied signal block (ie an occupied platform)
3116
031230112b25 (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
  1479
	 * will get this penalty. */
4431
7468c1484d20 (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
  1480
	SDT_VAR(Patches, npf_rail_lastred_penalty, SLE_UINT, 0, 0, (10 * NPF_TILE_LENGTH), 0, 100000, 0, STR_NULL, NULL),
1271
2b8bfb61ce90 (svn r1775) -Fix: The NPF patch setting was not synced in network.
truelight
parents: 1258
diff changeset
  1481
	/* When a train plans a route over a station tile, this penalty is
3116
031230112b25 (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
  1482
	 * applied. We want that trains plan a route around a typical, 4x5
031230112b25 (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
  1483
	 * station, which means two tiles to the right, and two tiles back to
031230112b25 (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
  1484
	 * the left around it, or 5 tiles of station through it. If we assign
031230112b25 (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
  1485
	 * a penalty of 1 tile for every station tile passed, the route will
031230112b25 (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
  1486
	 * be around it. */
4431
7468c1484d20 (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
  1487
	SDT_VAR(Patches, npf_rail_station_penalty, SLE_UINT, 0, 0, (1 * NPF_TILE_LENGTH), 0, 100000, 0, STR_NULL, NULL),
7468c1484d20 (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
  1488
	SDT_VAR(Patches, npf_rail_slope_penalty,   SLE_UINT, 0, 0, (1 * NPF_TILE_LENGTH), 0, 100000, 0, STR_NULL, NULL),
1751
954dd2900ac9 (svn r2255) - Fix: [ 9680363 ] [NPF] Broken buoy handling for ships
matthijs
parents: 1727
diff changeset
  1489
	/* This penalty is applied when a train makes a turn. Its value of 1 makes
954dd2900ac9 (svn r2255) - Fix: [ 9680363 ] [NPF] Broken buoy handling for ships
matthijs
parents: 1727
diff changeset
  1490
	 * sure that it has a minimal impact on the pathfinding, only when two
954dd2900ac9 (svn r2255) - Fix: [ 9680363 ] [NPF] Broken buoy handling for ships
matthijs
parents: 1727
diff changeset
  1491
	 * paths have equal length it will make a difference */
4431
7468c1484d20 (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
  1492
	SDT_VAR(Patches, npf_rail_curve_penalty,        SLE_UINT, 0, 0, 1,                      0, 100000, 0, STR_NULL, NULL),
1777
d328484bd6f2 (svn r2281) - Fix: [ 1115204 ] [NPF] When pressing the goto depot button, trains will now also look behind it if there is no depot in front. If so, the train reverses immediately. This also work anywhere, not just at stations.
matthijs
parents: 1751
diff changeset
  1493
	/* Ths penalty is applied when a vehicle reverses inside a depot (doesn't
d328484bd6f2 (svn r2281) - Fix: [ 1115204 ] [NPF] When pressing the goto depot button, trains will now also look behind it if there is no depot in front. If so, the train reverses immediately. This also work anywhere, not just at stations.
matthijs
parents: 1751
diff changeset
  1494
	 * apply to ships, as they can just come out the other end). XXX: Is this a
d328484bd6f2 (svn r2281) - Fix: [ 1115204 ] [NPF] When pressing the goto depot button, trains will now also look behind it if there is no depot in front. If so, the train reverses immediately. This also work anywhere, not just at stations.
matthijs
parents: 1751
diff changeset
  1495
	 * good value? */
4431
7468c1484d20 (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
  1496
	SDT_VAR(Patches, npf_rail_depot_reverse_penalty,SLE_UINT, 0, 0, (NPF_TILE_LENGTH * 50), 0, 100000, 0, STR_NULL, NULL),
7468c1484d20 (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
  1497
	SDT_VAR(Patches, npf_buoy_penalty,              SLE_UINT, 0, 0, (2 * NPF_TILE_LENGTH),  0, 100000, 0, STR_NULL, NULL),
1751
954dd2900ac9 (svn r2255) - Fix: [ 9680363 ] [NPF] Broken buoy handling for ships
matthijs
parents: 1727
diff changeset
  1498
	/* This penalty is applied when a ship makes a turn. It is bigger than the
954dd2900ac9 (svn r2255) - Fix: [ 9680363 ] [NPF] Broken buoy handling for ships
matthijs
parents: 1727
diff changeset
  1499
	 * rail curve penalty, since ships (realisticly) have more trouble with
954dd2900ac9 (svn r2255) - Fix: [ 9680363 ] [NPF] Broken buoy handling for ships
matthijs
parents: 1727
diff changeset
  1500
	 * making turns */
4431
7468c1484d20 (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
  1501
	SDT_VAR(Patches, npf_water_curve_penalty,       SLE_UINT, 0, 0, (NPF_TILE_LENGTH / 4),  0, 100000, 0, STR_NULL, NULL),
1941
b1cb02c0401c (svn r2447) * Add: [NPF] Penalty for road vehicles making turns.
matthijs
parents: 1891
diff changeset
  1502
	/* This is the penalty for road, same as for rail. */
4431
7468c1484d20 (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
  1503
	SDT_VAR(Patches, npf_road_curve_penalty,        SLE_UINT, 0, 0, 1,                      0, 100000, 0, STR_NULL, NULL),
2006
324916f22a8a (svn r2514) - Codechange: [NPF] Move the checking of railtype into a funciton IsCompatibleRail().
matthijs
parents: 1941
diff changeset
  1504
	/* This is the penalty for level crossings, for both road and rail vehicles */
4431
7468c1484d20 (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
  1505
	SDT_VAR(Patches, npf_crossing_penalty,          SLE_UINT, 0, 0, (3 * NPF_TILE_LENGTH),  0, 100000, 0, STR_NULL, NULL),
6338
0fb4f452873c (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 6309
diff changeset
  1506
	/* This is the penalty for drive-through road, stops. */
0fb4f452873c (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 6309
diff changeset
  1507
	SDT_CONDVAR (Patches, npf_road_drive_through_penalty, SLE_UINT, 47, SL_MAX_VERSION, 0, 0,  8 * NPF_TILE_LENGTH, 0, 1000000, 0, STR_NULL, NULL),
1271
2b8bfb61ce90 (svn r1775) -Fix: The NPF patch setting was not synced in network.
truelight
parents: 1258
diff changeset
  1508
3900
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3874
diff changeset
  1509
9908
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
  1510
	/* The maximum number of nodes to search */
4431
7468c1484d20 (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_CONDBOOL(Patches, yapf.disable_node_optimization  ,           28, SL_MAX_VERSION, 0, 0, false                   ,                       STR_NULL, NULL),
7468c1484d20 (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
  1512
	SDT_CONDVAR (Patches, yapf.max_search_nodes           , SLE_UINT, 28, SL_MAX_VERSION, 0, 0, 10000                   ,      500, 1000000, 0, STR_NULL, NULL),
7468c1484d20 (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_CONDBOOL(Patches, yapf.rail_firstred_twoway_eol   ,           28, SL_MAX_VERSION, 0, 0,  true                   ,                       STR_NULL, NULL),
7468c1484d20 (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_CONDVAR (Patches, yapf.rail_firstred_penalty      , SLE_UINT, 28, SL_MAX_VERSION, 0, 0,    10 * YAPF_TILE_LENGTH,        0, 1000000, 0, STR_NULL, NULL),
7468c1484d20 (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
  1515
	SDT_CONDVAR (Patches, yapf.rail_firstred_exit_penalty , SLE_UINT, 28, SL_MAX_VERSION, 0, 0,   100 * YAPF_TILE_LENGTH,        0, 1000000, 0, STR_NULL, NULL),
7468c1484d20 (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
  1516
	SDT_CONDVAR (Patches, yapf.rail_lastred_penalty       , SLE_UINT, 28, SL_MAX_VERSION, 0, 0,    10 * YAPF_TILE_LENGTH,        0, 1000000, 0, STR_NULL, NULL),
7468c1484d20 (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
  1517
	SDT_CONDVAR (Patches, yapf.rail_lastred_exit_penalty  , SLE_UINT, 28, SL_MAX_VERSION, 0, 0,   100 * YAPF_TILE_LENGTH,        0, 1000000, 0, STR_NULL, NULL),
7468c1484d20 (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
  1518
	SDT_CONDVAR (Patches, yapf.rail_station_penalty       , SLE_UINT, 28, SL_MAX_VERSION, 0, 0,    30 * YAPF_TILE_LENGTH,        0, 1000000, 0, STR_NULL, NULL),
7468c1484d20 (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
  1519
	SDT_CONDVAR (Patches, yapf.rail_slope_penalty         , SLE_UINT, 28, SL_MAX_VERSION, 0, 0,     2 * YAPF_TILE_LENGTH,        0, 1000000, 0, STR_NULL, NULL),
7468c1484d20 (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
  1520
	SDT_CONDVAR (Patches, yapf.rail_curve45_penalty       , SLE_UINT, 28, SL_MAX_VERSION, 0, 0,     1 * YAPF_TILE_LENGTH,        0, 1000000, 0, STR_NULL, NULL),
7468c1484d20 (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
  1521
	SDT_CONDVAR (Patches, yapf.rail_curve90_penalty       , SLE_UINT, 28, SL_MAX_VERSION, 0, 0,     6 * YAPF_TILE_LENGTH,        0, 1000000, 0, STR_NULL, NULL),
9908
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
  1522
	/* This penalty is applied when a train reverses inside a depot */
4431
7468c1484d20 (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
  1523
	SDT_CONDVAR (Patches, yapf.rail_depot_reverse_penalty , SLE_UINT, 28, SL_MAX_VERSION, 0, 0,    50 * YAPF_TILE_LENGTH,        0, 1000000, 0, STR_NULL, NULL),
9908
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
  1524
	/* This is the penalty for level crossings (for trains only) */
4431
7468c1484d20 (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
  1525
	SDT_CONDVAR (Patches, yapf.rail_crossing_penalty      , SLE_UINT, 28, SL_MAX_VERSION, 0, 0,     3 * YAPF_TILE_LENGTH,        0, 1000000, 0, STR_NULL, NULL),
9908
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
  1526
	/* look-ahead how many signals are checked */
5186
852c05442097 (svn r7296) -Fix: [YAPF] setting yapf.rail_look_ahead_max_signals to zero causes YAPF to behave incorrectly. Set its min value to 1. (Danny)
KUDr
parents: 5163
diff changeset
  1527
	SDT_CONDVAR (Patches, yapf.rail_look_ahead_max_signals, SLE_UINT, 28, SL_MAX_VERSION, 0, 0,    10                   ,        1,     100, 0, STR_NULL, NULL),
9908
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
  1528
	/* look-ahead n-th red signal penalty polynomial: penalty = p2 * n^2 + p1 * n + p0 */
4431
7468c1484d20 (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
  1529
	SDT_CONDVAR (Patches, yapf.rail_look_ahead_signal_p0  , SLE_INT , 28, SL_MAX_VERSION, 0, 0,   500                   , -1000000, 1000000, 0, STR_NULL, NULL),
7468c1484d20 (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
  1530
	SDT_CONDVAR (Patches, yapf.rail_look_ahead_signal_p1  , SLE_INT , 28, SL_MAX_VERSION, 0, 0,  -100                   , -1000000, 1000000, 0, STR_NULL, NULL),
7468c1484d20 (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
  1531
	SDT_CONDVAR (Patches, yapf.rail_look_ahead_signal_p2  , SLE_INT , 28, SL_MAX_VERSION, 0, 0,     5                   , -1000000, 1000000, 0, STR_NULL, NULL),
9908
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
  1532
	/* penalties for too long or too short station platforms */
4590
020290824b22 (svn r6440) -Fix: [YAPF] some YAPF settings were not saved (i misunderstood how save flags work). This probably caused some MP desyncs. Thanks Maedhros for noticing and peter1138 for this patch.
KUDr
parents: 4549
diff changeset
  1533
	SDT_CONDVAR (Patches, yapf.rail_longer_platform_penalty,           SLE_UINT, 33, SL_MAX_VERSION, 0, 0,  8 * YAPF_TILE_LENGTH, 0,   20000, 0, STR_NULL, NULL),
020290824b22 (svn r6440) -Fix: [YAPF] some YAPF settings were not saved (i misunderstood how save flags work). This probably caused some MP desyncs. Thanks Maedhros for noticing and peter1138 for this patch.
KUDr
parents: 4549
diff changeset
  1534
	SDT_CONDVAR (Patches, 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),
020290824b22 (svn r6440) -Fix: [YAPF] some YAPF settings were not saved (i misunderstood how save flags work). This probably caused some MP desyncs. Thanks Maedhros for noticing and peter1138 for this patch.
KUDr
parents: 4549
diff changeset
  1535
	SDT_CONDVAR (Patches, yapf.rail_shorter_platform_penalty,          SLE_UINT, 33, SL_MAX_VERSION, 0, 0, 40 * YAPF_TILE_LENGTH, 0,   20000, 0, STR_NULL, NULL),
020290824b22 (svn r6440) -Fix: [YAPF] some YAPF settings were not saved (i misunderstood how save flags work). This probably caused some MP desyncs. Thanks Maedhros for noticing and peter1138 for this patch.
KUDr
parents: 4549
diff changeset
  1536
	SDT_CONDVAR (Patches, 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),
9908
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
  1537
	/* road vehicles - penalties */
4590
020290824b22 (svn r6440) -Fix: [YAPF] some YAPF settings were not saved (i misunderstood how save flags work). This probably caused some MP desyncs. Thanks Maedhros for noticing and peter1138 for this patch.
KUDr
parents: 4549
diff changeset
  1538
	SDT_CONDVAR (Patches, yapf.road_slope_penalty                    , SLE_UINT, 33, SL_MAX_VERSION, 0, 0,  2 * YAPF_TILE_LENGTH, 0, 1000000, 0, STR_NULL, NULL),
020290824b22 (svn r6440) -Fix: [YAPF] some YAPF settings were not saved (i misunderstood how save flags work). This probably caused some MP desyncs. Thanks Maedhros for noticing and peter1138 for this patch.
KUDr
parents: 4549
diff changeset
  1539
	SDT_CONDVAR (Patches, yapf.road_curve_penalty                    , SLE_UINT, 33, SL_MAX_VERSION, 0, 0,  1 * YAPF_TILE_LENGTH, 0, 1000000, 0, STR_NULL, NULL),
020290824b22 (svn r6440) -Fix: [YAPF] some YAPF settings were not saved (i misunderstood how save flags work). This probably caused some MP desyncs. Thanks Maedhros for noticing and peter1138 for this patch.
KUDr
parents: 4549
diff changeset
  1540
	SDT_CONDVAR (Patches, yapf.road_crossing_penalty                 , SLE_UINT, 33, SL_MAX_VERSION, 0, 0,  3 * YAPF_TILE_LENGTH, 0, 1000000, 0, STR_NULL, NULL),
6338
0fb4f452873c (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 6309
diff changeset
  1541
	SDT_CONDVAR (Patches, yapf.road_stop_penalty                     , SLE_UINT, 47, SL_MAX_VERSION, 0, 0,  8 * YAPF_TILE_LENGTH, 0, 1000000, 0, STR_NULL, NULL),
3900
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3874
diff changeset
  1542
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4293
diff changeset
  1543
	/***************************************************************************/
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4293
diff changeset
  1544
	/* Terrain genation related patch options */
4431
7468c1484d20 (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
  1545
	SDT_CONDVAR(Patches,      land_generator,           SLE_UINT8,  30, SL_MAX_VERSION, 0, MS,   1,                   0,    1,               0, STR_CONFIG_PATCHES_LAND_GENERATOR,           NULL),
9906
6f41b8713b65 (svn r9674) [gamebalance] -Sync: r9322:9420 from trunk
celestar
parents: 9904
diff changeset
  1546
	SDT_CONDVAR(Patches,      oil_refinery_limit,       SLE_UINT8,  30, SL_MAX_VERSION, 0, 0,   32,                  12,   48,               0, STR_CONFIG_PATCHES_OIL_REF_EDGE_DISTANCE,    NULL),
4431
7468c1484d20 (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
  1547
	SDT_CONDVAR(Patches,      tgen_smoothness,          SLE_UINT8,  30, SL_MAX_VERSION, 0, MS,   1,                   0,    3,               0, STR_CONFIG_PATCHES_ROUGHNESS_OF_TERRAIN,     NULL),
7468c1484d20 (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
  1548
	SDT_CONDVAR(Patches,      generation_seed,          SLE_UINT32, 30, SL_MAX_VERSION, 0, 0,    GENERATE_NEW_SEED,   0, MAX_UVALUE(uint32), 0, STR_NULL,                                    NULL),
7468c1484d20 (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
  1549
	SDT_CONDVAR(Patches,      tree_placer,              SLE_UINT8,  30, SL_MAX_VERSION, 0, MS,   2,                   0,    2,               0, STR_CONFIG_PATCHES_TREE_PLACER,              NULL),
7468c1484d20 (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
  1550
	SDT_VAR    (Patches,      heightmap_rotation,       SLE_UINT8,                      S, MS,   0,                   0,    1,               0, STR_CONFIG_PATCHES_HEIGHTMAP_ROTATION,       NULL),
7468c1484d20 (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
  1551
	SDT_VAR    (Patches,      se_flat_world_height,     SLE_UINT8,                      S, 0,    0,                   0,   15,               0, STR_CONFIG_PATCHES_SE_FLAT_WORLD_HEIGHT,     NULL),
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4293
diff changeset
  1552
3116
031230112b25 (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
  1553
	SDT_END()
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
  1554
};
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
  1555
3116
031230112b25 (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
  1556
static const SettingDesc _currency_settings[] = {
4431
7468c1484d20 (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
  1557
	SDT_VAR(CurrencySpec, rate,    SLE_UINT16, S, 0,  1, 0, 100, 0, STR_NULL, NULL),
7468c1484d20 (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
  1558
	SDT_CHR(CurrencySpec, separator,           S, 0,        ".",    STR_NULL, NULL),
9910
0b2aebc8283e (svn r10134) [gamebalance] -Sync: r9670:9700 from trunk
celestar
parents: 9909
diff changeset
  1559
	SDT_VAR(CurrencySpec, to_euro,  SLE_INT32, S, 0,  0, 0, 3000, 0, STR_NULL, NULL),
4431
7468c1484d20 (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
  1560
	SDT_STR(CurrencySpec, prefix,   SLE_STRBQ, S, 0,       NULL,    STR_NULL, NULL),
7468c1484d20 (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
  1561
	SDT_STR(CurrencySpec, suffix,   SLE_STRBQ, S, 0, " credits",    STR_NULL, NULL),
3116
031230112b25 (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
  1562
	SDT_END()
759
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 738
diff changeset
  1563
};
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 738
diff changeset
  1564
3116
031230112b25 (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
  1565
/* Undefine for the shortcut macros above */
031230112b25 (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
  1566
#undef S
031230112b25 (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
  1567
#undef C
031230112b25 (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
  1568
#undef N
031230112b25 (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
  1569
031230112b25 (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
  1570
#undef D0
031230112b25 (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
  1571
#undef NC
031230112b25 (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
  1572
#undef MS
031230112b25 (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
  1573
#undef NO
031230112b25 (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
  1574
#undef CR
031230112b25 (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
  1575
9895
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6338
diff changeset
  1576
static uint NewsDisplayLoadConfig(IniFile *ini, const char *grpname)
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6338
diff changeset
  1577
{
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6338
diff changeset
  1578
	IniGroup *group = ini_getgroup(ini, grpname, -1);
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6338
diff changeset
  1579
	IniItem *item;
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6338
diff changeset
  1580
	/* By default, set everything to full (0xAAAAAAAA = 1010101010101010) */
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6338
diff changeset
  1581
	uint res = 0xAAAAAAAA;
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6338
diff changeset
  1582
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6338
diff changeset
  1583
	/* If no group exists, return everything full */
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6338
diff changeset
  1584
	if (group == NULL) return res;
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6338
diff changeset
  1585
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6338
diff changeset
  1586
	for (item = group->item; item != NULL; item = item->next) {
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6338
diff changeset
  1587
		int news_item = -1;
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6338
diff changeset
  1588
		for (int i = 0; i < NT_END; i++) {
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6338
diff changeset
  1589
			if (strcasecmp(item->name, _news_display_name[i]) == 0) {
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6338
diff changeset
  1590
				news_item = i;
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6338
diff changeset
  1591
				break;
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6338
diff changeset
  1592
			}
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6338
diff changeset
  1593
		}
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6338
diff changeset
  1594
		if (news_item == -1) {
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6338
diff changeset
  1595
			DEBUG(misc, 0, "Invalid display option: %s", item->name);
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6338
diff changeset
  1596
			continue;
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6338
diff changeset
  1597
		}
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6338
diff changeset
  1598
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6338
diff changeset
  1599
		if (strcasecmp(item->value, "full") == 0) {
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6338
diff changeset
  1600
			SB(res, news_item * 2, 2, 2);
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6338
diff changeset
  1601
		} else if (strcasecmp(item->value, "off") == 0) {
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6338
diff changeset
  1602
			SB(res, news_item * 2, 2, 0);
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6338
diff changeset
  1603
		} else if (strcasecmp(item->value, "summarized") == 0) {
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6338
diff changeset
  1604
			SB(res, news_item * 2, 2, 1);
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6338
diff changeset
  1605
		} else {
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6338
diff changeset
  1606
			DEBUG(misc, 0, "Invalid display value: %s", item->value);
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6338
diff changeset
  1607
			continue;
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6338
diff changeset
  1608
		}
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6338
diff changeset
  1609
	}
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6338
diff changeset
  1610
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6338
diff changeset
  1611
	return res;
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6338
diff changeset
  1612
}
3628
bd4a6601e5a2 (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
  1613
5329
2b117d8652f0 (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
  1614
/* Load a GRF configuration from the given group name */
2b117d8652f0 (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
  1615
static GRFConfig *GRFLoadConfig(IniFile *ini, const char *grpname, bool is_static)
2b117d8652f0 (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
  1616
{
2b117d8652f0 (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
  1617
	IniGroup *group = ini_getgroup(ini, grpname, -1);
2b117d8652f0 (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
  1618
	IniItem *item;
2b117d8652f0 (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
  1619
	GRFConfig *first = NULL;
2b117d8652f0 (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
  1620
	GRFConfig **curr = &first;
3628
bd4a6601e5a2 (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
  1621
5329
2b117d8652f0 (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
  1622
	if (group == NULL) return NULL;
2b117d8652f0 (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
  1623
2b117d8652f0 (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
  1624
	for (item = group->item; item != NULL; item = item->next) {
5860
7fdc9b423ba1 (svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents: 5852
diff changeset
  1625
		GRFConfig *c = CallocT<GRFConfig>(1);
9908
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
  1626
		c->full_path = strdup(item->name);
5329
2b117d8652f0 (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
  1627
2b117d8652f0 (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
  1628
		/* Parse parameters */
2b117d8652f0 (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
		if (*item->value != '\0') {
2b117d8652f0 (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
			c->num_params = parse_intlist(item->value, (int*)c->param, lengthof(c->param));
2b117d8652f0 (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
			if (c->num_params == (byte)-1) {
2b117d8652f0 (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
  1632
				ShowInfoF("ini: error in array '%s'", item->name);
2b117d8652f0 (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
				c->num_params = 0;
2b117d8652f0 (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
			}
2b117d8652f0 (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
		}
2b117d8652f0 (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
  1636
2b117d8652f0 (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
		/* Check if item is valid */
2b117d8652f0 (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
		if (!FillGRFDetails(c, is_static)) {
2b117d8652f0 (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
			const char *msg;
2b117d8652f0 (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
  1640
9895
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6338
diff changeset
  1641
			if (c->status == GCS_NOT_FOUND) {
5329
2b117d8652f0 (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
				msg = "not found";
2b117d8652f0 (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
			} else if (HASBIT(c->flags, GCF_UNSAFE)) {
2b117d8652f0 (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
  1644
				msg = "unsafe for static use";
2b117d8652f0 (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
			} else if (HASBIT(c->flags, GCF_SYSTEM)) {
2b117d8652f0 (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
				msg = "system NewGRF";
2b117d8652f0 (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
			} else {
2b117d8652f0 (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
				msg = "unknown";
2b117d8652f0 (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
			}
2b117d8652f0 (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
2b117d8652f0 (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
			ShowInfoF("ini: ignoring invalid NewGRF '%s': %s", item->name, msg);
5346
0d7cc9cefd2b (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
  1652
			ClearGRFConfig(&c);
5329
2b117d8652f0 (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
			continue;
2b117d8652f0 (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
		}
2b117d8652f0 (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
2b117d8652f0 (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
  1656
		/* Mark file as static to avoid saving in savegame. */
2b117d8652f0 (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
		if (is_static) SETBIT(c->flags, GCF_STATIC);
2b117d8652f0 (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
  1658
2b117d8652f0 (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
		/* Add item to list */
2b117d8652f0 (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
  1660
		*curr = c;
2b117d8652f0 (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
		curr = &c->next;
5307
3e336ae5724a (svn r7463) -Codechange: Don't load invalid NewGRF files from the configuration file; instead show a warning.
peter1138
parents: 5228
diff changeset
  1662
	}
3631
33532b85cce9 (svn r4530) - Fix [NewGRF]: don't spew a warning when a grf file has no parameters.
Darkvater
parents: 3628
diff changeset
  1663
5329
2b117d8652f0 (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
	return first;
3628
bd4a6601e5a2 (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
  1665
}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1666
9895
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6338
diff changeset
  1667
static void NewsDisplaySaveConfig(IniFile *ini, const char *grpname, uint news_display)
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6338
diff changeset
  1668
{
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6338
diff changeset
  1669
	IniGroup *group = ini_getgroup(ini, grpname, -1);
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6338
diff changeset
  1670
	IniItem **item;
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6338
diff changeset
  1671
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6338
diff changeset
  1672
	if (group == NULL) return;
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6338
diff changeset
  1673
	group->item = NULL;
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6338
diff changeset
  1674
	item = &group->item;
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6338
diff changeset
  1675
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6338
diff changeset
  1676
	for (int i = 0; i < NT_END; i++) {
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6338
diff changeset
  1677
		const char *value;
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6338
diff changeset
  1678
		int v = GB(news_display, i * 2, 2);
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6338
diff changeset
  1679
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6338
diff changeset
  1680
		value = (v == 0 ? "off" : (v == 1 ? "summarized" : "full"));
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6338
diff changeset
  1681
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6338
diff changeset
  1682
		*item = ini_item_alloc(group, _news_display_name[i], strlen(_news_display_name[i]));
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6338
diff changeset
  1683
		(*item)->value = (char*)pool_strdup(&ini->pool, value, strlen(value));
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6338
diff changeset
  1684
		item = &(*item)->next;
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6338
diff changeset
  1685
	}
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6338
diff changeset
  1686
}
5329
2b117d8652f0 (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
  1687
2b117d8652f0 (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
  1688
/* Save a GRF configuration to the given group name */
5309
02416fe4b891 (svn r7465) -Codechange: Save the default GRF configuration.
peter1138
parents: 5307
diff changeset
  1689
static void GRFSaveConfig(IniFile *ini, const char *grpname, const GRFConfig *list)
02416fe4b891 (svn r7465) -Codechange: Save the default GRF configuration.
peter1138
parents: 5307
diff changeset
  1690
{
02416fe4b891 (svn r7465) -Codechange: Save the default GRF configuration.
peter1138
parents: 5307
diff changeset
  1691
	IniGroup *group = ini_getgroup(ini, grpname, -1);
02416fe4b891 (svn r7465) -Codechange: Save the default GRF configuration.
peter1138
parents: 5307
diff changeset
  1692
	IniItem **item;
02416fe4b891 (svn r7465) -Codechange: Save the default GRF configuration.
peter1138
parents: 5307
diff changeset
  1693
	const GRFConfig *c;
02416fe4b891 (svn r7465) -Codechange: Save the default GRF configuration.
peter1138
parents: 5307
diff changeset
  1694
02416fe4b891 (svn r7465) -Codechange: Save the default GRF configuration.
peter1138
parents: 5307
diff changeset
  1695
	if (group == NULL) return;
02416fe4b891 (svn r7465) -Codechange: Save the default GRF configuration.
peter1138
parents: 5307
diff changeset
  1696
	group->item = NULL;
02416fe4b891 (svn r7465) -Codechange: Save the default GRF configuration.
peter1138
parents: 5307
diff changeset
  1697
	item = &group->item;
02416fe4b891 (svn r7465) -Codechange: Save the default GRF configuration.
peter1138
parents: 5307
diff changeset
  1698
02416fe4b891 (svn r7465) -Codechange: Save the default GRF configuration.
peter1138
parents: 5307
diff changeset
  1699
	for (c = list; c != NULL; c = c->next) {
02416fe4b891 (svn r7465) -Codechange: Save the default GRF configuration.
peter1138
parents: 5307
diff changeset
  1700
		char params[512];
02416fe4b891 (svn r7465) -Codechange: Save the default GRF configuration.
peter1138
parents: 5307
diff changeset
  1701
		GRFBuildParamList(params, c, lastof(params));
02416fe4b891 (svn r7465) -Codechange: Save the default GRF configuration.
peter1138
parents: 5307
diff changeset
  1702
9908
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
  1703
		*item = ini_item_alloc(group, c->full_path, strlen(c->full_path));
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5835
diff changeset
  1704
		(*item)->value = (char*)pool_strdup(&ini->pool, params, strlen(params));
5309
02416fe4b891 (svn r7465) -Codechange: Save the default GRF configuration.
peter1138
parents: 5307
diff changeset
  1705
		item = &(*item)->next;
02416fe4b891 (svn r7465) -Codechange: Save the default GRF configuration.
peter1138
parents: 5307
diff changeset
  1706
	}
02416fe4b891 (svn r7465) -Codechange: Save the default GRF configuration.
peter1138
parents: 5307
diff changeset
  1707
}
02416fe4b891 (svn r7465) -Codechange: Save the default GRF configuration.
peter1138
parents: 5307
diff changeset
  1708
3116
031230112b25 (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
  1709
/* Common handler for saving/loading variables to the configuration file */
031230112b25 (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
  1710
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
  1711
{
3116
031230112b25 (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
  1712
	proc(ini, (const SettingDesc*)_misc_settings,    "misc",  NULL);
031230112b25 (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
  1713
	proc(ini, (const SettingDesc*)_music_settings,   "music", &msf);
3051
16f6e40c67eb (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
  1714
#ifdef WIN32
3116
031230112b25 (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
  1715
	proc(ini, (const SettingDesc*)_win32_settings,   "win32", NULL);
3051
16f6e40c67eb (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
  1716
#endif /* WIN32 */
3116
031230112b25 (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
  1717
031230112b25 (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
  1718
	proc(ini, _gameopt_settings, "gameopt",  &_opt_newgame);
3121
2e50f731567a (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
  1719
	proc(ini, _patch_settings,   "patches",  &_patches_newgame);
3116
031230112b25 (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
  1720
	proc(ini, _currency_settings,"currency", &_custom_currency);
031230112b25 (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
  1721
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
  1722
#ifdef ENABLE_NETWORK
3116
031230112b25 (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
  1723
	proc(ini, (const SettingDesc*)_network_settings, "network", NULL);
3628
bd4a6601e5a2 (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
  1724
	proc_list(ini, "servers", _network_host_list, lengthof(_network_host_list), NULL);
bd4a6601e5a2 (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
  1725
	proc_list(ini, "bans",    _network_ban_list,  lengthof(_network_ban_list), NULL);
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
  1726
#endif /* ENABLE_NETWORK */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1727
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1728
9907
3b068c3a1c74 (svn r9675) [gamebalance] -Sync: r9420:9520 from trunk
celestar
parents: 9906
diff changeset
  1729
extern void CheckDifficultyLevels();
3b068c3a1c74 (svn r9675) [gamebalance] -Sync: r9420:9520 from trunk
celestar
parents: 9906
diff changeset
  1730
3116
031230112b25 (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
  1731
/** Load the values from the configuration files */
9895
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6338
diff changeset
  1732
void LoadFromConfig()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1733
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1734
	IniFile *ini = ini_load(_config_file);
9907
3b068c3a1c74 (svn r9675) [gamebalance] -Sync: r9420:9520 from trunk
celestar
parents: 9906
diff changeset
  1735
	ResetCurrencies(false); // Initialize the array of curencies, without preserving the custom one
3116
031230112b25 (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
	HandleSettingDescs(ini, ini_load_settings, ini_load_setting_list);
5329
2b117d8652f0 (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
  1737
	_grfconfig_newgame = GRFLoadConfig(ini, "newgrf", false);
2b117d8652f0 (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
  1738
	_grfconfig_static  = GRFLoadConfig(ini, "newgrf-static", true);
9895
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6338
diff changeset
  1739
	_news_display_opt  = NewsDisplayLoadConfig(ini, "news_display");
9907
3b068c3a1c74 (svn r9675) [gamebalance] -Sync: r9420:9520 from trunk
celestar
parents: 9906
diff changeset
  1740
	CheckDifficultyLevels();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1741
	ini_free(ini);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1742
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1743
3116
031230112b25 (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
  1744
/** Save the values to the configuration file */
9895
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6338
diff changeset
  1745
void SaveToConfig()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1746
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1747
	IniFile *ini = ini_load(_config_file);
3116
031230112b25 (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
  1748
	HandleSettingDescs(ini, ini_save_settings, ini_save_setting_list);
5309
02416fe4b891 (svn r7465) -Codechange: Save the default GRF configuration.
peter1138
parents: 5307
diff changeset
  1749
	GRFSaveConfig(ini, "newgrf", _grfconfig_newgame);
5329
2b117d8652f0 (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
  1750
	GRFSaveConfig(ini, "newgrf-static", _grfconfig_static);
9895
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6338
diff changeset
  1751
	NewsDisplaySaveConfig(ini, "news_display", _news_display_opt);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1752
	ini_save(_config_file, ini);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1753
	ini_free(ini);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1754
}
1688
787400219027 (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
  1755
3247
4e70e64adbb8 (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
  1756
static const SettingDesc *GetSettingDescription(uint index)
3118
99926945ccb1 (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
  1757
{
99926945ccb1 (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
  1758
	if (index >= lengthof(_patch_settings)) return NULL;
99926945ccb1 (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
  1759
	return &_patch_settings[index];
99926945ccb1 (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
  1760
}
99926945ccb1 (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
  1761
3119
08471cfc4ef8 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1762
/** Network-safe changing of patch-settings (server-only).
9909
dce9a6923bb7 (svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents: 9908
diff changeset
  1763
 * @param tile unused
dce9a6923bb7 (svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents: 9908
diff changeset
  1764
 * @param flags operation to perform
3119
08471cfc4ef8 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1765
 * @param p1 the index of the patch in the SettingDesc array which identifies it
08471cfc4ef8 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1766
 * @param p2 the new value for the patch
08471cfc4ef8 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1767
 * The new value is properly clamped to its minimum/maximum when setting
08471cfc4ef8 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1768
 * @see _patch_settings
08471cfc4ef8 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1769
 */
9913
e79cd19772dd (svn r10213) [gamebalance] -Sync: r10100:10200 from trunk
celestar
parents: 9912
diff changeset
  1770
CommandCost CmdChangePatchSetting(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
3119
08471cfc4ef8 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1771
{
08471cfc4ef8 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1772
	const SettingDesc *sd = GetSettingDescription(p1);
08471cfc4ef8 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1773
08471cfc4ef8 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1774
	if (sd == NULL) return CMD_ERROR;
3223
abf18a71767b (svn r3896) - [Patches] Fix: Honour any conditional settings when retrieving the setting entries.
Darkvater
parents: 3222
diff changeset
  1775
	if (!SlIsObjectCurrentlyValid(sd->save.version_from, sd->save.version_to)) return CMD_ERROR;
3119
08471cfc4ef8 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1776
08471cfc4ef8 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1777
	if (flags & DC_EXEC) {
3121
2e50f731567a (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
  1778
		Patches *patches_ptr = (_game_mode == GM_MENU) ? &_patches_newgame : &_patches;
5141
05a806850445 (svn r7231) -Codechange: rename ini_get_variable to GetVariableAddress for use both in settings.c
Darkvater
parents: 5116
diff changeset
  1779
		void *var = GetVariableAddress(patches_ptr, &sd->save);
3119
08471cfc4ef8 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1780
		Write_ValidateSetting(var, sd, (int32)p2);
5113
5626f4b8b46e (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
  1781
		if (sd->desc.proc != NULL) sd->desc.proc((int32)ReadValue(var, sd->save.conv));
3119
08471cfc4ef8 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1782
08471cfc4ef8 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1783
		InvalidateWindow(WC_GAME_OPTIONS, 0);
08471cfc4ef8 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1784
	}
08471cfc4ef8 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1785
08471cfc4ef8 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1786
	return 0;
08471cfc4ef8 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1787
}
08471cfc4ef8 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1788
3615
59b36aaa050a (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
  1789
/** Top function to save the new value of an element of the Patches struct
3118
99926945ccb1 (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
  1790
 * @param index offset in the SettingDesc array of the Patches struct which
99926945ccb1 (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
  1791
 * identifies the patch member we want to change
99926945ccb1 (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
  1792
 * @param object pointer to a valid patches struct that has its settings change.
99926945ccb1 (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
  1793
 * This only affects patch-members that are not needed to be the same on all
99926945ccb1 (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
  1794
 * clients in a network game.
99926945ccb1 (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
  1795
 * @param value new value of the patch */
4600
c3d1ca65a598 (svn r6450) -Feature: Make the 'patch' console command available for offline use and for
Darkvater
parents: 4590
diff changeset
  1796
bool SetPatchValue(uint index, const Patches *object, int32 value)
3118
99926945ccb1 (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
  1797
{
99926945ccb1 (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
  1798
	const SettingDesc *sd = &_patch_settings[index];
99926945ccb1 (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
  1799
	/* If an item is player-based, we do not send it over the network
99926945ccb1 (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
  1800
	 * (if any) to change. Also *hack*hack* we update the _newgame version
99926945ccb1 (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
  1801
	 * of patches because changing a player-based setting in a game also
99926945ccb1 (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
  1802
	 * changes its defaults. At least that is the convention we have chosen */
99926945ccb1 (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
  1803
	if (sd->save.conv & SLF_NETWORK_NO) {
5141
05a806850445 (svn r7231) -Codechange: rename ini_get_variable to GetVariableAddress for use both in settings.c
Darkvater
parents: 5116
diff changeset
  1804
		void *var = GetVariableAddress(object, &sd->save);
3118
99926945ccb1 (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
  1805
		Write_ValidateSetting(var, sd, value);
3121
2e50f731567a (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
  1806
2e50f731567a (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
  1807
		if (_game_mode != GM_MENU) {
5141
05a806850445 (svn r7231) -Codechange: rename ini_get_variable to GetVariableAddress for use both in settings.c
Darkvater
parents: 5116
diff changeset
  1808
			void *var2 = GetVariableAddress(&_patches_newgame, &sd->save);
4077
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4065
diff changeset
  1809
			Write_ValidateSetting(var2, sd, value);
3121
2e50f731567a (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
  1810
		}
5113
5626f4b8b46e (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
  1811
		if (sd->desc.proc != NULL) sd->desc.proc((int32)ReadValue(var, sd->save.conv));
4600
c3d1ca65a598 (svn r6450) -Feature: Make the 'patch' console command available for offline use and for
Darkvater
parents: 4590
diff changeset
  1812
		InvalidateWindow(WC_GAME_OPTIONS, 0);
c3d1ca65a598 (svn r6450) -Feature: Make the 'patch' console command available for offline use and for
Darkvater
parents: 4590
diff changeset
  1813
		return true;
3118
99926945ccb1 (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
  1814
	}
4600
c3d1ca65a598 (svn r6450) -Feature: Make the 'patch' console command available for offline use and for
Darkvater
parents: 4590
diff changeset
  1815
c3d1ca65a598 (svn r6450) -Feature: Make the 'patch' console command available for offline use and for
Darkvater
parents: 4590
diff changeset
  1816
	/* send non-player-based settings over the network */
c3d1ca65a598 (svn r6450) -Feature: Make the 'patch' console command available for offline use and for
Darkvater
parents: 4590
diff changeset
  1817
	if (!_networking || (_networking && _network_server)) {
c3d1ca65a598 (svn r6450) -Feature: Make the 'patch' console command available for offline use and for
Darkvater
parents: 4590
diff changeset
  1818
		return DoCommandP(0, index, value, NULL, CMD_CHANGE_PATCH_SETTING);
c3d1ca65a598 (svn r6450) -Feature: Make the 'patch' console command available for offline use and for
Darkvater
parents: 4590
diff changeset
  1819
	}
c3d1ca65a598 (svn r6450) -Feature: Make the 'patch' console command available for offline use and for
Darkvater
parents: 4590
diff changeset
  1820
	return false;
3118
99926945ccb1 (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
  1821
}
99926945ccb1 (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
  1822
3247
4e70e64adbb8 (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
  1823
const SettingDesc *GetPatchFromName(const char *name, uint *i)
3119
08471cfc4ef8 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1824
{
08471cfc4ef8 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1825
	const SettingDesc *sd;
08471cfc4ef8 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1826
3131
e856656f99a9 (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
  1827
	for (*i = 0, sd = _patch_settings; sd->save.cmd != SL_END; sd++, (*i)++) {
3223
abf18a71767b (svn r3896) - [Patches] Fix: Honour any conditional settings when retrieving the setting entries.
Darkvater
parents: 3222
diff changeset
  1828
		if (!SlIsObjectCurrentlyValid(sd->save.version_from, sd->save.version_to)) continue;
3210
c77ce9799650 (svn r3880) - just do a string compare without length restrictions; followup for r3875
Darkvater
parents: 3207
diff changeset
  1829
		if (strcmp(sd->desc.name, name) == 0) return sd;
3119
08471cfc4ef8 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1830
	}
08471cfc4ef8 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1831
08471cfc4ef8 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1832
	return NULL;
08471cfc4ef8 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1833
}
08471cfc4ef8 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1834
08471cfc4ef8 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1835
/* Those 2 functions need to be here, else we have to make some stuff non-static
4278
0025a4267abe (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
  1836
 * and besides, it is also better to keep stuff like this at the same place */
4600
c3d1ca65a598 (svn r6450) -Feature: Make the 'patch' console command available for offline use and for
Darkvater
parents: 4590
diff changeset
  1837
bool IConsoleSetPatchSetting(const char *name, int32 value)
3119
08471cfc4ef8 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1838
{
4600
c3d1ca65a598 (svn r6450) -Feature: Make the 'patch' console command available for offline use and for
Darkvater
parents: 4590
diff changeset
  1839
	bool success;
3119
08471cfc4ef8 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1840
	uint index;
08471cfc4ef8 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1841
	const SettingDesc *sd = GetPatchFromName(name, &index);
08471cfc4ef8 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1842
	const Patches *patches_ptr;
08471cfc4ef8 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1843
	void *ptr;
08471cfc4ef8 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1844
08471cfc4ef8 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1845
	if (sd == NULL) {
08471cfc4ef8 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1846
		IConsolePrintF(_icolour_warn, "'%s' is an unknown patch setting.", name);
4600
c3d1ca65a598 (svn r6450) -Feature: Make the 'patch' console command available for offline use and for
Darkvater
parents: 4590
diff changeset
  1847
		return true;
3119
08471cfc4ef8 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1848
	}
08471cfc4ef8 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1849
3121
2e50f731567a (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
  1850
	patches_ptr = (_game_mode == GM_MENU) ? &_patches_newgame : &_patches;
5141
05a806850445 (svn r7231) -Codechange: rename ini_get_variable to GetVariableAddress for use both in settings.c
Darkvater
parents: 5116
diff changeset
  1851
	ptr = GetVariableAddress(patches_ptr, &sd->save);
3119
08471cfc4ef8 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1852
4600
c3d1ca65a598 (svn r6450) -Feature: Make the 'patch' console command available for offline use and for
Darkvater
parents: 4590
diff changeset
  1853
	success = SetPatchValue(index, patches_ptr, value);
c3d1ca65a598 (svn r6450) -Feature: Make the 'patch' console command available for offline use and for
Darkvater
parents: 4590
diff changeset
  1854
	return success;
3119
08471cfc4ef8 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1855
}
08471cfc4ef8 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1856
08471cfc4ef8 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1857
void IConsoleGetPatchSetting(const char *name)
08471cfc4ef8 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1858
{
08471cfc4ef8 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1859
	char value[20];
08471cfc4ef8 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1860
	uint index;
08471cfc4ef8 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1861
	const SettingDesc *sd = GetPatchFromName(name, &index);
08471cfc4ef8 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1862
	const void *ptr;
08471cfc4ef8 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1863
08471cfc4ef8 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1864
	if (sd == NULL) {
08471cfc4ef8 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1865
		IConsolePrintF(_icolour_warn, "'%s' is an unknown patch setting.", name);
08471cfc4ef8 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1866
		return;
08471cfc4ef8 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1867
	}
08471cfc4ef8 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1868
5141
05a806850445 (svn r7231) -Codechange: rename ini_get_variable to GetVariableAddress for use both in settings.c
Darkvater
parents: 5116
diff changeset
  1869
	ptr = GetVariableAddress((_game_mode == GM_MENU) ? &_patches_newgame : &_patches, &sd->save);
3119
08471cfc4ef8 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1870
08471cfc4ef8 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1871
	if (sd->desc.cmd == SDT_BOOLX) {
08471cfc4ef8 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1872
		snprintf(value, sizeof(value), (*(bool*)ptr == 1) ? "on" : "off");
08471cfc4ef8 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1873
	} else {
08471cfc4ef8 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1874
		snprintf(value, sizeof(value), "%d", (int32)ReadValue(ptr, sd->save.conv));
08471cfc4ef8 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1875
	}
08471cfc4ef8 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1876
08471cfc4ef8 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1877
	IConsolePrintF(_icolour_warn, "Current value for '%s' is: '%s' (min: %s%d, max: %d)",
08471cfc4ef8 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1878
		name, value, (sd->desc.flags & SGF_0ISDISABLED) ? "(0) " : "", sd->desc.min, sd->desc.max);
08471cfc4ef8 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1879
}
08471cfc4ef8 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1880
9908
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
  1881
void IConsoleListPatches()
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
  1882
{
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
  1883
	IConsolePrintF(_icolour_warn, "All patches with their current value:");
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
  1884
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
  1885
	for (const SettingDesc *sd = _patch_settings; sd->save.cmd != SL_END; sd++) {
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
  1886
		char value[80];
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
  1887
		const void *ptr = GetVariableAddress((_game_mode == GM_MENU) ? &_patches_newgame : &_patches, &sd->save);
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
  1888
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
  1889
		if (sd->desc.cmd == SDT_BOOLX) {
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
  1890
			snprintf(value, lengthof(value), (*(bool*)ptr == 1) ? "on" : "off");
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
  1891
		} else {
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
  1892
			snprintf(value, lengthof(value), "%d", (uint32)ReadValue(ptr, sd->save.conv));
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
  1893
		}
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
  1894
		IConsolePrintF(_icolour_def, "%s = %s", sd->desc.name, value);
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
  1895
	}
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
  1896
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
  1897
	IConsolePrintF(_icolour_warn, "Use 'patch' command to change a value");
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
  1898
}
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9907
diff changeset
  1899
3117
8066b8d0802b (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
  1900
/** Save and load handler for patches/settings
8066b8d0802b (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
  1901
 * @param osd SettingDesc struct containing all information
8066b8d0802b (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
  1902
 * @param object can be either NULL in which case we load global variables or
8066b8d0802b (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
  1903
 * a pointer to a struct which is getting saved */
8066b8d0802b (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
  1904
static void LoadSettings(const SettingDesc *osd, void *object)
8066b8d0802b (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
  1905
{
8066b8d0802b (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
  1906
	for (; osd->save.cmd != SL_END; osd++) {
8066b8d0802b (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
  1907
		const SaveLoad *sld = &osd->save;
5141
05a806850445 (svn r7231) -Codechange: rename ini_get_variable to GetVariableAddress for use both in settings.c
Darkvater
parents: 5116
diff changeset
  1908
		void *ptr = GetVariableAddress(object, sld);
3117
8066b8d0802b (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
  1909
8066b8d0802b (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
  1910
		if (!SlObjectMember(ptr, sld)) continue;
8066b8d0802b (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
  1911
	}
8066b8d0802b (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
  1912
}
8066b8d0802b (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
  1913
8066b8d0802b (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
  1914
/** Loadhandler for a list of global variables
9909
dce9a6923bb7 (svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents: 9908
diff changeset
  1915
 * @param sdg pointer for the global variable list SettingDescGlobVarList
3117
8066b8d0802b (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
  1916
 * @note this is actually a stub for LoadSettings with the
8066b8d0802b (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
  1917
 * object pointer set to NULL */
8066b8d0802b (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
  1918
static inline void LoadSettingsGlobList(const SettingDescGlobVarList *sdg)
8066b8d0802b (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
  1919
{
8066b8d0802b (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
  1920
	LoadSettings((const SettingDesc*)sdg, NULL);
8066b8d0802b (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
  1921
}
8066b8d0802b (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
  1922
8066b8d0802b (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
  1923
/** Save and load handler for patches/settings
9909
dce9a6923bb7 (svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents: 9908
diff changeset
  1924
 * @param sd SettingDesc struct containing all information
3117
8066b8d0802b (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
  1925
 * @param object can be either NULL in which case we load global variables or
8066b8d0802b (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
  1926
 * a pointer to a struct which is getting saved */
8066b8d0802b (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
  1927
static void SaveSettings(const SettingDesc *sd, void *object)
8066b8d0802b (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
  1928
{
8066b8d0802b (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
  1929
	/* We need to write the CH_RIFF header, but unfortunately can't call
8066b8d0802b (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
  1930
	 * SlCalcLength() because we have a different format. So do this manually */
8066b8d0802b (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
  1931
	const SettingDesc *i;
8066b8d0802b (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
  1932
	size_t length = 0;
8066b8d0802b (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
  1933
	for (i = sd; i->save.cmd != SL_END; i++) {
5142
d423c895a5b4 (svn r7232) -Codechange: Also allow for the save/load of non pre-allocated strings inside structs.
Darkvater
parents: 5141
diff changeset
  1934
		const void *ptr = GetVariableAddress(object, &i->save);
d423c895a5b4 (svn r7232) -Codechange: Also allow for the save/load of non pre-allocated strings inside structs.
Darkvater
parents: 5141
diff changeset
  1935
		length += SlCalcObjMemberLength(ptr, &i->save);
3117
8066b8d0802b (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
  1936
	}
8066b8d0802b (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
  1937
	SlSetLength(length);
8066b8d0802b (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
  1938
8066b8d0802b (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
  1939
	for (i = sd; i->save.cmd != SL_END; i++) {
5141
05a806850445 (svn r7231) -Codechange: rename ini_get_variable to GetVariableAddress for use both in settings.c
Darkvater
parents: 5116
diff changeset
  1940
		void *ptr = GetVariableAddress(object, &i->save);
3117
8066b8d0802b (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
  1941
		SlObjectMember(ptr, &i->save);
8066b8d0802b (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
  1942
	}
8066b8d0802b (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
  1943
}
8066b8d0802b (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
  1944
8066b8d0802b (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
  1945
/** Savehandler for a list of global variables
8066b8d0802b (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
  1946
 * @note this is actually a stub for SaveSettings with the
8066b8d0802b (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
  1947
 * object pointer set to NULL */
8066b8d0802b (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
  1948
static inline void SaveSettingsGlobList(const SettingDescGlobVarList *sdg)
8066b8d0802b (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
  1949
{
8066b8d0802b (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
  1950
	SaveSettings((const SettingDesc*)sdg, NULL);
8066b8d0802b (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
  1951
}
8066b8d0802b (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
  1952
9895
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6338
diff changeset
  1953
static void Load_OPTS()
3117
8066b8d0802b (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
  1954
{
8066b8d0802b (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
  1955
	/* Copy over default setting since some might not get loaded in
8066b8d0802b (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
  1956
	 * a networking environment. This ensures for example that the local
8066b8d0802b (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
  1957
	 * autosave-frequency stays when joining a network-server */
8066b8d0802b (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
  1958
	_opt = _opt_newgame;
8066b8d0802b (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
  1959
	LoadSettings(_gameopt_settings, &_opt);
8066b8d0802b (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
  1960
}
8066b8d0802b (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
  1961
9895
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6338
diff changeset
  1962
static void Save_OPTS()
3117
8066b8d0802b (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
  1963
{
8066b8d0802b (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
  1964
	SaveSettings(_gameopt_settings, &_opt);
8066b8d0802b (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
  1965
}
8066b8d0802b (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
  1966
9895
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6338
diff changeset
  1967
static void Load_PATS()
3121
2e50f731567a (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
  1968
{
2e50f731567a (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
  1969
	/* Copy over default setting since some might not get loaded in
2e50f731567a (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
  1970
	 * a networking environment. This ensures for example that the local
2e50f731567a (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
  1971
	 * signal_side stays when joining a network-server */
2e50f731567a (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
  1972
	_patches = _patches_newgame;
2e50f731567a (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
  1973
	LoadSettings(_patch_settings, &_patches);
2e50f731567a (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
  1974
}
2e50f731567a (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
  1975
9895
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6338
diff changeset
  1976
static void Save_PATS()
3121
2e50f731567a (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
  1977
{
2e50f731567a (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
  1978
	SaveSettings(_patch_settings, &_patches);
2e50f731567a (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
  1979
}
2e50f731567a (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
  1980
9895
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6338
diff changeset
  1981
void CheckConfig()
1688
787400219027 (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
  1982
{
2044
68ec4a2f2d79 (svn r2553) - Fix: [pathfinding] Remove old-old train pathfinder. Enhanced old pathfinder.
ludde
parents: 2008
diff changeset
  1983
	// Increase old default values for pf_maxdepth and pf_maxlength
68ec4a2f2d79 (svn r2553) - Fix: [pathfinding] Remove old-old train pathfinder. Enhanced old pathfinder.
ludde
parents: 2008
diff changeset
  1984
	// to support big networks.
3121
2e50f731567a (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
  1985
	if (_patches_newgame.pf_maxdepth == 16 && _patches_newgame.pf_maxlength == 512) {
2e50f731567a (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
  1986
		_patches_newgame.pf_maxdepth = 48;
2e50f731567a (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
  1987
		_patches_newgame.pf_maxlength = 4096;
2044
68ec4a2f2d79 (svn r2553) - Fix: [pathfinding] Remove old-old train pathfinder. Enhanced old pathfinder.
ludde
parents: 2008
diff changeset
  1988
	}
1688
787400219027 (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
  1989
}
3112
05a599216d83 (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
  1990
9895
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6338
diff changeset
  1991
void UpdatePatches()
3121
2e50f731567a (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
  1992
{
2e50f731567a (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
  1993
	/* Since old(er) savegames don't have any patches saved, we initialise
2e50f731567a (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
  1994
	 * them with the default values just as it was in the old days.
2e50f731567a (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
  1995
	 * Also new games need this copying-over */
2e50f731567a (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
  1996
	_patches = _patches_newgame; /* backwards compatibility */
2e50f731567a (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
  1997
}
2e50f731567a (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
  1998
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5835
diff changeset
  1999
extern const ChunkHandler _setting_chunk_handlers[] = {
3121
2e50f731567a (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
  2000
	{ 'OPTS', Save_OPTS, Load_OPTS, CH_RIFF},
2e50f731567a (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
  2001
	{ 'PATS', Save_PATS, Load_PATS, CH_RIFF | CH_LAST},
3112
05a599216d83 (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
  2002
};
3900
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3874
diff changeset
  2003
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3874
diff changeset
  2004
static bool IsSignedVarMemType(VarType vt)
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3874
diff changeset
  2005
{
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3874
diff changeset
  2006
	switch (GetVarMemType(vt)) {
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3874
diff changeset
  2007
		case SLE_VAR_I8:
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3874
diff changeset
  2008
		case SLE_VAR_I16:
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3874
diff changeset
  2009
		case SLE_VAR_I32:
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3874
diff changeset
  2010
		case SLE_VAR_I64:
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3874
diff changeset
  2011
			return true;
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3874
diff changeset
  2012
	}
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3874
diff changeset
  2013
	return false;
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3874
diff changeset
  2014
}