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 445 by rossy, Sun Jul 19 11:03:44 2009 UTC vs.
Revision 476 by gumby, Tue Nov 3 10:38:47 2009 UTC

# Line 7 | Line 7
7   #include "Daodan_Cheater.h"
8   #include "Daodan_Persistence.h"
9   #include "Daodan_BSL.h"
10 + #include "Daodan_Console.h"
11  
12   #include "Daodan_WindowHack.h"
13  
# Line 38 | Line 39 | bool patch_particledisablebit = false;
39   bool patch_multibyte = false;
40   bool patch_cheattable = true;
41   bool patch_argb8888 = true;
42 + bool patch_killvtune = true;
43 + bool patch_getcmdline = true;
44 + bool patch_disablecmdline = true;
45  
46   bool patch_safeprintf = true;
47   bool patch_daodandisplayenum = true;
48   bool patch_usegettickcount = true;
49   bool patch_cheatsenabled = true;
50 < bool patch_usedaodangl = false;
51 < bool patch_windowhack = true;
50 > bool patch_usedaodangl = true;
51 > bool patch_windowhack = false;
52   bool patch_daodaninit = true;
53 + bool patch_bsl = true;
54 + bool patch_cheater = true;
55 +
56 + // bool patch_newweapon = true;
57  
58   bool opt_usedaodanbsl = true;
59 + bool opt_border = true;
60 + bool opt_shadow = false;
61 + bool opt_topmost = false;
62  
63   bool DDrPatch_Init()
64   {
# Line 159 | Line 170 | bool DDrPatch_Init()
170                  DDrPatch_Int32 (OniExe + 0x000f617a, (int)&DDr_CheatTable[0].message_on);
171          }
172          
173 +        // ARGB8888 textures
174          if (patch_argb8888)
175          {
176                  DDrPatch_Byte  (OniExe + 0x00135af0, 0x07);
177                  DDrPatch_Byte  (OniExe + 0x00135af4, 0x0B);
178          }
179 +
180 +        //Test newweap patch
181 + //      if (patch_newweapon) {
182 +                
183 +                //Makes it always say "Recieved weapon_name."
184 +                //Needs check for loc_4DFC66
185 +                DDrPatch_NOOP( OniExe + 0x000E4DF8,2);
186 +
187 +                //Adds Weapon name and ammo meter to pickup autoprompt
188 +                DDrPatch_NOOP( OniExe + 0x000FAC73, 9);
189 +                DDrPatch_NOOP( OniExe + 0x000FAC80, 5);
190 +                DDrPatch_MakeCall( OniExe + 0xFAC85, DDrWeapon2Message);
191 +                
192 +                //Moves location of colors
193 +                DDrPatch_Int32( OniExe + 0x0002E3D5, (int)&DDrDSayColors[0].Char );
194 +                DDrPatch_Int32( OniExe + 0x0002E3DA, (int)&DDrDSayColors[0].Char );
195 + //      }
196 +        
197 +        // Disable loading the vtuneapi.dll
198 +        if (patch_killvtune)
199 +                DDrPatch_Byte  (OniExe + 0x00026340, 0xC3);
200 +        
201 +        // Disable Oni's internal CLrGetCommandLine function (to eventually replace it with our own)
202 +        if (patch_getcmdline)
203 +                DDrPatch_NOOP  (OniExe + 0x000d3280, 51);
204 +        
205 +        // Disable Oni's command line parser so it doesn't interfere with ours
206 +        if (patch_disablecmdline)
207 +                DDrPatch_Int32 (OniExe + 0x000d3570, 0xc3c03366);
208          
209          return true;
210   }
# Line 185 | Line 226 | bool DDrIniCallback(char* section, bool
226                  else
227                  {
228                          ini_section = s_unknown;
229 <                        DDrStartupMessage("unrecognised ini section \"%s\"", section);
229 >                        DDrStartupMessage("unrecognised section \"%s\"", section);
230                  }
231          }
232          
# Line 193 | Line 234 | bool DDrIniCallback(char* section, bool
234          {
235                  case s_options:
236                          if (!stricmp(name, "usedaodanbsl"))
237 <                                opt_usedaodanbsl = !stricmp(value, "true");
237 >                                opt_usedaodanbsl = !stricmp(inifile_cleanstr(value), "true");
238 >                        else if (!stricmp(name, "border"))
239 >                                opt_border = !stricmp(inifile_cleanstr(value), "true");
240 >                        else if (!stricmp(name, "shadow"))
241 >                                opt_shadow = !stricmp(inifile_cleanstr(value), "true");
242 >                        else if (!stricmp(name, "topmost"))
243 >                                opt_topmost = !stricmp(inifile_cleanstr(value), "true");
244 >                        else if (!stricmp(name, "multibyte"))
245 >                                patch_multibyte = !stricmp(inifile_cleanstr(value), "true");
246 >                        else if (!stricmp(name, "debug"))
247 >                                AKgDebug_DebugMaps = !stricmp(inifile_cleanstr(value), "true");
248 >                        else if (!stricmp(name, "debugfiles"))
249 >                                BFgDebugFileEnable = !stricmp(inifile_cleanstr(value), "true");
250 >                        else if (!stricmp(name, "findsounds"))
251 >                                SSgSearchOnDisk = !stricmp(inifile_cleanstr(value), "true");
252 >                        else if (!stricmp(name, "ignore_private_data"))
253 >                                opt_ignore_private_data = !stricmp(inifile_cleanstr(value), "true");
254 >                        else if (!stricmp(name, "sound"))
255 >                                opt_sound = !stricmp(inifile_cleanstr(value), "true");
256 >                        else if (!stricmp(name, "switch"))
257 >                                M3gResolutionSwitch = !stricmp(inifile_cleanstr(value), "true");
258 >                        else
259 >                                DDrStartupMessage("unrecognised option \"%s\"", name);
260                          break;
261                  case s_patch:
262                          if (!stricmp(name, "fonttexturecache"))
263 <                                patch_fonttexturecache = !stricmp(value, "true");
263 >                                patch_fonttexturecache = !stricmp(inifile_cleanstr(value), "true");
264                          else if (!stricmp(name, "largetextures"))
265 <                                patch_largetextures = !stricmp(value, "true");
265 >                                patch_largetextures = !stricmp(inifile_cleanstr(value), "true");
266                          else if (!stricmp(name, "levelplugins"))
267 <                                patch_levelplugins = !stricmp(value, "true");
267 >                                patch_levelplugins = !stricmp(inifile_cleanstr(value), "true");
268                          else if (!stricmp(name, "pathfinding"))
269 <                                patch_pathfinding = !stricmp(value, "true");
269 >                                patch_pathfinding = !stricmp(inifile_cleanstr(value), "true");
270                          else if (!stricmp(name, "projaware"))
271 <                                patch_projaware = !stricmp(value, "true");
271 >                                patch_projaware = !stricmp(inifile_cleanstr(value), "true");
272                          else if (!stricmp(name, "directinput"))
273 <                                patch_directinput = !stricmp(value, "true");
273 >                                patch_directinput = !stricmp(inifile_cleanstr(value), "true");
274                          else if (!stricmp(name, "wpfadetime"))
275 <                                patch_wpfadetime = !stricmp(value, "true");
275 >                                patch_wpfadetime = !stricmp(inifile_cleanstr(value), "true");
276                          else if (!stricmp(name, "kickguns"))
277 <                                patch_kickguns = !stricmp(value, "true");
277 >                                patch_kickguns = !stricmp(inifile_cleanstr(value), "true");
278                          else if (!stricmp(name, "cooldowntimer"))
279 <                                patch_cooldowntimer = !stricmp(value, "true");
279 >                                patch_cooldowntimer = !stricmp(inifile_cleanstr(value), "true");
280                          else if (!stricmp(name, "throwtest"))
281 <                                patch_throwtest = !stricmp(value, "true");
281 >                                patch_throwtest = !stricmp(inifile_cleanstr(value), "true");
282                          else if (!stricmp(name, "alttab"))
283 <                                patch_alttab = !stricmp(value, "true");
283 >                                patch_alttab = !stricmp(inifile_cleanstr(value), "true");
284                          else if (!stricmp(name, "particledisablebit"))
285 <                                patch_particledisablebit = !stricmp(value, "true");
285 >                                patch_particledisablebit = !stricmp(inifile_cleanstr(value), "true");
286                          else if (!stricmp(name, "multibyte"))
287 <                                patch_multibyte = !stricmp(value, "true");
287 >                                patch_multibyte = !stricmp(inifile_cleanstr(value), "true");
288                          else if (!stricmp(name, "cheattable"))
289 <                                patch_cheattable = !stricmp(value, "true");
289 >                                patch_cheattable = !stricmp(inifile_cleanstr(value), "true");
290                          else if (!stricmp(name, "argb8888"))
291 <                                patch_argb8888 = !stricmp(value, "true");
291 >                                patch_argb8888 = !stricmp(inifile_cleanstr(value), "true");
292 >                        else if (!stricmp(name, "killvtune"))
293 >                                patch_killvtune = !stricmp(inifile_cleanstr(value), "true");
294 >                        else if (!stricmp(name, "getcmdline"))
295 >                                patch_getcmdline = !stricmp(inifile_cleanstr(value), "true");
296 >                        else if (!stricmp(name, "disablecmdline"))
297 >                                patch_disablecmdline = !stricmp(inifile_cleanstr(value), "true");
298                          else if (!stricmp(name, "safeprintf"))
299 <                                patch_safeprintf = !stricmp(value, "true");
299 >                                patch_safeprintf = !stricmp(inifile_cleanstr(value), "true");
300                          else if (!stricmp(name, "daodandisplayenum"))
301 <                                patch_daodandisplayenum = !stricmp(value, "true");
301 >                                patch_daodandisplayenum = !stricmp(inifile_cleanstr(value), "true");
302                          else if (!stricmp(name, "usegettickcount"))
303 <                                patch_usegettickcount = !stricmp(value, "true");
303 >                                patch_usegettickcount = !stricmp(inifile_cleanstr(value), "true");
304                          else if (!stricmp(name, "cheatsenabled"))
305 <                                patch_cheatsenabled = !stricmp(value, "true");
305 >                                patch_cheatsenabled = !stricmp(inifile_cleanstr(value), "true");
306                          else if (!stricmp(name, "usedaodangl"))
307 <                                patch_usedaodangl = !stricmp(value, "true");
307 >                                patch_usedaodangl = !stricmp(inifile_cleanstr(value), "true");
308                          else if (!stricmp(name, "windowhack"))
309 <                                patch_windowhack = !stricmp(value, "true");
309 >                                patch_windowhack = !stricmp(inifile_cleanstr(value), "true");
310                          else if (!stricmp(name, "daodaninit"))
311 <                                patch_daodaninit = !stricmp(value, "true");
311 >                                patch_daodaninit = !stricmp(inifile_cleanstr(value), "true");
312 >                        else if (!stricmp(name, "bsl"))
313 >                                patch_bsl = !stricmp(inifile_cleanstr(value), "true");
314 >                        else if (!stricmp(name, "cheater"))
315 >                                patch_cheater = !stricmp(inifile_cleanstr(value), "true");
316                          else
317                                  DDrStartupMessage("unrecognised patch \"%s\"", name);
318                          break;
246                case s_bsl:
247                        
248                        break;
319                  case s_language:
320                          if (!stricmp(name, "savepoint"))
321                          {
# Line 305 | Line 375 | bool DDrIniCallback(char* section, bool
375                          {
376                                  char* str = strdup(value);
377                                  DDr_CheatTable[11].message_on = str;
378 <                                DDr_CheatTable[cheat_devmodex].message_on = str;
378 >                                DDr_CheatTable[cheat_x].message_on = str;
379                          }
380                          else if (!stricmp(name, "devmode_off"))
381                          {
382                                  char* str = strdup(value);
383                                  DDr_CheatTable[11].message_off = str;
384 <                                DDr_CheatTable[cheat_devmodex].message_off = str;
384 >                                DDr_CheatTable[cheat_x].message_off = str;
385                          }
386                          else if (!stricmp(name, "reservoirdogs_on"))
387                                  DDr_CheatTable[12].message_on = strdup(value);
# Line 354 | Line 424 | bool DDrIniCallback(char* section, bool
424                          else
425                                  DDrStartupMessage("unrecognised language item \"%s\"", name);
426                          break;
427 +                case s_bsl:
428                  default:
429                          break;
430          }
# Line 389 | Line 460 | void ONICALL DDrGame_Init()
460   void __cdecl DDrMain(int argc, char* argv[])
461   {
462          DDrStartupMessage("daodan attached!");
463 +        
464 +        opt_ignore_private_data = false;
465 +        opt_sound = true;
466 +        
467          DDrConfig();
468 +        DDrStartupMessage("parsing command line...");
469 +        int i;
470 +        char* section;
471 +        char* option;
472 +        bool falseoption;
473 +        for (i = 1; i < argc; i ++)
474 +        {
475 +                if (argv[i][0] == '-')
476 +                {
477 +                        section = argv[i] + 1;
478 +                        if ((option = strchr(argv[i], '.')))
479 +                        {
480 +                                *option = '\0';
481 +                                falseoption = (option[1] == 'n' || option[1] == 'N') && (option[2] = 'o' || option[2] == 'O');
482 +                                if (i < (argc - 1) && argv[i + 1][0] != '-')
483 +                                        DDrIniCallback(section, true, option + 1, argv[++i]);
484 +                                else
485 +                                        DDrIniCallback(section, true, option + (falseoption ? 3 : 1), (falseoption ? "false" : "true"));
486 +                                *option = '.';
487 +                        }
488 +                        else
489 +                        {
490 +                                falseoption = (section[0] == 'n' || section[0] == 'N') && (section[1] = 'o' || section[1] == 'O');
491 +                                ini_section = s_options;
492 +                                if (i < (argc - 1) && argv[i + 1][0] != '-')
493 +                                        DDrIniCallback(NULL, false, section, argv[++i]);
494 +                                else
495 +                                        DDrIniCallback(NULL, false, section + (falseoption ? 2 : 0), (falseoption ? "false" : "true"));
496 +                        }
497 +                }
498 +                else
499 +                {
500 +                        DDrStartupMessage("parse error \"%s\"", argv[i]);
501 +                        break;
502 +                }
503 +        }
504 +        DDrStartupMessage("finished parsing");
505          DDrPatch_Init();
506          
507          // Safe startup message printer
# Line 426 | Line 538 | void __cdecl DDrMain(int argc, char* arg
538          if (patch_daodaninit)
539                  DDrPatch_MakeCall(OniExe + 0x000d345a, DDrGame_Init);
540          
541 +        // Patches for existing BSL functions
542 +        if (patch_bsl)
543 +                SLrDaodan_Patch();
544 +        
545 +        if (patch_cheater)
546 +        {
547 +                DDrPatch_MakeCall(OniExe + 0x000f618f, DDrCheater);
548 +                DDrPatch_Int16(OniExe + 0x000deb45, 0x5590);
549 +                DDrPatch_MakeCall(OniExe + 0x000deb47, FallingFrames);
550 +                DDrPatch_MakeJump(OniExe + 0x0010f021, DDrCheater_LevelLoad);
551 +        }
552 +        
553          init_daodan_gl();
554          
555          ONiMain(argc, argv);
556   }
557 <
557 > /*
558 > void DDrWrongExe()
559 > {
560 >        switch (MessageBox(NULL, "This version of the Daodan DLL is incompatible with your Oni.exe.\n"
561 >                "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))
562 >        {
563 >                case IDOK:
564 >                        {
565 >                                STARTUPINFO si;
566 >                                PROCESS_INFORMATION pi;
567 >                                FillMemory(&si, 0, sizeof(si));
568 >                                FillMemory(&pi, 0, sizeof(pi));
569 >                                si.cb = sizeof(si);
570 >                                if (!CreateProcess(NULL, "cmd /c \"start http://wiki.oni2.net/Daodan_DLL\"", NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
571 >                                        MessageBox(NULL, "", "", 0);
572 >                                CloseHandle(pi.hProcess);
573 >                                CloseHandle(pi.hThread);
574 >                        }
575 >                default:
576 >                        ExitProcess(0);
577 >        }
578 > }
579 > */
580   BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved)
581   {
582          switch (fdwReason)
# Line 439 | Line 585 | BOOL WINAPI DllMain(HINSTANCE hinstDLL,
585                          DDrDLLModule = hinstDLL;
586                          DDrONiModule = GetModuleHandle(NULL);
587                          
588 <                        DDrPatch_MakeCall(OniExe + 0x0010fb49, DDrMain);
589 <                        
588 >                        if (*(uint32_t*)((void*)OniExe + 0x0011acd0) == 0x09d36852)
589 >                                DDrPatch_MakeCall(OniExe + 0x0010fb49, DDrMain);
590 >                        else
591 >                                ExitProcess(0);
592                          break;
593          }
594          return TRUE;

Diff Legend

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