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 347 by rossy, Tue Jun 9 12:42:24 2009 UTC vs.
Revision 447 by rossy, Tue Jul 21 03:33:07 2009 UTC

# Line 6 | Line 6
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"
# Line 22 | Line 25 | 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 = true;
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 +
51 + bool opt_usedaodanbsl = true;
52  
53   bool DDrPatch_Init()
54   {
# Line 54 | Line 66 | bool DDrPatch_Init()
66                  DDrPatch_Byte  (OniExe + 0x00005251, 0x10);
67          
68          // Non-"_Final" levels are now valid
69 <        DDrPatch_Byte  (OniExe + 0x000206a8, 0x01);
69 >        if (patch_levelplugins)
70 >                DDrPatch_Byte  (OniExe + 0x000206a8, 0x01);
71          
72          // Pathfinding grid cache size x8
73          if (patch_pathfinding)
# Line 73 | Line 86 | bool DDrPatch_Init()
86          }
87          
88          // Forced DirectInput (for Windows NT)
89 <        DDrPatch_Byte  (OniExe + 0x00002e6d, 0xeb);
89 >        if (patch_directinput)
90 >                DDrPatch_Byte  (OniExe + 0x00002e6d, 0xeb);
91          
92          if (patch_wpfadetime)
93          {
# Line 119 | Line 133 | bool DDrPatch_Init()
133                  DDrPatch_Int16 (OniExe + 0x001b184, 0x9090);
134          
135          // Multi-byte patch (multiple language support)
136 <        if (patch_multibyte)
136 >        if (!patch_multibyte)
137          {
138                  DDrPatch_Byte  (OniExe + 0x0002d8f8, 0xeb);
139                  DDrPatch_Byte  (OniExe + 0x0002d9ad, 0xeb);
# Line 146 | Line 160 | bool DDrPatch_Init()
160                  DDrPatch_Int32 (OniExe + 0x000f617a, (int)&DDr_CheatTable[0].message_on);
161          }
162          
163 +        if (patch_argb8888)
164 +        {
165 +                DDrPatch_Byte  (OniExe + 0x00135af0, 0x07);
166 +                DDrPatch_Byte  (OniExe + 0x00135af4, 0x0B);
167 +        }
168 +        
169          return true;
170   }
171  
172 < enum {s_unknown, s_patch, s_language} ini_section;
172 > enum {s_unknown, s_options, s_patch, s_bsl, s_language} ini_section;
173  
174   bool DDrIniCallback(char* section, bool newsection, char* name, char* value)
175   {
176          if (newsection)
177          {
178 <                if (!stricmp(section, "patch"))
178 >                if (!stricmp(section, "options"))
179 >                        ini_section = s_options;
180 >                else if (!stricmp(section, "patch"))
181                          ini_section = s_patch;
182 +                else if (!stricmp(section, "bsl"))
183 +                        ini_section = s_bsl;
184                  else if (!stricmp(section, "language"))
185                          ini_section = s_language;
186                  else
# Line 168 | Line 192 | bool DDrIniCallback(char* section, bool
192          
193          switch (ini_section)
194          {
195 +                case s_options:
196 +                        if (!stricmp(name, "usedaodanbsl"))
197 +                                opt_usedaodanbsl = !stricmp(value, "true");
198 +                        break;
199                  case s_patch:
200                          if (!stricmp(name, "fonttexturecache"))
201                                  patch_fonttexturecache = !stricmp(value, "true");
202                          else if (!stricmp(name, "largetextures"))
203                                  patch_largetextures = !stricmp(value, "true");
204 +                        else if (!stricmp(name, "levelplugins"))
205 +                                patch_levelplugins = !stricmp(value, "true");
206                          else if (!stricmp(name, "pathfinding"))
207                                  patch_pathfinding = !stricmp(value, "true");
208                          else if (!stricmp(name, "projaware"))
209                                  patch_projaware = !stricmp(value, "true");
210 +                        else if (!stricmp(name, "directinput"))
211 +                                patch_directinput = !stricmp(value, "true");
212                          else if (!stricmp(name, "wpfadetime"))
213                                  patch_wpfadetime = !stricmp(value, "true");
214                          else if (!stricmp(name, "kickguns"))
# Line 193 | Line 225 | bool DDrIniCallback(char* section, bool
225                                  patch_multibyte = !stricmp(value, "true");
226                          else if (!stricmp(name, "cheattable"))
227                                  patch_cheattable = !stricmp(value, "true");
228 +                        else if (!stricmp(name, "argb8888"))
229 +                                patch_argb8888 = !stricmp(value, "true");
230                          else if (!stricmp(name, "safeprintf"))
231                                  patch_safeprintf = !stricmp(value, "true");
232                          else if (!stricmp(name, "daodandisplayenum"))
233                                  patch_daodandisplayenum = !stricmp(value, "true");
234                          else if (!stricmp(name, "usegettickcount"))
235                                  patch_usegettickcount = !stricmp(value, "true");
236 +                        else if (!stricmp(name, "cheatsenabled"))
237 +                                patch_cheatsenabled = !stricmp(value, "true");
238                          else if (!stricmp(name, "usedaodangl"))
239                                  patch_usedaodangl = !stricmp(value, "true");
240 +                        else if (!stricmp(name, "windowhack"))
241 +                                patch_windowhack = !stricmp(value, "true");
242 +                        else if (!stricmp(name, "daodaninit"))
243 +                                patch_daodaninit = !stricmp(value, "true");
244 +                        else if (!stricmp(name, "bsl"))
245 +                                patch_bsl = !stricmp(value, "true");
246                          else
247                                  DDrStartupMessage("unrecognised patch \"%s\"", name);
248                          break;
249 +                case s_bsl:
250 +                        
251 +                        break;
252                  case s_language:
253                          if (!stricmp(name, "savepoint"))
254                          {
# Line 221 | Line 266 | bool DDrIniCallback(char* section, bool
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_devmodex].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_devmodex].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;
# Line 250 | Line 383 | void DDrConfig()
383          DDrStartupMessage("finished parsing");
384   }
385  
386 + void ONICALL DDrGame_Init()
387 + {
388 +        if (opt_usedaodanbsl)
389 +                SLrDaodan_Initalize();
390 + }
391 +
392   void __cdecl DDrMain(int argc, char* argv[])
393   {
394          DDrStartupMessage("daodan attached!");
# Line 273 | Line 412 | void __cdecl DDrMain(int argc, char* arg
412          }
413          
414          // Cheats always enabled
415 <        DDrPatch_MakeJump(ONrPersist_GetWonGame, DDrPersist_GetWonGame);
415 >        if (patch_cheatsenabled)
416 >                DDrPatch_MakeJump(ONrPersist_GetWonGame, DDrPersist_GetWonGame);
417          
418          // Windowed mode
419          if (patch_usedaodangl)
# Line 282 | Line 422 | void __cdecl DDrMain(int argc, char* arg
422                  DDrPatch_MakeJump(gl_platform_initialize, daodangl_platform_initialize);
423          }
424          
425 +        // Hacked windowed mode (for when daodangl isn't working properly)
426 +        if (patch_windowhack)
427 +                DDrWindowHack_Install();
428 +        
429 +        if (patch_daodaninit)
430 +                DDrPatch_MakeCall(OniExe + 0x000d345a, DDrGame_Init);
431 +        
432 +        // Patches for existing BSL functions
433 +        if (patch_bsl)
434 +                SLrDaodan_Patch();
435 +        
436          init_daodan_gl();
437          
438          ONiMain(argc, argv);

Diff Legend

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