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 447 by rossy, Tue Jul 21 03:33:07 2009 UTC vs.
Revision 474 by rossy, Fri Oct 30 08:52:50 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;
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 = false;
60 + bool opt_topmost = false;
61  
62   bool DDrPatch_Init()
63   {
# Line 160 | Line 169 | bool DDrPatch_Init()
169                  DDrPatch_Int32 (OniExe + 0x000f617a, (int)&DDr_CheatTable[0].message_on);
170          }
171          
172 +        // ARGB8888 textures
173          if (patch_argb8888)
174          {
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   }
# Line 186 | 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 194 | Line 221 | bool DDrIniCallback(char* section, bool
221          {
222                  case s_options:
223                          if (!stricmp(name, "usedaodanbsl"))
224 <                                opt_usedaodanbsl = !stricmp(value, "true");
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"))
250 <                                patch_fonttexturecache = !stricmp(value, "true");
250 >                                patch_fonttexturecache = !stricmp(inifile_cleanstr(value), "true");
251                          else if (!stricmp(name, "largetextures"))
252 <                                patch_largetextures = !stricmp(value, "true");
252 >                                patch_largetextures = !stricmp(inifile_cleanstr(value), "true");
253                          else if (!stricmp(name, "levelplugins"))
254 <                                patch_levelplugins = !stricmp(value, "true");
254 >                                patch_levelplugins = !stricmp(inifile_cleanstr(value), "true");
255                          else if (!stricmp(name, "pathfinding"))
256 <                                patch_pathfinding = !stricmp(value, "true");
256 >                                patch_pathfinding = !stricmp(inifile_cleanstr(value), "true");
257                          else if (!stricmp(name, "projaware"))
258 <                                patch_projaware = !stricmp(value, "true");
258 >                                patch_projaware = !stricmp(inifile_cleanstr(value), "true");
259                          else if (!stricmp(name, "directinput"))
260 <                                patch_directinput = !stricmp(value, "true");
260 >                                patch_directinput = !stricmp(inifile_cleanstr(value), "true");
261                          else if (!stricmp(name, "wpfadetime"))
262 <                                patch_wpfadetime = !stricmp(value, "true");
262 >                                patch_wpfadetime = !stricmp(inifile_cleanstr(value), "true");
263                          else if (!stricmp(name, "kickguns"))
264 <                                patch_kickguns = !stricmp(value, "true");
264 >                                patch_kickguns = !stricmp(inifile_cleanstr(value), "true");
265                          else if (!stricmp(name, "cooldowntimer"))
266 <                                patch_cooldowntimer = !stricmp(value, "true");
266 >                                patch_cooldowntimer = !stricmp(inifile_cleanstr(value), "true");
267                          else if (!stricmp(name, "throwtest"))
268 <                                patch_throwtest = !stricmp(value, "true");
268 >                                patch_throwtest = !stricmp(inifile_cleanstr(value), "true");
269                          else if (!stricmp(name, "alttab"))
270 <                                patch_alttab = !stricmp(value, "true");
270 >                                patch_alttab = !stricmp(inifile_cleanstr(value), "true");
271                          else if (!stricmp(name, "particledisablebit"))
272 <                                patch_particledisablebit = !stricmp(value, "true");
272 >                                patch_particledisablebit = !stricmp(inifile_cleanstr(value), "true");
273                          else if (!stricmp(name, "multibyte"))
274 <                                patch_multibyte = !stricmp(value, "true");
274 >                                patch_multibyte = !stricmp(inifile_cleanstr(value), "true");
275                          else if (!stricmp(name, "cheattable"))
276 <                                patch_cheattable = !stricmp(value, "true");
276 >                                patch_cheattable = !stricmp(inifile_cleanstr(value), "true");
277                          else if (!stricmp(name, "argb8888"))
278 <                                patch_argb8888 = !stricmp(value, "true");
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(value, "true");
286 >                                patch_safeprintf = !stricmp(inifile_cleanstr(value), "true");
287                          else if (!stricmp(name, "daodandisplayenum"))
288 <                                patch_daodandisplayenum = !stricmp(value, "true");
288 >                                patch_daodandisplayenum = !stricmp(inifile_cleanstr(value), "true");
289                          else if (!stricmp(name, "usegettickcount"))
290 <                                patch_usegettickcount = !stricmp(value, "true");
290 >                                patch_usegettickcount = !stricmp(inifile_cleanstr(value), "true");
291                          else if (!stricmp(name, "cheatsenabled"))
292 <                                patch_cheatsenabled = !stricmp(value, "true");
292 >                                patch_cheatsenabled = !stricmp(inifile_cleanstr(value), "true");
293                          else if (!stricmp(name, "usedaodangl"))
294 <                                patch_usedaodangl = !stricmp(value, "true");
294 >                                patch_usedaodangl = !stricmp(inifile_cleanstr(value), "true");
295                          else if (!stricmp(name, "windowhack"))
296 <                                patch_windowhack = !stricmp(value, "true");
296 >                                patch_windowhack = !stricmp(inifile_cleanstr(value), "true");
297                          else if (!stricmp(name, "daodaninit"))
298 <                                patch_daodaninit = !stricmp(value, "true");
298 >                                patch_daodaninit = !stricmp(inifile_cleanstr(value), "true");
299                          else if (!stricmp(name, "bsl"))
300 <                                patch_bsl = !stricmp(value, "true");
300 >                                patch_bsl = !stricmp(inifile_cleanstr(value), "true");
301 >                        else if (!stricmp(name, "cheater"))
302 >                                patch_cheater = !stricmp(inifile_cleanstr(value), "true");
303                          else
304                                  DDrStartupMessage("unrecognised patch \"%s\"", name);
305                          break;
249                case s_bsl:
250                        
251                        break;
306                  case s_language:
307                          if (!stricmp(name, "savepoint"))
308                          {
# Line 308 | Line 362 | bool DDrIniCallback(char* section, bool
362                          {
363                                  char* str = strdup(value);
364                                  DDr_CheatTable[11].message_on = str;
365 <                                DDr_CheatTable[cheat_devmodex].message_on = str;
365 >                                DDr_CheatTable[cheat_x].message_on = str;
366                          }
367                          else if (!stricmp(name, "devmode_off"))
368                          {
369                                  char* str = strdup(value);
370                                  DDr_CheatTable[11].message_off = str;
371 <                                DDr_CheatTable[cheat_devmodex].message_off = str;
371 >                                DDr_CheatTable[cheat_x].message_off = str;
372                          }
373                          else if (!stricmp(name, "reservoirdogs_on"))
374                                  DDr_CheatTable[12].message_on = strdup(value);
# Line 357 | Line 411 | bool DDrIniCallback(char* section, bool
411                          else
412                                  DDrStartupMessage("unrecognised language item \"%s\"", name);
413                          break;
414 +                case s_bsl:
415                  default:
416                          break;
417          }
# Line 392 | 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 433 | Line 529 | void __cdecl DDrMain(int argc, char* arg
529          if (patch_bsl)
530                  SLrDaodan_Patch();
531          
532 +        if (patch_cheater)
533 +        {
534 +                DDrPatch_MakeCall(OniExe + 0x000f618f, DDrCheater);
535 +                DDrPatch_Int16(OniExe + 0x000deb45, 0x5590);
536 +                DDrPatch_MakeCall(OniExe + 0x000deb47, FallingFrames);
537 +                DDrPatch_MakeJump(OniExe + 0x0010f021, DDrCheater_LevelLoad);
538 +        }
539 +        
540          init_daodan_gl();
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 446 | 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)