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 349 by rossy, Wed Jun 10 12:40:16 2009 UTC vs.
Revision 468 by rossy, Sun Oct 18 02:26:30 2009 UTC

# Line 6 | Line 6
6   #include "Daodan_Win32.h"
7   #include "Daodan_Cheater.h"
8   #include "Daodan_Persistence.h"
9 + #include "Daodan_BSL.h"
10  
11   #include "Daodan_WindowHack.h"
12  
# Line 34 | Line 35 | bool patch_cooldowntimer = true;
35   bool patch_throwtest = false;
36   bool patch_alttab = true;
37   bool patch_particledisablebit = false;
38 < bool patch_multibyte = true;
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 43 | Line 48 | bool patch_usegettickcount = true;
48   bool patch_cheatsenabled = true;
49   bool patch_usedaodangl = false;
50   bool patch_windowhack = true;
51 + bool patch_daodaninit = true;
52 + 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 127 | Line 140 | bool DDrPatch_Init()
140                  DDrPatch_Int16 (OniExe + 0x001b184, 0x9090);
141          
142          // Multi-byte patch (multiple language support)
143 <        if (patch_multibyte)
143 >        if (!patch_multibyte)
144          {
145                  DDrPatch_Byte  (OniExe + 0x0002d8f8, 0xeb);
146                  DDrPatch_Byte  (OniExe + 0x0002d9ad, 0xeb);
# Line 154 | 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  
192 < enum {s_unknown, s_patch, s_language} ini_section;
192 > enum {s_unknown, s_options, s_patch, s_bsl, s_language} ini_section;
193  
194   bool DDrIniCallback(char* section, bool newsection, char* name, char* value)
195   {
196          if (newsection)
197          {
198 <                if (!stricmp(section, "patch"))
198 >                if (!stricmp(section, "options"))
199 >                        ini_section = s_options;
200 >                else if (!stricmp(section, "patch"))
201                          ini_section = s_patch;
202 +                else if (!stricmp(section, "bsl"))
203 +                        ini_section = s_bsl;
204                  else if (!stricmp(section, "language"))
205                          ini_section = s_language;
206                  else
207                  {
208                          ini_section = s_unknown;
209 <                        DDrStartupMessage("unrecognised ini section \"%s\"", section);
209 >                        DDrStartupMessage("unrecognised section \"%s\"", section);
210                  }
211          }
212          
213          switch (ini_section)
214          {
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"))
243 <                                patch_fonttexturecache = !stricmp(value, "true");
243 >                                patch_fonttexturecache = !stricmp(inifile_cleanstr(value), "true");
244                          else if (!stricmp(name, "largetextures"))
245 <                                patch_largetextures = !stricmp(value, "true");
245 >                                patch_largetextures = !stricmp(inifile_cleanstr(value), "true");
246                          else if (!stricmp(name, "levelplugins"))
247 <                                patch_levelplugins = !stricmp(value, "true");
247 >                                patch_levelplugins = !stricmp(inifile_cleanstr(value), "true");
248                          else if (!stricmp(name, "pathfinding"))
249 <                                patch_pathfinding = !stricmp(value, "true");
249 >                                patch_pathfinding = !stricmp(inifile_cleanstr(value), "true");
250                          else if (!stricmp(name, "projaware"))
251 <                                patch_projaware = !stricmp(value, "true");
251 >                                patch_projaware = !stricmp(inifile_cleanstr(value), "true");
252                          else if (!stricmp(name, "directinput"))
253 <                                patch_directinput = !stricmp(value, "true");
253 >                                patch_directinput = !stricmp(inifile_cleanstr(value), "true");
254                          else if (!stricmp(name, "wpfadetime"))
255 <                                patch_wpfadetime = !stricmp(value, "true");
255 >                                patch_wpfadetime = !stricmp(inifile_cleanstr(value), "true");
256                          else if (!stricmp(name, "kickguns"))
257 <                                patch_kickguns = !stricmp(value, "true");
257 >                                patch_kickguns = !stricmp(inifile_cleanstr(value), "true");
258                          else if (!stricmp(name, "cooldowntimer"))
259 <                                patch_cooldowntimer = !stricmp(value, "true");
259 >                                patch_cooldowntimer = !stricmp(inifile_cleanstr(value), "true");
260                          else if (!stricmp(name, "throwtest"))
261 <                                patch_throwtest = !stricmp(value, "true");
261 >                                patch_throwtest = !stricmp(inifile_cleanstr(value), "true");
262                          else if (!stricmp(name, "alttab"))
263 <                                patch_alttab = !stricmp(value, "true");
263 >                                patch_alttab = !stricmp(inifile_cleanstr(value), "true");
264                          else if (!stricmp(name, "particledisablebit"))
265 <                                patch_particledisablebit = !stricmp(value, "true");
265 >                                patch_particledisablebit = !stricmp(inifile_cleanstr(value), "true");
266                          else if (!stricmp(name, "multibyte"))
267 <                                patch_multibyte = !stricmp(value, "true");
267 >                                patch_multibyte = !stricmp(inifile_cleanstr(value), "true");
268                          else if (!stricmp(name, "cheattable"))
269 <                                patch_cheattable = !stricmp(value, "true");
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(value, "true");
279 >                                patch_safeprintf = !stricmp(inifile_cleanstr(value), "true");
280                          else if (!stricmp(name, "daodandisplayenum"))
281 <                                patch_daodandisplayenum = !stricmp(value, "true");
281 >                                patch_daodandisplayenum = !stricmp(inifile_cleanstr(value), "true");
282                          else if (!stricmp(name, "usegettickcount"))
283 <                                patch_usegettickcount = !stricmp(value, "true");
283 >                                patch_usegettickcount = !stricmp(inifile_cleanstr(value), "true");
284                          else if (!stricmp(name, "cheatsenabled"))
285 <                                patch_cheatsenabled = !stricmp(value, "true");
285 >                                patch_cheatsenabled = !stricmp(inifile_cleanstr(value), "true");
286                          else if (!stricmp(name, "usedaodangl"))
287 <                                patch_usedaodangl = !stricmp(value, "true");
287 >                                patch_usedaodangl = !stricmp(inifile_cleanstr(value), "true");
288                          else if (!stricmp(name, "windowhack"))
289 <                                patch_windowhack = !stricmp(value, "true");
289 >                                patch_windowhack = !stricmp(inifile_cleanstr(value), "true");
290 >                        else if (!stricmp(name, "daodaninit"))
291 >                                patch_daodaninit = !stricmp(inifile_cleanstr(value), "true");
292 >                        else if (!stricmp(name, "bsl"))
293 >                                patch_bsl = !stricmp(inifile_cleanstr(value), "true");
294 >                        else if (!stricmp(name, "cheater"))
295 >                                patch_cheater = !stricmp(inifile_cleanstr(value), "true");
296                          else
297                                  DDrStartupMessage("unrecognised patch \"%s\"", name);
298                          break;
# Line 279 | Line 355 | bool DDrIniCallback(char* section, bool
355                          {
356                                  char* str = strdup(value);
357                                  DDr_CheatTable[11].message_on = str;
358 <                                DDr_CheatTable[cheat_devmodex].message_on = str;
358 >                                DDr_CheatTable[cheat_x].message_on = str;
359                          }
360                          else if (!stricmp(name, "devmode_off"))
361                          {
362                                  char* str = strdup(value);
363                                  DDr_CheatTable[11].message_off = str;
364 <                                DDr_CheatTable[cheat_devmodex].message_off = str;
364 >                                DDr_CheatTable[cheat_x].message_off = str;
365                          }
366                          else if (!stricmp(name, "reservoirdogs_on"))
367                                  DDr_CheatTable[12].message_on = strdup(value);
# Line 328 | Line 404 | bool DDrIniCallback(char* section, bool
404                          else
405                                  DDrStartupMessage("unrecognised language item \"%s\"", name);
406                          break;
407 +                case s_bsl:
408                  default:
409                          break;
410          }
# Line 354 | Line 431 | void DDrConfig()
431          DDrStartupMessage("finished parsing");
432   }
433  
434 + void ONICALL DDrGame_Init()
435 + {
436 +        if (opt_usedaodanbsl)
437 +                SLrDaodan_Initalize();
438 + }
439 +
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 391 | Line 515 | void __cdecl DDrMain(int argc, char* arg
515          if (patch_windowhack)
516                  DDrWindowHack_Install();
517          
518 +        if (patch_daodaninit)
519 +                DDrPatch_MakeCall(OniExe + 0x000d345a, DDrGame_Init);
520 +        
521 +        // Patches for existing BSL functions
522 +        if (patch_bsl)
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 404 | 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)