settings.c
author Darkvater
Sun, 29 Jan 2006 21:38:24 +0000
changeset 2925 0fea187a09f5
parent 2923 272d1b0962bc
child 2952 6a26eeda9679
child 9945 10025bb0aff2
permissions -rw-r--r--
(svn r3481) - Try and fix an svn discrepancy of trolly.h #2
2186
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     1
/* $Id$ */
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     2
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     3
#include "stdafx.h"
1891
92a3b0aa0946 (svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents: 1777
diff changeset
     4
#include "openttd.h"
2291
2b064aa97f91 (svn r2815) Store the currency information in one central place instead of scattering it in several unrelated files
tron
parents: 2191
diff changeset
     5
#include "currency.h"
2163
637ec3c361f5 (svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents: 2153
diff changeset
     6
#include "functions.h"
2191
cb4985f271ae (svn r2706) Fix !WITH_NETWORK build
tron
parents: 2186
diff changeset
     7
#include "macros.h"
2121
c86a863485ee (svn r2631) Move screenshot related variables from variables.h to screenshot.[ch]
tron
parents: 2044
diff changeset
     8
#include "screenshot.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     9
#include "sound.h"
1317
f382f1b439c7 (svn r1821) Move generic string handling functions to string.[ch] and introduce stre{cpy,cat}, see string.h for their semantics
tron
parents: 1282
diff changeset
    10
#include "string.h"
2153
91e89aa8c299 (svn r2663) Include variables.h only in these files which need it, not globally via openttd.h
tron
parents: 2125
diff changeset
    11
#include "variables.h"
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
    12
#include "network.h"
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
    13
#include "settings.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    14
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    15
typedef struct IniFile IniFile;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    16
typedef struct IniItem IniItem;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    17
typedef struct IniGroup IniGroup;
1258
7b078174f796 (svn r1762) -Codechange: renamed 'MemoryPool' to 'SettingsMemoryPool' (we need
truelight
parents: 1247
diff changeset
    18
typedef struct SettingsMemoryPool SettingsMemoryPool;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    19
1258
7b078174f796 (svn r1762) -Codechange: renamed 'MemoryPool' to 'SettingsMemoryPool' (we need
truelight
parents: 1247
diff changeset
    20
static void pool_init(SettingsMemoryPool **pool);
7b078174f796 (svn r1762) -Codechange: renamed 'MemoryPool' to 'SettingsMemoryPool' (we need
truelight
parents: 1247
diff changeset
    21
static void *pool_alloc(SettingsMemoryPool **pool, uint size);
7b078174f796 (svn r1762) -Codechange: renamed 'MemoryPool' to 'SettingsMemoryPool' (we need
truelight
parents: 1247
diff changeset
    22
static void *pool_strdup(SettingsMemoryPool **pool, const char *mem, uint size);
7b078174f796 (svn r1762) -Codechange: renamed 'MemoryPool' to 'SettingsMemoryPool' (we need
truelight
parents: 1247
diff changeset
    23
static void pool_free(SettingsMemoryPool **pool);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    24
1258
7b078174f796 (svn r1762) -Codechange: renamed 'MemoryPool' to 'SettingsMemoryPool' (we need
truelight
parents: 1247
diff changeset
    25
struct SettingsMemoryPool {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    26
	uint pos,size;
1258
7b078174f796 (svn r1762) -Codechange: renamed 'MemoryPool' to 'SettingsMemoryPool' (we need
truelight
parents: 1247
diff changeset
    27
	SettingsMemoryPool *next;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    28
	byte mem[1];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    29
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    30
1258
7b078174f796 (svn r1762) -Codechange: renamed 'MemoryPool' to 'SettingsMemoryPool' (we need
truelight
parents: 1247
diff changeset
    31
static SettingsMemoryPool *pool_new(uint minsize)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    32
{
1258
7b078174f796 (svn r1762) -Codechange: renamed 'MemoryPool' to 'SettingsMemoryPool' (we need
truelight
parents: 1247
diff changeset
    33
	SettingsMemoryPool *p;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    34
	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
    35
1258
7b078174f796 (svn r1762) -Codechange: renamed 'MemoryPool' to 'SettingsMemoryPool' (we need
truelight
parents: 1247
diff changeset
    36
	p = malloc(sizeof(SettingsMemoryPool) - 1 + minsize);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    37
	p->pos = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    38
	p->size = minsize;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    39
	p->next = NULL;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    40
	return p;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    41
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    42
1258
7b078174f796 (svn r1762) -Codechange: renamed 'MemoryPool' to 'SettingsMemoryPool' (we need
truelight
parents: 1247
diff changeset
    43
static void pool_init(SettingsMemoryPool **pool)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    44
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    45
	*pool = pool_new(0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    46
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    47
1258
7b078174f796 (svn r1762) -Codechange: renamed 'MemoryPool' to 'SettingsMemoryPool' (we need
truelight
parents: 1247
diff changeset
    48
static void *pool_alloc(SettingsMemoryPool **pool, uint size)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    49
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    50
	uint pos;
1258
7b078174f796 (svn r1762) -Codechange: renamed 'MemoryPool' to 'SettingsMemoryPool' (we need
truelight
parents: 1247
diff changeset
    51
	SettingsMemoryPool *p = *pool;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    52
2450
44dc366c480e (svn r2976) -Fix: Align settings pool items to the size of void* to fix bus errors on 64bit architectures which require aligned variables
tron
parents: 2398
diff changeset
    53
	size = ALIGN(size, sizeof(void*));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    54
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    55
	// 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
    56
	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
    57
		p = p->next;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    58
	// 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
    59
	} else if (p->pos + size > p->size) {
1258
7b078174f796 (svn r1762) -Codechange: renamed 'MemoryPool' to 'SettingsMemoryPool' (we need
truelight
parents: 1247
diff changeset
    60
		SettingsMemoryPool *n = pool_new(size);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    61
		*pool = n;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    62
		n->next = p;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 188
diff changeset
    63
		p = n;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    64
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    65
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    66
	pos = p->pos;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    67
	p->pos += size;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    68
	return p->mem + pos;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    69
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    70
1258
7b078174f796 (svn r1762) -Codechange: renamed 'MemoryPool' to 'SettingsMemoryPool' (we need
truelight
parents: 1247
diff changeset
    71
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
    72
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    73
	byte *p = pool_alloc(pool, size + 1);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    74
	p[size] = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    75
	memcpy(p, mem, size);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    76
	return p;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    77
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    78
1258
7b078174f796 (svn r1762) -Codechange: renamed 'MemoryPool' to 'SettingsMemoryPool' (we need
truelight
parents: 1247
diff changeset
    79
static void pool_free(SettingsMemoryPool **pool)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    80
{
1258
7b078174f796 (svn r1762) -Codechange: renamed 'MemoryPool' to 'SettingsMemoryPool' (we need
truelight
parents: 1247
diff changeset
    81
	SettingsMemoryPool *p = *pool, *n;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    82
	*pool = NULL;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    83
	while (p) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    84
		n = p->next;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    85
		free(p);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    86
		p = n;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    87
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    88
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    89
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    90
// structs describing the ini format.
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    91
struct IniItem {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    92
	char *name;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    93
	char *value;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    94
	char *comment;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    95
	IniItem *next;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    96
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    97
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    98
struct IniGroup {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    99
	char *name; // name of group
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   100
	char *comment; //comment for group
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   101
	IniItem *item, **last_item;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   102
	IniGroup *next;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   103
	IniFile *ini;
705
e213445d82ec (svn r1157) Enhanced the config file (openttd.cfg) to use another section type. "List sections" as opposed to "variable sections" contain a list of values, separated by a new line. This is now used for the [newgrf] group. You have to edit each line in this section from e.g. "0 = firstset.grf" to only "firstset.grf".
dominik
parents: 690
diff changeset
   104
	IniGroupType type; // type of group
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   105
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   106
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   107
struct IniFile {
1258
7b078174f796 (svn r1762) -Codechange: renamed 'MemoryPool' to 'SettingsMemoryPool' (we need
truelight
parents: 1247
diff changeset
   108
	SettingsMemoryPool *pool;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   109
	IniGroup *group, **last_group;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   110
	char *comment; // last comment in file
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   111
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   112
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   113
// allocate an inifile object
1093
e8d26c7dc42f (svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents: 1037
diff changeset
   114
static IniFile *ini_alloc(void)
0
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
	IniFile *ini;
1258
7b078174f796 (svn r1762) -Codechange: renamed 'MemoryPool' to 'SettingsMemoryPool' (we need
truelight
parents: 1247
diff changeset
   117
	SettingsMemoryPool *pool;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   118
	pool_init(&pool);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   119
	ini = (IniFile*)pool_alloc(&pool, sizeof(IniFile));
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   120
	ini->pool = pool;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   121
	ini->group = NULL;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   122
	ini->last_group = &ini->group;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   123
	ini->comment = NULL;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   124
	return ini;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   125
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   126
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   127
// allocate an ini group object
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   128
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
   129
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   130
	IniGroup *grp = pool_alloc(&ini->pool, sizeof(IniGroup));
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   131
	grp->ini = ini;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   132
	grp->name = pool_strdup(&ini->pool, grpt, len);
841
8f0a68c6f43b (svn r1322) -Add: banning system (mostly tnx to guru3)
truelight
parents: 835
diff changeset
   133
	if(!strcmp(grp->name, "newgrf") || !strcmp(grp->name, "servers") || !strcmp(grp->name, "bans") )
705
e213445d82ec (svn r1157) Enhanced the config file (openttd.cfg) to use another section type. "List sections" as opposed to "variable sections" contain a list of values, separated by a new line. This is now used for the [newgrf] group. You have to edit each line in this section from e.g. "0 = firstset.grf" to only "firstset.grf".
dominik
parents: 690
diff changeset
   134
		grp->type = IGT_LIST;
e213445d82ec (svn r1157) Enhanced the config file (openttd.cfg) to use another section type. "List sections" as opposed to "variable sections" contain a list of values, separated by a new line. This is now used for the [newgrf] group. You have to edit each line in this section from e.g. "0 = firstset.grf" to only "firstset.grf".
dominik
parents: 690
diff changeset
   135
	else
e213445d82ec (svn r1157) Enhanced the config file (openttd.cfg) to use another section type. "List sections" as opposed to "variable sections" contain a list of values, separated by a new line. This is now used for the [newgrf] group. You have to edit each line in this section from e.g. "0 = firstset.grf" to only "firstset.grf".
dominik
parents: 690
diff changeset
   136
		grp->type = IGT_VARIABLES;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   137
	grp->next = NULL;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   138
	grp->item = NULL;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   139
	grp->comment = NULL;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   140
	grp->last_item = &grp->item;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   141
	*ini->last_group = grp;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   142
	ini->last_group = &grp->next;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   143
	return grp;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   144
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   145
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   146
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
   147
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   148
	IniItem *item = pool_alloc(&group->ini->pool, sizeof(IniItem));
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   149
	item->name = pool_strdup(&group->ini->pool, name, len);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   150
	item->next = NULL;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   151
	item->comment = NULL;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   152
	item->value = NULL;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   153
	*group->last_item = item;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   154
	group->last_item = &item->next;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   155
	return item;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   156
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   157
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   158
// load an ini file into the "abstract" format
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   159
static IniFile *ini_load(const char *filename)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   160
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   161
	char buffer[1024], c, *s, *t, *e;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   162
	FILE *in;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   163
	IniFile *ini;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   164
	IniGroup *group = NULL;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   165
	IniItem *item;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   166
1329
a8a0d60b0a8e (svn r1833) byte -> char transition: the rest
tron
parents: 1317
diff changeset
   167
	char *comment = NULL;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   168
	uint comment_size = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   169
	uint comment_alloc = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   170
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   171
	ini = ini_alloc();
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
	in = fopen(filename, "r");
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   174
	if (in == NULL) return ini;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   175
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   176
	// for each line in the file
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   177
	while (fgets(buffer, sizeof(buffer), in)) {
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 188
diff changeset
   178
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   179
		// trim whitespace from the left side
759
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 738
diff changeset
   180
		for(s=buffer; s[0] == ' ' || s[0] == '\t'; s++);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   181
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   182
		// trim whitespace from right side.
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   183
		e = s + strlen(s);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   184
		while (e > s && ((c=e[-1]) == '\n' || c == '\r' || c == ' ' || c == '\t')) e--;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   185
		*e = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   186
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   187
		// skip comments and empty lines
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   188
		if (*s == '#' || *s == 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   189
			uint ns = comment_size + (e - s + 1);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   190
			uint a = comment_alloc;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   191
			uint pos;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   192
			// add to comment
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   193
			if (ns > a) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   194
				a = max(a, 128);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   195
				do a*=2; while (a < ns);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   196
				comment = realloc(comment, comment_alloc = a);
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
			pos = comment_size;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   199
			comment_size += (e - s + 1);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   200
			comment[pos + e - s] = '\n'; // comment newline
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   201
			memcpy(comment + pos, s, e - s); // copy comment contents
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   202
			continue;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   203
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   204
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   205
		// it's a group?
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   206
		if (s[0] == '[') {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   207
			if (e[-1] != ']')
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   208
				ShowInfoF("ini: invalid group name '%s'\n", buffer);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   209
			else
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   210
				e--;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   211
			s++; // skip [
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   212
			group = ini_group_alloc(ini, s, e - s);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   213
			if (comment_size) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   214
				group->comment = pool_strdup(&ini->pool, comment, comment_size);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   215
				comment_size = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   216
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   217
		} else if (group) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   218
			// find end of keyname
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   219
			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
   220
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   221
			// it's an item in an existing group
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   222
			item = ini_item_alloc(group, s, t-s);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   223
			if (comment_size) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   224
				item->comment = pool_strdup(&ini->pool, comment, comment_size);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   225
				comment_size = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   226
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   227
705
e213445d82ec (svn r1157) Enhanced the config file (openttd.cfg) to use another section type. "List sections" as opposed to "variable sections" contain a list of values, separated by a new line. This is now used for the [newgrf] group. You have to edit each line in this section from e.g. "0 = firstset.grf" to only "firstset.grf".
dominik
parents: 690
diff changeset
   228
			// for list items, the name and value are the same:
e213445d82ec (svn r1157) Enhanced the config file (openttd.cfg) to use another section type. "List sections" as opposed to "variable sections" contain a list of values, separated by a new line. This is now used for the [newgrf] group. You have to edit each line in this section from e.g. "0 = firstset.grf" to only "firstset.grf".
dominik
parents: 690
diff changeset
   229
			if( group->type == IGT_LIST ) {
e213445d82ec (svn r1157) Enhanced the config file (openttd.cfg) to use another section type. "List sections" as opposed to "variable sections" contain a list of values, separated by a new line. This is now used for the [newgrf] group. You have to edit each line in this section from e.g. "0 = firstset.grf" to only "firstset.grf".
dominik
parents: 690
diff changeset
   230
				item->value = item->name;
e213445d82ec (svn r1157) Enhanced the config file (openttd.cfg) to use another section type. "List sections" as opposed to "variable sections" contain a list of values, separated by a new line. This is now used for the [newgrf] group. You have to edit each line in this section from e.g. "0 = firstset.grf" to only "firstset.grf".
dominik
parents: 690
diff changeset
   231
				continue;
e213445d82ec (svn r1157) Enhanced the config file (openttd.cfg) to use another section type. "List sections" as opposed to "variable sections" contain a list of values, separated by a new line. This is now used for the [newgrf] group. You have to edit each line in this section from e.g. "0 = firstset.grf" to only "firstset.grf".
dominik
parents: 690
diff changeset
   232
			}
e213445d82ec (svn r1157) Enhanced the config file (openttd.cfg) to use another section type. "List sections" as opposed to "variable sections" contain a list of values, separated by a new line. This is now used for the [newgrf] group. You have to edit each line in this section from e.g. "0 = firstset.grf" to only "firstset.grf".
dominik
parents: 690
diff changeset
   233
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   234
			// find start of parameter
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   235
			while (*t == '=' || *t == ' ' || *t == '\t') t++;
759
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 738
diff changeset
   236
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 738
diff changeset
   237
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 738
diff changeset
   238
			// remove starting quotation marks
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 738
diff changeset
   239
			if(*t=='\"') t++;
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 738
diff changeset
   240
			// remove ending quotation marks
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 738
diff changeset
   241
			e = t + strlen(t);
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 738
diff changeset
   242
			if(e>t && e[-1] =='\"') e--;
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 738
diff changeset
   243
			*e = 0;
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 738
diff changeset
   244
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   245
			item->value = pool_strdup(&ini->pool, t, e - t);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   246
		} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   247
			// it's an orphan item
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   248
			ShowInfoF("ini: '%s' outside of group\n", buffer);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   249
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   250
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   251
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   252
	if (comment_size) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   253
		ini->comment = pool_strdup(&ini->pool, comment, comment_size);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   254
		comment_size = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   255
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   256
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   257
	free(comment);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   258
	fclose(in);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   259
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   260
	return ini;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   261
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   262
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   263
// lookup a group or make a new one
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   264
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
   265
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   266
	IniGroup *group;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   267
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   268
	if (len == -1) len = strlen(name);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   269
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   270
	// does it exist already?
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   271
	for(group = ini->group; group; group = group->next)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   272
		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
   273
			return group;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   274
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   275
	// otherwise make a new one
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   276
	group = ini_group_alloc(ini, name, len);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   277
	group->comment = pool_strdup(&ini->pool, "\n", 1);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   278
	return group;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   279
}
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
// lookup an item or make a new one
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   282
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
   283
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   284
	IniItem *item;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   285
	uint len = strlen(name);
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
	for(item = group->item; item; item = item->next)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   288
		if (!strcmp(item->name, name))
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   289
			return item;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 188
diff changeset
   290
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   291
	if (!create) return NULL;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   292
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   293
	// otherwise make a new one
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   294
	item = ini_item_alloc(group, name, len);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   295
	return item;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   296
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   297
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   298
// save ini file from the "abstract" format.
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   299
static bool ini_save(const char *filename, IniFile *ini)
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
	FILE *f;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   302
	IniGroup *group;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   303
	IniItem *item;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 188
diff changeset
   304
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   305
	f = fopen(filename, "w");
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   306
	if (f == NULL) return false;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   307
2919
5a867896b255 (svn r3475) - Fix: you couldn't remove an item from a list-type of config ingame from the configuration file. Whatever you did, upon restart of OpenTTD those items were still there. To fix this we initialize the first item to NULL in SaveList as it is rebuilt anyways fully.
Darkvater
parents: 2916
diff changeset
   308
	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
   309
		if (group->comment) fputs(group->comment, f);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   310
		fprintf(f, "[%s]\n", group->name);
2919
5a867896b255 (svn r3475) - Fix: you couldn't remove an item from a list-type of config ingame from the configuration file. Whatever you did, upon restart of OpenTTD those items were still there. To fix this we initialize the first item to NULL in SaveList as it is rebuilt anyways fully.
Darkvater
parents: 2916
diff changeset
   311
		for (item = group->item; item != NULL; item = item->next) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   312
			if (item->comment) fputs(item->comment, f);
705
e213445d82ec (svn r1157) Enhanced the config file (openttd.cfg) to use another section type. "List sections" as opposed to "variable sections" contain a list of values, separated by a new line. This is now used for the [newgrf] group. You have to edit each line in this section from e.g. "0 = firstset.grf" to only "firstset.grf".
dominik
parents: 690
diff changeset
   313
			if(group->type==IGT_LIST)
e213445d82ec (svn r1157) Enhanced the config file (openttd.cfg) to use another section type. "List sections" as opposed to "variable sections" contain a list of values, separated by a new line. This is now used for the [newgrf] group. You have to edit each line in this section from e.g. "0 = firstset.grf" to only "firstset.grf".
dominik
parents: 690
diff changeset
   314
				fprintf(f, "%s\n", item->value ? item->value : "");
e213445d82ec (svn r1157) Enhanced the config file (openttd.cfg) to use another section type. "List sections" as opposed to "variable sections" contain a list of values, separated by a new line. This is now used for the [newgrf] group. You have to edit each line in this section from e.g. "0 = firstset.grf" to only "firstset.grf".
dominik
parents: 690
diff changeset
   315
			else
e213445d82ec (svn r1157) Enhanced the config file (openttd.cfg) to use another section type. "List sections" as opposed to "variable sections" contain a list of values, separated by a new line. This is now used for the [newgrf] group. You have to edit each line in this section from e.g. "0 = firstset.grf" to only "firstset.grf".
dominik
parents: 690
diff changeset
   316
				fprintf(f, "%s = %s\n", item->name, item->value ? item->value : "");
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   317
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   318
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   319
	if (ini->comment) fputs(ini->comment, f);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   320
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   321
	fclose(f);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   322
	return true;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   323
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   324
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   325
static void ini_free(IniFile *ini)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   326
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   327
	pool_free(&ini->pool);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   328
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   329
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   330
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
   331
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   332
	const char *s;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   333
	int idx;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   334
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   335
	if (onelen == -1) onelen = strlen(one);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   336
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   337
	// check if it's an integer
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   338
	if (*one >= '0' && *one <= '9')
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   339
		return strtoul(one, NULL, 0);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 188
diff changeset
   340
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   341
	idx = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   342
	for(;;) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   343
		// find end of item
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   344
		s = many;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   345
		while (*s != '|' && *s != 0) s++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   346
		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
   347
		if (*s == 0) return -1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   348
		many = s + 1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   349
		idx++;
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
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   352
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   353
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
   354
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   355
	const char *s;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   356
	int r;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   357
	uint32 res = 0;
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
	for(;;) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   360
		// skip "whitespace"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   361
		while (*str == ' ' || *str == '\t' || *str == '|') str++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   362
		if (*str == 0) break;
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
		s = str;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   365
		while (*s != 0 && *s != ' ' && *s != '\t' && *s != '|') s++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   366
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   367
		r = lookup_oneofmany(many, str, s - str);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   368
		if (r == -1) return (uint32)-1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   369
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   370
		res |= (1 << r);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   371
		if (*s == 0) break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   372
		str = s + 1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   373
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   374
	return res;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   375
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   376
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   377
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
   378
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   379
	int n = 0, v;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   380
	char *end;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   381
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   382
	for(;;) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   383
		v = strtol(p, &end, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   384
		if (p == end || n == maxitems) return -1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   385
		p = end;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   386
		items[n++] = v;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   387
		if (*p == 0) break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   388
		if (*p != ',') return -1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   389
		p++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   390
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   391
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   392
	return n;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   393
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   394
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   395
static bool load_intlist(const char *str, void *array, int nelems, int type)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   396
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   397
	int items[64];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   398
	int i,nitems;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 188
diff changeset
   399
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   400
	if (str == NULL) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   401
		memset(items, 0, sizeof(items));
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   402
		nitems = nelems;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   403
	} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   404
		nitems = parse_intlist(str, items, lengthof(items));
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   405
		if (nitems != nelems)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   406
			return false;
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
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   409
	switch(type) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   410
	case SDT_INT8 >> 4:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   411
	case SDT_UINT8 >> 4:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   412
		for(i=0; i!=nitems; i++) ((byte*)array)[i] = items[i];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   413
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   414
	case SDT_INT16 >> 4:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   415
	case SDT_UINT16 >> 4:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   416
		for(i=0; i!=nitems; i++) ((uint16*)array)[i] = items[i];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   417
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   418
	case SDT_INT32 >> 4:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   419
	case SDT_UINT32 >> 4:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   420
		for(i=0; i!=nitems; i++) ((uint32*)array)[i] = items[i];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   421
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   422
	default:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   423
		NOT_REACHED();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   424
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   425
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   426
	return true;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   427
}
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
static void make_intlist(char *buf, void *array, int nelems, int type)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   430
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   431
	int i, v = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   432
	byte *p = (byte*)array;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   433
	for(i=0; i!=nelems; i++) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   434
		switch(type) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   435
		case SDT_INT8 >> 4: v = *(int8*)p; p += 1; break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   436
		case SDT_UINT8 >> 4:v = *(byte*)p; p += 1; break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   437
		case SDT_INT16 >> 4:v = *(int16*)p; p += 2; break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   438
		case SDT_UINT16 >> 4:v = *(uint16*)p; p += 2; break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   439
		case SDT_INT32 >> 4:v = *(int32*)p; p += 4; break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   440
		case SDT_UINT32 >> 4:v = *(uint32*)p; p += 4; break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   441
		default: NOT_REACHED();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   442
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   443
		buf += sprintf(buf, i ? ",%d" : "%d", v);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   444
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   445
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   446
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   447
static void make_oneofmany(char *buf, const char *many, int i)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   448
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   449
	int orig_i = i;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   450
	char c;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   451
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   452
	while (--i >= 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   453
		do {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   454
			many++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   455
			if (many[-1] == 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   456
				sprintf(buf, "%d", orig_i);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   457
				return;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   458
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   459
		} while (many[-1] != '|');
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   460
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   461
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   462
	// copy until | or 0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   463
	while ((c=*many++) != 0 && c != '|')
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   464
		*buf++ = c;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   465
	*buf = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   466
}
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
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
   469
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   470
	const char *start;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   471
	int i = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   472
	bool init = true;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   473
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   474
	do {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   475
		start = many;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   476
		while (*many != 0 && *many != '|') many++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   477
		if (x & 1) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   478
			if (!init) *buf++ = '|';
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   479
			init = false;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   480
			if (start == many) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   481
				buf += sprintf(buf, "%d", i);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   482
			} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   483
				memcpy(buf, start, many - start);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   484
				buf += many - start;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   485
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   486
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   487
		if (*many == '|') many++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   488
	} while (++i, x>>=1);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   489
	*buf = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   490
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   491
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
   492
static const void *string_to_val(const SettingDesc *desc, const char *str)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   493
{
2923
272d1b0962bc (svn r3479) -Fix: fixed warnings on 64bit platforms (anyway, most 64bit platforms)
truelight
parents: 2919
diff changeset
   494
	unsigned long val;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   495
	char *end;
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
	switch(desc->flags & 0xF) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   498
	case SDT_INTX:
1688
787400219027 (svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents: 1643
diff changeset
   499
		val = strtoul(str, &end, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   500
		if (*end != 0) ShowInfoF("ini: trailing characters at end of setting '%s'", desc->name);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   501
		return (void*)val;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   502
	case SDT_ONEOFMANY: {
2923
272d1b0962bc (svn r3479) -Fix: fixed warnings on 64bit platforms (anyway, most 64bit platforms)
truelight
parents: 2919
diff changeset
   503
		long r = lookup_oneofmany((const char*)desc->b, str, -1);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   504
		if (r != -1) return (void*)r;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   505
		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
   506
		return 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   507
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   508
	case SDT_MANYOFMANY: {
2923
272d1b0962bc (svn r3479) -Fix: fixed warnings on 64bit platforms (anyway, most 64bit platforms)
truelight
parents: 2919
diff changeset
   509
		unsigned long r = lookup_manyofmany(desc->b, str);
272d1b0962bc (svn r3479) -Fix: fixed warnings on 64bit platforms (anyway, most 64bit platforms)
truelight
parents: 2919
diff changeset
   510
		if (r != (unsigned long)-1) return (void*)r;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   511
		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
   512
		return 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   513
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   514
	case SDT_BOOLX:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   515
		if (!strcmp(str, "true") || !strcmp(str, "on") || !strcmp(str, "1"))
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   516
			return (void*)true;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   517
		if (!strcmp(str, "false") || !strcmp(str, "off") || !strcmp(str, "0"))
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   518
			return (void*)false;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   519
		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
   520
		break;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 188
diff changeset
   521
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   522
	case SDT_STRING:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   523
	case SDT_STRINGBUF:
759
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 738
diff changeset
   524
	case SDT_STRINGQUOT:
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   525
	case SDT_INTLIST:
2307
63e18261a7e7 (svn r2831) Fix some potential and real buffer overflows
tron
parents: 2306
diff changeset
   526
	case SDT_CHAR:
1010
17470a8e5eb7 (svn r1509) Const correctness and add static where appropriate while touching the lines anyway
tron
parents: 998
diff changeset
   527
		return str;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   528
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   529
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   530
	return NULL;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   531
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   532
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   533
static void load_setting_desc(IniFile *ini, const SettingDesc *desc, const void *grpname)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   534
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   535
	IniGroup *group_def = ini_getgroup(ini, grpname, -1), *group;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   536
	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
   537
	const void *p;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   538
	void *ptr;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   539
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   540
	for (;desc->name;desc++) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   541
		// group override?
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   542
		const char *s = strchr(desc->name, '.');
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   543
		if (s) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   544
			group = ini_getgroup(ini, desc->name, s - desc->name);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   545
			s++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   546
		} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   547
			s = desc->name;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   548
			group = group_def;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   549
		}
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 188
diff changeset
   550
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   551
		item = ini_getitem(group, s, false);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   552
		if (!item) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   553
			p = desc->def;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   554
		} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   555
			p = string_to_val(desc, item->value);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   556
		}
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 188
diff changeset
   557
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   558
		// get ptr to array
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   559
		ptr = desc->ptr;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   560
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   561
		switch(desc->flags & 0xF) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   562
		// all these are stored in the same way
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   563
		case SDT_INTX:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   564
		case SDT_ONEOFMANY:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   565
		case SDT_MANYOFMANY:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   566
		case SDT_BOOLX:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   567
			switch(desc->flags >> 4 & 7) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   568
			case SDT_INT8 >> 4:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   569
			case SDT_UINT8 >> 4:
2923
272d1b0962bc (svn r3479) -Fix: fixed warnings on 64bit platforms (anyway, most 64bit platforms)
truelight
parents: 2919
diff changeset
   570
				*(byte*)ptr = (byte)(unsigned long)p;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   571
				break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   572
			case SDT_INT16 >> 4:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   573
			case SDT_UINT16 >> 4:
2923
272d1b0962bc (svn r3479) -Fix: fixed warnings on 64bit platforms (anyway, most 64bit platforms)
truelight
parents: 2919
diff changeset
   574
				*(uint16*)ptr = (uint16)(unsigned long)p;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   575
				break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   576
			case SDT_INT32 >> 4:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   577
			case SDT_UINT32 >> 4:
2923
272d1b0962bc (svn r3479) -Fix: fixed warnings on 64bit platforms (anyway, most 64bit platforms)
truelight
parents: 2919
diff changeset
   578
				*(uint32*)ptr = (uint32)(unsigned long)p;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   579
				break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   580
			default:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   581
				NOT_REACHED();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   582
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   583
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   584
		case SDT_STRING:
1104
33de58d78c02 (svn r1605) Remove redundant if
tron
parents: 1093
diff changeset
   585
			free(*(char**)ptr);
1010
17470a8e5eb7 (svn r1509) Const correctness and add static where appropriate while touching the lines anyway
tron
parents: 998
diff changeset
   586
			*(char**)ptr = strdup((const char*)p);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   587
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   588
		case SDT_STRINGBUF:
759
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 738
diff changeset
   589
		case SDT_STRINGQUOT:
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   590
			if (p) ttd_strlcpy((char*)ptr, p, desc->flags >> 16);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   591
			break;
2307
63e18261a7e7 (svn r2831) Fix some potential and real buffer overflows
tron
parents: 2306
diff changeset
   592
63e18261a7e7 (svn r2831) Fix some potential and real buffer overflows
tron
parents: 2306
diff changeset
   593
		case SDT_CHAR:
63e18261a7e7 (svn r2831) Fix some potential and real buffer overflows
tron
parents: 2306
diff changeset
   594
			*(char*)ptr = *(char*)p;
63e18261a7e7 (svn r2831) Fix some potential and real buffer overflows
tron
parents: 2306
diff changeset
   595
			break;
63e18261a7e7 (svn r2831) Fix some potential and real buffer overflows
tron
parents: 2306
diff changeset
   596
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   597
		case SDT_INTLIST: {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   598
			if (!load_intlist(p, ptr, desc->flags >> 16, desc->flags >> 4 & 7))
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   599
				ShowInfoF("ini: error in array '%s'", desc->name);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   600
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   601
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   602
		default:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   603
			NOT_REACHED();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   604
		}
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 188
diff changeset
   605
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   606
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   607
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   608
static void save_setting_desc(IniFile *ini, const SettingDesc *desc, const void *grpname)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   609
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   610
	IniGroup *group_def = NULL, *group;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   611
	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
   612
	const void *p;
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
   613
	void *ptr;
1688
787400219027 (svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents: 1643
diff changeset
   614
	uint32 i = 0;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   615
	char buf[512]; // setting buffer
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   616
	const char *s;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   617
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   618
	for (;desc->name;desc++) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   619
		if (desc->flags & SDT_NOSAVE)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   620
			continue;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 188
diff changeset
   621
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   622
		// group override?
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   623
		s = strchr(desc->name, '.');
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   624
		if (s) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   625
			group = ini_getgroup(ini, desc->name, s - desc->name);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   626
			s++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   627
		} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   628
			if (group_def == NULL)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   629
				group_def = ini_getgroup(ini, grpname, -1);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   630
			s = desc->name;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   631
			group = group_def;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   632
		}
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 188
diff changeset
   633
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   634
		item = ini_getitem(group, s, true);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   635
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   636
		// get ptr to array
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   637
		ptr = desc->ptr;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 188
diff changeset
   638
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   639
		if (item->value != NULL) {
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 188
diff changeset
   640
			// check if the value is the same as the old value
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   641
			p = string_to_val(desc, item->value);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   642
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   643
			switch(desc->flags & 0xF) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   644
			case SDT_INTX:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   645
			case SDT_ONEOFMANY:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   646
			case SDT_MANYOFMANY:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   647
			case SDT_BOOLX:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   648
				switch(desc->flags >> 4 & 7) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   649
				case SDT_INT8 >> 4:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   650
				case SDT_UINT8 >> 4:
2923
272d1b0962bc (svn r3479) -Fix: fixed warnings on 64bit platforms (anyway, most 64bit platforms)
truelight
parents: 2919
diff changeset
   651
					if (*(byte*)ptr == (byte)(unsigned long)p)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   652
						continue;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   653
					break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   654
				case SDT_INT16 >> 4:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   655
				case SDT_UINT16 >> 4:
2923
272d1b0962bc (svn r3479) -Fix: fixed warnings on 64bit platforms (anyway, most 64bit platforms)
truelight
parents: 2919
diff changeset
   656
					if (*(uint16*)ptr == (uint16)(unsigned long)p)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   657
						continue;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   658
					break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   659
				case SDT_INT32 >> 4:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   660
				case SDT_UINT32 >> 4:
2923
272d1b0962bc (svn r3479) -Fix: fixed warnings on 64bit platforms (anyway, most 64bit platforms)
truelight
parents: 2919
diff changeset
   661
					if (*(uint32*)ptr == (uint32)(unsigned long)p)
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 188
diff changeset
   662
						continue;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   663
					break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   664
				default:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   665
					NOT_REACHED();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   666
				}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   667
				break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   668
			case SDT_STRING:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   669
				assert(0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   670
				break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   671
			case SDT_INTLIST:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   672
				// assume intlist is always changed.
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   673
				break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   674
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   675
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   676
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   677
		switch(desc->flags & 0xF) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   678
		case SDT_INTX:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   679
		case SDT_ONEOFMANY:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   680
		case SDT_MANYOFMANY:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   681
		case SDT_BOOLX:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   682
			switch(desc->flags >> 4 & 7) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   683
			case SDT_INT8 >> 4: i = *(int8*)ptr; break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   684
			case SDT_UINT8 >> 4:i = *(byte*)ptr; break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   685
			case SDT_INT16 >> 4:i = *(int16*)ptr; break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   686
			case SDT_UINT16 >> 4:i = *(uint16*)ptr; break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   687
			case SDT_INT32 >> 4:i = *(int32*)ptr; break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   688
			case SDT_UINT32 >> 4:i = *(uint32*)ptr; break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   689
			default:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   690
				NOT_REACHED();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   691
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   692
			switch(desc->flags & 0xF) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   693
			case SDT_INTX:
1688
787400219027 (svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents: 1643
diff changeset
   694
				sprintf(buf, "%u", i);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   695
				break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   696
			case SDT_ONEOFMANY:
1010
17470a8e5eb7 (svn r1509) Const correctness and add static where appropriate while touching the lines anyway
tron
parents: 998
diff changeset
   697
				make_oneofmany(buf, (const char*)desc->b, i);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   698
				break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   699
			case SDT_MANYOFMANY:
1010
17470a8e5eb7 (svn r1509) Const correctness and add static where appropriate while touching the lines anyway
tron
parents: 998
diff changeset
   700
				make_manyofmany(buf, (const char*)desc->b, i);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   701
				break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   702
			case SDT_BOOLX:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   703
				strcpy(buf, i ? "true" : "false");
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   704
				break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   705
			default:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   706
				NOT_REACHED();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   707
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   708
			break;
759
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 738
diff changeset
   709
		case SDT_STRINGQUOT:
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 738
diff changeset
   710
			sprintf(buf, "\"%s\"", (char*)ptr);
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 738
diff changeset
   711
			break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   712
		case SDT_STRINGBUF:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   713
			strcpy(buf, (char*)ptr);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   714
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   715
		case SDT_STRING:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   716
			strcpy(buf, *(char**)ptr);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   717
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   718
		case SDT_INTLIST:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   719
			make_intlist(buf, ptr, desc->flags >> 16, desc->flags >> 4 & 7);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   720
			break;
2307
63e18261a7e7 (svn r2831) Fix some potential and real buffer overflows
tron
parents: 2306
diff changeset
   721
63e18261a7e7 (svn r2831) Fix some potential and real buffer overflows
tron
parents: 2306
diff changeset
   722
		case SDT_CHAR:
63e18261a7e7 (svn r2831) Fix some potential and real buffer overflows
tron
parents: 2306
diff changeset
   723
			sprintf(buf, "\"%c\"", *(char*)ptr);
63e18261a7e7 (svn r2831) Fix some potential and real buffer overflows
tron
parents: 2306
diff changeset
   724
			break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   725
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   726
		// the value is different, that means we have to write it to the ini
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   727
		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
   728
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   729
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   730
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   731
//***************************
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   732
// TTD specific INI stuff
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   733
//***************************
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   734
1584
aa7fe51c4368 (svn r2088) - Fix: [ 1155158 ] Make extmidi command a config option in addition to the compile-time MIDI switch. Patch by macbaine.
pasky
parents: 1500
diff changeset
   735
#ifndef EXTERNAL_PLAYER
aa7fe51c4368 (svn r2088) - Fix: [ 1155158 ] Make extmidi command a config option in addition to the compile-time MIDI switch. Patch by macbaine.
pasky
parents: 1500
diff changeset
   736
#define EXTERNAL_PLAYER "timidity"
aa7fe51c4368 (svn r2088) - Fix: [ 1155158 ] Make extmidi command a config option in addition to the compile-time MIDI switch. Patch by macbaine.
pasky
parents: 1500
diff changeset
   737
#endif
aa7fe51c4368 (svn r2088) - Fix: [ 1155158 ] Make extmidi command a config option in addition to the compile-time MIDI switch. Patch by macbaine.
pasky
parents: 1500
diff changeset
   738
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   739
static const SettingDesc music_settings[] = {
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   740
	{"playlist",	SDT_UINT8,	(void*)0,			&msf.playlist, NULL},
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   741
	{"music_vol", SDT_UINT8,	(void*)128,		&msf.music_vol, NULL},
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   742
	{"effect_vol",SDT_UINT8,	(void*)128,		&msf.effect_vol, NULL},
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   743
	{"custom_1",	SDT_INTLIST | SDT_UINT8 | lengthof(msf.custom_1) << 16, NULL, &msf.custom_1, NULL},
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   744
	{"custom_2",	SDT_INTLIST | SDT_UINT8 | lengthof(msf.custom_2) << 16, NULL, &msf.custom_2, NULL},
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   745
	{"playing",		SDT_BOOL,		(void*)true,	&msf.btn_down, NULL},
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   746
	{"shuffle",		SDT_BOOL,		(void*)false, &msf.shuffle, NULL},
1584
aa7fe51c4368 (svn r2088) - Fix: [ 1155158 ] Make extmidi command a config option in addition to the compile-time MIDI switch. Patch by macbaine.
pasky
parents: 1500
diff changeset
   747
	{"extmidi",   SDT_STRINGBUF | (lengthof(msf.extmidi)<<16), EXTERNAL_PLAYER, &msf.extmidi, NULL},
179
003096efeb9d (svn r180) -Fix: some more warning fixes for C99 (Tron)
darkvater
parents: 156
diff changeset
   748
	{NULL,				0,					NULL,					NULL,																NULL}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   749
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   750
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   751
static const SettingDesc win32_settings[] = {
179
003096efeb9d (svn r180) -Fix: some more warning fixes for C99 (Tron)
darkvater
parents: 156
diff changeset
   752
	{"display_hz",				SDT_UINT, (void*)0,			&_display_hz,					NULL},
003096efeb9d (svn r180) -Fix: some more warning fixes for C99 (Tron)
darkvater
parents: 156
diff changeset
   753
	{"force_full_redraw", SDT_BOOL, (void*)false, &_force_full_redraw,	NULL},
003096efeb9d (svn r180) -Fix: some more warning fixes for C99 (Tron)
darkvater
parents: 156
diff changeset
   754
	{"fullscreen_bpp",		SDT_UINT, (void*)8,			&_fullscreen_bpp,			NULL},
003096efeb9d (svn r180) -Fix: some more warning fixes for C99 (Tron)
darkvater
parents: 156
diff changeset
   755
	{"double_size",				SDT_BOOL, (void*)false, &_double_size,				NULL},
003096efeb9d (svn r180) -Fix: some more warning fixes for C99 (Tron)
darkvater
parents: 156
diff changeset
   756
	{NULL,								0,				NULL,					NULL,									NULL}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   757
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   758
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   759
static const SettingDesc misc_settings[] = {
395
4c990f33dab7 (svn r587) -newgrf: Rename all /Checkpoint/i tokens to 'Waypoint's. The name actually makes some sense and is also compatible with TTDPatch (pasky).
darkvater
parents: 350
diff changeset
   760
	{"display_opt",				SDT_MANYOFMANY | SDT_UINT8, (void*)(DO_SHOW_TOWN_NAMES|DO_SHOW_STATION_NAMES|DO_SHOW_SIGNS|DO_FULL_ANIMATION|DO_FULL_DETAIL|DO_TRANS_BUILDINGS|DO_WAYPOINTS), &_display_opt, "SHOW_TOWN_NAMES|SHOW_STATION_NAMES|SHOW_SIGNS|FULL_ANIMATION|TRANS_BUILDINGS|FULL_DETAIL|WAYPOINTS"},
1688
787400219027 (svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents: 1643
diff changeset
   761
	{"news_display_opt",	SDT_UINT32,		"0xAAAAAAAA",		&_news_display_opt,		NULL}, // default to all full messages: 10101010101010101010 = 0xAAAAAAAA
787400219027 (svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents: 1643
diff changeset
   762
	{"news_ticker_sound", SDT_BOOL,     (void*)true, &_news_ticker_sound,   NULL},
179
003096efeb9d (svn r180) -Fix: some more warning fixes for C99 (Tron)
darkvater
parents: 156
diff changeset
   763
	{"fullscreen",				SDT_BOOL,			(void*)false, &_fullscreen,					NULL},
003096efeb9d (svn r180) -Fix: some more warning fixes for C99 (Tron)
darkvater
parents: 156
diff changeset
   764
	{"videodriver",				SDT_STRINGBUF | (lengthof(_ini_videodriver)<<16) | SDT_NOSAVE,NULL,			_ini_videodriver,				NULL},
003096efeb9d (svn r180) -Fix: some more warning fixes for C99 (Tron)
darkvater
parents: 156
diff changeset
   765
	{"musicdriver",				SDT_STRINGBUF | (lengthof(_ini_musicdriver)<<16) | SDT_NOSAVE,NULL,			_ini_musicdriver,				NULL},
003096efeb9d (svn r180) -Fix: some more warning fixes for C99 (Tron)
darkvater
parents: 156
diff changeset
   766
	{"sounddriver",				SDT_STRINGBUF | (lengthof(_ini_sounddriver)<<16) | SDT_NOSAVE,NULL,			_ini_sounddriver,				NULL},
003096efeb9d (svn r180) -Fix: some more warning fixes for C99 (Tron)
darkvater
parents: 156
diff changeset
   767
	{"language",					SDT_STRINGBUF | lengthof(_dynlang.curr_file)<<16,							NULL,			_dynlang.curr_file,			NULL},
003096efeb9d (svn r180) -Fix: some more warning fixes for C99 (Tron)
darkvater
parents: 156
diff changeset
   768
	{"resolution",				SDT_UINT16 | SDT_INTLIST | lengthof(_cur_resolution) << 16,		"640,480",_cur_resolution,				NULL},
003096efeb9d (svn r180) -Fix: some more warning fixes for C99 (Tron)
darkvater
parents: 156
diff changeset
   769
	{"screenshot_format", SDT_STRINGBUF | (lengthof(_screenshot_format_name)<<16),			NULL,			_screenshot_format_name,NULL},
003096efeb9d (svn r180) -Fix: some more warning fixes for C99 (Tron)
darkvater
parents: 156
diff changeset
   770
	{"savegame_format",		SDT_STRINGBUF | (lengthof(_savegame_format)<<16),							NULL,			_savegame_format,				NULL},
003096efeb9d (svn r180) -Fix: some more warning fixes for C99 (Tron)
darkvater
parents: 156
diff changeset
   771
	{"rightclick_emulate",SDT_BOOL,			(void*)false, &_rightclick_emulate, NULL},
003096efeb9d (svn r180) -Fix: some more warning fixes for C99 (Tron)
darkvater
parents: 156
diff changeset
   772
	{NULL,								0,						NULL,					NULL,									NULL}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   773
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   774
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   775
#ifdef ENABLE_NETWORK
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   776
static const SettingDesc network_settings[] = {
641
8e3b3faa9617 (svn r1074) Fix: server_bind_ip was set to 255.255.255.255 by default
dominik
parents: 629
diff changeset
   777
	{"sync_freq",				SDT_UINT16 | SDT_NOSAVE,	(void*)100,			&_network_sync_freq,		NULL},
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   778
	{"frame_freq",			SDT_UINT8 | SDT_NOSAVE,	(void*)0,			&_network_frame_freq,		NULL},
1727
e5e752c14043 (svn r2231) - Fix: max_join_time pointing to _network_max_join_time is an uint16, so it should have type SDT_UINT16; fix for revision 2106 (thanks peter1138)
Darkvater
parents: 1723
diff changeset
   779
	{"max_join_time",		SDT_UINT16,	(void*)500,	&_network_max_join_time,	NULL},
1602
08783e4287dc (svn r2106) -Fix: improved the network-join algoritm, it is now a bit more stable
truelight
parents: 1584
diff changeset
   780
	{"pause_on_join",		SDT_BOOL, (void*)false, &_network_pause_on_join, NULL},
641
8e3b3faa9617 (svn r1074) Fix: server_bind_ip was set to 255.255.255.255 by default
dominik
parents: 629
diff changeset
   781
	{"server_bind_ip",	SDT_STRINGBUF | (lengthof(_network_server_bind_ip_host) << 16),	"0.0.0.0",	&_network_server_bind_ip_host,	NULL},
8e3b3faa9617 (svn r1074) Fix: server_bind_ip was set to 255.255.255.255 by default
dominik
parents: 629
diff changeset
   782
	{"server_port",			SDT_UINT,	(void*)NETWORK_DEFAULT_PORT,	&_network_server_port,	NULL},
675
b120ec0b3e39 (svn r1113) -Add: [Network] Added the GUI part for server advertising. When you go
truelight
parents: 643
diff changeset
   783
	{"server_advertise",SDT_BOOL, (void*)false, &_network_advertise, NULL},
764
68b398e2b780 (svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents: 759
diff changeset
   784
	{"lan_internet",		SDT_UINT8, (void*)0, &_network_lan_internet, NULL},
641
8e3b3faa9617 (svn r1074) Fix: server_bind_ip was set to 255.255.255.255 by default
dominik
parents: 629
diff changeset
   785
	{"player_name",			SDT_STRINGBUF | (lengthof(_network_player_name) << 16), NULL, &_network_player_name, NULL},
1026
5b2681cad645 (svn r1527) -Add: RCon (Remote Connection). A server can set:
truelight
parents: 1010
diff changeset
   786
	{"server_password",	SDT_STRINGBUF | (lengthof(_network_server_password) << 16), NULL, &_network_server_password, NULL},
5b2681cad645 (svn r1527) -Add: RCon (Remote Connection). A server can set:
truelight
parents: 1010
diff changeset
   787
	{"rcon_password",		SDT_STRINGBUF | (lengthof(_network_rcon_password) << 16), NULL, &_network_rcon_password, NULL},
641
8e3b3faa9617 (svn r1074) Fix: server_bind_ip was set to 255.255.255.255 by default
dominik
parents: 629
diff changeset
   788
	{"server_name",			SDT_STRINGBUF | (lengthof(_network_server_name) << 16), NULL, &_network_server_name, NULL},
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   789
	{"connect_to_ip",		SDT_STRINGBUF | (lengthof(_network_default_ip) << 16), NULL, &_network_default_ip, NULL},
641
8e3b3faa9617 (svn r1074) Fix: server_bind_ip was set to 255.255.255.255 by default
dominik
parents: 629
diff changeset
   790
	{"network_id",			SDT_STRINGBUF | (lengthof(_network_unique_id) << 16), NULL, &_network_unique_id, NULL},
690
9f449a6b133e (svn r1131) -Add: [Network] Autoclean_companies (set it with 'set autoclean_companies on/off').
truelight
parents: 675
diff changeset
   791
	{"autoclean_companies", SDT_BOOL, (void*)false, &_network_autoclean_companies, NULL},
9f449a6b133e (svn r1131) -Add: [Network] Autoclean_companies (set it with 'set autoclean_companies on/off').
truelight
parents: 675
diff changeset
   792
	{"autoclean_unprotected", SDT_UINT8, (void*)12, &_network_autoclean_unprotected, NULL},
9f449a6b133e (svn r1131) -Add: [Network] Autoclean_companies (set it with 'set autoclean_companies on/off').
truelight
parents: 675
diff changeset
   793
	{"autoclean_protected", SDT_UINT8, (void*)36, &_network_autoclean_protected, NULL},
785
e9ca2bcc9c8f (svn r1252) -Add: [Network] With 'set restart_game_date' you can set the date for in
truelight
parents: 774
diff changeset
   794
	{"restart_game_date", SDT_UINT16, (void*)0, &_network_restart_game_date, NULL},
641
8e3b3faa9617 (svn r1074) Fix: server_bind_ip was set to 255.255.255.255 by default
dominik
parents: 629
diff changeset
   795
	{NULL,							0,											NULL,					NULL,										NULL}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   796
};
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   797
#endif /* ENABLE_NETWORK */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   798
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   799
static const SettingDesc debug_settings[] = {
179
003096efeb9d (svn r180) -Fix: some more warning fixes for C99 (Tron)
darkvater
parents: 156
diff changeset
   800
	{"savedump_path",		SDT_STRINGBUF | (lengthof(_savedump_path)<<16) | SDT_NOSAVE, NULL, _savedump_path, NULL},
003096efeb9d (svn r180) -Fix: some more warning fixes for C99 (Tron)
darkvater
parents: 156
diff changeset
   801
	{"savedump_first",	SDT_UINT | SDT_NOSAVE,	0,				&_savedump_first, NULL},
003096efeb9d (svn r180) -Fix: some more warning fixes for C99 (Tron)
darkvater
parents: 156
diff changeset
   802
	{"savedump_freq",		SDT_UINT | SDT_NOSAVE,	(void*)1, &_savedump_freq,	NULL},
003096efeb9d (svn r180) -Fix: some more warning fixes for C99 (Tron)
darkvater
parents: 156
diff changeset
   803
	{"savedump_last",		SDT_UINT | SDT_NOSAVE,	0,				&_savedump_last,	NULL},
003096efeb9d (svn r180) -Fix: some more warning fixes for C99 (Tron)
darkvater
parents: 156
diff changeset
   804
	{NULL,							0,											NULL,			NULL,							NULL}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   805
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   806
1500
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1460
diff changeset
   807
/* The settings showed when opened in the intro-menu. These values also are saved to
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1460
diff changeset
   808
 * openttd.cfg, thus _opt_newgame is used here (not _opt which is used ingame with loaded games!) */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   809
static const SettingDesc gameopt_settings[] = {
1500
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1460
diff changeset
   810
  {"diff_level",  SDT_UINT8,                  (void*)9, &_opt_newgame.diff_level, NULL},
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1460
diff changeset
   811
  {"diff_custom", SDT_INTLIST | SDT_UINT32 | (sizeof(GameDifficulty)/4) << 16, NULL, &_opt_newgame.diff, NULL},
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1460
diff changeset
   812
  {"currency",    SDT_UINT8 | SDT_ONEOFMANY,  (void*)0, &_opt_newgame.currency,   "GBP|USD|EUR|YEN|ATS|BEF|CHF|CZK|DEM|DKK|ESP|FIM|FRF|GRD|HUF|ISK|ITL|NLG|NOK|PLN|ROL|RUR|SEK|custom" },
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1460
diff changeset
   813
  {"distances",   SDT_UINT8 | SDT_ONEOFMANY,  (void*)1, &_opt_newgame.kilometers, "imperial|metric" },
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1460
diff changeset
   814
  {"town_names",  SDT_UINT8 | SDT_ONEOFMANY,  (void*)0, &_opt_newgame.town_name,  "english|french|german|american|latin|silly|swedish|dutch|finnish|polish|slovakish|norwegian|hungarian|austrian|romanian|czech|swiss" },
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1460
diff changeset
   815
  {"landscape",   SDT_UINT8 | SDT_ONEOFMANY,  (void*)0, &_opt_newgame.landscape,  "normal|hilly|desert|candy" },
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1460
diff changeset
   816
  {"autosave",    SDT_UINT8 | SDT_ONEOFMANY,  (void*)1, &_opt_newgame.autosave,   "off|monthly|quarterly|half year|yearly" },
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1460
diff changeset
   817
  {"road_side",   SDT_UINT8 | SDT_ONEOFMANY,  (void*)1, &_opt_newgame.road_side,  "left|right" },
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1460
diff changeset
   818
  {NULL,          0,                          NULL,     NULL,                     NULL}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   819
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   820
2672
ea469d7b34ff (svn r3214) -Feature: openttd.cfg can now set how many autosaves to keep before starting to overwrite old ones
bjarni
parents: 2619
diff changeset
   821
#if !defined(MAX_NUM_AUTOSAVES)
ea469d7b34ff (svn r3214) -Feature: openttd.cfg can now set how many autosaves to keep before starting to overwrite old ones
bjarni
parents: 2619
diff changeset
   822
// no custom default max number of autosaves have been set in the makefile, so we will set the default max to 16
ea469d7b34ff (svn r3214) -Feature: openttd.cfg can now set how many autosaves to keep before starting to overwrite old ones
bjarni
parents: 2619
diff changeset
   823
#define MAX_NUM_AUTOSAVES 16
ea469d7b34ff (svn r3214) -Feature: openttd.cfg can now set how many autosaves to keep before starting to overwrite old ones
bjarni
parents: 2619
diff changeset
   824
#endif
ea469d7b34ff (svn r3214) -Feature: openttd.cfg can now set how many autosaves to keep before starting to overwrite old ones
bjarni
parents: 2619
diff changeset
   825
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   826
// The player-based settings (are not send over the network)
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   827
// Not everything can just be added to this list. For example, service_interval
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   828
//  can not be done, because every client assigns the service_interval value to the
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   829
//  v->service_interval, meaning that every client assigns his value to the interval.
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   830
//  If the setting was player-based, that would mean that vehicles could deside on
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   831
//  different moments that they are heading back to a service depot, causing desyncs
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   832
//  on a massive scale.
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   833
// Short, you can only add settings that does stuff for the screen, GUI, that kind
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   834
//  of stuff.
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   835
static const SettingDesc patch_player_settings[] = {
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   836
	{"vehicle_speed",				SDT_BOOL,		(void*)true,	&_patches.vehicle_speed,				NULL},
179
003096efeb9d (svn r180) -Fix: some more warning fixes for C99 (Tron)
darkvater
parents: 156
diff changeset
   837
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   838
	{"lost_train_days",			SDT_UINT16, (void*)180,		&_patches.lost_train_days,			NULL},
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   839
	{"train_income_warn",		SDT_BOOL,		(void*)true,	&_patches.train_income_warn,		NULL},
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   840
	{"order_review_system", SDT_UINT8,	(void*)2,			&_patches.order_review_system,	NULL},
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 188
diff changeset
   841
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   842
	{"status_long_date",		SDT_BOOL,		(void*)true,	&_patches.status_long_date,			NULL},
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   843
	{"show_finances",				SDT_BOOL,		(void*)true,	&_patches.show_finances,				NULL},
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   844
	{"autoscroll",					SDT_BOOL,		(void*)false,	&_patches.autoscroll,						NULL},
2680
576d9d47df80 (svn r3222) -Feature: Right-Click-Scrolling optionally moves in the opposite direction (Requested by manx)
tron
parents: 2672
diff changeset
   845
	{"reverse_scroll",      SDT_BOOL,   (void*)false, &_patches.reverse_scroll,       NULL},
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   846
	{"errmsg_duration",			SDT_UINT8,	(void*)5,			&_patches.errmsg_duration,			NULL},
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   847
	{"toolbar_pos",					SDT_UINT8,	(void*)0,			&_patches.toolbar_pos,					NULL},
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   848
	{"keep_all_autosave",		SDT_BOOL,		(void*)false, &_patches.keep_all_autosave,		NULL},
643
6f04156241bd (svn r1076) Feature: Patch setting to autosave the game on exit
dominik
parents: 641
diff changeset
   849
	{"autosave_on_exit",		SDT_BOOL,		(void*)false, &_patches.autosave_on_exit,			NULL},
2672
ea469d7b34ff (svn r3214) -Feature: openttd.cfg can now set how many autosaves to keep before starting to overwrite old ones
bjarni
parents: 2619
diff changeset
   850
	{"max_autosave_num",			SDT_UINT8, (void*)MAX_NUM_AUTOSAVES,		&_patches.max_num_autosaves,			NULL},
179
003096efeb9d (svn r180) -Fix: some more warning fixes for C99 (Tron)
darkvater
parents: 156
diff changeset
   851
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   852
	{"bridge_pillars",			SDT_BOOL,		(void*)true,	&_patches.bridge_pillars,				NULL},
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   853
	{"invisible_trees",			SDT_BOOL,		(void*)false, &_patches.invisible_trees,			NULL},
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   854
	{"drag_signals_density",SDT_UINT8,	(void*)4,			&_patches.drag_signals_density, NULL},
58
b9fdcc9b5c90 (svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater
parents: 55
diff changeset
   855
545
6e8767542192 (svn r945) -Fix: [Network] Terraform callback went wrong in merge
truelight
parents: 543
diff changeset
   856
	{"window_snap_radius",  SDT_UINT8,  (void*)10,    &_patches.window_snap_radius,   NULL},
6e8767542192 (svn r945) -Fix: [Network] Terraform callback went wrong in merge
truelight
parents: 543
diff changeset
   857
812
79c99885ad00 (svn r1283) -Add: AutoRenew is now a client-side patch instead of a game-side patch
truelight
parents: 794
diff changeset
   858
	{"autorenew",						SDT_BOOL,		(void*)false,	&_patches.autorenew,						NULL},
79c99885ad00 (svn r1283) -Add: AutoRenew is now a client-side patch instead of a game-side patch
truelight
parents: 794
diff changeset
   859
	{"autorenew_months",		SDT_INT16,	(void*)-6,		&_patches.autorenew_months,			NULL},
79c99885ad00 (svn r1283) -Add: AutoRenew is now a client-side patch instead of a game-side patch
truelight
parents: 794
diff changeset
   860
	{"autorenew_money",			SDT_INT32,	(void*)100000,&_patches.autorenew_money,			NULL},
79c99885ad00 (svn r1283) -Add: AutoRenew is now a client-side patch instead of a game-side patch
truelight
parents: 794
diff changeset
   861
835
a22d6bc16a51 (svn r1312) -Add: Patch which is on by default: population in label of the town
truelight
parents: 812
diff changeset
   862
	{"population_in_label",	SDT_BOOL,		(void*)true,	&_patches.population_in_label,	NULL},
2619
c2f488e400b1 (svn r3157) - Feature: Added patch option to link the terraform toolbar to the rail, road, water and airport toolbars. If enabled, the terraform toolbar will open and close with those toolbars.
peter1138
parents: 2456
diff changeset
   863
	{"link_terraform_toolbar",       SDT_BOOL,   (void*)false, &_patches.link_terraform_toolbar,       NULL},
835
a22d6bc16a51 (svn r1312) -Add: Patch which is on by default: population in label of the town
truelight
parents: 812
diff changeset
   864
179
003096efeb9d (svn r180) -Fix: some more warning fixes for C99 (Tron)
darkvater
parents: 156
diff changeset
   865
	{NULL,									0,					NULL,					NULL,																						NULL}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   866
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   867
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   868
// Non-static, needed in network_server.c
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   869
const SettingDesc patch_settings[] = {
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   870
	{"build_on_slopes",			SDT_BOOL,		(void*)true,	&_patches.build_on_slopes,			NULL},
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   871
	{"mammoth_trains",			SDT_BOOL,		(void*)true,	&_patches.mammoth_trains,				NULL},
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   872
	{"join_stations",				SDT_BOOL,		(void*)true,	&_patches.join_stations,				NULL},
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   873
	{"station_spread",			SDT_UINT8,	(void*)12,		&_patches.station_spread,				NULL},
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   874
	{"full_load_any",				SDT_BOOL,		(void*)true,	&_patches.full_load_any,				NULL},
951
9c58dedb8e5f (svn r1441) Fixed a couple of warnings, and removed a pointless assert
celestar
parents: 930
diff changeset
   875
	{"modified_catchment", 	SDT_BOOL,		(void*)true,	&_patches.modified_catchment,		NULL},
568
6eb7d394fb35 (svn r979) Allow more realistically sized catchment areas
Celestar
parents: 545
diff changeset
   876
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   877
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   878
	{"inflation",						SDT_BOOL,		(void*)true,	&_patches.inflation,						NULL},
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   879
	{"selectgoods",					SDT_BOOL,		(void*)true,	&_patches.selectgoods,					NULL},
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   880
	{"longbridges",					SDT_BOOL,		(void*)true, &_patches.longbridges,					NULL},
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   881
	{"gotodepot",						SDT_BOOL,		(void*)true,	&_patches.gotodepot,						NULL},
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   882
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   883
	{"build_rawmaterial_ind",	SDT_BOOL, (void*)false, &_patches.build_rawmaterial_ind,NULL},
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   884
	{"multiple_industry_per_town",SDT_BOOL, (void*)false, &_patches.multiple_industry_per_town, NULL},
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   885
	{"same_industry_close",	SDT_BOOL,		(void*)false, &_patches.same_industry_close,	NULL},
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   886
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   887
	{"signal_side",					SDT_BOOL,		(void*)true,	&_patches.signal_side,					NULL},
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   888
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   889
	{"new_nonstop",					SDT_BOOL,		(void*)false,	&_patches.new_nonstop,					NULL},
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   890
	{"roadveh_queue",				SDT_BOOL,		(void*)true,	&_patches.roadveh_queue,				NULL},
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   891
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   892
	{"snow_line_height",		SDT_UINT8,	(void*)7,			&_patches.snow_line_height,			NULL},
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   893
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   894
	{"bribe",								SDT_BOOL,		(void*)true,	&_patches.bribe,								NULL},
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   895
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   896
	{"nonuniform_stations",	SDT_BOOL,		(void*)true,	&_patches.nonuniform_stations,	NULL},
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   897
	{"always_small_airport",SDT_BOOL,		(void*)false,	&_patches.always_small_airport,	NULL},
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   898
	{"realistic_acceleration",SDT_BOOL, (void*)false,	&_patches.realistic_acceleration,	NULL},
2456
93041d70867b (svn r2982) Newgrf: Added patch option for wagon speed limits. This is enabled by default.
peter1138
parents: 2450
diff changeset
   899
	{"wagon_speed_limits",  SDT_BOOL,   (void*)true,  &_patches.wagon_speed_limits,   NULL},
1247
01711347f9ac (svn r1751) - Feature: New PathFinder (NPF).
matthijs
parents: 1218
diff changeset
   900
	{"forbid_90_deg",				SDT_BOOL, 	(void*)false, &_patches.forbid_90_deg,					NULL},
545
6e8767542192 (svn r945) -Fix: [Network] Terraform callback went wrong in merge
truelight
parents: 543
diff changeset
   901
	{"improved_load",				SDT_BOOL,		(void*)false,	&_patches.improved_load,				NULL},
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   902
1282
e7a73ee62d2f (svn r1786) -Fix: unitnumber is increased to 16bit, so now you can have up to 5000
truelight
parents: 1271
diff changeset
   903
	{"max_trains",					SDT_UINT16,	(void*)500,		&_patches.max_trains,						NULL},
e7a73ee62d2f (svn r1786) -Fix: unitnumber is increased to 16bit, so now you can have up to 5000
truelight
parents: 1271
diff changeset
   904
	{"max_roadveh",					SDT_UINT16,	(void*)500,		&_patches.max_roadveh,					NULL},
e7a73ee62d2f (svn r1786) -Fix: unitnumber is increased to 16bit, so now you can have up to 5000
truelight
parents: 1271
diff changeset
   905
	{"max_aircraft",				SDT_UINT16,	(void*)200,		&_patches.max_aircraft,					NULL},
e7a73ee62d2f (svn r1786) -Fix: unitnumber is increased to 16bit, so now you can have up to 5000
truelight
parents: 1271
diff changeset
   906
	{"max_ships",						SDT_UINT16,	(void*)300,		&_patches.max_ships,						NULL},
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   907
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   908
	{"servint_ispercent",		SDT_BOOL,		(void*)false,	&_patches.servint_ispercent,		NULL},
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   909
	{"servint_trains",			SDT_UINT16, (void*)150,		&_patches.servint_trains,				NULL},
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   910
	{"servint_roadveh",			SDT_UINT16, (void*)150,		&_patches.servint_roadveh,			NULL},
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   911
	{"servint_ships",				SDT_UINT16, (void*)360,		&_patches.servint_ships,				NULL},
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   912
	{"servint_aircraft",		SDT_UINT16, (void*)100,		&_patches.servint_aircraft,			NULL},
1037
60bb8079eeea (svn r1538) -Feature: [988816] Disable servicing when breakdowns set to none (jaguar7)
darkvater
parents: 1030
diff changeset
   913
	{"no_servicing_if_no_breakdowns", SDT_BOOL, (void*)0, &_patches.no_servicing_if_no_breakdowns, NULL},
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   914
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   915
	{"pf_maxlength",				SDT_UINT16, (void*)512,		&_patches.pf_maxlength,					NULL},
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   916
	{"pf_maxdepth",					SDT_UINT8,	(void*)16,		&_patches.pf_maxdepth,					NULL},
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   917
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   918
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   919
	{"ai_disable_veh_train",SDT_BOOL,		(void*)false, &_patches.ai_disable_veh_train,	NULL},
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   920
	{"ai_disable_veh_roadveh",SDT_BOOL,	(void*)false, &_patches.ai_disable_veh_roadveh,	NULL},
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   921
	{"ai_disable_veh_aircraft",SDT_BOOL,(void*)false, &_patches.ai_disable_veh_aircraft,NULL},
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   922
	{"ai_disable_veh_ship",	SDT_BOOL,		(void*)false, &_patches.ai_disable_veh_ship,	NULL},
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   923
	{"starting_date",				SDT_UINT32, (void*)1950,	&_patches.starting_date,				NULL},
998
d9dc257b8949 (svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents: 960
diff changeset
   924
	{"ending_date",				  SDT_UINT32, (void*)2051,	&_patches.ending_date,				  NULL},
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   925
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   926
	{"colored_news_date",		SDT_UINT32, (void*)2000,	&_patches.colored_news_date,		NULL},
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   927
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   928
	{"extra_dynamite",			SDT_BOOL,		(void*)false, &_patches.extra_dynamite,				NULL},
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   929
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   930
	{"never_expire_vehicles",SDT_BOOL,	(void*)false, &_patches.never_expire_vehicles,NULL},
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   931
	{"extend_vehicle_life",	SDT_UINT8,	(void*)0,			&_patches.extend_vehicle_life,	NULL},
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   932
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   933
	{"auto_euro",						SDT_BOOL,		(void*)true,	&_patches.auto_euro,						NULL},
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   934
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   935
	{"serviceathelipad",		SDT_BOOL,		(void*)true,	&_patches.serviceathelipad,			NULL},
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   936
	{"smooth_economy",			SDT_BOOL,		(void*)true,	&_patches.smooth_economy,				NULL},
930
524b02923ede (svn r1418) -Feature: [1098254] (dis)Allow Shares. Add patch options to allow buying/selling of shares (Hackykid)
darkvater
parents: 898
diff changeset
   937
	{"allow_shares",				SDT_BOOL,		(void*)true,	&_patches.allow_shares,					NULL},
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   938
	{"dist_local_authority",SDT_UINT8,	(void*)20,		&_patches.dist_local_authority, NULL},
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   939
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   940
	{"wait_oneway_signal",	SDT_UINT8,	(void*)15,		&_patches.wait_oneway_signal,		NULL},
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   941
	{"wait_twoway_signal",	SDT_UINT8,	(void*)41,		&_patches.wait_twoway_signal,		NULL},
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   942
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   943
	{"ainew_active",				SDT_BOOL,		(void*)false, &_patches.ainew_active,					NULL},
2682
94ca0b4dc53f (svn r3224) -Add: Allow the NewAI to work in Multiplayer Games (switchable via patch
truelight
parents: 2680
diff changeset
   944
	{"ai_in_multiplayer",		SDT_BOOL,		(void*)false, &_patches.ai_in_multiplayer,		NULL},
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
   945
1218
353a7773bc3c (svn r1722) -Feature: Bigger maps - anyone?
tron
parents: 1104
diff changeset
   946
	{"map_x", SDT_UINT32, (void*)8, &_patches.map_x, NULL},
353a7773bc3c (svn r1722) -Feature: Bigger maps - anyone?
tron
parents: 1104
diff changeset
   947
	{"map_y", SDT_UINT32, (void*)8, &_patches.map_y, NULL},
353a7773bc3c (svn r1722) -Feature: Bigger maps - anyone?
tron
parents: 1104
diff changeset
   948
1271
2b8bfb61ce90 (svn r1775) -Fix: The NPF patch setting was not synced in network.
truelight
parents: 1258
diff changeset
   949
	/* New Path Finding */
2b8bfb61ce90 (svn r1775) -Fix: The NPF patch setting was not synced in network.
truelight
parents: 1258
diff changeset
   950
	{"new_pathfinding_all",	SDT_BOOL,		(void*)false, &_patches.new_pathfinding_all,	NULL},
2b8bfb61ce90 (svn r1775) -Fix: The NPF patch setting was not synced in network.
truelight
parents: 1258
diff changeset
   951
1700
b8ecf0494fdd (svn r2204) - Add: [NPF] NPF now has a maximum number of nodes it will search. The default value is 5000 for now, which is an educated guess. Probably needs some finetuning. Hopefully this "feature" can be removed later on, when more sophisticated means of limiting the pathfinder have been implemented. This should make ships and larger networks playable for now, though.
matthijs
parents: 1688
diff changeset
   952
	/* The maximum number of nodes to search */
b8ecf0494fdd (svn r2204) - Add: [NPF] NPF now has a maximum number of nodes it will search. The default value is 5000 for now, which is an educated guess. Probably needs some finetuning. Hopefully this "feature" can be removed later on, when more sophisticated means of limiting the pathfinder have been implemented. This should make ships and larger networks playable for now, though.
matthijs
parents: 1688
diff changeset
   953
	{"npf_max_search_nodes",   SDT_UINT32, (void*)10000,  &_patches.npf_max_search_nodes,		NULL},
b8ecf0494fdd (svn r2204) - Add: [NPF] NPF now has a maximum number of nodes it will search. The default value is 5000 for now, which is an educated guess. Probably needs some finetuning. Hopefully this "feature" can be removed later on, when more sophisticated means of limiting the pathfinder have been implemented. This should make ships and larger networks playable for now, though.
matthijs
parents: 1688
diff changeset
   954
1271
2b8bfb61ce90 (svn r1775) -Fix: The NPF patch setting was not synced in network.
truelight
parents: 1258
diff changeset
   955
	/* When a red signal is encountered, a small detour can be made around
2b8bfb61ce90 (svn r1775) -Fix: The NPF patch setting was not synced in network.
truelight
parents: 1258
diff changeset
   956
	* it. This specifically occurs when a track is doubled, in which case
2b8bfb61ce90 (svn r1775) -Fix: The NPF patch setting was not synced in network.
truelight
parents: 1258
diff changeset
   957
	* the detour is typically 2 tiles. It is also often used at station
2b8bfb61ce90 (svn r1775) -Fix: The NPF patch setting was not synced in network.
truelight
parents: 1258
diff changeset
   958
	* entrances, when there is a choice of multiple platforms. If we take
2b8bfb61ce90 (svn r1775) -Fix: The NPF patch setting was not synced in network.
truelight
parents: 1258
diff changeset
   959
	* a typical 4 platform station, the detour is 4 tiles. To properly
2b8bfb61ce90 (svn r1775) -Fix: The NPF patch setting was not synced in network.
truelight
parents: 1258
diff changeset
   960
	* support larger stations we increase this value.
2b8bfb61ce90 (svn r1775) -Fix: The NPF patch setting was not synced in network.
truelight
parents: 1258
diff changeset
   961
	* We want to prevent that trains that want to leave at one side of a
2b8bfb61ce90 (svn r1775) -Fix: The NPF patch setting was not synced in network.
truelight
parents: 1258
diff changeset
   962
	* station, leave through the other side, turn around, enter the
2b8bfb61ce90 (svn r1775) -Fix: The NPF patch setting was not synced in network.
truelight
parents: 1258
diff changeset
   963
	* station on another platform and exit the station on the right side
2b8bfb61ce90 (svn r1775) -Fix: The NPF patch setting was not synced in network.
truelight
parents: 1258
diff changeset
   964
	* again, just because the sign at the right side was red. If we take
2b8bfb61ce90 (svn r1775) -Fix: The NPF patch setting was not synced in network.
truelight
parents: 1258
diff changeset
   965
	* a typical 5 length station, this detour is 10 or 11 tiles (not
2b8bfb61ce90 (svn r1775) -Fix: The NPF patch setting was not synced in network.
truelight
parents: 1258
diff changeset
   966
	* sure), so we set the default penalty at 10 (the station tile
1643
d38655053062 (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
   967
	* penalty will further prevent this.
d38655053062 (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
   968
	* We give presignal exits (and combo's) a different (larger) penalty, because we really
d38655053062 (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
   969
	* don't want trains waiting in front of a presignal exit. */
1751
954dd2900ac9 (svn r2255) - Fix: [ 9680363 ] [NPF] Broken buoy handling for ships
matthijs
parents: 1727
diff changeset
   970
	{"npf_rail_firstred_penalty",   SDT_UINT32, (void*)(10 * NPF_TILE_LENGTH),  &_patches.npf_rail_firstred_penalty,    NULL},
954dd2900ac9 (svn r2255) - Fix: [ 9680363 ] [NPF] Broken buoy handling for ships
matthijs
parents: 1727
diff changeset
   971
	{"npf_rail_firstred_exit_penalty", SDT_UINT32, (void*)(100 * NPF_TILE_LENGTH), &_patches.npf_rail_firstred_exit_penalty, NULL},
1459
6c1f01803928 (svn r1963) - Add: [NPF] Penalty for a red signal that is the last signal on the path.
matthijs
parents: 1422
diff changeset
   972
	/* This penalty is for when the last signal before the target is red.
6c1f01803928 (svn r1963) - Add: [NPF] Penalty for a red signal that is the last signal on the path.
matthijs
parents: 1422
diff changeset
   973
	 * This is useful for train stations, where there are multiple
6c1f01803928 (svn r1963) - Add: [NPF] Penalty for a red signal that is the last signal on the path.
matthijs
parents: 1422
diff changeset
   974
	 * platforms to choose from, which lie in different signal blocks.
6c1f01803928 (svn r1963) - Add: [NPF] Penalty for a red signal that is the last signal on the path.
matthijs
parents: 1422
diff changeset
   975
	 * Every target in a occupied signal block (ie an occupied platform)
6c1f01803928 (svn r1963) - Add: [NPF] Penalty for a red signal that is the last signal on the path.
matthijs
parents: 1422
diff changeset
   976
	 * will get this penalty.
6c1f01803928 (svn r1963) - Add: [NPF] Penalty for a red signal that is the last signal on the path.
matthijs
parents: 1422
diff changeset
   977
	 */
1643
d38655053062 (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
   978
	{"npf_rail_lastred_penalty",    SDT_UINT32, (void*)(10 * NPF_TILE_LENGTH),  &_patches.npf_rail_lastred_penalty,		NULL},
1271
2b8bfb61ce90 (svn r1775) -Fix: The NPF patch setting was not synced in network.
truelight
parents: 1258
diff changeset
   979
	/* When a train plans a route over a station tile, this penalty is
2b8bfb61ce90 (svn r1775) -Fix: The NPF patch setting was not synced in network.
truelight
parents: 1258
diff changeset
   980
	* applied. We want that trains plan a route around a typical, 4x5
2b8bfb61ce90 (svn r1775) -Fix: The NPF patch setting was not synced in network.
truelight
parents: 1258
diff changeset
   981
	* station, which means two tiles to the right, and two tiles back to
2b8bfb61ce90 (svn r1775) -Fix: The NPF patch setting was not synced in network.
truelight
parents: 1258
diff changeset
   982
	* the left around it, or 5 tiles of station through it. If we assign
2b8bfb61ce90 (svn r1775) -Fix: The NPF patch setting was not synced in network.
truelight
parents: 1258
diff changeset
   983
	* a penalty of 1 tile for every station tile passed, the route will
2b8bfb61ce90 (svn r1775) -Fix: The NPF patch setting was not synced in network.
truelight
parents: 1258
diff changeset
   984
	* be around it.
2b8bfb61ce90 (svn r1775) -Fix: The NPF patch setting was not synced in network.
truelight
parents: 1258
diff changeset
   985
	*/
1751
954dd2900ac9 (svn r2255) - Fix: [ 9680363 ] [NPF] Broken buoy handling for ships
matthijs
parents: 1727
diff changeset
   986
	{"npf_rail_station_penalty",    SDT_UINT32, (void*)(1 * NPF_TILE_LENGTH),   &_patches.npf_rail_station_penalty,     NULL},
954dd2900ac9 (svn r2255) - Fix: [ 9680363 ] [NPF] Broken buoy handling for ships
matthijs
parents: 1727
diff changeset
   987
	{"npf_rail_slope_penalty",      SDT_UINT32, (void*)(1 * NPF_TILE_LENGTH),   &_patches.npf_rail_slope_penalty,       NULL},
954dd2900ac9 (svn r2255) - Fix: [ 9680363 ] [NPF] Broken buoy handling for ships
matthijs
parents: 1727
diff changeset
   988
	/* This penalty is applied when a train makes a turn. Its value of 1 makes
954dd2900ac9 (svn r2255) - Fix: [ 9680363 ] [NPF] Broken buoy handling for ships
matthijs
parents: 1727
diff changeset
   989
	 * sure that it has a minimal impact on the pathfinding, only when two
954dd2900ac9 (svn r2255) - Fix: [ 9680363 ] [NPF] Broken buoy handling for ships
matthijs
parents: 1727
diff changeset
   990
	 * paths have equal length it will make a difference */
954dd2900ac9 (svn r2255) - Fix: [ 9680363 ] [NPF] Broken buoy handling for ships
matthijs
parents: 1727
diff changeset
   991
	{"npf_rail_curve_penalty",      SDT_UINT32, (void*)(1),                     &_patches.npf_rail_curve_penalty,       NULL},
1777
d328484bd6f2 (svn r2281) - Fix: [ 1115204 ] [NPF] When pressing the goto depot button, trains will now also look behind it if there is no depot in front. If so, the train reverses immediately. This also work anywhere, not just at stations.
matthijs
parents: 1751
diff changeset
   992
	/* Ths penalty is applied when a vehicle reverses inside a depot (doesn't
d328484bd6f2 (svn r2281) - Fix: [ 1115204 ] [NPF] When pressing the goto depot button, trains will now also look behind it if there is no depot in front. If so, the train reverses immediately. This also work anywhere, not just at stations.
matthijs
parents: 1751
diff changeset
   993
	 * apply to ships, as they can just come out the other end). XXX: Is this a
d328484bd6f2 (svn r2281) - Fix: [ 1115204 ] [NPF] When pressing the goto depot button, trains will now also look behind it if there is no depot in front. If so, the train reverses immediately. This also work anywhere, not just at stations.
matthijs
parents: 1751
diff changeset
   994
	 * good value? */
d328484bd6f2 (svn r2281) - Fix: [ 1115204 ] [NPF] When pressing the goto depot button, trains will now also look behind it if there is no depot in front. If so, the train reverses immediately. This also work anywhere, not just at stations.
matthijs
parents: 1751
diff changeset
   995
	{"npf_rail_depot_reverse_penalty", SDT_UINT32, (void*)(NPF_TILE_LENGTH * 50), &_patches.npf_rail_depot_reverse_penalty, NULL},
1751
954dd2900ac9 (svn r2255) - Fix: [ 9680363 ] [NPF] Broken buoy handling for ships
matthijs
parents: 1727
diff changeset
   996
	{"npf_buoy_penalty",            SDT_UINT32, (void*)(2 * NPF_TILE_LENGTH),   &_patches.npf_buoy_penalty,             NULL},
954dd2900ac9 (svn r2255) - Fix: [ 9680363 ] [NPF] Broken buoy handling for ships
matthijs
parents: 1727
diff changeset
   997
	/* This penalty is applied when a ship makes a turn. It is bigger than the
954dd2900ac9 (svn r2255) - Fix: [ 9680363 ] [NPF] Broken buoy handling for ships
matthijs
parents: 1727
diff changeset
   998
	 * rail curve penalty, since ships (realisticly) have more trouble with
954dd2900ac9 (svn r2255) - Fix: [ 9680363 ] [NPF] Broken buoy handling for ships
matthijs
parents: 1727
diff changeset
   999
	 * making turns */
954dd2900ac9 (svn r2255) - Fix: [ 9680363 ] [NPF] Broken buoy handling for ships
matthijs
parents: 1727
diff changeset
  1000
	{"npf_water_curve_penalty",     SDT_UINT32, (void*)(NPF_TILE_LENGTH / 4),   &_patches.npf_water_curve_penalty,      NULL},
1941
b1cb02c0401c (svn r2447) * Add: [NPF] Penalty for road vehicles making turns.
matthijs
parents: 1891
diff changeset
  1001
	/* This is the penalty for road, same as for rail. */
b1cb02c0401c (svn r2447) * Add: [NPF] Penalty for road vehicles making turns.
matthijs
parents: 1891
diff changeset
  1002
	{"npf_road_curve_penalty",      SDT_UINT32, (void*)(1),                     &_patches.npf_road_curve_penalty,       NULL},
2006
324916f22a8a (svn r2514) - Codechange: [NPF] Move the checking of railtype into a funciton IsCompatibleRail().
matthijs
parents: 1941
diff changeset
  1003
	/* This is the penalty for level crossings, for both road and rail vehicles */
324916f22a8a (svn r2514) - Codechange: [NPF] Move the checking of railtype into a funciton IsCompatibleRail().
matthijs
parents: 1941
diff changeset
  1004
 	{"npf_crossing_penalty",        SDT_UINT32, (void*)(3 * NPF_TILE_LENGTH),   &_patches.npf_crossing_penalty,         NULL},
1271
2b8bfb61ce90 (svn r1775) -Fix: The NPF patch setting was not synced in network.
truelight
parents: 1258
diff changeset
  1005
1751
954dd2900ac9 (svn r2255) - Fix: [ 9680363 ] [NPF] Broken buoy handling for ships
matthijs
parents: 1727
diff changeset
  1006
	{NULL,                          0,          NULL,                           NULL,                                   NULL}
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
  1007
};
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
  1008
759
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 738
diff changeset
  1009
static const SettingDesc currency_settings[] = {
2307
63e18261a7e7 (svn r2831) Fix some potential and real buffer overflows
tron
parents: 2306
diff changeset
  1010
	{ "rate",      SDT_UINT16,                                               (void*)1,   &_custom_currency.rate,      NULL },
63e18261a7e7 (svn r2831) Fix some potential and real buffer overflows
tron
parents: 2306
diff changeset
  1011
	{ "separator", SDT_CHAR,                                                 ".",        &_custom_currency.separator, NULL },
63e18261a7e7 (svn r2831) Fix some potential and real buffer overflows
tron
parents: 2306
diff changeset
  1012
	{ "to_euro",   SDT_UINT16,                                               (void*)0,   &_custom_currency.to_euro,   NULL },
63e18261a7e7 (svn r2831) Fix some potential and real buffer overflows
tron
parents: 2306
diff changeset
  1013
	{ "prefix",    SDT_STRINGQUOT | lengthof(_custom_currency.prefix) << 16, NULL,       &_custom_currency.prefix,    NULL },
63e18261a7e7 (svn r2831) Fix some potential and real buffer overflows
tron
parents: 2306
diff changeset
  1014
	{ "suffix",    SDT_STRINGQUOT | lengthof(_custom_currency.suffix) << 16, " credits", &_custom_currency.suffix,    NULL },
2306
3d4efe849dd9 (svn r2830) Move CheckSwitchToEuro() to currency.[ch] and hide the truth about the custom currency behind a #define
tron
parents: 2291
diff changeset
  1015
	{ NULL, 0, NULL, NULL, NULL }
759
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 738
diff changeset
  1016
};
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 738
diff changeset
  1017
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
  1018
typedef void SettingDescProc(IniFile *ini, const SettingDesc *desc, const void *grpname);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1019
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1020
static void HandleSettingDescs(IniFile *ini, SettingDescProc *proc)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1021
{
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
  1022
	proc(ini, misc_settings,		"misc");
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
  1023
	proc(ini, win32_settings,		"win32");
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
  1024
#ifdef ENABLE_NETWORK
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
  1025
	proc(ini, network_settings, "network");
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
  1026
#endif /* ENABLE_NETWORK */
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
  1027
	proc(ini, music_settings,		"music");
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
  1028
	proc(ini, gameopt_settings, "gameopt");
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
  1029
	proc(ini, patch_settings,		"patches");
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
  1030
	proc(ini, patch_player_settings,		"patches");
759
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 738
diff changeset
  1031
	proc(ini, currency_settings,"currency");
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1032
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 523
diff changeset
  1033
	proc(ini, debug_settings,		"debug");
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1034
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1035
710
e8402270679f (svn r1162) The server list can now be automatically filled from the config file. Add a section [servers] with the addresses each in a new line. Those will be checked upon OpenTTD startup.
dominik
parents: 705
diff changeset
  1036
// loads all items from a *grpname section into the **list
e8402270679f (svn r1162) The server list can now be automatically filled from the config file. Add a section [servers] with the addresses each in a new line. Those will be checked upon OpenTTD startup.
dominik
parents: 705
diff changeset
  1037
static void LoadList(IniFile *ini, const char *grpname, char **list, int len)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1038
{
710
e8402270679f (svn r1162) The server list can now be automatically filled from the config file. Add a section [servers] with the addresses each in a new line. Those will be checked upon OpenTTD startup.
dominik
parents: 705
diff changeset
  1039
	IniGroup *group = ini_getgroup(ini, grpname, -1);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1040
	IniItem *item;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1041
	int i;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1042
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1043
	if (!group)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1044
		return;
705
e213445d82ec (svn r1157) Enhanced the config file (openttd.cfg) to use another section type. "List sections" as opposed to "variable sections" contain a list of values, separated by a new line. This is now used for the [newgrf] group. You have to edit each line in this section from e.g. "0 = firstset.grf" to only "firstset.grf".
dominik
parents: 690
diff changeset
  1045
	item = group->item;
710
e8402270679f (svn r1162) The server list can now be automatically filled from the config file. Add a section [servers] with the addresses each in a new line. Those will be checked upon OpenTTD startup.
dominik
parents: 705
diff changeset
  1046
	for ( i=0; i != len; i++) {
e8402270679f (svn r1162) The server list can now be automatically filled from the config file. Add a section [servers] with the addresses each in a new line. Those will be checked upon OpenTTD startup.
dominik
parents: 705
diff changeset
  1047
		if (item == NULL) break;
e8402270679f (svn r1162) The server list can now be automatically filled from the config file. Add a section [servers] with the addresses each in a new line. Those will be checked upon OpenTTD startup.
dominik
parents: 705
diff changeset
  1048
		list[i] = strdup(item->value);
705
e213445d82ec (svn r1157) Enhanced the config file (openttd.cfg) to use another section type. "List sections" as opposed to "variable sections" contain a list of values, separated by a new line. This is now used for the [newgrf] group. You have to edit each line in this section from e.g. "0 = firstset.grf" to only "firstset.grf".
dominik
parents: 690
diff changeset
  1049
		item = item->next;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1050
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1051
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1052
738
0b2fb79e64fc (svn r1194) Feature: You can now add and remove servers from the server list. Those will be remembered until you delete them by pressing the Delete key.
dominik
parents: 710
diff changeset
  1053
static void SaveList(IniFile *ini, const char *grpname, char **list, int len)
0b2fb79e64fc (svn r1194) Feature: You can now add and remove servers from the server list. Those will be remembered until you delete them by pressing the Delete key.
dominik
parents: 710
diff changeset
  1054
{
0b2fb79e64fc (svn r1194) Feature: You can now add and remove servers from the server list. Those will be remembered until you delete them by pressing the Delete key.
dominik
parents: 710
diff changeset
  1055
	IniGroup *group = ini_getgroup(ini, grpname, -1);
774
258c11431acb (svn r1240) -Fix: OpenTTD once again compiles if ENABLE_NETWORK is disabled.
darkvater
parents: 764
diff changeset
  1056
	IniItem *item = NULL;
738
0b2fb79e64fc (svn r1194) Feature: You can now add and remove servers from the server list. Those will be remembered until you delete them by pressing the Delete key.
dominik
parents: 710
diff changeset
  1057
	int i;
0b2fb79e64fc (svn r1194) Feature: You can now add and remove servers from the server list. Those will be remembered until you delete them by pressing the Delete key.
dominik
parents: 710
diff changeset
  1058
	bool first = true;
0b2fb79e64fc (svn r1194) Feature: You can now add and remove servers from the server list. Those will be remembered until you delete them by pressing the Delete key.
dominik
parents: 710
diff changeset
  1059
2919
5a867896b255 (svn r3475) - Fix: you couldn't remove an item from a list-type of config ingame from the configuration file. Whatever you did, upon restart of OpenTTD those items were still there. To fix this we initialize the first item to NULL in SaveList as it is rebuilt anyways fully.
Darkvater
parents: 2916
diff changeset
  1060
	if (group == NULL) return;
5a867896b255 (svn r3475) - Fix: you couldn't remove an item from a list-type of config ingame from the configuration file. Whatever you did, upon restart of OpenTTD those items were still there. To fix this we initialize the first item to NULL in SaveList as it is rebuilt anyways fully.
Darkvater
parents: 2916
diff changeset
  1061
	group->item = NULL;
5a867896b255 (svn r3475) - Fix: you couldn't remove an item from a list-type of config ingame from the configuration file. Whatever you did, upon restart of OpenTTD those items were still there. To fix this we initialize the first item to NULL in SaveList as it is rebuilt anyways fully.
Darkvater
parents: 2916
diff changeset
  1062
774
258c11431acb (svn r1240) -Fix: OpenTTD once again compiles if ENABLE_NETWORK is disabled.
darkvater
parents: 764
diff changeset
  1063
	for (i = 0; i != len; i++) {
898
b3c0e2240239 (svn r1384) Fix: Sometimes when lists were saved, a lot of blank lines had been added
dominik
parents: 841
diff changeset
  1064
		if (list[i] == NULL || list[i][0] == '\0') continue;
738
0b2fb79e64fc (svn r1194) Feature: You can now add and remove servers from the server list. Those will be remembered until you delete them by pressing the Delete key.
dominik
parents: 710
diff changeset
  1065
0b2fb79e64fc (svn r1194) Feature: You can now add and remove servers from the server list. Those will be remembered until you delete them by pressing the Delete key.
dominik
parents: 710
diff changeset
  1066
		if (first) { // add first item to the head of the group
0b2fb79e64fc (svn r1194) Feature: You can now add and remove servers from the server list. Those will be remembered until you delete them by pressing the Delete key.
dominik
parents: 710
diff changeset
  1067
			item = ini_item_alloc(group, list[i], strlen(list[i]));
0b2fb79e64fc (svn r1194) Feature: You can now add and remove servers from the server list. Those will be remembered until you delete them by pressing the Delete key.
dominik
parents: 710
diff changeset
  1068
			item->value = item->name;
0b2fb79e64fc (svn r1194) Feature: You can now add and remove servers from the server list. Those will be remembered until you delete them by pressing the Delete key.
dominik
parents: 710
diff changeset
  1069
			group->item = item;
0b2fb79e64fc (svn r1194) Feature: You can now add and remove servers from the server list. Those will be remembered until you delete them by pressing the Delete key.
dominik
parents: 710
diff changeset
  1070
			first = false;
0b2fb79e64fc (svn r1194) Feature: You can now add and remove servers from the server list. Those will be remembered until you delete them by pressing the Delete key.
dominik
parents: 710
diff changeset
  1071
		} else { // all other items are attached to the previous one
0b2fb79e64fc (svn r1194) Feature: You can now add and remove servers from the server list. Those will be remembered until you delete them by pressing the Delete key.
dominik
parents: 710
diff changeset
  1072
			item->next = ini_item_alloc(group, list[i], strlen(list[i]));
0b2fb79e64fc (svn r1194) Feature: You can now add and remove servers from the server list. Those will be remembered until you delete them by pressing the Delete key.
dominik
parents: 710
diff changeset
  1073
			item = item->next;
0b2fb79e64fc (svn r1194) Feature: You can now add and remove servers from the server list. Those will be remembered until you delete them by pressing the Delete key.
dominik
parents: 710
diff changeset
  1074
			item->value = item->name;
0b2fb79e64fc (svn r1194) Feature: You can now add and remove servers from the server list. Those will be remembered until you delete them by pressing the Delete key.
dominik
parents: 710
diff changeset
  1075
		}
0b2fb79e64fc (svn r1194) Feature: You can now add and remove servers from the server list. Those will be remembered until you delete them by pressing the Delete key.
dominik
parents: 710
diff changeset
  1076
	}
0b2fb79e64fc (svn r1194) Feature: You can now add and remove servers from the server list. Those will be remembered until you delete them by pressing the Delete key.
dominik
parents: 710
diff changeset
  1077
}
0b2fb79e64fc (svn r1194) Feature: You can now add and remove servers from the server list. Those will be remembered until you delete them by pressing the Delete key.
dominik
parents: 710
diff changeset
  1078
1093
e8d26c7dc42f (svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents: 1037
diff changeset
  1079
void LoadFromConfig(void)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1080
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1081
	IniFile *ini = ini_load(_config_file);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1082
	HandleSettingDescs(ini, load_setting_desc);
710
e8402270679f (svn r1162) The server list can now be automatically filled from the config file. Add a section [servers] with the addresses each in a new line. Those will be checked upon OpenTTD startup.
dominik
parents: 705
diff changeset
  1083
	LoadList(ini, "newgrf", _newgrf_files, lengthof(_newgrf_files));
738
0b2fb79e64fc (svn r1194) Feature: You can now add and remove servers from the server list. Those will be remembered until you delete them by pressing the Delete key.
dominik
parents: 710
diff changeset
  1084
	LoadList(ini, "servers", _network_host_list, lengthof(_network_host_list));
841
8f0a68c6f43b (svn r1322) -Add: banning system (mostly tnx to guru3)
truelight
parents: 835
diff changeset
  1085
	LoadList(ini, "bans", _network_ban_list, lengthof(_network_ban_list));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1086
	ini_free(ini);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1087
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1088
1093
e8d26c7dc42f (svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents: 1037
diff changeset
  1089
void SaveToConfig(void)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1090
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1091
	IniFile *ini = ini_load(_config_file);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1092
	HandleSettingDescs(ini, save_setting_desc);
738
0b2fb79e64fc (svn r1194) Feature: You can now add and remove servers from the server list. Those will be remembered until you delete them by pressing the Delete key.
dominik
parents: 710
diff changeset
  1093
	SaveList(ini, "servers", _network_host_list, lengthof(_network_host_list));
841
8f0a68c6f43b (svn r1322) -Add: banning system (mostly tnx to guru3)
truelight
parents: 835
diff changeset
  1094
	SaveList(ini, "bans", _network_ban_list, lengthof(_network_ban_list));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1095
	ini_save(_config_file, ini);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1096
	ini_free(ini);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1097
}
1688
787400219027 (svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents: 1643
diff changeset
  1098
787400219027 (svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents: 1643
diff changeset
  1099
void CheckConfig(void)
787400219027 (svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents: 1643
diff changeset
  1100
{
787400219027 (svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents: 1643
diff changeset
  1101
	// fix up news_display_opt from old to new
787400219027 (svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents: 1643
diff changeset
  1102
	int i;
787400219027 (svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents: 1643
diff changeset
  1103
	uint32 tmp;
1723
82bee0c4e589 (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
  1104
	for (i = 0, tmp = _news_display_opt; i != 10; i++, tmp >>= 2) {
1688
787400219027 (svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents: 1643
diff changeset
  1105
		if ((tmp & 0x3) == 0x3) { // old settings
787400219027 (svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents: 1643
diff changeset
  1106
			_news_display_opt = 0xAAAAAAAA; // set all news-messages to full 1010101010...
787400219027 (svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents: 1643
diff changeset
  1107
			break;
787400219027 (svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents: 1643
diff changeset
  1108
		}
787400219027 (svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents: 1643
diff changeset
  1109
	}
2044
68ec4a2f2d79 (svn r2553) - Fix: [pathfinding] Remove old-old train pathfinder. Enhanced old pathfinder.
ludde
parents: 2008
diff changeset
  1110
68ec4a2f2d79 (svn r2553) - Fix: [pathfinding] Remove old-old train pathfinder. Enhanced old pathfinder.
ludde
parents: 2008
diff changeset
  1111
	// Increase old default values for pf_maxdepth and pf_maxlength
68ec4a2f2d79 (svn r2553) - Fix: [pathfinding] Remove old-old train pathfinder. Enhanced old pathfinder.
ludde
parents: 2008
diff changeset
  1112
	// to support big networks.
68ec4a2f2d79 (svn r2553) - Fix: [pathfinding] Remove old-old train pathfinder. Enhanced old pathfinder.
ludde
parents: 2008
diff changeset
  1113
	if (_patches.pf_maxdepth == 16 && _patches.pf_maxlength == 512) {
68ec4a2f2d79 (svn r2553) - Fix: [pathfinding] Remove old-old train pathfinder. Enhanced old pathfinder.
ludde
parents: 2008
diff changeset
  1114
		_patches.pf_maxdepth = 48;
68ec4a2f2d79 (svn r2553) - Fix: [pathfinding] Remove old-old train pathfinder. Enhanced old pathfinder.
ludde
parents: 2008
diff changeset
  1115
		_patches.pf_maxlength = 4096;
68ec4a2f2d79 (svn r2553) - Fix: [pathfinding] Remove old-old train pathfinder. Enhanced old pathfinder.
ludde
parents: 2008
diff changeset
  1116
	}
1688
787400219027 (svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents: 1643
diff changeset
  1117
}