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 466 by rossy, Sat Oct 17 11:49:49 2009 UTC vs.
Revision 837 by alloc, Mon Apr 29 15:26:54 2013 UTC

# Line 1 | Line 1
1 + #include <windows.h>
2   #include <string.h>
3  
4   #include "Daodan.h"
# Line 7 | Line 8
8   #include "Daodan_Cheater.h"
9   #include "Daodan_Persistence.h"
10   #include "Daodan_BSL.h"
11 <
11 < #include "Daodan_WindowHack.h"
11 > #include "Daodan_Console.h"
12  
13   #include "Oni.h"
14 #include "Oni_Persistence.h"
15
16 #include "BFW_Utility.h"
14  
15 < #include "oni_gl.h"
16 < #include "daodan_gl.h"
15 > #include "Oni_GL.h"
16 > #include "Daodan_GL.h"
17  
18 < #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 <
53 > bool patch_newweapon = true;
54   bool opt_usedaodanbsl = true;
55 + bool opt_border = true;
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  
87   bool DDrPatch_Init()
88   {
89 <        DDrStartupMessage("patching engine");
89 >        DDrStartupMessage("Daodan: Patching engine");
90          
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 <                DDrPatch_Byte  (OniExe + 0x0010b03b, 0x20);
110 <                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((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);
129 <        
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
142 +        //pathfinding fix
143 +
144 +        
145 +
146          
147          // Hackish fix for Konoko not kicking guns
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 (OniExe + 0x000f616b, (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
216 >        if (patch_newweapon) {
217 >                
218 >                //Makes it always say "Received weapon_name."
219 >                //Needs check for loc_4DFC66
220 >                //DDrPatch_NOOP((char*)(OniExe + 0x000E4DF8),2);
221 >
222 >                //Adds Weapon name and ammo meter to pickup autoprompt
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((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);
233 >        //if (patch_killvtune)
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 +        {
246 +                //Calculating the value of the needed offset is much more reliable when the compiler does it for you.
247 +
248 +                //TODO: fix moonshadow.
249 +                Character * Chr = 0;
250 +                int NoPath = (int)&(Chr[0].RegenHax) & 0x000000FF;
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
255 +                0x8B, 0x86, (char)NoPath, 0x01, 0x00, 0x00, // mov     eax, [esi+Character.field_1E8]
256 +                                                                                                        //      -> mov     eax, [esi+Character.RegenHax]
257 +                0x85, 0xC0,                                                                     // test eax, eax
258 +                0x74, 0x21                                                                      // jnz 0x21 -> jz 0x21
259 +                };      
260 +                DDrPatch_Const((char*)(OniExe + 0x0011BB64), regen_patch);
261 +        }
262 +        
263 +        if(patch_chinese)
264 +        {
265 +                if (GetFileAttributes("xfhsm_oni.dll") != INVALID_FILE_ATTRIBUTES)
266 +                {
267 +                        HMODULE dll;
268 +                        DWORD err;
269 +
270 +                        DDrStartupMessage("Daodan: Loading chinese DLL");
271 +                        dll = LoadLibrary("xfhsm_oni.dll");
272 +                        err = GetLastError();
273 +                        if( dll )
274 +                        {
275 +                                void* proc = GetProcAddress( dll, "InstallHook" );
276 +                                if(proc)
277 +                                {
278 +                                        ((CHINESEPROC)proc)(GetCurrentThreadId());
279 +                                }
280 +                        } else {
281 +                                char msg[100];
282 +                                FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, err, 0, msg, 100, NULL);
283 +                                DDrStartupMessage("Daodan: Loading DLL failed with error %i: %s", err, msg);
284 +                        }
285 +                }
286 +        }
287 +
288 +        //Fix crappy ai2_shownames
289 +        if(1)
290 +        {
291 +                //Set distance above head to 4.0
292 +                DDrPatch_Int32((int*)(OniExe + 0x0008C998), 0x005296C8);
293 +                //texture height
294 +                DDrPatch_Byte((char*)(OniExe + 0x0008C9DF), 0x3F );
295 +                //texture       width
296 +                DDrPatch_NOOP((char*)(OniExe + 0x0008C9CA), 6 );
297 +                //Set the text color to whatever we like ;)
298 +                DDrPatch_NOOP((char*)(OniExe + 0x0008C898), 6 );
299 +                DDrPatch_Byte((char*)(OniExe + 0x0008C898), 0x8B );
300 +                DDrPatch_Byte((char*)(OniExe + 0x0008C899), 0xCE );
301 + //FLATLINE?             DDrPatch_MakeCall((void*)(OniExe + 0x0008C8A3), FLrHook_DebugNameShadeHack);
302 +                
303 +                //Make the background black for additive blending
304 + //FLATLINE?             DDrPatch_MakeCall((void*)(OniExe + 0x0008C802), FLrHook_DebugNameTextureInit );
305 +        }
306 +
307 +        if(1)
308 +        {
309 +                //DDrPatch_NOOP((char*)(OniExe + 0x000E1957), 6 );
310 +                //DDrPatch_MakeCall((void*)(OniExe + 0x000E17F6), FLrHook_Lasers );
311 +        }
312 +
313 +        //Flatline related stuff
314 + //      DDrPatch_MakeCall((void*)(OniExe + 0x000FBCEA), DDrText_Hook);
315 +        
316 + //FLATLINE?     DDrPatch_Int32((int*)(OniExe + 0x000B24D2), FLrSpawnHack);
317 +
318 + //FLATLINE?     DDrPatch_NOOP((char*)(OniExe + 0x000C26CB), 6);
319 +
320 + //FLATLINE?     DDrPatch_MakeCall((void*)(OniExe + 0x000C26CB), FLrHook_DoorOpen);
321 + //FLATLINE?     DDrPatch_MakeCall((void*)(OniExe + 0x000EE3CF), FLrHook_ConsoleActivate);
322 +
323 +
324 +        // Fix options not visible in main menu when a game was started
325 +        if(patch_optionsvisible)
326 +        {
327 +                DDrPatch_MakeCall((void*)(OniExe + 0x000d2d2d), DDrShowOptionsButton);
328 +                DDrPatch_MakeCall((void*)(OniExe + 0x000d2d43), DDrShowResumeButton);
329 +        }
330 +
331 +        // Fix BinkBufferInit() call in BKrMovie_Play() to use GDI (DIB) blitting
332 +        // instead of DirectDraw; patch ONiRunGame to use the same method to play
333 +        // outro (ie., BKrMovie_Play() instead of ONrMovie_Play_Hardware() as the
334 +        // latter has problems on WINE).
335 +        if (patch_binkplay)
336 +        {
337 +                // push BINKBUFFERAUTO -> push BINKBUFFERDIBSECTION.
338 +                DDrPatch_Byte((void*)(OniExe + 0x0008829b + 1), 0x02);
339 +                // call ONrMovie_Play_Hardware -> call ONrMovie_Play
340 +                DDrPatch_MakeCall((void*)(OniExe + 0x000d496f), ONrMovie_Play);
341 +        }
342 +
343 +        // Patch a gamma slider in Options dialog (unconditionally).
344 +        // ONiOGU_Options_InitDialog: replace WMrSlider_SetRange(gammaSliderWindow, ...)
345 +        // call with our hook function.
346 +        DDrPatch_MakeCall((void*)(OniExe + 0x000d262c), (void*)DD_ONiOGU_GammaSlider_SetRange);
347 +
348          return true;
349   }
350  
351 +
352   enum {s_unknown, s_options, s_patch, s_bsl, s_language} ini_section;
353  
354   bool DDrIniCallback(char* section, bool newsection, char* name, char* value)
355   {
356          if (newsection)
357          {
358 <                if (!stricmp(section, "options"))
358 >                if (!_stricmp(section, "options"))
359                          ini_section = s_options;
360 <                else if (!stricmp(section, "patch"))
360 >                else if (!_stricmp(section, "patch"))
361                          ini_section = s_patch;
362 <                else if (!stricmp(section, "bsl"))
362 >                else if (!_stricmp(section, "bsl"))
363                          ini_section = s_bsl;
364 <                else if (!stricmp(section, "language"))
364 >                else if (!_stricmp(section, "language"))
365                          ini_section = s_language;
366                  else
367                  {
368                          ini_section = s_unknown;
369 <                        DDrStartupMessage("unrecognised section \"%s\"", section);
369 >                        DDrStartupMessage("Daodan: Unrecognised ini section \"%s\"", section);
370                  }
371          }
372          
373          switch (ini_section)
374          {
375                  case s_options:
376 <                        if (!stricmp(name, "usedaodanbsl"))
377 <                                opt_usedaodanbsl = !stricmp(inifile_cleanstr(value), "true");
378 <                        else if (!stricmp(name, "debug"))
379 <                                AKgDebug_DebugMaps = !stricmp(inifile_cleanstr(value), "true");
380 <                        else if (!stricmp(name, "debugfiles"))
381 <                                BFgDebugFileEnable = !stricmp(inifile_cleanstr(value), "true");
382 <                        else if (!stricmp(name, "findsounds"))
383 <                                SSgSearchOnDisk = !stricmp(inifile_cleanstr(value), "true");
384 <                        else if (!stricmp(name, "ignore_private_data"))
385 <                                opt_ignore_private_data = !stricmp(inifile_cleanstr(value), "true");
386 <                        else if (!stricmp(name, "sound"))
387 <                                opt_sound = !stricmp(inifile_cleanstr(value), "true");
388 <                        else if (!stricmp(name, "switch"))
389 <                                M3gResolutionSwitch = !stricmp(inifile_cleanstr(value), "true");
376 >                        if (!_stricmp(name, "usedaodanbsl"))
377 >                                opt_usedaodanbsl = !_stricmp(inifile_cleanstr(value), "true");
378 >                        else if (!_stricmp(name, "border"))
379 >                                opt_border = !_stricmp(inifile_cleanstr(value), "true");
380 >                        else if (!_stricmp(name, "topmost"))
381 >                                opt_topmost = !_stricmp(inifile_cleanstr(value), "true");
382 >                        else if (!_stricmp(name, "multibyte"))
383 >                                patch_multibyte = !_stricmp(inifile_cleanstr(value), "true");
384 >                        else if (!_stricmp(name, "debug"))
385 >                                AKgDebug_DebugMaps = !_stricmp(inifile_cleanstr(value), "true");
386 >                        else if (!_stricmp(name, "debugfiles"))
387 >                                BFgDebugFileEnable = !_stricmp(inifile_cleanstr(value), "true");
388 >                        else if (!_stricmp(name, "findsounds"))
389 >                                SSgSearchOnDisk = !_stricmp(inifile_cleanstr(value), "true");
390 >                        else if (!_stricmp(name, "ignore_private_data"))
391 >                                opt_ignore_private_data = !_stricmp(inifile_cleanstr(value), "true");
392 >                        else if (!_stricmp(name, "sound"))
393 >                                opt_sound = !_stricmp(inifile_cleanstr(value), "true");
394 >                        else if (!_stricmp(name, "switch"))
395 >                                M3gResolutionSwitch = !_stricmp(inifile_cleanstr(value), "true");
396 >                        else if (!_stricmp(name, "gamma"))
397 >                                opt_gamma = !_stricmp(inifile_cleanstr(value), "true");
398                          else
399 <                                DDrStartupMessage("unrecognised option \"%s\"", name);
399 >                                DDrStartupMessage("Daodan: Unrecognised ini option \"%s\"", name);
400                          break;
401                  case s_patch:
402 <                        if (!stricmp(name, "fonttexturecache"))
403 <                                patch_fonttexturecache = !stricmp(inifile_cleanstr(value), "true");
404 <                        else if (!stricmp(name, "largetextures"))
405 <                                patch_largetextures = !stricmp(inifile_cleanstr(value), "true");
406 <                        else if (!stricmp(name, "levelplugins"))
407 <                                patch_levelplugins = !stricmp(inifile_cleanstr(value), "true");
408 <                        else if (!stricmp(name, "pathfinding"))
409 <                                patch_pathfinding = !stricmp(inifile_cleanstr(value), "true");
410 <                        else if (!stricmp(name, "projaware"))
411 <                                patch_projaware = !stricmp(inifile_cleanstr(value), "true");
412 <                        else if (!stricmp(name, "directinput"))
413 <                                patch_directinput = !stricmp(inifile_cleanstr(value), "true");
414 <                        else if (!stricmp(name, "wpfadetime"))
415 <                                patch_wpfadetime = !stricmp(inifile_cleanstr(value), "true");
416 <                        else if (!stricmp(name, "kickguns"))
417 <                                patch_kickguns = !stricmp(inifile_cleanstr(value), "true");
418 <                        else if (!stricmp(name, "cooldowntimer"))
419 <                                patch_cooldowntimer = !stricmp(inifile_cleanstr(value), "true");
420 <                        else if (!stricmp(name, "throwtest"))
421 <                                patch_throwtest = !stricmp(inifile_cleanstr(value), "true");
422 <                        else if (!stricmp(name, "alttab"))
423 <                                patch_alttab = !stricmp(inifile_cleanstr(value), "true");
424 <                        else if (!stricmp(name, "particledisablebit"))
425 <                                patch_particledisablebit = !stricmp(inifile_cleanstr(value), "true");
426 <                        else if (!stricmp(name, "multibyte"))
427 <                                patch_multibyte = !stricmp(inifile_cleanstr(value), "true");
428 <                        else if (!stricmp(name, "cheattable"))
429 <                                patch_cheattable = !stricmp(inifile_cleanstr(value), "true");
430 <                        else if (!stricmp(name, "argb8888"))
431 <                                patch_argb8888 = !stricmp(inifile_cleanstr(value), "true");
432 <                        else if (!stricmp(name, "killvtune"))
433 <                                patch_killvtune = !stricmp(inifile_cleanstr(value), "true");
434 <                        else if (!stricmp(name, "getcmdline"))
435 <                                patch_getcmdline = !stricmp(inifile_cleanstr(value), "true");
436 <                        else if (!stricmp(name, "disablecmdline"))
437 <                                patch_disablecmdline = !stricmp(inifile_cleanstr(value), "true");
438 <                        else if (!stricmp(name, "safeprintf"))
439 <                                patch_safeprintf = !stricmp(inifile_cleanstr(value), "true");
440 <                        else if (!stricmp(name, "daodandisplayenum"))
441 <                                patch_daodandisplayenum = !stricmp(inifile_cleanstr(value), "true");
442 <                        else if (!stricmp(name, "usegettickcount"))
443 <                                patch_usegettickcount = !stricmp(inifile_cleanstr(value), "true");
444 <                        else if (!stricmp(name, "cheatsenabled"))
445 <                                patch_cheatsenabled = !stricmp(inifile_cleanstr(value), "true");
446 <                        else if (!stricmp(name, "usedaodangl"))
447 <                                patch_usedaodangl = !stricmp(inifile_cleanstr(value), "true");
448 <                        else if (!stricmp(name, "windowhack"))
449 <                                patch_windowhack = !stricmp(inifile_cleanstr(value), "true");
450 <                        else if (!stricmp(name, "daodaninit"))
451 <                                patch_daodaninit = !stricmp(inifile_cleanstr(value), "true");
452 <                        else if (!stricmp(name, "bsl"))
453 <                                patch_bsl = !stricmp(inifile_cleanstr(value), "true");
454 <                        else if (!stricmp(name, "cheater"))
455 <                                patch_cheater = !stricmp(inifile_cleanstr(value), "true");
402 >                        if (!_stricmp(name, "fonttexturecache"))
403 >                                patch_fonttexturecache = !_stricmp(inifile_cleanstr(value), "true");
404 >                        else if (!_stricmp(name, "largetextures"))
405 >                                patch_largetextures = !_stricmp(inifile_cleanstr(value), "true");
406 >                        else if (!_stricmp(name, "levelplugins"))
407 >                                patch_levelplugins = !_stricmp(inifile_cleanstr(value), "true");
408 >                        else if (!_stricmp(name, "pathfinding"))
409 >                                patch_pathfinding = !_stricmp(inifile_cleanstr(value), "true");
410 >                        else if (!_stricmp(name, "projaware"))
411 >                                patch_projaware = !_stricmp(inifile_cleanstr(value), "true");
412 >                        else if (!_stricmp(name, "directinput"))
413 >                                patch_directinput = !_stricmp(inifile_cleanstr(value), "true");
414 >                        else if (!_stricmp(name, "wpfadetime"))
415 >                                patch_wpfadetime = !_stricmp(inifile_cleanstr(value), "true");
416 >                        else if (!_stricmp(name, "kickguns"))
417 >                                patch_kickguns = !_stricmp(inifile_cleanstr(value), "true");
418 >                        else if (!_stricmp(name, "cooldowntimer"))
419 >                                patch_cooldowntimer = !_stricmp(inifile_cleanstr(value), "true");
420 >                        else if (!_stricmp(name, "throwtest"))
421 >                                patch_throwtest = !_stricmp(inifile_cleanstr(value), "true");
422 >                        else if (!_stricmp(name, "alttab"))
423 >                                patch_alttab = !_stricmp(inifile_cleanstr(value), "true");
424 >                        else if (!_stricmp(name, "particledisablebit"))
425 >                                patch_particledisablebit = !_stricmp(inifile_cleanstr(value), "true");
426 >                        else if (!_stricmp(name, "multibyte"))
427 >                                patch_multibyte = !_stricmp(inifile_cleanstr(value), "true");
428 >                        else if (!_stricmp(name, "cheattable"))
429 >                                patch_cheattable = !_stricmp(inifile_cleanstr(value), "true");
430 >                        else if (!_stricmp(name, "argb8888"))
431 >                                patch_argb8888 = !_stricmp(inifile_cleanstr(value), "true");
432 >                        else if (!_stricmp(name, "killvtune"))
433 >                                patch_killvtune = !_stricmp(inifile_cleanstr(value), "true");
434 >                        else if (!_stricmp(name, "getcmdline"))
435 >                                patch_getcmdline = !_stricmp(inifile_cleanstr(value), "true");
436 >                        else if (!_stricmp(name, "disablecmdline"))
437 >                                patch_disablecmdline = !_stricmp(inifile_cleanstr(value), "true");
438 >                        else if (!_stricmp(name, "safeprintf"))
439 >                                patch_safeprintf = !_stricmp(inifile_cleanstr(value), "true");
440 >                        else if (!_stricmp(name, "daodandisplayenum"))
441 >                                patch_daodandisplayenum = !_stricmp(inifile_cleanstr(value), "true");
442 >                        else if (!_stricmp(name, "usegettickcount"))
443 >                                patch_usegettickcount = !_stricmp(inifile_cleanstr(value), "true");
444 >                        else if (!_stricmp(name, "cheatsenabled"))
445 >                                patch_cheatsenabled = !_stricmp(inifile_cleanstr(value), "true");
446 >                        else if (!_stricmp(name, "usedaodangl"))
447 >                                patch_usedaodangl = !_stricmp(inifile_cleanstr(value), "true");
448 >                        else if (!_stricmp(name, "clipcursor"))
449 >                                patch_clipcursor = !_stricmp(inifile_cleanstr(value), "true");
450 >                        else if (!_stricmp(name, "daodaninit"))
451 >                                patch_daodaninit = !_stricmp(inifile_cleanstr(value), "true");
452 >                        else if (!_stricmp(name, "bsl"))
453 >                                patch_bsl = !_stricmp(inifile_cleanstr(value), "true");
454 >                        else if (!_stricmp(name, "cheater"))
455 >                                patch_cheater = !_stricmp(inifile_cleanstr(value), "true");
456 >                        else if (!_stricmp(name, "newweap"))
457 >                                patch_newweapon = !_stricmp(inifile_cleanstr(value), "true");
458 >                        else if (!_stricmp(name, "optionsvisible"))
459 >                                patch_optionsvisible = !_stricmp(inifile_cleanstr(value), "true");
460 >                        else if (!_stricmp(name, "binkplay"))
461 >                                patch_binkplay = !_stricmp(inifile_cleanstr(value), "true");
462                          else
463 <                                DDrStartupMessage("unrecognised patch \"%s\"", name);
463 >                                DDrStartupMessage("Daodan: Unrecognised ini patch \"%s\"", name);
464                          break;
465                  case s_language:
466 <                        if (!stricmp(name, "savepoint"))
466 >                        if (!_stricmp(name, "chinese"))
467 >                                patch_chinese = true;
468 >                        else if (!_stricmp(name, "savepoint"))
469                          {
470 <                                char* str = strdup(value);
471 <                                DDrPatch_Int32(OniExe + 0x000fd730, (int)str);
472 <                                DDrPatch_Int32(OniExe + 0x000fd738, (int)str);
470 >                                char* str = _strdup(value);
471 >                                DDrPatch_Int32((int*)(OniExe + 0x000fd730), (int)str);
472 >                                DDrPatch_Int32((int*)(OniExe + 0x000fd738), (int)str);
473                          }
474 <                        else if (!stricmp(name, "syndicatewarehouse"))
474 >                        else if (!_stricmp(name, "syndicatewarehouse"))
475                          {
476 <                                char* str = strdup(value);
477 <                                DDrPatch_Int32(OniExe + 0x000fd71a, (int)str);
478 <                                DDrPatch_Int32(OniExe + 0x0010ef75, (int)str);
476 >                                char* str = _strdup(value);
477 >                                DDrPatch_Int32((int*)(OniExe + 0x000fd71a), (int)str);
478 >                                DDrPatch_Int32((int*)(OniExe + 0x0010ef75), (int)str);
479                          }
480 <                        else if (!stricmp(name, "damn"))
481 <                                DDrPatch_StrDup(OniExe + 0x0010fb6e, value);
482 <                        else if (!stricmp(name, "blam"))
483 <                                DDrPatch_StrDup(OniExe + 0x0010fb73, value);
484 <                        else if (!stricmp(name, "shapeshifter_on"))
485 <                                DDr_CheatTable[0].message_on = strdup(value);
486 <                        else if (!stricmp(name, "shapeshifter_off"))
487 <                                DDr_CheatTable[0].message_off = strdup(value);
488 <                        else if (!stricmp(name, "liveforever_on"))
489 <                                DDr_CheatTable[1].message_on = strdup(value);
490 <                        else if (!stricmp(name, "liveforever_off"))
491 <                                DDr_CheatTable[1].message_off = strdup(value);
492 <                        else if (!stricmp(name, "touchofdeath_on"))
493 <                                DDr_CheatTable[2].message_on = strdup(value);
494 <                        else if (!stricmp(name, "touchofdeath_off"))
495 <                                DDr_CheatTable[2].message_off = strdup(value);
496 <                        else if (!stricmp(name, "canttouchthis_on"))
497 <                                DDr_CheatTable[3].message_on = strdup(value);
498 <                        else if (!stricmp(name, "canttouchthis_off"))
499 <                                DDr_CheatTable[3].message_off = strdup(value);
500 <                        else if (!stricmp(name, "fatloot_on"))
501 <                                DDr_CheatTable[4].message_on = strdup(value);
502 <                        else if (!stricmp(name, "glassworld_on"))
503 <                                DDr_CheatTable[5].message_on = strdup(value);
504 <                        else if (!stricmp(name, "glassworld_off"))
505 <                                DDr_CheatTable[5].message_off = strdup(value);
506 <                        else if (!stricmp(name, "winlevel_on"))
507 <                                DDr_CheatTable[6].message_on = strdup(value);
508 <                        else if (!stricmp(name, "loselevel_on"))
509 <                                DDr_CheatTable[7].message_on = strdup(value);
510 <                        else if (!stricmp(name, "bighead_on"))
511 <                                DDr_CheatTable[8].message_on = strdup(value);
512 <                        else if (!stricmp(name, "bighead_off"))
513 <                                DDr_CheatTable[8].message_off = strdup(value);
514 <                        else if (!stricmp(name, "minime_on"))
515 <                                DDr_CheatTable[9].message_on = strdup(value);
516 <                        else if (!stricmp(name, "minime_off"))
517 <                                DDr_CheatTable[9].message_off = strdup(value);
518 <                        else if (!stricmp(name, "superammo_on"))
519 <                                DDr_CheatTable[10].message_on = strdup(value);
520 <                        else if (!stricmp(name, "superammo_off"))
521 <                                DDr_CheatTable[10].message_off = strdup(value);
522 <                        else if (!stricmp(name, "devmode_on"))
480 >                        else if (!_stricmp(name, "damn"))
481 >                                DDrPatch__strdup((int*)(OniExe + 0x0010fb6e), value);
482 >                        else if (!_stricmp(name, "blam"))
483 >                                DDrPatch__strdup((int*)(OniExe + 0x0010fb73), value);
484 >                        else if (!_stricmp(name, "shapeshifter_on"))
485 >                                DDr_CheatTable[0].message_on = _strdup(value);
486 >                        else if (!_stricmp(name, "shapeshifter_off"))
487 >                                DDr_CheatTable[0].message_off = _strdup(value);
488 >                        else if (!_stricmp(name, "liveforever_on"))
489 >                                DDr_CheatTable[1].message_on = _strdup(value);
490 >                        else if (!_stricmp(name, "liveforever_off"))
491 >                                DDr_CheatTable[1].message_off = _strdup(value);
492 >                        else if (!_stricmp(name, "touchofdeath_on"))
493 >                                DDr_CheatTable[2].message_on = _strdup(value);
494 >                        else if (!_stricmp(name, "touchofdeath_off"))
495 >                                DDr_CheatTable[2].message_off = _strdup(value);
496 >                        else if (!_stricmp(name, "canttouchthis_on"))
497 >                                DDr_CheatTable[3].message_on = _strdup(value);
498 >                        else if (!_stricmp(name, "canttouchthis_off"))
499 >                                DDr_CheatTable[3].message_off = _strdup(value);
500 >                        else if (!_stricmp(name, "fatloot_on"))
501 >                                DDr_CheatTable[4].message_on = _strdup(value);
502 >                        else if (!_stricmp(name, "glassworld_on"))
503 >                                DDr_CheatTable[5].message_on = _strdup(value);
504 >                        else if (!_stricmp(name, "glassworld_off"))
505 >                                DDr_CheatTable[5].message_off = _strdup(value);
506 >                        else if (!_stricmp(name, "winlevel_on"))
507 >                                DDr_CheatTable[6].message_on = _strdup(value);
508 >                        else if (!_stricmp(name, "loselevel_on"))
509 >                                DDr_CheatTable[7].message_on = _strdup(value);
510 >                        else if (!_stricmp(name, "bighead_on"))
511 >                                DDr_CheatTable[8].message_on = _strdup(value);
512 >                        else if (!_stricmp(name, "bighead_off"))
513 >                                DDr_CheatTable[8].message_off = _strdup(value);
514 >                        else if (!_stricmp(name, "minime_on"))
515 >                                DDr_CheatTable[9].message_on = _strdup(value);
516 >                        else if (!_stricmp(name, "minime_off"))
517 >                                DDr_CheatTable[9].message_off = _strdup(value);
518 >                        else if (!_stricmp(name, "superammo_on"))
519 >                                DDr_CheatTable[10].message_on = _strdup(value);
520 >                        else if (!_stricmp(name, "superammo_off"))
521 >                                DDr_CheatTable[10].message_off = _strdup(value);
522 >                        else if (!_stricmp(name, "devmode_on"))
523                          {
524 <                                char* str = strdup(value);
524 >                                char* str = _strdup(value);
525                                  DDr_CheatTable[11].message_on = str;
526                                  DDr_CheatTable[cheat_x].message_on = str;
527                          }
528 <                        else if (!stricmp(name, "devmode_off"))
528 >                        else if (!_stricmp(name, "devmode_off"))
529                          {
530 <                                char* str = strdup(value);
530 >                                char* str = _strdup(value);
531                                  DDr_CheatTable[11].message_off = str;
532                                  DDr_CheatTable[cheat_x].message_off = str;
533                          }
534 <                        else if (!stricmp(name, "reservoirdogs_on"))
535 <                                DDr_CheatTable[12].message_on = strdup(value);
536 <                        else if (!stricmp(name, "reservoirdogs_off"))
537 <                                DDr_CheatTable[12].message_off = strdup(value);
538 <                        else if (!stricmp(name, "roughjustice_on"))
539 <                                DDr_CheatTable[13].message_on = strdup(value);
540 <                        else if (!stricmp(name, "roughjustice_off"))
541 <                                DDr_CheatTable[13].message_off = strdup(value);
542 <                        else if (!stricmp(name, "chenille_on"))
543 <                                DDr_CheatTable[14].message_on = strdup(value);
544 <                        else if (!stricmp(name, "chenille_off"))
545 <                                DDr_CheatTable[14].message_off = strdup(value);
546 <                        else if (!stricmp(name, "behemoth_on"))
547 <                                DDr_CheatTable[15].message_on = strdup(value);
548 <                        else if (!stricmp(name, "behemoth_off"))
549 <                                DDr_CheatTable[15].message_off = strdup(value);
550 <                        else if (!stricmp(name, "elderrune_on"))
551 <                                DDr_CheatTable[16].message_on = strdup(value);
552 <                        else if (!stricmp(name, "elderrune_off"))
553 <                                DDr_CheatTable[16].message_off = strdup(value);
554 <                        else if (!stricmp(name, "moonshadow_on"))
555 <                                DDr_CheatTable[17].message_on = strdup(value);
556 <                        else if (!stricmp(name, "moonshadow_off"))
557 <                                DDr_CheatTable[17].message_off = strdup(value);
558 <                        else if (!stricmp(name, "munitionfrenzy_on"))
559 <                                DDr_CheatTable[18].message_on = strdup(value);
560 <                        else if (!stricmp(name, "fistsoflegend_on"))
561 <                                DDr_CheatTable[19].message_on = strdup(value);
562 <                        else if (!stricmp(name, "fistsoflegend_off"))
563 <                                DDr_CheatTable[19].message_off = strdup(value);
564 <                        else if (!stricmp(name, "killmequick_on"))
565 <                                DDr_CheatTable[20].message_on = strdup(value);
566 <                        else if (!stricmp(name, "killmequick_off"))
567 <                                DDr_CheatTable[20].message_off = strdup(value);
568 <                        else if (!stricmp(name, "carousel_on"))
569 <                                DDr_CheatTable[21].message_on = strdup(value);
570 <                        else if (!stricmp(name, "carousel_off"))
571 <                                DDr_CheatTable[21].message_off = strdup(value);
534 >                        else if (!_stricmp(name, "reservoirdogs_on"))
535 >                                DDr_CheatTable[12].message_on = _strdup(value);
536 >                        else if (!_stricmp(name, "reservoirdogs_off"))
537 >                                DDr_CheatTable[12].message_off = _strdup(value);
538 >                        else if (!_stricmp(name, "roughjustice_on"))
539 >                                DDr_CheatTable[13].message_on = _strdup(value);
540 >                        else if (!_stricmp(name, "roughjustice_off"))
541 >                                DDr_CheatTable[13].message_off = _strdup(value);
542 >                        else if (!_stricmp(name, "chenille_on"))
543 >                                DDr_CheatTable[14].message_on = _strdup(value);
544 >                        else if (!_stricmp(name, "chenille_off"))
545 >                                DDr_CheatTable[14].message_off = _strdup(value);
546 >                        else if (!_stricmp(name, "behemoth_on"))
547 >                                DDr_CheatTable[15].message_on = _strdup(value);
548 >                        else if (!_stricmp(name, "behemoth_off"))
549 >                                DDr_CheatTable[15].message_off = _strdup(value);
550 >                        else if (!_stricmp(name, "elderrune_on"))
551 >                                DDr_CheatTable[16].message_on = _strdup(value);
552 >                        else if (!_stricmp(name, "elderrune_off"))
553 >                                DDr_CheatTable[16].message_off = _strdup(value);
554 >                        else if (!_stricmp(name, "moonshadow_on"))
555 >                                DDr_CheatTable[17].message_on = _strdup(value);
556 >                        else if (!_stricmp(name, "moonshadow_off"))
557 >                                DDr_CheatTable[17].message_off = _strdup(value);
558 >                        else if (!_stricmp(name, "munitionfrenzy_on"))
559 >                                DDr_CheatTable[18].message_on = _strdup(value);
560 >                        else if (!_stricmp(name, "fistsoflegend_on"))
561 >                                DDr_CheatTable[19].message_on = _strdup(value);
562 >                        else if (!_stricmp(name, "fistsoflegend_off"))
563 >                                DDr_CheatTable[19].message_off = _strdup(value);
564 >                        else if (!_stricmp(name, "killmequick_on"))
565 >                                DDr_CheatTable[20].message_on = _strdup(value);
566 >                        else if (!_stricmp(name, "killmequick_off"))
567 >                                DDr_CheatTable[20].message_off = _strdup(value);
568 >                        else if (!_stricmp(name, "carousel_on"))
569 >                                DDr_CheatTable[21].message_on = _strdup(value);
570 >                        else if (!_stricmp(name, "carousel_off"))
571 >                                DDr_CheatTable[21].message_off = _strdup(value);
572                          else
573 <                                DDrStartupMessage("unrecognised language item \"%s\"", name);
573 >                                DDrStartupMessage("Daodan: Unrecognised ini language item \"%s\"", name);
574                          break;
575                  case s_bsl:
576                  default:
# Line 403 | Line 582 | bool DDrIniCallback(char* section, bool
582  
583   void DDrConfig()
584   {
585 +
586          if (GetFileAttributes("daodan.ini") == INVALID_FILE_ATTRIBUTES)
587          {
588 <                DDrStartupMessage("daodan.ini doesn't exist, creating");
589 <                FILE* fp = fopen("daodan.ini", "w");
588 >                FILE* fp;
589 >                DDrStartupMessage("Daodan: daodan.ini doesn't exist, creating");
590 >                fp = fopen("daodan.ini", "w");
591                  if (fp)
592                  {
593                          fputs("[Options]\n", fp);
# Line 414 | Line 595 | void DDrConfig()
595                  }
596          }
597          
598 <        DDrStartupMessage("parsing daodan.ini...");
598 >        DDrStartupMessage("Daodan: Parsing daodan.ini...");
599          if (!inifile_read("daodan.ini", DDrIniCallback))
600 <                DDrStartupMessage("error reading daodan.ini, check your syntax!");
601 <        DDrStartupMessage("finished parsing");
600 >                DDrStartupMessage("Daodan: Error reading daodan.ini, check your syntax!");
601 >        DDrStartupMessage("Daodan: Finished parsing");
602   }
603  
604   void ONICALL DDrGame_Init()
605   {
606          if (opt_usedaodanbsl)
607 <                SLrDaodan_Initalize();
607 >                SLrDaodan_Initialize();
608 > }
609 >
610 > void DDrException() {
611 >        int* i = 0;
612 >        *i = 1;
613 > }
614 > #include <stdio.h>
615 >
616 > //this was broken
617 > FILE** _UUgError_WarningFile = (FILE**)0x005711B4;
618 > FILE *__fastcall DDrPrintWarning(int filename, int linenumber, unsigned __int16 errornum, int message)
619 > {
620 >
621 >        FILE *v4; // eax@1
622 >        FILE *result; // eax@4
623 >        char v6[512]; // [sp+0h] [bp-100h]@1
624 >        FILE* UUgError_WarningFile = *_UUgError_WarningFile;
625 >
626 >        if (filename && message && (strlen((const char*)filename)+strlen((const char*)message))<420) {
627 >                sprintf(
628 >                        v6,
629 >                        "Error %x reported from File: %s, Line: %d (message follows) \r\n%s",
630 >                        errornum,
631 >                        (const char*)filename,
632 >                        linenumber,
633 >                        (const char*)message);
634 >
635 >                if ( UUgError_WarningFile
636 >                        || (UUgError_WarningFile = oni_fopen("debugger.txt", "wb"), UUgError_WarningFile ) )
637 >                {
638 >                        oni_fprintf(UUgError_WarningFile, "%s\r\n", v6);
639 >                        oni_fflush(UUgError_WarningFile);
640 >                }
641 >        }
642 >        //oni_fprintf(stdout, v6);
643 >        //sprintf(&v6, "%s", message);
644 >        *_UUgError_WarningFile = UUgError_WarningFile;
645 >        result = UUgError_WarningFile;
646 >        return result;
647   }
648  
649   void __cdecl DDrMain(int argc, char* argv[])
650   {
651 <        DDrStartupMessage("daodan attached!");
651 >        int i;
652 >        char* section;
653 >        char* option;
654 >        bool falseoption;
655 >
656 >        DDrStartupMessage("Daodan: Daodan attached!");
657          
658 +        // Tell Oni to not load non levelX_final-files by default:
659          opt_ignore_private_data = false;
660 +
661 +        // Enable sound by default:
662          opt_sound = true;
663          
664          DDrConfig();
665 <        DDrStartupMessage("parsing command line...");
438 <        int i;
439 <        char* section;
440 <        char* option;
441 <        bool falseoption;
665 >        DDrStartupMessage("Daodan: Parsing command line...");
666          for (i = 1; i < argc; i ++)
667          {
668                  if (argv[i][0] == '-')
# Line 449 | Line 673 | void __cdecl DDrMain(int argc, char* arg
673                                  *option = '\0';
674                                  falseoption = (option[1] == 'n' || option[1] == 'N') && (option[2] = 'o' || option[2] == 'O');
675                                  if (i < (argc - 1) && argv[i + 1][0] != '-')
676 <                                        DDrIniCallback(section, true, option + (falseoption ? 3 : 1), argv[++i]);
676 >                                        DDrIniCallback(section, true, option + 1, argv[++i]);
677                                  else
678                                          DDrIniCallback(section, true, option + (falseoption ? 3 : 1), (falseoption ? "false" : "true"));
679                                  *option = '.';
# Line 459 | Line 683 | void __cdecl DDrMain(int argc, char* arg
683                                  falseoption = (section[0] == 'n' || section[0] == 'N') && (section[1] = 'o' || section[1] == 'O');
684                                  ini_section = s_options;
685                                  if (i < (argc - 1) && argv[i + 1][0] != '-')
686 <                                        DDrIniCallback(NULL, false, section + (falseoption ? 2 : 0), argv[++i]);
686 >                                        DDrIniCallback(NULL, false, section, argv[++i]);
687                                  else
688                                          DDrIniCallback(NULL, false, section + (falseoption ? 2 : 0), (falseoption ? "false" : "true"));
689                          }
690                  }
691                  else
692                  {
693 <                        DDrStartupMessage("parse error \"%s\"", argv[i]);
693 >                        DDrStartupMessage("Daodan: Parse error \"%s\"", argv[i]);
694                          break;
695                  }
696          }
697 <        DDrStartupMessage("finished parsing");
697 >        DDrStartupMessage("Daodan: Finished parsing");
698          DDrPatch_Init();
699          
700          // Safe startup message printer
701          if (patch_safeprintf)
702 <                DDrPatch_MakeJump(UUrStartupMessage, DDrStartupMessage);
702 >                DDrPatch_MakeJump((void*)UUrStartupMessage, (void*)DDrStartupMessage);
703          
704          // Daodan device mode enumeration function
705          if (patch_daodandisplayenum)
706 <                DDrPatch_MakeJump(gl_enumerate_valid_display_modes, daodan_enumerate_valid_display_modes);
706 >                DDrPatch_MakeJump((void*)gl_enumerate_valid_display_modes, (void*)DD_GLrEnumerateDisplayModes);
707          
708          // Performance patch
709          if (patch_usegettickcount)
710          {
711 <                DDrPatch_MakeJump(UUrMachineTime_High, DDrMachineTime_High);
712 <                DDrPatch_MakeJump(UUrMachineTime_High_Frequency, DDrMachineTime_High_Frequency);
713 <                DDrPatch_MakeJump(UUrMachineTime_Sixtieths, DDrMachineTime_Sixtieths);
711 >                DDrPatch_MakeJump((void*)UUrMachineTime_High, (void*)DDrMachineTime_High);
712 >                DDrPatch_MakeJump((void*)UUrMachineTime_High_Frequency, (void*)DDrMachineTime_High_Frequency);
713 >                DDrPatch_MakeJump((void*)UUrMachineTime_Sixtieths, (void*)DDrMachineTime_Sixtieths);
714          }
715 <        
715 >
716          // Cheats always enabled
717          if (patch_cheatsenabled)
718 <                DDrPatch_MakeJump(ONrPersist_GetWonGame, DDrPersist_GetWonGame);
719 <        
720 <        // Windowed mode
718 >                DDrPatch_MakeJump((void*)ONrPersist_GetWonGame, (void*)DDrPersist_GetWonGame);
719 >
720 >        // DaodanGL with windowed mode support.
721          if (patch_usedaodangl)
722          {
723 <                DDrPatch_MakeJump(ONrPlatform_Initialize, DDrPlatform_Initialize);
724 <                DDrPatch_MakeJump(gl_platform_initialize, daodangl_platform_initialize);
723 >                // LIrPlatform_Mode_Set: GetWindowRect -> GetClientRect.
724 >                DDrPatch_NOOP((char*) OniExe + 0x00002dd6, 6);
725 >                DDrPatch_MakeCall((char*) OniExe + 0x00002dd6, (void*) GetClientRect);
726 >
727 >                // UUrWindow_GetSize: GetWindowRect -> GetClientRect.
728 >                DDrPatch_NOOP((char*) OniExe + 0x0002651c, 6);
729 >                DDrPatch_MakeCall((char*) OniExe + 0x0002651c, (void*) GetClientRect);
730 >
731 >                // LIrPlatform_PollInputForAction: fix GetCursorPos call to return client coordinates.
732 >                DDrPatch_NOOP((char*) OniExe + 0x000032cc, 6);
733 >                DDrPatch_MakeCall((char*) OniExe + 0x000032cc, (void*) DD_GetCursorPos);
734 >
735 >                // LIrPlatform_InputEvent_GetMouse: fix GetCursorPos call to return client coordinates.
736 >                DDrPatch_NOOP((char*) OniExe + 0x00002cc2, 6);
737 >                DDrPatch_MakeCall((char*) OniExe + 0x00002cc2, (void*) DD_GetCursorPos);
738 >
739 >                // LIrPlatform_PollInputForAction: translate SetCursorPos position to screen coordinates.
740 >                DDrPatch_NOOP((char*) OniExe + 0x000032b7, 6);
741 >                DDrPatch_MakeCall((char*) OniExe + 0x000032b7, (void*) DD_SetCursorPos);
742 >
743 >                // LIrPlatform_PollInputForAction: translate SetCursorPos position to screen coordinates.
744 >                DDrPatch_NOOP((char*) OniExe + 0x00003349, 6);
745 >                DDrPatch_MakeCall((char*) OniExe + 0x00003349, (void*) DD_SetCursorPos);
746 >
747 >                // Replace ONrPlatformInitialize.
748 >                DDrPatch_MakeJump((void*) ONrPlatform_Initialize, (void*) DD_ONrPlatform_Initialize);
749 >
750 >                // Replace gl_platform_initialize.
751 >                DDrPatch_MakeJump((void*) gl_platform_initialize, (void*) DD_GLrPlatform_Initialize);
752 >
753 >                // Replace gl_platform_dispose.
754 >                DDrPatch_MakeJump((void *) gl_platform_dispose, (void*) DD_GLrPlatform_Dispose);
755 >        }
756 >
757 >        if (patch_clipcursor)
758 >        {
759 >                // LIrMode_Set: replace LIrPlatform_Mode_Set call with our hook.
760 >                DDrPatch_MakeCall((void*)(OniExe + 0x00003f9f), (void*) DD_LIrPlatform_Mode_Set);
761 >
762 >                // LIrMode_Set_Internal: replace LIrPlatform_Mode_Set call with our hook.
763 >                DDrPatch_MakeCall((void*)(OniExe + 0x00003fff), (void*) DD_LIrPlatform_Mode_Set);
764 >                
765 >                // LIrTermiante: replace LIrPlatform_Terminate call with our hook.
766 >                DDrPatch_MakeCall((void*)(OniExe + 0x000004cb8), (void*) DD_LIrPlatform_Terminate);
767          }
768 <        
503 <        // Hacked windowed mode (for when daodangl isn't working properly)
504 <        if (patch_windowhack)
505 <                DDrWindowHack_Install();
768 >
769          
770          if (patch_daodaninit)
771 <                DDrPatch_MakeCall(OniExe + 0x000d345a, DDrGame_Init);
771 >                DDrPatch_MakeCall((void*)(OniExe + 0x000d345a), (void*)DDrGame_Init);
772          
773          // Patches for existing BSL functions
774          if (patch_bsl)
775                  SLrDaodan_Patch();
776 <        
776 >                
777          if (patch_cheater)
778          {
779 <                DDrPatch_MakeCall(OniExe + 0x000f618f, DDrCheater);
780 <                DDrPatch_Int16(OniExe + 0x000deb45, 0x5590);
781 <                DDrPatch_MakeCall(OniExe + 0x000deb47, FallingFrames);
782 <                DDrPatch_MakeJump(OniExe + 0x0010f021, DDrCheater_LevelLoad);
779 >                DDrPatch_MakeCall((void*)(OniExe + 0x000f618f), (void*)DDrCheater);
780 >                DDrPatch_Int16((short*)(OniExe + 0x000deb45), 0x5590);
781 > #if 1
782 >                DDrPatch_MakeCall((void*)(OniExe + 0x000deb47), (void*)FallingFrames);
783 > #endif
784 >                DDrPatch_MakeJump((void*)(OniExe + 0x0010f021), (void*)DDrCheater_LevelLoad);
785          }
786 <        
787 <        init_daodan_gl();
786 >
787 >        DDrPatch_MakeJump((void*)(OniExe + 0x000245A0), (void*)DDrPrintWarning);
788          
789          ONiMain(argc, argv);
790   }
# Line 554 | Line 819 | BOOL WINAPI DllMain(HINSTANCE hinstDLL,
819                          DDrDLLModule = hinstDLL;
820                          DDrONiModule = GetModuleHandle(NULL);
821                          
822 <                        if (*(uint32_t*)((void*)OniExe + 0x0011acd0) == 0x09d36852)
823 <                                DDrPatch_MakeCall(OniExe + 0x0010fb49, DDrMain);
822 >                        if (*(uint32_t*)(OniExe + 0x0011acd0) == 0x09d36852)
823 >                                DDrPatch_MakeCall((void*)(OniExe + 0x0010fb49), (void*)DDrMain);
824                          else
825                                  ExitProcess(0);
826                          break;

Diff Legend

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