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 693 by alloc, Thu Mar 7 22:38:21 2013 UTC

# Line 1 | Line 1
1 + #include <windows.h>
2   #include <string.h>
3  
4   #include "Daodan.h"
# Line 6 | Line 7
7   #include "Daodan_Win32.h"
8   #include "Daodan_Cheater.h"
9   #include "Daodan_Persistence.h"
10 <
10 > #include "Daodan_BSL.h"
11 > #include "Daodan_Console.h"
12   #include "Daodan_WindowHack.h"
13  
14   #include "Oni.h"
13 #include "Oni_Persistence.h"
14
15 #include "BFW_Utility.h"
15  
16 < #include "oni_gl.h"
17 < #include "daodan_gl.h"
16 > #include "Oni_GL.h"
17 > #include "Daodan_GL.h"
18  
19 < #include "inifile.h"
19 > #include "Inifile_Reader.h"
20  
21   HMODULE DDrDLLModule;
22   HMODULE DDrONiModule;
# Line 34 | Line 33 | bool patch_cooldowntimer = true;
33   bool patch_throwtest = false;
34   bool patch_alttab = true;
35   bool patch_particledisablebit = false;
36 < bool patch_multibyte = true;
36 > bool patch_multibyte = false;
37   bool patch_cheattable = true;
38 + bool patch_argb8888 = true;
39 + bool patch_killvtune = true;
40 + bool patch_getcmdline = true;
41 + bool patch_disablecmdline = true;
42 + bool patch_optionsvisible = true;
43  
44   bool patch_safeprintf = true;
45   bool patch_daodandisplayenum = true;
# Line 43 | Line 47 | bool patch_usegettickcount = true;
47   bool patch_cheatsenabled = true;
48   bool patch_usedaodangl = false;
49   bool patch_windowhack = true;
50 + bool patch_daodaninit = true;
51 + bool patch_bsl = true;
52 + bool patch_cheater = true;
53 + bool patch_newweapon = true;
54 + bool opt_usedaodanbsl = true;
55 + bool opt_border = true;
56 + bool opt_topmost = false;
57 +
58 + typedef int (__cdecl *CHINESEPROC)(DWORD WINAPI);
59 + bool patch_chinese = false;
60 +
61 +
62 +
63 + void ONICALL DDrShowResumeButton(int window, int visibility)
64 + {
65 +        if (visibility)
66 +                WMrWindow_SetLocation(window, 150, 350);
67 +        WMrWindow_SetVisible(window, visibility);
68 + }
69 +
70 +
71 + /* Options always visible patch */
72 + void ONICALL DDrShowOptionsButton(int window, int visibility)
73 + {
74 +        WMrWindow_SetVisible(window, 1);
75 + }
76 +
77 +
78  
79   bool DDrPatch_Init()
80   {
# Line 51 | Line 83 | bool DDrPatch_Init()
83          // Font texture cache doubled
84          if (patch_fonttexturecache)
85          {
86 <                DDrPatch_Byte  (OniExe + 0x00020ea7, 0x20);
87 <                DDrPatch_Byte  (OniExe + 0x00020f4a, 0x40);
86 >                DDrPatch_Byte((char*)(OniExe + 0x00020ea7), 0x20);
87 >                DDrPatch_Byte((char*)(OniExe + 0x00020f4a), 0x40);
88          }
89          
90          // Now supports textures up to 512x512
91          if (patch_largetextures)
92 <                DDrPatch_Byte  (OniExe + 0x00005251, 0x10);
92 >                DDrPatch_Byte  ((char*)(OniExe + 0x00005251), 0x10);
93          
94          // Non-"_Final" levels are now valid
95          if (patch_levelplugins)
96 <                DDrPatch_Byte  (OniExe + 0x000206a8, 0x01);
96 >                DDrPatch_Byte  ((char*)(OniExe + 0x000206a8), 0x01);
97          
98          // Pathfinding grid cache size x8
99          if (patch_pathfinding)
100          {
101 <                DDrPatch_Byte  (OniExe + 0x0010b03b, 0x20);
102 <                DDrPatch_Byte  (OniExe + 0x0010b04c, 0x20);
101 >                const unsigned char pathfinding[2] = {0x90 , 0xE9 };
102 >                DDrPatch_Byte  ((char*)(OniExe + 0x0010b03b), 0x20);
103 >                DDrPatch_Byte  ((char*)(OniExe + 0x0010b04c), 0x20);
104 >
105 >                //other stuff
106 >                DDrPatch_Const((char*)(OniExe + 0x00040789), pathfinding);
107          }
108          
109          // Projectile awareness fixed
110          if (patch_projaware)
111          {
112 <                DDrPatch_Byte  (OniExe + 0x0009c07c, 0x6c);
113 <                DDrPatch_Byte  (OniExe + 0x0009c080, 0x70);
114 <                DDrPatch_Byte  (OniExe + 0x0009c084, 0x74);
115 <                DDrPatch_Byte  (OniExe + 0x0009c110, 0x6c);
112 >                DDrPatch_Byte  ((char*)(OniExe + 0x0009c07c), 0x6c);
113 >                DDrPatch_Byte  ((char*)(OniExe + 0x0009c080), 0x70);
114 >                DDrPatch_Byte  ((char*)(OniExe + 0x0009c084), 0x74);
115 >                DDrPatch_Byte  ((char*)(OniExe + 0x0009c110), 0x6c);
116          }
117          
118          // Forced DirectInput (for Windows NT)
119          if (patch_directinput)
120 <                DDrPatch_Byte  (OniExe + 0x00002e6d, 0xeb);
121 <        
120 >                DDrPatch_Byte((char*)(OniExe + 0x00002e6d), 0xeb);
121 >
122          if (patch_wpfadetime)
123          {
124                  // Makes wp_fadetime actually have a function
125 <                const char fadetime_patch[] = { 0x66, 0x8B, 0x1D, 0xC4, 0x7D, 0x62, 0x00, 0x66, 0x89, 0x5E, 0x46, 0x5B, 0x5E, 0x83, 0xC4, 0x14, 0xC3 };
126 <                DDrPatch_Const (OniExe + 0x0011a889, fadetime_patch);
127 <                DDrPatch_Byte  (OniExe + 0x0011a560, 0x31);
125 >                const unsigned char fadetime_patch[] = { 0x66, 0x8B, 0x1D, 0xC4, 0x7D, 0x62, 0x00, 0x66, 0x89, 0x5E, 0x46, 0x5B, 0x5E, 0x83, 0xC4, 0x14, 0xC3 };
126 >                DDrPatch_Const ((char*)(OniExe + 0x0011a889), fadetime_patch);
127 >                DDrPatch_Byte  ((char*)(OniExe + 0x0011a560), 0x31);
128                  
129                  // Sets the fadetime to 4800 by default
130 <                DDrPatch_Int16 (OniExe + 0x0011ab0e, 0x12c0);
130 >                DDrPatch_Int16 ((short*)(OniExe + 0x0011ab0e), 0x12c0);
131          }
132          
133 +        // FIXME: add switches
134 +        //pathfinding fix
135 +
136 +        
137 +
138          
139          // Hackish fix for Konoko not kicking guns
140 +        // Don't use this, it breaks stairs.
141          if (patch_kickguns)
142          {
143 <                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 };
144 <                DDrPatch_Const (OniExe + 0x000dc420, kickgun_patch);
143 >                const unsigned 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 };
144 >                DDrPatch_Const ((char*)(OniExe + 0x000dc420), kickgun_patch);
145          }
146          
147          // Cooldown timer exploit fix ^_^
148          if (patch_cooldowntimer)
149          {
150 <                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 };
151 <                DDrPatch_Const (OniExe + 0x0011a825, cooldown_patch);
150 >                const unsigned 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 };
151 >                DDrPatch_Const ((char*)(OniExe + 0x0011a825), cooldown_patch);
152          }
153          
154          if (patch_throwtest)
155          {
156 <                const char throwtest_patch[] = { 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 };
157 <                DDrPatch_Const(OniExe + 0x000dc190, throwtest_patch);
156 >                const unsigned char throwtest_patch[] = { 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 };
157 >                DDrPatch_Const((char*)(OniExe + 0x000dc190), throwtest_patch);
158          }
159          
160          // 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.
161          if (patch_alttab)
162          {
163 <                DDrPatch_Byte  ((void*)UUrPlatform_Initialize, 0xC3);
164 <                DDrPatch_Byte  ((void*)UUrPlatform_Terminate, 0xC3);
163 >                // 0xC3 = ret, so makes those functions just have a "ret" instruction at their start
164 >                DDrPatch_Byte  ((char*)UUrPlatform_Initialize, 0xC3);
165 >                DDrPatch_Byte  ((char*)UUrPlatform_Terminate, 0xC3);
166          }
167          
168          // 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.)
169          if (patch_particledisablebit)
170 <                DDrPatch_Int16 (OniExe + 0x001b184, 0x9090);
170 >                DDrPatch_Int16 ((short*)(OniExe + 0x001b184), 0x9090);
171          
172          // Multi-byte patch (multiple language support)
173 <        if (patch_multibyte)
173 >        if (!patch_multibyte)
174          {
175 <                DDrPatch_Byte  (OniExe + 0x0002d8f8, 0xeb);
176 <                DDrPatch_Byte  (OniExe + 0x0002d9ad, 0xeb);
177 <                DDrPatch_Byte  (OniExe + 0x0002dbe2, 0xeb);
178 <                DDrPatch_Byte  (OniExe + 0x0002dec3, 0xeb);
179 <                DDrPatch_Byte  (OniExe + 0x0002e2ab, 0xeb);
180 <                DDrPatch_Byte  (OniExe + 0x0002e2c4, 0xeb);
181 <                DDrPatch_Byte  (OniExe + 0x0002e379, 0xeb);
182 <                DDrPatch_Byte  (OniExe + 0x0002e48c, 0xeb);
183 <                DDrPatch_Byte  (OniExe + 0x0002e4d0, 0xeb);
184 <                DDrPatch_Byte  (OniExe + 0x0002e4f4, 0xeb);
185 <                DDrPatch_Byte  (OniExe + 0x0002e646, 0xeb);
186 <                DDrPatch_Byte  (OniExe + 0x0002e695, 0xeb);
187 <                DDrPatch_Byte  (OniExe + 0x0002e944, 0xeb);
188 <                DDrPatch_Byte  (OniExe + 0x0002e95d, 0xeb);
189 <                DDrPatch_Byte  (OniExe + 0x0002e98e, 0xeb);
190 <                DDrPatch_Byte  (OniExe + 0x0002e9dc, 0xeb);
175 >                DDrPatch_Byte  ((char*)(OniExe + 0x0002d8f8), 0xeb);
176 >                DDrPatch_Byte  ((char*)(OniExe + 0x0002d9ad), 0xeb);
177 >                DDrPatch_Byte  ((char*)(OniExe + 0x0002dbe2), 0xeb);
178 >                DDrPatch_Byte  ((char*)(OniExe + 0x0002dec3), 0xeb);
179 >                DDrPatch_Byte  ((char*)(OniExe + 0x0002e2ab), 0xeb);
180 >                DDrPatch_Byte  ((char*)(OniExe + 0x0002e2c4), 0xeb);
181 >                DDrPatch_Byte  ((char*)(OniExe + 0x0002e379), 0xeb);
182 >                DDrPatch_Byte  ((char*)(OniExe + 0x0002e48c), 0xeb);
183 >                DDrPatch_Byte  ((char*)(OniExe + 0x0002e4d0), 0xeb);
184 >                DDrPatch_Byte  ((char*)(OniExe + 0x0002e4f4), 0xeb);
185 >                DDrPatch_Byte  ((char*)(OniExe + 0x0002e646), 0xeb);
186 >                DDrPatch_Byte  ((char*)(OniExe + 0x0002e695), 0xeb);
187 >                DDrPatch_Byte  ((char*)(OniExe + 0x0002e944), 0xeb);
188 >                DDrPatch_Byte  ((char*)(OniExe + 0x0002e95d), 0xeb);
189 >                DDrPatch_Byte  ((char*)(OniExe + 0x0002e98e), 0xeb);
190 >                DDrPatch_Byte  ((char*)(OniExe + 0x0002e9dc), 0xeb);
191          }
192          
193          // Cheat table patch
194          if (patch_cheattable)
195          {
196 <                DDrPatch_Int32 (OniExe + 0x000f616b, (int)&DDr_CheatTable[0].name);
197 <                DDrPatch_Int32 (OniExe + 0x000f617a, (int)&DDr_CheatTable[0].message_on);
196 >                DDrPatch_Int32 ((int*)(OniExe + 0x000f616b), (int)&DDr_CheatTable[0].name);
197 >                DDrPatch_Int32 ((int*)(OniExe + 0x000f617a), (int)&DDr_CheatTable[0].message_on);
198 >        }
199 >        
200 >        // ARGB8888 textures
201 >        if (patch_argb8888)
202 >        {
203 >                DDrPatch_Byte  ((char*)(OniExe + 0x00135af0), 0x07);
204 >                DDrPatch_Byte  ((char*)(OniExe + 0x00135af4), 0x0B);
205 >        }
206 >
207 >        //Test newweap patch
208 >        if (patch_newweapon) {
209 >                
210 >                //Makes it always say "Recieved weapon_name."
211 >                //Needs check for loc_4DFC66
212 >                //DDrPatch_NOOP((char*)(OniExe + 0x000E4DF8),2);
213 >
214 >                //Adds Weapon name and ammo meter to pickup autoprompt
215 >                DDrPatch_NOOP((char*)(OniExe + 0x000FAC73), 9);
216 >                DDrPatch_NOOP((char*)(OniExe + 0x000FAC80), 5);
217 >                DDrPatch_MakeCall((void*)(OniExe + 0xFAC85), (void*)DDrWeapon2Message);
218 >                
219 >                //Moves location of colors
220 >                //DDrPatch_Int32((int*)(OniExe + 0x0002E3D5), (int)&DDrDSayColors );
221 >                //DDrPatch_Int32((int*)(OniExe + 0x0002E3DA), (int)&DDrDSayColors );
222 >        }
223 >        
224 >        // Disable loading the vtuneapi.dll
225 >        //if (patch_killvtune)
226 >                //DDrPatch_Byte  ((char*)(OniExe + 0x00026340), 0xC3);
227 >        
228 >        // Disable Oni's internal CLrGetCommandLine function (to eventually replace it with our own)
229 >        if (patch_getcmdline)
230 >                DDrPatch_NOOP  ((char*)(OniExe + 0x000d3280), 51);
231 >        
232 >        // Disable Oni's command line parser so it doesn't interfere with ours
233 >        if (patch_disablecmdline)
234 >                DDrPatch_Int32 ((int*)(OniExe + 0x000d3570), 0xc3c03366);
235 >        
236 >        if (patch_bsl)
237 >        {
238 >                //Calculating the value of the needed offset is much more reliable when the compiler does it for you.
239 >
240 >                //TODO: fix moonshadow.
241 >                Character * Chr = 0;
242 >                int NoPath = (int)&(Chr[0].RegenHax) & 0x000000FF;
243 >                const unsigned char regen_patch[] =
244 >                {0x90, 0x90, 0x90, 0x90, 0x90,                          // mov    al, _WPgRegenerationCheat     -> NOOP
245 >                0x90, 0x90,                                                                     // test   al, al                                        -> NOOP
246 >                0x90, 0x90,                                                                     // jz     short loc_51BB98                      -> NOOP
247 >                0x8B, 0x86, (char)NoPath, 0x01, 0x00, 0x00, // mov     eax, [esi+Character.field_1E8]
248 >                                                                                                        //      -> mov     eax, [esi+Character.RegenHax]
249 >                0x85, 0xC0,                                                                     // test eax, eax
250 >                0x74, 0x21                                                                      // jnz 0x21 -> jz 0x21
251 >                };      
252 >                DDrPatch_Const((char*)(OniExe + 0x0011BB64), regen_patch);
253 >        }
254 >        
255 >        if(patch_chinese)
256 >        {
257 >                HMODULE dll = LoadLibrary("xfhsm_oni.dll");
258 >                if( dll )
259 >                {
260 >                        void* proc = GetProcAddress( dll, "InstallHook" );
261 >                        if(proc)
262 >                        {
263 >                                ((CHINESEPROC)proc)(GetCurrentThreadId());
264 >                        }
265 >                }
266 >        }
267 >
268 >        //Fix crappy ai2_shownames
269 >        if(1)
270 >        {
271 >                //Set distance above head to 4.0
272 >                DDrPatch_Int32((int*)(OniExe + 0x0008C998), 0x005296C8);
273 >                //texture height
274 >                DDrPatch_Byte((char*)(OniExe + 0x0008C9DF), 0x3F );
275 >                //texture       width
276 >                DDrPatch_NOOP((char*)(OniExe + 0x0008C9CA), 6 );
277 >                //Set the text color to whatever we like ;)
278 >                DDrPatch_NOOP((char*)(OniExe + 0x0008C898), 6 );
279 >                DDrPatch_Byte((char*)(OniExe + 0x0008C898), 0x8B );
280 >                DDrPatch_Byte((char*)(OniExe + 0x0008C899), 0xCE );
281 > //FLATLINE?             DDrPatch_MakeCall((void*)(OniExe + 0x0008C8A3), FLrHook_DebugNameShadeHack);
282 >                
283 >                //Make the background black for additive blending
284 > //FLATLINE?             DDrPatch_MakeCall((void*)(OniExe + 0x0008C802), FLrHook_DebugNameTextureInit );
285 >        }
286 >
287 >        if(1)
288 >        {
289 >                //DDrPatch_NOOP((char*)(OniExe + 0x000E1957), 6 );
290 >                //DDrPatch_MakeCall((void*)(OniExe + 0x000E17F6), FLrHook_Lasers );
291          }
292 +
293 +        //Flatline related stuff
294 + //      DDrPatch_MakeCall((void*)(OniExe + 0x000FBCEA), DDrText_Hook);
295          
296 + //FLATLINE?     DDrPatch_Int32((int*)(OniExe + 0x000B24D2), FLrSpawnHack);
297 +
298 + //FLATLINE?     DDrPatch_NOOP((char*)(OniExe + 0x000C26CB), 6);
299 +
300 + //FLATLINE?     DDrPatch_MakeCall((void*)(OniExe + 0x000C26CB), FLrHook_DoorOpen);
301 + //FLATLINE?     DDrPatch_MakeCall((void*)(OniExe + 0x000EE3CF), FLrHook_ConsoleActivate);
302 +
303 +
304 +        // Fix options not visible in main menu when a game was started
305 +        if(patch_optionsvisible)
306 +        {
307 +                DDrPatch_MakeCall((void*)(OniExe + 0x000d2d2d), DDrShowOptionsButton);
308 +                DDrPatch_MakeCall((void*)(OniExe + 0x000d2d43), DDrShowResumeButton);
309 +        }
310 +
311          return true;
312   }
313  
314 < enum {s_unknown, s_patch, s_language} ini_section;
314 >
315 > enum {s_unknown, s_options, s_patch, s_bsl, s_language} ini_section;
316  
317   bool DDrIniCallback(char* section, bool newsection, char* name, char* value)
318   {
319          if (newsection)
320          {
321 <                if (!stricmp(section, "patch"))
321 >                if (!_stricmp(section, "options"))
322 >                        ini_section = s_options;
323 >                else if (!_stricmp(section, "patch"))
324                          ini_section = s_patch;
325 <                else if (!stricmp(section, "language"))
325 >                else if (!_stricmp(section, "bsl"))
326 >                        ini_section = s_bsl;
327 >                else if (!_stricmp(section, "language"))
328                          ini_section = s_language;
329                  else
330                  {
331                          ini_section = s_unknown;
332 <                        DDrStartupMessage("unrecognised ini section \"%s\"", section);
332 >                        DDrStartupMessage("unrecognised section \"%s\"", section);
333                  }
334          }
335          
336          switch (ini_section)
337          {
338 +                case s_options:
339 +                        if (!_stricmp(name, "usedaodanbsl"))
340 +                                opt_usedaodanbsl = !_stricmp(inifile_cleanstr(value), "true");
341 +                        else if (!_stricmp(name, "border"))
342 +                                opt_border = !_stricmp(inifile_cleanstr(value), "true");
343 +                        else if (!_stricmp(name, "topmost"))
344 +                                opt_topmost = !_stricmp(inifile_cleanstr(value), "true");
345 +                        else if (!_stricmp(name, "multibyte"))
346 +                                patch_multibyte = !_stricmp(inifile_cleanstr(value), "true");
347 +                        else if (!_stricmp(name, "debug"))
348 +                                AKgDebug_DebugMaps = !_stricmp(inifile_cleanstr(value), "true");
349 +                        else if (!_stricmp(name, "debugfiles"))
350 +                                BFgDebugFileEnable = !_stricmp(inifile_cleanstr(value), "true");
351 +                        else if (!_stricmp(name, "findsounds"))
352 +                                SSgSearchOnDisk = !_stricmp(inifile_cleanstr(value), "true");
353 +                        else if (!_stricmp(name, "ignore_private_data"))
354 +                                opt_ignore_private_data = !_stricmp(inifile_cleanstr(value), "true");
355 +                        else if (!_stricmp(name, "sound"))
356 +                                opt_sound = !_stricmp(inifile_cleanstr(value), "true");
357 +                        else if (!_stricmp(name, "switch"))
358 +                                M3gResolutionSwitch = !_stricmp(inifile_cleanstr(value), "true");
359 +                        else
360 +                                DDrStartupMessage("unrecognised option \"%s\"", name);
361 +                        break;
362                  case s_patch:
363 <                        if (!stricmp(name, "fonttexturecache"))
364 <                                patch_fonttexturecache = !stricmp(value, "true");
365 <                        else if (!stricmp(name, "largetextures"))
366 <                                patch_largetextures = !stricmp(value, "true");
367 <                        else if (!stricmp(name, "levelplugins"))
368 <                                patch_levelplugins = !stricmp(value, "true");
369 <                        else if (!stricmp(name, "pathfinding"))
370 <                                patch_pathfinding = !stricmp(value, "true");
371 <                        else if (!stricmp(name, "projaware"))
372 <                                patch_projaware = !stricmp(value, "true");
373 <                        else if (!stricmp(name, "directinput"))
374 <                                patch_directinput = !stricmp(value, "true");
375 <                        else if (!stricmp(name, "wpfadetime"))
376 <                                patch_wpfadetime = !stricmp(value, "true");
377 <                        else if (!stricmp(name, "kickguns"))
378 <                                patch_kickguns = !stricmp(value, "true");
379 <                        else if (!stricmp(name, "cooldowntimer"))
380 <                                patch_cooldowntimer = !stricmp(value, "true");
381 <                        else if (!stricmp(name, "throwtest"))
382 <                                patch_throwtest = !stricmp(value, "true");
383 <                        else if (!stricmp(name, "alttab"))
384 <                                patch_alttab = !stricmp(value, "true");
385 <                        else if (!stricmp(name, "particledisablebit"))
386 <                                patch_particledisablebit = !stricmp(value, "true");
387 <                        else if (!stricmp(name, "multibyte"))
388 <                                patch_multibyte = !stricmp(value, "true");
389 <                        else if (!stricmp(name, "cheattable"))
390 <                                patch_cheattable = !stricmp(value, "true");
391 <                        else if (!stricmp(name, "safeprintf"))
392 <                                patch_safeprintf = !stricmp(value, "true");
393 <                        else if (!stricmp(name, "daodandisplayenum"))
394 <                                patch_daodandisplayenum = !stricmp(value, "true");
395 <                        else if (!stricmp(name, "usegettickcount"))
396 <                                patch_usegettickcount = !stricmp(value, "true");
397 <                        else if (!stricmp(name, "cheatsenabled"))
398 <                                patch_cheatsenabled = !stricmp(value, "true");
399 <                        else if (!stricmp(name, "usedaodangl"))
400 <                                patch_usedaodangl = !stricmp(value, "true");
401 <                        else if (!stricmp(name, "windowhack"))
402 <                                patch_windowhack = !stricmp(value, "true");
363 >                        if (!_stricmp(name, "fonttexturecache"))
364 >                                patch_fonttexturecache = !_stricmp(inifile_cleanstr(value), "true");
365 >                        else if (!_stricmp(name, "largetextures"))
366 >                                patch_largetextures = !_stricmp(inifile_cleanstr(value), "true");
367 >                        else if (!_stricmp(name, "levelplugins"))
368 >                                patch_levelplugins = !_stricmp(inifile_cleanstr(value), "true");
369 >                        else if (!_stricmp(name, "pathfinding"))
370 >                                patch_pathfinding = !_stricmp(inifile_cleanstr(value), "true");
371 >                        else if (!_stricmp(name, "projaware"))
372 >                                patch_projaware = !_stricmp(inifile_cleanstr(value), "true");
373 >                        else if (!_stricmp(name, "directinput"))
374 >                                patch_directinput = !_stricmp(inifile_cleanstr(value), "true");
375 >                        else if (!_stricmp(name, "wpfadetime"))
376 >                                patch_wpfadetime = !_stricmp(inifile_cleanstr(value), "true");
377 >                        else if (!_stricmp(name, "kickguns"))
378 >                                patch_kickguns = !_stricmp(inifile_cleanstr(value), "true");
379 >                        else if (!_stricmp(name, "cooldowntimer"))
380 >                                patch_cooldowntimer = !_stricmp(inifile_cleanstr(value), "true");
381 >                        else if (!_stricmp(name, "throwtest"))
382 >                                patch_throwtest = !_stricmp(inifile_cleanstr(value), "true");
383 >                        else if (!_stricmp(name, "alttab"))
384 >                                patch_alttab = !_stricmp(inifile_cleanstr(value), "true");
385 >                        else if (!_stricmp(name, "particledisablebit"))
386 >                                patch_particledisablebit = !_stricmp(inifile_cleanstr(value), "true");
387 >                        else if (!_stricmp(name, "multibyte"))
388 >                                patch_multibyte = !_stricmp(inifile_cleanstr(value), "true");
389 >                        else if (!_stricmp(name, "cheattable"))
390 >                                patch_cheattable = !_stricmp(inifile_cleanstr(value), "true");
391 >                        else if (!_stricmp(name, "argb8888"))
392 >                                patch_argb8888 = !_stricmp(inifile_cleanstr(value), "true");
393 >                        else if (!_stricmp(name, "killvtune"))
394 >                                patch_killvtune = !_stricmp(inifile_cleanstr(value), "true");
395 >                        else if (!_stricmp(name, "getcmdline"))
396 >                                patch_getcmdline = !_stricmp(inifile_cleanstr(value), "true");
397 >                        else if (!_stricmp(name, "disablecmdline"))
398 >                                patch_disablecmdline = !_stricmp(inifile_cleanstr(value), "true");
399 >                        else if (!_stricmp(name, "safeprintf"))
400 >                                patch_safeprintf = !_stricmp(inifile_cleanstr(value), "true");
401 >                        else if (!_stricmp(name, "daodandisplayenum"))
402 >                                patch_daodandisplayenum = !_stricmp(inifile_cleanstr(value), "true");
403 >                        else if (!_stricmp(name, "usegettickcount"))
404 >                                patch_usegettickcount = !_stricmp(inifile_cleanstr(value), "true");
405 >                        else if (!_stricmp(name, "cheatsenabled"))
406 >                                patch_cheatsenabled = !_stricmp(inifile_cleanstr(value), "true");
407 >                        else if (!_stricmp(name, "usedaodangl"))
408 >                                patch_usedaodangl = !_stricmp(inifile_cleanstr(value), "true");
409 >                        else if (!_stricmp(name, "windowhack"))
410 >                                patch_windowhack = !_stricmp(inifile_cleanstr(value), "true");
411 >                        else if (!_stricmp(name, "daodaninit"))
412 >                                patch_daodaninit = !_stricmp(inifile_cleanstr(value), "true");
413 >                        else if (!_stricmp(name, "bsl"))
414 >                                patch_bsl = !_stricmp(inifile_cleanstr(value), "true");
415 >                        else if (!_stricmp(name, "cheater"))
416 >                                patch_cheater = !_stricmp(inifile_cleanstr(value), "true");
417 >                        else if (!_stricmp(name, "newweap"))
418 >                                patch_newweapon = !_stricmp(inifile_cleanstr(value), "true");
419 >                        else if (!_stricmp(name, "optionsvisible"))
420 >                                patch_optionsvisible = !_stricmp(inifile_cleanstr(value), "true");
421                          else
422                                  DDrStartupMessage("unrecognised patch \"%s\"", name);
423                          break;
424                  case s_language:
425 <                        if (!stricmp(name, "savepoint"))
425 >                        if (!_stricmp(name, "chinese"))
426 >                                patch_chinese = true;
427 >                        else if (!_stricmp(name, "savepoint"))
428                          {
429 <                                char* str = strdup(value);
430 <                                DDrPatch_Int32(OniExe + 0x000fd730, (int)str);
431 <                                DDrPatch_Int32(OniExe + 0x000fd738, (int)str);
429 >                                char* str = _strdup(value);
430 >                                DDrPatch_Int32((int*)(OniExe + 0x000fd730), (int)str);
431 >                                DDrPatch_Int32((int*)(OniExe + 0x000fd738), (int)str);
432                          }
433 <                        else if (!stricmp(name, "syndicatewarehouse"))
433 >                        else if (!_stricmp(name, "syndicatewarehouse"))
434                          {
435 <                                char* str = strdup(value);
436 <                                DDrPatch_Int32(OniExe + 0x000fd71a, (int)str);
437 <                                DDrPatch_Int32(OniExe + 0x0010ef75, (int)str);
435 >                                char* str = _strdup(value);
436 >                                DDrPatch_Int32((int*)(OniExe + 0x000fd71a), (int)str);
437 >                                DDrPatch_Int32((int*)(OniExe + 0x0010ef75), (int)str);
438                          }
439 <                        else if (!stricmp(name, "damn"))
440 <                                DDrPatch_StrDup(OniExe + 0x0010fb6e, value);
441 <                        else if (!stricmp(name, "blam"))
442 <                                DDrPatch_StrDup(OniExe + 0x0010fb73, value);
443 <                        else if (!stricmp(name, "shapeshifter_on"))
444 <                                DDr_CheatTable[0].message_on = strdup(value);
445 <                        else if (!stricmp(name, "shapeshifter_off"))
446 <                                DDr_CheatTable[0].message_off = strdup(value);
447 <                        else if (!stricmp(name, "liveforever_on"))
448 <                                DDr_CheatTable[1].message_on = strdup(value);
449 <                        else if (!stricmp(name, "liveforever_off"))
450 <                                DDr_CheatTable[1].message_off = strdup(value);
451 <                        else if (!stricmp(name, "touchofdeath_on"))
452 <                                DDr_CheatTable[2].message_on = strdup(value);
453 <                        else if (!stricmp(name, "touchofdeath_off"))
454 <                                DDr_CheatTable[2].message_off = strdup(value);
455 <                        else if (!stricmp(name, "canttouchthis_on"))
456 <                                DDr_CheatTable[3].message_on = strdup(value);
457 <                        else if (!stricmp(name, "canttouchthis_off"))
458 <                                DDr_CheatTable[3].message_off = strdup(value);
459 <                        else if (!stricmp(name, "fatloot_on"))
460 <                                DDr_CheatTable[4].message_on = strdup(value);
461 <                        else if (!stricmp(name, "glassworld_on"))
462 <                                DDr_CheatTable[5].message_on = strdup(value);
463 <                        else if (!stricmp(name, "glassworld_off"))
464 <                                DDr_CheatTable[5].message_off = strdup(value);
465 <                        else if (!stricmp(name, "winlevel_on"))
466 <                                DDr_CheatTable[6].message_on = strdup(value);
467 <                        else if (!stricmp(name, "loselevel_on"))
468 <                                DDr_CheatTable[7].message_on = strdup(value);
469 <                        else if (!stricmp(name, "bighead_on"))
470 <                                DDr_CheatTable[8].message_on = strdup(value);
471 <                        else if (!stricmp(name, "bighead_off"))
472 <                                DDr_CheatTable[8].message_off = strdup(value);
473 <                        else if (!stricmp(name, "minime_on"))
474 <                                DDr_CheatTable[9].message_on = strdup(value);
475 <                        else if (!stricmp(name, "minime_off"))
476 <                                DDr_CheatTable[9].message_off = strdup(value);
477 <                        else if (!stricmp(name, "superammo_on"))
478 <                                DDr_CheatTable[10].message_on = strdup(value);
479 <                        else if (!stricmp(name, "superammo_off"))
480 <                                DDr_CheatTable[10].message_off = strdup(value);
481 <                        else if (!stricmp(name, "devmode_on"))
439 >                        else if (!_stricmp(name, "damn"))
440 >                                DDrPatch__strdup((int*)(OniExe + 0x0010fb6e), value);
441 >                        else if (!_stricmp(name, "blam"))
442 >                                DDrPatch__strdup((int*)(OniExe + 0x0010fb73), value);
443 >                        else if (!_stricmp(name, "shapeshifter_on"))
444 >                                DDr_CheatTable[0].message_on = _strdup(value);
445 >                        else if (!_stricmp(name, "shapeshifter_off"))
446 >                                DDr_CheatTable[0].message_off = _strdup(value);
447 >                        else if (!_stricmp(name, "liveforever_on"))
448 >                                DDr_CheatTable[1].message_on = _strdup(value);
449 >                        else if (!_stricmp(name, "liveforever_off"))
450 >                                DDr_CheatTable[1].message_off = _strdup(value);
451 >                        else if (!_stricmp(name, "touchofdeath_on"))
452 >                                DDr_CheatTable[2].message_on = _strdup(value);
453 >                        else if (!_stricmp(name, "touchofdeath_off"))
454 >                                DDr_CheatTable[2].message_off = _strdup(value);
455 >                        else if (!_stricmp(name, "canttouchthis_on"))
456 >                                DDr_CheatTable[3].message_on = _strdup(value);
457 >                        else if (!_stricmp(name, "canttouchthis_off"))
458 >                                DDr_CheatTable[3].message_off = _strdup(value);
459 >                        else if (!_stricmp(name, "fatloot_on"))
460 >                                DDr_CheatTable[4].message_on = _strdup(value);
461 >                        else if (!_stricmp(name, "glassworld_on"))
462 >                                DDr_CheatTable[5].message_on = _strdup(value);
463 >                        else if (!_stricmp(name, "glassworld_off"))
464 >                                DDr_CheatTable[5].message_off = _strdup(value);
465 >                        else if (!_stricmp(name, "winlevel_on"))
466 >                                DDr_CheatTable[6].message_on = _strdup(value);
467 >                        else if (!_stricmp(name, "loselevel_on"))
468 >                                DDr_CheatTable[7].message_on = _strdup(value);
469 >                        else if (!_stricmp(name, "bighead_on"))
470 >                                DDr_CheatTable[8].message_on = _strdup(value);
471 >                        else if (!_stricmp(name, "bighead_off"))
472 >                                DDr_CheatTable[8].message_off = _strdup(value);
473 >                        else if (!_stricmp(name, "minime_on"))
474 >                                DDr_CheatTable[9].message_on = _strdup(value);
475 >                        else if (!_stricmp(name, "minime_off"))
476 >                                DDr_CheatTable[9].message_off = _strdup(value);
477 >                        else if (!_stricmp(name, "superammo_on"))
478 >                                DDr_CheatTable[10].message_on = _strdup(value);
479 >                        else if (!_stricmp(name, "superammo_off"))
480 >                                DDr_CheatTable[10].message_off = _strdup(value);
481 >                        else if (!_stricmp(name, "devmode_on"))
482                          {
483 <                                char* str = strdup(value);
483 >                                char* str = _strdup(value);
484                                  DDr_CheatTable[11].message_on = str;
485 <                                DDr_CheatTable[cheat_devmodex].message_on = str;
485 >                                DDr_CheatTable[cheat_x].message_on = str;
486                          }
487 <                        else if (!stricmp(name, "devmode_off"))
487 >                        else if (!_stricmp(name, "devmode_off"))
488                          {
489 <                                char* str = strdup(value);
489 >                                char* str = _strdup(value);
490                                  DDr_CheatTable[11].message_off = str;
491 <                                DDr_CheatTable[cheat_devmodex].message_off = str;
491 >                                DDr_CheatTable[cheat_x].message_off = str;
492                          }
493 <                        else if (!stricmp(name, "reservoirdogs_on"))
494 <                                DDr_CheatTable[12].message_on = strdup(value);
495 <                        else if (!stricmp(name, "reservoirdogs_off"))
496 <                                DDr_CheatTable[12].message_off = strdup(value);
497 <                        else if (!stricmp(name, "roughjustice_on"))
498 <                                DDr_CheatTable[13].message_on = strdup(value);
499 <                        else if (!stricmp(name, "roughjustice_off"))
500 <                                DDr_CheatTable[13].message_off = strdup(value);
501 <                        else if (!stricmp(name, "chenille_on"))
502 <                                DDr_CheatTable[14].message_on = strdup(value);
503 <                        else if (!stricmp(name, "chenille_off"))
504 <                                DDr_CheatTable[14].message_off = strdup(value);
505 <                        else if (!stricmp(name, "behemoth_on"))
506 <                                DDr_CheatTable[15].message_on = strdup(value);
507 <                        else if (!stricmp(name, "behemoth_off"))
508 <                                DDr_CheatTable[15].message_off = strdup(value);
509 <                        else if (!stricmp(name, "elderrune_on"))
510 <                                DDr_CheatTable[16].message_on = strdup(value);
511 <                        else if (!stricmp(name, "elderrune_off"))
512 <                                DDr_CheatTable[16].message_off = strdup(value);
513 <                        else if (!stricmp(name, "moonshadow_on"))
514 <                                DDr_CheatTable[17].message_on = strdup(value);
515 <                        else if (!stricmp(name, "moonshadow_off"))
516 <                                DDr_CheatTable[17].message_off = strdup(value);
517 <                        else if (!stricmp(name, "munitionfrenzy_on"))
518 <                                DDr_CheatTable[18].message_on = strdup(value);
519 <                        else if (!stricmp(name, "fistsoflegend_on"))
520 <                                DDr_CheatTable[19].message_on = strdup(value);
521 <                        else if (!stricmp(name, "fistsoflegend_off"))
522 <                                DDr_CheatTable[19].message_off = strdup(value);
523 <                        else if (!stricmp(name, "killmequick_on"))
524 <                                DDr_CheatTable[20].message_on = strdup(value);
525 <                        else if (!stricmp(name, "killmequick_off"))
526 <                                DDr_CheatTable[20].message_off = strdup(value);
527 <                        else if (!stricmp(name, "carousel_on"))
528 <                                DDr_CheatTable[21].message_on = strdup(value);
529 <                        else if (!stricmp(name, "carousel_off"))
530 <                                DDr_CheatTable[21].message_off = strdup(value);
493 >                        else if (!_stricmp(name, "reservoirdogs_on"))
494 >                                DDr_CheatTable[12].message_on = _strdup(value);
495 >                        else if (!_stricmp(name, "reservoirdogs_off"))
496 >                                DDr_CheatTable[12].message_off = _strdup(value);
497 >                        else if (!_stricmp(name, "roughjustice_on"))
498 >                                DDr_CheatTable[13].message_on = _strdup(value);
499 >                        else if (!_stricmp(name, "roughjustice_off"))
500 >                                DDr_CheatTable[13].message_off = _strdup(value);
501 >                        else if (!_stricmp(name, "chenille_on"))
502 >                                DDr_CheatTable[14].message_on = _strdup(value);
503 >                        else if (!_stricmp(name, "chenille_off"))
504 >                                DDr_CheatTable[14].message_off = _strdup(value);
505 >                        else if (!_stricmp(name, "behemoth_on"))
506 >                                DDr_CheatTable[15].message_on = _strdup(value);
507 >                        else if (!_stricmp(name, "behemoth_off"))
508 >                                DDr_CheatTable[15].message_off = _strdup(value);
509 >                        else if (!_stricmp(name, "elderrune_on"))
510 >                                DDr_CheatTable[16].message_on = _strdup(value);
511 >                        else if (!_stricmp(name, "elderrune_off"))
512 >                                DDr_CheatTable[16].message_off = _strdup(value);
513 >                        else if (!_stricmp(name, "moonshadow_on"))
514 >                                DDr_CheatTable[17].message_on = _strdup(value);
515 >                        else if (!_stricmp(name, "moonshadow_off"))
516 >                                DDr_CheatTable[17].message_off = _strdup(value);
517 >                        else if (!_stricmp(name, "munitionfrenzy_on"))
518 >                                DDr_CheatTable[18].message_on = _strdup(value);
519 >                        else if (!_stricmp(name, "fistsoflegend_on"))
520 >                                DDr_CheatTable[19].message_on = _strdup(value);
521 >                        else if (!_stricmp(name, "fistsoflegend_off"))
522 >                                DDr_CheatTable[19].message_off = _strdup(value);
523 >                        else if (!_stricmp(name, "killmequick_on"))
524 >                                DDr_CheatTable[20].message_on = _strdup(value);
525 >                        else if (!_stricmp(name, "killmequick_off"))
526 >                                DDr_CheatTable[20].message_off = _strdup(value);
527 >                        else if (!_stricmp(name, "carousel_on"))
528 >                                DDr_CheatTable[21].message_on = _strdup(value);
529 >                        else if (!_stricmp(name, "carousel_off"))
530 >                                DDr_CheatTable[21].message_off = _strdup(value);
531                          else
532                                  DDrStartupMessage("unrecognised language item \"%s\"", name);
533                          break;
534 +                case s_bsl:
535                  default:
536                          break;
537          }
# Line 337 | Line 541 | bool DDrIniCallback(char* section, bool
541  
542   void DDrConfig()
543   {
544 +
545          if (GetFileAttributes("daodan.ini") == INVALID_FILE_ATTRIBUTES)
546          {
547 +                FILE* fp;
548                  DDrStartupMessage("daodan.ini doesn't exist, creating");
549 <                FILE* fp = fopen("daodan.ini", "w");
549 >                fp = fopen("daodan.ini", "w");
550                  if (fp)
551                  {
552                          fputs("[Options]\n", fp);
# Line 354 | Line 560 | void DDrConfig()
560          DDrStartupMessage("finished parsing");
561   }
562  
563 + void ONICALL DDrGame_Init()
564 + {
565 +        if (opt_usedaodanbsl)
566 +                SLrDaodan_Initalize();
567 + }
568 +
569 + void DDrException() {
570 +        int* i = 0;
571 +        *i = 1;
572 + }
573 + #include <stdio.h>
574 +
575 + //this was broken
576 + FILE** _UUgError_WarningFile = (FILE**)0x005711B4;
577 + FILE *__fastcall DDrPrintWarning(int filename, int linenumber, unsigned __int16 errornum, int message)
578 + {
579 +
580 +        FILE *v4; // eax@1
581 +        FILE *result; // eax@4
582 +        char v6[512]; // [sp+0h] [bp-100h]@1
583 +        FILE* UUgError_WarningFile = *_UUgError_WarningFile;
584 +
585 +        if (filename && message && (strlen((const char*)filename)+strlen((const char*)message))<420) {
586 +                sprintf(
587 +                        v6,
588 +                        "Error %x reported from File: %s, Line: %d (message follows) \r\n%s",
589 +                        errornum,
590 +                        (const char*)filename,
591 +                        linenumber,
592 +                        (const char*)message);
593 +
594 +                if ( UUgError_WarningFile
595 +                        || (UUgError_WarningFile = oni_fopen("debugger.txt", "wb"), UUgError_WarningFile ) )
596 +                {
597 +                        oni_fprintf(UUgError_WarningFile, "%s\r\n", v6);
598 +                        oni_fflush(UUgError_WarningFile);
599 +                }
600 +        }
601 +        //oni_fprintf(stdout, v6);
602 +        //sprintf(&v6, "%s", message);
603 +        *_UUgError_WarningFile = UUgError_WarningFile;
604 +        result = UUgError_WarningFile;
605 +        return result;
606 + }
607 +
608   void __cdecl DDrMain(int argc, char* argv[])
609   {
610 +        int i;
611 +        char* section;
612 +        char* option;
613 +        bool falseoption;
614 +
615          DDrStartupMessage("daodan attached!");
616 +        
617 +        // Tell Oni to not load non levelX_final-files by default:
618 +        opt_ignore_private_data = false;
619 +
620 +        // Enable sound by default:
621 +        opt_sound = true;
622 +        
623          DDrConfig();
624 +        DDrStartupMessage("parsing command line...");
625 +        for (i = 1; i < argc; i ++)
626 +        {
627 +                if (argv[i][0] == '-')
628 +                {
629 +                        section = argv[i] + 1;
630 +                        if ((option = strchr(argv[i], '.')))
631 +                        {
632 +                                *option = '\0';
633 +                                falseoption = (option[1] == 'n' || option[1] == 'N') && (option[2] = 'o' || option[2] == 'O');
634 +                                if (i < (argc - 1) && argv[i + 1][0] != '-')
635 +                                        DDrIniCallback(section, true, option + 1, argv[++i]);
636 +                                else
637 +                                        DDrIniCallback(section, true, option + (falseoption ? 3 : 1), (falseoption ? "false" : "true"));
638 +                                *option = '.';
639 +                        }
640 +                        else
641 +                        {
642 +                                falseoption = (section[0] == 'n' || section[0] == 'N') && (section[1] = 'o' || section[1] == 'O');
643 +                                ini_section = s_options;
644 +                                if (i < (argc - 1) && argv[i + 1][0] != '-')
645 +                                        DDrIniCallback(NULL, false, section, argv[++i]);
646 +                                else
647 +                                        DDrIniCallback(NULL, false, section + (falseoption ? 2 : 0), (falseoption ? "false" : "true"));
648 +                        }
649 +                }
650 +                else
651 +                {
652 +                        DDrStartupMessage("parse error \"%s\"", argv[i]);
653 +                        break;
654 +                }
655 +        }
656 +        DDrStartupMessage("finished parsing");
657          DDrPatch_Init();
658          
659          // Safe startup message printer
660          if (patch_safeprintf)
661 <                DDrPatch_MakeJump(UUrStartupMessage, DDrStartupMessage);
661 >                DDrPatch_MakeJump((void*)UUrStartupMessage, (void*)DDrStartupMessage);
662          
663          // Daodan device mode enumeration function
664          if (patch_daodandisplayenum)
665 <                DDrPatch_MakeJump(gl_enumerate_valid_display_modes, daodan_enumerate_valid_display_modes);
665 >                DDrPatch_MakeJump((void*)gl_enumerate_valid_display_modes, (void*)daodan_enumerate_valid_display_modes);
666          
667          // Performance patch
668          if (patch_usegettickcount)
669          {
670 <                DDrPatch_MakeJump(UUrMachineTime_High, DDrMachineTime_High);
671 <                DDrPatch_MakeJump(UUrMachineTime_High_Frequency, DDrMachineTime_High_Frequency);
672 <                DDrPatch_MakeJump(UUrMachineTime_Sixtieths, DDrMachineTime_Sixtieths);
670 >                DDrPatch_MakeJump((void*)UUrMachineTime_High, (void*)DDrMachineTime_High);
671 >                DDrPatch_MakeJump((void*)UUrMachineTime_High_Frequency, (void*)DDrMachineTime_High_Frequency);
672 >                DDrPatch_MakeJump((void*)UUrMachineTime_Sixtieths, (void*)DDrMachineTime_Sixtieths);
673          }
674 <        
674 >
675          // Cheats always enabled
676          if (patch_cheatsenabled)
677 <                DDrPatch_MakeJump(ONrPersist_GetWonGame, DDrPersist_GetWonGame);
678 <        
677 >                DDrPatch_MakeJump((void*)ONrPersist_GetWonGame, (void*)DDrPersist_GetWonGame);
678 >
679          // Windowed mode
680          if (patch_usedaodangl)
681          {
682 <                DDrPatch_MakeJump(ONrPlatform_Initialize, DDrPlatform_Initialize);
683 <                DDrPatch_MakeJump(gl_platform_initialize, daodangl_platform_initialize);
388 <        }
682 >                DDrPatch_NOOP((char*)(OniExe + 0x000032B7), 6);
683 >                DDrPatch_MakeCall((void*)(OniExe + 0x000032B7), (void*)LIiP_SetCursorPosHook);
684          
685 +                DDrPatch_NOOP((char*)(OniExe + 0x00003349), 6);
686 +                DDrPatch_MakeCall((void*)(OniExe + 0x00003349), (void*)LIiP_SetCursorPosHook);
687 +                DDrPatch_MakeJump((void*)ONrPlatform_Initialize, (void*)DDrPlatform_Initialize);
688 +                DDrPatch_MakeJump((void*)gl_platform_initialize, (void*)daodangl_platform_initialize);
689 +        }
690          // Hacked windowed mode (for when daodangl isn't working properly)
691 <        if (patch_windowhack)
691 >        else if (patch_windowhack)
692                  DDrWindowHack_Install();
693          
694 <        init_daodan_gl();
694 >        if (patch_daodaninit)
695 >                DDrPatch_MakeCall((void*)(OniExe + 0x000d345a), (void*)DDrGame_Init);
696          
697 <        ONiMain(argc, argv);
698 < }
697 >        // Patches for existing BSL functions
698 >        if (patch_bsl)
699 >                SLrDaodan_Patch();
700 >                
701 >        if (patch_cheater)
702 >        {
703 >                DDrPatch_MakeCall((void*)(OniExe + 0x000f618f), (void*)DDrCheater);
704 >                DDrPatch_Int16((short*)(OniExe + 0x000deb45), 0x5590);
705 > #if 1
706 >                DDrPatch_MakeCall((void*)(OniExe + 0x000deb47), (void*)FallingFrames);
707 > #endif
708 >                DDrPatch_MakeJump((void*)(OniExe + 0x0010f021), (void*)DDrCheater_LevelLoad);
709 >        }
710  
711 +        DDrPatch_MakeJump((void*)(OniExe + 0x000245A0), (void*)DDrPrintWarning);
712 +        
713 +        ONiMain(argc, argv);
714 + }
715 + /*
716 + void DDrWrongExe()
717 + {
718 +        switch (MessageBox(NULL, "This version of the Daodan DLL is incompatible with your Oni.exe.\n"
719 +                "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))
720 +        {
721 +                case IDOK:
722 +                        {
723 +                                STARTUPINFO si;
724 +                                PROCESS_INFORMATION pi;
725 +                                FillMemory(&si, 0, sizeof(si));
726 +                                FillMemory(&pi, 0, sizeof(pi));
727 +                                si.cb = sizeof(si);
728 +                                if (!CreateProcess(NULL, "cmd /c \"start http://wiki.oni2.net/Daodan_DLL\"", NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
729 +                                        MessageBox(NULL, "", "", 0);
730 +                                CloseHandle(pi.hProcess);
731 +                                CloseHandle(pi.hThread);
732 +                        }
733 +                default:
734 +                        ExitProcess(0);
735 +        }
736 + }
737 + */
738   BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved)
739   {
740          switch (fdwReason)
# Line 404 | Line 743 | BOOL WINAPI DllMain(HINSTANCE hinstDLL,
743                          DDrDLLModule = hinstDLL;
744                          DDrONiModule = GetModuleHandle(NULL);
745                          
746 <                        DDrPatch_MakeCall(OniExe + 0x0010fb49, DDrMain);
747 <                        
746 >                        if (*(uint32_t*)(OniExe + 0x0011acd0) == 0x09d36852)
747 >                                DDrPatch_MakeCall((void*)(OniExe + 0x0010fb49), (void*)DDrMain);
748 >                        else
749 >                                ExitProcess(0);
750                          break;
751          }
752          return TRUE;

Diff Legend

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