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 452 by rossy, Mon Aug 10 09:09:53 2009 UTC vs.
Revision 468 by rossy, Sun Oct 18 02:26:30 2009 UTC

# Line 38 | Line 38 | bool patch_particledisablebit = false;
38   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;
# Line 50 | Line 53 | bool patch_bsl = true;
53   bool patch_cheater = true;
54  
55   bool opt_usedaodanbsl = true;
56 + bool opt_border = true;
57 + bool opt_shadow = true;
58 + bool opt_topmost = false;
59  
60   bool DDrPatch_Init()
61   {
# Line 161 | Line 167 | bool DDrPatch_Init()
167                  DDrPatch_Int32 (OniExe + 0x000f617a, (int)&DDr_CheatTable[0].message_on);
168          }
169          
170 +        // ARGB8888 textures
171          if (patch_argb8888)
172          {
173                  DDrPatch_Byte  (OniExe + 0x00135af0, 0x07);
174                  DDrPatch_Byte  (OniExe + 0x00135af4, 0x0B);
175          }
176          
177 +        // Disable loading the vtuneapi.dll
178 +        if (patch_killvtune)
179 +                DDrPatch_Byte  (OniExe + 0x00026340, 0xC3);
180 +        
181 +        // Disable Oni's internal CLrGetCommandLine function (to eventually replace it with our own)
182 +        if (patch_getcmdline)
183 +                DDrPatch_NOOP  (OniExe + 0x000d3280, 51);
184 +        
185 +        // Disable Oni's command line parser so it doesn't interfere with ours
186 +        if (patch_disablecmdline)
187 +                DDrPatch_Int32 (OniExe + 0x000d3570, 0xc3c03366);
188 +        
189          return true;
190   }
191  
# Line 187 | Line 206 | bool DDrIniCallback(char* section, bool
206                  else
207                  {
208                          ini_section = s_unknown;
209 <                        DDrStartupMessage("unrecognised ini section \"%s\"", section);
209 >                        DDrStartupMessage("unrecognised section \"%s\"", section);
210                  }
211          }
212          
# Line 196 | Line 215 | bool DDrIniCallback(char* section, bool
215                  case s_options:
216                          if (!stricmp(name, "usedaodanbsl"))
217                                  opt_usedaodanbsl = !stricmp(inifile_cleanstr(value), "true");
218 +                        else if (!stricmp(name, "border"))
219 +                                opt_border = !stricmp(inifile_cleanstr(value), "true");
220 +                        else if (!stricmp(name, "shadow"))
221 +                                opt_shadow = !stricmp(inifile_cleanstr(value), "true");
222 +                        else if (!stricmp(name, "topmost"))
223 +                                opt_topmost = !stricmp(inifile_cleanstr(value), "true");
224 +                        else if (!stricmp(name, "multibyte"))
225 +                                patch_multibyte = !stricmp(inifile_cleanstr(value), "true");
226 +                        else if (!stricmp(name, "debug"))
227 +                                AKgDebug_DebugMaps = !stricmp(inifile_cleanstr(value), "true");
228 +                        else if (!stricmp(name, "debugfiles"))
229 +                                BFgDebugFileEnable = !stricmp(inifile_cleanstr(value), "true");
230 +                        else if (!stricmp(name, "findsounds"))
231 +                                SSgSearchOnDisk = !stricmp(inifile_cleanstr(value), "true");
232 +                        else if (!stricmp(name, "ignore_private_data"))
233 +                                opt_ignore_private_data = !stricmp(inifile_cleanstr(value), "true");
234 +                        else if (!stricmp(name, "sound"))
235 +                                opt_sound = !stricmp(inifile_cleanstr(value), "true");
236 +                        else if (!stricmp(name, "switch"))
237 +                                M3gResolutionSwitch = !stricmp(inifile_cleanstr(value), "true");
238 +                        else
239 +                                DDrStartupMessage("unrecognised option \"%s\"", name);
240                          break;
241                  case s_patch:
242                          if (!stricmp(name, "fonttexturecache"))
# Line 228 | Line 269 | bool DDrIniCallback(char* section, bool
269                                  patch_cheattable = !stricmp(inifile_cleanstr(value), "true");
270                          else if (!stricmp(name, "argb8888"))
271                                  patch_argb8888 = !stricmp(inifile_cleanstr(value), "true");
272 +                        else if (!stricmp(name, "killvtune"))
273 +                                patch_killvtune = !stricmp(inifile_cleanstr(value), "true");
274 +                        else if (!stricmp(name, "getcmdline"))
275 +                                patch_getcmdline = !stricmp(inifile_cleanstr(value), "true");
276 +                        else if (!stricmp(name, "disablecmdline"))
277 +                                patch_disablecmdline = !stricmp(inifile_cleanstr(value), "true");
278                          else if (!stricmp(name, "safeprintf"))
279                                  patch_safeprintf = !stricmp(inifile_cleanstr(value), "true");
280                          else if (!stricmp(name, "daodandisplayenum"))
# Line 393 | Line 440 | void ONICALL DDrGame_Init()
440   void __cdecl DDrMain(int argc, char* argv[])
441   {
442          DDrStartupMessage("daodan attached!");
443 +        
444 +        opt_ignore_private_data = false;
445 +        opt_sound = true;
446 +        
447          DDrConfig();
448 +        DDrStartupMessage("parsing command line...");
449 +        int i;
450 +        char* section;
451 +        char* option;
452 +        bool falseoption;
453 +        for (i = 1; i < argc; i ++)
454 +        {
455 +                if (argv[i][0] == '-')
456 +                {
457 +                        section = argv[i] + 1;
458 +                        if ((option = strchr(argv[i], '.')))
459 +                        {
460 +                                *option = '\0';
461 +                                falseoption = (option[1] == 'n' || option[1] == 'N') && (option[2] = 'o' || option[2] == 'O');
462 +                                if (i < (argc - 1) && argv[i + 1][0] != '-')
463 +                                        DDrIniCallback(section, true, option + 1, argv[++i]);
464 +                                else
465 +                                        DDrIniCallback(section, true, option + (falseoption ? 3 : 1), (falseoption ? "false" : "true"));
466 +                                *option = '.';
467 +                        }
468 +                        else
469 +                        {
470 +                                falseoption = (section[0] == 'n' || section[0] == 'N') && (section[1] = 'o' || section[1] == 'O');
471 +                                ini_section = s_options;
472 +                                if (i < (argc - 1) && argv[i + 1][0] != '-')
473 +                                        DDrIniCallback(NULL, false, section, argv[++i]);
474 +                                else
475 +                                        DDrIniCallback(NULL, false, section + (falseoption ? 2 : 0), (falseoption ? "false" : "true"));
476 +                        }
477 +                }
478 +                else
479 +                {
480 +                        DDrStartupMessage("parse error \"%s\"", argv[i]);
481 +                        break;
482 +                }
483 +        }
484 +        DDrStartupMessage("finished parsing");
485          DDrPatch_Init();
486          
487          // Safe startup message printer
# Line 435 | Line 523 | void __cdecl DDrMain(int argc, char* arg
523                  SLrDaodan_Patch();
524          
525          if (patch_cheater)
526 +        {
527                  DDrPatch_MakeCall(OniExe + 0x000f618f, DDrCheater);
528 +                DDrPatch_Int16(OniExe + 0x000deb45, 0x5590);
529 +                DDrPatch_MakeCall(OniExe + 0x000deb47, FallingFrames);
530 +                DDrPatch_MakeJump(OniExe + 0x0010f021, DDrCheater_LevelLoad);
531 +        }
532          
533          init_daodan_gl();
534          
535          ONiMain(argc, argv);
536   }
537 <
537 > /*
538 > void DDrWrongExe()
539 > {
540 >        switch (MessageBox(NULL, "This version of the Daodan DLL is incompatible with your Oni.exe.\n"
541 >                "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))
542 >        {
543 >                case IDOK:
544 >                        {
545 >                                STARTUPINFO si;
546 >                                PROCESS_INFORMATION pi;
547 >                                FillMemory(&si, 0, sizeof(si));
548 >                                FillMemory(&pi, 0, sizeof(pi));
549 >                                si.cb = sizeof(si);
550 >                                if (!CreateProcess(NULL, "cmd /c \"start http://wiki.oni2.net/Daodan_DLL\"", NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
551 >                                        MessageBox(NULL, "", "", 0);
552 >                                CloseHandle(pi.hProcess);
553 >                                CloseHandle(pi.hThread);
554 >                        }
555 >                default:
556 >                        ExitProcess(0);
557 >        }
558 > }
559 > */
560   BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved)
561   {
562          switch (fdwReason)
# Line 450 | Line 565 | BOOL WINAPI DllMain(HINSTANCE hinstDLL,
565                          DDrDLLModule = hinstDLL;
566                          DDrONiModule = GetModuleHandle(NULL);
567                          
568 <                        DDrPatch_MakeCall(OniExe + 0x0010fb49, DDrMain);
569 <                        
568 >                        if (*(uint32_t*)((void*)OniExe + 0x0011acd0) == 0x09d36852)
569 >                                DDrPatch_MakeCall(OniExe + 0x0010fb49, DDrMain);
570 >                        else
571 >                                ExitProcess(0);
572                          break;
573          }
574          return TRUE;

Diff Legend

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