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

Comparing Daodan/src/Daodan.c (file contents):
Revision 459 by rossy, Mon Aug 24 11:32:06 2009 UTC vs.
Revision 473 by gumby, Fri Oct 30 07:41:39 2009 UTC

# Line 39 | Line 39 | bool patch_multibyte = false;
39   bool patch_cheattable = true;
40   bool patch_argb8888 = true;
41   bool patch_killvtune = true;
42 + bool patch_getcmdline = true;
43 + bool patch_disablecmdline = true;
44  
45   bool patch_safeprintf = true;
46   bool patch_daodandisplayenum = true;
47   bool patch_usegettickcount = true;
48   bool patch_cheatsenabled = true;
49 < bool patch_usedaodangl = false;
50 < bool patch_windowhack = true;
49 > bool patch_usedaodangl = true;
50 > bool patch_windowhack = false;
51   bool patch_daodaninit = true;
52   bool patch_bsl = true;
53   bool patch_cheater = true;
54  
55 + bool patch_newweapon = true;
56 +
57   bool opt_usedaodanbsl = true;
58 + bool opt_border = true;
59 + bool opt_shadow = true;
60 + bool opt_topmost = false;
61  
62   bool DDrPatch_Init()
63   {
# Line 168 | Line 175 | bool DDrPatch_Init()
175                  DDrPatch_Byte  (OniExe + 0x00135af0, 0x07);
176                  DDrPatch_Byte  (OniExe + 0x00135af4, 0x0B);
177          }
178 +
179 +        //Test newweap patch
180 + //      if (patch_newweapon) {
181 + //              DDrPatch_NOOP( OniExe + 0x000E4DF8, 2);
182 + //      }
183          
184          // Disable loading the vtuneapi.dll
185          if (patch_killvtune)
186                  DDrPatch_Byte  (OniExe + 0x00026340, 0xC3);
187          
188 +        // Disable Oni's internal CLrGetCommandLine function (to eventually replace it with our own)
189 +        if (patch_getcmdline)
190 +                DDrPatch_NOOP  (OniExe + 0x000d3280, 51);
191 +        
192 +        // Disable Oni's command line parser so it doesn't interfere with ours
193 +        if (patch_disablecmdline)
194 +                DDrPatch_Int32 (OniExe + 0x000d3570, 0xc3c03366);
195 +        
196          return true;
197   }
198  
# Line 193 | Line 213 | bool DDrIniCallback(char* section, bool
213                  else
214                  {
215                          ini_section = s_unknown;
216 <                        DDrStartupMessage("unrecognised ini section \"%s\"", section);
216 >                        DDrStartupMessage("unrecognised section \"%s\"", section);
217                  }
218          }
219          
# Line 202 | Line 222 | bool DDrIniCallback(char* section, bool
222                  case s_options:
223                          if (!stricmp(name, "usedaodanbsl"))
224                                  opt_usedaodanbsl = !stricmp(inifile_cleanstr(value), "true");
225 +                        else if (!stricmp(name, "border"))
226 +                                opt_border = !stricmp(inifile_cleanstr(value), "true");
227 +                        else if (!stricmp(name, "shadow"))
228 +                                opt_shadow = !stricmp(inifile_cleanstr(value), "true");
229 +                        else if (!stricmp(name, "topmost"))
230 +                                opt_topmost = !stricmp(inifile_cleanstr(value), "true");
231 +                        else if (!stricmp(name, "multibyte"))
232 +                                patch_multibyte = !stricmp(inifile_cleanstr(value), "true");
233 +                        else if (!stricmp(name, "debug"))
234 +                                AKgDebug_DebugMaps = !stricmp(inifile_cleanstr(value), "true");
235 +                        else if (!stricmp(name, "debugfiles"))
236 +                                BFgDebugFileEnable = !stricmp(inifile_cleanstr(value), "true");
237 +                        else if (!stricmp(name, "findsounds"))
238 +                                SSgSearchOnDisk = !stricmp(inifile_cleanstr(value), "true");
239 +                        else if (!stricmp(name, "ignore_private_data"))
240 +                                opt_ignore_private_data = !stricmp(inifile_cleanstr(value), "true");
241 +                        else if (!stricmp(name, "sound"))
242 +                                opt_sound = !stricmp(inifile_cleanstr(value), "true");
243 +                        else if (!stricmp(name, "switch"))
244 +                                M3gResolutionSwitch = !stricmp(inifile_cleanstr(value), "true");
245 +                        else
246 +                                DDrStartupMessage("unrecognised option \"%s\"", name);
247                          break;
248                  case s_patch:
249                          if (!stricmp(name, "fonttexturecache"))
# Line 236 | Line 278 | bool DDrIniCallback(char* section, bool
278                                  patch_argb8888 = !stricmp(inifile_cleanstr(value), "true");
279                          else if (!stricmp(name, "killvtune"))
280                                  patch_killvtune = !stricmp(inifile_cleanstr(value), "true");
281 +                        else if (!stricmp(name, "getcmdline"))
282 +                                patch_getcmdline = !stricmp(inifile_cleanstr(value), "true");
283 +                        else if (!stricmp(name, "disablecmdline"))
284 +                                patch_disablecmdline = !stricmp(inifile_cleanstr(value), "true");
285                          else if (!stricmp(name, "safeprintf"))
286                                  patch_safeprintf = !stricmp(inifile_cleanstr(value), "true");
287                          else if (!stricmp(name, "daodandisplayenum"))
# Line 401 | Line 447 | void ONICALL DDrGame_Init()
447   void __cdecl DDrMain(int argc, char* argv[])
448   {
449          DDrStartupMessage("daodan attached!");
450 +        
451 +        opt_ignore_private_data = false;
452 +        opt_sound = true;
453 +        
454          DDrConfig();
455 +        DDrStartupMessage("parsing command line...");
456 +        int i;
457 +        char* section;
458 +        char* option;
459 +        bool falseoption;
460 +        for (i = 1; i < argc; i ++)
461 +        {
462 +                if (argv[i][0] == '-')
463 +                {
464 +                        section = argv[i] + 1;
465 +                        if ((option = strchr(argv[i], '.')))
466 +                        {
467 +                                *option = '\0';
468 +                                falseoption = (option[1] == 'n' || option[1] == 'N') && (option[2] = 'o' || option[2] == 'O');
469 +                                if (i < (argc - 1) && argv[i + 1][0] != '-')
470 +                                        DDrIniCallback(section, true, option + 1, argv[++i]);
471 +                                else
472 +                                        DDrIniCallback(section, true, option + (falseoption ? 3 : 1), (falseoption ? "false" : "true"));
473 +                                *option = '.';
474 +                        }
475 +                        else
476 +                        {
477 +                                falseoption = (section[0] == 'n' || section[0] == 'N') && (section[1] = 'o' || section[1] == 'O');
478 +                                ini_section = s_options;
479 +                                if (i < (argc - 1) && argv[i + 1][0] != '-')
480 +                                        DDrIniCallback(NULL, false, section, argv[++i]);
481 +                                else
482 +                                        DDrIniCallback(NULL, false, section + (falseoption ? 2 : 0), (falseoption ? "false" : "true"));
483 +                        }
484 +                }
485 +                else
486 +                {
487 +                        DDrStartupMessage("parse error \"%s\"", argv[i]);
488 +                        break;
489 +                }
490 +        }
491 +        DDrStartupMessage("finished parsing");
492          DDrPatch_Init();
493          
494          // Safe startup message printer
# Line 454 | Line 541 | void __cdecl DDrMain(int argc, char* arg
541          
542          ONiMain(argc, argv);
543   }
544 <
544 > /*
545 > void DDrWrongExe()
546 > {
547 >        switch (MessageBox(NULL, "This version of the Daodan DLL is incompatible with your Oni.exe.\n"
548 >                "Click OK for more information. To continue using Oni without the patch, replace the downloaded binkw32.dll with the original.", "Daodan", MB_OKCANCEL | MB_ICONERROR))
549 >        {
550 >                case IDOK:
551 >                        {
552 >                                STARTUPINFO si;
553 >                                PROCESS_INFORMATION pi;
554 >                                FillMemory(&si, 0, sizeof(si));
555 >                                FillMemory(&pi, 0, sizeof(pi));
556 >                                si.cb = sizeof(si);
557 >                                if (!CreateProcess(NULL, "cmd /c \"start http://wiki.oni2.net/Daodan_DLL\"", NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
558 >                                        MessageBox(NULL, "", "", 0);
559 >                                CloseHandle(pi.hProcess);
560 >                                CloseHandle(pi.hThread);
561 >                        }
562 >                default:
563 >                        ExitProcess(0);
564 >        }
565 > }
566 > */
567   BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved)
568   {
569          switch (fdwReason)
# Line 463 | Line 572 | BOOL WINAPI DllMain(HINSTANCE hinstDLL,
572                          DDrDLLModule = hinstDLL;
573                          DDrONiModule = GetModuleHandle(NULL);
574                          
575 <                        DDrPatch_MakeCall(OniExe + 0x0010fb49, DDrMain);
576 <                        
575 >                        if (*(uint32_t*)((void*)OniExe + 0x0011acd0) == 0x09d36852)
576 >                                DDrPatch_MakeCall(OniExe + 0x0010fb49, DDrMain);
577 >                        else
578 >                                ExitProcess(0);
579                          break;
580          }
581          return TRUE;

Diff Legend

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