author | truelight |
Thu, 24 Mar 2005 14:43:40 +0000 | |
changeset 1540 | 6eef12dab5bf |
parent 1500 | a66721629bc0 |
child 1584 | 7122e759d56c |
permissions | -rw-r--r-- |
0 | 1 |
#include "stdafx.h" |
2 |
#include "ttd.h" |
|
3 |
#include "sound.h" |
|
1317
3c90086ff34f
(svn r1821) Move generic string handling functions to string.[ch] and introduce stre{cpy,cat}, see string.h for their semantics
tron
parents:
1282
diff
changeset
|
4 |
#include "string.h" |
759
a445474d7c21
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
738
diff
changeset
|
5 |
#include "table/currency.h" |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
6 |
#include "network.h" |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
7 |
#include "settings.h" |
0 | 8 |
|
9 |
typedef struct IniFile IniFile; |
|
10 |
typedef struct IniItem IniItem; |
|
11 |
typedef struct IniGroup IniGroup; |
|
1258
220b6e3b4d10
(svn r1762) -Codechange: renamed 'MemoryPool' to 'SettingsMemoryPool' (we need
truelight
parents:
1247
diff
changeset
|
12 |
typedef struct SettingsMemoryPool SettingsMemoryPool; |
0 | 13 |
|
1258
220b6e3b4d10
(svn r1762) -Codechange: renamed 'MemoryPool' to 'SettingsMemoryPool' (we need
truelight
parents:
1247
diff
changeset
|
14 |
static void pool_init(SettingsMemoryPool **pool); |
220b6e3b4d10
(svn r1762) -Codechange: renamed 'MemoryPool' to 'SettingsMemoryPool' (we need
truelight
parents:
1247
diff
changeset
|
15 |
static void *pool_alloc(SettingsMemoryPool **pool, uint size); |
220b6e3b4d10
(svn r1762) -Codechange: renamed 'MemoryPool' to 'SettingsMemoryPool' (we need
truelight
parents:
1247
diff
changeset
|
16 |
static void *pool_strdup(SettingsMemoryPool **pool, const char *mem, uint size); |
220b6e3b4d10
(svn r1762) -Codechange: renamed 'MemoryPool' to 'SettingsMemoryPool' (we need
truelight
parents:
1247
diff
changeset
|
17 |
static void pool_free(SettingsMemoryPool **pool); |
0 | 18 |
|
1258
220b6e3b4d10
(svn r1762) -Codechange: renamed 'MemoryPool' to 'SettingsMemoryPool' (we need
truelight
parents:
1247
diff
changeset
|
19 |
struct SettingsMemoryPool { |
0 | 20 |
uint pos,size; |
1258
220b6e3b4d10
(svn r1762) -Codechange: renamed 'MemoryPool' to 'SettingsMemoryPool' (we need
truelight
parents:
1247
diff
changeset
|
21 |
SettingsMemoryPool *next; |
0 | 22 |
byte mem[1]; |
23 |
}; |
|
24 |
||
1258
220b6e3b4d10
(svn r1762) -Codechange: renamed 'MemoryPool' to 'SettingsMemoryPool' (we need
truelight
parents:
1247
diff
changeset
|
25 |
static SettingsMemoryPool *pool_new(uint minsize) |
0 | 26 |
{ |
1258
220b6e3b4d10
(svn r1762) -Codechange: renamed 'MemoryPool' to 'SettingsMemoryPool' (we need
truelight
parents:
1247
diff
changeset
|
27 |
SettingsMemoryPool *p; |
0 | 28 |
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
|
29 |
|
1258
220b6e3b4d10
(svn r1762) -Codechange: renamed 'MemoryPool' to 'SettingsMemoryPool' (we need
truelight
parents:
1247
diff
changeset
|
30 |
p = malloc(sizeof(SettingsMemoryPool) - 1 + minsize); |
0 | 31 |
p->pos = 0; |
32 |
p->size = minsize; |
|
33 |
p->next = NULL; |
|
34 |
return p; |
|
35 |
} |
|
36 |
||
1258
220b6e3b4d10
(svn r1762) -Codechange: renamed 'MemoryPool' to 'SettingsMemoryPool' (we need
truelight
parents:
1247
diff
changeset
|
37 |
static void pool_init(SettingsMemoryPool **pool) |
0 | 38 |
{ |
39 |
*pool = pool_new(0); |
|
40 |
} |
|
41 |
||
1258
220b6e3b4d10
(svn r1762) -Codechange: renamed 'MemoryPool' to 'SettingsMemoryPool' (we need
truelight
parents:
1247
diff
changeset
|
42 |
static void *pool_alloc(SettingsMemoryPool **pool, uint size) |
0 | 43 |
{ |
44 |
uint pos; |
|
1258
220b6e3b4d10
(svn r1762) -Codechange: renamed 'MemoryPool' to 'SettingsMemoryPool' (we need
truelight
parents:
1247
diff
changeset
|
45 |
SettingsMemoryPool *p = *pool; |
0 | 46 |
|
47 |
size = (size + 3) & ~3; // align everything to a 32 bit boundary |
|
48 |
||
49 |
// first check if there's memory in the next pool |
|
50 |
if (p->next && p->next->pos + size <= p->next->size) { |
|
51 |
p = p->next; |
|
52 |
// then check if there's not memory in the cur pool |
|
53 |
} else if (p->pos + size > p->size) { |
|
1258
220b6e3b4d10
(svn r1762) -Codechange: renamed 'MemoryPool' to 'SettingsMemoryPool' (we need
truelight
parents:
1247
diff
changeset
|
54 |
SettingsMemoryPool *n = pool_new(size); |
0 | 55 |
*pool = n; |
56 |
n->next = p; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
188
diff
changeset
|
57 |
p = n; |
0 | 58 |
} |
59 |
||
60 |
pos = p->pos; |
|
61 |
p->pos += size; |
|
62 |
return p->mem + pos; |
|
63 |
} |
|
64 |
||
1258
220b6e3b4d10
(svn r1762) -Codechange: renamed 'MemoryPool' to 'SettingsMemoryPool' (we need
truelight
parents:
1247
diff
changeset
|
65 |
static void *pool_strdup(SettingsMemoryPool **pool, const char *mem, uint size) |
0 | 66 |
{ |
67 |
byte *p = pool_alloc(pool, size + 1); |
|
68 |
p[size] = 0; |
|
69 |
memcpy(p, mem, size); |
|
70 |
return p; |
|
71 |
} |
|
72 |
||
1258
220b6e3b4d10
(svn r1762) -Codechange: renamed 'MemoryPool' to 'SettingsMemoryPool' (we need
truelight
parents:
1247
diff
changeset
|
73 |
static void pool_free(SettingsMemoryPool **pool) |
0 | 74 |
{ |
1258
220b6e3b4d10
(svn r1762) -Codechange: renamed 'MemoryPool' to 'SettingsMemoryPool' (we need
truelight
parents:
1247
diff
changeset
|
75 |
SettingsMemoryPool *p = *pool, *n; |
0 | 76 |
*pool = NULL; |
77 |
while (p) { |
|
78 |
n = p->next; |
|
79 |
free(p); |
|
80 |
p = n; |
|
81 |
} |
|
82 |
} |
|
83 |
||
84 |
// structs describing the ini format. |
|
85 |
struct IniItem { |
|
86 |
char *name; |
|
87 |
char *value; |
|
88 |
char *comment; |
|
89 |
IniItem *next; |
|
90 |
}; |
|
91 |
||
92 |
struct IniGroup { |
|
93 |
char *name; // name of group |
|
94 |
char *comment; //comment for group |
|
95 |
IniItem *item, **last_item; |
|
96 |
IniGroup *next; |
|
97 |
IniFile *ini; |
|
705
71cf9f0d7e7f
(svn r1157) Enhanced the config file (openttd.cfg) to use another section type. "List sections" as opposed to "variable sections" contain a list of values, separated by a new line. This is now used for the [newgrf] group. You have to edit each line in this section from e.g. "0 = firstset.grf" to only "firstset.grf".
dominik
parents:
690
diff
changeset
|
98 |
IniGroupType type; // type of group |
0 | 99 |
}; |
100 |
||
101 |
struct IniFile { |
|
1258
220b6e3b4d10
(svn r1762) -Codechange: renamed 'MemoryPool' to 'SettingsMemoryPool' (we need
truelight
parents:
1247
diff
changeset
|
102 |
SettingsMemoryPool *pool; |
0 | 103 |
IniGroup *group, **last_group; |
104 |
char *comment; // last comment in file |
|
105 |
}; |
|
106 |
||
107 |
// allocate an inifile object |
|
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1037
diff
changeset
|
108 |
static IniFile *ini_alloc(void) |
0 | 109 |
{ |
110 |
IniFile *ini; |
|
1258
220b6e3b4d10
(svn r1762) -Codechange: renamed 'MemoryPool' to 'SettingsMemoryPool' (we need
truelight
parents:
1247
diff
changeset
|
111 |
SettingsMemoryPool *pool; |
0 | 112 |
pool_init(&pool); |
113 |
ini = (IniFile*)pool_alloc(&pool, sizeof(IniFile)); |
|
114 |
ini->pool = pool; |
|
115 |
ini->group = NULL; |
|
116 |
ini->last_group = &ini->group; |
|
117 |
ini->comment = NULL; |
|
118 |
return ini; |
|
119 |
} |
|
120 |
||
121 |
// allocate an ini group object |
|
122 |
static IniGroup *ini_group_alloc(IniFile *ini, const char *grpt, int len) |
|
123 |
{ |
|
124 |
IniGroup *grp = pool_alloc(&ini->pool, sizeof(IniGroup)); |
|
125 |
grp->ini = ini; |
|
126 |
grp->name = pool_strdup(&ini->pool, grpt, len); |
|
841
4874b9ce2765
(svn r1322) -Add: banning system (mostly tnx to guru3)
truelight
parents:
835
diff
changeset
|
127 |
if(!strcmp(grp->name, "newgrf") || !strcmp(grp->name, "servers") || !strcmp(grp->name, "bans") ) |
705
71cf9f0d7e7f
(svn r1157) Enhanced the config file (openttd.cfg) to use another section type. "List sections" as opposed to "variable sections" contain a list of values, separated by a new line. This is now used for the [newgrf] group. You have to edit each line in this section from e.g. "0 = firstset.grf" to only "firstset.grf".
dominik
parents:
690
diff
changeset
|
128 |
grp->type = IGT_LIST; |
71cf9f0d7e7f
(svn r1157) Enhanced the config file (openttd.cfg) to use another section type. "List sections" as opposed to "variable sections" contain a list of values, separated by a new line. This is now used for the [newgrf] group. You have to edit each line in this section from e.g. "0 = firstset.grf" to only "firstset.grf".
dominik
parents:
690
diff
changeset
|
129 |
else |
71cf9f0d7e7f
(svn r1157) Enhanced the config file (openttd.cfg) to use another section type. "List sections" as opposed to "variable sections" contain a list of values, separated by a new line. This is now used for the [newgrf] group. You have to edit each line in this section from e.g. "0 = firstset.grf" to only "firstset.grf".
dominik
parents:
690
diff
changeset
|
130 |
grp->type = IGT_VARIABLES; |
0 | 131 |
grp->next = NULL; |
132 |
grp->item = NULL; |
|
133 |
grp->comment = NULL; |
|
134 |
grp->last_item = &grp->item; |
|
135 |
*ini->last_group = grp; |
|
136 |
ini->last_group = &grp->next; |
|
137 |
return grp; |
|
138 |
} |
|
139 |
||
140 |
static IniItem *ini_item_alloc(IniGroup *group, const char *name, int len) |
|
141 |
{ |
|
142 |
IniItem *item = pool_alloc(&group->ini->pool, sizeof(IniItem)); |
|
143 |
item->name = pool_strdup(&group->ini->pool, name, len); |
|
144 |
item->next = NULL; |
|
145 |
item->comment = NULL; |
|
146 |
item->value = NULL; |
|
147 |
*group->last_item = item; |
|
148 |
group->last_item = &item->next; |
|
149 |
return item; |
|
150 |
} |
|
151 |
||
152 |
// load an ini file into the "abstract" format |
|
153 |
static IniFile *ini_load(const char *filename) |
|
154 |
{ |
|
155 |
char buffer[1024], c, *s, *t, *e; |
|
156 |
FILE *in; |
|
157 |
IniFile *ini; |
|
158 |
IniGroup *group = NULL; |
|
159 |
IniItem *item; |
|
160 |
||
1329 | 161 |
char *comment = NULL; |
0 | 162 |
uint comment_size = 0; |
163 |
uint comment_alloc = 0; |
|
164 |
||
165 |
ini = ini_alloc(); |
|
166 |
||
167 |
in = fopen(filename, "r"); |
|
168 |
if (in == NULL) return ini; |
|
169 |
||
170 |
// for each line in the file |
|
171 |
while (fgets(buffer, sizeof(buffer), in)) { |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
188
diff
changeset
|
172 |
|
0 | 173 |
// trim whitespace from the left side |
759
a445474d7c21
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
738
diff
changeset
|
174 |
for(s=buffer; s[0] == ' ' || s[0] == '\t'; s++); |
0 | 175 |
|
176 |
// trim whitespace from right side. |
|
177 |
e = s + strlen(s); |
|
178 |
while (e > s && ((c=e[-1]) == '\n' || c == '\r' || c == ' ' || c == '\t')) e--; |
|
179 |
*e = 0; |
|
180 |
||
181 |
// skip comments and empty lines |
|
182 |
if (*s == '#' || *s == 0) { |
|
183 |
uint ns = comment_size + (e - s + 1); |
|
184 |
uint a = comment_alloc; |
|
185 |
uint pos; |
|
186 |
// add to comment |
|
187 |
if (ns > a) { |
|
188 |
a = max(a, 128); |
|
189 |
do a*=2; while (a < ns); |
|
190 |
comment = realloc(comment, comment_alloc = a); |
|
191 |
} |
|
192 |
pos = comment_size; |
|
193 |
comment_size += (e - s + 1); |
|
194 |
comment[pos + e - s] = '\n'; // comment newline |
|
195 |
memcpy(comment + pos, s, e - s); // copy comment contents |
|
196 |
continue; |
|
197 |
} |
|
198 |
||
199 |
// it's a group? |
|
200 |
if (s[0] == '[') { |
|
201 |
if (e[-1] != ']') |
|
202 |
ShowInfoF("ini: invalid group name '%s'\n", buffer); |
|
203 |
else |
|
204 |
e--; |
|
205 |
s++; // skip [ |
|
206 |
group = ini_group_alloc(ini, s, e - s); |
|
207 |
if (comment_size) { |
|
208 |
group->comment = pool_strdup(&ini->pool, comment, comment_size); |
|
209 |
comment_size = 0; |
|
210 |
} |
|
211 |
} else if (group) { |
|
212 |
// find end of keyname |
|
213 |
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
|
214 |
|
0 | 215 |
// it's an item in an existing group |
216 |
item = ini_item_alloc(group, s, t-s); |
|
217 |
if (comment_size) { |
|
218 |
item->comment = pool_strdup(&ini->pool, comment, comment_size); |
|
219 |
comment_size = 0; |
|
220 |
} |
|
221 |
||
705
71cf9f0d7e7f
(svn r1157) Enhanced the config file (openttd.cfg) to use another section type. "List sections" as opposed to "variable sections" contain a list of values, separated by a new line. This is now used for the [newgrf] group. You have to edit each line in this section from e.g. "0 = firstset.grf" to only "firstset.grf".
dominik
parents:
690
diff
changeset
|
222 |
// for list items, the name and value are the same: |
71cf9f0d7e7f
(svn r1157) Enhanced the config file (openttd.cfg) to use another section type. "List sections" as opposed to "variable sections" contain a list of values, separated by a new line. This is now used for the [newgrf] group. You have to edit each line in this section from e.g. "0 = firstset.grf" to only "firstset.grf".
dominik
parents:
690
diff
changeset
|
223 |
if( group->type == IGT_LIST ) { |
71cf9f0d7e7f
(svn r1157) Enhanced the config file (openttd.cfg) to use another section type. "List sections" as opposed to "variable sections" contain a list of values, separated by a new line. This is now used for the [newgrf] group. You have to edit each line in this section from e.g. "0 = firstset.grf" to only "firstset.grf".
dominik
parents:
690
diff
changeset
|
224 |
item->value = item->name; |
71cf9f0d7e7f
(svn r1157) Enhanced the config file (openttd.cfg) to use another section type. "List sections" as opposed to "variable sections" contain a list of values, separated by a new line. This is now used for the [newgrf] group. You have to edit each line in this section from e.g. "0 = firstset.grf" to only "firstset.grf".
dominik
parents:
690
diff
changeset
|
225 |
continue; |
71cf9f0d7e7f
(svn r1157) Enhanced the config file (openttd.cfg) to use another section type. "List sections" as opposed to "variable sections" contain a list of values, separated by a new line. This is now used for the [newgrf] group. You have to edit each line in this section from e.g. "0 = firstset.grf" to only "firstset.grf".
dominik
parents:
690
diff
changeset
|
226 |
} |
71cf9f0d7e7f
(svn r1157) Enhanced the config file (openttd.cfg) to use another section type. "List sections" as opposed to "variable sections" contain a list of values, separated by a new line. This is now used for the [newgrf] group. You have to edit each line in this section from e.g. "0 = firstset.grf" to only "firstset.grf".
dominik
parents:
690
diff
changeset
|
227 |
|
0 | 228 |
// find start of parameter |
229 |
while (*t == '=' || *t == ' ' || *t == '\t') t++; |
|
759
a445474d7c21
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
738
diff
changeset
|
230 |
|
a445474d7c21
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
738
diff
changeset
|
231 |
|
a445474d7c21
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
738
diff
changeset
|
232 |
// remove starting quotation marks |
a445474d7c21
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
738
diff
changeset
|
233 |
if(*t=='\"') t++; |
a445474d7c21
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
738
diff
changeset
|
234 |
// remove ending quotation marks |
a445474d7c21
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
738
diff
changeset
|
235 |
e = t + strlen(t); |
a445474d7c21
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
738
diff
changeset
|
236 |
if(e>t && e[-1] =='\"') e--; |
a445474d7c21
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
738
diff
changeset
|
237 |
*e = 0; |
a445474d7c21
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
738
diff
changeset
|
238 |
|
0 | 239 |
item->value = pool_strdup(&ini->pool, t, e - t); |
240 |
} else { |
|
241 |
// it's an orphan item |
|
242 |
ShowInfoF("ini: '%s' outside of group\n", buffer); |
|
243 |
} |
|
244 |
} |
|
245 |
||
246 |
if (comment_size) { |
|
247 |
ini->comment = pool_strdup(&ini->pool, comment, comment_size); |
|
248 |
comment_size = 0; |
|
249 |
} |
|
250 |
||
251 |
free(comment); |
|
252 |
fclose(in); |
|
253 |
||
254 |
return ini; |
|
255 |
} |
|
256 |
||
257 |
// lookup a group or make a new one |
|
258 |
static IniGroup *ini_getgroup(IniFile *ini, const char *name, int len) |
|
259 |
{ |
|
260 |
IniGroup *group; |
|
261 |
||
262 |
if (len == -1) len = strlen(name); |
|
263 |
||
264 |
// does it exist already? |
|
265 |
for(group = ini->group; group; group = group->next) |
|
266 |
if (!memcmp(group->name, name, len) && group->name[len] == 0) |
|
267 |
return group; |
|
268 |
||
269 |
// otherwise make a new one |
|
270 |
group = ini_group_alloc(ini, name, len); |
|
271 |
group->comment = pool_strdup(&ini->pool, "\n", 1); |
|
272 |
return group; |
|
273 |
} |
|
274 |
||
275 |
// lookup an item or make a new one |
|
276 |
static IniItem *ini_getitem(IniGroup *group, const char *name, bool create) |
|
277 |
{ |
|
278 |
IniItem *item; |
|
279 |
uint len = strlen(name); |
|
280 |
||
281 |
for(item = group->item; item; item = item->next) |
|
282 |
if (!strcmp(item->name, name)) |
|
283 |
return item; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
188
diff
changeset
|
284 |
|
0 | 285 |
if (!create) return NULL; |
286 |
||
287 |
// otherwise make a new one |
|
288 |
item = ini_item_alloc(group, name, len); |
|
289 |
return item; |
|
290 |
} |
|
291 |
||
292 |
// save ini file from the "abstract" format. |
|
293 |
static bool ini_save(const char *filename, IniFile *ini) |
|
294 |
{ |
|
295 |
FILE *f; |
|
296 |
IniGroup *group; |
|
297 |
IniItem *item; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
188
diff
changeset
|
298 |
|
0 | 299 |
f = fopen(filename, "w"); |
300 |
if (f == NULL) return false; |
|
301 |
||
302 |
for(group = ini->group; group; group = group->next) { |
|
303 |
if (group->comment) fputs(group->comment, f); |
|
304 |
fprintf(f, "[%s]\n", group->name); |
|
305 |
for(item = group->item; item; item = item->next) { |
|
306 |
if (item->comment) fputs(item->comment, f); |
|
705
71cf9f0d7e7f
(svn r1157) Enhanced the config file (openttd.cfg) to use another section type. "List sections" as opposed to "variable sections" contain a list of values, separated by a new line. This is now used for the [newgrf] group. You have to edit each line in this section from e.g. "0 = firstset.grf" to only "firstset.grf".
dominik
parents:
690
diff
changeset
|
307 |
if(group->type==IGT_LIST) |
71cf9f0d7e7f
(svn r1157) Enhanced the config file (openttd.cfg) to use another section type. "List sections" as opposed to "variable sections" contain a list of values, separated by a new line. This is now used for the [newgrf] group. You have to edit each line in this section from e.g. "0 = firstset.grf" to only "firstset.grf".
dominik
parents:
690
diff
changeset
|
308 |
fprintf(f, "%s\n", item->value ? item->value : ""); |
71cf9f0d7e7f
(svn r1157) Enhanced the config file (openttd.cfg) to use another section type. "List sections" as opposed to "variable sections" contain a list of values, separated by a new line. This is now used for the [newgrf] group. You have to edit each line in this section from e.g. "0 = firstset.grf" to only "firstset.grf".
dominik
parents:
690
diff
changeset
|
309 |
else |
71cf9f0d7e7f
(svn r1157) Enhanced the config file (openttd.cfg) to use another section type. "List sections" as opposed to "variable sections" contain a list of values, separated by a new line. This is now used for the [newgrf] group. You have to edit each line in this section from e.g. "0 = firstset.grf" to only "firstset.grf".
dominik
parents:
690
diff
changeset
|
310 |
fprintf(f, "%s = %s\n", item->name, item->value ? item->value : ""); |
0 | 311 |
} |
312 |
} |
|
313 |
if (ini->comment) fputs(ini->comment, f); |
|
314 |
||
315 |
fclose(f); |
|
316 |
return true; |
|
317 |
} |
|
318 |
||
319 |
static void ini_free(IniFile *ini) |
|
320 |
{ |
|
321 |
pool_free(&ini->pool); |
|
322 |
} |
|
323 |
||
324 |
static int lookup_oneofmany(const char *many, const char *one, int onelen) |
|
325 |
{ |
|
326 |
const char *s; |
|
327 |
int idx; |
|
328 |
||
329 |
if (onelen == -1) onelen = strlen(one); |
|
330 |
||
331 |
// check if it's an integer |
|
332 |
if (*one >= '0' && *one <= '9') |
|
333 |
return strtoul(one, NULL, 0); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
188
diff
changeset
|
334 |
|
0 | 335 |
idx = 0; |
336 |
for(;;) { |
|
337 |
// find end of item |
|
338 |
s = many; |
|
339 |
while (*s != '|' && *s != 0) s++; |
|
340 |
if (s - many == onelen && !memcmp(one, many, onelen)) return idx; |
|
341 |
if (*s == 0) return -1; |
|
342 |
many = s + 1; |
|
343 |
idx++; |
|
344 |
} |
|
345 |
} |
|
346 |
||
347 |
static uint32 lookup_manyofmany(const char *many, const char *str) |
|
348 |
{ |
|
349 |
const char *s; |
|
350 |
int r; |
|
351 |
uint32 res = 0; |
|
352 |
||
353 |
for(;;) { |
|
354 |
// skip "whitespace" |
|
355 |
while (*str == ' ' || *str == '\t' || *str == '|') str++; |
|
356 |
if (*str == 0) break; |
|
357 |
||
358 |
s = str; |
|
359 |
while (*s != 0 && *s != ' ' && *s != '\t' && *s != '|') s++; |
|
360 |
||
361 |
r = lookup_oneofmany(many, str, s - str); |
|
362 |
if (r == -1) return (uint32)-1; |
|
363 |
||
364 |
res |= (1 << r); |
|
365 |
if (*s == 0) break; |
|
366 |
str = s + 1; |
|
367 |
} |
|
368 |
return res; |
|
369 |
} |
|
370 |
||
371 |
static int parse_intlist(const char *p, int *items, int maxitems) |
|
372 |
{ |
|
373 |
int n = 0, v; |
|
374 |
char *end; |
|
375 |
||
376 |
for(;;) { |
|
377 |
v = strtol(p, &end, 0); |
|
378 |
if (p == end || n == maxitems) return -1; |
|
379 |
p = end; |
|
380 |
items[n++] = v; |
|
381 |
if (*p == 0) break; |
|
382 |
if (*p != ',') return -1; |
|
383 |
p++; |
|
384 |
} |
|
385 |
||
386 |
return n; |
|
387 |
} |
|
388 |
||
389 |
static bool load_intlist(const char *str, void *array, int nelems, int type) |
|
390 |
{ |
|
391 |
int items[64]; |
|
392 |
int i,nitems; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
188
diff
changeset
|
393 |
|
0 | 394 |
if (str == NULL) { |
395 |
memset(items, 0, sizeof(items)); |
|
396 |
nitems = nelems; |
|
397 |
} else { |
|
398 |
nitems = parse_intlist(str, items, lengthof(items)); |
|
399 |
if (nitems != nelems) |
|
400 |
return false; |
|
401 |
} |
|
402 |
||
403 |
switch(type) { |
|
404 |
case SDT_INT8 >> 4: |
|
405 |
case SDT_UINT8 >> 4: |
|
406 |
for(i=0; i!=nitems; i++) ((byte*)array)[i] = items[i]; |
|
407 |
break; |
|
408 |
case SDT_INT16 >> 4: |
|
409 |
case SDT_UINT16 >> 4: |
|
410 |
for(i=0; i!=nitems; i++) ((uint16*)array)[i] = items[i]; |
|
411 |
break; |
|
412 |
case SDT_INT32 >> 4: |
|
413 |
case SDT_UINT32 >> 4: |
|
414 |
for(i=0; i!=nitems; i++) ((uint32*)array)[i] = items[i]; |
|
415 |
break; |
|
416 |
default: |
|
417 |
NOT_REACHED(); |
|
418 |
} |
|
419 |
||
420 |
return true; |
|
421 |
} |
|
422 |
||
423 |
static void make_intlist(char *buf, void *array, int nelems, int type) |
|
424 |
{ |
|
425 |
int i, v = 0; |
|
426 |
byte *p = (byte*)array; |
|
427 |
for(i=0; i!=nelems; i++) { |
|
428 |
switch(type) { |
|
429 |
case SDT_INT8 >> 4: v = *(int8*)p; p += 1; break; |
|
430 |
case SDT_UINT8 >> 4:v = *(byte*)p; p += 1; break; |
|
431 |
case SDT_INT16 >> 4:v = *(int16*)p; p += 2; break; |
|
432 |
case SDT_UINT16 >> 4:v = *(uint16*)p; p += 2; break; |
|
433 |
case SDT_INT32 >> 4:v = *(int32*)p; p += 4; break; |
|
434 |
case SDT_UINT32 >> 4:v = *(uint32*)p; p += 4; break; |
|
435 |
default: NOT_REACHED(); |
|
436 |
} |
|
437 |
buf += sprintf(buf, i ? ",%d" : "%d", v); |
|
438 |
} |
|
439 |
} |
|
440 |
||
441 |
static void make_oneofmany(char *buf, const char *many, int i) |
|
442 |
{ |
|
443 |
int orig_i = i; |
|
444 |
char c; |
|
445 |
||
446 |
while (--i >= 0) { |
|
447 |
do { |
|
448 |
many++; |
|
449 |
if (many[-1] == 0) { |
|
450 |
sprintf(buf, "%d", orig_i); |
|
451 |
return; |
|
452 |
} |
|
453 |
} while (many[-1] != '|'); |
|
454 |
} |
|
455 |
||
456 |
// copy until | or 0 |
|
457 |
while ((c=*many++) != 0 && c != '|') |
|
458 |
*buf++ = c; |
|
459 |
*buf = 0; |
|
460 |
} |
|
461 |
||
462 |
static void make_manyofmany(char *buf, const char *many, uint32 x) |
|
463 |
{ |
|
464 |
const char *start; |
|
465 |
int i = 0; |
|
466 |
bool init = true; |
|
467 |
||
468 |
do { |
|
469 |
start = many; |
|
470 |
while (*many != 0 && *many != '|') many++; |
|
471 |
if (x & 1) { |
|
472 |
if (!init) *buf++ = '|'; |
|
473 |
init = false; |
|
474 |
if (start == many) { |
|
475 |
buf += sprintf(buf, "%d", i); |
|
476 |
} else { |
|
477 |
memcpy(buf, start, many - start); |
|
478 |
buf += many - start; |
|
479 |
} |
|
480 |
} |
|
481 |
if (*many == '|') many++; |
|
482 |
} while (++i, x>>=1); |
|
483 |
*buf = 0; |
|
484 |
} |
|
485 |
||
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
|
486 |
static const void *string_to_val(const SettingDesc *desc, const char *str) |
0 | 487 |
{ |
488 |
unsigned long val; |
|
489 |
char *end; |
|
490 |
||
491 |
switch(desc->flags & 0xF) { |
|
492 |
case SDT_INTX: |
|
493 |
val = strtol(str, &end, 0); |
|
494 |
if (*end != 0) ShowInfoF("ini: trailing characters at end of setting '%s'", desc->name); |
|
495 |
return (void*)val; |
|
496 |
case SDT_ONEOFMANY: { |
|
1010
977aafc6b8e3
(svn r1509) Const correctness and add static where appropriate while touching the lines anyway
tron
parents:
998
diff
changeset
|
497 |
int r = lookup_oneofmany((const char*)desc->b, str, -1); |
0 | 498 |
if (r != -1) return (void*)r; |
499 |
ShowInfoF("ini: invalid value '%s' for '%s'", str, desc->name); |
|
500 |
return 0; |
|
501 |
} |
|
502 |
case SDT_MANYOFMANY: { |
|
503 |
uint32 r = lookup_manyofmany(desc->b, str); |
|
504 |
if (r != (uint32)-1) return (void*)r; |
|
505 |
ShowInfoF("ini: invalid value '%s' for '%s'", str, desc->name); |
|
506 |
return 0; |
|
507 |
} |
|
508 |
case SDT_BOOLX: |
|
509 |
if (!strcmp(str, "true") || !strcmp(str, "on") || !strcmp(str, "1")) |
|
510 |
return (void*)true; |
|
511 |
if (!strcmp(str, "false") || !strcmp(str, "off") || !strcmp(str, "0")) |
|
512 |
return (void*)false; |
|
513 |
ShowInfoF("ini: invalid setting value '%s' for '%s'", str, desc->name); |
|
514 |
break; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
188
diff
changeset
|
515 |
|
0 | 516 |
case SDT_STRING: |
517 |
case SDT_STRINGBUF: |
|
759
a445474d7c21
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
738
diff
changeset
|
518 |
case SDT_STRINGQUOT: |
0 | 519 |
case SDT_INTLIST: |
1010
977aafc6b8e3
(svn r1509) Const correctness and add static where appropriate while touching the lines anyway
tron
parents:
998
diff
changeset
|
520 |
return str; |
0 | 521 |
} |
522 |
||
523 |
return NULL; |
|
524 |
} |
|
525 |
||
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
526 |
static void load_setting_desc(IniFile *ini, const SettingDesc *desc, const void *grpname) |
0 | 527 |
{ |
528 |
IniGroup *group_def = ini_getgroup(ini, grpname, -1), *group; |
|
529 |
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
|
530 |
const void *p; |
0 | 531 |
void *ptr; |
532 |
||
533 |
for (;desc->name;desc++) { |
|
534 |
// group override? |
|
535 |
const char *s = strchr(desc->name, '.'); |
|
536 |
if (s) { |
|
537 |
group = ini_getgroup(ini, desc->name, s - desc->name); |
|
538 |
s++; |
|
539 |
} else { |
|
540 |
s = desc->name; |
|
541 |
group = group_def; |
|
542 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
188
diff
changeset
|
543 |
|
0 | 544 |
item = ini_getitem(group, s, false); |
545 |
if (!item) { |
|
546 |
p = desc->def; |
|
547 |
} else { |
|
548 |
p = string_to_val(desc, item->value); |
|
549 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
188
diff
changeset
|
550 |
|
0 | 551 |
// get ptr to array |
552 |
ptr = desc->ptr; |
|
553 |
||
554 |
switch(desc->flags & 0xF) { |
|
555 |
// all these are stored in the same way |
|
556 |
case SDT_INTX: |
|
557 |
case SDT_ONEOFMANY: |
|
558 |
case SDT_MANYOFMANY: |
|
559 |
case SDT_BOOLX: |
|
560 |
switch(desc->flags >> 4 & 7) { |
|
561 |
case SDT_INT8 >> 4: |
|
562 |
case SDT_UINT8 >> 4: |
|
563 |
*(byte*)ptr = (byte)(uint)p; |
|
564 |
break; |
|
565 |
case SDT_INT16 >> 4: |
|
566 |
case SDT_UINT16 >> 4: |
|
567 |
*(uint16*)ptr = (uint16)(uint)p; |
|
568 |
break; |
|
569 |
case SDT_INT32 >> 4: |
|
570 |
case SDT_UINT32 >> 4: |
|
571 |
*(uint32*)ptr = (uint32)p; |
|
572 |
break; |
|
573 |
default: |
|
574 |
NOT_REACHED(); |
|
575 |
} |
|
576 |
break; |
|
577 |
case SDT_STRING: |
|
1104 | 578 |
free(*(char**)ptr); |
1010
977aafc6b8e3
(svn r1509) Const correctness and add static where appropriate while touching the lines anyway
tron
parents:
998
diff
changeset
|
579 |
*(char**)ptr = strdup((const char*)p); |
0 | 580 |
break; |
581 |
case SDT_STRINGBUF: |
|
759
a445474d7c21
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
738
diff
changeset
|
582 |
case SDT_STRINGQUOT: |
0 | 583 |
if (p) ttd_strlcpy((char*)ptr, p, desc->flags >> 16); |
584 |
break; |
|
585 |
case SDT_INTLIST: { |
|
586 |
if (!load_intlist(p, ptr, desc->flags >> 16, desc->flags >> 4 & 7)) |
|
587 |
ShowInfoF("ini: error in array '%s'", desc->name); |
|
588 |
break; |
|
589 |
} |
|
590 |
default: |
|
591 |
NOT_REACHED(); |
|
592 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
188
diff
changeset
|
593 |
} |
0 | 594 |
} |
595 |
||
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
596 |
static void save_setting_desc(IniFile *ini, const SettingDesc *desc, const void *grpname) |
0 | 597 |
{ |
598 |
IniGroup *group_def = NULL, *group; |
|
599 |
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
|
600 |
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
|
601 |
void *ptr; |
0 | 602 |
int i = 0; |
603 |
char buf[512]; // setting buffer |
|
604 |
const char *s; |
|
605 |
||
606 |
for (;desc->name;desc++) { |
|
607 |
if (desc->flags & SDT_NOSAVE) |
|
608 |
continue; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
188
diff
changeset
|
609 |
|
0 | 610 |
// group override? |
611 |
s = strchr(desc->name, '.'); |
|
612 |
if (s) { |
|
613 |
group = ini_getgroup(ini, desc->name, s - desc->name); |
|
614 |
s++; |
|
615 |
} else { |
|
616 |
if (group_def == NULL) |
|
617 |
group_def = ini_getgroup(ini, grpname, -1); |
|
618 |
s = desc->name; |
|
619 |
group = group_def; |
|
620 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
188
diff
changeset
|
621 |
|
0 | 622 |
item = ini_getitem(group, s, true); |
623 |
||
624 |
// get ptr to array |
|
625 |
ptr = desc->ptr; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
188
diff
changeset
|
626 |
|
0 | 627 |
if (item->value != NULL) { |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
188
diff
changeset
|
628 |
// check if the value is the same as the old value |
0 | 629 |
p = string_to_val(desc, item->value); |
630 |
||
631 |
switch(desc->flags & 0xF) { |
|
632 |
case SDT_INTX: |
|
633 |
case SDT_ONEOFMANY: |
|
634 |
case SDT_MANYOFMANY: |
|
635 |
case SDT_BOOLX: |
|
636 |
switch(desc->flags >> 4 & 7) { |
|
637 |
case SDT_INT8 >> 4: |
|
638 |
case SDT_UINT8 >> 4: |
|
639 |
if (*(byte*)ptr == (byte)(uint)p) |
|
640 |
continue; |
|
641 |
break; |
|
642 |
case SDT_INT16 >> 4: |
|
643 |
case SDT_UINT16 >> 4: |
|
644 |
if (*(uint16*)ptr == (uint16)(uint)p) |
|
645 |
continue; |
|
646 |
break; |
|
647 |
case SDT_INT32 >> 4: |
|
648 |
case SDT_UINT32 >> 4: |
|
649 |
if (*(uint32*)ptr == (uint32)p) |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
188
diff
changeset
|
650 |
continue; |
0 | 651 |
break; |
652 |
default: |
|
653 |
NOT_REACHED(); |
|
654 |
} |
|
655 |
break; |
|
656 |
case SDT_STRING: |
|
657 |
assert(0); |
|
658 |
break; |
|
659 |
case SDT_INTLIST: |
|
660 |
// assume intlist is always changed. |
|
661 |
break; |
|
662 |
} |
|
663 |
} |
|
664 |
||
665 |
switch(desc->flags & 0xF) { |
|
666 |
case SDT_INTX: |
|
667 |
case SDT_ONEOFMANY: |
|
668 |
case SDT_MANYOFMANY: |
|
669 |
case SDT_BOOLX: |
|
670 |
switch(desc->flags >> 4 & 7) { |
|
671 |
case SDT_INT8 >> 4: i = *(int8*)ptr; break; |
|
672 |
case SDT_UINT8 >> 4:i = *(byte*)ptr; break; |
|
673 |
case SDT_INT16 >> 4:i = *(int16*)ptr; break; |
|
674 |
case SDT_UINT16 >> 4:i = *(uint16*)ptr; break; |
|
675 |
case SDT_INT32 >> 4:i = *(int32*)ptr; break; |
|
676 |
case SDT_UINT32 >> 4:i = *(uint32*)ptr; break; |
|
677 |
default: |
|
678 |
NOT_REACHED(); |
|
679 |
} |
|
680 |
switch(desc->flags & 0xF) { |
|
681 |
case SDT_INTX: |
|
682 |
sprintf(buf, "%d", i); |
|
683 |
break; |
|
684 |
case SDT_ONEOFMANY: |
|
1010
977aafc6b8e3
(svn r1509) Const correctness and add static where appropriate while touching the lines anyway
tron
parents:
998
diff
changeset
|
685 |
make_oneofmany(buf, (const char*)desc->b, i); |
0 | 686 |
break; |
687 |
case SDT_MANYOFMANY: |
|
1010
977aafc6b8e3
(svn r1509) Const correctness and add static where appropriate while touching the lines anyway
tron
parents:
998
diff
changeset
|
688 |
make_manyofmany(buf, (const char*)desc->b, i); |
0 | 689 |
break; |
690 |
case SDT_BOOLX: |
|
691 |
strcpy(buf, i ? "true" : "false"); |
|
692 |
break; |
|
693 |
default: |
|
694 |
NOT_REACHED(); |
|
695 |
} |
|
696 |
break; |
|
759
a445474d7c21
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
738
diff
changeset
|
697 |
case SDT_STRINGQUOT: |
a445474d7c21
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
738
diff
changeset
|
698 |
sprintf(buf, "\"%s\"", (char*)ptr); |
a445474d7c21
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
738
diff
changeset
|
699 |
break; |
0 | 700 |
case SDT_STRINGBUF: |
701 |
strcpy(buf, (char*)ptr); |
|
702 |
break; |
|
703 |
case SDT_STRING: |
|
704 |
strcpy(buf, *(char**)ptr); |
|
705 |
break; |
|
706 |
case SDT_INTLIST: |
|
707 |
make_intlist(buf, ptr, desc->flags >> 16, desc->flags >> 4 & 7); |
|
708 |
break; |
|
709 |
} |
|
710 |
// the value is different, that means we have to write it to the ini |
|
711 |
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
|
712 |
} |
0 | 713 |
} |
714 |
||
715 |
//*************************** |
|
716 |
// TTD specific INI stuff |
|
717 |
//*************************** |
|
718 |
||
719 |
static const SettingDesc music_settings[] = { |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
720 |
{"playlist", SDT_UINT8, (void*)0, &msf.playlist, NULL}, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
721 |
{"music_vol", SDT_UINT8, (void*)128, &msf.music_vol, NULL}, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
722 |
{"effect_vol",SDT_UINT8, (void*)128, &msf.effect_vol, NULL}, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
723 |
{"custom_1", SDT_INTLIST | SDT_UINT8 | lengthof(msf.custom_1) << 16, NULL, &msf.custom_1, NULL}, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
724 |
{"custom_2", SDT_INTLIST | SDT_UINT8 | lengthof(msf.custom_2) << 16, NULL, &msf.custom_2, NULL}, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
725 |
{"playing", SDT_BOOL, (void*)true, &msf.btn_down, NULL}, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
726 |
{"shuffle", SDT_BOOL, (void*)false, &msf.shuffle, NULL}, |
179
003096efeb9d
(svn r180) -Fix: some more warning fixes for C99 (Tron)
darkvater
parents:
156
diff
changeset
|
727 |
{NULL, 0, NULL, NULL, NULL} |
0 | 728 |
}; |
729 |
||
730 |
static const SettingDesc win32_settings[] = { |
|
179
003096efeb9d
(svn r180) -Fix: some more warning fixes for C99 (Tron)
darkvater
parents:
156
diff
changeset
|
731 |
{"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
|
732 |
{"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
|
733 |
{"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
|
734 |
{"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
|
735 |
{NULL, 0, NULL, NULL, NULL} |
0 | 736 |
}; |
737 |
||
738 |
static const SettingDesc misc_settings[] = { |
|
395
788a9bba0889
(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
|
739 |
{"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"}, |
179
003096efeb9d
(svn r180) -Fix: some more warning fixes for C99 (Tron)
darkvater
parents:
156
diff
changeset
|
740 |
{"news_display_opt", SDT_UINT16, (void*)-1, &_news_display_opt, NULL}, |
003096efeb9d
(svn r180) -Fix: some more warning fixes for C99 (Tron)
darkvater
parents:
156
diff
changeset
|
741 |
{"fullscreen", SDT_BOOL, (void*)false, &_fullscreen, NULL}, |
003096efeb9d
(svn r180) -Fix: some more warning fixes for C99 (Tron)
darkvater
parents:
156
diff
changeset
|
742 |
{"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
|
743 |
{"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
|
744 |
{"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
|
745 |
{"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
|
746 |
{"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
|
747 |
{"cache_sprites", SDT_BOOL, (void*)false, &_cache_sprites, NULL}, |
003096efeb9d
(svn r180) -Fix: some more warning fixes for C99 (Tron)
darkvater
parents:
156
diff
changeset
|
748 |
{"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
|
749 |
{"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
|
750 |
{"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
|
751 |
{NULL, 0, NULL, NULL, NULL} |
0 | 752 |
}; |
753 |
||
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
754 |
#ifdef ENABLE_NETWORK |
0 | 755 |
static const SettingDesc network_settings[] = { |
641
6f202631c443
(svn r1074) Fix: server_bind_ip was set to 255.255.255.255 by default
dominik
parents:
629
diff
changeset
|
756 |
{"sync_freq", SDT_UINT16 | SDT_NOSAVE, (void*)100, &_network_sync_freq, NULL}, |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
757 |
{"frame_freq", SDT_UINT8 | SDT_NOSAVE, (void*)0, &_network_frame_freq, NULL}, |
641
6f202631c443
(svn r1074) Fix: server_bind_ip was set to 255.255.255.255 by default
dominik
parents:
629
diff
changeset
|
758 |
{"server_bind_ip", SDT_STRINGBUF | (lengthof(_network_server_bind_ip_host) << 16), "0.0.0.0", &_network_server_bind_ip_host, NULL}, |
6f202631c443
(svn r1074) Fix: server_bind_ip was set to 255.255.255.255 by default
dominik
parents:
629
diff
changeset
|
759 |
{"server_port", SDT_UINT, (void*)NETWORK_DEFAULT_PORT, &_network_server_port, NULL}, |
675
9be22ffb4625
(svn r1113) -Add: [Network] Added the GUI part for server advertising. When you go
truelight
parents:
643
diff
changeset
|
760 |
{"server_advertise",SDT_BOOL, (void*)false, &_network_advertise, NULL}, |
764
7e1e17b7c7d4
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
759
diff
changeset
|
761 |
{"lan_internet", SDT_UINT8, (void*)0, &_network_lan_internet, NULL}, |
641
6f202631c443
(svn r1074) Fix: server_bind_ip was set to 255.255.255.255 by default
dominik
parents:
629
diff
changeset
|
762 |
{"player_name", SDT_STRINGBUF | (lengthof(_network_player_name) << 16), NULL, &_network_player_name, NULL}, |
1026
02cc18821508
(svn r1527) -Add: RCon (Remote Connection). A server can set:
truelight
parents:
1010
diff
changeset
|
763 |
{"server_password", SDT_STRINGBUF | (lengthof(_network_server_password) << 16), NULL, &_network_server_password, NULL}, |
02cc18821508
(svn r1527) -Add: RCon (Remote Connection). A server can set:
truelight
parents:
1010
diff
changeset
|
764 |
{"rcon_password", SDT_STRINGBUF | (lengthof(_network_rcon_password) << 16), NULL, &_network_rcon_password, NULL}, |
641
6f202631c443
(svn r1074) Fix: server_bind_ip was set to 255.255.255.255 by default
dominik
parents:
629
diff
changeset
|
765 |
{"server_name", SDT_STRINGBUF | (lengthof(_network_server_name) << 16), NULL, &_network_server_name, NULL}, |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
766 |
{"connect_to_ip", SDT_STRINGBUF | (lengthof(_network_default_ip) << 16), NULL, &_network_default_ip, NULL}, |
641
6f202631c443
(svn r1074) Fix: server_bind_ip was set to 255.255.255.255 by default
dominik
parents:
629
diff
changeset
|
767 |
{"network_id", SDT_STRINGBUF | (lengthof(_network_unique_id) << 16), NULL, &_network_unique_id, NULL}, |
690
3afcad69d4f7
(svn r1131) -Add: [Network] Autoclean_companies (set it with 'set autoclean_companies on/off').
truelight
parents:
675
diff
changeset
|
768 |
{"autoclean_companies", SDT_BOOL, (void*)false, &_network_autoclean_companies, NULL}, |
3afcad69d4f7
(svn r1131) -Add: [Network] Autoclean_companies (set it with 'set autoclean_companies on/off').
truelight
parents:
675
diff
changeset
|
769 |
{"autoclean_unprotected", SDT_UINT8, (void*)12, &_network_autoclean_unprotected, NULL}, |
3afcad69d4f7
(svn r1131) -Add: [Network] Autoclean_companies (set it with 'set autoclean_companies on/off').
truelight
parents:
675
diff
changeset
|
770 |
{"autoclean_protected", SDT_UINT8, (void*)36, &_network_autoclean_protected, NULL}, |
785
bba7b3b35dec
(svn r1252) -Add: [Network] With 'set restart_game_date' you can set the date for in
truelight
parents:
774
diff
changeset
|
771 |
{"restart_game_date", SDT_UINT16, (void*)0, &_network_restart_game_date, NULL}, |
641
6f202631c443
(svn r1074) Fix: server_bind_ip was set to 255.255.255.255 by default
dominik
parents:
629
diff
changeset
|
772 |
{NULL, 0, NULL, NULL, NULL} |
0 | 773 |
}; |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
774 |
#endif /* ENABLE_NETWORK */ |
0 | 775 |
|
776 |
static const SettingDesc debug_settings[] = { |
|
179
003096efeb9d
(svn r180) -Fix: some more warning fixes for C99 (Tron)
darkvater
parents:
156
diff
changeset
|
777 |
{"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
|
778 |
{"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
|
779 |
{"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
|
780 |
{"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
|
781 |
{NULL, 0, NULL, NULL, NULL} |
0 | 782 |
}; |
783 |
||
1500
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1460
diff
changeset
|
784 |
/* The settings showed when opened in the intro-menu. These values also are saved to |
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1460
diff
changeset
|
785 |
* openttd.cfg, thus _opt_newgame is used here (not _opt which is used ingame with loaded games!) */ |
0 | 786 |
static const SettingDesc gameopt_settings[] = { |
1500
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1460
diff
changeset
|
787 |
{"diff_level", SDT_UINT8, (void*)9, &_opt_newgame.diff_level, NULL}, |
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1460
diff
changeset
|
788 |
{"diff_custom", SDT_INTLIST | SDT_UINT32 | (sizeof(GameDifficulty)/4) << 16, NULL, &_opt_newgame.diff, NULL}, |
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1460
diff
changeset
|
789 |
{"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" }, |
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1460
diff
changeset
|
790 |
{"distances", SDT_UINT8 | SDT_ONEOFMANY, (void*)1, &_opt_newgame.kilometers, "imperial|metric" }, |
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1460
diff
changeset
|
791 |
{"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" }, |
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1460
diff
changeset
|
792 |
{"landscape", SDT_UINT8 | SDT_ONEOFMANY, (void*)0, &_opt_newgame.landscape, "normal|hilly|desert|candy" }, |
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1460
diff
changeset
|
793 |
{"autosave", SDT_UINT8 | SDT_ONEOFMANY, (void*)1, &_opt_newgame.autosave, "off|monthly|quarterly|half year|yearly" }, |
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1460
diff
changeset
|
794 |
{"road_side", SDT_UINT8 | SDT_ONEOFMANY, (void*)1, &_opt_newgame.road_side, "left|right" }, |
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1460
diff
changeset
|
795 |
{NULL, 0, NULL, NULL, NULL} |
0 | 796 |
}; |
797 |
||
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
798 |
// The player-based settings (are not send over the network) |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
799 |
// Not everything can just be added to this list. For example, service_interval |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
800 |
// can not be done, because every client assigns the service_interval value to the |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
801 |
// v->service_interval, meaning that every client assigns his value to the interval. |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
802 |
// If the setting was player-based, that would mean that vehicles could deside on |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
803 |
// different moments that they are heading back to a service depot, causing desyncs |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
804 |
// on a massive scale. |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
805 |
// Short, you can only add settings that does stuff for the screen, GUI, that kind |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
806 |
// of stuff. |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
807 |
static const SettingDesc patch_player_settings[] = { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
808 |
{"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
|
809 |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
810 |
{"lost_train_days", SDT_UINT16, (void*)180, &_patches.lost_train_days, NULL}, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
811 |
{"train_income_warn", SDT_BOOL, (void*)true, &_patches.train_income_warn, NULL}, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
812 |
{"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
|
813 |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
814 |
{"status_long_date", SDT_BOOL, (void*)true, &_patches.status_long_date, NULL}, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
815 |
{"show_finances", SDT_BOOL, (void*)true, &_patches.show_finances, NULL}, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
816 |
{"autoscroll", SDT_BOOL, (void*)false, &_patches.autoscroll, NULL}, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
817 |
{"errmsg_duration", SDT_UINT8, (void*)5, &_patches.errmsg_duration, NULL}, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
818 |
{"toolbar_pos", SDT_UINT8, (void*)0, &_patches.toolbar_pos, NULL}, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
819 |
{"keep_all_autosave", SDT_BOOL, (void*)false, &_patches.keep_all_autosave, NULL}, |
643
a9c84d04eacb
(svn r1076) Feature: Patch setting to autosave the game on exit
dominik
parents:
641
diff
changeset
|
820 |
{"autosave_on_exit", SDT_BOOL, (void*)false, &_patches.autosave_on_exit, NULL}, |
179
003096efeb9d
(svn r180) -Fix: some more warning fixes for C99 (Tron)
darkvater
parents:
156
diff
changeset
|
821 |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
822 |
{"bridge_pillars", SDT_BOOL, (void*)true, &_patches.bridge_pillars, NULL}, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
823 |
{"invisible_trees", SDT_BOOL, (void*)false, &_patches.invisible_trees, NULL}, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
824 |
{"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
|
825 |
|
545
ab2098c1da75
(svn r945) -Fix: [Network] Terraform callback went wrong in merge
truelight
parents:
543
diff
changeset
|
826 |
{"window_snap_radius", SDT_UINT8, (void*)10, &_patches.window_snap_radius, NULL}, |
ab2098c1da75
(svn r945) -Fix: [Network] Terraform callback went wrong in merge
truelight
parents:
543
diff
changeset
|
827 |
|
812
65ecc321b3db
(svn r1283) -Add: AutoRenew is now a client-side patch instead of a game-side patch
truelight
parents:
794
diff
changeset
|
828 |
{"autorenew", SDT_BOOL, (void*)false, &_patches.autorenew, NULL}, |
65ecc321b3db
(svn r1283) -Add: AutoRenew is now a client-side patch instead of a game-side patch
truelight
parents:
794
diff
changeset
|
829 |
{"autorenew_months", SDT_INT16, (void*)-6, &_patches.autorenew_months, NULL}, |
65ecc321b3db
(svn r1283) -Add: AutoRenew is now a client-side patch instead of a game-side patch
truelight
parents:
794
diff
changeset
|
830 |
{"autorenew_money", SDT_INT32, (void*)100000,&_patches.autorenew_money, NULL}, |
65ecc321b3db
(svn r1283) -Add: AutoRenew is now a client-side patch instead of a game-side patch
truelight
parents:
794
diff
changeset
|
831 |
|
835
f6a341f541d7
(svn r1312) -Add: Patch which is on by default: population in label of the town
truelight
parents:
812
diff
changeset
|
832 |
{"population_in_label", SDT_BOOL, (void*)true, &_patches.population_in_label, NULL}, |
f6a341f541d7
(svn r1312) -Add: Patch which is on by default: population in label of the town
truelight
parents:
812
diff
changeset
|
833 |
|
179
003096efeb9d
(svn r180) -Fix: some more warning fixes for C99 (Tron)
darkvater
parents:
156
diff
changeset
|
834 |
{NULL, 0, NULL, NULL, NULL} |
0 | 835 |
}; |
836 |
||
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
837 |
// Non-static, needed in network_server.c |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
838 |
const SettingDesc patch_settings[] = { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
839 |
{"build_on_slopes", SDT_BOOL, (void*)true, &_patches.build_on_slopes, NULL}, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
840 |
{"mammoth_trains", SDT_BOOL, (void*)true, &_patches.mammoth_trains, NULL}, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
841 |
{"join_stations", SDT_BOOL, (void*)true, &_patches.join_stations, NULL}, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
842 |
{"station_spread", SDT_UINT8, (void*)12, &_patches.station_spread, NULL}, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
843 |
{"full_load_any", SDT_BOOL, (void*)true, &_patches.full_load_any, NULL}, |
951
759ca1b993db
(svn r1441) Fixed a couple of warnings, and removed a pointless assert
celestar
parents:
930
diff
changeset
|
844 |
{"modified_catchment", SDT_BOOL, (void*)true, &_patches.modified_catchment, NULL}, |
568
b0d0df062880
(svn r979) Allow more realistically sized catchment areas
Celestar
parents:
545
diff
changeset
|
845 |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
846 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
847 |
{"inflation", SDT_BOOL, (void*)true, &_patches.inflation, NULL}, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
848 |
{"selectgoods", SDT_BOOL, (void*)true, &_patches.selectgoods, NULL}, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
849 |
{"longbridges", SDT_BOOL, (void*)true, &_patches.longbridges, NULL}, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
850 |
{"gotodepot", SDT_BOOL, (void*)true, &_patches.gotodepot, NULL}, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
851 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
852 |
{"build_rawmaterial_ind", SDT_BOOL, (void*)false, &_patches.build_rawmaterial_ind,NULL}, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
853 |
{"multiple_industry_per_town",SDT_BOOL, (void*)false, &_patches.multiple_industry_per_town, NULL}, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
854 |
{"same_industry_close", SDT_BOOL, (void*)false, &_patches.same_industry_close, NULL}, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
855 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
856 |
{"signal_side", SDT_BOOL, (void*)true, &_patches.signal_side, NULL}, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
857 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
858 |
{"new_nonstop", SDT_BOOL, (void*)false, &_patches.new_nonstop, NULL}, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
859 |
{"roadveh_queue", SDT_BOOL, (void*)true, &_patches.roadveh_queue, NULL}, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
860 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
861 |
{"snow_line_height", SDT_UINT8, (void*)7, &_patches.snow_line_height, NULL}, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
862 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
863 |
{"bribe", SDT_BOOL, (void*)true, &_patches.bribe, NULL}, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
864 |
{"new_depot_finding", SDT_BOOL, (void*)false, &_patches.new_depot_finding, NULL}, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
865 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
866 |
{"nonuniform_stations", SDT_BOOL, (void*)true, &_patches.nonuniform_stations, NULL}, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
867 |
{"always_small_airport",SDT_BOOL, (void*)false, &_patches.always_small_airport, NULL}, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
868 |
{"realistic_acceleration",SDT_BOOL, (void*)false, &_patches.realistic_acceleration, NULL}, |
1247 | 869 |
{"forbid_90_deg", SDT_BOOL, (void*)false, &_patches.forbid_90_deg, NULL}, |
545
ab2098c1da75
(svn r945) -Fix: [Network] Terraform callback went wrong in merge
truelight
parents:
543
diff
changeset
|
870 |
{"improved_load", SDT_BOOL, (void*)false, &_patches.improved_load, NULL}, |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
871 |
|
1282
ea2ae881814c
(svn r1786) -Fix: unitnumber is increased to 16bit, so now you can have up to 5000
truelight
parents:
1271
diff
changeset
|
872 |
{"max_trains", SDT_UINT16, (void*)500, &_patches.max_trains, NULL}, |
ea2ae881814c
(svn r1786) -Fix: unitnumber is increased to 16bit, so now you can have up to 5000
truelight
parents:
1271
diff
changeset
|
873 |
{"max_roadveh", SDT_UINT16, (void*)500, &_patches.max_roadveh, NULL}, |
ea2ae881814c
(svn r1786) -Fix: unitnumber is increased to 16bit, so now you can have up to 5000
truelight
parents:
1271
diff
changeset
|
874 |
{"max_aircraft", SDT_UINT16, (void*)200, &_patches.max_aircraft, NULL}, |
ea2ae881814c
(svn r1786) -Fix: unitnumber is increased to 16bit, so now you can have up to 5000
truelight
parents:
1271
diff
changeset
|
875 |
{"max_ships", SDT_UINT16, (void*)300, &_patches.max_ships, NULL}, |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
876 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
877 |
{"servint_ispercent", SDT_BOOL, (void*)false, &_patches.servint_ispercent, NULL}, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
878 |
{"servint_trains", SDT_UINT16, (void*)150, &_patches.servint_trains, NULL}, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
879 |
{"servint_roadveh", SDT_UINT16, (void*)150, &_patches.servint_roadveh, NULL}, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
880 |
{"servint_ships", SDT_UINT16, (void*)360, &_patches.servint_ships, NULL}, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
881 |
{"servint_aircraft", SDT_UINT16, (void*)100, &_patches.servint_aircraft, NULL}, |
1037
4fbbb01cf87b
(svn r1538) -Feature: [988816] Disable servicing when breakdowns set to none (jaguar7)
darkvater
parents:
1030
diff
changeset
|
882 |
{"no_servicing_if_no_breakdowns", SDT_BOOL, (void*)0, &_patches.no_servicing_if_no_breakdowns, NULL}, |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
883 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
884 |
{"new_pathfinding", SDT_BOOL, (void*)true, &_patches.new_pathfinding, NULL}, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
885 |
{"pf_maxlength", SDT_UINT16, (void*)512, &_patches.pf_maxlength, NULL}, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
886 |
{"pf_maxdepth", SDT_UINT8, (void*)16, &_patches.pf_maxdepth, NULL}, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
887 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
888 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
889 |
{"ai_disable_veh_train",SDT_BOOL, (void*)false, &_patches.ai_disable_veh_train, NULL}, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
890 |
{"ai_disable_veh_roadveh",SDT_BOOL, (void*)false, &_patches.ai_disable_veh_roadveh, NULL}, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
891 |
{"ai_disable_veh_aircraft",SDT_BOOL,(void*)false, &_patches.ai_disable_veh_aircraft,NULL}, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
892 |
{"ai_disable_veh_ship", SDT_BOOL, (void*)false, &_patches.ai_disable_veh_ship, NULL}, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
893 |
{"starting_date", SDT_UINT32, (void*)1950, &_patches.starting_date, NULL}, |
998
c90459c24842
(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
|
894 |
{"ending_date", SDT_UINT32, (void*)2051, &_patches.ending_date, NULL}, |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
895 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
896 |
{"colored_news_date", SDT_UINT32, (void*)2000, &_patches.colored_news_date, NULL}, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
897 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
898 |
{"extra_dynamite", SDT_BOOL, (void*)false, &_patches.extra_dynamite, NULL}, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
899 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
900 |
{"never_expire_vehicles",SDT_BOOL, (void*)false, &_patches.never_expire_vehicles,NULL}, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
901 |
{"extend_vehicle_life", SDT_UINT8, (void*)0, &_patches.extend_vehicle_life, NULL}, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
902 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
903 |
{"auto_euro", SDT_BOOL, (void*)true, &_patches.auto_euro, NULL}, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
904 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
905 |
{"serviceathelipad", SDT_BOOL, (void*)true, &_patches.serviceathelipad, NULL}, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
906 |
{"smooth_economy", SDT_BOOL, (void*)true, &_patches.smooth_economy, NULL}, |
930
ab42e283749d
(svn r1418) -Feature: [1098254] (dis)Allow Shares. Add patch options to allow buying/selling of shares (Hackykid)
darkvater
parents:
898
diff
changeset
|
907 |
{"allow_shares", SDT_BOOL, (void*)true, &_patches.allow_shares, NULL}, |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
908 |
{"dist_local_authority",SDT_UINT8, (void*)20, &_patches.dist_local_authority, NULL}, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
909 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
910 |
{"wait_oneway_signal", SDT_UINT8, (void*)15, &_patches.wait_oneway_signal, NULL}, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
911 |
{"wait_twoway_signal", SDT_UINT8, (void*)41, &_patches.wait_twoway_signal, NULL}, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
912 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
913 |
{"ainew_active", SDT_BOOL, (void*)false, &_patches.ainew_active, NULL}, |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
914 |
|
1218 | 915 |
{"map_x", SDT_UINT32, (void*)8, &_patches.map_x, NULL}, |
916 |
{"map_y", SDT_UINT32, (void*)8, &_patches.map_y, NULL}, |
|
917 |
||
1271
322ab55eca62
(svn r1775) -Fix: The NPF patch setting was not synced in network.
truelight
parents:
1258
diff
changeset
|
918 |
/* New Path Finding */ |
322ab55eca62
(svn r1775) -Fix: The NPF patch setting was not synced in network.
truelight
parents:
1258
diff
changeset
|
919 |
{"new_pathfinding_all", SDT_BOOL, (void*)false, &_patches.new_pathfinding_all, NULL}, |
322ab55eca62
(svn r1775) -Fix: The NPF patch setting was not synced in network.
truelight
parents:
1258
diff
changeset
|
920 |
|
322ab55eca62
(svn r1775) -Fix: The NPF patch setting was not synced in network.
truelight
parents:
1258
diff
changeset
|
921 |
/* When a red signal is encountered, a small detour can be made around |
322ab55eca62
(svn r1775) -Fix: The NPF patch setting was not synced in network.
truelight
parents:
1258
diff
changeset
|
922 |
* it. This specifically occurs when a track is doubled, in which case |
322ab55eca62
(svn r1775) -Fix: The NPF patch setting was not synced in network.
truelight
parents:
1258
diff
changeset
|
923 |
* the detour is typically 2 tiles. It is also often used at station |
322ab55eca62
(svn r1775) -Fix: The NPF patch setting was not synced in network.
truelight
parents:
1258
diff
changeset
|
924 |
* entrances, when there is a choice of multiple platforms. If we take |
322ab55eca62
(svn r1775) -Fix: The NPF patch setting was not synced in network.
truelight
parents:
1258
diff
changeset
|
925 |
* a typical 4 platform station, the detour is 4 tiles. To properly |
322ab55eca62
(svn r1775) -Fix: The NPF patch setting was not synced in network.
truelight
parents:
1258
diff
changeset
|
926 |
* support larger stations we increase this value. |
322ab55eca62
(svn r1775) -Fix: The NPF patch setting was not synced in network.
truelight
parents:
1258
diff
changeset
|
927 |
* We want to prevent that trains that want to leave at one side of a |
322ab55eca62
(svn r1775) -Fix: The NPF patch setting was not synced in network.
truelight
parents:
1258
diff
changeset
|
928 |
* station, leave through the other side, turn around, enter the |
322ab55eca62
(svn r1775) -Fix: The NPF patch setting was not synced in network.
truelight
parents:
1258
diff
changeset
|
929 |
* station on another platform and exit the station on the right side |
322ab55eca62
(svn r1775) -Fix: The NPF patch setting was not synced in network.
truelight
parents:
1258
diff
changeset
|
930 |
* again, just because the sign at the right side was red. If we take |
322ab55eca62
(svn r1775) -Fix: The NPF patch setting was not synced in network.
truelight
parents:
1258
diff
changeset
|
931 |
* a typical 5 length station, this detour is 10 or 11 tiles (not |
322ab55eca62
(svn r1775) -Fix: The NPF patch setting was not synced in network.
truelight
parents:
1258
diff
changeset
|
932 |
* sure), so we set the default penalty at 10 (the station tile |
322ab55eca62
(svn r1775) -Fix: The NPF patch setting was not synced in network.
truelight
parents:
1258
diff
changeset
|
933 |
* penalty will further prevent this */ |
322ab55eca62
(svn r1775) -Fix: The NPF patch setting was not synced in network.
truelight
parents:
1258
diff
changeset
|
934 |
{"npf_rail_firstred_penalty", SDT_UINT32, (void*)(10 * NPF_TILE_LENGTH), &_patches.npf_rail_firstred_penalty, NULL}, |
1459
19333d7f99b3
(svn r1963) - Add: [NPF] Penalty for a red signal that is the last signal on the path.
matthijs
parents:
1422
diff
changeset
|
935 |
/* This penalty is for when the last signal before the target is red. |
19333d7f99b3
(svn r1963) - Add: [NPF] Penalty for a red signal that is the last signal on the path.
matthijs
parents:
1422
diff
changeset
|
936 |
* This is useful for train stations, where there are multiple |
19333d7f99b3
(svn r1963) - Add: [NPF] Penalty for a red signal that is the last signal on the path.
matthijs
parents:
1422
diff
changeset
|
937 |
* platforms to choose from, which lie in different signal blocks. |
19333d7f99b3
(svn r1963) - Add: [NPF] Penalty for a red signal that is the last signal on the path.
matthijs
parents:
1422
diff
changeset
|
938 |
* Every target in a occupied signal block (ie an occupied platform) |
19333d7f99b3
(svn r1963) - Add: [NPF] Penalty for a red signal that is the last signal on the path.
matthijs
parents:
1422
diff
changeset
|
939 |
* will get this penalty. |
19333d7f99b3
(svn r1963) - Add: [NPF] Penalty for a red signal that is the last signal on the path.
matthijs
parents:
1422
diff
changeset
|
940 |
*/ |
19333d7f99b3
(svn r1963) - Add: [NPF] Penalty for a red signal that is the last signal on the path.
matthijs
parents:
1422
diff
changeset
|
941 |
{"npf_rail_lastred_penalty", SDT_UINT32, (void*)(10 * NPF_TILE_LENGTH), &_patches.npf_rail_lastred_penalty, NULL}, |
1271
322ab55eca62
(svn r1775) -Fix: The NPF patch setting was not synced in network.
truelight
parents:
1258
diff
changeset
|
942 |
/* When a train plans a route over a station tile, this penalty is |
322ab55eca62
(svn r1775) -Fix: The NPF patch setting was not synced in network.
truelight
parents:
1258
diff
changeset
|
943 |
* applied. We want that trains plan a route around a typical, 4x5 |
322ab55eca62
(svn r1775) -Fix: The NPF patch setting was not synced in network.
truelight
parents:
1258
diff
changeset
|
944 |
* station, which means two tiles to the right, and two tiles back to |
322ab55eca62
(svn r1775) -Fix: The NPF patch setting was not synced in network.
truelight
parents:
1258
diff
changeset
|
945 |
* the left around it, or 5 tiles of station through it. If we assign |
322ab55eca62
(svn r1775) -Fix: The NPF patch setting was not synced in network.
truelight
parents:
1258
diff
changeset
|
946 |
* a penalty of 1 tile for every station tile passed, the route will |
322ab55eca62
(svn r1775) -Fix: The NPF patch setting was not synced in network.
truelight
parents:
1258
diff
changeset
|
947 |
* be around it. |
322ab55eca62
(svn r1775) -Fix: The NPF patch setting was not synced in network.
truelight
parents:
1258
diff
changeset
|
948 |
*/ |
322ab55eca62
(svn r1775) -Fix: The NPF patch setting was not synced in network.
truelight
parents:
1258
diff
changeset
|
949 |
{"npf_rail_station_penalty", SDT_UINT32, (void*)(1 * NPF_TILE_LENGTH), &_patches.npf_rail_station_penalty, NULL}, |
322ab55eca62
(svn r1775) -Fix: The NPF patch setting was not synced in network.
truelight
parents:
1258
diff
changeset
|
950 |
{"npf_rail_slope_penalty", SDT_UINT32, (void*)(1 * NPF_TILE_LENGTH), &_patches.npf_rail_slope_penalty, NULL}, |
1460 | 951 |
{"npf_rail_curve_penalty", SDT_UINT32, (void*)(1), &_patches.npf_rail_curve_penalty, NULL}, |
1271
322ab55eca62
(svn r1775) -Fix: The NPF patch setting was not synced in network.
truelight
parents:
1258
diff
changeset
|
952 |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
953 |
{NULL, 0, NULL, NULL, NULL} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
954 |
}; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
955 |
|
759
a445474d7c21
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
738
diff
changeset
|
956 |
static const SettingDesc currency_settings[] = { |
a445474d7c21
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
738
diff
changeset
|
957 |
{"rate", SDT_UINT16, (void*)1, &_currency_specs[23].rate, NULL}, |
a445474d7c21
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
738
diff
changeset
|
958 |
{"separator", SDT_STRINGQUOT | (2) << 16, ".", &_currency_specs[23].separator, NULL}, |
a445474d7c21
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
738
diff
changeset
|
959 |
{"to_euro", SDT_UINT16, (void*)0, &_currency_specs[23].to_euro, NULL}, |
788
951b52443d48
(svn r1255) Renamed "postfix" to "suffix", for strings and variable names
dominik
parents:
785
diff
changeset
|
960 |
{"prefix", SDT_STRINGQUOT | (16) << 16, NULL, &_currency_specs[23].prefix, NULL}, |
951b52443d48
(svn r1255) Renamed "postfix" to "suffix", for strings and variable names
dominik
parents:
785
diff
changeset
|
961 |
{"suffix", SDT_STRINGQUOT | (16) << 16, " credits", &_currency_specs[23].suffix, NULL}, |
759
a445474d7c21
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
738
diff
changeset
|
962 |
{NULL, 0, NULL, NULL, NULL} |
a445474d7c21
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
738
diff
changeset
|
963 |
}; |
a445474d7c21
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
738
diff
changeset
|
964 |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
965 |
typedef void SettingDescProc(IniFile *ini, const SettingDesc *desc, const void *grpname); |
0 | 966 |
|
967 |
static void HandleSettingDescs(IniFile *ini, SettingDescProc *proc) |
|
968 |
{ |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
969 |
proc(ini, misc_settings, "misc"); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
970 |
proc(ini, win32_settings, "win32"); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
971 |
#ifdef ENABLE_NETWORK |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
972 |
proc(ini, network_settings, "network"); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
973 |
#endif /* ENABLE_NETWORK */ |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
974 |
proc(ini, music_settings, "music"); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
975 |
proc(ini, gameopt_settings, "gameopt"); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
976 |
proc(ini, patch_settings, "patches"); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
977 |
proc(ini, patch_player_settings, "patches"); |
759
a445474d7c21
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
738
diff
changeset
|
978 |
proc(ini, currency_settings,"currency"); |
0 | 979 |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
523
diff
changeset
|
980 |
proc(ini, debug_settings, "debug"); |
0 | 981 |
} |
982 |
||
710
2a13862fe86b
(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
|
983 |
// loads all items from a *grpname section into the **list |
2a13862fe86b
(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
|
984 |
static void LoadList(IniFile *ini, const char *grpname, char **list, int len) |
0 | 985 |
{ |
710
2a13862fe86b
(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
|
986 |
IniGroup *group = ini_getgroup(ini, grpname, -1); |
0 | 987 |
IniItem *item; |
988 |
int i; |
|
989 |
||
990 |
if (!group) |
|
991 |
return; |
|
705
71cf9f0d7e7f
(svn r1157) Enhanced the config file (openttd.cfg) to use another section type. "List sections" as opposed to "variable sections" contain a list of values, separated by a new line. This is now used for the [newgrf] group. You have to edit each line in this section from e.g. "0 = firstset.grf" to only "firstset.grf".
dominik
parents:
690
diff
changeset
|
992 |
item = group->item; |
710
2a13862fe86b
(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
|
993 |
for ( i=0; i != len; i++) { |
2a13862fe86b
(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
|
994 |
if (item == NULL) break; |
2a13862fe86b
(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
|
995 |
list[i] = strdup(item->value); |
705
71cf9f0d7e7f
(svn r1157) Enhanced the config file (openttd.cfg) to use another section type. "List sections" as opposed to "variable sections" contain a list of values, separated by a new line. This is now used for the [newgrf] group. You have to edit each line in this section from e.g. "0 = firstset.grf" to only "firstset.grf".
dominik
parents:
690
diff
changeset
|
996 |
item = item->next; |
0 | 997 |
} |
998 |
} |
|
999 |
||
738
b96ab9e63d22
(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
|
1000 |
static void SaveList(IniFile *ini, const char *grpname, char **list, int len) |
b96ab9e63d22
(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
|
1001 |
{ |
b96ab9e63d22
(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
|
1002 |
IniGroup *group = ini_getgroup(ini, grpname, -1); |
774
bb9ec520a1b1
(svn r1240) -Fix: OpenTTD once again compiles if ENABLE_NETWORK is disabled.
darkvater
parents:
764
diff
changeset
|
1003 |
IniItem *item = NULL; |
738
b96ab9e63d22
(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
|
1004 |
int i; |
b96ab9e63d22
(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
|
1005 |
bool first = true; |
b96ab9e63d22
(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
|
1006 |
|
b96ab9e63d22
(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
|
1007 |
if (!group) |
b96ab9e63d22
(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
|
1008 |
return; |
774
bb9ec520a1b1
(svn r1240) -Fix: OpenTTD once again compiles if ENABLE_NETWORK is disabled.
darkvater
parents:
764
diff
changeset
|
1009 |
for (i = 0; i != len; i++) { |
898
3413f88ae525
(svn r1384) Fix: Sometimes when lists were saved, a lot of blank lines had been added
dominik
parents:
841
diff
changeset
|
1010 |
if (list[i] == NULL || list[i][0] == '\0') continue; |
738
b96ab9e63d22
(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
|
1011 |
|
b96ab9e63d22
(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
|
1012 |
if (first) { // add first item to the head of the group |
b96ab9e63d22
(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
|
1013 |
item = ini_item_alloc(group, list[i], strlen(list[i])); |
b96ab9e63d22
(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
|
1014 |
item->value = item->name; |
b96ab9e63d22
(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
|
1015 |
group->item = item; |
b96ab9e63d22
(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
|
1016 |
first = false; |
b96ab9e63d22
(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
|
1017 |
} else { // all other items are attached to the previous one |
b96ab9e63d22
(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
|
1018 |
item->next = ini_item_alloc(group, list[i], strlen(list[i])); |
b96ab9e63d22
(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
|
1019 |
item = item->next; |
b96ab9e63d22
(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
|
1020 |
item->value = item->name; |
b96ab9e63d22
(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
|
1021 |
} |
b96ab9e63d22
(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
|
1022 |
} |
b96ab9e63d22
(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
|
1023 |
} |
b96ab9e63d22
(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
|
1024 |
|
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1037
diff
changeset
|
1025 |
void LoadFromConfig(void) |
0 | 1026 |
{ |
1027 |
IniFile *ini = ini_load(_config_file); |
|
1028 |
HandleSettingDescs(ini, load_setting_desc); |
|
710
2a13862fe86b
(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
|
1029 |
LoadList(ini, "newgrf", _newgrf_files, lengthof(_newgrf_files)); |
738
b96ab9e63d22
(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
|
1030 |
LoadList(ini, "servers", _network_host_list, lengthof(_network_host_list)); |
841
4874b9ce2765
(svn r1322) -Add: banning system (mostly tnx to guru3)
truelight
parents:
835
diff
changeset
|
1031 |
LoadList(ini, "bans", _network_ban_list, lengthof(_network_ban_list)); |
0 | 1032 |
ini_free(ini); |
1033 |
} |
|
1034 |
||
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1037
diff
changeset
|
1035 |
void SaveToConfig(void) |
0 | 1036 |
{ |
1037 |
IniFile *ini = ini_load(_config_file); |
|
1038 |
HandleSettingDescs(ini, save_setting_desc); |
|
738
b96ab9e63d22
(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
|
1039 |
SaveList(ini, "servers", _network_host_list, lengthof(_network_host_list)); |
841
4874b9ce2765
(svn r1322) -Add: banning system (mostly tnx to guru3)
truelight
parents:
835
diff
changeset
|
1040 |
SaveList(ini, "bans", _network_ban_list, lengthof(_network_ban_list)); |
0 | 1041 |
ini_save(_config_file, ini); |
1042 |
ini_free(ini); |
|
1043 |
} |