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 329 by rossy, Wed Jun 3 12:12:21 2009 UTC vs.
Revision 452 by rossy, Mon Aug 10 09:09:53 2009 UTC

# Line 1 | Line 1
1 + #include <string.h>
2 +
3   #include "Daodan.h"
4   #include "Daodan_Patch.h"
5   #include "Daodan_Utility.h"
6   #include "Daodan_Win32.h"
7 + #include "Daodan_Cheater.h"
8 + #include "Daodan_Persistence.h"
9 + #include "Daodan_BSL.h"
10 +
11 + #include "Daodan_WindowHack.h"
12  
13   #include "Oni.h"
14 + #include "Oni_Persistence.h"
15 +
16   #include "BFW_Utility.h"
17  
18   #include "oni_gl.h"
19   #include "daodan_gl.h"
20  
21 + #include "inifile.h"
22 +
23   HMODULE DDrDLLModule;
24   HMODULE DDrONiModule;
25  
26 + bool patch_fonttexturecache = true;
27 + bool patch_largetextures = true;
28 + bool patch_levelplugins = true;
29 + bool patch_pathfinding = true;
30 + bool patch_projaware = true;
31 + bool patch_directinput = true;
32 + bool patch_wpfadetime = true;
33 + bool patch_kickguns = false;
34 + bool patch_cooldowntimer = true;
35 + bool patch_throwtest = false;
36 + bool patch_alttab = true;
37 + bool patch_particledisablebit = false;
38 + bool patch_multibyte = false;
39 + bool patch_cheattable = true;
40 + bool patch_argb8888 = true;
41 +
42 + bool patch_safeprintf = true;
43 + bool patch_daodandisplayenum = true;
44 + bool patch_usegettickcount = true;
45 + bool patch_cheatsenabled = true;
46 + bool patch_usedaodangl = false;
47 + bool patch_windowhack = true;
48 + bool patch_daodaninit = true;
49 + bool patch_bsl = true;
50 + bool patch_cheater = true;
51 +
52 + bool opt_usedaodanbsl = true;
53 +
54   bool DDrPatch_Init()
55   {
56 +        DDrStartupMessage("patching engine");
57 +        
58          // Font texture cache doubled
59 <        DDrPatch_Byte  (OniExe + 0x00020ea7, 0x20);
60 <        DDrPatch_Byte  (OniExe + 0x00020f4a, 0x40);
59 >        if (patch_fonttexturecache)
60 >        {
61 >                DDrPatch_Byte  (OniExe + 0x00020ea7, 0x20);
62 >                DDrPatch_Byte  (OniExe + 0x00020f4a, 0x40);
63 >        }
64          
65          // Now supports textures up to 512x512
66 <        DDrPatch_Byte  (OniExe + 0x00005251, 0x10);
66 >        if (patch_largetextures)
67 >                DDrPatch_Byte  (OniExe + 0x00005251, 0x10);
68          
69          // Non-"_Final" levels are now valid
70 <        DDrPatch_Byte  (OniExe + 0x000206a8, 0x01);
70 >        if (patch_levelplugins)
71 >                DDrPatch_Byte  (OniExe + 0x000206a8, 0x01);
72          
73          // Pathfinding grid cache size x8
74 <        DDrPatch_Byte  (OniExe + 0x0010b03b, 0x20);
75 <        DDrPatch_Byte  (OniExe + 0x0010b04c, 0x20);
74 >        if (patch_pathfinding)
75 >        {
76 >                DDrPatch_Byte  (OniExe + 0x0010b03b, 0x20);
77 >                DDrPatch_Byte  (OniExe + 0x0010b04c, 0x20);
78 >        }
79          
80          // Projectile awareness fixed
81 <        DDrPatch_Byte  (OniExe + 0x0009c07c, 0x6c);
82 <        DDrPatch_Byte  (OniExe + 0x0009c080, 0x70);
83 <        DDrPatch_Byte  (OniExe + 0x0009c084, 0x74);
84 <        DDrPatch_Byte  (OniExe + 0x0009c110, 0x6c);
81 >        if (patch_projaware)
82 >        {
83 >                DDrPatch_Byte  (OniExe + 0x0009c07c, 0x6c);
84 >                DDrPatch_Byte  (OniExe + 0x0009c080, 0x70);
85 >                DDrPatch_Byte  (OniExe + 0x0009c084, 0x74);
86 >                DDrPatch_Byte  (OniExe + 0x0009c110, 0x6c);
87 >        }
88          
89          // Forced DirectInput (for Windows NT)
90 <        DDrPatch_Byte  (OniExe + 0x00002e6d, 0xeb);
91 <        
40 <        // Makes wp_fadetime actually have a function
41 <        const char fadetime_patch[] = { 0x66, 0x8B, 0x1D, 0xC4, 0x7D, 0x62, 0x00, 0x66, 0x89, 0x5E, 0x46, 0x5B, 0x5E, 0x83, 0xC4, 0x14, 0xC3 };
42 <        DDrPatch_Const (OniExe + 0x0011a889, fadetime_patch);
43 <        DDrPatch_Byte  (OniExe + 0x0011a560, 0x31);
90 >        if (patch_directinput)
91 >                DDrPatch_Byte  (OniExe + 0x00002e6d, 0xeb);
92          
93 <        // Sets the fadetime to 4800 by default
94 <        DDrPatch_Int16 (OniExe + 0x0011ab0e, 0x12c0);
93 >        if (patch_wpfadetime)
94 >        {
95 >                // Makes wp_fadetime actually have a function
96 >                const char fadetime_patch[] = { 0x66, 0x8B, 0x1D, 0xC4, 0x7D, 0x62, 0x00, 0x66, 0x89, 0x5E, 0x46, 0x5B, 0x5E, 0x83, 0xC4, 0x14, 0xC3 };
97 >                DDrPatch_Const (OniExe + 0x0011a889, fadetime_patch);
98 >                DDrPatch_Byte  (OniExe + 0x0011a560, 0x31);
99 >                
100 >                // Sets the fadetime to 4800 by default
101 >                DDrPatch_Int16 (OniExe + 0x0011ab0e, 0x12c0);
102 >        }
103          
104          
105          // Hackish fix for Konoko not kicking guns
106 < //      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 };
107 < //      DDrPatch_Const (OniExe + 0x000dc420, kickgun_patch);
106 >        if (patch_kickguns)
107 >        {
108 >                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 };
109 >                DDrPatch_Const (OniExe + 0x000dc420, kickgun_patch);
110 >        }
111          
112          // Cooldown timer exploit fix ^_^
113 <        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 };
114 <        DDrPatch_Const (OniExe + 0x0011a825, cooldown_patch);
115 <        
116 < //      const char throwtest_patch[] = { 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 };
117 < //      DDrPatch_Const(OniExe + 0x000dc190, throwtest_patch);
113 >        if (patch_cooldowntimer)
114 >        {
115 >                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 };
116 >                DDrPatch_Const (OniExe + 0x0011a825, cooldown_patch);
117 >        }
118 >        
119 >        if (patch_throwtest)
120 >        {
121 >                const char throwtest_patch[] = { 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 };
122 >                DDrPatch_Const(OniExe + 0x000dc190, throwtest_patch);
123 >        }
124          
125          // 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.
126 <        DDrPatch_Byte  ((void*)UUrPlatform_Initialize, 0xC3);
127 <        DDrPatch_Byte  ((void*)UUrPlatform_Terminate, 0xC3);
126 >        if (patch_alttab)
127 >        {
128 >                DDrPatch_Byte  ((void*)UUrPlatform_Initialize, 0xC3);
129 >                DDrPatch_Byte  ((void*)UUrPlatform_Terminate, 0xC3);
130 >        }
131          
132          // 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.)
133 <        //DDrPatch_Int16 (OniExe + 0x001b184, 0x9090);
133 >        if (patch_particledisablebit)
134 >                DDrPatch_Int16 (OniExe + 0x001b184, 0x9090);
135          
136          // Multi-byte patch (multiple language support)
137 <        DDrPatch_Byte  (OniExe + 0x0002d8f8, 0xeb);
138 <        DDrPatch_Byte  (OniExe + 0x0002d9ad, 0xeb);
139 <        DDrPatch_Byte  (OniExe + 0x0002dbe2, 0xeb);
140 <        DDrPatch_Byte  (OniExe + 0x0002dec3, 0xeb);
141 <        DDrPatch_Byte  (OniExe + 0x0002e2ab, 0xeb);
142 <        DDrPatch_Byte  (OniExe + 0x0002e2c4, 0xeb);
143 <        DDrPatch_Byte  (OniExe + 0x0002e379, 0xeb);
144 <        DDrPatch_Byte  (OniExe + 0x0002e48c, 0xeb);
145 <        DDrPatch_Byte  (OniExe + 0x0002e4d0, 0xeb);
146 <        DDrPatch_Byte  (OniExe + 0x0002e4f4, 0xeb);
147 <        DDrPatch_Byte  (OniExe + 0x0002e646, 0xeb);
148 <        DDrPatch_Byte  (OniExe + 0x0002e695, 0xeb);
149 <        DDrPatch_Byte  (OniExe + 0x0002e944, 0xeb);
150 <        DDrPatch_Byte  (OniExe + 0x0002e95d, 0xeb);
151 <        DDrPatch_Byte  (OniExe + 0x0002e98e, 0xeb);
152 <        DDrPatch_Byte  (OniExe + 0x0002e9dc, 0xeb);
137 >        if (!patch_multibyte)
138 >        {
139 >                DDrPatch_Byte  (OniExe + 0x0002d8f8, 0xeb);
140 >                DDrPatch_Byte  (OniExe + 0x0002d9ad, 0xeb);
141 >                DDrPatch_Byte  (OniExe + 0x0002dbe2, 0xeb);
142 >                DDrPatch_Byte  (OniExe + 0x0002dec3, 0xeb);
143 >                DDrPatch_Byte  (OniExe + 0x0002e2ab, 0xeb);
144 >                DDrPatch_Byte  (OniExe + 0x0002e2c4, 0xeb);
145 >                DDrPatch_Byte  (OniExe + 0x0002e379, 0xeb);
146 >                DDrPatch_Byte  (OniExe + 0x0002e48c, 0xeb);
147 >                DDrPatch_Byte  (OniExe + 0x0002e4d0, 0xeb);
148 >                DDrPatch_Byte  (OniExe + 0x0002e4f4, 0xeb);
149 >                DDrPatch_Byte  (OniExe + 0x0002e646, 0xeb);
150 >                DDrPatch_Byte  (OniExe + 0x0002e695, 0xeb);
151 >                DDrPatch_Byte  (OniExe + 0x0002e944, 0xeb);
152 >                DDrPatch_Byte  (OniExe + 0x0002e95d, 0xeb);
153 >                DDrPatch_Byte  (OniExe + 0x0002e98e, 0xeb);
154 >                DDrPatch_Byte  (OniExe + 0x0002e9dc, 0xeb);
155 >        }
156 >        
157 >        // Cheat table patch
158 >        if (patch_cheattable)
159 >        {
160 >                DDrPatch_Int32 (OniExe + 0x000f616b, (int)&DDr_CheatTable[0].name);
161 >                DDrPatch_Int32 (OniExe + 0x000f617a, (int)&DDr_CheatTable[0].message_on);
162 >        }
163 >        
164 >        if (patch_argb8888)
165 >        {
166 >                DDrPatch_Byte  (OniExe + 0x00135af0, 0x07);
167 >                DDrPatch_Byte  (OniExe + 0x00135af4, 0x0B);
168 >        }
169          
170          return true;
171   }
172  
173 + enum {s_unknown, s_options, s_patch, s_bsl, s_language} ini_section;
174 +
175 + bool DDrIniCallback(char* section, bool newsection, char* name, char* value)
176 + {
177 +        if (newsection)
178 +        {
179 +                if (!stricmp(section, "options"))
180 +                        ini_section = s_options;
181 +                else if (!stricmp(section, "patch"))
182 +                        ini_section = s_patch;
183 +                else if (!stricmp(section, "bsl"))
184 +                        ini_section = s_bsl;
185 +                else if (!stricmp(section, "language"))
186 +                        ini_section = s_language;
187 +                else
188 +                {
189 +                        ini_section = s_unknown;
190 +                        DDrStartupMessage("unrecognised ini section \"%s\"", section);
191 +                }
192 +        }
193 +        
194 +        switch (ini_section)
195 +        {
196 +                case s_options:
197 +                        if (!stricmp(name, "usedaodanbsl"))
198 +                                opt_usedaodanbsl = !stricmp(inifile_cleanstr(value), "true");
199 +                        break;
200 +                case s_patch:
201 +                        if (!stricmp(name, "fonttexturecache"))
202 +                                patch_fonttexturecache = !stricmp(inifile_cleanstr(value), "true");
203 +                        else if (!stricmp(name, "largetextures"))
204 +                                patch_largetextures = !stricmp(inifile_cleanstr(value), "true");
205 +                        else if (!stricmp(name, "levelplugins"))
206 +                                patch_levelplugins = !stricmp(inifile_cleanstr(value), "true");
207 +                        else if (!stricmp(name, "pathfinding"))
208 +                                patch_pathfinding = !stricmp(inifile_cleanstr(value), "true");
209 +                        else if (!stricmp(name, "projaware"))
210 +                                patch_projaware = !stricmp(inifile_cleanstr(value), "true");
211 +                        else if (!stricmp(name, "directinput"))
212 +                                patch_directinput = !stricmp(inifile_cleanstr(value), "true");
213 +                        else if (!stricmp(name, "wpfadetime"))
214 +                                patch_wpfadetime = !stricmp(inifile_cleanstr(value), "true");
215 +                        else if (!stricmp(name, "kickguns"))
216 +                                patch_kickguns = !stricmp(inifile_cleanstr(value), "true");
217 +                        else if (!stricmp(name, "cooldowntimer"))
218 +                                patch_cooldowntimer = !stricmp(inifile_cleanstr(value), "true");
219 +                        else if (!stricmp(name, "throwtest"))
220 +                                patch_throwtest = !stricmp(inifile_cleanstr(value), "true");
221 +                        else if (!stricmp(name, "alttab"))
222 +                                patch_alttab = !stricmp(inifile_cleanstr(value), "true");
223 +                        else if (!stricmp(name, "particledisablebit"))
224 +                                patch_particledisablebit = !stricmp(inifile_cleanstr(value), "true");
225 +                        else if (!stricmp(name, "multibyte"))
226 +                                patch_multibyte = !stricmp(inifile_cleanstr(value), "true");
227 +                        else if (!stricmp(name, "cheattable"))
228 +                                patch_cheattable = !stricmp(inifile_cleanstr(value), "true");
229 +                        else if (!stricmp(name, "argb8888"))
230 +                                patch_argb8888 = !stricmp(inifile_cleanstr(value), "true");
231 +                        else if (!stricmp(name, "safeprintf"))
232 +                                patch_safeprintf = !stricmp(inifile_cleanstr(value), "true");
233 +                        else if (!stricmp(name, "daodandisplayenum"))
234 +                                patch_daodandisplayenum = !stricmp(inifile_cleanstr(value), "true");
235 +                        else if (!stricmp(name, "usegettickcount"))
236 +                                patch_usegettickcount = !stricmp(inifile_cleanstr(value), "true");
237 +                        else if (!stricmp(name, "cheatsenabled"))
238 +                                patch_cheatsenabled = !stricmp(inifile_cleanstr(value), "true");
239 +                        else if (!stricmp(name, "usedaodangl"))
240 +                                patch_usedaodangl = !stricmp(inifile_cleanstr(value), "true");
241 +                        else if (!stricmp(name, "windowhack"))
242 +                                patch_windowhack = !stricmp(inifile_cleanstr(value), "true");
243 +                        else if (!stricmp(name, "daodaninit"))
244 +                                patch_daodaninit = !stricmp(inifile_cleanstr(value), "true");
245 +                        else if (!stricmp(name, "bsl"))
246 +                                patch_bsl = !stricmp(inifile_cleanstr(value), "true");
247 +                        else if (!stricmp(name, "cheater"))
248 +                                patch_cheater = !stricmp(inifile_cleanstr(value), "true");
249 +                        else
250 +                                DDrStartupMessage("unrecognised patch \"%s\"", name);
251 +                        break;
252 +                case s_language:
253 +                        if (!stricmp(name, "savepoint"))
254 +                        {
255 +                                char* str = strdup(value);
256 +                                DDrPatch_Int32(OniExe + 0x000fd730, (int)str);
257 +                                DDrPatch_Int32(OniExe + 0x000fd738, (int)str);
258 +                        }
259 +                        else if (!stricmp(name, "syndicatewarehouse"))
260 +                        {
261 +                                char* str = strdup(value);
262 +                                DDrPatch_Int32(OniExe + 0x000fd71a, (int)str);
263 +                                DDrPatch_Int32(OniExe + 0x0010ef75, (int)str);
264 +                        }
265 +                        else if (!stricmp(name, "damn"))
266 +                                DDrPatch_StrDup(OniExe + 0x0010fb6e, value);
267 +                        else if (!stricmp(name, "blam"))
268 +                                DDrPatch_StrDup(OniExe + 0x0010fb73, value);
269 +                        else if (!stricmp(name, "shapeshifter_on"))
270 +                                DDr_CheatTable[0].message_on = strdup(value);
271 +                        else if (!stricmp(name, "shapeshifter_off"))
272 +                                DDr_CheatTable[0].message_off = strdup(value);
273 +                        else if (!stricmp(name, "liveforever_on"))
274 +                                DDr_CheatTable[1].message_on = strdup(value);
275 +                        else if (!stricmp(name, "liveforever_off"))
276 +                                DDr_CheatTable[1].message_off = strdup(value);
277 +                        else if (!stricmp(name, "touchofdeath_on"))
278 +                                DDr_CheatTable[2].message_on = strdup(value);
279 +                        else if (!stricmp(name, "touchofdeath_off"))
280 +                                DDr_CheatTable[2].message_off = strdup(value);
281 +                        else if (!stricmp(name, "canttouchthis_on"))
282 +                                DDr_CheatTable[3].message_on = strdup(value);
283 +                        else if (!stricmp(name, "canttouchthis_off"))
284 +                                DDr_CheatTable[3].message_off = strdup(value);
285 +                        else if (!stricmp(name, "fatloot_on"))
286 +                                DDr_CheatTable[4].message_on = strdup(value);
287 +                        else if (!stricmp(name, "glassworld_on"))
288 +                                DDr_CheatTable[5].message_on = strdup(value);
289 +                        else if (!stricmp(name, "glassworld_off"))
290 +                                DDr_CheatTable[5].message_off = strdup(value);
291 +                        else if (!stricmp(name, "winlevel_on"))
292 +                                DDr_CheatTable[6].message_on = strdup(value);
293 +                        else if (!stricmp(name, "loselevel_on"))
294 +                                DDr_CheatTable[7].message_on = strdup(value);
295 +                        else if (!stricmp(name, "bighead_on"))
296 +                                DDr_CheatTable[8].message_on = strdup(value);
297 +                        else if (!stricmp(name, "bighead_off"))
298 +                                DDr_CheatTable[8].message_off = strdup(value);
299 +                        else if (!stricmp(name, "minime_on"))
300 +                                DDr_CheatTable[9].message_on = strdup(value);
301 +                        else if (!stricmp(name, "minime_off"))
302 +                                DDr_CheatTable[9].message_off = strdup(value);
303 +                        else if (!stricmp(name, "superammo_on"))
304 +                                DDr_CheatTable[10].message_on = strdup(value);
305 +                        else if (!stricmp(name, "superammo_off"))
306 +                                DDr_CheatTable[10].message_off = strdup(value);
307 +                        else if (!stricmp(name, "devmode_on"))
308 +                        {
309 +                                char* str = strdup(value);
310 +                                DDr_CheatTable[11].message_on = str;
311 +                                DDr_CheatTable[cheat_x].message_on = str;
312 +                        }
313 +                        else if (!stricmp(name, "devmode_off"))
314 +                        {
315 +                                char* str = strdup(value);
316 +                                DDr_CheatTable[11].message_off = str;
317 +                                DDr_CheatTable[cheat_x].message_off = str;
318 +                        }
319 +                        else if (!stricmp(name, "reservoirdogs_on"))
320 +                                DDr_CheatTable[12].message_on = strdup(value);
321 +                        else if (!stricmp(name, "reservoirdogs_off"))
322 +                                DDr_CheatTable[12].message_off = strdup(value);
323 +                        else if (!stricmp(name, "roughjustice_on"))
324 +                                DDr_CheatTable[13].message_on = strdup(value);
325 +                        else if (!stricmp(name, "roughjustice_off"))
326 +                                DDr_CheatTable[13].message_off = strdup(value);
327 +                        else if (!stricmp(name, "chenille_on"))
328 +                                DDr_CheatTable[14].message_on = strdup(value);
329 +                        else if (!stricmp(name, "chenille_off"))
330 +                                DDr_CheatTable[14].message_off = strdup(value);
331 +                        else if (!stricmp(name, "behemoth_on"))
332 +                                DDr_CheatTable[15].message_on = strdup(value);
333 +                        else if (!stricmp(name, "behemoth_off"))
334 +                                DDr_CheatTable[15].message_off = strdup(value);
335 +                        else if (!stricmp(name, "elderrune_on"))
336 +                                DDr_CheatTable[16].message_on = strdup(value);
337 +                        else if (!stricmp(name, "elderrune_off"))
338 +                                DDr_CheatTable[16].message_off = strdup(value);
339 +                        else if (!stricmp(name, "moonshadow_on"))
340 +                                DDr_CheatTable[17].message_on = strdup(value);
341 +                        else if (!stricmp(name, "moonshadow_off"))
342 +                                DDr_CheatTable[17].message_off = strdup(value);
343 +                        else if (!stricmp(name, "munitionfrenzy_on"))
344 +                                DDr_CheatTable[18].message_on = strdup(value);
345 +                        else if (!stricmp(name, "fistsoflegend_on"))
346 +                                DDr_CheatTable[19].message_on = strdup(value);
347 +                        else if (!stricmp(name, "fistsoflegend_off"))
348 +                                DDr_CheatTable[19].message_off = strdup(value);
349 +                        else if (!stricmp(name, "killmequick_on"))
350 +                                DDr_CheatTable[20].message_on = strdup(value);
351 +                        else if (!stricmp(name, "killmequick_off"))
352 +                                DDr_CheatTable[20].message_off = strdup(value);
353 +                        else if (!stricmp(name, "carousel_on"))
354 +                                DDr_CheatTable[21].message_on = strdup(value);
355 +                        else if (!stricmp(name, "carousel_off"))
356 +                                DDr_CheatTable[21].message_off = strdup(value);
357 +                        else
358 +                                DDrStartupMessage("unrecognised language item \"%s\"", name);
359 +                        break;
360 +                case s_bsl:
361 +                default:
362 +                        break;
363 +        }
364 +        
365 +        return true;
366 + }
367 +
368 + void DDrConfig()
369 + {
370 +        if (GetFileAttributes("daodan.ini") == INVALID_FILE_ATTRIBUTES)
371 +        {
372 +                DDrStartupMessage("daodan.ini doesn't exist, creating");
373 +                FILE* fp = fopen("daodan.ini", "w");
374 +                if (fp)
375 +                {
376 +                        fputs("[Options]\n", fp);
377 +                        fclose(fp);
378 +                }
379 +        }
380 +        
381 +        DDrStartupMessage("parsing daodan.ini...");
382 +        if (!inifile_read("daodan.ini", DDrIniCallback))
383 +                DDrStartupMessage("error reading daodan.ini, check your syntax!");
384 +        DDrStartupMessage("finished parsing");
385 + }
386 +
387 + void ONICALL DDrGame_Init()
388 + {
389 +        if (opt_usedaodanbsl)
390 +                SLrDaodan_Initalize();
391 + }
392 +
393   void __cdecl DDrMain(int argc, char* argv[])
394   {
395 +        DDrStartupMessage("daodan attached!");
396 +        DDrConfig();
397          DDrPatch_Init();
398          
399          // Safe startup message printer
400 <        DDrPatch_MakeJump(UUrStartupMessage, DDrStartupMessage);
400 >        if (patch_safeprintf)
401 >                DDrPatch_MakeJump(UUrStartupMessage, DDrStartupMessage);
402          
403          // Daodan device mode enumeration function
404 <        DDrPatch_MakeJump(gl_enumerate_valid_display_modes, daodan_enumerate_valid_display_modes);
404 >        if (patch_daodandisplayenum)
405 >                DDrPatch_MakeJump(gl_enumerate_valid_display_modes, daodan_enumerate_valid_display_modes);
406          
407          // Performance patch
408 <        DDrPatch_MakeJump(UUrMachineTime_High, DDrMachineTime_High);
409 <        DDrPatch_MakeJump(UUrMachineTime_High_Frequency, DDrMachineTime_High_Frequency);
410 <        DDrPatch_MakeJump(UUrMachineTime_Sixtieths, DDrMachineTime_Sixtieths);
408 >        if (patch_usegettickcount)
409 >        {
410 >                DDrPatch_MakeJump(UUrMachineTime_High, DDrMachineTime_High);
411 >                DDrPatch_MakeJump(UUrMachineTime_High_Frequency, DDrMachineTime_High_Frequency);
412 >                DDrPatch_MakeJump(UUrMachineTime_Sixtieths, DDrMachineTime_Sixtieths);
413 >        }
414 >        
415 >        // Cheats always enabled
416 >        if (patch_cheatsenabled)
417 >                DDrPatch_MakeJump(ONrPersist_GetWonGame, DDrPersist_GetWonGame);
418          
419          // Windowed mode
420 < //      DDrPatch_MakeJump(ONrPlatform_Initialize, DDrPlatform_Initialize);
421 < //      DDrPatch_MakeJump(gl_platform_initialize, daodangl_platform_initialize);
420 >        if (patch_usedaodangl)
421 >        {
422 >                DDrPatch_MakeJump(ONrPlatform_Initialize, DDrPlatform_Initialize);
423 >                DDrPatch_MakeJump(gl_platform_initialize, daodangl_platform_initialize);
424 >        }
425 >        
426 >        // Hacked windowed mode (for when daodangl isn't working properly)
427 >        if (patch_windowhack)
428 >                DDrWindowHack_Install();
429 >        
430 >        if (patch_daodaninit)
431 >                DDrPatch_MakeCall(OniExe + 0x000d345a, DDrGame_Init);
432 >        
433 >        // Patches for existing BSL functions
434 >        if (patch_bsl)
435 >                SLrDaodan_Patch();
436 >        
437 >        if (patch_cheater)
438 >                DDrPatch_MakeCall(OniExe + 0x000f618f, DDrCheater);
439          
440 < //      init_daodan_gl();
440 >        init_daodan_gl();
441          
442          ONiMain(argc, argv);
443   }

Diff Legend

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