| 1 |  | #include <windows.h> | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 2 |  | #include <string.h> | 
 
 
 
 
 
 
 
 | 3 | + | #include <time.h> | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 4 |  |  | 
 
 
 
 
 
 
 
 
 | 4 | – | #include "Daodan_Cheater.h" | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 5 |  | #include "Daodan_Config.h" | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 6 |  | #include "Daodan_Patch.h" | 
 
 
 
 
 
 
 
 
 
 
 | 7 | < | #include "Daodan_Utility.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 | + | void DDrConfig_PrintHelp(); | 
 
 
 
 
 
 
 
 | 22 | + |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 23 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 24 |  | ConfigSection_t config[] = { | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 25 |  | { "patches", "Patches", { | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 99 |  | {.intBoolVal = true}, | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 100 |  | {.intBoolVal = true} }, | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 101 |  | { "hdscreens_lowres", | 
 
 
 
 
 
 
 
 
 
 
 | 102 | < | "???", | 
 
 
 
 
 
 
 
 
 | 102 | > | "Allow HD screens with resolution < 1024*768.", | 
 
 
 
 
 
 
 
 
 
 
 | 103 |  | C_BOOL, | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 104 |  | {.intBoolVal = true}, | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 105 |  | {.intBoolVal = true} }, | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 216 |  | C_BOOL, | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 217 |  | {.intBoolVal = true}, | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 218 |  | {.intBoolVal = true} }, | 
 
 
 
 
 
 
 
 | 219 | + | { "help", | 
 
 
 
 
 
 
 
 | 220 | + | "Generates this help file.", | 
 
 
 
 
 
 
 
 | 221 | + | C_CMD, | 
 
 
 
 
 
 
 
 | 222 | + | {.intBoolVal = 0}, | 
 
 
 
 
 
 
 
 | 223 | + | {.callback = DDrConfig_PrintHelp} }, | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 224 |  | { "ignore_private_data", | 
 
 
 
 
 
 
 
 
 
 
 | 225 | < | "???", | 
 
 
 
 
 
 
 
 
 | 225 | > | "? No effect ?", | 
 
 
 
 
 
 
 
 
 
 
 | 226 |  | EXT_BOOL, | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 227 |  | {.intBoolVal = false }, | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 228 |  | {.extBoolVal = &opt_ignore_private_data } }, | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 267 |  | case EXT_BOOL: | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 268 |  | STARTUPMESSAGE("Option %s.%s = %d (def %d)", config[s].name, co->name, *co->value.extBoolVal, co->defaultValue.intBoolVal); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 269 |  | break; | 
 
 
 
 
 
 
 
 | 270 | + | case C_CMD: | 
 
 
 
 
 
 
 
 | 271 | + | break; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 272 |  | default: | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 273 |  | STARTUPMESSAGE("Option %s.%s = %d (def %d)", config[s].name, co->name, co->value.intBoolVal, co->defaultValue.intBoolVal); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 274 |  | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 276 |  | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 277 |  | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 278 |  |  | 
 
 
 
 
 
 
 
 | 279 | + | void DDrConfig_PrintHelp() | 
 
 
 
 
 
 
 
 | 280 | + | { | 
 
 
 
 
 
 
 
 | 281 | + | STARTUPMESSAGE("Writing Daodan help file (%s)", helpFile); | 
 
 
 
 
 
 
 
 | 282 | + |  | 
 
 
 
 
 
 
 
 | 283 | + | FILE* fp; | 
 
 
 
 
 
 
 
 | 284 | + | remove(helpFile); | 
 
 
 
 
 
 
 
 | 285 | + | fp = fopen(helpFile, "w"); | 
 
 
 
 
 
 
 
 | 286 | + | if (fp) | 
 
 
 
 
 
 
 
 | 287 | + | { | 
 
 
 
 
 
 
 
 | 288 | + | time_t rawtime; | 
 
 
 
 
 
 
 
 | 289 | + | struct tm* timeinfo; | 
 
 
 
 
 
 
 
 | 290 | + | char buffer[80]; | 
 
 
 
 
 
 
 
 | 291 | + | time(&rawtime); | 
 
 
 
 
 
 
 
 | 292 | + | timeinfo = localtime(&rawtime); | 
 
 
 
 
 
 
 
 | 293 | + | strftime(buffer, 80, "%Y-%m-%d %H:%M:%S", timeinfo); | 
 
 
 
 
 
 
 
 | 294 | + |  | 
 
 
 
 
 
 
 
 | 295 | + | fprintf(fp, "Daodan help - generated on %s for Daodan v."DAODAN_VERSION_STRING"\n\n", buffer); | 
 
 
 
 
 
 
 
 | 296 | + | fprintf(fp, "List of Daodan configuration parameters:\n"); | 
 
 
 
 
 
 
 
 | 297 | + | for (unsigned int s = 0; s < ARRAY_SIZE(config); s++) { | 
 
 
 
 
 
 
 
 | 298 | + | fprintf(fp, "    %s - %s:\n", config[s].name, config[s].description); | 
 
 
 
 
 
 
 
 | 299 | + | for (ConfigOption_t* co = config[s].options; co->name != 0; co++) { | 
 
 
 
 
 
 
 
 | 300 | + | char* name = co->name; | 
 
 
 
 
 
 
 
 | 301 | + | char* desc = co->description; | 
 
 
 
 
 
 
 
 | 302 | + | const char* tName = DDrConfig_GetOptionTypeName(co->type); | 
 
 
 
 
 
 
 
 | 303 | + | int boolV = co->defaultValue.intBoolVal; | 
 
 
 
 
 
 
 
 | 304 | + | char* val; | 
 
 
 
 
 
 
 
 | 305 | + | switch (co->type) { | 
 
 
 
 
 
 
 
 | 306 | + | case C_STRING: | 
 
 
 
 
 
 
 
 | 307 | + | val = co->defaultValue.stringVal; | 
 
 
 
 
 
 
 
 | 308 | + | break; | 
 
 
 
 
 
 
 
 | 309 | + | case EXT_BOOL: | 
 
 
 
 
 
 
 
 | 310 | + | val = (boolV ? "true" : "false"); | 
 
 
 
 
 
 
 
 | 311 | + | break; | 
 
 
 
 
 
 
 
 | 312 | + | case C_BOOL: | 
 
 
 
 
 
 
 
 | 313 | + | val = (boolV ? "true" : "false"); | 
 
 
 
 
 
 
 
 | 314 | + | break; | 
 
 
 
 
 
 
 
 | 315 | + | case C_CMD: | 
 
 
 
 
 
 
 
 | 316 | + | val = ""; | 
 
 
 
 
 
 
 
 | 317 | + | break; | 
 
 
 
 
 
 
 
 | 318 | + | default: | 
 
 
 
 
 
 
 
 | 319 | + | val = malloc(20); | 
 
 
 
 
 
 
 
 | 320 | + | sprintf(val, "%d", boolV); | 
 
 
 
 
 
 
 
 | 321 | + | } | 
 
 
 
 
 
 
 
 | 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 -sectionX.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"); | 
 
 
 
 
 
 
 
 | 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"); | 
 
 
 
 
 
 
 
 | 335 | + | fprintf(fp, "If no section is given it is assumed to be \"%s\", e.g.\n", defaultSection); | 
 
 
 
 
 
 
 
 | 336 | + | fprintf(fp, "    Oni.exe -%s.parametername\n", defaultSection); | 
 
 
 
 
 
 
 
 | 337 | + | fprintf(fp, "can simply be written as\n"); | 
 
 
 
 
 
 
 
 | 338 | + | fprintf(fp, "    Oni.exe -parametername\n"); | 
 
 
 
 
 
 
 
 | 339 | + |  | 
 
 
 
 
 
 
 
 | 340 | + | fclose(fp); | 
 
 
 
 
 
 
 
 | 341 | + | } | 
 
 
 
 
 
 
 
 | 342 | + | else | 
 
 
 
 
 
 
 
 | 343 | + | { | 
 
 
 
 
 
 
 
 | 344 | + | STARTUPMESSAGE("Writing Daodan help file failed", 0); | 
 
 
 
 
 
 
 
 | 345 | + | } | 
 
 
 
 
 
 
 
 | 346 | + | } | 
 
 
 
 
 
 
 
 | 347 | + |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 348 |  | const char* DDrConfig_GetOptionTypeName(OptionType_t type) | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 349 |  | { | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 350 |  | switch (type) { | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 354 |  | return "Bool"; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 355 |  | case C_STRING: | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 356 |  | return "String"; | 
 
 
 
 
 
 
 
 | 357 | + | case C_CMD: | 
 
 
 
 
 
 
 
 | 358 | + | return "Cmd"; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 359 |  | case EXT_BOOL: | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 360 |  | return "pBool"; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 361 |  | default: | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 406 |  | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 407 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 408 |  |  | 
 
 
 
 
 
 
 
 | 409 | + |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 410 |  | void DDrConfig_InitExtBools() | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 411 |  | { | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 412 |  | for (unsigned int s = 0; s < ARRAY_SIZE(config); s++) { | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 420 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 421 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 422 |  |  | 
 
 
 
 
 
 
 
 
 
 
 | 423 | < | void DDrIniCallback(char* section, char* name, char* value) | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 423 | > | void DDrConfig_WriteTemplateIni() | 
 
 
 
 
 | 424 | > | { | 
 
 
 
 
 | 425 | > | FILE* fp; | 
 
 
 
 
 | 426 | > | STARTUPMESSAGE("%s doesn't exist, creating", iniName); | 
 
 
 
 
 | 427 | > | fp = fopen(iniName, "w"); | 
 
 
 
 
 | 428 | > | if (fp) | 
 
 
 
 
 | 429 | > | { | 
 
 
 
 
 | 430 | > | for (unsigned int s = 0; s < ARRAY_SIZE(config); s++) { | 
 
 
 
 
 | 431 | > | fprintf(fp, "[%s]\n", config[s].name); | 
 
 
 
 
 | 432 | > | } | 
 
 
 
 
 | 433 | > | fclose(fp); | 
 
 
 
 
 | 434 | > | } | 
 
 
 
 
 | 435 | > | else | 
 
 
 
 
 | 436 | > | { | 
 
 
 
 
 | 437 | > | STARTUPMESSAGE("Writing %s template file failed", iniName); | 
 
 
 
 
 | 438 | > | } | 
 
 
 
 
 | 439 | > | } | 
 
 
 
 
 | 440 | > |  | 
 
 
 
 
 | 441 | > |  | 
 
 
 
 
 | 442 | > | void DDrIniCallback(const char* section, const char* name, const char* value) | 
 
 
 
 
 
 
 
 
 
 
 | 443 |  | { | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 444 |  | static char curSection[20]; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 445 |  | char fullOptName[50]; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 457 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 458 |  | if (co) | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 459 |  | { | 
 
 
 
 
 
 
 
 | 460 | + | char* buf = 0; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 461 |  | switch (co->type) { | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 462 |  | case C_INT: | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 463 |  | co->value.intBoolVal = strtol(value, NULL, 0); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 466 |  | co->value.intBoolVal = !_stricmp(value, "true"); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 467 |  | break; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 468 |  | case C_STRING: | 
 
 
 
 
 
 
 
 
 
 
 | 469 | < | co->value.stringVal = value; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 469 | > | buf = malloc(strlen(value)+1); | 
 
 
 
 
 | 470 | > | strcpy(buf, value); | 
 
 
 
 
 | 471 | > | co->value.stringVal = buf; | 
 
 
 
 
 | 472 | > | break; | 
 
 
 
 
 | 473 | > | case C_CMD: | 
 
 
 
 
 | 474 | > | co->value.callback(); | 
 
 
 
 
 
 
 
 
 
 
 | 475 |  | break; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 476 |  | case EXT_BOOL: | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 477 |  | *(co->value.extBoolVal) = !_stricmp(value, "true"); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 482 |  | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 483 |  | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 484 |  |  | 
 
 
 
 
 
 
 
 
 
 
 | 485 | < | void DDrConfig_WriteTemplateIni() | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 485 | > |  | 
 
 
 
 
 | 486 | > | bool DDrConfig_ParseCommandLine(int argc, char* argv[]) | 
 
 
 
 
 
 
 
 
 
 
 | 487 |  | { | 
 
 
 
 
 
 
 
 
 
 
 | 488 | < | FILE* fp; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 377 | < | STARTUPMESSAGE("%s doesn't exist, creating", iniName); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 378 | < | fp = fopen(iniName, "w"); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 379 | < | if (fp) | 
 
 
 
 
 
 
 
 
 | 488 | > | for (int i = 1; i < argc; i ++) | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 489 |  | { | 
 
 
 
 
 
 
 
 
 
 
 | 490 | < | for (unsigned int s = 0; s < ARRAY_SIZE(config); s++) { | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 491 | < | fprintf(fp, "[%s]\n", config[s].name); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 490 | > | if (argv[i][0] == '-') | 
 
 
 
 
 | 491 | > | { | 
 
 
 
 
 | 492 | > | const char* section; | 
 
 
 
 
 | 493 | > | char* optionsep; | 
 
 
 
 
 | 494 | > | char* option; | 
 
 
 
 
 | 495 | > | bool invertedOption; | 
 
 
 
 
 | 496 | > |  | 
 
 
 
 
 | 497 | > | if ((optionsep = strchr(argv[i], '.'))) | 
 
 
 
 
 | 498 | > | // Is "section.option" | 
 
 
 
 
 | 499 | > | { | 
 
 
 
 
 | 500 | > | *optionsep = 0; | 
 
 
 
 
 | 501 | > | option = optionsep+1; | 
 
 
 
 
 | 502 | > | section = argv[i]+1; | 
 
 
 
 
 | 503 | > | } | 
 
 
 
 
 | 504 | > | else | 
 
 
 
 
 | 505 | > | // Is just "option" | 
 
 
 
 
 | 506 | > | { | 
 
 
 
 
 | 507 | > | section = defaultSection; | 
 
 
 
 
 | 508 | > | option = argv[i]+1; | 
 
 
 
 
 | 509 | > | } | 
 
 
 
 
 | 510 | > |  | 
 
 
 
 
 | 511 | > | invertedOption = (option[0] == 'n' || option[0] == 'N') && (option[1] == 'o' || option[1] == 'O'); | 
 
 
 
 
 | 512 | > | if (invertedOption) | 
 
 
 
 
 | 513 | > | option += 2; | 
 
 
 
 
 | 514 | > |  | 
 
 
 
 
 | 515 | > | if (i < (argc - 1) && argv[i+1][0] != '-') | 
 
 
 
 
 | 516 | > | // Has value in next field | 
 
 
 
 
 | 517 | > | { | 
 
 
 
 
 | 518 | > | DDrIniCallback(section, option, argv[++i]); | 
 
 
 
 
 | 519 | > | } | 
 
 
 
 
 | 520 | > | else | 
 
 
 
 
 | 521 | > | // Implicit value | 
 
 
 
 
 | 522 | > | { | 
 
 
 
 
 | 523 | > | DDrIniCallback(section, option, (invertedOption ? "false" : "true")); | 
 
 
 
 
 | 524 | > | } | 
 
 
 
 
 | 525 | > |  | 
 
 
 
 
 | 526 | > | if (optionsep) | 
 
 
 
 
 | 527 | > | *optionsep = '.'; | 
 
 
 
 
 | 528 | > | } | 
 
 
 
 
 | 529 | > | else | 
 
 
 
 
 | 530 | > | { | 
 
 
 
 
 | 531 | > | STARTUPMESSAGE("Parse error \"%s\"", argv[i]); | 
 
 
 
 
 | 532 | > | return false; | 
 
 
 
 
 
 
 
 
 
 
 | 533 |  | } | 
 
 
 
 
 
 
 
 
 | 384 | – | fclose(fp); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 534 |  | } | 
 
 
 
 
 
 
 
 | 535 | + | return true; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 536 |  | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 537 |  |  | 
 
 
 
 
 
 
 
 
 | 388 | – |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 538 |  | void DDrConfig(int argc, char* argv[]) | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 539 |  | { | 
 
 
 
 
 
 
 
 
 
 
 | 540 | < | int i; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 392 | < | char* section; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 393 | < | char* option; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 394 | < | bool falseoption; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 395 | < |  | 
 
 
 
 
 
 
 
 
 | 540 | > | STARTUPMESSAGE("Initializing standard booleans", 0); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 541 |  | DDrConfig_InitExtBools(); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 542 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 543 |  | if (GetFileAttributes(iniName) == INVALID_FILE_ATTRIBUTES) | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 551 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 552 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 553 |  | STARTUPMESSAGE("Parsing command line...", 0); | 
 
 
 
 
 
 
 
 
 
 
 | 554 | < | for (i = 1; i < argc; i ++) | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 410 | < | { | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 411 | < | if (argv[i][0] == '-') | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 412 | < | { | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 413 | < | section = argv[i] + 1; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 414 | < | if ((option = strchr(argv[i], '.'))) | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 415 | < | { | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 416 | < | *option = '\0'; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 417 | < | falseoption = (option[1] == 'n' || option[1] == 'N') && (option[2] == 'o' || option[2] == 'O'); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 418 | < | if (i < (argc - 1) && argv[i + 1][0] != '-') | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 419 | < | DDrIniCallback(section, option + 1, argv[++i]); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 420 | < | else | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 421 | < | DDrIniCallback(section, option + (falseoption ? 3 : 1), (falseoption ? "false" : "true")); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 422 | < | *option = '.'; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 423 | < | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 424 | < | else | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 425 | < | { | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 426 | < | falseoption = (section[0] == 'n' || section[0] == 'N') && (section[1] == 'o' || section[1] == 'O'); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 427 | < | if (i < (argc - 1) && argv[i + 1][0] != '-') | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 428 | < | DDrIniCallback("options", section, argv[++i]); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 429 | < | else | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 430 | < | DDrIniCallback("options", section + (falseoption ? 2 : 0), (falseoption ? "false" : "true")); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 431 | < | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 432 | < | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 433 | < | else | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 434 | < | { | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 435 | < | STARTUPMESSAGE("Parse error \"%s\"", argv[i]); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 436 | < | break; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 437 | < | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 438 | < | } | 
 
 
 
 
 
 
 
 
 | 554 | > | DDrConfig_ParseCommandLine(argc, argv); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 555 |  | STARTUPMESSAGE("Finished parsing", 0); | 
 
 
 
 
 
 
 
 
 | 440 | – | } | 
 
 
 
 
 
 
 
 
 | 441 | – |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 556 |  |  | 
 
 
 
 
 
 
 
 
 
 
 | 557 | < | /* | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 558 | < | case s_language: | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 445 | < | else if (!_stricmp(name, "blam")) | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 446 | < | DDrPatch__strdup((int*)(OniExe + 0x0010fb73), value); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 447 | < | else if (!_stricmp(name, "damn")) | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 448 | < | DDrPatch__strdup((int*)(OniExe + 0x0010fb6e), value); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 449 | < | else if (!_stricmp(name, "savepoint")) | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 450 | < | { | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 451 | < | char* str = _strdup(value); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 452 | < | DDrPatch_Int32((int*)(OniExe + 0x000fd730), (int)str); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 453 | < | DDrPatch_Int32((int*)(OniExe + 0x000fd738), (int)str); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 454 | < | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 455 | < | else if (!_stricmp(name, "syndicatewarehouse")) | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 456 | < | { | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 457 | < | char* str = _strdup(value); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 458 | < | DDrPatch_Int32((int*)(OniExe + 0x000fd71a), (int)str); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 459 | < | DDrPatch_Int32((int*)(OniExe + 0x0010ef75), (int)str); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 460 | < | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 461 | < | else if (!_stricmp(name, "shapeshifter_on")) | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 462 | < | DDr_CheatTable[0].message_on = _strdup(value); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 463 | < | else if (!_stricmp(name, "shapeshifter_off")) | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 464 | < | DDr_CheatTable[0].message_off = _strdup(value); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 465 | < | else if (!_stricmp(name, "liveforever_on")) | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 466 | < | DDr_CheatTable[1].message_on = _strdup(value); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 467 | < | else if (!_stricmp(name, "liveforever_off")) | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 468 | < | DDr_CheatTable[1].message_off = _strdup(value); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 469 | < | else if (!_stricmp(name, "touchofdeath_on")) | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 470 | < | DDr_CheatTable[2].message_on = _strdup(value); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 471 | < | else if (!_stricmp(name, "touchofdeath_off")) | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 472 | < | DDr_CheatTable[2].message_off = _strdup(value); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 473 | < | else if (!_stricmp(name, "canttouchthis_on")) | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 474 | < | DDr_CheatTable[3].message_on = _strdup(value); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 475 | < | else if (!_stricmp(name, "canttouchthis_off")) | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 476 | < | DDr_CheatTable[3].message_off = _strdup(value); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 477 | < | else if (!_stricmp(name, "fatloot_on")) | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 478 | < | DDr_CheatTable[4].message_on = _strdup(value); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 479 | < | else if (!_stricmp(name, "glassworld_on")) | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 480 | < | DDr_CheatTable[5].message_on = _strdup(value); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 481 | < | else if (!_stricmp(name, "glassworld_off")) | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 482 | < | DDr_CheatTable[5].message_off = _strdup(value); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 483 | < | else if (!_stricmp(name, "winlevel_on")) | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 484 | < | DDr_CheatTable[6].message_on = _strdup(value); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 485 | < | else if (!_stricmp(name, "loselevel_on")) | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 486 | < | DDr_CheatTable[7].message_on = _strdup(value); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 487 | < | else if (!_stricmp(name, "bighead_on")) | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 488 | < | DDr_CheatTable[8].message_on = _strdup(value); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 489 | < | else if (!_stricmp(name, "bighead_off")) | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 490 | < | DDr_CheatTable[8].message_off = _strdup(value); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 491 | < | else if (!_stricmp(name, "minime_on")) | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 492 | < | DDr_CheatTable[9].message_on = _strdup(value); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 493 | < | else if (!_stricmp(name, "minime_off")) | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 494 | < | DDr_CheatTable[9].message_off = _strdup(value); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 495 | < | else if (!_stricmp(name, "superammo_on")) | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 496 | < | DDr_CheatTable[10].message_on = _strdup(value); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 497 | < | else if (!_stricmp(name, "superammo_off")) | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 498 | < | DDr_CheatTable[10].message_off = _strdup(value); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 499 | < | else if (!_stricmp(name, "devmode_on")) | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 500 | < | { | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 501 | < | char* str = _strdup(value); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 502 | < | DDr_CheatTable[11].message_on = str; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 503 | < | DDr_CheatTable[cheat_x].message_on = str; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 504 | < | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 505 | < | else if (!_stricmp(name, "devmode_off")) | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 506 | < | { | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 507 | < | char* str = _strdup(value); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 508 | < | DDr_CheatTable[11].message_off = str; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 509 | < | DDr_CheatTable[cheat_x].message_off = str; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 510 | < | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 511 | < | else if (!_stricmp(name, "reservoirdogs_on")) | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 512 | < | DDr_CheatTable[12].message_on = _strdup(value); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 513 | < | else if (!_stricmp(name, "reservoirdogs_off")) | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 514 | < | DDr_CheatTable[12].message_off = _strdup(value); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 515 | < | else if (!_stricmp(name, "roughjustice_on")) | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 516 | < | DDr_CheatTable[13].message_on = _strdup(value); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 517 | < | else if (!_stricmp(name, "roughjustice_off")) | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 518 | < | DDr_CheatTable[13].message_off = _strdup(value); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 519 | < | else if (!_stricmp(name, "chenille_on")) | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 520 | < | DDr_CheatTable[14].message_on = _strdup(value); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 521 | < | else if (!_stricmp(name, "chenille_off")) | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 522 | < | DDr_CheatTable[14].message_off = _strdup(value); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 523 | < | else if (!_stricmp(name, "behemoth_on")) | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 524 | < | DDr_CheatTable[15].message_on = _strdup(value); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 525 | < | else if (!_stricmp(name, "behemoth_off")) | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 526 | < | DDr_CheatTable[15].message_off = _strdup(value); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 527 | < | else if (!_stricmp(name, "elderrune_on")) | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 528 | < | DDr_CheatTable[16].message_on = _strdup(value); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 529 | < | else if (!_stricmp(name, "elderrune_off")) | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 530 | < | DDr_CheatTable[16].message_off = _strdup(value); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 531 | < | else if (!_stricmp(name, "moonshadow_on")) | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 532 | < | DDr_CheatTable[17].message_on = _strdup(value); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 533 | < | else if (!_stricmp(name, "moonshadow_off")) | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 534 | < | DDr_CheatTable[17].message_off = _strdup(value); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 535 | < | else if (!_stricmp(name, "munitionfrenzy_on")) | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 536 | < | DDr_CheatTable[18].message_on = _strdup(value); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 537 | < | else if (!_stricmp(name, "fistsoflegend_on")) | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 538 | < | DDr_CheatTable[19].message_on = _strdup(value); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 539 | < | else if (!_stricmp(name, "fistsoflegend_off")) | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 540 | < | DDr_CheatTable[19].message_off = _strdup(value); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 541 | < | else if (!_stricmp(name, "killmequick_on")) | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 542 | < | DDr_CheatTable[20].message_on = _strdup(value); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 543 | < | else if (!_stricmp(name, "killmequick_off")) | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 544 | < | DDr_CheatTable[20].message_off = _strdup(value); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 545 | < | else if (!_stricmp(name, "carousel_on")) | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 546 | < | DDr_CheatTable[21].message_on = _strdup(value); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 547 | < | else if (!_stricmp(name, "carousel_off")) | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 548 | < | DDr_CheatTable[21].message_off = _strdup(value); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 549 | < | */ | 
 
 
 
 
 
 
 
 
 | 557 | > | //      DDrConfig_Print(); | 
 
 
 
 
 | 558 | > | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 559 |  |  |