1 |
#include <windows.h> |
2 |
#include <string.h> |
3 |
#include <time.h> |
4 |
|
5 |
#include "Daodan_Config.h" |
6 |
#include "Daodan_Patch.h" |
7 |
#include "Patches/Utility.h" |
8 |
|
9 |
#include "Oni/Oni.h" |
10 |
#include "_Version.h" |
11 |
|
12 |
#include "Inifile_Reader.h" |
13 |
|
14 |
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0])) |
15 |
|
16 |
static const char* iniName = "daodan.ini"; |
17 |
static const char* helpFile = "daodan_help.txt"; |
18 |
|
19 |
static const char* defaultSection = "options"; |
20 |
|
21 |
static char invalidCurParamaters[2000] = ""; |
22 |
static char invalidTotalParamaters[4000] = ""; |
23 |
|
24 |
void DDrConfig_PrintHelp(); |
25 |
|
26 |
|
27 |
ConfigSection_t config[] = { |
28 |
{ "", "Command line only", { |
29 |
{ "help", |
30 |
"Generates this help file.", |
31 |
C_CMD, |
32 |
{.intBoolVal = 0}, |
33 |
{.callback = DDrConfig_PrintHelp} }, |
34 |
{ 0, 0, 0, {0}, {0} } |
35 |
} }, |
36 |
{ "devmode", "Developer Mode", { |
37 |
{ "highres_console", |
38 |
"Fixes bug where console line becomes invisible at higher resolutions.", |
39 |
C_BOOL, |
40 |
{.intBoolVal = true}, |
41 |
{.intBoolVal = true} }, |
42 |
{ "showtriggervolumes", |
43 |
"Allows BSL variable \"show_triggervolumes\" and Ctrl+Shift+X (in devmode) to work.", |
44 |
C_BOOL, |
45 |
{.intBoolVal = true}, |
46 |
{.intBoolVal = true} }, |
47 |
{ 0, 0, 0, {0}, {0} } |
48 |
} }, |
49 |
{ "gameplay", "Gameplay", { |
50 |
{ "cheatsenabled", |
51 |
"Enables cheats without having to beat the game first.", |
52 |
C_BOOL, |
53 |
{.intBoolVal = true}, |
54 |
{.intBoolVal = true} }, |
55 |
{ "cheattable", |
56 |
"Replaces Oni's cheat table with table that includes new cheats including devmode.", |
57 |
C_BOOL, |
58 |
{.intBoolVal = true}, |
59 |
{.intBoolVal = true} }, |
60 |
{ "cooldowntimer", |
61 |
"Disables weapon cooldown exploit.", |
62 |
C_BOOL, |
63 |
{.intBoolVal = true}, |
64 |
{.intBoolVal = true} }, |
65 |
{ "kickguns", |
66 |
"EXPERIMENTAL! Unfinished, do not use.", |
67 |
C_BOOL, |
68 |
{.intBoolVal = false}, |
69 |
{.intBoolVal = false} }, |
70 |
{ "pathfinding", |
71 |
"Size of pathfinding grid cache increased by eight times in order to prevent crashes in large levels.", |
72 |
C_BOOL, |
73 |
{.intBoolVal = true}, |
74 |
{.intBoolVal = true} }, |
75 |
{ "projaware", |
76 |
"Allows AI to dodge incoming gunfire properly.", |
77 |
C_BOOL, |
78 |
{.intBoolVal = true}, |
79 |
{.intBoolVal = true} }, |
80 |
{ "throwtest", |
81 |
"EXPERIMENTAL! Experiment with allowing enemies to be thrown over railings.", |
82 |
C_BOOL, |
83 |
{.intBoolVal = false}, |
84 |
{.intBoolVal = false} }, |
85 |
{ "wpfadetime", |
86 |
"Adds working function for existing BSL command wp_fadetime, sets fade time to 4800.", |
87 |
C_BOOL, |
88 |
{.intBoolVal = true}, |
89 |
{.intBoolVal = true} }, |
90 |
{ 0, 0, 0, {0}, {0} } |
91 |
} }, |
92 |
{ "graphics", "Graphics", { |
93 |
{ "binkplay", |
94 |
"Fix binkplay calls to use GDI and outro same mode as intro.", |
95 |
C_BOOL, |
96 |
{.intBoolVal = true}, |
97 |
{.intBoolVal = true} }, |
98 |
{ "daodangl", |
99 |
"Provides an improved windowed mode (-noswitch).", |
100 |
C_BOOL, |
101 |
{.intBoolVal = true}, |
102 |
{.intBoolVal = true} }, |
103 |
{ "displayenum", |
104 |
"Offers a more accurate list of available display modes in the Options menu.", |
105 |
C_BOOL, |
106 |
{.intBoolVal = true}, |
107 |
{.intBoolVal = true} }, |
108 |
{ "gamma", |
109 |
"Enable gamma slider in fullscreen, disable in windowed mode.", |
110 |
C_BOOL, |
111 |
{.intBoolVal = true}, |
112 |
{.intBoolVal = true} }, |
113 |
{ "newweap", |
114 |
"Standing above a weapon displays a message containing the weapon name and amount of ammo.", |
115 |
C_BOOL, |
116 |
{.intBoolVal = true}, |
117 |
{.intBoolVal = true} }, |
118 |
{ "optionsvisible", |
119 |
"Always show options button in main menu, even when pausing from a game.", |
120 |
C_BOOL, |
121 |
{.intBoolVal = true}, |
122 |
{.intBoolVal = true} }, |
123 |
{ "showalllasersights", |
124 |
"Show all (also enemies') weapon lasersights.", |
125 |
C_BOOL, |
126 |
{.intBoolVal = false}, |
127 |
{.intBoolVal = false} }, |
128 |
{ "widescreenportraits", |
129 |
"Prevents fly-in portraits from being stretched when playing in widescreen resolutions.", |
130 |
C_BOOL, |
131 |
{.intBoolVal = true}, |
132 |
{.intBoolVal = true} }, |
133 |
{ 0, 0, 0, {0}, {0} } |
134 |
} }, |
135 |
{ "language", "Language", { |
136 |
{ "chinese", |
137 |
"Allow for chinese fonts to be shown if the required DLL is available.", |
138 |
C_BOOL, |
139 |
{.intBoolVal = true}, |
140 |
{.intBoolVal = true} }, |
141 |
{ "fonttexturecache", |
142 |
"Doubles size of font texture cache.", |
143 |
C_BOOL, |
144 |
{.intBoolVal = true}, |
145 |
{.intBoolVal = true} }, |
146 |
{ "language", |
147 |
"Localization for hardcoded strings (e.g. \"Savepoints\").", |
148 |
C_STRING, |
149 |
{.stringVal = "en"}, |
150 |
{.stringVal = "en"} }, |
151 |
{ "nomultibyte", |
152 |
"Enables languages which use multibyte coding (such as Chinese).", |
153 |
C_BOOL, |
154 |
{.intBoolVal = true}, |
155 |
{.intBoolVal = true} }, |
156 |
{ 0, 0, 0, {0}, {0} } |
157 |
} }, |
158 |
{ "modding", "Modding", { |
159 |
{ "argb8888", |
160 |
"Allows using textures with ARGB8888.", |
161 |
C_BOOL, |
162 |
{.intBoolVal = true}, |
163 |
{.intBoolVal = true} }, |
164 |
{ "d_regen", |
165 |
"Enables script command d_regen (query/set regeneration for any character).", |
166 |
C_BOOL, |
167 |
{.intBoolVal = true}, |
168 |
{.intBoolVal = true} }, |
169 |
{ "daodanbsl", |
170 |
"Adds new BSL commands.", |
171 |
C_BOOL, |
172 |
{.intBoolVal = true}, |
173 |
{.intBoolVal = true} }, |
174 |
{ "hdscreens_lowres", |
175 |
"Allow HD intro/ending screens on game resolutions smaller than 1024x768.", |
176 |
C_BOOL, |
177 |
{.intBoolVal = true}, |
178 |
{.intBoolVal = true} }, |
179 |
{ "largetextures", |
180 |
"Textures up to 512x512 can be used.", |
181 |
C_BOOL, |
182 |
{.intBoolVal = true}, |
183 |
{.intBoolVal = true} }, |
184 |
{ "levelplugins", |
185 |
"Allows level files to be loaded which do not end in \"_Final\".", |
186 |
C_BOOL, |
187 |
{.intBoolVal = true}, |
188 |
{.intBoolVal = true} }, |
189 |
{ 0, 0, 0, {0}, {0} } |
190 |
} }, |
191 |
{ "oni", "Original Oni Options", { |
192 |
{ "debug", |
193 |
"Not useful, probably does nothing.", |
194 |
EXT_BOOL, |
195 |
{.intBoolVal = false }, |
196 |
{.extBoolVal = &AKgDebug_DebugMaps } }, |
197 |
{ "debugfiles", |
198 |
"Logs called BSL functions to script_debug.txt.", |
199 |
EXT_BOOL, |
200 |
{.intBoolVal = false }, |
201 |
{.extBoolVal = &BFgDebugFileEnable } }, |
202 |
{ "findsounds", |
203 |
"Not useful, extends output of sound_list_broken_links.", |
204 |
EXT_BOOL, |
205 |
{.intBoolVal = false }, |
206 |
{.extBoolVal = &SSgSearchOnDisk } }, |
207 |
{ "ignore_private_data", |
208 |
"Not useful, probably does nothing.", |
209 |
EXT_BOOL, |
210 |
{.intBoolVal = false }, |
211 |
{.extBoolVal = &opt_ignore_private_data } }, |
212 |
{ "sound", |
213 |
"Enable sound.", |
214 |
EXT_BOOL, |
215 |
{.intBoolVal = true }, |
216 |
{.extBoolVal = &opt_sound } }, |
217 |
{ "switch", |
218 |
"Switch to fullscreen instead of staying in a window.", |
219 |
EXT_BOOL, |
220 |
{.intBoolVal = true}, |
221 |
{.extBoolVal = &M3gResolutionSwitch} }, |
222 |
{ 0, 0, 0, {0}, {0} } |
223 |
} }, |
224 |
{ "windows", "Windows", { |
225 |
{ "alttab", |
226 |
"Allows to Alt-Tab out of Oni and use Windows key. May enable the screensaver as well.", |
227 |
C_BOOL, |
228 |
{.intBoolVal = true}, |
229 |
{.intBoolVal = true} }, |
230 |
{ "border", |
231 |
"Add a border if in windowed mode and \"usedaodangl\" patch is active.", |
232 |
C_BOOL, |
233 |
{.intBoolVal = true}, |
234 |
{.intBoolVal = true} }, |
235 |
{ "clipcursor", |
236 |
"Limit cursor to Oni's window.", |
237 |
C_BOOL, |
238 |
{.intBoolVal = true}, |
239 |
{.intBoolVal = true} }, |
240 |
{ "directinput", |
241 |
"Enforces the usage of DirectInput on every system. Should be off for Linux/Wine.", |
242 |
C_BOOL, |
243 |
{.intBoolVal = true}, |
244 |
{.intBoolVal = true} }, |
245 |
{ "disablecmdline", |
246 |
"Disables Oni's existing command line parser as Daodan has its own.", |
247 |
C_BOOL, |
248 |
{.intBoolVal = true}, |
249 |
{.intBoolVal = true} }, |
250 |
{ "killvtune", |
251 |
"Prevent loading of vtuneapi.dll.", |
252 |
C_BOOL, |
253 |
{.intBoolVal = false}, |
254 |
{.intBoolVal = false} }, |
255 |
{ "safeprintf", |
256 |
"Replaces Oni's function that prints to startup.txt with a safer one.", |
257 |
C_BOOL, |
258 |
{.intBoolVal = true}, |
259 |
{.intBoolVal = true} }, |
260 |
{ "topmost", |
261 |
"Keep game window on top in windowed mode, even when switching applications.", |
262 |
C_BOOL, |
263 |
{.intBoolVal = false}, |
264 |
{.intBoolVal = false} }, |
265 |
{ "usegettickcount", |
266 |
"Replaces Oni's timing functions with more accurate ones.", |
267 |
C_BOOL, |
268 |
{.intBoolVal = true}, |
269 |
{.intBoolVal = true} }, |
270 |
{ 0, 0, 0, {0}, {0} } |
271 |
} } |
272 |
}; |
273 |
|
274 |
|
275 |
void DDrConfig_Print() |
276 |
{ |
277 |
for (unsigned int s = 0; s < ARRAY_SIZE(config); s++) { |
278 |
for (ConfigOption_t* co = config[s].options; co->name != 0; co++) { |
279 |
switch (co->type) { |
280 |
case C_STRING: |
281 |
STARTUPMESSAGE("Option %s.%s = %s (def %s)", config[s].name, co->name, co->value.stringVal, co->defaultValue.stringVal); |
282 |
break; |
283 |
case EXT_BOOL: |
284 |
STARTUPMESSAGE("Option %s.%s = %d (def %d)", config[s].name, co->name, *co->value.extBoolVal, co->defaultValue.intBoolVal); |
285 |
break; |
286 |
case C_CMD: |
287 |
break; |
288 |
default: |
289 |
STARTUPMESSAGE("Option %s.%s = %d (def %d)", config[s].name, co->name, co->value.intBoolVal, co->defaultValue.intBoolVal); |
290 |
} |
291 |
} |
292 |
} |
293 |
} |
294 |
|
295 |
void DDrConfig_PrintHelp() |
296 |
{ |
297 |
STARTUPMESSAGE("Writing Daodan help file (%s)", helpFile); |
298 |
|
299 |
FILE* fp; |
300 |
remove(helpFile); |
301 |
fp = fopen(helpFile, "w"); |
302 |
if (fp) |
303 |
{ |
304 |
time_t rawtime; |
305 |
struct tm* timeinfo; |
306 |
char buffer[80]; |
307 |
time(&rawtime); |
308 |
timeinfo = localtime(&rawtime); |
309 |
strftime(buffer, 80, "%Y-%m-%d %H:%M:%S", timeinfo); |
310 |
|
311 |
fprintf(fp, "Daodan help - generated on %s for Daodan v."DAODAN_VERSION_STRING"\n\n", buffer); |
312 |
fprintf(fp, "List of Daodan configuration parameters:\n"); |
313 |
for (unsigned int s = 0; s < ARRAY_SIZE(config); s++) { |
314 |
fprintf(fp, " %s - %s:\n", config[s].name, config[s].description); |
315 |
for (ConfigOption_t* co = config[s].options; co->name != 0; co++) { |
316 |
char* name = co->name; |
317 |
char* desc = co->description; |
318 |
const char* tName = DDrConfig_GetOptionTypeName(co->type); |
319 |
const char* val = DDrConfig_GetOptionValueString(co, 1); |
320 |
if (!val) |
321 |
val = ""; |
322 |
fprintf(fp, " %-22s %6s=%-5s %s\n", name, tName, val, desc); |
323 |
} |
324 |
fprintf(fp, "\n"); |
325 |
} |
326 |
fprintf(fp, "\nConfiguration parameters can be either set in daodan.ini or passed on command line.\n\n"); |
327 |
fprintf(fp, "In daodan.ini each section of parameters has its own section in the ini file started by [section name]. Parameters are given within that section by their name only, followed by an equals sign and the desired value. Example:\n"); |
328 |
fprintf(fp, " [sectionX]\n parameterName = false\n"); |
329 |
fprintf(fp, "\nTo pass the parameter on the command line:\n"); |
330 |
fprintf(fp, " Oni.exe -parameterName false\n"); |
331 |
fprintf(fp, "For bool parameters the value can be ommitted so it is regarded as \"true\":\n"); |
332 |
fprintf(fp, " Oni.exe -parameterName\n"); |
333 |
fprintf(fp, "To disable a bool parameter you can prefix \"no\" to the parameter name like this:\n"); |
334 |
fprintf(fp, " Oni.exe -noparameterName\n"); |
335 |
|
336 |
fclose(fp); |
337 |
} |
338 |
else |
339 |
{ |
340 |
STARTUPMESSAGE("Writing Daodan help file failed", 0); |
341 |
} |
342 |
} |
343 |
|
344 |
const char* DDrConfig_GetOptionTypeName(OptionType_t type) |
345 |
{ |
346 |
switch (type) { |
347 |
case C_INT: |
348 |
return "Int"; |
349 |
case C_BOOL: |
350 |
return "Bool"; |
351 |
case C_STRING: |
352 |
return "String"; |
353 |
case C_CMD: |
354 |
return "Cmd"; |
355 |
case EXT_BOOL: |
356 |
return "pBool"; |
357 |
default: |
358 |
return "unknown"; |
359 |
} |
360 |
} |
361 |
|
362 |
const char* DDrConfig_GetOptionValueString(ConfigOption_t* opt, char printdefault) |
363 |
{ |
364 |
OptionValue_t* optVal = (printdefault ? &opt->defaultValue : &opt->value); |
365 |
int boolV = optVal->intBoolVal; |
366 |
char* val = 0; |
367 |
switch (opt->type) { |
368 |
case C_STRING: |
369 |
return optVal->stringVal; |
370 |
case EXT_BOOL: |
371 |
if (printdefault) |
372 |
return (boolV ? "true" : "false"); |
373 |
else |
374 |
return (*optVal->extBoolVal ? "true" : "false"); |
375 |
case C_BOOL: |
376 |
return (boolV ? "true" : "false"); |
377 |
case C_CMD: |
378 |
return 0; |
379 |
default: |
380 |
val = malloc(20); |
381 |
sprintf(val, "%d", boolV); |
382 |
return val; |
383 |
} |
384 |
} |
385 |
|
386 |
char DDrConfig_NonDefaultOptionValue(ConfigOption_t* opt) |
387 |
{ |
388 |
switch (opt->type) { |
389 |
case C_STRING: |
390 |
return _stricmp(opt->defaultValue.stringVal, opt->value.stringVal); |
391 |
case EXT_BOOL: |
392 |
return !opt->defaultValue.intBoolVal != !*opt->value.extBoolVal; |
393 |
case C_BOOL: |
394 |
return !opt->defaultValue.intBoolVal != !opt->value.intBoolVal; |
395 |
case C_CMD: |
396 |
return 0; |
397 |
case C_INT: |
398 |
return opt->defaultValue.intBoolVal != opt->value.intBoolVal; |
399 |
} |
400 |
return 0; |
401 |
} |
402 |
|
403 |
static ConfigOption_t* DDrConfig_GetOption(const char* fullOptName) |
404 |
{ |
405 |
char section[50]; |
406 |
strcpy(section, fullOptName); |
407 |
|
408 |
char* option = strchr(section, '.'); |
409 |
if (option == 0) { |
410 |
STARTUPMESSAGE("Could not find option separator in \"%s\"", fullOptName); |
411 |
return 0; |
412 |
} |
413 |
*option++ = 0; |
414 |
|
415 |
char isWildcardSection = !_stricmp(section, "*"); |
416 |
|
417 |
for (unsigned int s = 0; s < ARRAY_SIZE(config); s++) { |
418 |
if (isWildcardSection || !_stricmp(config[s].name, section)) { |
419 |
for (ConfigOption_t* co = config[s].options; co->name != 0; co++) { |
420 |
if (!_stricmp(co->name, option)) { |
421 |
return co; |
422 |
} |
423 |
} |
424 |
if (!isWildcardSection) { |
425 |
STARTUPMESSAGE("Could not find option \"%s\" in section \"%s\"", option, section); |
426 |
return 0; |
427 |
} |
428 |
} |
429 |
} |
430 |
if (!isWildcardSection) |
431 |
STARTUPMESSAGE("Could not find section \"%s\" for option \"%s\"", section, option); |
432 |
else |
433 |
STARTUPMESSAGE("Could not find option \"%s\"", option); |
434 |
return 0; |
435 |
} |
436 |
|
437 |
|
438 |
|
439 |
ConfigOption_t* DDrConfig_GetOptOfType(const char* fullOptName, OptionType_t type) |
440 |
{ |
441 |
ConfigOption_t* co = DDrConfig_GetOption(fullOptName); |
442 |
if (co == 0) |
443 |
return 0; |
444 |
|
445 |
if (co->type != type) { |
446 |
STARTUPMESSAGE("Option \"%s\" is not of type %s", fullOptName, DDrConfig_GetOptionTypeName(type)); |
447 |
return 0; |
448 |
} |
449 |
return co; |
450 |
} |
451 |
|
452 |
|
453 |
|
454 |
void DDrConfig_InitExtBools() |
455 |
{ |
456 |
for (unsigned int s = 0; s < ARRAY_SIZE(config); s++) { |
457 |
for (ConfigOption_t* co = config[s].options; co->name != 0; co++) { |
458 |
if (co->type == EXT_BOOL) { |
459 |
*co->value.extBoolVal = co->defaultValue.intBoolVal; |
460 |
} |
461 |
} |
462 |
} |
463 |
} |
464 |
|
465 |
|
466 |
|
467 |
void DDrConfig_WriteIni() |
468 |
{ |
469 |
FILE* fp; |
470 |
STARTUPMESSAGE("%s doesn't exist, creating", iniName); |
471 |
fp = fopen(iniName, "w"); |
472 |
if (fp) |
473 |
{ |
474 |
for (unsigned int s = 0; s < ARRAY_SIZE(config); s++) { |
475 |
if (strlen(config[s].name)) { |
476 |
fprintf(fp, "[%s]\n", config[s].name); |
477 |
for (ConfigOption_t* co = config[s].options; co->name != 0; co++) { |
478 |
char* name = co->name; |
479 |
const char* val = DDrConfig_GetOptionValueString(co, 0); |
480 |
if (val && DDrConfig_NonDefaultOptionValue(co)) |
481 |
fprintf(fp, "%s = %s\n", name, val); |
482 |
} |
483 |
fprintf(fp, "\n"); |
484 |
} |
485 |
} |
486 |
fclose(fp); |
487 |
} |
488 |
else |
489 |
{ |
490 |
STARTUPMESSAGE("Writing %s template file failed", iniName); |
491 |
} |
492 |
} |
493 |
|
494 |
|
495 |
void DDrIniCallback(const char* section, const char* name, const char* value) |
496 |
{ |
497 |
char fullOptName[50]; |
498 |
|
499 |
if (!_stricmp(section, "patch")) |
500 |
section = "patches"; |
501 |
|
502 |
strcpy(fullOptName, section); |
503 |
fullOptName[strlen(section)] = '.'; |
504 |
strcpy(fullOptName+strlen(section)+1, name); |
505 |
|
506 |
ConfigOption_t* co = DDrConfig_GetOption(fullOptName); |
507 |
|
508 |
if (co) |
509 |
{ |
510 |
char* buf = 0; |
511 |
switch (co->type) { |
512 |
case C_INT: |
513 |
co->value.intBoolVal = strtol(value, NULL, 0); |
514 |
break; |
515 |
case C_BOOL: |
516 |
co->value.intBoolVal = !_stricmp(value, "true"); |
517 |
break; |
518 |
case C_STRING: |
519 |
buf = malloc(strlen(value)+1); |
520 |
strcpy(buf, value); |
521 |
co->value.stringVal = buf; |
522 |
break; |
523 |
case C_CMD: |
524 |
co->value.callback(); |
525 |
break; |
526 |
case EXT_BOOL: |
527 |
*(co->value.extBoolVal) = !_stricmp(value, "true"); |
528 |
break; |
529 |
default: |
530 |
STARTUPMESSAGE("Config value type unknown: %d", co->type); |
531 |
} |
532 |
} else { |
533 |
char buf[100]; |
534 |
if (!_stricmp(section, "*")) |
535 |
sprintf(buf, " %s\n", name); |
536 |
else |
537 |
sprintf(buf, " %s.%s\n", section, name); |
538 |
if (strlen(buf) + strlen(invalidCurParamaters) < sizeof(invalidCurParamaters) - 1) { |
539 |
strcpy(invalidCurParamaters + strlen(invalidCurParamaters), buf); |
540 |
} |
541 |
} |
542 |
} |
543 |
|
544 |
|
545 |
bool DDrConfig_ParseCommandLine(int argc, char* argv[]) |
546 |
{ |
547 |
for (int i = 1; i < argc; i ++) |
548 |
{ |
549 |
if (argv[i][0] == '-') |
550 |
{ |
551 |
char* option; |
552 |
bool invertedOption; |
553 |
|
554 |
option = argv[i]+1; |
555 |
|
556 |
invertedOption = (option[0] == 'n' || option[0] == 'N') && (option[1] == 'o' || option[1] == 'O'); |
557 |
if (invertedOption) |
558 |
option += 2; |
559 |
|
560 |
if (i < (argc - 1) && argv[i+1][0] != '-') |
561 |
// Has value in next field |
562 |
{ |
563 |
DDrIniCallback("*", option, argv[++i]); |
564 |
} |
565 |
else |
566 |
// Implicit value |
567 |
{ |
568 |
DDrIniCallback("*", option, (invertedOption ? "false" : "true")); |
569 |
} |
570 |
} |
571 |
else |
572 |
{ |
573 |
STARTUPMESSAGE("Parse error \"%s\"", argv[i]); |
574 |
return false; |
575 |
} |
576 |
} |
577 |
return true; |
578 |
} |
579 |
|
580 |
void DDrConfig(int argc, char* argv[]) |
581 |
{ |
582 |
STARTUPMESSAGE("Initializing standard booleans", 0); |
583 |
DDrConfig_InitExtBools(); |
584 |
|
585 |
if (GetFileAttributes(iniName) == INVALID_FILE_ATTRIBUTES) |
586 |
DDrConfig_WriteIni(); |
587 |
|
588 |
STARTUPMESSAGE("Parsing daodan.ini...", 0); |
589 |
if (!Inifile_Read(iniName, DDrIniCallback)) |
590 |
STARTUPMESSAGE("Error reading daodan.ini, check your syntax!", 0); |
591 |
STARTUPMESSAGE("Finished parsing", 0); |
592 |
|
593 |
if (strlen(invalidCurParamaters) > 0) |
594 |
{ |
595 |
sprintf(invalidTotalParamaters, "In %s:\n%s\n", iniName, invalidCurParamaters); |
596 |
invalidCurParamaters[0] = 0; |
597 |
} |
598 |
|
599 |
STARTUPMESSAGE("Parsing command line...", 0); |
600 |
DDrConfig_ParseCommandLine(argc, argv); |
601 |
STARTUPMESSAGE("Finished parsing", 0); |
602 |
|
603 |
if (strlen(invalidCurParamaters) > 0) |
604 |
{ |
605 |
sprintf(invalidTotalParamaters, "%sOn command line:\n%s\n", invalidTotalParamaters, invalidCurParamaters); |
606 |
} |
607 |
|
608 |
if (strlen(invalidTotalParamaters) > 0) |
609 |
{ |
610 |
char msg[4096]; |
611 |
sprintf(msg, "Invalid parameters given:\n%sContinue launching Oni?", invalidTotalParamaters); |
612 |
int res = MessageBox(NULL, msg, "Parameters invalid", MB_ICONWARNING | MB_YESNO | MB_DEFBUTTON1); |
613 |
if (res == IDNO) { |
614 |
exit(0); |
615 |
} |
616 |
} |
617 |
|
618 |
DDrConfig_WriteIni(); |
619 |
|
620 |
// DDrConfig_Print(); |
621 |
} |
622 |
|