| 25 |
|
|
| 26 |
|
|
| 27 |
|
ConfigSection_t config[] = { |
| 28 |
< |
{ "patches", "Patches", { |
| 29 |
< |
{ "alttab", |
| 30 |
< |
"Allows to Alt-Tab out of Oni and use Windows key. May enable the screensaver as well.", |
| 31 |
< |
C_BOOL, |
| 32 |
< |
{.intBoolVal = true}, |
| 33 |
< |
{.intBoolVal = true} }, |
| 34 |
< |
{ "argb8888", |
| 35 |
< |
"Allows using textures with ARGB8888.", |
| 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 |
< |
{ "binkplay", |
| 43 |
< |
"Fix binkplay calls to use GDI and outro same mode as intro.", |
| 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, |
| 57 |
|
C_BOOL, |
| 58 |
|
{.intBoolVal = true}, |
| 59 |
|
{.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} }, |
| 60 |
|
{ "cooldowntimer", |
| 61 |
|
"Disables weapon cooldown exploit.", |
| 62 |
|
C_BOOL, |
| 63 |
|
{.intBoolVal = true}, |
| 64 |
|
{.intBoolVal = true} }, |
| 65 |
< |
{ "d_regen", |
| 66 |
< |
"Enables script command d_regen (query/set regeneration for any character).", |
| 65 |
> |
{ "kickguns", |
| 66 |
> |
"EXPERIMENTAL! Unfinished, do not use.", |
| 67 |
|
C_BOOL, |
| 68 |
< |
{.intBoolVal = true}, |
| 69 |
< |
{.intBoolVal = true} }, |
| 70 |
< |
{ "daodandisplayenum", |
| 71 |
< |
"Offers a more accurate list of available display modes in the Options menu.", |
| 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 |
< |
{ "directinput", |
| 76 |
< |
"Enforces the usage of DirectInput on every system. Should be off for Linux/Wine.", |
| 75 |
> |
{ "projaware", |
| 76 |
> |
"Allows AI to dodge incoming gunfire properly.", |
| 77 |
|
C_BOOL, |
| 78 |
|
{.intBoolVal = true}, |
| 79 |
|
{.intBoolVal = true} }, |
| 80 |
< |
{ "disablecmdline", |
| 81 |
< |
"Disables Oni's existing command line parser as Daodan has its own.", |
| 80 |
> |
{ "throwtest", |
| 81 |
> |
"EXPERIMENTAL! Experiment with allowing enemies to be thrown over railings.", |
| 82 |
|
C_BOOL, |
| 83 |
< |
{.intBoolVal = true}, |
| 84 |
< |
{.intBoolVal = true} }, |
| 85 |
< |
{ "fonttexturecache", |
| 86 |
< |
"Doubles size of font texture cache.", |
| 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 |
< |
{ "hdscreens_lowres", |
| 91 |
< |
"Allow HD intro/ending screens on game resolutions smaller than 1024x768.", |
| 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 |
< |
{ "highres_console", |
| 99 |
< |
"Fixes bug where console line becomes invisible at higher resolutions.", |
| 98 |
> |
{ "daodangl", |
| 99 |
> |
"Provides an improved windowed mode (-noswitch).", |
| 100 |
|
C_BOOL, |
| 101 |
|
{.intBoolVal = true}, |
| 102 |
|
{.intBoolVal = true} }, |
| 103 |
< |
{ "kickguns", |
| 104 |
< |
"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.", |
| 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 |
< |
{ "levelplugins", |
| 109 |
< |
"Allows level files to be loaded which do not end in \"_Final\".", |
| 108 |
> |
{ "gamma", |
| 109 |
> |
"Enable gamma slider in fullscreen, disable in windowed mode.", |
| 110 |
|
C_BOOL, |
| 111 |
|
{.intBoolVal = true}, |
| 112 |
|
{.intBoolVal = true} }, |
| 115 |
|
C_BOOL, |
| 116 |
|
{.intBoolVal = true}, |
| 117 |
|
{.intBoolVal = true} }, |
| 129 |
– |
{ "nomultibyte", |
| 130 |
– |
"Enables languages which use multibyte coding (such as Chinese).", |
| 131 |
– |
C_BOOL, |
| 132 |
– |
{.intBoolVal = true}, |
| 133 |
– |
{.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 |
< |
{ "pathfinding", |
| 124 |
< |
"Size of pathfinding grid cache increased by eight times in order to prevent crashes in large levels.", |
| 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 |
< |
{ "projaware", |
| 134 |
< |
"Allows AI to dodge incoming gunfire properly.", |
| 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 |
< |
{ "safeprintf", |
| 142 |
< |
"Replaces Oni's function that prints to startup.txt with a safer one.", |
| 141 |
> |
{ "fonttexturecache", |
| 142 |
> |
"Doubles size of font texture cache.", |
| 143 |
|
C_BOOL, |
| 144 |
|
{.intBoolVal = true}, |
| 145 |
|
{.intBoolVal = true} }, |
| 146 |
< |
{ "showalllasersights", |
| 147 |
< |
"Show all (also enemies') weapon lasersights.", |
| 148 |
< |
C_BOOL, |
| 149 |
< |
{.intBoolVal = false}, |
| 150 |
< |
{.intBoolVal = false} }, |
| 151 |
< |
{ "showtriggervolumes", |
| 152 |
< |
"Allows BSL variable \"show_triggervolumes\" and Ctrl+Shift+X (in devmode) to work.", |
| 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 |
< |
{ "throwtest", |
| 157 |
< |
"EXPERIMENTAL! Experiment with allowing enemies to be thrown over railings.", |
| 158 |
< |
C_BOOL, |
| 159 |
< |
{.intBoolVal = false}, |
| 160 |
< |
{.intBoolVal = false} }, |
| 169 |
< |
{ "usedaodanbsl", |
| 170 |
< |
"Adds new BSL commands.", |
| 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 |
< |
{ "usedaodangl", |
| 165 |
< |
"Provides an improved windowed mode (-noswitch).", |
| 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 |
< |
{ "usegettickcount", |
| 170 |
< |
"Replaces Oni's timing functions with more accurate ones.", |
| 169 |
> |
{ "daodanbsl", |
| 170 |
> |
"Adds new BSL commands.", |
| 171 |
|
C_BOOL, |
| 172 |
|
{.intBoolVal = true}, |
| 173 |
|
{.intBoolVal = true} }, |
| 174 |
< |
{ "widescreenportraits", |
| 175 |
< |
"Prevents fly-in portraits from being stretched when playing in widescreen resolutions.", |
| 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 |
< |
{ "wpfadetime", |
| 180 |
< |
"Adds working function for existing BSL command wp_fadetime, sets fade time to 4800.", |
| 179 |
> |
{ "largetextures", |
| 180 |
> |
"Textures up to 512x512 can be used.", |
| 181 |
|
C_BOOL, |
| 182 |
|
{.intBoolVal = true}, |
| 183 |
|
{.intBoolVal = true} }, |
| 184 |
< |
{ 0, 0, 0, {0}, {0} } |
| 185 |
< |
} }, |
| 196 |
< |
{ "options", "Options", { |
| 197 |
< |
{ "border", |
| 198 |
< |
"Add a border if in windowed mode and \"usedaodangl\" patch is active.", |
| 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, |
| 204 |
|
EXT_BOOL, |
| 205 |
|
{.intBoolVal = false }, |
| 206 |
|
{.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} }, |
| 207 |
|
{ "ignore_private_data", |
| 208 |
|
"Not useful, probably does nothing.", |
| 209 |
|
EXT_BOOL, |
| 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 |
< |
{ "language", |
| 266 |
< |
"Localization for hardcoded strings (e.g. \"Savepoints\").", |
| 267 |
< |
C_STRING, |
| 268 |
< |
{.stringVal = "en"}, |
| 269 |
< |
{.stringVal = "en"} }, |
| 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 |
|
}; |
| 316 |
|
char* name = co->name; |
| 317 |
|
char* desc = co->description; |
| 318 |
|
const char* tName = DDrConfig_GetOptionTypeName(co->type); |
| 319 |
< |
int boolV = co->defaultValue.intBoolVal; |
| 320 |
< |
char* val; |
| 321 |
< |
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 |
< |
} |
| 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"); |
| 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 -sectionX.parameterName false\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 -sectionX.parameterName\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 -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"); |
| 334 |
> |
fprintf(fp, " Oni.exe -noparameterName\n"); |
| 335 |
|
|
| 336 |
|
fclose(fp); |
| 337 |
|
} |
| 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]; |
| 412 |
|
} |
| 413 |
|
*option++ = 0; |
| 414 |
|
|
| 415 |
+ |
char isWildcardSection = !_stricmp(section, "*"); |
| 416 |
+ |
|
| 417 |
|
for (unsigned int s = 0; s < ARRAY_SIZE(config); s++) { |
| 418 |
< |
if (!_stricmp(config[s].name, section)) { |
| 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 |
< |
STARTUPMESSAGE("Could not find option \"%s\" in section \"%s\"", option, section); |
| 425 |
< |
return 0; |
| 424 |
> |
if (!isWildcardSection) { |
| 425 |
> |
STARTUPMESSAGE("Could not find option \"%s\" in section \"%s\"", option, section); |
| 426 |
> |
return 0; |
| 427 |
> |
} |
| 428 |
|
} |
| 429 |
|
} |
| 430 |
< |
STARTUPMESSAGE("Could not find section \"%s\" for option \"%s\"", section, option); |
| 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 |
|
|
| 464 |
|
|
| 465 |
|
|
| 466 |
|
|
| 467 |
< |
void DDrConfig_WriteTemplateIni() |
| 467 |
> |
void DDrConfig_WriteIni() |
| 468 |
|
{ |
| 469 |
|
FILE* fp; |
| 470 |
|
STARTUPMESSAGE("%s doesn't exist, creating", iniName); |
| 472 |
|
if (fp) |
| 473 |
|
{ |
| 474 |
|
for (unsigned int s = 0; s < ARRAY_SIZE(config); s++) { |
| 475 |
< |
fprintf(fp, "[%s]\n", config[s].name); |
| 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 |
|
} |
| 494 |
|
|
| 495 |
|
void DDrIniCallback(const char* section, const char* name, const char* value) |
| 496 |
|
{ |
| 442 |
– |
static char curSection[20]; |
| 497 |
|
char fullOptName[50]; |
| 498 |
|
|
| 499 |
|
if (!_stricmp(section, "patch")) |
| 500 |
|
section = "patches"; |
| 501 |
|
|
| 502 |
< |
strcpy(curSection, section); |
| 503 |
< |
|
| 504 |
< |
strcpy(fullOptName, curSection); |
| 451 |
< |
fullOptName[strlen(curSection)] = '.'; |
| 452 |
< |
strcpy(fullOptName+strlen(curSection)+1, name); |
| 502 |
> |
strcpy(fullOptName, section); |
| 503 |
> |
fullOptName[strlen(section)] = '.'; |
| 504 |
> |
strcpy(fullOptName+strlen(section)+1, name); |
| 505 |
|
|
| 506 |
|
ConfigOption_t* co = DDrConfig_GetOption(fullOptName); |
| 507 |
|
|
| 531 |
|
} |
| 532 |
|
} else { |
| 533 |
|
char buf[50]; |
| 534 |
< |
sprintf_s(buf, sizeof(buf), " %s.%s\n", section, name); |
| 534 |
> |
if (!_stricmp(section, "*")) |
| 535 |
> |
sprintf_s(buf, sizeof(buf), " %s\n", name); |
| 536 |
> |
else |
| 537 |
> |
sprintf_s(buf, sizeof(buf), " %s.%s\n", section, name); |
| 538 |
|
if (strlen(buf) + strlen(invalidCurParamaters) < sizeof(invalidCurParamaters) - 1) { |
| 539 |
|
strcpy(invalidCurParamaters + strlen(invalidCurParamaters), buf); |
| 540 |
|
} |
| 548 |
|
{ |
| 549 |
|
if (argv[i][0] == '-') |
| 550 |
|
{ |
| 496 |
– |
const char* section; |
| 497 |
– |
char* optionsep; |
| 551 |
|
char* option; |
| 552 |
|
bool invertedOption; |
| 553 |
|
|
| 554 |
< |
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 |
< |
} |
| 554 |
> |
option = argv[i]+1; |
| 555 |
|
|
| 556 |
|
invertedOption = (option[0] == 'n' || option[0] == 'N') && (option[1] == 'o' || option[1] == 'O'); |
| 557 |
|
if (invertedOption) |
| 560 |
|
if (i < (argc - 1) && argv[i+1][0] != '-') |
| 561 |
|
// Has value in next field |
| 562 |
|
{ |
| 563 |
< |
DDrIniCallback(section, option, argv[++i]); |
| 563 |
> |
DDrIniCallback("*", option, argv[++i]); |
| 564 |
|
} |
| 565 |
|
else |
| 566 |
|
// Implicit value |
| 567 |
|
{ |
| 568 |
< |
DDrIniCallback(section, option, (invertedOption ? "false" : "true")); |
| 568 |
> |
DDrIniCallback("*", option, (invertedOption ? "false" : "true")); |
| 569 |
|
} |
| 529 |
– |
|
| 530 |
– |
if (optionsep) |
| 531 |
– |
*optionsep = '.'; |
| 570 |
|
} |
| 571 |
|
else |
| 572 |
|
{ |
| 583 |
|
DDrConfig_InitExtBools(); |
| 584 |
|
|
| 585 |
|
if (GetFileAttributes(iniName) == INVALID_FILE_ATTRIBUTES) |
| 586 |
< |
DDrConfig_WriteTemplateIni(); |
| 586 |
> |
DDrConfig_WriteIni(); |
| 587 |
|
|
| 588 |
|
STARTUPMESSAGE("Parsing daodan.ini...", 0); |
| 589 |
|
if (!Inifile_Read(iniName, DDrIniCallback)) |
| 615 |
|
} |
| 616 |
|
} |
| 617 |
|
|
| 618 |
+ |
DDrConfig_WriteIni(); |
| 619 |
+ |
|
| 620 |
|
// DDrConfig_Print(); |
| 621 |
|
} |
| 622 |
|
|