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 468 by rossy, Sun Oct 18 02:26:30 2009 UTC vs.
Revision 839 by alloc, Mon Apr 29 19:08:16 2013 UTC

# Line 1 | Line 1
1 + #include <windows.h>
2   #include <string.h>
3 + #include <stdio.h>
4  
5   #include "Daodan.h"
6   #include "Daodan_Patch.h"
7   #include "Daodan_Utility.h"
6 #include "Daodan_Win32.h"
8   #include "Daodan_Cheater.h"
8 #include "Daodan_Persistence.h"
9   #include "Daodan_BSL.h"
10 <
11 < #include "Daodan_WindowHack.h"
10 > #include "Daodan_Console.h"
11 > #include "Daodan_Config.h"
12 > #include "patches/Patches.h"
13  
14   #include "Oni.h"
14 #include "Oni_Persistence.h"
15
16 #include "BFW_Utility.h"
15  
16 < #include "oni_gl.h"
19 < #include "daodan_gl.h"
20 <
21 < #include "inifile.h"
16 > #include "Oni_GL.h"
17  
18   HMODULE DDrDLLModule;
19   HMODULE DDrONiModule;
20  
26 bool patch_fonttexturecache = true;
27 bool patch_largetextures = true;
28 bool patch_levelplugins = true;
29 bool patch_pathfinding = true;
30 bool patch_projaware = true;
31 bool patch_directinput = true;
32 bool patch_wpfadetime = true;
33 bool patch_kickguns = false;
34 bool patch_cooldowntimer = true;
35 bool patch_throwtest = false;
36 bool patch_alttab = true;
37 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;
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 {
62        DDrStartupMessage("patching engine");
63        
64        // Font texture cache doubled
65        if (patch_fonttexturecache)
66        {
67                DDrPatch_Byte  (OniExe + 0x00020ea7, 0x20);
68                DDrPatch_Byte  (OniExe + 0x00020f4a, 0x40);
69        }
70        
71        // Now supports textures up to 512x512
72        if (patch_largetextures)
73                DDrPatch_Byte  (OniExe + 0x00005251, 0x10);
74        
75        // Non-"_Final" levels are now valid
76        if (patch_levelplugins)
77                DDrPatch_Byte  (OniExe + 0x000206a8, 0x01);
78        
79        // Pathfinding grid cache size x8
80        if (patch_pathfinding)
81        {
82                DDrPatch_Byte  (OniExe + 0x0010b03b, 0x20);
83                DDrPatch_Byte  (OniExe + 0x0010b04c, 0x20);
84        }
85        
86        // Projectile awareness fixed
87        if (patch_projaware)
88        {
89                DDrPatch_Byte  (OniExe + 0x0009c07c, 0x6c);
90                DDrPatch_Byte  (OniExe + 0x0009c080, 0x70);
91                DDrPatch_Byte  (OniExe + 0x0009c084, 0x74);
92                DDrPatch_Byte  (OniExe + 0x0009c110, 0x6c);
93        }
94        
95        // Forced DirectInput (for Windows NT)
96        if (patch_directinput)
97                DDrPatch_Byte  (OniExe + 0x00002e6d, 0xeb);
98        
99        if (patch_wpfadetime)
100        {
101                // Makes wp_fadetime actually have a function
102                const char fadetime_patch[] = { 0x66, 0x8B, 0x1D, 0xC4, 0x7D, 0x62, 0x00, 0x66, 0x89, 0x5E, 0x46, 0x5B, 0x5E, 0x83, 0xC4, 0x14, 0xC3 };
103                DDrPatch_Const (OniExe + 0x0011a889, fadetime_patch);
104                DDrPatch_Byte  (OniExe + 0x0011a560, 0x31);
105                
106                // Sets the fadetime to 4800 by default
107                DDrPatch_Int16 (OniExe + 0x0011ab0e, 0x12c0);
108        }
109        
110        
111        // Hackish fix for Konoko not kicking guns
112        if (patch_kickguns)
113        {
114                const char kickgun_patch[] = { 0x00, 0x05, 0x00, 0x00, 0x00, 0xC7, 0x05, 0x1C, 0xC9, 0x5E, 0x00, 0x70, 0xB8, 0x43, 0x00, 0xC7, 0x05, 0x20, 0xC9, 0x5E, 0x00, 0x20, 0xBE, 0x43 };
115                DDrPatch_Const (OniExe + 0x000dc420, kickgun_patch);
116        }
117        
118        // Cooldown timer exploit fix ^_^
119        if (patch_cooldowntimer)
120        {
121                const char cooldown_patch[] = { 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 };
122                DDrPatch_Const (OniExe + 0x0011a825, cooldown_patch);
123        }
124        
125        if (patch_throwtest)
126        {
127                const char throwtest_patch[] = { 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 };
128                DDrPatch_Const(OniExe + 0x000dc190, throwtest_patch);
129        }
130        
131        // Disable UUrPlatform_Initalize/Terminate, this enables the Alt-Tab and the Windows key but has the possible side effect of allowing the screensaver to enable itself in-game.
132        if (patch_alttab)
133        {
134                DDrPatch_Byte  ((void*)UUrPlatform_Initialize, 0xC3);
135                DDrPatch_Byte  ((void*)UUrPlatform_Terminate, 0xC3);
136        }
137        
138        // Unlocks particle action disabling/enabling bits for all events. (Will be controlled by a command line switch when I figure out how to do that without Win32 hacks.)
139        if (patch_particledisablebit)
140                DDrPatch_Int16 (OniExe + 0x001b184, 0x9090);
141        
142        // Multi-byte patch (multiple language support)
143        if (!patch_multibyte)
144        {
145                DDrPatch_Byte  (OniExe + 0x0002d8f8, 0xeb);
146                DDrPatch_Byte  (OniExe + 0x0002d9ad, 0xeb);
147                DDrPatch_Byte  (OniExe + 0x0002dbe2, 0xeb);
148                DDrPatch_Byte  (OniExe + 0x0002dec3, 0xeb);
149                DDrPatch_Byte  (OniExe + 0x0002e2ab, 0xeb);
150                DDrPatch_Byte  (OniExe + 0x0002e2c4, 0xeb);
151                DDrPatch_Byte  (OniExe + 0x0002e379, 0xeb);
152                DDrPatch_Byte  (OniExe + 0x0002e48c, 0xeb);
153                DDrPatch_Byte  (OniExe + 0x0002e4d0, 0xeb);
154                DDrPatch_Byte  (OniExe + 0x0002e4f4, 0xeb);
155                DDrPatch_Byte  (OniExe + 0x0002e646, 0xeb);
156                DDrPatch_Byte  (OniExe + 0x0002e695, 0xeb);
157                DDrPatch_Byte  (OniExe + 0x0002e944, 0xeb);
158                DDrPatch_Byte  (OniExe + 0x0002e95d, 0xeb);
159                DDrPatch_Byte  (OniExe + 0x0002e98e, 0xeb);
160                DDrPatch_Byte  (OniExe + 0x0002e9dc, 0xeb);
161        }
162        
163        // Cheat table patch
164        if (patch_cheattable)
165        {
166                DDrPatch_Int32 (OniExe + 0x000f616b, (int)&DDr_CheatTable[0].name);
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_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, "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 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(inifile_cleanstr(value), "true");
244                        else if (!stricmp(name, "largetextures"))
245                                patch_largetextures = !stricmp(inifile_cleanstr(value), "true");
246                        else if (!stricmp(name, "levelplugins"))
247                                patch_levelplugins = !stricmp(inifile_cleanstr(value), "true");
248                        else if (!stricmp(name, "pathfinding"))
249                                patch_pathfinding = !stricmp(inifile_cleanstr(value), "true");
250                        else if (!stricmp(name, "projaware"))
251                                patch_projaware = !stricmp(inifile_cleanstr(value), "true");
252                        else if (!stricmp(name, "directinput"))
253                                patch_directinput = !stricmp(inifile_cleanstr(value), "true");
254                        else if (!stricmp(name, "wpfadetime"))
255                                patch_wpfadetime = !stricmp(inifile_cleanstr(value), "true");
256                        else if (!stricmp(name, "kickguns"))
257                                patch_kickguns = !stricmp(inifile_cleanstr(value), "true");
258                        else if (!stricmp(name, "cooldowntimer"))
259                                patch_cooldowntimer = !stricmp(inifile_cleanstr(value), "true");
260                        else if (!stricmp(name, "throwtest"))
261                                patch_throwtest = !stricmp(inifile_cleanstr(value), "true");
262                        else if (!stricmp(name, "alttab"))
263                                patch_alttab = !stricmp(inifile_cleanstr(value), "true");
264                        else if (!stricmp(name, "particledisablebit"))
265                                patch_particledisablebit = !stricmp(inifile_cleanstr(value), "true");
266                        else if (!stricmp(name, "multibyte"))
267                                patch_multibyte = !stricmp(inifile_cleanstr(value), "true");
268                        else if (!stricmp(name, "cheattable"))
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"))
281                                patch_daodandisplayenum = !stricmp(inifile_cleanstr(value), "true");
282                        else if (!stricmp(name, "usegettickcount"))
283                                patch_usegettickcount = !stricmp(inifile_cleanstr(value), "true");
284                        else if (!stricmp(name, "cheatsenabled"))
285                                patch_cheatsenabled = !stricmp(inifile_cleanstr(value), "true");
286                        else if (!stricmp(name, "usedaodangl"))
287                                patch_usedaodangl = !stricmp(inifile_cleanstr(value), "true");
288                        else if (!stricmp(name, "windowhack"))
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;
299                case s_language:
300                        if (!stricmp(name, "savepoint"))
301                        {
302                                char* str = strdup(value);
303                                DDrPatch_Int32(OniExe + 0x000fd730, (int)str);
304                                DDrPatch_Int32(OniExe + 0x000fd738, (int)str);
305                        }
306                        else if (!stricmp(name, "syndicatewarehouse"))
307                        {
308                                char* str = strdup(value);
309                                DDrPatch_Int32(OniExe + 0x000fd71a, (int)str);
310                                DDrPatch_Int32(OniExe + 0x0010ef75, (int)str);
311                        }
312                        else if (!stricmp(name, "damn"))
313                                DDrPatch_StrDup(OniExe + 0x0010fb6e, value);
314                        else if (!stricmp(name, "blam"))
315                                DDrPatch_StrDup(OniExe + 0x0010fb73, value);
316                        else if (!stricmp(name, "shapeshifter_on"))
317                                DDr_CheatTable[0].message_on = strdup(value);
318                        else if (!stricmp(name, "shapeshifter_off"))
319                                DDr_CheatTable[0].message_off = strdup(value);
320                        else if (!stricmp(name, "liveforever_on"))
321                                DDr_CheatTable[1].message_on = strdup(value);
322                        else if (!stricmp(name, "liveforever_off"))
323                                DDr_CheatTable[1].message_off = strdup(value);
324                        else if (!stricmp(name, "touchofdeath_on"))
325                                DDr_CheatTable[2].message_on = strdup(value);
326                        else if (!stricmp(name, "touchofdeath_off"))
327                                DDr_CheatTable[2].message_off = strdup(value);
328                        else if (!stricmp(name, "canttouchthis_on"))
329                                DDr_CheatTable[3].message_on = strdup(value);
330                        else if (!stricmp(name, "canttouchthis_off"))
331                                DDr_CheatTable[3].message_off = strdup(value);
332                        else if (!stricmp(name, "fatloot_on"))
333                                DDr_CheatTable[4].message_on = strdup(value);
334                        else if (!stricmp(name, "glassworld_on"))
335                                DDr_CheatTable[5].message_on = strdup(value);
336                        else if (!stricmp(name, "glassworld_off"))
337                                DDr_CheatTable[5].message_off = strdup(value);
338                        else if (!stricmp(name, "winlevel_on"))
339                                DDr_CheatTable[6].message_on = strdup(value);
340                        else if (!stricmp(name, "loselevel_on"))
341                                DDr_CheatTable[7].message_on = strdup(value);
342                        else if (!stricmp(name, "bighead_on"))
343                                DDr_CheatTable[8].message_on = strdup(value);
344                        else if (!stricmp(name, "bighead_off"))
345                                DDr_CheatTable[8].message_off = strdup(value);
346                        else if (!stricmp(name, "minime_on"))
347                                DDr_CheatTable[9].message_on = strdup(value);
348                        else if (!stricmp(name, "minime_off"))
349                                DDr_CheatTable[9].message_off = strdup(value);
350                        else if (!stricmp(name, "superammo_on"))
351                                DDr_CheatTable[10].message_on = strdup(value);
352                        else if (!stricmp(name, "superammo_off"))
353                                DDr_CheatTable[10].message_off = strdup(value);
354                        else if (!stricmp(name, "devmode_on"))
355                        {
356                                char* str = strdup(value);
357                                DDr_CheatTable[11].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_x].message_off = str;
365                        }
366                        else if (!stricmp(name, "reservoirdogs_on"))
367                                DDr_CheatTable[12].message_on = strdup(value);
368                        else if (!stricmp(name, "reservoirdogs_off"))
369                                DDr_CheatTable[12].message_off = strdup(value);
370                        else if (!stricmp(name, "roughjustice_on"))
371                                DDr_CheatTable[13].message_on = strdup(value);
372                        else if (!stricmp(name, "roughjustice_off"))
373                                DDr_CheatTable[13].message_off = strdup(value);
374                        else if (!stricmp(name, "chenille_on"))
375                                DDr_CheatTable[14].message_on = strdup(value);
376                        else if (!stricmp(name, "chenille_off"))
377                                DDr_CheatTable[14].message_off = strdup(value);
378                        else if (!stricmp(name, "behemoth_on"))
379                                DDr_CheatTable[15].message_on = strdup(value);
380                        else if (!stricmp(name, "behemoth_off"))
381                                DDr_CheatTable[15].message_off = strdup(value);
382                        else if (!stricmp(name, "elderrune_on"))
383                                DDr_CheatTable[16].message_on = strdup(value);
384                        else if (!stricmp(name, "elderrune_off"))
385                                DDr_CheatTable[16].message_off = strdup(value);
386                        else if (!stricmp(name, "moonshadow_on"))
387                                DDr_CheatTable[17].message_on = strdup(value);
388                        else if (!stricmp(name, "moonshadow_off"))
389                                DDr_CheatTable[17].message_off = strdup(value);
390                        else if (!stricmp(name, "munitionfrenzy_on"))
391                                DDr_CheatTable[18].message_on = strdup(value);
392                        else if (!stricmp(name, "fistsoflegend_on"))
393                                DDr_CheatTable[19].message_on = strdup(value);
394                        else if (!stricmp(name, "fistsoflegend_off"))
395                                DDr_CheatTable[19].message_off = strdup(value);
396                        else if (!stricmp(name, "killmequick_on"))
397                                DDr_CheatTable[20].message_on = strdup(value);
398                        else if (!stricmp(name, "killmequick_off"))
399                                DDr_CheatTable[20].message_off = strdup(value);
400                        else if (!stricmp(name, "carousel_on"))
401                                DDr_CheatTable[21].message_on = strdup(value);
402                        else if (!stricmp(name, "carousel_off"))
403                                DDr_CheatTable[21].message_off = strdup(value);
404                        else
405                                DDrStartupMessage("unrecognised language item \"%s\"", name);
406                        break;
407                case s_bsl:
408                default:
409                        break;
410        }
411        
412        return true;
413 }
414
415 void DDrConfig()
416 {
417        if (GetFileAttributes("daodan.ini") == INVALID_FILE_ATTRIBUTES)
418        {
419                DDrStartupMessage("daodan.ini doesn't exist, creating");
420                FILE* fp = fopen("daodan.ini", "w");
421                if (fp)
422                {
423                        fputs("[Options]\n", fp);
424                        fclose(fp);
425                }
426        }
427        
428        DDrStartupMessage("parsing daodan.ini...");
429        if (!inifile_read("daodan.ini", DDrIniCallback))
430                DDrStartupMessage("error reading daodan.ini, check your syntax!");
431        DDrStartupMessage("finished parsing");
432 }
433
434 void ONICALL DDrGame_Init()
435 {
436        if (opt_usedaodanbsl)
437                SLrDaodan_Initalize();
438 }
21  
22   void __cdecl DDrMain(int argc, char* argv[])
23   {
24 <        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
488 <        if (patch_safeprintf)
489 <                DDrPatch_MakeJump(UUrStartupMessage, DDrStartupMessage);
490 <        
491 <        // Daodan device mode enumeration function
492 <        if (patch_daodandisplayenum)
493 <                DDrPatch_MakeJump(gl_enumerate_valid_display_modes, daodan_enumerate_valid_display_modes);
24 >        DDrStartupMessage("Daodan: Daodan attached!");
25          
26 <        // Performance patch
27 <        if (patch_usegettickcount)
28 <        {
498 <                DDrPatch_MakeJump(UUrMachineTime_High, DDrMachineTime_High);
499 <                DDrPatch_MakeJump(UUrMachineTime_High_Frequency, DDrMachineTime_High_Frequency);
500 <                DDrPatch_MakeJump(UUrMachineTime_Sixtieths, DDrMachineTime_Sixtieths);
501 <        }
502 <        
503 <        // Cheats always enabled
504 <        if (patch_cheatsenabled)
505 <                DDrPatch_MakeJump(ONrPersist_GetWonGame, DDrPersist_GetWonGame);
506 <        
507 <        // Windowed mode
508 <        if (patch_usedaodangl)
509 <        {
510 <                DDrPatch_MakeJump(ONrPlatform_Initialize, DDrPlatform_Initialize);
511 <                DDrPatch_MakeJump(gl_platform_initialize, daodangl_platform_initialize);
512 <        }
513 <        
514 <        // Hacked windowed mode (for when daodangl isn't working properly)
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 <        }
26 >        DDrConfig(argc, argv);
27 >
28 >        DD_Patch_Init();
29          
533        init_daodan_gl();
30          
31          ONiMain(argc, argv);
32   }
# Line 565 | Line 61 | BOOL WINAPI DllMain(HINSTANCE hinstDLL,
61                          DDrDLLModule = hinstDLL;
62                          DDrONiModule = GetModuleHandle(NULL);
63                          
64 <                        if (*(uint32_t*)((void*)OniExe + 0x0011acd0) == 0x09d36852)
65 <                                DDrPatch_MakeCall(OniExe + 0x0010fb49, DDrMain);
64 >                        if (*(uint32_t*)(OniExe + 0x0011acd0) == 0x09d36852)
65 >                                DDrPatch_MakeCall((void*)(OniExe + 0x0010fb49), (void*)DDrMain);
66                          else
67                                  ExitProcess(0);
68                          break;

Diff Legend

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