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 681 by alloc, Sun Mar 3 04:37:58 2013 UTC vs.
Revision 705 by alloc, Tue Mar 19 15:00:23 2013 UTC

# Line 1 | Line 1
1 + #include <windows.h>
2   #include <string.h>
3  
4   #include "Daodan.h"
# Line 8 | Line 9
9   #include "Daodan_Persistence.h"
10   #include "Daodan_BSL.h"
11   #include "Daodan_Console.h"
11 #include "Daodan_WindowHack.h"
12  
13   #include "Oni.h"
14 #include "Oni_Persistence.h"
14  
15 < #include "BFW_Utility.h"
15 > #include "Oni_GL.h"
16 > #include "Daodan_GL.h"
17  
18 < #include "oni_gl.h"
19 < #include "daodan_gl.h"
20 <
21 < #include "inifile.h"
18 > #include "Inifile_Reader.h"
19  
20   HMODULE DDrDLLModule;
21   HMODULE DDrONiModule;
# Line 41 | Line 38 | bool patch_argb8888 = true;
38   bool patch_killvtune = true;
39   bool patch_getcmdline = true;
40   bool patch_disablecmdline = true;
41 + bool patch_optionsvisible = true;
42  
43 + bool patch_binkplay = true;
44   bool patch_safeprintf = true;
45   bool patch_daodandisplayenum = true;
46   bool patch_usegettickcount = true;
47   bool patch_cheatsenabled = true;
48 < bool patch_usedaodangl = false;
49 < bool patch_windowhack = true;
48 > bool patch_usedaodangl = true;
49 > bool patch_clipcursor = 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;
57 bool opt_shadow = false;
56   bool opt_topmost = false;
57 + bool opt_gamma = true;
58 +
59 + typedef int (__cdecl *CHINESEPROC)(DWORD ThreadId);
60 + bool patch_chinese = true;
61 +
62 +
63 + // Hooked WMrSlider_SetRange() in ONiOGU_Options_InitDialog. Disables a gamma
64 + // slider in windowed mode.
65 + static void ONICALL DD_ONiOGU_GammaSlider_SetRange(WMtWindow* window, int min_value, int max_value)
66 + {
67 +        WMrWindow_SetEnabled(window, M3gResolutionSwitch && opt_gamma);
68 +        WMrSlider_SetRange(window, min_value, max_value);
69 + }
70 +
71 + void ONICALL DDrShowResumeButton(WMtWindow* window, int visibility)
72 + {
73 +        if (visibility)
74 +                WMrWindow_SetLocation(window, 150, 350);
75 +        WMrWindow_SetVisible(window, visibility);
76 + }
77 +
78 +
79 + /* Options always visible patch */
80 + void ONICALL DDrShowOptionsButton(WMtWindow* window, int visibility)
81 + {
82 +        WMrWindow_SetVisible(window, 1);
83 + }
84 +
85 +
86  
60 typedef int (__cdecl *CHINESEPROC)(DWORD WINAPI);
61 bool patch_chinese = false;
87   bool DDrPatch_Init()
88   {
89          DDrStartupMessage("patching engine");
# Line 66 | Line 91 | bool DDrPatch_Init()
91          // Font texture cache doubled
92          if (patch_fonttexturecache)
93          {
94 <                DDrPatch_Byte(OniExe + 0x00020ea7, 0x20);
95 <                DDrPatch_Byte(OniExe + 0x00020f4a, 0x40);
94 >                DDrPatch_Byte((char*)(OniExe + 0x00020ea7), 0x20);
95 >                DDrPatch_Byte((char*)(OniExe + 0x00020f4a), 0x40);
96          }
97          
98          // Now supports textures up to 512x512
99          if (patch_largetextures)
100 <                DDrPatch_Byte  (OniExe + 0x00005251, 0x10);
100 >                DDrPatch_Byte  ((char*)(OniExe + 0x00005251), 0x10);
101          
102          // Non-"_Final" levels are now valid
103          if (patch_levelplugins)
104 <                DDrPatch_Byte  (OniExe + 0x000206a8, 0x01);
104 >                DDrPatch_Byte  ((char*)(OniExe + 0x000206a8), 0x01);
105          
106          // Pathfinding grid cache size x8
107          if (patch_pathfinding)
108          {
109 <                const char pathfinding[2] = {0x90 , 0xE9 };
110 <                DDrPatch_Byte  (OniExe + 0x0010b03b, 0x20);
111 <                DDrPatch_Byte  (OniExe + 0x0010b04c, 0x20);
109 >                const unsigned char pathfinding[2] = {0x90 , 0xE9 };
110 >                DDrPatch_Byte  ((char*)(OniExe + 0x0010b03b), 0x20);
111 >                DDrPatch_Byte  ((char*)(OniExe + 0x0010b04c), 0x20);
112  
113                  //other stuff
114 <                DDrPatch_Const(0x440789, pathfinding);
114 >                DDrPatch_Const((char*)(OniExe + 0x00040789), pathfinding);
115          }
116          
117          // Projectile awareness fixed
118          if (patch_projaware)
119          {
120 <                DDrPatch_Byte  (OniExe + 0x0009c07c, 0x6c);
121 <                DDrPatch_Byte  (OniExe + 0x0009c080, 0x70);
122 <                DDrPatch_Byte  (OniExe + 0x0009c084, 0x74);
123 <                DDrPatch_Byte  (OniExe + 0x0009c110, 0x6c);
120 >                DDrPatch_Byte  ((char*)(OniExe + 0x0009c07c), 0x6c);
121 >                DDrPatch_Byte  ((char*)(OniExe + 0x0009c080), 0x70);
122 >                DDrPatch_Byte  ((char*)(OniExe + 0x0009c084), 0x74);
123 >                DDrPatch_Byte  ((char*)(OniExe + 0x0009c110), 0x6c);
124          }
125          
126          // Forced DirectInput (for Windows NT)
127          if (patch_directinput)
128 <                DDrPatch_Byte  (OniExe + 0x00002e6d, 0xeb);
128 >                DDrPatch_Byte((char*)(OniExe + 0x00002e6d), 0xeb);
129  
130          if (patch_wpfadetime)
131          {
132                  // Makes wp_fadetime actually have a function
133 <                const char fadetime_patch[] = { 0x66, 0x8B, 0x1D, 0xC4, 0x7D, 0x62, 0x00, 0x66, 0x89, 0x5E, 0x46, 0x5B, 0x5E, 0x83, 0xC4, 0x14, 0xC3 };
134 <                DDrPatch_Const (OniExe + 0x0011a889, fadetime_patch);
135 <                DDrPatch_Byte  (OniExe + 0x0011a560, 0x31);
133 >                const unsigned char fadetime_patch[] = { 0x66, 0x8B, 0x1D, 0xC4, 0x7D, 0x62, 0x00, 0x66, 0x89, 0x5E, 0x46, 0x5B, 0x5E, 0x83, 0xC4, 0x14, 0xC3 };
134 >                DDrPatch_Const ((char*)(OniExe + 0x0011a889), fadetime_patch);
135 >                DDrPatch_Byte  ((char*)(OniExe + 0x0011a560), 0x31);
136                  
137                  // Sets the fadetime to 4800 by default
138 <                DDrPatch_Int16 ((OniExe + 0x0011ab0e), 0x12c0);
138 >                DDrPatch_Int16 ((short*)(OniExe + 0x0011ab0e), 0x12c0);
139          }
140          
141          // FIXME: add switches
# Line 123 | Line 148 | bool DDrPatch_Init()
148          // Don't use this, it breaks stairs.
149          if (patch_kickguns)
150          {
151 <                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 };
152 <                DDrPatch_Const (OniExe + 0x000dc420, kickgun_patch);
151 >                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 };
152 >                DDrPatch_Const ((char*)(OniExe + 0x000dc420), kickgun_patch);
153          }
154          
155          // Cooldown timer exploit fix ^_^
156          if (patch_cooldowntimer)
157          {
158 <                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 };
159 <                DDrPatch_Const (OniExe + 0x0011a825, cooldown_patch);
158 >                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 };
159 >                DDrPatch_Const ((char*)(OniExe + 0x0011a825), cooldown_patch);
160          }
161          
162          if (patch_throwtest)
163          {
164 <                const char throwtest_patch[] = { 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 };
165 <                DDrPatch_Const(OniExe + 0x000dc190, throwtest_patch);
164 >                const unsigned char throwtest_patch[] = { 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 };
165 >                DDrPatch_Const((char*)(OniExe + 0x000dc190), throwtest_patch);
166          }
167          
168          // 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.
169          if (patch_alttab)
170          {
171 <                DDrPatch_Byte  ((void*)UUrPlatform_Initialize, 0xC3);
172 <                DDrPatch_Byte  ((void*)UUrPlatform_Terminate, 0xC3);
171 >                // 0xC3 = ret, so makes those functions just have a "ret" instruction at their start
172 >                DDrPatch_Byte  ((char*)UUrPlatform_Initialize, 0xC3);
173 >                DDrPatch_Byte  ((char*)UUrPlatform_Terminate, 0xC3);
174          }
175          
176          // 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.)
177          if (patch_particledisablebit)
178 <                DDrPatch_Int16 (OniExe + 0x001b184, 0x9090);
178 >                DDrPatch_Int16 ((short*)(OniExe + 0x001b184), 0x9090);
179          
180          // Multi-byte patch (multiple language support)
181          if (!patch_multibyte)
182          {
183 <                DDrPatch_Byte  (OniExe + 0x0002d8f8, 0xeb);
184 <                DDrPatch_Byte  (OniExe + 0x0002d9ad, 0xeb);
185 <                DDrPatch_Byte  (OniExe + 0x0002dbe2, 0xeb);
186 <                DDrPatch_Byte  (OniExe + 0x0002dec3, 0xeb);
187 <                DDrPatch_Byte  (OniExe + 0x0002e2ab, 0xeb);
188 <                DDrPatch_Byte  (OniExe + 0x0002e2c4, 0xeb);
189 <                DDrPatch_Byte  (OniExe + 0x0002e379, 0xeb);
190 <                DDrPatch_Byte  (OniExe + 0x0002e48c, 0xeb);
191 <                DDrPatch_Byte  (OniExe + 0x0002e4d0, 0xeb);
192 <                DDrPatch_Byte  (OniExe + 0x0002e4f4, 0xeb);
193 <                DDrPatch_Byte  (OniExe + 0x0002e646, 0xeb);
194 <                DDrPatch_Byte  (OniExe + 0x0002e695, 0xeb);
195 <                DDrPatch_Byte  (OniExe + 0x0002e944, 0xeb);
196 <                DDrPatch_Byte  (OniExe + 0x0002e95d, 0xeb);
197 <                DDrPatch_Byte  (OniExe + 0x0002e98e, 0xeb);
198 <                DDrPatch_Byte  (OniExe + 0x0002e9dc, 0xeb);
183 >                DDrPatch_Byte  ((char*)(OniExe + 0x0002d8f8), 0xeb);
184 >                DDrPatch_Byte  ((char*)(OniExe + 0x0002d9ad), 0xeb);
185 >                DDrPatch_Byte  ((char*)(OniExe + 0x0002dbe2), 0xeb);
186 >                DDrPatch_Byte  ((char*)(OniExe + 0x0002dec3), 0xeb);
187 >                DDrPatch_Byte  ((char*)(OniExe + 0x0002e2ab), 0xeb);
188 >                DDrPatch_Byte  ((char*)(OniExe + 0x0002e2c4), 0xeb);
189 >                DDrPatch_Byte  ((char*)(OniExe + 0x0002e379), 0xeb);
190 >                DDrPatch_Byte  ((char*)(OniExe + 0x0002e48c), 0xeb);
191 >                DDrPatch_Byte  ((char*)(OniExe + 0x0002e4d0), 0xeb);
192 >                DDrPatch_Byte  ((char*)(OniExe + 0x0002e4f4), 0xeb);
193 >                DDrPatch_Byte  ((char*)(OniExe + 0x0002e646), 0xeb);
194 >                DDrPatch_Byte  ((char*)(OniExe + 0x0002e695), 0xeb);
195 >                DDrPatch_Byte  ((char*)(OniExe + 0x0002e944), 0xeb);
196 >                DDrPatch_Byte  ((char*)(OniExe + 0x0002e95d), 0xeb);
197 >                DDrPatch_Byte  ((char*)(OniExe + 0x0002e98e), 0xeb);
198 >                DDrPatch_Byte  ((char*)(OniExe + 0x0002e9dc), 0xeb);
199          }
200          
201          // Cheat table patch
202          if (patch_cheattable)
203          {
204 <                DDrPatch_Int32 (0x004f616b, (int)&DDr_CheatTable[0].name);
205 <                DDrPatch_Int32 (OniExe + 0x000f617a, (int)&DDr_CheatTable[0].message_on);
204 >                DDrPatch_Int32 ((int*)(OniExe + 0x000f616b), (int)&DDr_CheatTable[0].name);
205 >                DDrPatch_Int32 ((int*)(OniExe + 0x000f617a), (int)&DDr_CheatTable[0].message_on);
206          }
207          
208          // ARGB8888 textures
209          if (patch_argb8888)
210          {
211 <                DDrPatch_Byte  (OniExe + 0x00135af0, 0x07);
212 <                DDrPatch_Byte  (OniExe + 0x00135af4, 0x0B);
211 >                DDrPatch_Byte  ((char*)(OniExe + 0x00135af0), 0x07);
212 >                DDrPatch_Byte  ((char*)(OniExe + 0x00135af4), 0x0B);
213          }
214  
215          //Test newweap patch
# Line 191 | Line 217 | bool DDrPatch_Init()
217                  
218                  //Makes it always say "Recieved weapon_name."
219                  //Needs check for loc_4DFC66
220 <                //DDrPatch_NOOP( OniExe + 0x000E4DF8,2);
220 >                //DDrPatch_NOOP((char*)(OniExe + 0x000E4DF8),2);
221  
222                  //Adds Weapon name and ammo meter to pickup autoprompt
223 <                DDrPatch_NOOP( OniExe + 0x000FAC73, 9);
224 <                DDrPatch_NOOP( OniExe + 0x000FAC80, 5);
225 <                DDrPatch_MakeCall( OniExe + 0xFAC85, DDrWeapon2Message);
223 >                DDrPatch_NOOP((char*)(OniExe + 0x000FAC73), 9);
224 >                DDrPatch_NOOP((char*)(OniExe + 0x000FAC80), 5);
225 >                DDrPatch_MakeCall((void*)(OniExe + 0xFAC85), (void*)DDrWeapon2Message);
226                  
227                  //Moves location of colors
228 <                //DDrPatch_Int32( 0x0042E3D5, (int)&DDrDSayColors );
229 <                //DDrPatch_Int32( 0x0042E3DA, (int)&DDrDSayColors );
228 >                //DDrPatch_Int32((int*)(OniExe + 0x0002E3D5), (int)&DDrDSayColors );
229 >                //DDrPatch_Int32((int*)(OniExe + 0x0002E3DA), (int)&DDrDSayColors );
230          }
231          
232          // Disable loading the vtuneapi.dll
233          //if (patch_killvtune)
234 <                //DDrPatch_Byte  (OniExe + 0x00026340, 0xC3);
234 >                //DDrPatch_Byte  ((char*)(OniExe + 0x00026340), 0xC3);
235          
236          // Disable Oni's internal CLrGetCommandLine function (to eventually replace it with our own)
237          if (patch_getcmdline)
238 <                DDrPatch_NOOP  (OniExe + 0x000d3280, 51);
238 >                DDrPatch_NOOP  ((char*)(OniExe + 0x000d3280), 51);
239          
240          // Disable Oni's command line parser so it doesn't interfere with ours
241          if (patch_disablecmdline)
242 <                DDrPatch_Int32 (OniExe + 0x000d3570, 0xc3c03366);
242 >                DDrPatch_Int32 ((int*)(OniExe + 0x000d3570), 0xc3c03366);
243          
244          if (patch_bsl)
245          {
# Line 222 | Line 248 | bool DDrPatch_Init()
248                  //TODO: fix moonshadow.
249                  Character * Chr = 0;
250                  int NoPath = (int)&(Chr[0].RegenHax) & 0x000000FF;
251 <                const char regen_patch[] =
251 >                const unsigned char regen_patch[] =
252                  {0x90, 0x90, 0x90, 0x90, 0x90,                          // mov    al, _WPgRegenerationCheat     -> NOOP
253                  0x90, 0x90,                                                                     // test   al, al                                        -> NOOP
254                  0x90, 0x90,                                                                     // jz     short loc_51BB98                      -> NOOP
# Line 231 | Line 257 | bool DDrPatch_Init()
257                  0x85, 0xC0,                                                                     // test eax, eax
258                  0x74, 0x21                                                                      // jnz 0x21 -> jz 0x21
259                  };      
260 <                DDrPatch_Const(0x0051BB64, regen_patch);
260 >                DDrPatch_Const((char*)(OniExe + 0x0011BB64), regen_patch);
261          }
262          
263          if(patch_chinese)
264          {
265 <                HMODULE dll = LoadLibrary("xfhsm_oni.dll");
265 >                HMODULE dll;
266 >                DWORD err;
267 >
268 >                DDrStartupMessage("Loading chinese DLL");
269 >                dll = LoadLibrary("xfhsm_oni.dll");
270 >                err = GetLastError();
271                  if( dll )
272                  {
273                          void* proc = GetProcAddress( dll, "InstallHook" );
# Line 244 | Line 275 | bool DDrPatch_Init()
275                          {
276                                  ((CHINESEPROC)proc)(GetCurrentThreadId());
277                          }
278 +                } else {
279 +                        char msg[100];
280 +                        FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, err, 0, msg, 100, NULL);
281 +                        DDrStartupMessage(" - Module loading failed with error %i: %s", err, msg);
282                  }
283          }
284  
# Line 251 | Line 286 | bool DDrPatch_Init()
286          if(1)
287          {
288                  //Set distance above head to 4.0
289 <                DDrPatch_Int32(0x0048C998, 0x005296C8);
289 >                DDrPatch_Int32((int*)(OniExe + 0x0008C998), 0x005296C8);
290                  //texture height
291 <                DDrPatch_Byte( 0x0048C9DF, 0x3F );
291 >                DDrPatch_Byte((char*)(OniExe + 0x0008C9DF), 0x3F );
292                  //texture       width
293 <                DDrPatch_NOOP( (char*)0x0048C9CA, 6 );
293 >                DDrPatch_NOOP((char*)(OniExe + 0x0008C9CA), 6 );
294                  //Set the text color to whatever we like ;)
295 <                DDrPatch_NOOP( 0x0048C898, 6 );
296 <                DDrPatch_Byte( 0x0048C898, 0x8B );
297 <                DDrPatch_Byte( 0x0048C899, 0xCE );
298 < //FLATLINE?             DDrPatch_MakeCall( 0x0048C8A3, FLrHook_DebugNameShadeHack);
295 >                DDrPatch_NOOP((char*)(OniExe + 0x0008C898), 6 );
296 >                DDrPatch_Byte((char*)(OniExe + 0x0008C898), 0x8B );
297 >                DDrPatch_Byte((char*)(OniExe + 0x0008C899), 0xCE );
298 > //FLATLINE?             DDrPatch_MakeCall((void*)(OniExe + 0x0008C8A3), FLrHook_DebugNameShadeHack);
299                  
300                  //Make the background black for additive blending
301 < //FLATLINE?             DDrPatch_MakeCall( 0x0048C802, FLrHook_DebugNameTextureInit );
301 > //FLATLINE?             DDrPatch_MakeCall((void*)(OniExe + 0x0008C802), FLrHook_DebugNameTextureInit );
302          }
303  
304          if(1)
305          {
306 <                //DDrPatch_NOOP( 0x004E1957, 6 );
307 <                //DDrPatch_MakeCall( 0x004E17F6, FLrHook_Lasers );
306 >                //DDrPatch_NOOP((char*)(OniExe + 0x000E1957), 6 );
307 >                //DDrPatch_MakeCall((void*)(OniExe + 0x000E17F6), FLrHook_Lasers );
308          }
309  
310          //Flatline related stuff
311 < //      DDrPatch_MakeCall(0x004FBCEA, DDrText_Hook);
311 > //      DDrPatch_MakeCall((void*)(OniExe + 0x000FBCEA), DDrText_Hook);
312          
313 < //FLATLINE?     DDrPatch_Int32( 0x004B24D2, FLrSpawnHack);
313 > //FLATLINE?     DDrPatch_Int32((int*)(OniExe + 0x000B24D2), FLrSpawnHack);
314 >
315 > //FLATLINE?     DDrPatch_NOOP((char*)(OniExe + 0x000C26CB), 6);
316  
317 < //FLATLINE?     DDrPatch_NOOP(0x004C26CB, 6);
317 > //FLATLINE?     DDrPatch_MakeCall((void*)(OniExe + 0x000C26CB), FLrHook_DoorOpen);
318 > //FLATLINE?     DDrPatch_MakeCall((void*)(OniExe + 0x000EE3CF), FLrHook_ConsoleActivate);
319 >
320 >
321 >        // Fix options not visible in main menu when a game was started
322 >        if(patch_optionsvisible)
323 >        {
324 >                DDrPatch_MakeCall((void*)(OniExe + 0x000d2d2d), DDrShowOptionsButton);
325 >                DDrPatch_MakeCall((void*)(OniExe + 0x000d2d43), DDrShowResumeButton);
326 >        }
327 >
328 >        // Fix BinkBufferInit() call in BKrMovie_Play() to use GDI (DIB) blitting
329 >        // instead of DirectDraw; patch ONiRunGame to use the same method to play
330 >        // outro (ie., BKrMovie_Play() instead of ONrMovie_Play_Hardware() as the
331 >        // latter has problems on WINE).
332 >        if (patch_binkplay)
333 >        {
334 >                // push BINKBUFFERAUTO -> push BINKBUFFERDIBSECTION.
335 >                DDrPatch_Byte((void*)(OniExe + 0x0008829b + 1), 0x02);
336 >                // call ONrMovie_Play_Hardware -> call ONrMovie_Play
337 >                DDrPatch_MakeCall((void*)(OniExe + 0x000d496f), ONrMovie_Play);
338 >        }
339 >
340 >        // Patch a gamma slider in Options dialog (unconditionally).
341 >        // ONiOGU_Options_InitDialog: replace WMrSlider_SetRange(gammaSliderWindow, ...)
342 >        // call with our hook function.
343 >        DDrPatch_MakeCall((void*)(OniExe + 0x000d262c), (void*)DD_ONiOGU_GammaSlider_SetRange);
344  
282 //FLATLINE?     DDrPatch_MakeCall( 0x004C26CB, FLrHook_DoorOpen);
283 //FLATLINE?     DDrPatch_MakeCall( 0x004EE3CF, FLrHook_ConsoleActivate);
345          return true;
346   }
347  
348 +
349   enum {s_unknown, s_options, s_patch, s_bsl, s_language} ini_section;
350  
351   bool DDrIniCallback(char* section, bool newsection, char* name, char* value)
# Line 312 | Line 374 | bool DDrIniCallback(char* section, bool
374                                  opt_usedaodanbsl = !_stricmp(inifile_cleanstr(value), "true");
375                          else if (!_stricmp(name, "border"))
376                                  opt_border = !_stricmp(inifile_cleanstr(value), "true");
315                        else if (!_stricmp(name, "shadow"))
316                                opt_shadow = !_stricmp(inifile_cleanstr(value), "true");
377                          else if (!_stricmp(name, "topmost"))
378                                  opt_topmost = !_stricmp(inifile_cleanstr(value), "true");
379                          else if (!_stricmp(name, "multibyte"))
# Line 330 | Line 390 | bool DDrIniCallback(char* section, bool
390                                  opt_sound = !_stricmp(inifile_cleanstr(value), "true");
391                          else if (!_stricmp(name, "switch"))
392                                  M3gResolutionSwitch = !_stricmp(inifile_cleanstr(value), "true");
393 <                        //else if (!_stricmp(name, "devmode"))
394 <                                //turn_dev_mode_on = !_stricmp(inifile_cleanstr(value), "true");
393 >                        else if (!_stricmp(name, "gamma"))
394 >                                opt_gamma = !_stricmp(inifile_cleanstr(value), "true");
395                          else
396                                  DDrStartupMessage("unrecognised option \"%s\"", name);
397                          break;
# Line 382 | Line 442 | bool DDrIniCallback(char* section, bool
442                                  patch_cheatsenabled = !_stricmp(inifile_cleanstr(value), "true");
443                          else if (!_stricmp(name, "usedaodangl"))
444                                  patch_usedaodangl = !_stricmp(inifile_cleanstr(value), "true");
445 <                        else if (!_stricmp(name, "windowhack"))
446 <                                patch_windowhack = !_stricmp(inifile_cleanstr(value), "true");
445 >                        else if (!_stricmp(name, "clipcursor"))
446 >                                patch_clipcursor = !_stricmp(inifile_cleanstr(value), "true");
447                          else if (!_stricmp(name, "daodaninit"))
448                                  patch_daodaninit = !_stricmp(inifile_cleanstr(value), "true");
449                          else if (!_stricmp(name, "bsl"))
# Line 392 | Line 452 | bool DDrIniCallback(char* section, bool
452                                  patch_cheater = !_stricmp(inifile_cleanstr(value), "true");
453                          else if (!_stricmp(name, "newweap"))
454                                  patch_newweapon = !_stricmp(inifile_cleanstr(value), "true");
455 +                        else if (!_stricmp(name, "optionsvisible"))
456 +                                patch_optionsvisible = !_stricmp(inifile_cleanstr(value), "true");
457 +                        else if (!_stricmp(name, "binkplay"))
458 +                                patch_binkplay = !_stricmp(inifile_cleanstr(value), "true");
459                          else
460                                  DDrStartupMessage("unrecognised patch \"%s\"", name);
461                          break;
# Line 401 | Line 465 | bool DDrIniCallback(char* section, bool
465                          else if (!_stricmp(name, "savepoint"))
466                          {
467                                  char* str = _strdup(value);
468 <                                DDrPatch_Int32(OniExe + 0x000fd730, (int)str);
469 <                                DDrPatch_Int32(OniExe + 0x000fd738, (int)str);
468 >                                DDrPatch_Int32((int*)(OniExe + 0x000fd730), (int)str);
469 >                                DDrPatch_Int32((int*)(OniExe + 0x000fd738), (int)str);
470                          }
471                          else if (!_stricmp(name, "syndicatewarehouse"))
472                          {
473                                  char* str = _strdup(value);
474 <                                DDrPatch_Int32(OniExe + 0x000fd71a, (int)str);
475 <                                DDrPatch_Int32(OniExe + 0x0010ef75, (int)str);
474 >                                DDrPatch_Int32((int*)(OniExe + 0x000fd71a), (int)str);
475 >                                DDrPatch_Int32((int*)(OniExe + 0x0010ef75), (int)str);
476                          }
477                          else if (!_stricmp(name, "damn"))
478 <                                DDrPatch__strdup(OniExe + 0x0010fb6e, value);
478 >                                DDrPatch__strdup((int*)(OniExe + 0x0010fb6e), value);
479                          else if (!_stricmp(name, "blam"))
480 <                                DDrPatch__strdup(OniExe + 0x0010fb73, value);
480 >                                DDrPatch__strdup((int*)(OniExe + 0x0010fb73), value);
481                          else if (!_stricmp(name, "shapeshifter_on"))
482                                  DDr_CheatTable[0].message_on = _strdup(value);
483                          else if (!_stricmp(name, "shapeshifter_off"))
# Line 556 | Line 620 | FILE *__fastcall DDrPrintWarning(int fil
620          char v6[512]; // [sp+0h] [bp-100h]@1
621          FILE* UUgError_WarningFile = *_UUgError_WarningFile;
622  
623 <        if (filename && message && (strlen(filename)+strlen(message))<420) {
623 >        if (filename && message && (strlen((const char*)filename)+strlen((const char*)message))<420) {
624                  sprintf(
625                          v6,
626                          "Error %x reported from File: %s, Line: %d (message follows) \r\n%s",
627                          errornum,
628 <                        filename,
628 >                        (const char*)filename,
629                          linenumber,
630 <                        message);
630 >                        (const char*)message);
631  
632                  if ( UUgError_WarningFile
633                          || (UUgError_WarningFile = oni_fopen("debugger.txt", "wb"), UUgError_WarningFile ) )
# Line 588 | Line 652 | void __cdecl DDrMain(int argc, char* arg
652  
653          DDrStartupMessage("daodan attached!");
654          
655 +        // Tell Oni to not load non levelX_final-files by default:
656          opt_ignore_private_data = false;
657 +
658 +        // Enable sound by default:
659          opt_sound = true;
660          
661          DDrConfig();
# Line 629 | Line 696 | void __cdecl DDrMain(int argc, char* arg
696          
697          // Safe startup message printer
698          if (patch_safeprintf)
699 <                DDrPatch_MakeJump(UUrStartupMessage, DDrStartupMessage);
699 >                DDrPatch_MakeJump((void*)UUrStartupMessage, (void*)DDrStartupMessage);
700          
701          // Daodan device mode enumeration function
702          if (patch_daodandisplayenum)
703 <                DDrPatch_MakeJump(gl_enumerate_valid_display_modes, daodan_enumerate_valid_display_modes);
703 >                DDrPatch_MakeJump((void*)gl_enumerate_valid_display_modes, (void*)DD_GLrEnumerateDisplayModes);
704          
705          // Performance patch
706          if (patch_usegettickcount)
707          {
708 <                DDrPatch_MakeJump(UUrMachineTime_High, DDrMachineTime_High);
709 <                DDrPatch_MakeJump(UUrMachineTime_High_Frequency, DDrMachineTime_High_Frequency);
710 <                DDrPatch_MakeJump(UUrMachineTime_Sixtieths, DDrMachineTime_Sixtieths);
708 >                DDrPatch_MakeJump((void*)UUrMachineTime_High, (void*)DDrMachineTime_High);
709 >                DDrPatch_MakeJump((void*)UUrMachineTime_High_Frequency, (void*)DDrMachineTime_High_Frequency);
710 >                DDrPatch_MakeJump((void*)UUrMachineTime_Sixtieths, (void*)DDrMachineTime_Sixtieths);
711          }
712  
713          // Cheats always enabled
714          if (patch_cheatsenabled)
715 <                DDrPatch_MakeJump(ONrPersist_GetWonGame, DDrPersist_GetWonGame);
715 >                DDrPatch_MakeJump((void*)ONrPersist_GetWonGame, (void*)DDrPersist_GetWonGame);
716  
717 <        // Windowed mode
717 >        // DaodanGL with windowed mode support.
718          if (patch_usedaodangl)
719          {
720 <        DDrPatch_NOOP((char*)0x004032B7, 6);
721 <        DDrPatch_MakeCall((char*)0x004032B7, LIiP_SetCursorPosHook);
722 <        
723 <        DDrPatch_NOOP((char*)0x00403349, 6);
724 <        DDrPatch_MakeCall((char*)0x00403349, LIiP_SetCursorPosHook);
725 <                DDrPatch_MakeJump(ONrPlatform_Initialize, DDrPlatform_Initialize);
726 <                DDrPatch_MakeJump(gl_platform_initialize, daodangl_platform_initialize);
727 <        }
728 <        // Hacked windowed mode (for when daodangl isn't working properly)
729 <        else if (patch_windowhack)
730 <                DDrWindowHack_Install();
720 >                // LIrPlatform_Mode_Set: GetWindowRect -> GetClientRect.
721 >                DDrPatch_NOOP((char*) OniExe + 0x00002dd6, 6);
722 >                DDrPatch_MakeCall((char*) OniExe + 0x00002dd6, (void*) GetClientRect);
723 >
724 >                // UUrWindow_GetSize: GetWindowRect -> GetClientRect.
725 >                DDrPatch_NOOP((char*) OniExe + 0x0002651c, 6);
726 >                DDrPatch_MakeCall((char*) OniExe + 0x0002651c, (void*) GetClientRect);
727 >
728 >                // LIrPlatform_PollInputForAction: fix GetCursorPos call to return client coordinates.
729 >                DDrPatch_NOOP((char*) OniExe + 0x000032cc, 6);
730 >                DDrPatch_MakeCall((char*) OniExe + 0x000032cc, (void*) DD_GetCursorPos);
731 >
732 >                // LIrPlatform_InputEvent_GetMouse: fix GetCursorPos call to return client coordinates.
733 >                DDrPatch_NOOP((char*) OniExe + 0x00002cc2, 6);
734 >                DDrPatch_MakeCall((char*) OniExe + 0x00002cc2, (void*) DD_GetCursorPos);
735 >
736 >                // LIrPlatform_PollInputForAction: translate SetCursorPos position to screen coordinates.
737 >                DDrPatch_NOOP((char*) OniExe + 0x000032b7, 6);
738 >                DDrPatch_MakeCall((char*) OniExe + 0x000032b7, (void*) DD_SetCursorPos);
739 >
740 >                // LIrPlatform_PollInputForAction: translate SetCursorPos position to screen coordinates.
741 >                DDrPatch_NOOP((char*) OniExe + 0x00003349, 6);
742 >                DDrPatch_MakeCall((char*) OniExe + 0x00003349, (void*) DD_SetCursorPos);
743 >
744 >                // Replace ONrPlatformInitialize.
745 >                DDrPatch_MakeJump((void*) ONrPlatform_Initialize, (void*) DD_ONrPlatform_Initialize);
746 >
747 >                // Replace gl_platform_initialize.
748 >                DDrPatch_MakeJump((void*) gl_platform_initialize, (void*) DD_GLrPlatform_Initialize);
749 >
750 >                // Replace gl_platform_dispose.
751 >                DDrPatch_MakeJump((void *) gl_platform_dispose, (void*) DD_GLrPlatform_Dispose);
752 >        }
753 >
754 >        if (patch_clipcursor)
755 >        {
756 >                // LIrMode_Set: replace LIrPlatform_Mode_Set call with our hook.
757 >                DDrPatch_MakeCall((void*)(OniExe + 0x00003f9f), (void*) DD_LIrPlatform_Mode_Set);
758 >
759 >                // LIrMode_Set_Internal: replace LIrPlatform_Mode_Set call with our hook.
760 >                DDrPatch_MakeCall((void*)(OniExe + 0x00003fff), (void*) DD_LIrPlatform_Mode_Set);
761 >                
762 >                // LIrTermiante: replace LIrPlatform_Terminate call with our hook.
763 >                DDrPatch_MakeCall((void*)(OniExe + 0x000004cb8), (void*) DD_LIrPlatform_Terminate);
764 >        }
765 >
766          
767          if (patch_daodaninit)
768 <                DDrPatch_MakeCall(OniExe + 0x000d345a, DDrGame_Init);
768 >                DDrPatch_MakeCall((void*)(OniExe + 0x000d345a), (void*)DDrGame_Init);
769          
770          // Patches for existing BSL functions
771          if (patch_bsl)
# Line 671 | Line 773 | void __cdecl DDrMain(int argc, char* arg
773                  
774          if (patch_cheater)
775          {
776 <                DDrPatch_MakeCall(OniExe + 0x000f618f, DDrCheater);
777 <                DDrPatch_Int16(OniExe + 0x000deb45, 0x5590);
776 >                DDrPatch_MakeCall((void*)(OniExe + 0x000f618f), (void*)DDrCheater);
777 >                DDrPatch_Int16((short*)(OniExe + 0x000deb45), 0x5590);
778   #if 1
779 <                DDrPatch_MakeCall(OniExe + 0x000deb47, FallingFrames);
779 >                DDrPatch_MakeCall((void*)(OniExe + 0x000deb47), (void*)FallingFrames);
780   #endif
781 <                DDrPatch_MakeJump(OniExe + 0x0010f021, DDrCheater_LevelLoad);
781 >                DDrPatch_MakeJump((void*)(OniExe + 0x0010f021), (void*)DDrCheater_LevelLoad);
782          }
783  
784 <        //DDrPatch_MakeJump(0x004378c0, DDrException);
683 <        DDrPatch_MakeJump(0x004245A0, DDrPrintWarning);
684 <        //init_daodan_gl();
784 >        DDrPatch_MakeJump((void*)(OniExe + 0x000245A0), (void*)DDrPrintWarning);
785          
786 <        ONiMain(argc, argv);
786 >        ONiMain(argc, argv);
787   }
788   /*
789   void DDrWrongExe()
# Line 717 | Line 817 | BOOL WINAPI DllMain(HINSTANCE hinstDLL,
817                          DDrONiModule = GetModuleHandle(NULL);
818                          
819                          if (*(uint32_t*)(OniExe + 0x0011acd0) == 0x09d36852)
820 <                                DDrPatch_MakeCall(OniExe + 0x0010fb49, DDrMain);
820 >                                DDrPatch_MakeCall((void*)(OniExe + 0x0010fb49), (void*)DDrMain);
821                          else
822                                  ExitProcess(0);
823                          break;

Diff Legend

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