settings.c
author Darkvater
Sat, 22 Apr 2006 00:10:38 +0000
changeset 3615 4afd81377ba3
parent 3606 743a2cd312a9
child 3628 69646d0924a5
permissions -rw-r--r--
(svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
2186
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     1
/* $Id$ */
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     2
3615
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
     3
/** @file
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
     4
 * All actions handling saving and loading of the settings/configuration goes on in this file.
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
     5
 * The file consists of four parts:
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
     6
 * <ol>
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
     7
 * <li>Parsing the configuration file (openttd.cfg). This is achieved with the ini_ functions which
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
     8
 *     handle various types, such as normal 'key = value' pairs, lists and value combinations of
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
     9
 *     lists, strings, integers, 'bit'-masks and element selections.
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
    10
 * <li>Defining the data structures that go into the configuration. These include for example
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
    11
 *     the _patches struct, but also network-settings, banlists, newgrf, etc. There are a lot
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
    12
 *     of helper macros available for the various types, and also saving/loading of these settings
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
    13
 *     in a savegame is handled inside these structures.
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
    14
 * <li>Handle reading and writing to the setting-structures from inside the game either from
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
    15
 *     the console for example or through the gui with CMD_ functions.
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
    16
 * <li>Handle saving/loading of the PATS chunk inside the savegame.
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
    17
 * </ol>
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
    18
 * @see SettingDesc
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
    19
 * @see SaveLoad
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
    20
 */
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
    21
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    22
#include "stdafx.h"
1891
862800791170 (svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents: 1777
diff changeset
    23
#include "openttd.h"
2291
c142846954ee (svn r2815) Store the currency information in one central place instead of scattering it in several unrelated files
tron
parents: 2191
diff changeset
    24
#include "currency.h"
2163
b17b313113a0 (svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents: 2153
diff changeset
    25
#include "functions.h"
2191
5bcc2e995aa6 (svn r2706) Fix !WITH_NETWORK build
tron
parents: 2186
diff changeset
    26
#include "macros.h"
2121
267f7d75d036 (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
3c90086ff34f (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
ecfc674410b4 (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"
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
    31
#include "network.h"
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
    32
#include "settings.h"
3119
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
    33
#include "command.h"
8f1b561d9870 (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
a6fda4d4c7ca (svn r3716) - Move the option settings (_game_opt_desc) from misc.c into settings.c. This will be merged with SettingDesc misc_settings above as they are actually the same. No functionality has changed beside the fact that the settings are now in a different Chunkhandler.
Darkvater
parents: 3052
diff changeset
    35
#include "saveload.h"
3358
c69b64a580b2 (svn r4153) -Codechange. Changed NPF_TILE_LENGTH into an enum and moved it out of variables.h. Just a drop in the bucket, but it is a start
celestar
parents: 3352
diff changeset
    36
#include "npf.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    37
3121
72fb0554f9f1 (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
    38
/** The patch values that are used for new games and/or modified in config file */
72fb0554f9f1 (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
    39
Patches _patches_newgame;
72fb0554f9f1 (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
    40
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    41
typedef struct IniFile IniFile;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    42
typedef struct IniItem IniItem;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    43
typedef struct IniGroup IniGroup;
1258
220b6e3b4d10 (svn r1762) -Codechange: renamed 'MemoryPool' to 'SettingsMemoryPool' (we need
truelight
parents: 1247
diff changeset
    44
typedef struct SettingsMemoryPool SettingsMemoryPool;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    45
1258
220b6e3b4d10 (svn r1762) -Codechange: renamed 'MemoryPool' to 'SettingsMemoryPool' (we need
truelight
parents: 1247
diff changeset
    46
static void pool_init(SettingsMemoryPool **pool);
220b6e3b4d10 (svn r1762) -Codechange: renamed 'MemoryPool' to 'SettingsMemoryPool' (we need
truelight
parents: 1247
diff changeset
    47
static void *pool_alloc(SettingsMemoryPool **pool, uint size);
220b6e3b4d10 (svn r1762) -Codechange: renamed 'MemoryPool' to 'SettingsMemoryPool' (we need
truelight
parents: 1247
diff changeset
    48
static void *pool_strdup(SettingsMemoryPool **pool, const char *mem, uint size);
220b6e3b4d10 (svn r1762) -Codechange: renamed 'MemoryPool' to 'SettingsMemoryPool' (we need
truelight
parents: 1247
diff changeset
    49
static void pool_free(SettingsMemoryPool **pool);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    50
1258
220b6e3b4d10 (svn r1762) -Codechange: renamed 'MemoryPool' to 'SettingsMemoryPool' (we need
truelight
parents: 1247
diff changeset
    51
struct SettingsMemoryPool {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    52
	uint pos,size;
1258
220b6e3b4d10 (svn r1762) -Codechange: renamed 'MemoryPool' to 'SettingsMemoryPool' (we need
truelight
parents: 1247
diff changeset
    53
	SettingsMemoryPool *next;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    54
	byte mem[1];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    55
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    56
1258
220b6e3b4d10 (svn r1762) -Codechange: renamed 'MemoryPool' to 'SettingsMemoryPool' (we need
truelight
parents: 1247
diff changeset
    57
static SettingsMemoryPool *pool_new(uint minsize)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    58
{
1258
220b6e3b4d10 (svn r1762) -Codechange: renamed 'MemoryPool' to 'SettingsMemoryPool' (we need
truelight
parents: 1247
diff changeset
    59
	SettingsMemoryPool *p;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    60
	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
    61
1258
220b6e3b4d10 (svn r1762) -Codechange: renamed 'MemoryPool' to 'SettingsMemoryPool' (we need
truelight
parents: 1247
diff changeset
    62
	p = malloc(sizeof(SettingsMemoryPool) - 1 + minsize);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    63
	p->pos = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    64
	p->size = minsize;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    65
	p->next = NULL;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    66
	return p;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    67
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    68
1258
220b6e3b4d10 (svn r1762) -Codechange: renamed 'MemoryPool' to 'SettingsMemoryPool' (we need
truelight
parents: 1247
diff changeset
    69
static void pool_init(SettingsMemoryPool **pool)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    70
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    71
	*pool = pool_new(0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    72
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    73
1258
220b6e3b4d10 (svn r1762) -Codechange: renamed 'MemoryPool' to 'SettingsMemoryPool' (we need
truelight
parents: 1247
diff changeset
    74
static void *pool_alloc(SettingsMemoryPool **pool, uint size)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    75
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    76
	uint pos;
1258
220b6e3b4d10 (svn r1762) -Codechange: renamed 'MemoryPool' to 'SettingsMemoryPool' (we need
truelight
parents: 1247
diff changeset
    77
	SettingsMemoryPool *p = *pool;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    78
2450
d7edd1def1e0 (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
    79
	size = ALIGN(size, sizeof(void*));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    80
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    81
	// first check if there's memory in the next pool
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    82
	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
    83
		p = p->next;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    84
	// then check if there's not memory in the cur pool
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    85
	} else if (p->pos + size > p->size) {
1258
220b6e3b4d10 (svn r1762) -Codechange: renamed 'MemoryPool' to 'SettingsMemoryPool' (we need
truelight
parents: 1247
diff changeset
    86
		SettingsMemoryPool *n = pool_new(size);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    87
		*pool = n;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    88
		n->next = p;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 188
diff changeset
    89
		p = n;
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
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    92
	pos = p->pos;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    93
	p->pos += size;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    94
	return p->mem + pos;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    95
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    96
1258
220b6e3b4d10 (svn r1762) -Codechange: renamed 'MemoryPool' to 'SettingsMemoryPool' (we need
truelight
parents: 1247
diff changeset
    97
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
    98
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    99
	byte *p = pool_alloc(pool, size + 1);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   100
	p[size] = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   101
	memcpy(p, mem, size);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   102
	return p;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   103
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   104
1258
220b6e3b4d10 (svn r1762) -Codechange: renamed 'MemoryPool' to 'SettingsMemoryPool' (we need
truelight
parents: 1247
diff changeset
   105
static void pool_free(SettingsMemoryPool **pool)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   106
{
1258
220b6e3b4d10 (svn r1762) -Codechange: renamed 'MemoryPool' to 'SettingsMemoryPool' (we need
truelight
parents: 1247
diff changeset
   107
	SettingsMemoryPool *p = *pool, *n;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   108
	*pool = NULL;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   109
	while (p) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   110
		n = p->next;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   111
		free(p);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   112
		p = n;
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
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   115
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   116
// structs describing the ini format.
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   117
struct IniItem {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   118
	char *name;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   119
	char *value;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   120
	char *comment;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   121
	IniItem *next;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   122
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   123
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   124
struct IniGroup {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   125
	char *name; // name of group
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   126
	char *comment; //comment for group
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   127
	IniItem *item, **last_item;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   128
	IniGroup *next;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   129
	IniFile *ini;
705
71cf9f0d7e7f (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
   130
	IniGroupType type; // type of group
0
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
struct IniFile {
1258
220b6e3b4d10 (svn r1762) -Codechange: renamed 'MemoryPool' to 'SettingsMemoryPool' (we need
truelight
parents: 1247
diff changeset
   134
	SettingsMemoryPool *pool;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   135
	IniGroup *group, **last_group;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   136
	char *comment; // last comment in file
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   137
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   138
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   139
// allocate an inifile object
1093
4fdc46eaf423 (svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents: 1037
diff changeset
   140
static IniFile *ini_alloc(void)
0
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
	IniFile *ini;
1258
220b6e3b4d10 (svn r1762) -Codechange: renamed 'MemoryPool' to 'SettingsMemoryPool' (we need
truelight
parents: 1247
diff changeset
   143
	SettingsMemoryPool *pool;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   144
	pool_init(&pool);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   145
	ini = (IniFile*)pool_alloc(&pool, sizeof(IniFile));
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   146
	ini->pool = pool;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   147
	ini->group = NULL;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   148
	ini->last_group = &ini->group;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   149
	ini->comment = NULL;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   150
	return ini;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   151
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   152
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   153
// allocate an ini group object
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   154
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
   155
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   156
	IniGroup *grp = pool_alloc(&ini->pool, sizeof(IniGroup));
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   157
	grp->ini = ini;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   158
	grp->name = pool_strdup(&ini->pool, grpt, len);
2953
4d933ef9a41f (svn r3512) Yet more whitespace fixes (mostly by Rubidium)
peter1138
parents: 2952
diff changeset
   159
	if (!strcmp(grp->name, "newgrf") || !strcmp(grp->name, "servers") || !strcmp(grp->name, "bans")) {
705
71cf9f0d7e7f (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
   160
		grp->type = IGT_LIST;
2953
4d933ef9a41f (svn r3512) Yet more whitespace fixes (mostly by Rubidium)
peter1138
parents: 2952
diff changeset
   161
	} else {
705
71cf9f0d7e7f (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
   162
		grp->type = IGT_VARIABLES;
2953
4d933ef9a41f (svn r3512) Yet more whitespace fixes (mostly by Rubidium)
peter1138
parents: 2952
diff changeset
   163
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   164
	grp->next = NULL;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   165
	grp->item = NULL;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   166
	grp->comment = NULL;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   167
	grp->last_item = &grp->item;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   168
	*ini->last_group = grp;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   169
	ini->last_group = &grp->next;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   170
	return grp;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   171
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   172
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   173
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
   174
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   175
	IniItem *item = pool_alloc(&group->ini->pool, sizeof(IniItem));
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   176
	item->name = pool_strdup(&group->ini->pool, name, len);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   177
	item->next = NULL;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   178
	item->comment = NULL;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   179
	item->value = NULL;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   180
	*group->last_item = item;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   181
	group->last_item = &item->next;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   182
	return item;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   183
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   184
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   185
// load an ini file into the "abstract" format
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   186
static IniFile *ini_load(const char *filename)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   187
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   188
	char buffer[1024], c, *s, *t, *e;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   189
	FILE *in;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   190
	IniFile *ini;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   191
	IniGroup *group = NULL;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   192
	IniItem *item;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   193
1329
6988419aa6f0 (svn r1833) byte -> char transition: the rest
tron
parents: 1317
diff changeset
   194
	char *comment = NULL;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   195
	uint comment_size = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   196
	uint comment_alloc = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   197
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   198
	ini = ini_alloc();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   199
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   200
	in = fopen(filename, "r");
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   201
	if (in == NULL) return ini;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   202
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   203
	// for each line in the file
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   204
	while (fgets(buffer, sizeof(buffer), in)) {
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 188
diff changeset
   205
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   206
		// trim whitespace from the left side
3598
a02daaf41761 (svn r4489) - Codechange: some small cleanups in the settings-parser code, mainly substituting terminating 0 characters with '\0'.
Darkvater
parents: 3596
diff changeset
   207
		for (s = buffer; *s == ' ' || *s == '\t'; s++);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   208
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   209
		// trim whitespace from right side.
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   210
		e = s + strlen(s);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   211
		while (e > s && ((c=e[-1]) == '\n' || c == '\r' || c == ' ' || c == '\t')) e--;
3598
a02daaf41761 (svn r4489) - Codechange: some small cleanups in the settings-parser code, mainly substituting terminating 0 characters with '\0'.
Darkvater
parents: 3596
diff changeset
   212
		*e = '\0';
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   213
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   214
		// skip comments and empty lines
3598
a02daaf41761 (svn r4489) - Codechange: some small cleanups in the settings-parser code, mainly substituting terminating 0 characters with '\0'.
Darkvater
parents: 3596
diff changeset
   215
		if (*s == '#' || *s == '\0') {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   216
			uint ns = comment_size + (e - s + 1);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   217
			uint a = comment_alloc;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   218
			uint pos;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   219
			// add to comment
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   220
			if (ns > a) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   221
				a = max(a, 128);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   222
				do a*=2; while (a < ns);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   223
				comment = realloc(comment, comment_alloc = a);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   224
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   225
			pos = comment_size;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   226
			comment_size += (e - s + 1);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   227
			comment[pos + e - s] = '\n'; // comment newline
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   228
			memcpy(comment + pos, s, e - s); // copy comment contents
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   229
			continue;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   230
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   231
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   232
		// it's a group?
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   233
		if (s[0] == '[') {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   234
			if (e[-1] != ']')
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   235
				ShowInfoF("ini: invalid group name '%s'\n", buffer);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   236
			else
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   237
				e--;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   238
			s++; // skip [
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   239
			group = ini_group_alloc(ini, s, e - s);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   240
			if (comment_size) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   241
				group->comment = pool_strdup(&ini->pool, comment, comment_size);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   242
				comment_size = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   243
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   244
		} else if (group) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   245
			// find end of keyname
3598
a02daaf41761 (svn r4489) - Codechange: some small cleanups in the settings-parser code, mainly substituting terminating 0 characters with '\0'.
Darkvater
parents: 3596
diff changeset
   246
			for (t = s; *t != '\0' && *t != '=' && *t != '\t' && *t != ' '; t++);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 188
diff changeset
   247
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   248
			// it's an item in an existing group
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   249
			item = ini_item_alloc(group, s, t-s);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   250
			if (comment_size) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   251
				item->comment = pool_strdup(&ini->pool, comment, comment_size);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   252
				comment_size = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   253
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   254
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   255
			// find start of parameter
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   256
			while (*t == '=' || *t == ' ' || *t == '\t') t++;
759
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 738
diff changeset
   257
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 738
diff changeset
   258
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 738
diff changeset
   259
			// remove starting quotation marks
2952
58522ed8f0f1 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2923
diff changeset
   260
			if (*t == '\"') t++;
759
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 738
diff changeset
   261
			// remove ending quotation marks
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 738
diff changeset
   262
			e = t + strlen(t);
3598
a02daaf41761 (svn r4489) - Codechange: some small cleanups in the settings-parser code, mainly substituting terminating 0 characters with '\0'.
Darkvater
parents: 3596
diff changeset
   263
			if (e > t && e[-1] == '\"') e--;
a02daaf41761 (svn r4489) - Codechange: some small cleanups in the settings-parser code, mainly substituting terminating 0 characters with '\0'.
Darkvater
parents: 3596
diff changeset
   264
			*e = '\0';
759
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 738
diff changeset
   265
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   266
			item->value = pool_strdup(&ini->pool, t, e - t);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   267
		} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   268
			// it's an orphan item
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   269
			ShowInfoF("ini: '%s' outside of group\n", buffer);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   270
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   271
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   272
3615
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   273
	if (comment_size > 0) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   274
		ini->comment = pool_strdup(&ini->pool, comment, comment_size);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   275
		comment_size = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   276
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   277
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   278
	free(comment);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   279
	fclose(in);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   280
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   281
	return ini;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   282
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   283
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   284
// lookup a group or make a new one
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   285
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
   286
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   287
	IniGroup *group;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   288
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   289
	if (len == -1) len = strlen(name);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   290
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   291
	// does it exist already?
2952
58522ed8f0f1 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2923
diff changeset
   292
	for (group = ini->group; group; group = group->next)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   293
		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
   294
			return group;
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
	// otherwise make a new one
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   297
	group = ini_group_alloc(ini, name, len);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   298
	group->comment = pool_strdup(&ini->pool, "\n", 1);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   299
	return group;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   300
}
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
// lookup an item or make a new one
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   303
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
   304
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   305
	IniItem *item;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   306
	uint len = strlen(name);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   307
2952
58522ed8f0f1 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2923
diff changeset
   308
	for (item = group->item; item; item = item->next)
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   309
		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
   310
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   311
	if (!create) return NULL;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   312
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   313
	// otherwise make a new one
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   314
	return ini_item_alloc(group, name, len);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   315
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   316
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   317
// save ini file from the "abstract" format.
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   318
static bool ini_save(const char *filename, IniFile *ini)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   319
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   320
	FILE *f;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   321
	IniGroup *group;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   322
	IniItem *item;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 188
diff changeset
   323
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   324
	f = fopen(filename, "w");
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   325
	if (f == NULL) return false;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   326
2919
3e42ca528f01 (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
   327
	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
   328
		if (group->comment) fputs(group->comment, f);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   329
		fprintf(f, "[%s]\n", group->name);
2919
3e42ca528f01 (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
   330
		for (item = group->item; item != NULL; item = item->next) {
3600
b2f245c26617 (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
   331
			assert(item->value != NULL);
b2f245c26617 (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
   332
			if (item->comment != NULL) fputs(item->comment, f);
b2f245c26617 (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
   333
b2f245c26617 (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
   334
			//*Don't give an equal sign to list items that don't have a parameter */
b2f245c26617 (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
   335
			if (group->type == IGT_LIST && *item->value == '\0') {
b2f245c26617 (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
   336
				fprintf(f, "%s\n", item->name);
b2f245c26617 (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
   337
			} else
b2f245c26617 (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
   338
				fprintf(f, "%s = %s\n", item->name, item->value);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   339
		}
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
	if (ini->comment) fputs(ini->comment, f);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   342
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   343
	fclose(f);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   344
	return true;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   345
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   346
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   347
static void ini_free(IniFile *ini)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   348
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   349
	pool_free(&ini->pool);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   350
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   351
3615
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   352
/** Find the index value of a ONEofMANY type in a string seperated by |
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   353
 * @param many full domain of values the ONEofMANY setting can have
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   354
 * @param one the current value of the setting for which a value needs found
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   355
 * @param onelen force calculation of the *one parameter
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   356
 * @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
   357
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
   358
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   359
	const char *s;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   360
	int idx;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   361
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   362
	if (onelen == -1) onelen = strlen(one);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   363
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   364
	// check if it's an integer
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   365
	if (*one >= '0' && *one <= '9')
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   366
		return strtoul(one, NULL, 0);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 188
diff changeset
   367
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   368
	idx = 0;
2952
58522ed8f0f1 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2923
diff changeset
   369
	for (;;) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   370
		// find end of item
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   371
		s = many;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   372
		while (*s != '|' && *s != 0) s++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   373
		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
   374
		if (*s == 0) return -1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   375
		many = s + 1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   376
		idx++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   377
	}
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
3615
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   380
/** Find the set-integer value MANYofMANY type in a string
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   381
 * @param many full domain of values the MANYofMANY setting can have
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   382
 * @param str the current string value of the setting, each individual
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   383
 * of seperated by a whitespace\tab or | character
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   384
 * @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
   385
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
   386
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   387
	const char *s;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   388
	int r;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   389
	uint32 res = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   390
2952
58522ed8f0f1 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2923
diff changeset
   391
	for (;;) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   392
		// skip "whitespace"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   393
		while (*str == ' ' || *str == '\t' || *str == '|') str++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   394
		if (*str == 0) break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   395
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   396
		s = str;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   397
		while (*s != 0 && *s != ' ' && *s != '\t' && *s != '|') s++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   398
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   399
		r = lookup_oneofmany(many, str, s - str);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   400
		if (r == -1) return (uint32)-1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   401
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   402
		SETBIT(res, r); // value found, set it
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   403
		if (*s == 0) break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   404
		str = s + 1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   405
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   406
	return res;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   407
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   408
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   409
/** Parse an integerlist string and set each found value
3615
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   410
 * @param p the string to be parsed. Each element in the list is seperated by a
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   411
 * comma or a space character
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   412
 * @param items pointer to the integerlist-array that will be filled with values
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   413
 * @param maxitems the maximum number of elements the integerlist-array has
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   414
 * @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
   415
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
   416
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   417
	int n = 0, v;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   418
	char *end;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   419
2952
58522ed8f0f1 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2923
diff changeset
   420
	for (;;) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   421
		v = strtol(p, &end, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   422
		if (p == end || n == maxitems) return -1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   423
		p = end;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   424
		items[n++] = v;
3598
a02daaf41761 (svn r4489) - Codechange: some small cleanups in the settings-parser code, mainly substituting terminating 0 characters with '\0'.
Darkvater
parents: 3596
diff changeset
   425
		if (*p == '\0') break;
3599
c09257ed88f8 (svn r4490) - Feature: The integer-list parser now accepts a space character as an item seperator next to the comma.
Darkvater
parents: 3598
diff changeset
   426
		if (*p != ',' && *p != ' ') return -1;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   427
		p++;
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
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   430
	return n;
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
3615
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   433
/** Load parsed string-values into an integer-array (intlist)
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   434
 * @param str the string that contains the values (and will be parsed)
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   435
 * @param array pointer to the integer-arrays that will be filled
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   436
 * @param nelems the number of elements the array holds. Maximum is 64 elements
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   437
 * @param type the type of elements the array holds (eg INT8, UINT16, etc.)
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   438
 * @return return true on success and false on error */
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   439
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
   440
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   441
	int items[64];
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   442
	int i, nitems;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 188
diff changeset
   443
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   444
	if (str == NULL) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   445
		memset(items, 0, sizeof(items));
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   446
		nitems = nelems;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   447
	} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   448
		nitems = parse_intlist(str, items, lengthof(items));
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   449
		if (nitems != nelems) return false;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   450
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   451
2952
58522ed8f0f1 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2923
diff changeset
   452
	switch (type) {
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   453
	case SLE_VAR_BL:
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   454
	case SLE_VAR_I8:
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   455
	case SLE_VAR_U8:
2952
58522ed8f0f1 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2923
diff changeset
   456
		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
   457
		break;
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   458
	case SLE_VAR_I16:
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   459
	case SLE_VAR_U16:
2952
58522ed8f0f1 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2923
diff changeset
   460
		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
   461
		break;
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   462
	case SLE_VAR_I32:
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   463
	case SLE_VAR_U32:
2952
58522ed8f0f1 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2923
diff changeset
   464
		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
   465
		break;
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   466
	default: NOT_REACHED();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   467
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   468
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   469
	return true;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   470
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   471
3615
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   472
/** Convert an integer-array (intlist) to a string representation. Each value
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   473
 * is seperated by a comma or a space character
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   474
 * @param buf output buffer where the string-representation will be stored
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   475
 * @param array pointer to the integer-arrays that is read from
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   476
 * @param nelems the number of elements the array holds.
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   477
 * @param type the type of elements the array holds (eg INT8, UINT16, etc.) */
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   478
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
   479
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   480
	int i, v = 0;
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   481
	const byte *p = (const byte*)array;
2952
58522ed8f0f1 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2923
diff changeset
   482
58522ed8f0f1 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2923
diff changeset
   483
	for (i = 0; i != nelems; i++) {
58522ed8f0f1 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2923
diff changeset
   484
		switch (type) {
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   485
		case SLE_VAR_BL:
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   486
		case SLE_VAR_I8:  v = *(int8*)p;   p += 1; break;
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   487
		case SLE_VAR_U8:  v = *(byte*)p;   p += 1; break;
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   488
		case SLE_VAR_I16: v = *(int16*)p;  p += 2; break;
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   489
		case SLE_VAR_U16: v = *(uint16*)p; p += 2; break;
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   490
		case SLE_VAR_I32: v = *(int32*)p;  p += 4; break;
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   491
		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
   492
		default: NOT_REACHED();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   493
		}
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   494
		buf += sprintf(buf, (i == 0) ? "%d" : ",%d", v);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   495
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   496
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   497
3615
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   498
/** Convert a ONEofMANY structure to a string representation.
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   499
 * @param buf output buffer where the string-representation will be stored
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   500
 * @param many the full-domain string of possible values
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   501
 * @param id the value of the variable and whose string-representation must be found */
2973
454819aa8fe0 (svn r3548) - [Patches]: rework two loops in make_oneofmany() and make_manyofmany()
Darkvater
parents: 2972
diff changeset
   502
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
   503
{
2973
454819aa8fe0 (svn r3548) - [Patches]: rework two loops in make_oneofmany() and make_manyofmany()
Darkvater
parents: 2972
diff changeset
   504
	int orig_id = id;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   505
2973
454819aa8fe0 (svn r3548) - [Patches]: rework two loops in make_oneofmany() and make_manyofmany()
Darkvater
parents: 2972
diff changeset
   506
	// Look for the id'th element
454819aa8fe0 (svn r3548) - [Patches]: rework two loops in make_oneofmany() and make_manyofmany()
Darkvater
parents: 2972
diff changeset
   507
	while (--id >= 0) {
454819aa8fe0 (svn r3548) - [Patches]: rework two loops in make_oneofmany() and make_manyofmany()
Darkvater
parents: 2972
diff changeset
   508
		for (; *many != '|'; many++) {
454819aa8fe0 (svn r3548) - [Patches]: rework two loops in make_oneofmany() and make_manyofmany()
Darkvater
parents: 2972
diff changeset
   509
			if (*many == '\0') { // not found
454819aa8fe0 (svn r3548) - [Patches]: rework two loops in make_oneofmany() and make_manyofmany()
Darkvater
parents: 2972
diff changeset
   510
				sprintf(buf, "%d", orig_id);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   511
				return;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   512
			}
2973
454819aa8fe0 (svn r3548) - [Patches]: rework two loops in make_oneofmany() and make_manyofmany()
Darkvater
parents: 2972
diff changeset
   513
		}
454819aa8fe0 (svn r3548) - [Patches]: rework two loops in make_oneofmany() and make_manyofmany()
Darkvater
parents: 2972
diff changeset
   514
		many++; // pass the |-character
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   515
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   516
2973
454819aa8fe0 (svn r3548) - [Patches]: rework two loops in make_oneofmany() and make_manyofmany()
Darkvater
parents: 2972
diff changeset
   517
	// copy string until next item (|) or the end of the list if this is the last one
454819aa8fe0 (svn r3548) - [Patches]: rework two loops in make_oneofmany() and make_manyofmany()
Darkvater
parents: 2972
diff changeset
   518
	while (*many != '\0' && *many != '|') *buf++ = *many++;
454819aa8fe0 (svn r3548) - [Patches]: rework two loops in make_oneofmany() and make_manyofmany()
Darkvater
parents: 2972
diff changeset
   519
	*buf = '\0';
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   520
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   521
3615
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   522
/** Convert a MANYofMANY structure to a string representation.
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   523
 * @param buf output buffer where the string-representation will be stored
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   524
 * @param many the full-domain string of possible values
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   525
 * @param x the value of the variable and whose string-representation must
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   526
 *        be found in the bitmasked many string */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   527
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
   528
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   529
	const char *start;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   530
	int i = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   531
	bool init = true;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   532
2973
454819aa8fe0 (svn r3548) - [Patches]: rework two loops in make_oneofmany() and make_manyofmany()
Darkvater
parents: 2972
diff changeset
   533
	for (; x != 0; x >>= 1, i++) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   534
		start = many;
2973
454819aa8fe0 (svn r3548) - [Patches]: rework two loops in make_oneofmany() and make_manyofmany()
Darkvater
parents: 2972
diff changeset
   535
		while (*many != 0 && *many != '|') many++; // advance to the next element
454819aa8fe0 (svn r3548) - [Patches]: rework two loops in make_oneofmany() and make_manyofmany()
Darkvater
parents: 2972
diff changeset
   536
454819aa8fe0 (svn r3548) - [Patches]: rework two loops in make_oneofmany() and make_manyofmany()
Darkvater
parents: 2972
diff changeset
   537
		if (HASBIT(x, 0)) { // item found, copy it
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   538
			if (!init) *buf++ = '|';
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   539
			init = false;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   540
			if (start == many) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   541
				buf += sprintf(buf, "%d", i);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   542
			} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   543
				memcpy(buf, start, many - start);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   544
				buf += many - start;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   545
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   546
		}
2973
454819aa8fe0 (svn r3548) - [Patches]: rework two loops in make_oneofmany() and make_manyofmany()
Darkvater
parents: 2972
diff changeset
   547
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   548
		if (*many == '|') many++;
2973
454819aa8fe0 (svn r3548) - [Patches]: rework two loops in make_oneofmany() and make_manyofmany()
Darkvater
parents: 2972
diff changeset
   549
	}
454819aa8fe0 (svn r3548) - [Patches]: rework two loops in make_oneofmany() and make_manyofmany()
Darkvater
parents: 2972
diff changeset
   550
454819aa8fe0 (svn r3548) - [Patches]: rework two loops in make_oneofmany() and make_manyofmany()
Darkvater
parents: 2972
diff changeset
   551
	*buf = '\0';
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   552
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   553
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   554
/** Convert a string representation (external) of a setting to the internal rep.
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   555
 * @param desc SettingDesc struct that holds all information about the variable
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   556
 * @param str input string that will be parsed based on the type of desc
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   557
 * @return return the parsed value of the setting */
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   558
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
   559
{
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   560
	switch (desc->cmd) {
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   561
	case SDT_NUMX: {
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   562
		char *end;
2991
8a6e9bfa2f2f (svn r3567) -Fix: for once and for all, use 'unsigned long' if you want to cast something
truelight
parents: 2975
diff changeset
   563
		unsigned long val = strtoul(str, &end, 0);
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   564
		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
   565
		return (void*)val;
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   566
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   567
	case SDT_ONEOFMANY: {
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   568
		long r = lookup_oneofmany(desc->many, str, -1);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   569
		if (r != -1) return (void*)r;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   570
		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
   571
		return 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   572
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   573
	case SDT_MANYOFMANY: {
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   574
		unsigned long r = lookup_manyofmany(desc->many, str);
2923
f4d43b8c6a40 (svn r3479) -Fix: fixed warnings on 64bit platforms (anyway, most 64bit platforms)
truelight
parents: 2919
diff changeset
   575
		if (r != (unsigned long)-1) return (void*)r;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   576
		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
   577
		return 0;
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
	case SDT_BOOLX:
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   580
		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
   581
			return (void*)true;
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   582
		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
   583
			return (void*)false;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   584
		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
   585
		break;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 188
diff changeset
   586
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   587
	case SDT_STRING:
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   588
	case SDT_INTLIST: return str;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   589
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   590
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   591
	return NULL;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   592
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   593
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   594
/** Set the value of a setting and if needed clamp the value to
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   595
 * the preset minimum and maximum.
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   596
 * @param ptr the variable itself
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   597
 * @param sd pointer to the 'information'-database of the variable
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   598
 * @param val signed long version of the new value
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   599
 * @pre SettingDesc is of type SDT_BOOLX, SDT_NUMX,
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   600
 * SDT_ONEOFMANY or SDT_MANYOFMANY. Other types are not supported as of now */
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   601
static void Write_ValidateSetting(void *ptr, const SettingDesc *sd, int32 val)
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   602
{
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   603
	const SettingDescBase *sdb = &sd->desc;
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   604
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   605
	if (sdb->cmd != SDT_BOOLX && sdb->cmd != SDT_NUMX &&
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   606
		  sdb->cmd != SDT_ONEOFMANY && sdb->cmd != SDT_MANYOFMANY) return;
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   607
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   608
	/* We cannot know the maximum value of a bitset variable, so just have faith */
3352
99e5e3634e9d (svn r4142) - Fix [FS#74]: Incorrectly loaded settings from the config file when the signed uint32 variable would be negative.
Darkvater
parents: 3342
diff changeset
   609
	if (sdb->cmd != SDT_MANYOFMANY) {
99e5e3634e9d (svn r4142) - Fix [FS#74]: Incorrectly loaded settings from the config file when the signed uint32 variable would be negative.
Darkvater
parents: 3342
diff changeset
   610
		/* We need to take special care of the uint32 type as we receive from the function
99e5e3634e9d (svn r4142) - Fix [FS#74]: Incorrectly loaded settings from the config file when the signed uint32 variable would be negative.
Darkvater
parents: 3342
diff changeset
   611
		 * a signed integer. While here also bail out on 64-bit settings as those are not
99e5e3634e9d (svn r4142) - Fix [FS#74]: Incorrectly loaded settings from the config file when the signed uint32 variable would be negative.
Darkvater
parents: 3342
diff changeset
   612
		 * supported. Unsigned 8 and 16-bit variables are safe since they fit into a signed
99e5e3634e9d (svn r4142) - Fix [FS#74]: Incorrectly loaded settings from the config file when the signed uint32 variable would be negative.
Darkvater
parents: 3342
diff changeset
   613
		 * 32-bit variable
99e5e3634e9d (svn r4142) - Fix [FS#74]: Incorrectly loaded settings from the config file when the signed uint32 variable would be negative.
Darkvater
parents: 3342
diff changeset
   614
		 * TODO: Support 64-bit settings/variables */
99e5e3634e9d (svn r4142) - Fix [FS#74]: Incorrectly loaded settings from the config file when the signed uint32 variable would be negative.
Darkvater
parents: 3342
diff changeset
   615
		switch (GetVarMemType(sd->save.conv)) {
99e5e3634e9d (svn r4142) - Fix [FS#74]: Incorrectly loaded settings from the config file when the signed uint32 variable would be negative.
Darkvater
parents: 3342
diff changeset
   616
			case SLE_VAR_BL:
99e5e3634e9d (svn r4142) - Fix [FS#74]: Incorrectly loaded settings from the config file when the signed uint32 variable would be negative.
Darkvater
parents: 3342
diff changeset
   617
			case SLE_VAR_I8:
99e5e3634e9d (svn r4142) - Fix [FS#74]: Incorrectly loaded settings from the config file when the signed uint32 variable would be negative.
Darkvater
parents: 3342
diff changeset
   618
			case SLE_VAR_U8:
99e5e3634e9d (svn r4142) - Fix [FS#74]: Incorrectly loaded settings from the config file when the signed uint32 variable would be negative.
Darkvater
parents: 3342
diff changeset
   619
			case SLE_VAR_I16:
99e5e3634e9d (svn r4142) - Fix [FS#74]: Incorrectly loaded settings from the config file when the signed uint32 variable would be negative.
Darkvater
parents: 3342
diff changeset
   620
			case SLE_VAR_U16:
99e5e3634e9d (svn r4142) - Fix [FS#74]: Incorrectly loaded settings from the config file when the signed uint32 variable would be negative.
Darkvater
parents: 3342
diff changeset
   621
			case SLE_VAR_I32: {
99e5e3634e9d (svn r4142) - Fix [FS#74]: Incorrectly loaded settings from the config file when the signed uint32 variable would be negative.
Darkvater
parents: 3342
diff changeset
   622
				/* Override the minimum value. No value below sdb->min, except special value 0 */
99e5e3634e9d (svn r4142) - Fix [FS#74]: Incorrectly loaded settings from the config file when the signed uint32 variable would be negative.
Darkvater
parents: 3342
diff changeset
   623
				int32 min = ((sdb->flags & SGF_0ISDISABLED) && val <= sdb->min) ? 0 : sdb->min;
99e5e3634e9d (svn r4142) - Fix [FS#74]: Incorrectly loaded settings from the config file when the signed uint32 variable would be negative.
Darkvater
parents: 3342
diff changeset
   624
				val = clamp(val, min, sdb->max);
99e5e3634e9d (svn r4142) - Fix [FS#74]: Incorrectly loaded settings from the config file when the signed uint32 variable would be negative.
Darkvater
parents: 3342
diff changeset
   625
			} break;
99e5e3634e9d (svn r4142) - Fix [FS#74]: Incorrectly loaded settings from the config file when the signed uint32 variable would be negative.
Darkvater
parents: 3342
diff changeset
   626
			case SLE_VAR_U32: {
99e5e3634e9d (svn r4142) - Fix [FS#74]: Incorrectly loaded settings from the config file when the signed uint32 variable would be negative.
Darkvater
parents: 3342
diff changeset
   627
				/* Override the minimum value. No value below sdb->min, except special value 0 */
99e5e3634e9d (svn r4142) - Fix [FS#74]: Incorrectly loaded settings from the config file when the signed uint32 variable would be negative.
Darkvater
parents: 3342
diff changeset
   628
				uint min = ((sdb->flags & SGF_0ISDISABLED) && (uint)val <= (uint)sdb->min) ? 0 : sdb->min;
99e5e3634e9d (svn r4142) - Fix [FS#74]: Incorrectly loaded settings from the config file when the signed uint32 variable would be negative.
Darkvater
parents: 3342
diff changeset
   629
				WriteValue(ptr, SLE_VAR_U32, (int64)clampu(val, min, sdb->max));
99e5e3634e9d (svn r4142) - Fix [FS#74]: Incorrectly loaded settings from the config file when the signed uint32 variable would be negative.
Darkvater
parents: 3342
diff changeset
   630
				return;
99e5e3634e9d (svn r4142) - Fix [FS#74]: Incorrectly loaded settings from the config file when the signed uint32 variable would be negative.
Darkvater
parents: 3342
diff changeset
   631
			}
99e5e3634e9d (svn r4142) - Fix [FS#74]: Incorrectly loaded settings from the config file when the signed uint32 variable would be negative.
Darkvater
parents: 3342
diff changeset
   632
			case SLE_VAR_I64:
99e5e3634e9d (svn r4142) - Fix [FS#74]: Incorrectly loaded settings from the config file when the signed uint32 variable would be negative.
Darkvater
parents: 3342
diff changeset
   633
			case SLE_VAR_U64:
99e5e3634e9d (svn r4142) - Fix [FS#74]: Incorrectly loaded settings from the config file when the signed uint32 variable would be negative.
Darkvater
parents: 3342
diff changeset
   634
			default: NOT_REACHED(); break;
99e5e3634e9d (svn r4142) - Fix [FS#74]: Incorrectly loaded settings from the config file when the signed uint32 variable would be negative.
Darkvater
parents: 3342
diff changeset
   635
		}
99e5e3634e9d (svn r4142) - Fix [FS#74]: Incorrectly loaded settings from the config file when the signed uint32 variable would be negative.
Darkvater
parents: 3342
diff changeset
   636
	}
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   637
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   638
	WriteValue(ptr, sd->save.conv, (int64)val);
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   639
}
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   640
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   641
/** Load values from a group of an IniFile structure into the internal representation
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   642
 * @param ini pointer to IniFile structure that holds administrative information
3615
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   643
 * @param sd pointer to SettingDesc structure whose internally pointed variables will
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   644
 *        be given values
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   645
 * @param grpname the group of the IniFile to search in for the new values */
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   646
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
   647
{
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   648
	IniGroup *group;
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   649
	IniGroup *group_def = ini_getgroup(ini, grpname, -1);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   650
	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
   651
	const void *p;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   652
	void *ptr;
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   653
	const char *s;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   654
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   655
	for (; sd->save.cmd != SL_END; sd++) {
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   656
		const SettingDescBase *sdb = &sd->desc;
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   657
		const SaveLoad        *sld = &sd->save;
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   658
3117
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
   659
		if (!SlIsObjectCurrentlyValid(sld->version_from, sld->version_to)) continue;
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
   660
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   661
		// XXX - wtf is this?? (group override?)
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   662
		s = strchr(sdb->name, '.');
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   663
		if (s != NULL) {
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   664
			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
   665
			s++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   666
		} else {
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   667
			s = sdb->name;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   668
			group = group_def;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   669
		}
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 188
diff changeset
   670
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   671
		item = ini_getitem(group, s, false);
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   672
		p = (item == NULL) ? sdb->def : string_to_val(sdb, item->value);
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   673
		ptr = ini_get_variable(sld, object);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 188
diff changeset
   674
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   675
		switch (sdb->cmd) {
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   676
		case SDT_BOOLX: /* All four are various types of (integer) numbers */
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   677
		case SDT_NUMX:
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   678
		case SDT_ONEOFMANY:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   679
		case SDT_MANYOFMANY:
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   680
			Write_ValidateSetting(ptr, sd, (unsigned long)p); break;
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   681
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   682
		case SDT_STRING:
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   683
			switch (GetVarMemType(sld->conv)) {
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   684
				case SLE_VAR_STRB:
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   685
				case SLE_VAR_STRQ:
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   686
					if (p != NULL) ttd_strlcpy((char*)ptr, p, sld->length);
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   687
					break;
3192
ad4404f6d03d (svn r3852) - Revert r3733 which fixed the default value loading for char, but broke loading a set value. Added a better fix which needs a char value to be a string (eg enclosed in double-quotes)
Darkvater
parents: 3152
diff changeset
   688
				case SLE_VAR_CHAR: *(char*)ptr = *(char*)p; break;
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   689
				default: NOT_REACHED(); break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   690
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   691
			break;
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   692
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   693
		case SDT_INTLIST: {
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   694
			if (!load_intlist(p, ptr, sld->length, GetVarMemType(sld->conv)))
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   695
				ShowInfoF("ini: error in array '%s'", sdb->name);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   696
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   697
		}
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   698
		default: NOT_REACHED(); break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   699
		}
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 188
diff changeset
   700
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   701
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   702
3615
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   703
/** Save the values of settings to the inifile.
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   704
 * @param ini pointer to IniFile structure
3615
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   705
 * @param sd read-only SettingDesc structure which contains the unmodified,
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   706
 *        loaded values of the configuration file and various information about it
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   707
 * @param grpname holds the name of the group (eg. [network]) where these will be saved
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   708
 * The function works as follows: for each item in the SettingDesc structure we have
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   709
 * a look if the value has changed since we started the game (the original values
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   710
 * are reloaded when saving). If settings indeed have changed, we get these and save them.*/
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   711
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
   712
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   713
	IniGroup *group_def = NULL, *group;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   714
	IniItem *item;
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   715
	char buf[512];
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   716
	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
   717
	void *ptr;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   718
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   719
	for (; sd->save.cmd != SL_END; sd++) {
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   720
		const SettingDescBase *sdb = &sd->desc;
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   721
		const SaveLoad        *sld = &sd->save;
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   722
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   723
		/* If the setting is not saved to the configuration
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   724
		 * file, just continue with the next setting */
3117
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
   725
		if (!SlIsObjectCurrentlyValid(sld->version_from, sld->version_to)) continue;
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   726
		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
   727
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   728
		// XXX - wtf is this?? (group override?)
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   729
		s = strchr(sdb->name, '.');
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   730
		if (s != NULL) {
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   731
			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
   732
			s++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   733
		} else {
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   734
			if (group_def == NULL) group_def = ini_getgroup(ini, grpname, -1);
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   735
			s = sdb->name;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   736
			group = group_def;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   737
		}
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 188
diff changeset
   738
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   739
		item = ini_getitem(group, s, true);
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   740
		ptr = ini_get_variable(sld, object);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 188
diff changeset
   741
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   742
		if (item->value != NULL) {
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 188
diff changeset
   743
			// check if the value is the same as the old value
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   744
			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
   745
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   746
			/* The main type of a variable/setting is in bytes 8-15
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   747
			* The subtype (what kind of numbers do we have there) is in 0-7 */
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   748
			switch (sdb->cmd) {
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   749
			case SDT_BOOLX:
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   750
			case SDT_NUMX:
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   751
			case SDT_ONEOFMANY:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   752
			case SDT_MANYOFMANY:
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   753
				switch (GetVarMemType(sld->conv)) {
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   754
				case SLE_VAR_BL:
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   755
				case SLE_VAR_I8:
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   756
				case SLE_VAR_U8:
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   757
					if (*(byte*)ptr == (byte)(unsigned long)p) continue;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   758
					break;
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   759
				case SLE_VAR_I16:
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   760
				case SLE_VAR_U16:
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   761
					if (*(uint16*)ptr == (uint16)(unsigned long)p) continue;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   762
					break;
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   763
				case SLE_VAR_I32:
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   764
				case SLE_VAR_U32:
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   765
					if (*(uint32*)ptr == (uint32)(unsigned long)p) continue;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   766
					break;
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   767
				default: NOT_REACHED();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   768
				}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   769
				break;
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   770
			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
   771
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   772
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   773
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   774
		/* Value has changed, get the new value and put it into a buffer */
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   775
		switch (sdb->cmd) {
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   776
		case SDT_BOOLX:
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   777
		case SDT_NUMX:
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   778
		case SDT_ONEOFMANY:
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   779
		case SDT_MANYOFMANY: {
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   780
			uint32 i = (uint32)ReadValue(ptr, sld->conv);
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   781
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   782
			switch (sdb->cmd) {
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   783
			case SDT_BOOLX:      strcpy(buf, (i != 0) ? "true" : "false"); break;
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   784
			case SDT_NUMX:       sprintf(buf, "%u", i); break;
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   785
			case SDT_ONEOFMANY:  make_oneofmany(buf, sdb->many, i); break;
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   786
			case SDT_MANYOFMANY: make_manyofmany(buf, sdb->many, i); break;
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   787
			default: NOT_REACHED();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   788
			}
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   789
		} break;
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   790
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   791
		case SDT_STRING:
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   792
			switch (GetVarMemType(sld->conv)) {
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   793
			case SLE_VAR_STRB: strcpy(buf, (char*)ptr); break;
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   794
			case SLE_VAR_STRQ: sprintf(buf, "\"%s\"", (char*)ptr); break;
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   795
			case SLE_VAR_CHAR: sprintf(buf, "\"%c\"", *(char*)ptr); break;
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   796
			default: NOT_REACHED();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   797
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   798
			break;
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   799
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   800
		case SDT_INTLIST:
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   801
			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
   802
			break;
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   803
		default: NOT_REACHED();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   804
		}
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   805
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   806
		/* The value is different, that means we have to write it to the ini */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   807
		item->value = 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
   808
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   809
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   810
3615
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   811
/** Loads all items from a 'grpname' section into a list
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   812
 * The list parameter can be a NULL pointer, in this case nothing will be
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   813
 * saved and a callback function should be defined that will take over the
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   814
 * list-handling and store the data itself somewhere.
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   815
 * @param IniFile handle to the ini file with the source data
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   816
 * @param grpname character string identifying the section-header of the ini
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   817
 * file that will be parsed
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   818
 * @param list pointer to an string(pointer) array that will store the parsed
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   819
 * entries of the given section
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   820
 * @param len the maximum number of items available for the above list */
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   821
static void ini_load_setting_list(IniFile *ini, const char *grpname, char **list, uint len)
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   822
{
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   823
	IniGroup *group = ini_getgroup(ini, grpname, -1);
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   824
	IniItem *item;
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   825
	uint i;
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   826
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   827
	if (group == NULL) return;
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   828
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   829
	item = group->item;
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   830
	for (i = 0; i != len; i++) {
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   831
		if (item == NULL) break;
3606
743a2cd312a9 (svn r4498) - Use an item's name instead of value when parsing configuration lists.
peter1138
parents: 3600
diff changeset
   832
		list[i] = strdup(item->name);
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   833
		item = item->next;
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   834
	}
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   835
}
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   836
3615
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   837
/** Saves all items from a list into the 'grpname' section
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   838
 * The list parameter can be a NULL pointer, in this case a callback function
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   839
 * should be defined that will provide the source data to be saved.
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   840
 * @param IniFile handle to the ini file where the destination data is saved
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   841
 * @param grpname character string identifying the section-header of the ini file
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   842
 * @param list pointer to an string(pointer) array that will be used as the
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   843
 * source to be saved into the relevant ini section
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   844
 * @param len the maximum number of items available for the above list
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
   845
 * @param proc callback function that can will provide the source data if defined */
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   846
static void ini_save_setting_list(IniFile *ini, const char *grpname, char **list, uint len)
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   847
{
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   848
	IniGroup *group = ini_getgroup(ini, grpname, -1);
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   849
	IniItem *item = NULL;
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   850
	uint i;
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   851
	bool first = true;
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   852
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   853
	if (group == NULL) return;
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   854
	group->item = NULL;
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   855
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   856
	for (i = 0; i != len; i++) {
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   857
		if (list[i] == NULL || list[i][0] == '\0') continue;
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   858
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   859
		if (first) { // add first item to the head of the group
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   860
			item = ini_item_alloc(group, list[i], strlen(list[i]));
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   861
			item->value = item->name;
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   862
			group->item = item;
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   863
			first = false;
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   864
		} else { // all other items are attached to the previous one
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   865
			item->next = ini_item_alloc(group, list[i], strlen(list[i]));
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   866
			item = item->next;
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   867
			item->value = item->name;
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   868
		}
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   869
	}
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   870
}
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
   871
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   872
//***************************
2972
1eacb2fc37ae (svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents: 2969
diff changeset
   873
// OTTD specific INI stuff
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   874
//***************************
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   875
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   876
/** Settings-macro usage:
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   877
 * The list might look daunting at first, but is in general easy to understand.
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   878
 * We have two types of list:
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   879
 * 1. SDTG_something
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   880
 * 2. SDT_something
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   881
 * The 'G' stands for global, so this is the one you will use for a SettingDescGlobVarList
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   882
 * section meaning global variables. The other uses a Base/Offset and runtime variable
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   883
 * selection mechanism, known from the saveload convention (it also has global so it
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   884
 * should not be hard).
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   885
 * Of each type there are again two versions, the normal one and one prefixed with 'COND'.
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   886
 * COND means that the setting is only valid in certain savegame versions (since patches
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   887
 * are saved to the savegame, this bookkeeping is necessary.
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   888
 * Now there are a lot of types. Easy ones are:
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   889
 * - VAR:  any number type, 'type' field specifies what number. eg int8 or uint32
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   890
 * - BOOL: a boolean number type
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   891
 * - STR:  a string or character. 'type' field specifies what string. Normal, string, or quoted
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   892
 * A bit more difficult to use are MMANY (meaning ManyOfMany) and OMANY (OneOfMany)
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   893
 * These are actually normal numbers, only bitmasked. In MMANY several bits can be
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   894
 * set, in the other only one.
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   895
 * The most complex type is INTLIST. This is basically an array of numbers. If
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   896
 * the intlist is only valid in certain savegame versions because for example
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   897
 * it has grown in size its length cannot be automatically be calculated so
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   898
 * use SDT(G)_CONDLISTO() meaning Old.
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   899
 * If nothing fits you, you can use the GENERAL macros, but it exposes the internal
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   900
 * structure somewhat so it needs a little looking. There are _NULL() macros as
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   901
 * well, these fill up space so you can add more patches there (in place) and you
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   902
 * DON'T have to increase the savegame version. */
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   903
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   904
#define NSD_GENERAL(name, def, cmd, guiflags, min, max, many, str, proc)\
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   905
	{name, (const void*)def, cmd, guiflags, min, max, many, str, proc}
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   906
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   907
/* Macros for various objects to go in the configuration file.
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   908
 * This section is for global variables */
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   909
#define SDTG_GENERAL(name, sdt_cmd, sle_cmd, type, flags, guiflags, var, length, def, min, max, full, str, proc, from, to)\
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   910
{NSD_GENERAL(name, def, sdt_cmd, guiflags, min, max, full, str, proc), SLEG_GENERAL(sle_cmd, var, type | flags, length, from, to)}
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   911
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   912
#define SDTG_CONDVAR(name, type, flags, guiflags, var, def, min, max, str, proc, from, to)\
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   913
	SDTG_GENERAL(name, SDT_NUMX, SL_VAR, type, flags, guiflags, var, 0, def, min, max, NULL, str, proc, from, to)
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   914
#define SDTG_VAR(name, type, flags, guiflags, var, def, min, max, str, proc)\
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   915
	SDTG_CONDVAR(name, type, flags, guiflags, var, def, min, max, str, proc, 0, SL_MAX_VERSION)
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   916
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   917
#define SDTG_CONDBOOL(name, flags, guiflags, var, def, str, proc, from, to)\
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   918
	SDTG_GENERAL(name, SDT_BOOLX, SL_VAR, SLE_UINT8, flags, guiflags, var, 0, def, 0, 1, NULL, str, proc, from, to)
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   919
#define SDTG_BOOL(name, flags, guiflags, var, def, str, proc)\
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   920
	SDTG_CONDBOOL(name, flags, guiflags, var, def, str, proc, 0, SL_MAX_VERSION)
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   921
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   922
#define SDTG_CONDLIST(name, type, length, flags, guiflags, var, def, str, proc, from, to)\
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   923
	SDTG_GENERAL(name, SDT_INTLIST, SL_ARR, type, flags, guiflags, var, length, def, 0, 0, NULL, str, proc, from, to)
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   924
#define SDTG_LIST(name, type, flags, guiflags, var, def, str, proc)\
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   925
	SDTG_GENERAL(name, SDT_INTLIST, SL_ARR, type, flags, guiflags, var, lengthof(var), def, 0, 0, NULL, str, proc, 0, SL_MAX_VERSION)
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   926
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   927
#define SDTG_CONDSTR(name, type, length, flags, guiflags, var, def, str, proc, from, to)\
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   928
	SDTG_GENERAL(name, SDT_STRING, SL_STR, type, flags, guiflags, var, length, def, 0, 0, NULL, str, proc, from, to)
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   929
#define SDTG_STR(name, type, flags, guiflags, var, def, str, proc)\
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   930
	SDTG_GENERAL(name, SDT_STRING, SL_STR, type, flags, guiflags, var, lengthof(var), def, 0, 0, NULL, str, proc, 0, SL_MAX_VERSION)
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   931
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   932
#define SDTG_CONDOMANY(name, type, flags, guiflags, var, def, max, full, str, proc, from, to)\
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   933
	SDTG_GENERAL(name, SDT_ONEOFMANY, SL_VAR, type, flags, guiflags, var, 0, def, 0, max, full, str, proc, from, to)
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   934
#define SDTG_OMANY(name, type, flags, guiflags, var, def, max, full, str, proc)\
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   935
	SDTG_CONDOMANY(name, type, flags, guiflags, var, def, max full, str, proc, 0, SL_MAX_VERSION)
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   936
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   937
#define SDTG_CONDMMANY(name, type, flags, guiflags, var, def, full, str, proc, from, to)\
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   938
	SDTG_GENERAL(name, SDT_MANYOFMANY, SL_VAR, type, flags, guiflags, var, 0, def, 0, 0, full, str, proc, from, to)
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   939
#define SDTG_MMANY(name, type, flags, guiflags, var, def, full, str, proc)\
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   940
	SDTG_CONDMMANY(name, type, flags, guiflags, var, def, full, str, proc, 0, SL_MAX_VERSION)
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   941
3222
6de22e06a1e9 (svn r3895) - Add proper SLE(G)_CONDNULL macros for the empty space reservation in savegames and update where used
Darkvater
parents: 3210
diff changeset
   942
#define SDTG_CONDNULL(length, from, to)\
3240
204f995f25df (svn r3914) - Properly implement SDT(G)_CONDNULL macro's without special cases (add flag SLF_CONFIG_NO and empty string as name)
Darkvater
parents: 3223
diff changeset
   943
	{{"", NULL, 0, 0, 0, 0, NULL, STR_NULL, NULL}, SLEG_CONDNULL(length, from, to)}
3222
6de22e06a1e9 (svn r3895) - Add proper SLE(G)_CONDNULL macros for the empty space reservation in savegames and update where used
Darkvater
parents: 3210
diff changeset
   944
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   945
#define SDTG_END() {{NULL, NULL, 0, 0, 0, 0, NULL, STR_NULL, NULL}, SLEG_END()}
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   946
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   947
/* Macros for various objects to go in the configuration file.
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   948
 * This section is for structures where their various members are saved */
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   949
#define SDT_GENERAL(name, sdt_cmd, sle_cmd, type, flags, guiflags, base, var, length, def, min, max, full, str, proc, from, to)\
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   950
	{NSD_GENERAL(name, def, sdt_cmd, guiflags, min, max, full, str, proc), SLE_GENERAL(sle_cmd, base, var, type | flags, length, from, to)}
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   951
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   952
#define SDT_CONDVAR(base, var, type, from, to, flags, guiflags, def, min, max, str, proc)\
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   953
	SDT_GENERAL(#var, SDT_NUMX, SL_VAR, type, flags, guiflags, base, var, 1, def, min, max, NULL, str, proc, from, to)
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   954
#define SDT_VAR(base, var, type, flags, guiflags, def, min, max, str, proc)\
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   955
	SDT_CONDVAR(base, var, type, 0, SL_MAX_VERSION, flags, guiflags, def, min, max, str, proc)
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   956
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   957
#define SDT_CONDBOOL(base, var, from, to, flags, guiflags, def, str, proc)\
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   958
	SDT_GENERAL(#var, SDT_BOOLX, SL_VAR, SLE_BOOL, flags, guiflags, base, var, 1, def, 0, 1, NULL, str, proc, from, to)
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   959
#define SDT_BOOL(base, var, flags, guiflags, def, str, proc)\
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   960
	SDT_CONDBOOL(base, var, 0, SL_MAX_VERSION, flags, guiflags, def, str, proc)
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   961
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   962
#define SDT_CONDLIST(base, var, type, from, to, flags, guiflags, def, str, proc)\
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   963
	SDT_GENERAL(#var, SDT_INTLIST, SL_ARR, type, flags, guiflags, base, var, lengthof(((base*)8)->var), def, 0, 0, NULL, str, proc, from, to)
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   964
#define SDT_LIST(base, var, type, flags, guiflags, def, str, proc)\
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   965
	SDT_CONDLIST(base, var, type, 0, SL_MAX_VERSION, flags, guiflags, def, str, proc)
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   966
#define SDT_CONDLISTO(base, var, length, type, from, to, flags, guiflags, def, str, proc)\
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   967
	SDT_GENERAL(#var, SDT_INTLIST, SL_ARR, type, flags, guiflags, base, var, length, def, 0, 0, NULL, str, proc, from, to)
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   968
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   969
#define SDT_CONDSTR(base, var, type, from, to, flags, guiflags, def, str, proc)\
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   970
	SDT_GENERAL(#var, SDT_STRING, SL_STR, type, flags, guiflags, base, var, lengthof(((base*)8)->var), def, 0, 0, NULL, str, proc, from, to)
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   971
#define SDT_STR(base, var, type, flags, guiflags, def, str, proc)\
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   972
	SDT_CONDSTR(base, var, type, 0, SL_MAX_VERSION, flags, guiflags, def, str, proc)
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   973
#define SDT_CONDSTRO(base, var, length, type, from, to, flags, def, str, proc)\
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   974
	SDT_GENERAL(#var, SDT_STRING, SL_STR, type, flags, 0, base, var, length, def, 0, 0, NULL, str, proc, from, to)
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   975
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   976
#define SDT_CONDCHR(base, var, from, to, flags, guiflags, def, str, proc)\
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   977
	SDT_GENERAL(#var, SDT_STRING, SL_VAR, SLE_CHAR, flags, guiflags, base, var, 1, def, 0, 0, NULL, str, proc, from, to)
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   978
#define SDT_CHR(base, var, flags, guiflags, def, str, proc)\
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   979
	SDT_CONDCHR(base, var, 0, SL_MAX_VERSION, flags, guiflags, def, str, proc)
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   980
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   981
#define SDT_CONDOMANY(base, var, type, from, to, flags, guiflags, def, max, full, str, proc)\
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   982
	SDT_GENERAL(#var, SDT_ONEOFMANY, SL_VAR, type, flags, guiflags, base, var, 1, def, 0, max, full, str, proc, from, to)
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   983
#define SDT_OMANY(base, var, type, flags, guiflags, def, max, full, str, proc)\
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   984
	SDT_CONDOMANY(base, var, type, 0, SL_MAX_VERSION, flags, guiflags, def, max, full, str, proc)
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   985
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   986
#define SDT_CONDMMANY(base, var, type, from, to, flags, guiflags, def, full, str, proc)\
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   987
	SDT_GENERAL(#var, SDT_MANYOFMANY, SL_VAR, type, flags, guiflags, base, var, 1, def, 0, 0, full, str, proc, from, to)
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   988
#define SDT_MMANY(base, var, type, flags, guiflags, def, full, str, proc)\
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   989
	SDT_CONDMMANY(base, var, type, 0, SL_MAX_VERSION, flags, guiflags, def, full, str, proc)
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   990
3222
6de22e06a1e9 (svn r3895) - Add proper SLE(G)_CONDNULL macros for the empty space reservation in savegames and update where used
Darkvater
parents: 3210
diff changeset
   991
#define SDT_CONDNULL(length, from, to)\
3240
204f995f25df (svn r3914) - Properly implement SDT(G)_CONDNULL macro's without special cases (add flag SLF_CONFIG_NO and empty string as name)
Darkvater
parents: 3223
diff changeset
   992
	{{"", NULL, 0, 0, 0, 0, NULL, STR_NULL, NULL}, SLE_CONDNULL(length, from, to)}
3222
6de22e06a1e9 (svn r3895) - Add proper SLE(G)_CONDNULL macros for the empty space reservation in savegames and update where used
Darkvater
parents: 3210
diff changeset
   993
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   994
#define SDT_END() {{NULL, NULL, 0, 0, 0, 0, NULL, STR_NULL, NULL}, SLE_END()}
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   995
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   996
/* Shortcuts for macros below. Logically if we don't save the value
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   997
 * we also don't sync it in a network game */
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   998
#define S SLF_SAVE_NO | SLF_NETWORK_NO
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
   999
#define C SLF_CONFIG_NO
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1000
#define N SLF_NETWORK_NO
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1001
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1002
#define D0 SGF_0ISDISABLED
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1003
#define NC SGF_NOCOMMA
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1004
#define MS SGF_MULTISTRING
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1005
#define NO SGF_NETWORK_ONLY
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1006
#define CR SGF_CURRENCY
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1007
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1008
#include "table/strings.h"
3131
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1009
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1010
/* Begin - Callback Functions for the various settings */
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1011
#include "window.h"
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1012
#include "gui.h"
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1013
#include "town.h"
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1014
#include "gfx.h"
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1015
// virtual PositionMainToolbar function, calls the right one.
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1016
static int32 v_PositionMainToolbar(int32 p1)
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1017
{
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1018
	if (_game_mode != GM_MENU) PositionMainToolbar(NULL);
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1019
	return 0;
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1020
}
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1021
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1022
static int32 AiNew_PatchActive_Warning(int32 p1)
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1023
{
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1024
	if (p1 == 1) ShowErrorMessage(INVALID_STRING_ID, TEMP_AI_ACTIVATED, 0, 0);
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1025
	return 0;
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1026
}
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1027
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1028
static int32 Ai_In_Multiplayer_Warning(int32 p1)
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1029
{
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1030
	if (p1 == 1) {
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1031
		ShowErrorMessage(INVALID_STRING_ID, TEMP_AI_MULTIPLAYER, 0, 0);
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1032
		_patches.ainew_active = true;
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1033
	}
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1034
	return 0;
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1035
}
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1036
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1037
static int32 PopulationInLabelActive(int32 p1)
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1038
{
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1039
	Town* t;
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1040
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1041
	FOR_ALL_TOWNS(t) {
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1042
		if (t->xy != 0) UpdateTownVirtCoord(t);
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1043
	}
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1044
	return 0;
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1045
}
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1046
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1047
static int32 InvisibleTreesActive(int32 p1)
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1048
{
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1049
	MarkWholeScreenDirty();
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1050
	return 0;
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1051
}
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1052
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1053
static int32 InValidateDetailsWindow(int32 p1)
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1054
{
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1055
	InvalidateWindowClasses(WC_VEHICLE_DETAILS);
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1056
	return 0;
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1057
}
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1058
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1059
static int32 InvalidateStationBuildWindow(int32 p1)
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1060
{
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1061
	InvalidateWindow(WC_BUILD_STATION, 0);
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1062
	return 0;
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1063
}
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1064
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1065
/* Check service intervals of vehicles, p1 is value of % or day based servicing */
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1066
static int32 CheckInterval(int32 p1)
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1067
{
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1068
	bool warning;
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1069
	const Patches *ptc = (_game_mode == GM_MENU) ? &_patches_newgame : &_patches;
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1070
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1071
	if (p1) {
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1072
		warning = ( (IS_INT_INSIDE(ptc->servint_trains,   5, 90+1) || ptc->servint_trains   == 0) &&
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1073
								(IS_INT_INSIDE(ptc->servint_roadveh,  5, 90+1) || ptc->servint_roadveh  == 0) &&
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1074
								(IS_INT_INSIDE(ptc->servint_aircraft, 5, 90+1) || ptc->servint_aircraft == 0) &&
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1075
								(IS_INT_INSIDE(ptc->servint_ships,    5, 90+1) || ptc->servint_ships    == 0) );
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1076
	} else {
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1077
		warning = ( (IS_INT_INSIDE(ptc->servint_trains,   30, 800+1) || ptc->servint_trains   == 0) &&
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1078
								(IS_INT_INSIDE(ptc->servint_roadveh,  30, 800+1) || ptc->servint_roadveh  == 0) &&
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1079
								(IS_INT_INSIDE(ptc->servint_aircraft, 30, 800+1) || ptc->servint_aircraft == 0) &&
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1080
								(IS_INT_INSIDE(ptc->servint_ships,    30, 800+1) || ptc->servint_ships    == 0) );
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1081
	}
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1082
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1083
	if (!warning)
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1084
		ShowErrorMessage(INVALID_STRING_ID, STR_CONFIG_PATCHES_SERVICE_INTERVAL_INCOMPATIBLE, 0, 0);
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1085
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1086
	return InValidateDetailsWindow(0);
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1087
}
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1088
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1089
static int32 EngineRenewUpdate(int32 p1)
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1090
{
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1091
	DoCommandP(0, 0, _patches.autorenew, NULL, CMD_REPLACE_VEHICLE);
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1092
	return 0;
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1093
}
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1094
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1095
static int32 EngineRenewMonthsUpdate(int32 p1)
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1096
{
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1097
	DoCommandP(0, 1, _patches.autorenew_months, NULL, CMD_REPLACE_VEHICLE);
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1098
	return 0;
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1099
}
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1100
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1101
static int32 EngineRenewMoneyUpdate(int32 p1)
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1102
{
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1103
	DoCommandP(0, 2, _patches.autorenew_money, NULL, CMD_REPLACE_VEHICLE);
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1104
	return 0;
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1105
}
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1106
/* End - Callback Functions */
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1107
1584
7122e759d56c (svn r2088) - Fix: [ 1155158 ] Make extmidi command a config option in addition to the compile-time MIDI switch. Patch by macbaine.
pasky
parents: 1500
diff changeset
  1108
#ifndef EXTERNAL_PLAYER
7122e759d56c (svn r2088) - Fix: [ 1155158 ] Make extmidi command a config option in addition to the compile-time MIDI switch. Patch by macbaine.
pasky
parents: 1500
diff changeset
  1109
#define EXTERNAL_PLAYER "timidity"
7122e759d56c (svn r2088) - Fix: [ 1155158 ] Make extmidi command a config option in addition to the compile-time MIDI switch. Patch by macbaine.
pasky
parents: 1500
diff changeset
  1110
#endif
7122e759d56c (svn r2088) - Fix: [ 1155158 ] Make extmidi command a config option in addition to the compile-time MIDI switch. Patch by macbaine.
pasky
parents: 1500
diff changeset
  1111
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1112
static const SettingDesc _music_settings[] = {
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1113
	 SDT_VAR(MusicFileSettings, playlist,  SLE_UINT8, S, 0,   0, 0,   5, STR_NULL, NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1114
	 SDT_VAR(MusicFileSettings, music_vol, SLE_UINT8, S, 0, 128, 0, 100, STR_NULL, NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1115
	 SDT_VAR(MusicFileSettings, effect_vol,SLE_UINT8, S, 0, 128, 0, 100, STR_NULL, NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1116
	SDT_LIST(MusicFileSettings, custom_1,  SLE_UINT8, S, 0, NULL,        STR_NULL, NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1117
	SDT_LIST(MusicFileSettings, custom_2,  SLE_UINT8, S, 0, NULL,        STR_NULL, NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1118
	SDT_BOOL(MusicFileSettings, playing,              S, 0, true,        STR_NULL, NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1119
	SDT_BOOL(MusicFileSettings, shuffle,              S, 0,false,        STR_NULL, NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1120
	 SDT_STR(MusicFileSettings, extmidi,    SLE_STRB, S, 0, EXTERNAL_PLAYER,STR_NULL, NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1121
	 SDT_END()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1122
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1123
3051
6a9ddcac6d56 (svn r3640) - Remove win32-only variables from variables.h and put them into win32_v.c. Also ifdef the win32 specific configuration file settings.
Darkvater
parents: 3042
diff changeset
  1124
/* win32_v.c only settings */
6a9ddcac6d56 (svn r3640) - Remove win32-only variables from variables.h and put them into win32_v.c. Also ifdef the win32 specific configuration file settings.
Darkvater
parents: 3042
diff changeset
  1125
#ifdef WIN32
6a9ddcac6d56 (svn r3640) - Remove win32-only variables from variables.h and put them into win32_v.c. Also ifdef the win32 specific configuration file settings.
Darkvater
parents: 3042
diff changeset
  1126
extern bool _force_full_redraw, _double_size;
6a9ddcac6d56 (svn r3640) - Remove win32-only variables from variables.h and put them into win32_v.c. Also ifdef the win32 specific configuration file settings.
Darkvater
parents: 3042
diff changeset
  1127
extern uint _display_hz, _fullscreen_bpp;
6a9ddcac6d56 (svn r3640) - Remove win32-only variables from variables.h and put them into win32_v.c. Also ifdef the win32 specific configuration file settings.
Darkvater
parents: 3042
diff changeset
  1128
3124
cf624337b649 (svn r3732) - Fix two warnings. Stupid MSVC didn't even complain :s (Thank Tron and peter1138)
Darkvater
parents: 3121
diff changeset
  1129
static const SettingDescGlobVarList _win32_settings[] = {
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1130
	 SDTG_VAR("display_hz",     SLE_UINT, S, 0, _display_hz,       0, 0, 120, STR_NULL, NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1131
	SDTG_BOOL("force_full_redraw",        S, 0, _force_full_redraw,false,     STR_NULL, NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1132
	 SDTG_VAR("fullscreen_bpp", SLE_UINT, S, 0, _fullscreen_bpp,   8, 8,  32, STR_NULL, NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1133
	SDTG_BOOL("double_size",              S, 0, _double_size,      false,     STR_NULL, NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1134
	 SDTG_END()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1135
};
3051
6a9ddcac6d56 (svn r3640) - Remove win32-only variables from variables.h and put them into win32_v.c. Also ifdef the win32 specific configuration file settings.
Darkvater
parents: 3042
diff changeset
  1136
#endif /* WIN32 */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1137
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1138
static const SettingDescGlobVarList _misc_settings[] = {
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1139
	SDTG_MMANY("display_opt",     SLE_UINT8, S, 0, _display_opt,       (DO_SHOW_TOWN_NAMES|DO_SHOW_STATION_NAMES|DO_SHOW_SIGNS|DO_FULL_ANIMATION|DO_FULL_DETAIL|DO_TRANS_BUILDINGS|DO_WAYPOINTS), "SHOW_TOWN_NAMES|SHOW_STATION_NAMES|SHOW_SIGNS|FULL_ANIMATION|TRANS_BUILDINGS|FULL_DETAIL|WAYPOINTS", STR_NULL, NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1140
	  SDTG_VAR("news_display_opt", SLE_UINT, S, 0, _news_display_opt,0xAAAAAAAA,0,0xAAAAAAAA,STR_NULL, NULL), // default to all full messages: 10101010101010101010 = 0xAAAAAAAA
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1141
	 SDTG_BOOL("news_ticker_sound",          S, 0, _news_ticker_sound,     true,    STR_NULL, NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1142
	 SDTG_BOOL("fullscreen",                 S, 0, _fullscreen,           false,    STR_NULL, NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1143
	  SDTG_STR("videodriver",      SLE_STRB,C|S,0, _ini_videodriver,       NULL,    STR_NULL, NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1144
	  SDTG_STR("musicdriver",      SLE_STRB,C|S,0, _ini_musicdriver,       NULL,    STR_NULL, NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1145
	  SDTG_STR("sounddriver",      SLE_STRB,C|S,0, _ini_sounddriver,       NULL,    STR_NULL, NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1146
	  SDTG_STR("language",         SLE_STRB, S, 0, _dynlang.curr_file,     NULL,    STR_NULL, NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1147
	 SDTG_LIST("resolution",     SLE_UINT16, S, 0, _cur_resolution,   "640,480",    STR_NULL, NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1148
	  SDTG_STR("screenshot_format",SLE_STRB, S, 0, _screenshot_format_name,NULL,    STR_NULL, NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1149
	  SDTG_STR("savegame_format",  SLE_STRB, S, 0, _savegame_format,       NULL,    STR_NULL, NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1150
	 SDTG_BOOL("rightclick_emulate",         S, 0, _rightclick_emulate,   false,    STR_NULL, NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1151
	  SDTG_END()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1152
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1153
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
  1154
#ifdef ENABLE_NETWORK
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1155
static const SettingDescGlobVarList _network_settings[] = {
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1156
	 SDTG_VAR("sync_freq",           SLE_UINT16,C|S,0, _network_sync_freq,            100, 0,  100,STR_NULL, NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1157
	 SDTG_VAR("frame_freq",           SLE_UINT8,C|S,0, _network_frame_freq,             0, 0,  100,STR_NULL, NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1158
	 SDTG_VAR("max_join_time",       SLE_UINT16, S, 0, _network_max_join_time,        500, 0,32000,STR_NULL, NULL),
3283
8c66f18e58f4 (svn r3997) - Default the patch-setting 'pause_on_join' to true.
Darkvater
parents: 3247
diff changeset
  1159
	SDTG_BOOL("pause_on_join",                   S, 0, _network_pause_on_join,        true,        STR_NULL, NULL),
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1160
	 SDTG_STR("server_bind_ip",        SLE_STRB, S, 0, _network_server_bind_ip_host,  "0.0.0.0",   STR_NULL, NULL),
3152
00aa2d4cf39e (svn r3775) Fix loading of server_port from config file, introduced in Darkvater's unified configuration changes (r3719+)
peter1138
parents: 3131
diff changeset
  1161
	 SDTG_VAR("server_port",         SLE_UINT16, S, 0, _network_server_port,          NETWORK_DEFAULT_PORT, 0, 65535,STR_NULL, NULL),
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1162
	SDTG_BOOL("server_advertise",                S, 0, _network_advertise,            false,       STR_NULL, NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1163
	SDTG_BOOL("lan_internet",                    S, 0, _network_lan_internet,         false,       STR_NULL, NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1164
	 SDTG_STR("player_name",           SLE_STRB, S, 0, _network_player_name,          NULL,        STR_NULL, NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1165
	 SDTG_STR("server_password",       SLE_STRB, S, 0, _network_server_password,      NULL,        STR_NULL, NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1166
	 SDTG_STR("rcon_password",         SLE_STRB, S, 0, _network_rcon_password,        NULL,        STR_NULL, NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1167
	 SDTG_STR("server_name",           SLE_STRB, S, 0, _network_server_name,          NULL,        STR_NULL, NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1168
	 SDTG_STR("connect_to_ip",         SLE_STRB, S, 0, _network_default_ip,           NULL,        STR_NULL, NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1169
	 SDTG_STR("network_id",            SLE_STRB, S, 0, _network_unique_id,            NULL,        STR_NULL, NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1170
	SDTG_BOOL("autoclean_companies",             S, 0, _network_autoclean_companies,  false,       STR_NULL, NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1171
	 SDTG_VAR("autoclean_unprotected",SLE_UINT8, S, 0, _network_autoclean_unprotected,12, 0,  60,  STR_NULL, NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1172
	 SDTG_VAR("autoclean_protected",  SLE_UINT8, S, 0, _network_autoclean_protected,  36, 0, 180,  STR_NULL, NULL),
3194
8059a48ec9f6 (svn r3854) - Fix restart_game_date to default to zero and allow a value of 0 which got screwed up during the patch-rewrite. Thanks peter1138
Darkvater
parents: 3192
diff changeset
  1173
	 SDTG_VAR("restart_game_date",   SLE_UINT16, S,D0, _network_restart_game_date,    0, MAX_YEAR_BEGIN_REAL, MAX_YEAR_END_REAL, STR_NULL, NULL),
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1174
	 SDTG_END()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1175
};
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
  1176
#endif /* ENABLE_NETWORK */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1177
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1178
static const SettingDesc _gameopt_settings[] = {
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1179
	/* In version 4 a new difficulty setting has been added to the difficulty settings,
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1180
	 * town attitude towards demolishing. Needs special handling because some dimwit thought
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1181
	 * it funny to have the GameDifficulty struct be an array while it is a struct of
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1182
	 * same-sized members
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1183
	 * XXX - To save file-space and since values are never bigger than about 10? only
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1184
	 * save the first 16 bits in the savegame. Question is why the values are still int32
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1185
	 * and why not byte for example? */
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1186
	SDT_GENERAL("diff_custom", SDT_INTLIST, SL_ARR, (SLE_FILE_I16 | SLE_VAR_I32), 0, 0, GameOptions, diff, 17, 0, 0, 0, NULL, STR_NULL, NULL, 0, 3),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1187
	SDT_GENERAL("diff_custom", SDT_INTLIST, SL_ARR, (SLE_FILE_I16 | SLE_VAR_I32), 0, 0, GameOptions, diff, 18, 0, 0, 0, NULL, STR_NULL, NULL, 4, SL_MAX_VERSION),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1188
	    SDT_VAR(GameOptions, diff_level,SLE_UINT8, 0, 0, 9,0, 9, STR_NULL, NULL),
3596
6654541a3958 (svn r4487) - Codechange: replace the custom currency magic number 23 with a define
peter1138
parents: 3564
diff changeset
  1189
	  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|SEK|custom", STR_NULL, NULL),
3342
cb9b5c6dd74c (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3283
diff changeset
  1190
	  SDT_OMANY(GameOptions, units,     SLE_UINT8, N, 0, 1,   2, "imperial|metric|si", STR_NULL, NULL),
3564
ce1862c6cc7f (svn r4445) -Fix: FS#108 Danish name generator bug
bjarni
parents: 3491
diff changeset
  1191
	  SDT_OMANY(GameOptions, town_name, SLE_UINT8, 0, 0, 0,  17, "english|french|german|american|latin|silly|swedish|dutch|finnish|polish|slovakish|norwegian|hungarian|austrian|romanian|czech|swiss|danish", STR_NULL, NULL),
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1192
	  SDT_OMANY(GameOptions, landscape, SLE_UINT8, 0, 0, 0,   3, "normal|hilly|desert|candy", STR_NULL, NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1193
	    SDT_VAR(GameOptions, snow_line, SLE_UINT8, 0, 0, 1,0,56, STR_NULL, NULL),
3241
99a877e225a8 (svn r3915) - Savegame version 23: Do not save the autosave interval anymore with savegames. Some people should be very happe atm ;)
Darkvater
parents: 3240
diff changeset
  1194
	SDT_CONDOMANY(GameOptions,autosave, SLE_UINT8, 0, 22,             N, 0, 0, 0, "", STR_NULL, NULL),
99a877e225a8 (svn r3915) - Savegame version 23: Do not save the autosave interval anymore with savegames. Some people should be very happe atm ;)
Darkvater
parents: 3240
diff changeset
  1195
	SDT_CONDOMANY(GameOptions,autosave, SLE_UINT8,23, SL_MAX_VERSION, S, 0, 1, 4, "off|monthly|quarterly|half year|yearly", STR_NULL, NULL),
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1196
	  SDT_OMANY(GameOptions, road_side, SLE_UINT8, 0, 0, 1,   1, "left|right", STR_NULL, NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1197
	    SDT_END()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1198
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1199
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1200
/* Some patches do not need to be synchronised when playing in multiplayer.
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1201
 * These include for example the GUI settings and will not be saved with the
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1202
 * savegame.
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1203
 * It is also a bit tricky since you would think that service_interval
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1204
 * for example doesn't need to be synched. Every client assigns the service_interval
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1205
 * value to the v->service_interval, meaning that every client assigns his value. If
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1206
 * the setting was player-based, that would mean that vehicles could decide on
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1207
 * different moments that they are heading back to a service depot, causing desyncs
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1208
 * on a massive scale. */
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1209
const SettingDesc _patch_settings[] = {
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1210
	/***************************************************************************/
3247
ede7a53941b2 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3246
diff changeset
  1211
	/* User-interface section of the GUI-configure patches window */
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1212
	SDT_BOOL(Patches, vehicle_speed,                 S, 0,  true,    STR_CONFIG_PATCHES_VEHICLESPEED,          NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1213
	SDT_BOOL(Patches, status_long_date,              S, 0,  true,    STR_CONFIG_PATCHES_LONGDATE,              NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1214
	SDT_BOOL(Patches, show_finances,                 S, 0,  true,    STR_CONFIG_PATCHES_SHOWFINANCES,          NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1215
	SDT_BOOL(Patches, autoscroll,                    S, 0, false,    STR_CONFIG_PATCHES_AUTOSCROLL,            NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1216
	SDT_BOOL(Patches, reverse_scroll,                S, 0, false,    STR_CONFIG_PATCHES_REVERSE_SCROLLING,     NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1217
	 SDT_VAR(Patches, errmsg_duration,    SLE_UINT8, S, 0,  5, 0,20, STR_CONFIG_PATCHES_ERRMSG_DURATION,       NULL),
3131
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1218
	 SDT_VAR(Patches, toolbar_pos,        SLE_UINT8, S,MS,  0, 0, 2, STR_CONFIG_PATCHES_TOOLBAR_POS,           v_PositionMainToolbar),
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1219
	 SDT_VAR(Patches, window_snap_radius, SLE_UINT8, S,D0, 10, 1,32, STR_CONFIG_PATCHES_SNAP_RADIUS,           NULL),
3131
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1220
	SDT_BOOL(Patches, invisible_trees,               S, 0, false,    STR_CONFIG_PATCHES_INVISIBLE_TREES,       InvisibleTreesActive),
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1221
	SDT_BOOL(Patches, population_in_label,           S, 0,  true,    STR_CONFIG_PATCHES_POPULATION_IN_LABEL,   PopulationInLabelActive),
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1222
	 SDT_VAR(Patches, map_x,              SLE_UINT8, S, 0,  8, 6,11, STR_CONFIG_PATCHES_MAP_X,                 NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1223
	 SDT_VAR(Patches, map_y,              SLE_UINT8, S, 0,  8, 6,11, STR_CONFIG_PATCHES_MAP_Y,                 NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1224
	SDT_BOOL(Patches, link_terraform_toolbar,        S, 0, false,    STR_CONFIG_PATCHES_LINK_TERRAFORM_TOOLBAR,NULL),
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
  1225
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1226
	/***************************************************************************/
3247
ede7a53941b2 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3246
diff changeset
  1227
	/* Construction section of the GUI-configure patches window */
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1228
	SDT_BOOL(Patches, build_on_slopes,               0, 0,  true,    STR_CONFIG_PATCHES_BUILDONSLOPES,       NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1229
	SDT_BOOL(Patches, extra_dynamite,                0, 0, false,    STR_CONFIG_PATCHES_EXTRADYNAMITE,       NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1230
	SDT_BOOL(Patches, longbridges,                   0, 0,  true,    STR_CONFIG_PATCHES_LONGBRIDGES,         NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1231
	SDT_BOOL(Patches, signal_side,                   N, 0,  true,    STR_CONFIG_PATCHES_SIGNALSIDE,          NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1232
	SDT_BOOL(Patches, always_small_airport,          0, 0, false,    STR_CONFIG_PATCHES_SMALL_AIRPORTS,      NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1233
	 SDT_VAR(Patches, drag_signals_density,SLE_UINT8,S, 0,  4, 1,20, STR_CONFIG_PATCHES_DRAG_SIGNALS_DENSITY,NULL),
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
  1234
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1235
	/***************************************************************************/
3247
ede7a53941b2 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3246
diff changeset
  1236
	/* Vehicle section of the GUI-configure patches window */
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1237
	SDT_BOOL(Patches, realistic_acceleration,        0, 0, false,                STR_CONFIG_PATCHES_REALISTICACCEL,       NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1238
	SDT_BOOL(Patches, forbid_90_deg,                 0, 0, false,                STR_CONFIG_PATCHES_FORBID_90_DEG,        NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1239
	SDT_BOOL(Patches, mammoth_trains,                0, 0,  true,                STR_CONFIG_PATCHES_MAMMOTHTRAINS,        NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1240
	SDT_BOOL(Patches, gotodepot,                     0, 0,  true,                STR_CONFIG_PATCHES_GOTODEPOT,            NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1241
	SDT_BOOL(Patches, roadveh_queue,                 0, 0,  true,                STR_CONFIG_PATCHES_ROADVEH_QUEUE,        NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1242
	SDT_BOOL(Patches, new_pathfinding_all,           0, 0, false,                STR_CONFIG_PATCHES_NEW_PATHFINDING_ALL,  NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1243
	SDT_BOOL(Patches, train_income_warn,             S, 0,  true,                STR_CONFIG_PATCHES_WARN_INCOME_LESS,     NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1244
	 SDT_VAR(Patches, order_review_system,SLE_UINT8, S,MS,     2,      0,     2, STR_CONFIG_PATCHES_ORDER_REVIEW,         NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1245
	SDT_BOOL(Patches, never_expire_vehicles,         0, 0, false,                STR_CONFIG_PATCHES_NEVER_EXPIRE_VEHICLES,NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1246
	 SDT_VAR(Patches, lost_train_days,   SLE_UINT16, S,D0,   180,    180,   720, STR_CONFIG_PATCHES_LOST_TRAIN_DAYS,      NULL),
3131
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1247
	SDT_BOOL(Patches, autorenew,                     S, 0, false,                STR_CONFIG_PATCHES_AUTORENEW_VEHICLE,    EngineRenewUpdate),
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1248
	 SDT_VAR(Patches, autorenew_months,   SLE_INT16, S, 0,     6,    -12,    12, STR_CONFIG_PATCHES_AUTORENEW_MONTHS,     EngineRenewMonthsUpdate),
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1249
	 SDT_VAR(Patches, autorenew_money,     SLE_UINT, S,CR,100000,     0,2000000, STR_CONFIG_PATCHES_AUTORENEW_MONEY,      EngineRenewMoneyUpdate),
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1250
	 SDT_VAR(Patches, max_trains,        SLE_UINT16, 0, 0,   500,     0,   5000, STR_CONFIG_PATCHES_MAX_TRAINS,           NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1251
	 SDT_VAR(Patches, max_roadveh,       SLE_UINT16, 0, 0,   500,     0,   5000, STR_CONFIG_PATCHES_MAX_ROADVEH,          NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1252
	 SDT_VAR(Patches, max_aircraft,      SLE_UINT16, 0, 0,   200,     0,   5000, STR_CONFIG_PATCHES_MAX_AIRCRAFT,         NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1253
	 SDT_VAR(Patches, max_ships,         SLE_UINT16, 0, 0,   300,     0,   5000, STR_CONFIG_PATCHES_MAX_SHIPS,            NULL),
3131
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1254
	SDT_BOOL(Patches, servint_ispercent,             0, 0, false,                STR_CONFIG_PATCHES_SERVINT_ISPERCENT,    CheckInterval),
3246
512d9f9ce1e4 (svn r3926) - [Patches]: Switched string for ship and aircraft replacement, and also forgot to put back the callback function. Thanks Tron
Darkvater
parents: 3245
diff changeset
  1255
	 SDT_VAR(Patches, servint_trains,    SLE_UINT16, 0,D0,   150,     5,    800, STR_CONFIG_PATCHES_SERVINT_TRAINS,       InValidateDetailsWindow),
3131
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1256
	 SDT_VAR(Patches, servint_roadveh,   SLE_UINT16, 0,D0,   150,     5,    800, STR_CONFIG_PATCHES_SERVINT_ROADVEH,      InValidateDetailsWindow),
3246
512d9f9ce1e4 (svn r3926) - [Patches]: Switched string for ship and aircraft replacement, and also forgot to put back the callback function. Thanks Tron
Darkvater
parents: 3245
diff changeset
  1257
	 SDT_VAR(Patches, servint_ships,     SLE_UINT16, 0,D0,   360,     5,    800, STR_CONFIG_PATCHES_SERVINT_SHIPS,        InValidateDetailsWindow),
512d9f9ce1e4 (svn r3926) - [Patches]: Switched string for ship and aircraft replacement, and also forgot to put back the callback function. Thanks Tron
Darkvater
parents: 3245
diff changeset
  1258
	 SDT_VAR(Patches, servint_aircraft,  SLE_UINT16, 0,D0,   100,     5,    800, STR_CONFIG_PATCHES_SERVINT_AIRCRAFT,     InValidateDetailsWindow),
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1259
	SDT_BOOL(Patches, no_servicing_if_no_breakdowns, 0, 0, false,                STR_CONFIG_PATCHES_NOSERVICE,            NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1260
	SDT_BOOL(Patches, wagon_speed_limits,            0, 0,  true,                STR_CONFIG_PATCHES_WAGONSPEEDLIMITS,     NULL),
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
  1261
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1262
	/***************************************************************************/
3247
ede7a53941b2 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3246
diff changeset
  1263
	/* Station section of the GUI-configure patches window */
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1264
	SDT_BOOL(Patches, join_stations,           0, 0,  true,   STR_CONFIG_PATCHES_JOINSTATIONS,       NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1265
	SDT_BOOL(Patches, full_load_any,           0, 0,  true,   STR_CONFIG_PATCHES_FULLLOADANY,        NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1266
	SDT_BOOL(Patches, improved_load,           0, 0, false,   STR_CONFIG_PATCHES_IMPROVEDLOAD,       NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1267
	SDT_BOOL(Patches, selectgoods,             0, 0,  true,   STR_CONFIG_PATCHES_SELECTGOODS,        NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1268
	SDT_BOOL(Patches, new_nonstop,             0, 0, false,   STR_CONFIG_PATCHES_NEW_NONSTOP,        NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1269
	SDT_BOOL(Patches, nonuniform_stations,     0, 0,  true,   STR_CONFIG_PATCHES_NONUNIFORM_STATIONS,NULL),
3131
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1270
	 SDT_VAR(Patches, station_spread,SLE_UINT8,0, 0, 12, 4,64,STR_CONFIG_PATCHES_STATION_SPREAD,     InvalidateStationBuildWindow),
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1271
	SDT_BOOL(Patches, serviceathelipad,        0, 0,  true,   STR_CONFIG_PATCHES_SERVICEATHELIPAD,   NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1272
	SDT_BOOL(Patches, modified_catchment,      0, 0,  true,   STR_CONFIG_PATCHES_CATCHMENT,          NULL),
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
  1273
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1274
	/***************************************************************************/
3247
ede7a53941b2 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3246
diff changeset
  1275
	/* Economy section of the GUI-configure patches window */
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1276
	SDT_BOOL(Patches, inflation,                  0, 0,  true,            STR_CONFIG_PATCHES_INFLATION,        NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1277
	SDT_BOOL(Patches, build_rawmaterial_ind,      0, 0, false,            STR_CONFIG_PATCHES_BUILDXTRAIND,     NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1278
	SDT_BOOL(Patches, multiple_industry_per_town, 0, 0, false,            STR_CONFIG_PATCHES_MULTIPINDTOWN,    NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1279
	SDT_BOOL(Patches, same_industry_close,        0, 0, false,            STR_CONFIG_PATCHES_SAMEINDCLOSE,     NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1280
	SDT_BOOL(Patches, bribe,                      0, 0,  true,            STR_CONFIG_PATCHES_BRIBE,            NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1281
	 SDT_VAR(Patches, snow_line_height,SLE_UINT8, 0, 0,     7,   2,   13, STR_CONFIG_PATCHES_SNOWLINE_HEIGHT,  NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1282
	 SDT_VAR(Patches, colored_news_date,SLE_UINT, 0,NC,  2000,1900, 2200, STR_CONFIG_PATCHES_COLORED_NEWS_DATE,NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1283
	 SDT_VAR(Patches, starting_date,    SLE_UINT, 0,NC,  1950, MAX_YEAR_BEGIN_REAL, MAX_YEAR_END_REAL, STR_CONFIG_PATCHES_STARTING_DATE,NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1284
	 SDT_VAR(Patches, ending_date,      SLE_UINT,0,NC|NO,2051, MAX_YEAR_BEGIN_REAL, MAX_YEAR_END_REAL, STR_CONFIG_PATCHES_ENDING_DATE,  NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1285
	SDT_BOOL(Patches, smooth_economy,             0, 0,  true,            STR_CONFIG_PATCHES_SMOOTH_ECONOMY,   NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1286
	SDT_BOOL(Patches, allow_shares,               0, 0,  true,            STR_CONFIG_PATCHES_ALLOW_SHARES,     NULL),
1218
c6a624956ac6 (svn r1722) -Feature: Bigger maps - anyone?
tron
parents: 1104
diff changeset
  1287
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1288
	/***************************************************************************/
3247
ede7a53941b2 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3246
diff changeset
  1289
	/* AI section of the GUI-configure patches window */
3131
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1290
	SDT_BOOL(Patches, ainew_active,           0, 0, false, STR_CONFIG_PATCHES_AINEW_ACTIVE,      AiNew_PatchActive_Warning),
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1291
	SDT_BOOL(Patches, ai_in_multiplayer,      0, 0, false, STR_CONFIG_PATCHES_AI_IN_MULTIPLAYER, Ai_In_Multiplayer_Warning),
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1292
	SDT_BOOL(Patches, ai_disable_veh_train,   0, 0, false, STR_CONFIG_PATCHES_AI_BUILDS_TRAINS,  NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1293
	SDT_BOOL(Patches, ai_disable_veh_roadveh, 0, 0, false, STR_CONFIG_PATCHES_AI_BUILDS_ROADVEH, NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1294
	SDT_BOOL(Patches, ai_disable_veh_aircraft,0, 0, false, STR_CONFIG_PATCHES_AI_BUILDS_AIRCRAFT,NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1295
	SDT_BOOL(Patches, ai_disable_veh_ship,    0, 0, false, STR_CONFIG_PATCHES_AI_BUILDS_SHIPS,   NULL),
1271
322ab55eca62 (svn r1775) -Fix: The NPF patch setting was not synced in network.
truelight
parents: 1258
diff changeset
  1296
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1297
	/***************************************************************************/
3247
ede7a53941b2 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3246
diff changeset
  1298
	/* Patches without any GUI representation */
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1299
	SDT_BOOL(Patches, keep_all_autosave,              S, 0, false,      STR_NULL, NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1300
	SDT_BOOL(Patches, autosave_on_exit,               S, 0, false,      STR_NULL, NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1301
	 SDT_VAR(Patches, max_num_autosaves,   SLE_UINT8, S, 0, 16, 0, 255, STR_NULL, NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1302
	SDT_BOOL(Patches, bridge_pillars,                 S, 0,  true,      STR_NULL, NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1303
	 SDT_VAR(Patches, extend_vehicle_life, SLE_UINT8, 0, 0,  0, 0, 100, STR_NULL, NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1304
	SDT_BOOL(Patches, auto_euro,                      S, 0,  true,      STR_NULL, NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1305
	 SDT_VAR(Patches, dist_local_authority,SLE_UINT8, 0, 0, 20, 5,  60, STR_NULL, NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1306
	 SDT_VAR(Patches, wait_oneway_signal,  SLE_UINT8, 0, 0, 15, 2, 100, STR_NULL, NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1307
	 SDT_VAR(Patches, wait_twoway_signal,  SLE_UINT8, 0, 0, 41, 2, 100, STR_NULL, NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1308
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1309
	/***************************************************************************/
3247
ede7a53941b2 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3246
diff changeset
  1310
	/* New Pathfinding patch settings */
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1311
	SDT_VAR(Patches, pf_maxlength,      SLE_UINT16, 0, 0, 4096, 64, 65535, STR_NULL, NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1312
	SDT_VAR(Patches, pf_maxdepth,        SLE_UINT8, 0, 0,   48,  4,   255, STR_NULL, NULL),
1700
e1fe3446d013 (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
  1313
	/* The maximum number of nodes to search */
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1314
	SDT_VAR(Patches, npf_max_search_nodes,SLE_UINT, 0, 0,10000,500,100000, STR_NULL, NULL),
1700
e1fe3446d013 (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
  1315
1271
322ab55eca62 (svn r1775) -Fix: The NPF patch setting was not synced in network.
truelight
parents: 1258
diff changeset
  1316
	/* When a red signal is encountered, a small detour can be made around
322ab55eca62 (svn r1775) -Fix: The NPF patch setting was not synced in network.
truelight
parents: 1258
diff changeset
  1317
	* it. This specifically occurs when a track is doubled, in which case
322ab55eca62 (svn r1775) -Fix: The NPF patch setting was not synced in network.
truelight
parents: 1258
diff changeset
  1318
	* the detour is typically 2 tiles. It is also often used at station
322ab55eca62 (svn r1775) -Fix: The NPF patch setting was not synced in network.
truelight
parents: 1258
diff changeset
  1319
	* entrances, when there is a choice of multiple platforms. If we take
322ab55eca62 (svn r1775) -Fix: The NPF patch setting was not synced in network.
truelight
parents: 1258
diff changeset
  1320
	* a typical 4 platform station, the detour is 4 tiles. To properly
322ab55eca62 (svn r1775) -Fix: The NPF patch setting was not synced in network.
truelight
parents: 1258
diff changeset
  1321
	* support larger stations we increase this value.
322ab55eca62 (svn r1775) -Fix: The NPF patch setting was not synced in network.
truelight
parents: 1258
diff changeset
  1322
	* We want to prevent that trains that want to leave at one side of a
322ab55eca62 (svn r1775) -Fix: The NPF patch setting was not synced in network.
truelight
parents: 1258
diff changeset
  1323
	* station, leave through the other side, turn around, enter the
322ab55eca62 (svn r1775) -Fix: The NPF patch setting was not synced in network.
truelight
parents: 1258
diff changeset
  1324
	* station on another platform and exit the station on the right side
322ab55eca62 (svn r1775) -Fix: The NPF patch setting was not synced in network.
truelight
parents: 1258
diff changeset
  1325
	* again, just because the sign at the right side was red. If we take
322ab55eca62 (svn r1775) -Fix: The NPF patch setting was not synced in network.
truelight
parents: 1258
diff changeset
  1326
	* a typical 5 length station, this detour is 10 or 11 tiles (not
322ab55eca62 (svn r1775) -Fix: The NPF patch setting was not synced in network.
truelight
parents: 1258
diff changeset
  1327
	* sure), so we set the default penalty at 10 (the station tile
1643
420cad9e62e4 (svn r2147) - Add: [NPF] Give red presignal exit signals a different (higher) penalty, to discourage trains from waiting at presignal exits.
matthijs
parents: 1602
diff changeset
  1328
	* penalty will further prevent this.
420cad9e62e4 (svn r2147) - Add: [NPF] Give red presignal exit signals a different (higher) penalty, to discourage trains from waiting at presignal exits.
matthijs
parents: 1602
diff changeset
  1329
	* We give presignal exits (and combo's) a different (larger) penalty, because we really
420cad9e62e4 (svn r2147) - Add: [NPF] Give red presignal exit signals a different (higher) penalty, to discourage trains from waiting at presignal exits.
matthijs
parents: 1602
diff changeset
  1330
	* don't want trains waiting in front of a presignal exit. */
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1331
	SDT_VAR(Patches, npf_rail_firstred_penalty,     SLE_UINT, 0, 0, (10 * NPF_TILE_LENGTH), 0, 100000, STR_NULL, NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1332
	SDT_VAR(Patches, npf_rail_firstred_exit_penalty,SLE_UINT, 0, 0, (100 * NPF_TILE_LENGTH),0, 100000, STR_NULL, NULL),
1459
19333d7f99b3 (svn r1963) - Add: [NPF] Penalty for a red signal that is the last signal on the path.
matthijs
parents: 1422
diff changeset
  1333
	/* This penalty is for when the last signal before the target is red.
19333d7f99b3 (svn r1963) - Add: [NPF] Penalty for a red signal that is the last signal on the path.
matthijs
parents: 1422
diff changeset
  1334
	 * This is useful for train stations, where there are multiple
19333d7f99b3 (svn r1963) - Add: [NPF] Penalty for a red signal that is the last signal on the path.
matthijs
parents: 1422
diff changeset
  1335
	 * platforms to choose from, which lie in different signal blocks.
19333d7f99b3 (svn r1963) - Add: [NPF] Penalty for a red signal that is the last signal on the path.
matthijs
parents: 1422
diff changeset
  1336
	 * Every target in a occupied signal block (ie an occupied platform)
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1337
	 * will get this penalty. */
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1338
	SDT_VAR(Patches, npf_rail_lastred_penalty, SLE_UINT, 0, 0, (10 * NPF_TILE_LENGTH), 0, 100000, STR_NULL, NULL),
1271
322ab55eca62 (svn r1775) -Fix: The NPF patch setting was not synced in network.
truelight
parents: 1258
diff changeset
  1339
	/* When a train plans a route over a station tile, this penalty is
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1340
	 * applied. We want that trains plan a route around a typical, 4x5
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1341
	 * station, which means two tiles to the right, and two tiles back to
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1342
	 * the left around it, or 5 tiles of station through it. If we assign
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1343
	 * a penalty of 1 tile for every station tile passed, the route will
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1344
	 * be around it. */
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1345
	SDT_VAR(Patches, npf_rail_station_penalty, SLE_UINT, 0, 0, (1 * NPF_TILE_LENGTH), 0, 100000, STR_NULL, NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1346
	SDT_VAR(Patches, npf_rail_slope_penalty,   SLE_UINT, 0, 0, (1 * NPF_TILE_LENGTH), 0, 100000, STR_NULL, NULL),
1751
009a240d035a (svn r2255) - Fix: [ 9680363 ] [NPF] Broken buoy handling for ships
matthijs
parents: 1727
diff changeset
  1347
	/* This penalty is applied when a train makes a turn. Its value of 1 makes
009a240d035a (svn r2255) - Fix: [ 9680363 ] [NPF] Broken buoy handling for ships
matthijs
parents: 1727
diff changeset
  1348
	 * sure that it has a minimal impact on the pathfinding, only when two
009a240d035a (svn r2255) - Fix: [ 9680363 ] [NPF] Broken buoy handling for ships
matthijs
parents: 1727
diff changeset
  1349
	 * paths have equal length it will make a difference */
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1350
	SDT_VAR(Patches, npf_rail_curve_penalty,        SLE_UINT, 0, 0, 1,                      0, 100000, STR_NULL, NULL),
1777
f703cf05b5b9 (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
  1351
	/* Ths penalty is applied when a vehicle reverses inside a depot (doesn't
f703cf05b5b9 (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
  1352
	 * apply to ships, as they can just come out the other end). XXX: Is this a
f703cf05b5b9 (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
  1353
	 * good value? */
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1354
	SDT_VAR(Patches, npf_rail_depot_reverse_penalty,SLE_UINT, 0, 0, (NPF_TILE_LENGTH * 50), 0, 100000, STR_NULL, NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1355
	SDT_VAR(Patches, npf_buoy_penalty,              SLE_UINT, 0, 0, (2 * NPF_TILE_LENGTH),  0, 100000, STR_NULL, NULL),
1751
009a240d035a (svn r2255) - Fix: [ 9680363 ] [NPF] Broken buoy handling for ships
matthijs
parents: 1727
diff changeset
  1356
	/* This penalty is applied when a ship makes a turn. It is bigger than the
009a240d035a (svn r2255) - Fix: [ 9680363 ] [NPF] Broken buoy handling for ships
matthijs
parents: 1727
diff changeset
  1357
	 * rail curve penalty, since ships (realisticly) have more trouble with
009a240d035a (svn r2255) - Fix: [ 9680363 ] [NPF] Broken buoy handling for ships
matthijs
parents: 1727
diff changeset
  1358
	 * making turns */
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1359
	SDT_VAR(Patches, npf_water_curve_penalty,       SLE_UINT, 0, 0, (NPF_TILE_LENGTH / 4),  0, 100000, STR_NULL, NULL),
1941
ca268f8837df (svn r2447) * Add: [NPF] Penalty for road vehicles making turns.
matthijs
parents: 1891
diff changeset
  1360
	/* This is the penalty for road, same as for rail. */
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1361
	SDT_VAR(Patches, npf_road_curve_penalty,        SLE_UINT, 0, 0, 1,                      0, 100000, STR_NULL, NULL),
2006
9d5d7fd428c2 (svn r2514) - Codechange: [NPF] Move the checking of railtype into a funciton IsCompatibleRail().
matthijs
parents: 1941
diff changeset
  1362
	/* This is the penalty for level crossings, for both road and rail vehicles */
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1363
	SDT_VAR(Patches, npf_crossing_penalty,          SLE_UINT, 0, 0, (3 * NPF_TILE_LENGTH),  0, 100000, STR_NULL, NULL),
1271
322ab55eca62 (svn r1775) -Fix: The NPF patch setting was not synced in network.
truelight
parents: 1258
diff changeset
  1364
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1365
	SDT_END()
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
  1366
};
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
  1367
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1368
static const SettingDesc _currency_settings[] = {
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1369
	SDT_VAR(CurrencySpec, rate,    SLE_UINT16, S, 0,  1, 0, 100, STR_NULL, NULL),
3192
ad4404f6d03d (svn r3852) - Revert r3733 which fixed the default value loading for char, but broke loading a set value. Added a better fix which needs a char value to be a string (eg enclosed in double-quotes)
Darkvater
parents: 3152
diff changeset
  1370
	SDT_CHR(CurrencySpec, separator,           S, 0,        ".", STR_NULL, NULL),
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1371
	SDT_VAR(CurrencySpec, to_euro, SLE_UINT16, S, 0,  0, 0,1000, STR_NULL, NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1372
	SDT_STR(CurrencySpec, prefix,    SLE_STRQ, S, 0,       NULL, STR_NULL, NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1373
	SDT_STR(CurrencySpec, suffix,    SLE_STRQ, S, 0, " credits", STR_NULL, NULL),
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1374
	SDT_END()
759
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 738
diff changeset
  1375
};
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 738
diff changeset
  1376
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1377
/* Undefine for the shortcut macros above */
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1378
#undef S
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1379
#undef C
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1380
#undef N
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1381
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1382
#undef D0
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1383
#undef NC
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1384
#undef MS
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1385
#undef NO
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1386
#undef CR
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1387
3115
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
  1388
typedef void SettingDescProc(IniFile *ini, const SettingDesc *desc, const char *grpname, void *object);
24c7e92baa31 (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3112
diff changeset
  1389
typedef void SettingDescProcList(IniFile *ini, const char *grpname, char **list, uint len);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1390
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1391
/* Common handler for saving/loading variables to the configuration file */
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1392
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
  1393
{
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1394
	proc(ini, (const SettingDesc*)_misc_settings,    "misc",  NULL);
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1395
	proc(ini, (const SettingDesc*)_music_settings,   "music", &msf);
3051
6a9ddcac6d56 (svn r3640) - Remove win32-only variables from variables.h and put them into win32_v.c. Also ifdef the win32 specific configuration file settings.
Darkvater
parents: 3042
diff changeset
  1396
#ifdef WIN32
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1397
	proc(ini, (const SettingDesc*)_win32_settings,   "win32", NULL);
3051
6a9ddcac6d56 (svn r3640) - Remove win32-only variables from variables.h and put them into win32_v.c. Also ifdef the win32 specific configuration file settings.
Darkvater
parents: 3042
diff changeset
  1398
#endif /* WIN32 */
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1399
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1400
	proc(ini, _gameopt_settings, "gameopt",  &_opt_newgame);
3121
72fb0554f9f1 (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
  1401
	proc(ini, _patch_settings,   "patches",  &_patches_newgame);
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1402
	proc(ini, _currency_settings,"currency", &_custom_currency);
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1403
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
  1404
#ifdef ENABLE_NETWORK
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1405
	proc(ini, (const SettingDesc*)_network_settings, "network", NULL);
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1406
	proc_list(ini, "servers", _network_host_list, lengthof(_network_host_list));
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1407
	proc_list(ini, "bans",    _network_ban_list,  lengthof(_network_ban_list));
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
  1408
#endif /* ENABLE_NETWORK */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1409
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1410
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1411
/** Load the values from the configuration files */
1093
4fdc46eaf423 (svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents: 1037
diff changeset
  1412
void LoadFromConfig(void)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1413
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1414
	IniFile *ini = ini_load(_config_file);
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1415
	HandleSettingDescs(ini, ini_load_settings, ini_load_setting_list);
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1416
	ini_load_setting_list(ini, "newgrf", _newgrf_files, lengthof(_newgrf_files));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1417
	ini_free(ini);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1418
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1419
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1420
/** Save the values to the configuration file */
1093
4fdc46eaf423 (svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents: 1037
diff changeset
  1421
void SaveToConfig(void)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1422
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1423
	IniFile *ini = ini_load(_config_file);
3116
b125bf75b4b0 (svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents: 3115
diff changeset
  1424
	HandleSettingDescs(ini, ini_save_settings, ini_save_setting_list);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1425
	ini_save(_config_file, ini);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1426
	ini_free(ini);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1427
}
1688
af2bb9bcb2ed (svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents: 1643
diff changeset
  1428
3247
ede7a53941b2 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3246
diff changeset
  1429
static const SettingDesc *GetSettingDescription(uint index)
3118
adc86793eee1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3117
diff changeset
  1430
{
adc86793eee1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3117
diff changeset
  1431
	if (index >= lengthof(_patch_settings)) return NULL;
adc86793eee1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3117
diff changeset
  1432
	return &_patch_settings[index];
adc86793eee1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3117
diff changeset
  1433
}
adc86793eee1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3117
diff changeset
  1434
3119
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1435
/** Network-safe changing of patch-settings (server-only).
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1436
 * @param p1 the index of the patch in the SettingDesc array which identifies it
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1437
 * @param p2 the new value for the patch
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1438
 * The new value is properly clamped to its minimum/maximum when setting
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1439
 * @see _patch_settings
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1440
 */
3491
35d747bb5e82 (svn r4342) Change the first two parameters of commands - virtual pixel coordinates of the tile to operate on - to a TileIndex
tron
parents: 3358
diff changeset
  1441
int32 CmdChangePatchSetting(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
3119
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1442
{
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1443
	const SettingDesc *sd = GetSettingDescription(p1);
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1444
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1445
	if (sd == NULL) return CMD_ERROR;
3223
eed8c6a62ec2 (svn r3896) - [Patches] Fix: Honour any conditional settings when retrieving the setting entries.
Darkvater
parents: 3222
diff changeset
  1446
	if (!SlIsObjectCurrentlyValid(sd->save.version_from, sd->save.version_to)) return CMD_ERROR;
3119
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1447
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1448
	if (flags & DC_EXEC) {
3121
72fb0554f9f1 (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
  1449
		Patches *patches_ptr = (_game_mode == GM_MENU) ? &_patches_newgame : &_patches;
3119
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1450
		void *var = ini_get_variable(&sd->save, patches_ptr);
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1451
		Write_ValidateSetting(var, sd, (int32)p2);
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1452
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1453
		InvalidateWindow(WC_GAME_OPTIONS, 0);
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1454
	}
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1455
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1456
	return 0;
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1457
}
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1458
3615
4afd81377ba3 (svn r4512) - Codechange: Sprinkle some doxygen magic over settings.c
Darkvater
parents: 3606
diff changeset
  1459
/** Top function to save the new value of an element of the Patches struct
3118
adc86793eee1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3117
diff changeset
  1460
 * @param index offset in the SettingDesc array of the Patches struct which
adc86793eee1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3117
diff changeset
  1461
 * identifies the patch member we want to change
adc86793eee1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3117
diff changeset
  1462
 * @param object pointer to a valid patches struct that has its settings change.
adc86793eee1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3117
diff changeset
  1463
 * This only affects patch-members that are not needed to be the same on all
adc86793eee1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3117
diff changeset
  1464
 * clients in a network game.
adc86793eee1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3117
diff changeset
  1465
 * @param value new value of the patch */
adc86793eee1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3117
diff changeset
  1466
void SetPatchValue(uint index, const Patches *object, int32 value)
adc86793eee1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3117
diff changeset
  1467
{
adc86793eee1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3117
diff changeset
  1468
	const SettingDesc *sd = &_patch_settings[index];
adc86793eee1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3117
diff changeset
  1469
	/* If an item is player-based, we do not send it over the network
adc86793eee1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3117
diff changeset
  1470
	 * (if any) to change. Also *hack*hack* we update the _newgame version
adc86793eee1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3117
diff changeset
  1471
	 * of patches because changing a player-based setting in a game also
adc86793eee1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3117
diff changeset
  1472
	 * changes its defaults. At least that is the convention we have chosen */
adc86793eee1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3117
diff changeset
  1473
	if (sd->save.conv & SLF_NETWORK_NO) {
adc86793eee1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3117
diff changeset
  1474
		void *var = ini_get_variable(&sd->save, object);
adc86793eee1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3117
diff changeset
  1475
		Write_ValidateSetting(var, sd, value);
3121
72fb0554f9f1 (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
  1476
72fb0554f9f1 (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
  1477
		if (_game_mode != GM_MENU) {
72fb0554f9f1 (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
  1478
		 void *var2 = ini_get_variable(&sd->save, &_patches_newgame);
72fb0554f9f1 (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
  1479
		 Write_ValidateSetting(var2, sd, value);
72fb0554f9f1 (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
  1480
		}
3118
adc86793eee1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3117
diff changeset
  1481
	} else {
adc86793eee1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3117
diff changeset
  1482
		DoCommandP(0, index, value, NULL, CMD_CHANGE_PATCH_SETTING);
adc86793eee1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3117
diff changeset
  1483
	}
adc86793eee1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3117
diff changeset
  1484
}
adc86793eee1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3117
diff changeset
  1485
3247
ede7a53941b2 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3246
diff changeset
  1486
const SettingDesc *GetPatchFromName(const char *name, uint *i)
3119
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1487
{
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1488
	const SettingDesc *sd;
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1489
3131
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1490
	for (*i = 0, sd = _patch_settings; sd->save.cmd != SL_END; sd++, (*i)++) {
3223
eed8c6a62ec2 (svn r3896) - [Patches] Fix: Honour any conditional settings when retrieving the setting entries.
Darkvater
parents: 3222
diff changeset
  1491
		if (!SlIsObjectCurrentlyValid(sd->save.version_from, sd->save.version_to)) continue;
3210
2c3f6ea896f4 (svn r3880) - just do a string compare without length restrictions; followup for r3875
Darkvater
parents: 3207
diff changeset
  1492
		if (strcmp(sd->desc.name, name) == 0) return sd;
3119
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1493
	}
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1494
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1495
	return NULL;
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1496
}
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1497
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1498
/* Those 2 functions need to be here, else we have to make some stuff non-static
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1499
 * and besides, it is also better to keep stuff like this at the same place */
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1500
void IConsoleSetPatchSetting(const char *name, const char *value)
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1501
{
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1502
	char newval[20];
3131
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1503
	int32 val;
3119
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1504
	uint index;
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1505
	const SettingDesc *sd = GetPatchFromName(name, &index);
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1506
	const Patches *patches_ptr;
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1507
	void *ptr;
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1508
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1509
	if (sd == NULL) {
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1510
		IConsolePrintF(_icolour_warn, "'%s' is an unknown patch setting.", name);
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1511
		return;
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1512
	}
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1513
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1514
	sscanf(value, "%d", &val);
3121
72fb0554f9f1 (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
  1515
	patches_ptr = (_game_mode == GM_MENU) ? &_patches_newgame : &_patches;
3119
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1516
	ptr = ini_get_variable(&sd->save, patches_ptr);
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1517
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1518
	SetPatchValue(index, patches_ptr, val);
3131
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1519
	val = ReadValue(ptr, sd->save.conv);
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1520
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1521
	if (sd->desc.proc != NULL) sd->desc.proc(val);
3119
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1522
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1523
	if (sd->desc.cmd == SDT_BOOLX) {
3131
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1524
		snprintf(newval, sizeof(newval), (val != 0) ? "on" : "off");
3119
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1525
	} else {
3131
b56514952c8c (svn r3746) - [7/7] Moving the callback functions for the setting-changes from settings_gui.c to settings.c. Also enable the callback functionality through the console.
Darkvater
parents: 3125
diff changeset
  1526
		snprintf(newval, sizeof(newval), "%d", val);
3119
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1527
	}
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1528
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1529
	IConsolePrintF(_icolour_warn, "'%s' changed to:  %s", name, newval);
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1530
}
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1531
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1532
void IConsoleGetPatchSetting(const char *name)
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1533
{
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1534
	char value[20];
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1535
	uint index;
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1536
	const SettingDesc *sd = GetPatchFromName(name, &index);
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1537
	const void *ptr;
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1538
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1539
	if (sd == NULL) {
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1540
		IConsolePrintF(_icolour_warn, "'%s' is an unknown patch setting.", name);
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1541
		return;
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1542
	}
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1543
3121
72fb0554f9f1 (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
  1544
	ptr = ini_get_variable(&sd->save, (_game_mode == GM_MENU) ? &_patches_newgame : &_patches);
3119
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1545
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1546
	if (sd->desc.cmd == SDT_BOOLX) {
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1547
		snprintf(value, sizeof(value), (*(bool*)ptr == 1) ? "on" : "off");
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1548
	} else {
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1549
		snprintf(value, sizeof(value), "%d", (int32)ReadValue(ptr, sd->save.conv));
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1550
	}
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1551
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1552
	IConsolePrintF(_icolour_warn, "Current value for '%s' is: '%s' (min: %s%d, max: %d)",
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1553
		name, value, (sd->desc.flags & SGF_0ISDISABLED) ? "(0) " : "", sd->desc.min, sd->desc.max);
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1554
}
8f1b561d9870 (svn r3723) - [5/6] Move over the console commands from settings_gui to settings where they rather belong.
Darkvater
parents: 3118
diff changeset
  1555
3117
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  1556
/** Save and load handler for patches/settings
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  1557
 * @param osd SettingDesc struct containing all information
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  1558
 * @param object can be either NULL in which case we load global variables or
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  1559
 * a pointer to a struct which is getting saved */
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  1560
static void LoadSettings(const SettingDesc *osd, void *object)
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  1561
{
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  1562
	for (; osd->save.cmd != SL_END; osd++) {
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  1563
		const SaveLoad *sld = &osd->save;
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  1564
		void *ptr = ini_get_variable(sld, object);
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  1565
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  1566
		if (!SlObjectMember(ptr, sld)) continue;
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  1567
	}
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  1568
}
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  1569
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  1570
/** Loadhandler for a list of global variables
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  1571
 * @note this is actually a stub for LoadSettings with the
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  1572
 * object pointer set to NULL */
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  1573
static inline void LoadSettingsGlobList(const SettingDescGlobVarList *sdg)
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  1574
{
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  1575
	LoadSettings((const SettingDesc*)sdg, NULL);
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  1576
}
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  1577
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  1578
/** Save and load handler for patches/settings
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  1579
 * @param osd SettingDesc struct containing all information
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  1580
 * @param object can be either NULL in which case we load global variables or
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  1581
 * a pointer to a struct which is getting saved */
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  1582
static void SaveSettings(const SettingDesc *sd, void *object)
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  1583
{
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  1584
	/* We need to write the CH_RIFF header, but unfortunately can't call
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  1585
	 * SlCalcLength() because we have a different format. So do this manually */
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  1586
	const SettingDesc *i;
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  1587
	size_t length = 0;
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  1588
	for (i = sd; i->save.cmd != SL_END; i++) {
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  1589
		length += SlCalcObjMemberLength(&i->save);
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  1590
	}
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  1591
	SlSetLength(length);
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  1592
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  1593
	for (i = sd; i->save.cmd != SL_END; i++) {
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  1594
		void *ptr = ini_get_variable(&i->save, object);
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  1595
		SlObjectMember(ptr, &i->save);
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  1596
	}
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  1597
}
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  1598
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  1599
/** Savehandler for a list of global variables
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  1600
 * @note this is actually a stub for SaveSettings with the
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  1601
 * object pointer set to NULL */
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  1602
static inline void SaveSettingsGlobList(const SettingDescGlobVarList *sdg)
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  1603
{
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  1604
	SaveSettings((const SettingDesc*)sdg, NULL);
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  1605
}
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  1606
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  1607
static void Load_OPTS(void)
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  1608
{
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  1609
	/* Copy over default setting since some might not get loaded in
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  1610
	 * a networking environment. This ensures for example that the local
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  1611
	 * autosave-frequency stays when joining a network-server */
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  1612
	_opt = _opt_newgame;
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  1613
	LoadSettings(_gameopt_settings, &_opt);
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  1614
}
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  1615
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  1616
static void Save_OPTS(void)
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  1617
{
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  1618
	SaveSettings(_gameopt_settings, &_opt);
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  1619
}
4c9e8842598e (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3116
diff changeset
  1620
3121
72fb0554f9f1 (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
  1621
static void Load_PATS(void)
72fb0554f9f1 (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
  1622
{
72fb0554f9f1 (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
  1623
	/* Copy over default setting since some might not get loaded in
72fb0554f9f1 (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
  1624
	 * a networking environment. This ensures for example that the local
72fb0554f9f1 (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
  1625
	 * signal_side stays when joining a network-server */
72fb0554f9f1 (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
  1626
	_patches = _patches_newgame;
72fb0554f9f1 (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
  1627
	LoadSettings(_patch_settings, &_patches);
72fb0554f9f1 (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
  1628
}
72fb0554f9f1 (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
  1629
72fb0554f9f1 (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
  1630
static void Save_PATS(void)
72fb0554f9f1 (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
  1631
{
72fb0554f9f1 (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
  1632
	SaveSettings(_patch_settings, &_patches);
72fb0554f9f1 (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
  1633
}
72fb0554f9f1 (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
  1634
1688
af2bb9bcb2ed (svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents: 1643
diff changeset
  1635
void CheckConfig(void)
af2bb9bcb2ed (svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents: 1643
diff changeset
  1636
{
af2bb9bcb2ed (svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents: 1643
diff changeset
  1637
	// fix up news_display_opt from old to new
af2bb9bcb2ed (svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents: 1643
diff changeset
  1638
	int i;
af2bb9bcb2ed (svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents: 1643
diff changeset
  1639
	uint32 tmp;
1723
edb80d6bcc2d (svn r2227) - Fix (regression): [ 1188408 ] Fix news settings load check. When updating old news-message-types to new ones, certain combinations of new were wrongly recognized as old (glx)
Darkvater
parents: 1700
diff changeset
  1640
	for (i = 0, tmp = _news_display_opt; i != 10; i++, tmp >>= 2) {
1688
af2bb9bcb2ed (svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents: 1643
diff changeset
  1641
		if ((tmp & 0x3) == 0x3) { // old settings
af2bb9bcb2ed (svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents: 1643
diff changeset
  1642
			_news_display_opt = 0xAAAAAAAA; // set all news-messages to full 1010101010...
af2bb9bcb2ed (svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents: 1643
diff changeset
  1643
			break;
af2bb9bcb2ed (svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents: 1643
diff changeset
  1644
		}
af2bb9bcb2ed (svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents: 1643
diff changeset
  1645
	}
2044
df63b9a7dec3 (svn r2553) - Fix: [pathfinding] Remove old-old train pathfinder. Enhanced old pathfinder.
ludde
parents: 2008
diff changeset
  1646
df63b9a7dec3 (svn r2553) - Fix: [pathfinding] Remove old-old train pathfinder. Enhanced old pathfinder.
ludde
parents: 2008
diff changeset
  1647
	// Increase old default values for pf_maxdepth and pf_maxlength
df63b9a7dec3 (svn r2553) - Fix: [pathfinding] Remove old-old train pathfinder. Enhanced old pathfinder.
ludde
parents: 2008
diff changeset
  1648
	// to support big networks.
3121
72fb0554f9f1 (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
  1649
	if (_patches_newgame.pf_maxdepth == 16 && _patches_newgame.pf_maxlength == 512) {
72fb0554f9f1 (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
  1650
		_patches_newgame.pf_maxdepth = 48;
72fb0554f9f1 (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
  1651
		_patches_newgame.pf_maxlength = 4096;
2044
df63b9a7dec3 (svn r2553) - Fix: [pathfinding] Remove old-old train pathfinder. Enhanced old pathfinder.
ludde
parents: 2008
diff changeset
  1652
	}
1688
af2bb9bcb2ed (svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents: 1643
diff changeset
  1653
}
3112
a6fda4d4c7ca (svn r3716) - Move the option settings (_game_opt_desc) from misc.c into settings.c. This will be merged with SettingDesc misc_settings above as they are actually the same. No functionality has changed beside the fact that the settings are now in a different Chunkhandler.
Darkvater
parents: 3052
diff changeset
  1654
3121
72fb0554f9f1 (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
  1655
void UpdatePatches(void)
72fb0554f9f1 (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
  1656
{
72fb0554f9f1 (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
  1657
	/* Since old(er) savegames don't have any patches saved, we initialise
72fb0554f9f1 (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
  1658
	 * them with the default values just as it was in the old days.
72fb0554f9f1 (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
  1659
	 * Also new games need this copying-over */
72fb0554f9f1 (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
  1660
	_patches = _patches_newgame; /* backwards compatibility */
72fb0554f9f1 (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
  1661
}
72fb0554f9f1 (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
  1662
3112
a6fda4d4c7ca (svn r3716) - Move the option settings (_game_opt_desc) from misc.c into settings.c. This will be merged with SettingDesc misc_settings above as they are actually the same. No functionality has changed beside the fact that the settings are now in a different Chunkhandler.
Darkvater
parents: 3052
diff changeset
  1663
const ChunkHandler _setting_chunk_handlers[] = {
3121
72fb0554f9f1 (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
  1664
	{ 'OPTS', Save_OPTS, Load_OPTS, CH_RIFF},
72fb0554f9f1 (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
  1665
	{ 'PATS', Save_PATS, Load_PATS, CH_RIFF | CH_LAST},
3112
a6fda4d4c7ca (svn r3716) - Move the option settings (_game_opt_desc) from misc.c into settings.c. This will be merged with SettingDesc misc_settings above as they are actually the same. No functionality has changed beside the fact that the settings are now in a different Chunkhandler.
Darkvater
parents: 3052
diff changeset
  1666
};