| 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 |
+ |
static char invalidCurParamaters[1000] = ""; |
| 22 |
+ |
static char invalidTotalParamaters[3000] = ""; |
| 23 |
+ |
|
| 24 |
+ |
void DDrConfig_PrintHelp(); |
| 25 |
+ |
|
| 26 |
|
|
| 27 |
|
ConfigSection_t config[] = { |
| 28 |
|
{ "patches", "Patches", { |
| 29 |
|
{ "alttab", |
| 30 |
< |
"Allows user to switch applications while in Oni (Alt-Tab) and use Windows key, however it may enable the screensaver as well.", |
| 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 |
< |
"Textures using ARGB8888 can be used.", |
| 35 |
> |
"Allows using textures with ARGB8888.", |
| 36 |
|
C_BOOL, |
| 37 |
|
{.intBoolVal = true}, |
| 38 |
|
{.intBoolVal = true} }, |
| 41 |
|
C_BOOL, |
| 42 |
|
{.intBoolVal = true}, |
| 43 |
|
{.intBoolVal = true} }, |
| 34 |
– |
{ "bsl", |
| 35 |
– |
"Enables d_regen (unfinished) and prevents fly-in portraits from being stretched when playing in widescreen resolutions.", |
| 36 |
– |
C_BOOL, |
| 37 |
– |
{.intBoolVal = true}, |
| 38 |
– |
{.intBoolVal = true} }, |
| 39 |
– |
{ "cheater", |
| 40 |
– |
"Adds new cheat codes (see section below).", |
| 41 |
– |
C_BOOL, |
| 42 |
– |
{.intBoolVal = true}, |
| 43 |
– |
{.intBoolVal = true} }, |
| 44 |
|
{ "cheatsenabled", |
| 45 |
|
"Enables cheats without having to beat the game first.", |
| 46 |
|
C_BOOL, |
| 47 |
|
{.intBoolVal = true}, |
| 48 |
|
{.intBoolVal = true} }, |
| 49 |
|
{ "cheattable", |
| 50 |
< |
"Replaces Oni's cheat table with table that includes new cheats (see section below).", |
| 50 |
> |
"Replaces Oni's cheat table with table that includes new cheats including devmode.", |
| 51 |
|
C_BOOL, |
| 52 |
|
{.intBoolVal = true}, |
| 53 |
|
{.intBoolVal = true} }, |
| 54 |
|
{ "chinese", |
| 55 |
< |
"Allow for chinese fonts to be shown.", |
| 55 |
> |
"Allow for chinese fonts to be shown if the required DLL is available.", |
| 56 |
|
C_BOOL, |
| 57 |
|
{.intBoolVal = true}, |
| 58 |
|
{.intBoolVal = true} }, |
| 66 |
|
C_BOOL, |
| 67 |
|
{.intBoolVal = true}, |
| 68 |
|
{.intBoolVal = true} }, |
| 69 |
+ |
{ "d_regen", |
| 70 |
+ |
"Enables script command d_regen (query/set regeneration for any character).", |
| 71 |
+ |
C_BOOL, |
| 72 |
+ |
{.intBoolVal = true}, |
| 73 |
+ |
{.intBoolVal = true} }, |
| 74 |
|
{ "daodandisplayenum", |
| 75 |
< |
"Offers more display modes in the Options menu.", |
| 75 |
> |
"Offers a more accurate list of available display modes in the Options menu.", |
| 76 |
|
C_BOOL, |
| 77 |
|
{.intBoolVal = true}, |
| 78 |
|
{.intBoolVal = true} }, |
| 79 |
|
{ "directinput", |
| 80 |
< |
"Forces on DirectInput.", |
| 80 |
> |
"Enforces the usage of DirectInput on every system. Should be off for Linux/Wine.", |
| 81 |
|
C_BOOL, |
| 82 |
|
{.intBoolVal = true}, |
| 83 |
|
{.intBoolVal = true} }, |
| 84 |
|
{ "disablecmdline", |
| 85 |
< |
"Replaces existing command line parser with Daodan's in order to add new commands. Meant to be used with getcmdline.", |
| 85 |
> |
"Disables Oni's existing command line parser as Daodan has its own.", |
| 86 |
|
C_BOOL, |
| 87 |
|
{.intBoolVal = true}, |
| 88 |
|
{.intBoolVal = true} }, |
| 91 |
|
C_BOOL, |
| 92 |
|
{.intBoolVal = true}, |
| 93 |
|
{.intBoolVal = true} }, |
| 89 |
– |
{ "getcmdline", |
| 90 |
– |
"Replaces existing command line parser with Daodan's in order to add new commands. Meant to be used with disablecmdline.", |
| 91 |
– |
C_BOOL, |
| 92 |
– |
{.intBoolVal = true}, |
| 93 |
– |
{.intBoolVal = true} }, |
| 94 |
|
{ "hdscreens_lowres", |
| 95 |
< |
"???", |
| 95 |
> |
"Allow HD intro/ending screens on game resolutions smaller than 1024x768.", |
| 96 |
|
C_BOOL, |
| 97 |
|
{.intBoolVal = true}, |
| 98 |
|
{.intBoolVal = true} }, |
| 102 |
|
{.intBoolVal = true}, |
| 103 |
|
{.intBoolVal = true} }, |
| 104 |
|
{ "kickguns", |
| 105 |
< |
"Unfinished, do not use.", |
| 105 |
> |
"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} }, |
| 117 |
|
{.intBoolVal = true}, |
| 118 |
|
{.intBoolVal = true} }, |
| 119 |
|
{ "levelplugins", |
| 120 |
< |
"Allows level files to be loaded from the GDF which do not end in \"_Final\".", |
| 120 |
> |
"Allows level files to be loaded which do not end in \"_Final\".", |
| 121 |
|
C_BOOL, |
| 122 |
|
{.intBoolVal = true}, |
| 123 |
|
{.intBoolVal = true} }, |
| 124 |
|
{ "newweap", |
| 125 |
< |
"Picking up a weapon displays a message containing the weapon name and amount of ammo.", |
| 125 |
> |
"Standing above a weapon displays a message containing the weapon name and amount of ammo.", |
| 126 |
|
C_BOOL, |
| 127 |
|
{.intBoolVal = true}, |
| 128 |
|
{.intBoolVal = true} }, |
| 136 |
|
C_BOOL, |
| 137 |
|
{.intBoolVal = true}, |
| 138 |
|
{.intBoolVal = true} }, |
| 134 |
– |
{ "particledisablebit", |
| 135 |
– |
"Unlocks particle action disabling/enabling bits for all events so that a particle event can occur multiple times.", |
| 136 |
– |
C_BOOL, |
| 137 |
– |
{.intBoolVal = false}, |
| 138 |
– |
{.intBoolVal = false} }, |
| 139 |
|
{ "pathfinding", |
| 140 |
< |
"Multiplies size of pathfinding grid cache by eight in order to prevent crashes in large levels.", |
| 140 |
> |
"Size of pathfinding grid cache increased by eight times in order to prevent crashes in large levels.", |
| 141 |
|
C_BOOL, |
| 142 |
|
{.intBoolVal = true}, |
| 143 |
|
{.intBoolVal = true} }, |
| 157 |
|
{.intBoolVal = false}, |
| 158 |
|
{.intBoolVal = false} }, |
| 159 |
|
{ "showtriggervolumes", |
| 160 |
< |
"Allows BSL variable \"show_triggervolumes\" to work when set to 1.", |
| 160 |
> |
"Allows BSL variable \"show_triggervolumes\" and Ctrl+Shift+X (in devmode) to work.", |
| 161 |
|
C_BOOL, |
| 162 |
|
{.intBoolVal = true}, |
| 163 |
|
{.intBoolVal = true} }, |
| 164 |
|
{ "throwtest", |
| 165 |
< |
"Not recommended for use; experiment with allowing enemies to be thrown over railings.", |
| 165 |
> |
"EXPERIMENTAL! Experiment with allowing enemies to be thrown over railings.", |
| 166 |
|
C_BOOL, |
| 167 |
|
{.intBoolVal = false}, |
| 168 |
|
{.intBoolVal = false} }, |
| 169 |
+ |
{ "usedaodanbsl", |
| 170 |
+ |
"Adds new BSL commands.", |
| 171 |
+ |
C_BOOL, |
| 172 |
+ |
{.intBoolVal = true}, |
| 173 |
+ |
{.intBoolVal = true} }, |
| 174 |
|
{ "usedaodangl", |
| 175 |
< |
"Provides an improved windowed mode (-noswitch); this patch is known to break the hiding of the Windows taskbar in fullscreen mode.", |
| 175 |
> |
"Provides an improved windowed mode (-noswitch).", |
| 176 |
|
C_BOOL, |
| 177 |
|
{.intBoolVal = true}, |
| 178 |
|
{.intBoolVal = true} }, |
| 181 |
|
C_BOOL, |
| 182 |
|
{.intBoolVal = true}, |
| 183 |
|
{.intBoolVal = true} }, |
| 184 |
+ |
{ "widescreenportraits", |
| 185 |
+ |
"Prevents fly-in portraits from being stretched when playing in widescreen resolutions.", |
| 186 |
+ |
C_BOOL, |
| 187 |
+ |
{.intBoolVal = true}, |
| 188 |
+ |
{.intBoolVal = true} }, |
| 189 |
|
{ "wpfadetime", |
| 190 |
|
"Adds working function for existing BSL command wp_fadetime, sets fade time to 4800.", |
| 191 |
|
C_BOOL, |
| 195 |
|
} }, |
| 196 |
|
{ "options", "Options", { |
| 197 |
|
{ "border", |
| 198 |
< |
"If \"windowhack\" patch is active, make sure game window has border in windowed mode.", |
| 198 |
> |
"Add a border if in windowed mode and \"usedaodangl\" patch is active.", |
| 199 |
|
C_BOOL, |
| 200 |
|
{.intBoolVal = true}, |
| 201 |
|
{.intBoolVal = true} }, |
| 202 |
|
{ "debug", |
| 203 |
< |
"???", |
| 203 |
> |
"Not useful, probably does nothing.", |
| 204 |
|
EXT_BOOL, |
| 205 |
|
{.intBoolVal = false }, |
| 206 |
|
{.extBoolVal = &AKgDebug_DebugMaps } }, |
| 207 |
|
{ "debugfiles", |
| 208 |
< |
"???", |
| 208 |
> |
"Not useful, probably does nothing.", |
| 209 |
|
EXT_BOOL, |
| 210 |
|
{.intBoolVal = false }, |
| 211 |
|
{.extBoolVal = &BFgDebugFileEnable } }, |
| 212 |
|
{ "findsounds", |
| 213 |
< |
"???", |
| 213 |
> |
"Not useful, extends output of sound_list_broken_links.", |
| 214 |
|
EXT_BOOL, |
| 215 |
|
{.intBoolVal = false }, |
| 216 |
|
{.extBoolVal = &SSgSearchOnDisk } }, |
| 217 |
|
{ "gamma", |
| 218 |
< |
"Enable gamma slider in fullscreen.", |
| 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} }, |
| 227 |
|
{ "ignore_private_data", |
| 228 |
< |
"???", |
| 228 |
> |
"Not useful, probably does nothing.", |
| 229 |
|
EXT_BOOL, |
| 230 |
|
{.intBoolVal = false }, |
| 231 |
|
{.extBoolVal = &opt_ignore_private_data } }, |
| 232 |
|
{ "sound", |
| 233 |
< |
"???", |
| 233 |
> |
"Enable sound.", |
| 234 |
|
EXT_BOOL, |
| 235 |
|
{.intBoolVal = true }, |
| 236 |
|
{.extBoolVal = &opt_sound } }, |
| 237 |
|
{ "switch", |
| 238 |
< |
"Always switch screen to resolution on Oni's Options screen, making the game fullscreen; opposite of Oni's built-in argument \"noswitch\".", |
| 238 |
> |
"Switch to fullscreen instead of staying in a window.", |
| 239 |
|
EXT_BOOL, |
| 240 |
|
{.intBoolVal = true}, |
| 241 |
|
{.extBoolVal = &M3gResolutionSwitch} }, |
| 244 |
|
C_BOOL, |
| 245 |
|
{.intBoolVal = false}, |
| 246 |
|
{.intBoolVal = false} }, |
| 232 |
– |
{ "usedaodanbsl", |
| 233 |
– |
"Adds new BSL commands (see below).", |
| 234 |
– |
C_BOOL, |
| 235 |
– |
{.intBoolVal = true}, |
| 236 |
– |
{.intBoolVal = true} }, |
| 247 |
|
{ "language", |
| 248 |
|
"Localization for hardcoded strings (e.g. \"Savepoints\").", |
| 249 |
|
C_STRING, |
| 265 |
|
case EXT_BOOL: |
| 266 |
|
STARTUPMESSAGE("Option %s.%s = %d (def %d)", config[s].name, co->name, *co->value.extBoolVal, co->defaultValue.intBoolVal); |
| 267 |
|
break; |
| 268 |
+ |
case C_CMD: |
| 269 |
+ |
break; |
| 270 |
|
default: |
| 271 |
|
STARTUPMESSAGE("Option %s.%s = %d (def %d)", config[s].name, co->name, co->value.intBoolVal, co->defaultValue.intBoolVal); |
| 272 |
|
} |
| 274 |
|
} |
| 275 |
|
} |
| 276 |
|
|
| 277 |
+ |
void DDrConfig_PrintHelp() |
| 278 |
+ |
{ |
| 279 |
+ |
STARTUPMESSAGE("Writing Daodan help file (%s)", helpFile); |
| 280 |
+ |
|
| 281 |
+ |
FILE* fp; |
| 282 |
+ |
remove(helpFile); |
| 283 |
+ |
fp = fopen(helpFile, "w"); |
| 284 |
+ |
if (fp) |
| 285 |
+ |
{ |
| 286 |
+ |
time_t rawtime; |
| 287 |
+ |
struct tm* timeinfo; |
| 288 |
+ |
char buffer[80]; |
| 289 |
+ |
time(&rawtime); |
| 290 |
+ |
timeinfo = localtime(&rawtime); |
| 291 |
+ |
strftime(buffer, 80, "%Y-%m-%d %H:%M:%S", timeinfo); |
| 292 |
+ |
|
| 293 |
+ |
fprintf(fp, "Daodan help - generated on %s for Daodan v."DAODAN_VERSION_STRING"\n\n", buffer); |
| 294 |
+ |
fprintf(fp, "List of Daodan configuration parameters:\n"); |
| 295 |
+ |
for (unsigned int s = 0; s < ARRAY_SIZE(config); s++) { |
| 296 |
+ |
fprintf(fp, " %s - %s:\n", config[s].name, config[s].description); |
| 297 |
+ |
for (ConfigOption_t* co = config[s].options; co->name != 0; co++) { |
| 298 |
+ |
char* name = co->name; |
| 299 |
+ |
char* desc = co->description; |
| 300 |
+ |
const char* tName = DDrConfig_GetOptionTypeName(co->type); |
| 301 |
+ |
int boolV = co->defaultValue.intBoolVal; |
| 302 |
+ |
char* val; |
| 303 |
+ |
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 |
+ |
} |
| 320 |
+ |
fprintf(fp, " %-22s %6s=%-5s %s\n", name, tName, val, desc); |
| 321 |
+ |
} |
| 322 |
+ |
fprintf(fp, "\n"); |
| 323 |
+ |
} |
| 324 |
+ |
fprintf(fp, "\nConfiguration parameters can be either set in daodan.ini or passed on command line.\n\n"); |
| 325 |
+ |
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"); |
| 326 |
+ |
fprintf(fp, " [sectionX]\n parameterName = false\n"); |
| 327 |
+ |
fprintf(fp, "\nTo pass the parameter on the command line:\n"); |
| 328 |
+ |
fprintf(fp, " Oni.exe -sectionX.parameterName false\n"); |
| 329 |
+ |
fprintf(fp, "For bool parameters the value can be ommitted so it is regarded as \"true\":\n"); |
| 330 |
+ |
fprintf(fp, " Oni.exe -sectionX.parameterName\n"); |
| 331 |
+ |
fprintf(fp, "To disable a bool parameter you can prefix \"no\" to the parameter name like this:\n"); |
| 332 |
+ |
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"); |
| 337 |
+ |
|
| 338 |
+ |
fclose(fp); |
| 339 |
+ |
} |
| 340 |
+ |
else |
| 341 |
+ |
{ |
| 342 |
+ |
STARTUPMESSAGE("Writing Daodan help file failed", 0); |
| 343 |
+ |
} |
| 344 |
+ |
} |
| 345 |
+ |
|
| 346 |
|
const char* DDrConfig_GetOptionTypeName(OptionType_t type) |
| 347 |
|
{ |
| 348 |
|
switch (type) { |
| 352 |
|
return "Bool"; |
| 353 |
|
case C_STRING: |
| 354 |
|
return "String"; |
| 355 |
+ |
case C_CMD: |
| 356 |
+ |
return "Cmd"; |
| 357 |
|
case EXT_BOOL: |
| 358 |
|
return "pBool"; |
| 359 |
|
default: |
| 404 |
|
} |
| 405 |
|
|
| 406 |
|
|
| 407 |
+ |
|
| 408 |
|
void DDrConfig_InitExtBools() |
| 409 |
|
{ |
| 410 |
|
for (unsigned int s = 0; s < ARRAY_SIZE(config); s++) { |
| 418 |
|
|
| 419 |
|
|
| 420 |
|
|
| 421 |
< |
void DDrIniCallback(char* section, char* name, char* value) |
| 421 |
> |
void DDrConfig_WriteTemplateIni() |
| 422 |
> |
{ |
| 423 |
> |
FILE* fp; |
| 424 |
> |
STARTUPMESSAGE("%s doesn't exist, creating", iniName); |
| 425 |
> |
fp = fopen(iniName, "w"); |
| 426 |
> |
if (fp) |
| 427 |
> |
{ |
| 428 |
> |
for (unsigned int s = 0; s < ARRAY_SIZE(config); s++) { |
| 429 |
> |
fprintf(fp, "[%s]\n", config[s].name); |
| 430 |
> |
} |
| 431 |
> |
fclose(fp); |
| 432 |
> |
} |
| 433 |
> |
else |
| 434 |
> |
{ |
| 435 |
> |
STARTUPMESSAGE("Writing %s template file failed", iniName); |
| 436 |
> |
} |
| 437 |
> |
} |
| 438 |
> |
|
| 439 |
> |
|
| 440 |
> |
void DDrIniCallback(const char* section, const char* name, const char* value) |
| 441 |
|
{ |
| 442 |
|
static char curSection[20]; |
| 443 |
|
char fullOptName[50]; |
| 455 |
|
|
| 456 |
|
if (co) |
| 457 |
|
{ |
| 458 |
+ |
char* buf = 0; |
| 459 |
|
switch (co->type) { |
| 460 |
|
case C_INT: |
| 461 |
|
co->value.intBoolVal = strtol(value, NULL, 0); |
| 464 |
|
co->value.intBoolVal = !_stricmp(value, "true"); |
| 465 |
|
break; |
| 466 |
|
case C_STRING: |
| 467 |
< |
co->value.stringVal = value; |
| 467 |
> |
buf = malloc(strlen(value)+1); |
| 468 |
> |
strcpy(buf, value); |
| 469 |
> |
co->value.stringVal = buf; |
| 470 |
> |
break; |
| 471 |
> |
case C_CMD: |
| 472 |
> |
co->value.callback(); |
| 473 |
|
break; |
| 474 |
|
case EXT_BOOL: |
| 475 |
|
*(co->value.extBoolVal) = !_stricmp(value, "true"); |
| 477 |
|
default: |
| 478 |
|
STARTUPMESSAGE("Config value type unknown: %d", co->type); |
| 479 |
|
} |
| 480 |
+ |
} else { |
| 481 |
+ |
char buf[50]; |
| 482 |
+ |
sprintf_s(buf, sizeof(buf), " %s.%s\n", section, name); |
| 483 |
+ |
if (strlen(buf) + strlen(invalidCurParamaters) < sizeof(invalidCurParamaters) - 1) { |
| 484 |
+ |
strcpy(invalidCurParamaters + strlen(invalidCurParamaters), buf); |
| 485 |
+ |
} |
| 486 |
|
} |
| 487 |
|
} |
| 488 |
|
|
| 489 |
< |
void DDrConfig_WriteTemplateIni() |
| 489 |
> |
|
| 490 |
> |
bool DDrConfig_ParseCommandLine(int argc, char* argv[]) |
| 491 |
|
{ |
| 492 |
< |
FILE* fp; |
| 377 |
< |
STARTUPMESSAGE("%s doesn't exist, creating", iniName); |
| 378 |
< |
fp = fopen(iniName, "w"); |
| 379 |
< |
if (fp) |
| 492 |
> |
for (int i = 1; i < argc; i ++) |
| 493 |
|
{ |
| 494 |
< |
for (unsigned int s = 0; s < ARRAY_SIZE(config); s++) { |
| 495 |
< |
fprintf(fp, "[%s]\n", config[s].name); |
| 494 |
> |
if (argv[i][0] == '-') |
| 495 |
> |
{ |
| 496 |
> |
const char* section; |
| 497 |
> |
char* optionsep; |
| 498 |
> |
char* option; |
| 499 |
> |
bool invertedOption; |
| 500 |
> |
|
| 501 |
> |
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 |
> |
} |
| 514 |
> |
|
| 515 |
> |
invertedOption = (option[0] == 'n' || option[0] == 'N') && (option[1] == 'o' || option[1] == 'O'); |
| 516 |
> |
if (invertedOption) |
| 517 |
> |
option += 2; |
| 518 |
> |
|
| 519 |
> |
if (i < (argc - 1) && argv[i+1][0] != '-') |
| 520 |
> |
// Has value in next field |
| 521 |
> |
{ |
| 522 |
> |
DDrIniCallback(section, option, argv[++i]); |
| 523 |
> |
} |
| 524 |
> |
else |
| 525 |
> |
// Implicit value |
| 526 |
> |
{ |
| 527 |
> |
DDrIniCallback(section, option, (invertedOption ? "false" : "true")); |
| 528 |
> |
} |
| 529 |
> |
|
| 530 |
> |
if (optionsep) |
| 531 |
> |
*optionsep = '.'; |
| 532 |
> |
} |
| 533 |
> |
else |
| 534 |
> |
{ |
| 535 |
> |
STARTUPMESSAGE("Parse error \"%s\"", argv[i]); |
| 536 |
> |
return false; |
| 537 |
|
} |
| 384 |
– |
fclose(fp); |
| 538 |
|
} |
| 539 |
+ |
return true; |
| 540 |
|
} |
| 541 |
|
|
| 388 |
– |
|
| 542 |
|
void DDrConfig(int argc, char* argv[]) |
| 543 |
|
{ |
| 544 |
< |
int i; |
| 392 |
< |
char* section; |
| 393 |
< |
char* option; |
| 394 |
< |
bool falseoption; |
| 395 |
< |
|
| 544 |
> |
STARTUPMESSAGE("Initializing standard booleans", 0); |
| 545 |
|
DDrConfig_InitExtBools(); |
| 546 |
|
|
| 547 |
|
if (GetFileAttributes(iniName) == INVALID_FILE_ATTRIBUTES) |
| 552 |
|
STARTUPMESSAGE("Error reading daodan.ini, check your syntax!", 0); |
| 553 |
|
STARTUPMESSAGE("Finished parsing", 0); |
| 554 |
|
|
| 555 |
< |
|
| 555 |
> |
if (strlen(invalidCurParamaters) > 0) |
| 556 |
> |
{ |
| 557 |
> |
sprintf_s(invalidTotalParamaters, sizeof(invalidTotalParamaters), "In %s:\n%s\n", iniName, invalidCurParamaters); |
| 558 |
> |
invalidCurParamaters[0] = 0; |
| 559 |
> |
} |
| 560 |
|
|
| 561 |
|
STARTUPMESSAGE("Parsing command line...", 0); |
| 562 |
< |
for (i = 1; i < argc; i ++) |
| 562 |
> |
DDrConfig_ParseCommandLine(argc, argv); |
| 563 |
> |
STARTUPMESSAGE("Finished parsing", 0); |
| 564 |
> |
|
| 565 |
> |
if (strlen(invalidCurParamaters) > 0) |
| 566 |
|
{ |
| 567 |
< |
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 |
< |
} |
| 567 |
> |
sprintf_s(invalidTotalParamaters, sizeof(invalidTotalParamaters), "%sOn command line:\n%s\n", invalidTotalParamaters, invalidCurParamaters); |
| 568 |
|
} |
| 439 |
– |
STARTUPMESSAGE("Finished parsing", 0); |
| 440 |
– |
} |
| 569 |
|
|
| 570 |
+ |
if (strlen(invalidTotalParamaters) > 0) |
| 571 |
+ |
{ |
| 572 |
+ |
char msg[3200]; |
| 573 |
+ |
sprintf_s(msg, sizeof(msg), "Invalid parameters given:\n%sContinue launching Oni?", invalidTotalParamaters); |
| 574 |
+ |
int res = MessageBox(NULL, msg, "Parameters invalid", MB_ICONWARNING | MB_YESNO | MB_DEFBUTTON1); |
| 575 |
+ |
if (res == IDNO) { |
| 576 |
+ |
exit(0); |
| 577 |
+ |
} |
| 578 |
+ |
} |
| 579 |
|
|
| 580 |
< |
/* |
| 581 |
< |
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 |
< |
*/ |
| 580 |
> |
// DDrConfig_Print(); |
| 581 |
> |
} |
| 582 |
|
|