ViewVC Help
View File | Revision Log | View Changeset | Root Listing
root/Oni2/Daodan/src/Daodan_Config.c
(Generate patch)

Comparing Daodan/src/Daodan_Config.c (file contents):
Revision 996 by alloc, Wed Apr 9 09:12:52 2014 UTC vs.
Revision 1162 by rossy, Sun Oct 24 02:50:32 2021 UTC

# Line 2 | Line 2
2   #include <string.h>
3   #include <time.h>
4  
5 + #include "Daodan.h"
6   #include "Daodan_Config.h"
7   #include "Daodan_Patch.h"
8   #include "Patches/Utility.h"
# Line 11 | Line 12
12  
13   #include "Inifile_Reader.h"
14  
14 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0]))
15
15   static const char* iniName = "daodan.ini";
16   static const char* helpFile = "daodan_help.txt";
17  
18   static const char* defaultSection = "options";
19  
20 < static char invalidCurParamaters[1000] = "";
21 < static char invalidTotalParamaters[3000] = "";
20 > static char invalidCurParamaters[2000] = "";
21 > static char invalidTotalParamaters[4000] = "";
22  
23   void DDrConfig_PrintHelp();
24  
25  
26   ConfigSection_t config[] = {
27 <        { "patches", "Patches", {
28 <                { "alttab",
29 <                        "Allows to Alt-Tab out of Oni and use Windows key. May enable the screensaver as well.",
27 >        { "", "Command line only", {
28 >                { "help",
29 >                        "Generates this help file.",
30 >                        C_CMD,
31 >                        {.intBoolVal = 0},
32 >                        {.callback = DDrConfig_PrintHelp} },
33 >                { 0, 0, 0, {0}, {0} }
34 >        } },
35 >        { "devmode", "Developer Mode", {
36 >                { "highres_console",
37 >                        "Fixes bug where console line becomes invisible at higher resolutions.",
38                          C_BOOL,
39                          {.intBoolVal = true},
40                          {.intBoolVal = true} },
41 <                { "argb8888",
42 <                        "Allows using textures with ARGB8888.",
41 >                { "showtriggervolumes",
42 >                        "Allows BSL variable \"show_triggervolumes\" and Ctrl+Shift+X (in devmode) to work.",
43                          C_BOOL,
44                          {.intBoolVal = true},
45                          {.intBoolVal = true} },
46 <                { "binkplay",
47 <                        "Fix binkplay calls to use GDI and outro same mode as intro.",
46 >                { 0, 0, 0, {0}, {0} }
47 >        } },
48 >        { "gameplay", "Gameplay", {
49 >                { "bindablecheats",
50 >                        "Allows cheats to be bound to keys. Requires 'customactions' and 'cheattable' to be true.",
51 >                        C_BOOL,
52 >                        {.intBoolVal = true},
53 >                        {.intBoolVal = true} },
54 >                { "characterawareness",
55 >                        "Makes AI remember the player.",
56                          C_BOOL,
57                          {.intBoolVal = true},
58                          {.intBoolVal = true} },
# Line 51 | Line 66 | ConfigSection_t config[] = {
66                          C_BOOL,
67                          {.intBoolVal = true},
68                          {.intBoolVal = true} },
54                { "chinese",
55                        "Allow for chinese fonts to be shown if the required DLL is available.",
56                        C_BOOL,
57                        {.intBoolVal = true},
58                        {.intBoolVal = true} },
59                { "clipcursor",
60                        "Limit cursor to Oni's window.",
61                        C_BOOL,
62                        {.intBoolVal = true},
63                        {.intBoolVal = true} },
69                  { "cooldowntimer",
70                          "Disables weapon cooldown exploit.",
71                          C_BOOL,
72                          {.intBoolVal = true},
73                          {.intBoolVal = true} },
74 <                { "d_regen",
75 <                        "Enables script command d_regen (query/set regeneration for any character).",
74 >                { "customactions",
75 >                        "Allows more actions to be bound through Daodan.",
76                          C_BOOL,
77                          {.intBoolVal = true},
78                          {.intBoolVal = true} },
79 <                { "daodandisplayenum",
80 <                        "Offers a more accurate list of available display modes in the Options menu.",
79 >                { "kickguns",
80 >                        "EXPERIMENTAL! Unfinished, do not use.",
81                          C_BOOL,
82 <                        {.intBoolVal = true},
83 <                        {.intBoolVal = true} },
84 <                { "directinput",
85 <                        "Enforces the usage of DirectInput on every system. Should be off for Linux/Wine.",
82 >                        {.intBoolVal = false},
83 >                        {.intBoolVal = false} },
84 >                { "pathfinding",
85 >                        "Size of pathfinding grid cache increased by eight times in order to prevent crashes in large levels.",
86                          C_BOOL,
87                          {.intBoolVal = true},
88                          {.intBoolVal = true} },
89 <                { "disablecmdline",
90 <                        "Disables Oni's existing command line parser as Daodan has its own.",
89 >                { "projaware",
90 >                        "Allows AI to dodge incoming gunfire properly.",
91                          C_BOOL,
92                          {.intBoolVal = true},
93                          {.intBoolVal = true} },
94 <                { "fonttexturecache",
95 <                        "Doubles size of font texture cache.",
94 >                { "throwtest",
95 >                        "EXPERIMENTAL! Experiment with allowing enemies to be thrown over railings.",
96 >                        C_BOOL,
97 >                        {.intBoolVal = false},
98 >                        {.intBoolVal = false} },
99 >                { "wpfadetime",
100 >                        "Adds working function for existing BSL command wp_fadetime, sets fade time to 4800.",
101                          C_BOOL,
102                          {.intBoolVal = true},
103                          {.intBoolVal = true} },
104 <                { "hdscreens_lowres",
105 <                        "Allow HD intro/ending screens on game resolutions smaller than 1024x768.",
104 >                { 0, 0, 0, {0}, {0} }
105 >        } },
106 >        { "graphics", "Graphics", {
107 >                { "binkplay",
108 >                        "Fix binkplay calls to use GDI and outro same mode as intro.",
109                          C_BOOL,
110                          {.intBoolVal = true},
111                          {.intBoolVal = true} },
112 <                { "highres_console",
113 <                        "Fixes bug where console line becomes invisible at higher resolutions.",
112 >                { "daodangl",
113 >                        "Provides an improved windowed mode (-noswitch).",
114                          C_BOOL,
115                          {.intBoolVal = true},
116                          {.intBoolVal = true} },
117 <                { "kickguns",
118 <                        "EXPERIMENTAL! Unfinished, do not use.",
106 <                        C_BOOL,
107 <                        {.intBoolVal = false},
108 <                        {.intBoolVal = false} },
109 <                { "killvtune",
110 <                        "Prevent loading of vtuneapi.dll.",
111 <                        C_BOOL,
112 <                        {.intBoolVal = false},
113 <                        {.intBoolVal = false} },
114 <                { "largetextures",
115 <                        "Textures up to 512x512 can be used.",
117 >                { "displayenum",
118 >                        "Offers a more accurate list of available display modes in the Options menu.",
119                          C_BOOL,
120                          {.intBoolVal = true},
121                          {.intBoolVal = true} },
122 <                { "levelplugins",
123 <                        "Allows level files to be loaded which do not end in \"_Final\".",
122 >                { "gamma",
123 >                        "Enable gamma slider in fullscreen, disable in windowed mode.",
124                          C_BOOL,
125                          {.intBoolVal = true},
126                          {.intBoolVal = true} },
# Line 126 | Line 129 | ConfigSection_t config[] = {
129                          C_BOOL,
130                          {.intBoolVal = true},
131                          {.intBoolVal = true} },
129                { "nomultibyte",
130                        "Enables languages which use multibyte coding (such as Chinese).",
131                        C_BOOL,
132                        {.intBoolVal = true},
133                        {.intBoolVal = true} },
132                  { "optionsvisible",
133                          "Always show options button in main menu, even when pausing from a game.",
134                          C_BOOL,
135                          {.intBoolVal = true},
136                          {.intBoolVal = true} },
137 <                { "pathfinding",
138 <                        "Size of pathfinding grid cache increased by eight times in order to prevent crashes in large levels.",
137 >                { "showalllasersights",
138 >                        "Show all (also enemies') weapon lasersights.",
139 >                        C_BOOL,
140 >                        {.intBoolVal = false},
141 >                        {.intBoolVal = false} },
142 >                { "widescreenportraits",
143 >                        "Prevents fly-in portraits from being stretched when playing in widescreen resolutions.",
144                          C_BOOL,
145                          {.intBoolVal = true},
146                          {.intBoolVal = true} },
147 <                { "projaware",
148 <                        "Allows AI to dodge incoming gunfire properly.",
147 >                { 0, 0, 0, {0}, {0} }
148 >        } },
149 >        { "language", "Language", {
150 >                { "chinese",
151 >                        "Allow for chinese fonts to be shown if the required DLL is available.",
152                          C_BOOL,
153                          {.intBoolVal = true},
154                          {.intBoolVal = true} },
155 <                { "safeprintf",
156 <                        "Replaces Oni's function that prints to startup.txt with a safer one.",
155 >                { "fonttexturecache",
156 >                        "Doubles size of font texture cache.",
157                          C_BOOL,
158                          {.intBoolVal = true},
159                          {.intBoolVal = true} },
160 <                { "showalllasersights",
161 <                        "Show all (also enemies') weapon lasersights.",
162 <                        C_BOOL,
163 <                        {.intBoolVal = false},
164 <                        {.intBoolVal = false} },
165 <                { "showtriggervolumes",
166 <                        "Allows BSL variable \"show_triggervolumes\" and Ctrl+Shift+X (in devmode) to work.",
160 >                { "language",
161 >                        "Localization for hardcoded strings (e.g. \"Savepoints\").",
162 >                        C_STRING,
163 >                        {.stringVal = "en"},
164 >                        {.stringVal = "en"} },
165 >                { "nomultibyte",
166 >                        "Enables languages which use multibyte coding (such as Chinese).",
167                          C_BOOL,
168                          {.intBoolVal = true},
169                          {.intBoolVal = true} },
170 <                { "throwtest",
171 <                        "EXPERIMENTAL! Experiment with allowing enemies to be thrown over railings.",
172 <                        C_BOOL,
173 <                        {.intBoolVal = false},
174 <                        {.intBoolVal = false} },
169 <                { "usedaodanbsl",
170 <                        "Adds new BSL commands.",
170 >                { 0, 0, 0, {0}, {0} }
171 >        } },
172 >        { "modding", "Modding", {
173 >                { "argb8888",
174 >                        "Allows using textures with ARGB8888.",
175                          C_BOOL,
176                          {.intBoolVal = true},
177                          {.intBoolVal = true} },
178 <                { "usedaodangl",
179 <                        "Provides an improved windowed mode (-noswitch).",
178 >                { "d_regen",
179 >                        "Enables script command d_regen (query/set regeneration for any character).",
180                          C_BOOL,
181                          {.intBoolVal = true},
182                          {.intBoolVal = true} },
183 <                { "usegettickcount",
184 <                        "Replaces Oni's timing functions with more accurate ones.",
183 >                { "daodanbsl",
184 >                        "Adds new BSL commands.",
185                          C_BOOL,
186                          {.intBoolVal = true},
187                          {.intBoolVal = true} },
188 <                { "widescreenportraits",
189 <                        "Prevents fly-in portraits from being stretched when playing in widescreen resolutions.",
188 >                { "hdscreens_lowres",
189 >                        "Allow HD intro/ending screens on game resolutions smaller than 1024x768.",
190                          C_BOOL,
191                          {.intBoolVal = true},
192                          {.intBoolVal = true} },
193 <                { "wpfadetime",
194 <                        "Adds working function for existing BSL command wp_fadetime, sets fade time to 4800.",
193 >                { "largetextures",
194 >                        "Textures up to 512x512 can be used.",
195                          C_BOOL,
196                          {.intBoolVal = true},
197                          {.intBoolVal = true} },
198 <                { 0, 0, 0, {0}, {0} }
199 <        } },
196 <        { "options", "Options", {
197 <                { "border",
198 <                        "Add a border if in windowed mode and \"usedaodangl\" patch is active.",
198 >                { "levelplugins",
199 >                        "Allows level files to be loaded which do not end in \"_Final\".",
200                          C_BOOL,
201                          {.intBoolVal = true},
202                          {.intBoolVal = true} },
203 +                { 0, 0, 0, {0}, {0} }
204 +        } },
205 +        { "oni", "Original Oni Options", {
206                  { "debug",
207                          "Not useful, probably does nothing.",
208                          EXT_BOOL,
# Line 214 | Line 218 | ConfigSection_t config[] = {
218                          EXT_BOOL,
219                          {.intBoolVal = false },
220                          {.extBoolVal = &SSgSearchOnDisk } },
217                { "gamma",
218                        "Enable gamma slider in fullscreen, disable in windowed mode.",
219                        C_BOOL,
220                        {.intBoolVal = true},
221                        {.intBoolVal = true} },
222                { "help",
223                        "Generates this help file.",
224                        C_CMD,
225                        {.intBoolVal = 0},
226                        {.callback = DDrConfig_PrintHelp} },
221                  { "ignore_private_data",
222                          "Not useful, probably does nothing.",
223                          EXT_BOOL,
# Line 239 | Line 233 | ConfigSection_t config[] = {
233                          EXT_BOOL,
234                          {.intBoolVal = true},
235                          {.extBoolVal = &M3gResolutionSwitch} },
236 +                { 0, 0, 0, {0}, {0} }
237 +        } },
238 +        { "windows", "Windows", {
239 +                { "alttab",
240 +                        "Allows to Alt-Tab out of Oni and use Windows key. May enable the screensaver as well.",
241 +                        C_BOOL,
242 +                        {.intBoolVal = true},
243 +                        {.intBoolVal = true} },
244 +                { "border",
245 +                        "Add a border if in windowed mode and \"usedaodangl\" patch is active.",
246 +                        C_BOOL,
247 +                        {.intBoolVal = true},
248 +                        {.intBoolVal = true} },
249 +                { "clipcursor",
250 +                        "Limit cursor to Oni's window.",
251 +                        C_BOOL,
252 +                        {.intBoolVal = true},
253 +                        {.intBoolVal = true} },
254 +                { "directinput",
255 +                        "Enforces the usage of DirectInput on every system. Should be off for Linux/Wine.",
256 +                        C_BOOL,
257 +                        {.intBoolVal = true},
258 +                        {.intBoolVal = true} },
259 +                { "disablecmdline",
260 +                        "Disables Oni's existing command line parser as Daodan has its own.",
261 +                        C_BOOL,
262 +                        {.intBoolVal = true},
263 +                        {.intBoolVal = true} },
264 +                { "killvtune",
265 +                        "Prevent loading of vtuneapi.dll.",
266 +                        C_BOOL,
267 +                        {.intBoolVal = false},
268 +                        {.intBoolVal = false} },
269 +                { "safeprintf",
270 +                        "Replaces Oni's function that prints to startup.txt with a safer one.",
271 +                        C_BOOL,
272 +                        {.intBoolVal = true},
273 +                        {.intBoolVal = true} },
274                  { "topmost",
275                          "Keep game window on top in windowed mode, even when switching applications.",
276                          C_BOOL,
277                          {.intBoolVal = false},
278                          {.intBoolVal = false} },
279 <                { "language",
280 <                        "Localization for hardcoded strings (e.g. \"Savepoints\").",
281 <                        C_STRING,
282 <                        {.stringVal = "en"},
283 <                        {.stringVal = "en"} },
279 >                { "usegettickcount",
280 >                        "Replaces Oni's timing functions with more accurate ones.",
281 >                        C_BOOL,
282 >                        {.intBoolVal = true},
283 >                        {.intBoolVal = true} },
284                  { 0, 0, 0, {0}, {0} }
285          } }
286   };
# Line 267 | Line 299 | void DDrConfig_Print()
299                                          break;
300                                  case C_CMD:
301                                          break;
302 +                                case C_FLOAT:
303 +                                        STARTUPMESSAGE("Option %s.%s = %f (def %f)", config[s].name, co->name, co->value.floatVal, co->defaultValue.floatVal);
304 +                                        break;
305                                  default:
306                                          STARTUPMESSAGE("Option %s.%s = %d (def %d)", config[s].name, co->name, co->value.intBoolVal, co->defaultValue.intBoolVal);
307                          }
# Line 298 | Line 333 | void DDrConfig_PrintHelp()
333                                  char* name = co->name;
334                                  char* desc = co->description;
335                                  const char* tName = DDrConfig_GetOptionTypeName(co->type);
336 <                                int boolV = co->defaultValue.intBoolVal;
337 <                                char* val;
338 <                                switch (co->type) {
304 <                                        case C_STRING:
305 <                                                val = co->defaultValue.stringVal;
306 <                                                break;
307 <                                        case EXT_BOOL:
308 <                                                val = (boolV ? "true" : "false");
309 <                                                break;
310 <                                        case C_BOOL:
311 <                                                val = (boolV ? "true" : "false");
312 <                                                break;
313 <                                        case C_CMD:
314 <                                                val = "";
315 <                                                break;
316 <                                        default:
317 <                                                val = malloc(20);
318 <                                                sprintf(val, "%d", boolV);
319 <                                }
336 >                                const char* val = DDrConfig_GetOptionValueString(co, 1);
337 >                                if (!val)
338 >                                        val = "";
339                                  fprintf(fp, "        %-22s %6s=%-5s %s\n", name, tName, val, desc);
340                          }
341                          fprintf(fp, "\n");
# Line 325 | Line 344 | void DDrConfig_PrintHelp()
344                  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");
345                  fprintf(fp, "    [sectionX]\n    parameterName = false\n");
346                  fprintf(fp, "\nTo pass the parameter on the command line:\n");
347 <                fprintf(fp, "    Oni.exe -sectionX.parameterName false\n");
347 >                fprintf(fp, "    Oni.exe -parameterName false\n");
348                  fprintf(fp, "For bool parameters the value can be ommitted so it is regarded as \"true\":\n");
349 <                fprintf(fp, "    Oni.exe -sectionX.parameterName\n");
349 >                fprintf(fp, "    Oni.exe -parameterName\n");
350                  fprintf(fp, "To disable a bool parameter you can prefix \"no\" to the parameter name like this:\n");
351 <                fprintf(fp, "    Oni.exe -sectionX.noparameterName\n");
333 <                fprintf(fp, "If no section is given it is assumed to be \"%s\", e.g.\n", defaultSection);
334 <                fprintf(fp, "    Oni.exe -%s.parametername\n", defaultSection);
335 <                fprintf(fp, "can simply be written as\n");
336 <                fprintf(fp, "    Oni.exe -parametername\n");
351 >                fprintf(fp, "    Oni.exe -noparameterName\n");
352  
353                  fclose(fp);
354          }
# Line 348 | Line 363 | const char* DDrConfig_GetOptionTypeName(
363          switch (type) {
364                  case C_INT:
365                          return "Int";
366 +                case C_FLOAT:
367 +                        return "Float";
368                  case C_BOOL:
369                          return "Bool";
370                  case C_STRING:
# Line 361 | Line 378 | const char* DDrConfig_GetOptionTypeName(
378          }
379   }
380  
381 + const char* DDrConfig_GetOptionValueString(ConfigOption_t* opt, char printdefault)
382 + {
383 +        OptionValue_t* optVal = (printdefault ? &opt->defaultValue : &opt->value);
384 +        int boolV = optVal->intBoolVal;
385 +        char* val = 0;
386 +        switch (opt->type) {
387 +                case C_STRING:
388 +                        return optVal->stringVal;
389 +                case EXT_BOOL:
390 +                        if (printdefault)
391 +                                return (boolV ? "true" : "false");
392 +                        else
393 +                                return (*optVal->extBoolVal ? "true" : "false");
394 +                case C_BOOL:
395 +                        return (boolV ? "true" : "false");
396 +                case C_CMD:
397 +                        return 0;
398 +                case C_FLOAT:
399 +                        val = malloc(50);
400 +                        sprintf(val, "%f", optVal->floatVal);
401 +                        return val;
402 +                default:
403 +                        val = malloc(20);
404 +                        sprintf(val, "%d", boolV);
405 +                        return val;
406 +        }
407 + }
408 +
409 + char DDrConfig_NonDefaultOptionValue(ConfigOption_t* opt)
410 + {
411 +        switch (opt->type) {
412 +                case C_STRING:
413 +                        return _stricmp(opt->defaultValue.stringVal, opt->value.stringVal);
414 +                case EXT_BOOL:
415 +                        return !opt->defaultValue.intBoolVal != !*opt->value.extBoolVal;
416 +                case C_BOOL:
417 +                        return !opt->defaultValue.intBoolVal != !opt->value.intBoolVal;
418 +                case C_CMD:
419 +                        return 0;
420 +                case C_INT:
421 +                        return opt->defaultValue.intBoolVal != opt->value.intBoolVal;
422 +                case C_FLOAT:
423 +                        return opt->defaultValue.floatVal != opt->value.floatVal;
424 +        }
425 +        return 0;
426 + }
427 +
428   static ConfigOption_t* DDrConfig_GetOption(const char* fullOptName)
429   {
430          char section[50];
# Line 373 | Line 437 | static ConfigOption_t* DDrConfig_GetOpti
437          }
438          *option++ = 0;
439  
440 +        char isWildcardSection = !_stricmp(section, "*");
441 +
442          for (unsigned int s = 0; s < ARRAY_SIZE(config); s++) {
443 <                if (!_stricmp(config[s].name, section)) {
443 >                if (isWildcardSection || !_stricmp(config[s].name, section)) {
444                          for (ConfigOption_t* co = config[s].options; co->name != 0; co++) {
445                                  if (!_stricmp(co->name, option)) {
446                                          return co;
447                                  }
448                          }
449 <                        STARTUPMESSAGE("Could not find option \"%s\" in section \"%s\"", option, section);
450 <                        return 0;
449 >                        if (!isWildcardSection) {
450 >                                STARTUPMESSAGE("Could not find option \"%s\" in section \"%s\"", option, section);
451 >                                return 0;
452 >                        }
453                  }
454          }
455 <        STARTUPMESSAGE("Could not find section \"%s\" for option \"%s\"", section, option);
455 >        if (!isWildcardSection)
456 >                STARTUPMESSAGE("Could not find section \"%s\" for option \"%s\"", section, option);
457 >        else
458 >                STARTUPMESSAGE("Could not find option \"%s\"", option);
459          return 0;
460   }
461  
# Line 418 | Line 489 | void DDrConfig_InitExtBools()
489  
490  
491  
492 < void DDrConfig_WriteTemplateIni()
492 > void DDrConfig_WriteIni()
493   {
494          FILE* fp;
495          STARTUPMESSAGE("%s doesn't exist, creating", iniName);
# Line 426 | Line 497 | void DDrConfig_WriteTemplateIni()
497          if (fp)
498          {
499                  for (unsigned int s = 0; s < ARRAY_SIZE(config); s++) {
500 <                        fprintf(fp, "[%s]\n", config[s].name);
500 >                        if (strlen(config[s].name)) {
501 >                                fprintf(fp, "[%s]\n", config[s].name);
502 >                                for (ConfigOption_t* co = config[s].options; co->name != 0; co++) {
503 >                                        char* name = co->name;
504 >                                        const char* val = DDrConfig_GetOptionValueString(co, 0);
505 >                                        if (val && DDrConfig_NonDefaultOptionValue(co))
506 >                                                fprintf(fp, "%s = %s\n", name, val);
507 >                                }
508 >                                fprintf(fp, "\n");
509 >                        }
510                  }
511                  fclose(fp);
512          }
# Line 439 | Line 519 | void DDrConfig_WriteTemplateIni()
519  
520   void DDrIniCallback(const char* section, const char* name, const char* value)
521   {
442        static char curSection[20];
522          char fullOptName[50];
523  
524          if (!_stricmp(section, "patch"))
525                  section = "patches";
526  
527 <        strcpy(curSection, section);
528 <
529 <        strcpy(fullOptName, curSection);
451 <        fullOptName[strlen(curSection)] = '.';
452 <        strcpy(fullOptName+strlen(curSection)+1, name);
527 >        strcpy(fullOptName, section);
528 >        fullOptName[strlen(section)] = '.';
529 >        strcpy(fullOptName+strlen(section)+1, name);
530  
531          ConfigOption_t* co = DDrConfig_GetOption(fullOptName);
532  
# Line 460 | Line 537 | void DDrIniCallback(const char* section,
537                          case C_INT:
538                                  co->value.intBoolVal = strtol(value, NULL, 0);
539                                  break;
540 +                        case C_FLOAT:
541 +                                co->value.floatVal = strtof(value, NULL);
542 +                                break;
543                          case C_BOOL:
544                                  co->value.intBoolVal = !_stricmp(value, "true");
545                                  break;
# Line 478 | Line 558 | void DDrIniCallback(const char* section,
558                                  STARTUPMESSAGE("Config value type unknown: %d", co->type);
559                  }
560          } else {
561 <                char buf[50];
562 <                sprintf_s(buf, sizeof(buf), "  %s.%s\n", section, name);
561 >                char buf[100];
562 >                if (!_stricmp(section, "*"))
563 >                        sprintf(buf, "  %s\n", name);
564 >                else
565 >                        sprintf(buf, "  %s.%s\n", section, name);
566                  if (strlen(buf) + strlen(invalidCurParamaters) < sizeof(invalidCurParamaters) - 1) {
567                          strcpy(invalidCurParamaters + strlen(invalidCurParamaters), buf);
568                  }
# Line 493 | Line 576 | bool DDrConfig_ParseCommandLine(int argc
576          {
577                  if (argv[i][0] == '-')
578                  {
496                        const char* section;
497                        char* optionsep;
579                          char* option;
580                          bool invertedOption;
581  
582 <                        if ((optionsep = strchr(argv[i], '.')))
502 <                        // Is "section.option"
503 <                        {
504 <                                *optionsep = 0;
505 <                                option = optionsep+1;
506 <                                section = argv[i]+1;
507 <                        }
508 <                        else
509 <                        // Is just "option"
510 <                        {
511 <                                section = defaultSection;
512 <                                option = argv[i]+1;
513 <                        }
582 >                        option = argv[i]+1;
583  
584                          invertedOption = (option[0] == 'n' || option[0] == 'N') && (option[1] == 'o' || option[1] == 'O');
585                          if (invertedOption)
# Line 519 | Line 588 | bool DDrConfig_ParseCommandLine(int argc
588                          if (i < (argc - 1) && argv[i+1][0] != '-')
589                          // Has value in next field
590                          {
591 <                                DDrIniCallback(section, option, argv[++i]);
591 >                                DDrIniCallback("*", option, argv[++i]);
592                          }
593                          else
594                          // Implicit value
595                          {
596 <                                DDrIniCallback(section, option, (invertedOption ? "false" : "true"));
596 >                                DDrIniCallback("*", option, (invertedOption ? "false" : "true"));
597                          }
529
530                        if (optionsep)
531                                *optionsep = '.';
598                  }
599                  else
600                  {
# Line 545 | Line 611 | void DDrConfig(int argc, char* argv[])
611          DDrConfig_InitExtBools();
612  
613          if (GetFileAttributes(iniName) == INVALID_FILE_ATTRIBUTES)
614 <                DDrConfig_WriteTemplateIni();
614 >                DDrConfig_WriteIni();
615          
616          STARTUPMESSAGE("Parsing daodan.ini...", 0);
617          if (!Inifile_Read(iniName, DDrIniCallback))
# Line 554 | Line 620 | void DDrConfig(int argc, char* argv[])
620  
621          if (strlen(invalidCurParamaters) > 0)
622          {
623 <                sprintf_s(invalidTotalParamaters, sizeof(invalidTotalParamaters), "In %s:\n%s\n", iniName, invalidCurParamaters);
623 >                sprintf(invalidTotalParamaters, "In %s:\n%s\n", iniName, invalidCurParamaters);
624                  invalidCurParamaters[0] = 0;
625          }
626  
# Line 564 | Line 630 | void DDrConfig(int argc, char* argv[])
630  
631          if (strlen(invalidCurParamaters) > 0)
632          {
633 <                sprintf_s(invalidTotalParamaters, sizeof(invalidTotalParamaters), "%sOn command line:\n%s\n", invalidTotalParamaters, invalidCurParamaters);
633 >                sprintf(invalidTotalParamaters, "%sOn command line:\n%s\n", invalidTotalParamaters, invalidCurParamaters);
634          }
635  
636          if (strlen(invalidTotalParamaters) > 0)
637          {
638 <                char msg[3200];
639 <                sprintf_s(msg, sizeof(msg), "Invalid parameters given:\n%sContinue launching Oni?", invalidTotalParamaters);
638 >                char msg[4096];
639 >                sprintf(msg, "Invalid parameters given:\n%sContinue launching Oni?", invalidTotalParamaters);
640                  int res = MessageBox(NULL, msg, "Parameters invalid", MB_ICONWARNING | MB_YESNO | MB_DEFBUTTON1);
641                  if (res == IDNO) {
642                          exit(0);
643                  }
644          }
645  
646 +        DDrConfig_WriteIni();
647 +
648   //      DDrConfig_Print();
649   }
650  

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)