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 677 by alloc, Sat Mar 2 23:46:33 2013 UTC vs.
Revision 694 by alloc, Fri Mar 8 00:31:30 2013 UTC

# Line 1 | Line 1
1 + #include <windows.h>
2   #include <string.h>
3  
4   #include "Daodan.h"
# Line 11 | Line 12
12   #include "Daodan_WindowHack.h"
13  
14   #include "Oni.h"
14 #include "Oni_Persistence.h"
15  
16 < #include "BFW_Utility.h"
16 > #include "Oni_GL.h"
17 > #include "Daodan_GL.h"
18  
19 < #include "oni_gl.h"
19 < #include "daodan_gl.h"
20 <
21 < #include "inifile.h"
19 > #include "Inifile_Reader.h"
20  
21   HMODULE DDrDLLModule;
22   HMODULE DDrONiModule;
# Line 41 | Line 39 | 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 54 | Line 53 | bool patch_cheater = true;
53   bool patch_newweapon = true;
54   bool opt_usedaodanbsl = true;
55   bool opt_border = true;
57 bool opt_shadow = false;
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   {
81          DDrStartupMessage("patching engine");
# Line 66 | 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 <                const char pathfinding[2] = {0x90 , 0xE9 };
102 <                DDrPatch_Byte  (OniExe + 0x0010b03b, 0x20);
103 <                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(0x440789, pathfinding);
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);
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
# Line 123 | Line 140 | bool DDrPatch_Init()
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)
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 (0x004f616b, (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  (OniExe + 0x00135af0, 0x07);
204 <                DDrPatch_Byte  (OniExe + 0x00135af4, 0x0B);
203 >                DDrPatch_Byte  ((char*)(OniExe + 0x00135af0), 0x07);
204 >                DDrPatch_Byte  ((char*)(OniExe + 0x00135af4), 0x0B);
205          }
206  
207          //Test newweap patch
# Line 191 | Line 209 | bool DDrPatch_Init()
209                  
210                  //Makes it always say "Recieved weapon_name."
211                  //Needs check for loc_4DFC66
212 <                //DDrPatch_NOOP( OniExe + 0x000E4DF8,2);
212 >                //DDrPatch_NOOP((char*)(OniExe + 0x000E4DF8),2);
213  
214                  //Adds Weapon name and ammo meter to pickup autoprompt
215 <                DDrPatch_NOOP( OniExe + 0x000FAC73, 9);
216 <                DDrPatch_NOOP( OniExe + 0x000FAC80, 5);
217 <                DDrPatch_MakeCall( OniExe + 0xFAC85, DDrWeapon2Message);
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( 0x0042E3D5, (int)&DDrDSayColors );
221 <                //DDrPatch_Int32( 0x0042E3DA, (int)&DDrDSayColors );
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  (OniExe + 0x00026340, 0xC3);
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  (OniExe + 0x000d3280, 51);
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 (OniExe + 0x000d3570, 0xc3c03366);
234 >                DDrPatch_Int32 ((int*)(OniExe + 0x000d3570), 0xc3c03366);
235          
236          if (patch_bsl)
237          {
# Line 222 | Line 240 | bool DDrPatch_Init()
240                  //TODO: fix moonshadow.
241                  Character * Chr = 0;
242                  int NoPath = (int)&(Chr[0].RegenHax) & 0x000000FF;
243 <                const char regen_patch[] =
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
# Line 231 | Line 249 | bool DDrPatch_Init()
249                  0x85, 0xC0,                                                                     // test eax, eax
250                  0x74, 0x21                                                                      // jnz 0x21 -> jz 0x21
251                  };      
252 <                DDrPatch_Const(0x0051BB64, regen_patch);
252 >                DDrPatch_Const((char*)(OniExe + 0x0011BB64), regen_patch);
253          }
254          
255          if(patch_chinese)
256          {
257 +                DDrStartupMessage("Loading chinese DLL");
258                  HMODULE dll = LoadLibrary("xfhsm_oni.dll");
259 +                DWORD err = GetLastError();
260 +                DDrStartupMessage(" - Module loading returned error %i", err);
261                  if( dll )
262                  {
263                          void* proc = GetProcAddress( dll, "InstallHook" );
# Line 251 | Line 272 | bool DDrPatch_Init()
272          if(1)
273          {
274                  //Set distance above head to 4.0
275 <                DDrPatch_Int32(0x0048C998, 0x005296C8);
275 >                DDrPatch_Int32((int*)(OniExe + 0x0008C998), 0x005296C8);
276                  //texture height
277 <                DDrPatch_Byte( 0x0048C9DF, 0x3F );
277 >                DDrPatch_Byte((char*)(OniExe + 0x0008C9DF), 0x3F );
278                  //texture       width
279 <                DDrPatch_NOOP( (char*)0x0048C9CA, 6 );
279 >                DDrPatch_NOOP((char*)(OniExe + 0x0008C9CA), 6 );
280                  //Set the text color to whatever we like ;)
281 <                DDrPatch_NOOP( 0x0048C898, 6 );
282 <                DDrPatch_Byte( 0x0048C898, 0x8B );
283 <                DDrPatch_Byte( 0x0048C899, 0xCE );
284 < //FLATLINE?             DDrPatch_MakeCall( 0x0048C8A3, FLrHook_DebugNameShadeHack);
281 >                DDrPatch_NOOP((char*)(OniExe + 0x0008C898), 6 );
282 >                DDrPatch_Byte((char*)(OniExe + 0x0008C898), 0x8B );
283 >                DDrPatch_Byte((char*)(OniExe + 0x0008C899), 0xCE );
284 > //FLATLINE?             DDrPatch_MakeCall((void*)(OniExe + 0x0008C8A3), FLrHook_DebugNameShadeHack);
285                  
286                  //Make the background black for additive blending
287 < //FLATLINE?             DDrPatch_MakeCall( 0x0048C802, FLrHook_DebugNameTextureInit );
287 > //FLATLINE?             DDrPatch_MakeCall((void*)(OniExe + 0x0008C802), FLrHook_DebugNameTextureInit );
288          }
289  
290          if(1)
291          {
292 <                //DDrPatch_NOOP( 0x004E1957, 6 );
293 <                //DDrPatch_MakeCall( 0x004E17F6, FLrHook_Lasers );
292 >                //DDrPatch_NOOP((char*)(OniExe + 0x000E1957), 6 );
293 >                //DDrPatch_MakeCall((void*)(OniExe + 0x000E17F6), FLrHook_Lasers );
294          }
295  
296          //Flatline related stuff
297 < //      DDrPatch_MakeCall(0x004FBCEA, DDrText_Hook);
297 > //      DDrPatch_MakeCall((void*)(OniExe + 0x000FBCEA), DDrText_Hook);
298          
299 < //FLATLINE?     DDrPatch_Int32( 0x004B24D2, FLrSpawnHack);
299 > //FLATLINE?     DDrPatch_Int32((int*)(OniExe + 0x000B24D2), FLrSpawnHack);
300 >
301 > //FLATLINE?     DDrPatch_NOOP((char*)(OniExe + 0x000C26CB), 6);
302  
303 < //FLATLINE?     DDrPatch_NOOP(0x004C26CB, 6);
303 > //FLATLINE?     DDrPatch_MakeCall((void*)(OniExe + 0x000C26CB), FLrHook_DoorOpen);
304 > //FLATLINE?     DDrPatch_MakeCall((void*)(OniExe + 0x000EE3CF), FLrHook_ConsoleActivate);
305 >
306 >
307 >        // Fix options not visible in main menu when a game was started
308 >        if(patch_optionsvisible)
309 >        {
310 >                DDrPatch_MakeCall((void*)(OniExe + 0x000d2d2d), DDrShowOptionsButton);
311 >                DDrPatch_MakeCall((void*)(OniExe + 0x000d2d43), DDrShowResumeButton);
312 >        }
313  
282 //FLATLINE?     DDrPatch_MakeCall( 0x004C26CB, FLrHook_DoorOpen);
283 //FLATLINE?     DDrPatch_MakeCall( 0x004EE3CF, FLrHook_ConsoleActivate);
314          return true;
315   }
316  
317 +
318   enum {s_unknown, s_options, s_patch, s_bsl, s_language} ini_section;
319  
320   bool DDrIniCallback(char* section, bool newsection, char* name, char* value)
# Line 312 | Line 343 | bool DDrIniCallback(char* section, bool
343                                  opt_usedaodanbsl = !_stricmp(inifile_cleanstr(value), "true");
344                          else if (!_stricmp(name, "border"))
345                                  opt_border = !_stricmp(inifile_cleanstr(value), "true");
315                        else if (!_stricmp(name, "shadow"))
316                                opt_shadow = !_stricmp(inifile_cleanstr(value), "true");
346                          else if (!_stricmp(name, "topmost"))
347                                  opt_topmost = !_stricmp(inifile_cleanstr(value), "true");
348                          else if (!_stricmp(name, "multibyte"))
# Line 330 | Line 359 | bool DDrIniCallback(char* section, bool
359                                  opt_sound = !_stricmp(inifile_cleanstr(value), "true");
360                          else if (!_stricmp(name, "switch"))
361                                  M3gResolutionSwitch = !_stricmp(inifile_cleanstr(value), "true");
333                        //else if (!_stricmp(name, "devmode"))
334                                //turn_dev_mode_on = !_stricmp(inifile_cleanstr(value), "true");
362                          else
363                                  DDrStartupMessage("unrecognised option \"%s\"", name);
364                          break;
# Line 392 | Line 419 | bool DDrIniCallback(char* section, bool
419                                  patch_cheater = !_stricmp(inifile_cleanstr(value), "true");
420                          else if (!_stricmp(name, "newweap"))
421                                  patch_newweapon = !_stricmp(inifile_cleanstr(value), "true");
422 +                        else if (!_stricmp(name, "optionsvisible"))
423 +                                patch_optionsvisible = !_stricmp(inifile_cleanstr(value), "true");
424                          else
425                                  DDrStartupMessage("unrecognised patch \"%s\"", name);
426                          break;
# Line 401 | Line 430 | bool DDrIniCallback(char* section, bool
430                          else if (!_stricmp(name, "savepoint"))
431                          {
432                                  char* str = _strdup(value);
433 <                                DDrPatch_Int32(OniExe + 0x000fd730, (int)str);
434 <                                DDrPatch_Int32(OniExe + 0x000fd738, (int)str);
433 >                                DDrPatch_Int32((int*)(OniExe + 0x000fd730), (int)str);
434 >                                DDrPatch_Int32((int*)(OniExe + 0x000fd738), (int)str);
435                          }
436                          else if (!_stricmp(name, "syndicatewarehouse"))
437                          {
438                                  char* str = _strdup(value);
439 <                                DDrPatch_Int32(OniExe + 0x000fd71a, (int)str);
440 <                                DDrPatch_Int32(OniExe + 0x0010ef75, (int)str);
439 >                                DDrPatch_Int32((int*)(OniExe + 0x000fd71a), (int)str);
440 >                                DDrPatch_Int32((int*)(OniExe + 0x0010ef75), (int)str);
441                          }
442                          else if (!_stricmp(name, "damn"))
443 <                                DDrPatch__strdup(OniExe + 0x0010fb6e, value);
443 >                                DDrPatch__strdup((int*)(OniExe + 0x0010fb6e), value);
444                          else if (!_stricmp(name, "blam"))
445 <                                DDrPatch__strdup(OniExe + 0x0010fb73, value);
445 >                                DDrPatch__strdup((int*)(OniExe + 0x0010fb73), value);
446                          else if (!_stricmp(name, "shapeshifter_on"))
447                                  DDr_CheatTable[0].message_on = _strdup(value);
448                          else if (!_stricmp(name, "shapeshifter_off"))
# Line 555 | Line 584 | FILE *__fastcall DDrPrintWarning(int fil
584          FILE *result; // eax@4
585          char v6[512]; // [sp+0h] [bp-100h]@1
586          FILE* UUgError_WarningFile = *_UUgError_WarningFile;
587 <        sprintf_s(
588 <                v6, 512,
589 <                "Error %x reported from File: %s, Line: %d (message follows) \r\n%s",
590 <                errornum,
591 <                filename,
592 <                linenumber,
593 <                message);
594 <
595 <        if ( UUgError_WarningFile
596 <                || (UUgError_WarningFile = oni_fopen("debugger.txt", "wb"), UUgError_WarningFile ) )
597 <        {
598 <                oni_fprintf(UUgError_WarningFile, "%s\r\n", v6);
599 <                oni_fflush(UUgError_WarningFile);
587 >
588 >        if (filename && message && (strlen((const char*)filename)+strlen((const char*)message))<420) {
589 >                sprintf(
590 >                        v6,
591 >                        "Error %x reported from File: %s, Line: %d (message follows) \r\n%s",
592 >                        errornum,
593 >                        (const char*)filename,
594 >                        linenumber,
595 >                        (const char*)message);
596 >
597 >                if ( UUgError_WarningFile
598 >                        || (UUgError_WarningFile = oni_fopen("debugger.txt", "wb"), UUgError_WarningFile ) )
599 >                {
600 >                        oni_fprintf(UUgError_WarningFile, "%s\r\n", v6);
601 >                        oni_fflush(UUgError_WarningFile);
602 >                }
603          }
604          //oni_fprintf(stdout, v6);
605          //sprintf(&v6, "%s", message);
# Line 585 | Line 617 | void __cdecl DDrMain(int argc, char* arg
617  
618          DDrStartupMessage("daodan attached!");
619          
620 +        // Tell Oni to not load non levelX_final-files by default:
621          opt_ignore_private_data = false;
622 +
623 +        // Enable sound by default:
624          opt_sound = true;
625          
626          DDrConfig();
# Line 626 | Line 661 | void __cdecl DDrMain(int argc, char* arg
661          
662          // Safe startup message printer
663          if (patch_safeprintf)
664 <                DDrPatch_MakeJump(UUrStartupMessage, DDrStartupMessage);
664 >                DDrPatch_MakeJump((void*)UUrStartupMessage, (void*)DDrStartupMessage);
665          
666          // Daodan device mode enumeration function
667          if (patch_daodandisplayenum)
668 <                DDrPatch_MakeJump(gl_enumerate_valid_display_modes, daodan_enumerate_valid_display_modes);
668 >                DDrPatch_MakeJump((void*)gl_enumerate_valid_display_modes, (void*)daodan_enumerate_valid_display_modes);
669          
670          // Performance patch
671          if (patch_usegettickcount)
672          {
673 <                DDrPatch_MakeJump(UUrMachineTime_High, DDrMachineTime_High);
674 <                DDrPatch_MakeJump(UUrMachineTime_High_Frequency, DDrMachineTime_High_Frequency);
675 <                DDrPatch_MakeJump(UUrMachineTime_Sixtieths, DDrMachineTime_Sixtieths);
673 >                DDrPatch_MakeJump((void*)UUrMachineTime_High, (void*)DDrMachineTime_High);
674 >                DDrPatch_MakeJump((void*)UUrMachineTime_High_Frequency, (void*)DDrMachineTime_High_Frequency);
675 >                DDrPatch_MakeJump((void*)UUrMachineTime_Sixtieths, (void*)DDrMachineTime_Sixtieths);
676          }
677  
678          // Cheats always enabled
679          if (patch_cheatsenabled)
680 <                DDrPatch_MakeJump(ONrPersist_GetWonGame, DDrPersist_GetWonGame);
680 >                DDrPatch_MakeJump((void*)ONrPersist_GetWonGame, (void*)DDrPersist_GetWonGame);
681  
682          // Windowed mode
683          if (patch_usedaodangl)
684          {
685 <        DDrPatch_NOOP((char*)0x004032B7, 6);
686 <        DDrPatch_MakeCall((char*)0x004032B7, LIiP_SetCursorPosHook);
685 >                DDrPatch_NOOP((char*)(OniExe + 0x000032B7), 6);
686 >                DDrPatch_MakeCall((void*)(OniExe + 0x000032B7), (void*)LIiP_SetCursorPosHook);
687          
688 <        DDrPatch_NOOP((char*)0x00403349, 6);
689 <        DDrPatch_MakeCall((char*)0x00403349, LIiP_SetCursorPosHook);
690 <                DDrPatch_MakeJump(ONrPlatform_Initialize, DDrPlatform_Initialize);
691 <                DDrPatch_MakeJump(gl_platform_initialize, daodangl_platform_initialize);
688 >                DDrPatch_NOOP((char*)(OniExe + 0x00003349), 6);
689 >                DDrPatch_MakeCall((void*)(OniExe + 0x00003349), (void*)LIiP_SetCursorPosHook);
690 >                DDrPatch_MakeJump((void*)ONrPlatform_Initialize, (void*)DDrPlatform_Initialize);
691 >                DDrPatch_MakeJump((void*)gl_platform_initialize, (void*)daodangl_platform_initialize);
692          }
693          // Hacked windowed mode (for when daodangl isn't working properly)
694          else if (patch_windowhack)
695                  DDrWindowHack_Install();
696          
697          if (patch_daodaninit)
698 <                DDrPatch_MakeCall(OniExe + 0x000d345a, DDrGame_Init);
698 >                DDrPatch_MakeCall((void*)(OniExe + 0x000d345a), (void*)DDrGame_Init);
699          
700          // Patches for existing BSL functions
701          if (patch_bsl)
# Line 668 | Line 703 | void __cdecl DDrMain(int argc, char* arg
703                  
704          if (patch_cheater)
705          {
706 <                DDrPatch_MakeCall(OniExe + 0x000f618f, DDrCheater);
707 <                DDrPatch_Int16(OniExe + 0x000deb45, 0x5590);
706 >                DDrPatch_MakeCall((void*)(OniExe + 0x000f618f), (void*)DDrCheater);
707 >                DDrPatch_Int16((short*)(OniExe + 0x000deb45), 0x5590);
708   #if 1
709 <                DDrPatch_MakeCall(OniExe + 0x000deb47, FallingFrames);
709 >                DDrPatch_MakeCall((void*)(OniExe + 0x000deb47), (void*)FallingFrames);
710   #endif
711 <                DDrPatch_MakeJump(OniExe + 0x0010f021, DDrCheater_LevelLoad);
711 >                DDrPatch_MakeJump((void*)(OniExe + 0x0010f021), (void*)DDrCheater_LevelLoad);
712          }
713  
714 <        //DDrPatch_MakeJump(0x004378c0, DDrException);
680 <        DDrPatch_MakeJump(0x004245A0, DDrPrintWarning);
681 <        //init_daodan_gl();
714 >        DDrPatch_MakeJump((void*)(OniExe + 0x000245A0), (void*)DDrPrintWarning);
715          
716          ONiMain(argc, argv);
717   }
# Line 714 | Line 747 | BOOL WINAPI DllMain(HINSTANCE hinstDLL,
747                          DDrONiModule = GetModuleHandle(NULL);
748                          
749                          if (*(uint32_t*)(OniExe + 0x0011acd0) == 0x09d36852)
750 <                                DDrPatch_MakeCall(OniExe + 0x0010fb49, DDrMain);
750 >                                DDrPatch_MakeCall((void*)(OniExe + 0x0010fb49), (void*)DDrMain);
751                          else
752                                  ExitProcess(0);
753                          break;

Diff Legend

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