- Timestamp:
- Apr 7, 2014, 12:33:27 PM (11 years ago)
- Location:
- Daodan
- Files:
-
- 20 added
- 18 deleted
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
Daodan/src/Daodan.c
r993 r994 6 6 #include "Daodan.h" 7 7 #include "Daodan_Patch.h" 8 #include " Daodan_Utility.h"9 #include " Daodan_Cheater.h"10 #include " Daodan_BSL.h"11 #include " Daodan_Console.h"8 #include "Patches/Utility.h" 9 #include "Patches/Cheater.h" 10 #include "Patches/BSL.h" 11 #include "Patches/Console.h" 12 12 #include "Daodan_Config.h" 13 #include "patches/Patches.h" 13 #include "Patches/Patches.h" 14 #include "Patches/Localization.h" 14 15 #include "bink-proxy.h" 15 16 #include "_Version.h" … … 33 34 34 35 DDrConfig(argc, argv); 36 DD_Localization(); 35 37 36 38 if(GetKeyState(VK_SHIFT) & 0x8000) { -
Daodan/src/Daodan_Config.c
r993 r994 1 1 #include <windows.h> 2 2 #include <string.h> 3 4 #include "Daodan_Cheater.h" 3 #include <time.h> 4 5 5 #include "Daodan_Config.h" 6 6 #include "Daodan_Patch.h" 7 #include " Daodan_Utility.h"7 #include "Patches/Utility.h" 8 8 9 9 #include "Oni/Oni.h" 10 #include "_Version.h" 10 11 11 12 #include "Inifile_Reader.h" … … 14 15 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 16 23 17 24 ConfigSection_t config[] = { … … 93 100 {.intBoolVal = true} }, 94 101 { "hdscreens_lowres", 95 " ???",102 "Allow HD screens with resolution < 1024*768.", 96 103 C_BOOL, 97 104 {.intBoolVal = true}, … … 210 217 {.intBoolVal = true}, 211 218 {.intBoolVal = true} }, 219 { "help", 220 "Generates this help file.", 221 C_CMD, 222 {.intBoolVal = 0}, 223 {.callback = DDrConfig_PrintHelp} }, 212 224 { "ignore_private_data", 213 "? ??",225 "? No effect ?", 214 226 EXT_BOOL, 215 227 {.intBoolVal = false }, … … 256 268 STARTUPMESSAGE("Option %s.%s = %d (def %d)", config[s].name, co->name, *co->value.extBoolVal, co->defaultValue.intBoolVal); 257 269 break; 270 case C_CMD: 271 break; 258 272 default: 259 273 STARTUPMESSAGE("Option %s.%s = %d (def %d)", config[s].name, co->name, co->value.intBoolVal, co->defaultValue.intBoolVal); 260 274 } 261 275 } 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); 262 345 } 263 346 } … … 272 355 case C_STRING: 273 356 return "String"; 357 case C_CMD: 358 return "Cmd"; 274 359 case EXT_BOOL: 275 360 return "pBool"; … … 322 407 323 408 409 324 410 void DDrConfig_InitExtBools() 325 411 { … … 335 421 336 422 337 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) 338 443 { 339 444 static char curSection[20]; … … 353 458 if (co) 354 459 { 460 char* buf = 0; 355 461 switch (co->type) { 356 462 case C_INT: … … 361 467 break; 362 468 case C_STRING: 363 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(); 364 475 break; 365 476 case EXT_BOOL: … … 372 483 } 373 484 374 void DDrConfig_WriteTemplateIni() 375 { 376 FILE* fp; 377 STARTUPMESSAGE("%s doesn't exist, creating", iniName); 378 fp = fopen(iniName, "w"); 379 if (fp) 485 486 bool DDrConfig_ParseCommandLine(int argc, char* argv[]) 487 { 488 for (int i = 1; i < argc; i ++) 380 489 { 381 for (unsigned int s = 0; s < ARRAY_SIZE(config); s++) { 382 fprintf(fp, "[%s]\n", config[s].name); 383 } 384 fclose(fp); 385 } 386 } 387 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 } 534 } 535 return true; 536 } 388 537 389 538 void DDrConfig(int argc, char* argv[]) 390 539 { 391 int i; 392 char* section; 393 char* option; 394 bool falseoption; 395 540 STARTUPMESSAGE("Initializing standard booleans", 0); 396 541 DDrConfig_InitExtBools(); 397 542 … … 407 552 408 553 STARTUPMESSAGE("Parsing command line...", 0); 409 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); 439 555 STARTUPMESSAGE("Finished parsing", 0); 440 } 441 442 443 /* 444 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 */ 550 556 557 // DDrConfig_Print(); 558 } 559 -
Daodan/src/Daodan_Config.h
r993 r994 4 4 #include "stdint.h" 5 5 6 typedef void (*cmd_callback)(); 7 6 8 typedef enum { 9 C_CMD, 7 10 C_BOOL, 8 11 C_INT, … … 15 18 uint8_t* extBoolVal; 16 19 char* stringVal; 20 cmd_callback callback; 17 21 } OptionValue_t; 18 22 -
Daodan/src/Daodan_Patch.c
r993 r994 1 1 #include "Daodan_Patch.h" 2 #include " Daodan_Utility.h"2 #include "Patches/Utility.h" 3 3 #include <beaengine/BeaEngine.h> 4 4 … … 280 280 } 281 281 282 bool DDrPatch__strdup(int* dest, const char* value)283 {284 DWORD oldp;285 286 if (VirtualProtect(dest, 4, PAGE_EXECUTE_READWRITE, &oldp))287 {288 *dest = (int)_strdup(value);289 VirtualProtect(dest, 4, oldp, &oldp);290 return true;291 }292 else293 return false;294 }295 296 282 bool DDrPatch_NOOP(char* dest, unsigned int length) 297 283 { … … 307 293 return false; 308 294 } 295 296 297 void DDrPatch_PrintDisasm(void* addr, int instLimit, int sizeLimit) 298 { 299 DISASM MyDisasm; 300 int len = 0; 301 int size = 0; 302 int i = 0; 303 304 memset(&MyDisasm, 0, sizeof(DISASM)); 305 306 MyDisasm.EIP = (UIntPtr) addr; 307 308 STARTUPMESSAGE("", 0); 309 STARTUPMESSAGE("Disassembly @ 0x%06x", addr); 310 311 if (sizeLimit <= 0) 312 sizeLimit = 20 * instLimit; 313 314 while ((i < instLimit) && (size < sizeLimit)) { 315 len = Disasm(&MyDisasm); 316 if (len != UNKNOWN_OPCODE) { 317 size += len; 318 STARTUPMESSAGE(" %s, Opcode: 0x%x, len: %d, branch: %d, to: 0x%06x", MyDisasm.CompleteInstr, MyDisasm.Instruction.Opcode, len, MyDisasm.Instruction.BranchType, MyDisasm.Instruction.AddrValue); 319 STARTUPMESSAGE(" Cat: 0x%04x, prefix count: %d", MyDisasm.Instruction.Category & 0xffff, MyDisasm.Prefix.Number ); 320 321 MyDisasm.EIP += (UIntPtr)len; 322 i++; 323 } 324 }; 325 326 STARTUPMESSAGE("", 0); 327 } 328 -
Daodan/src/Daodan_Patch.h
r983 r994 15 15 bool DDrPatch_Int32(int* dest, unsigned int value); 16 16 bool DDrPatch_Int16(short* dest, unsigned short value); 17 bool DDrPatch__strdup(int* dest, const char* value);18 17 bool DDrPatch_NOOP(char* dest, unsigned int length); 19 18 19 void DDrPatch_PrintDisasm(void* addr, int instLimit, int sizeLimit); 20 20 21 #endif -
Daodan/src/Inifile_Reader.h
r993 r994 4 4 #include "stdint.h" 5 5 6 typedef void (*inifile_callback)(c har* section, char* name,char* value);6 typedef void (*inifile_callback)(const char* section, const char* name, const char* value); 7 7 8 bool Inifile_Read(const char* filename, inifile_callback callback);8 bool Inifile_Read(const char* filename, const inifile_callback callback); 9 9 10 10 #endif -
Daodan/src/Oni/Symbols_Var.h
r993 r994 12 12 13 13 // Option "debug" ... but what does it do? 14 #define AKgDebug_DebugMaps (*((onibool*)0x00 2b2204))14 #define AKgDebug_DebugMaps (*((onibool*)0x006b2204)) 15 15 16 16 // Option "debugfiles" ... but what does it do? -
Daodan/src/bink-proxy.c
r993 r994 2 2 3 3 #include <windows.h> 4 #include " Daodan_Utility.h"4 #include "Patches/Utility.h" 5 5 6 6
Note:
See TracChangeset
for help on using the changeset viewer.