source: Daodan/src/Daodan.c@ 586

Last change on this file since 586 was 476, checked in by gumby, 15 years ago

Added Weapon information for dropped weapons
Started on adding new dsay colors

File size: 20.3 KB
RevLine 
[346]1#include <string.h>
2
[272]3#include "Daodan.h"
4#include "Daodan_Patch.h"
5#include "Daodan_Utility.h"
[323]6#include "Daodan_Win32.h"
[339]7#include "Daodan_Cheater.h"
8#include "Daodan_Persistence.h"
[439]9#include "Daodan_BSL.h"
[476]10#include "Daodan_Console.h"
[272]11
[349]12#include "Daodan_WindowHack.h"
13
[273]14#include "Oni.h"
[339]15#include "Oni_Persistence.h"
16
[272]17#include "BFW_Utility.h"
18
[297]19#include "oni_gl.h"
20#include "daodan_gl.h"
21
[346]22#include "inifile.h"
23
[272]24HMODULE DDrDLLModule;
25HMODULE DDrONiModule;
26
[347]27bool patch_fonttexturecache = true;
28bool patch_largetextures = true;
[349]29bool patch_levelplugins = true;
[347]30bool patch_pathfinding = true;
31bool patch_projaware = true;
[348]32bool patch_directinput = true;
[347]33bool patch_wpfadetime = true;
34bool patch_kickguns = false;
35bool patch_cooldowntimer = true;
36bool patch_throwtest = false;
37bool patch_alttab = true;
38bool patch_particledisablebit = false;
[422]39bool patch_multibyte = false;
[347]40bool patch_cheattable = true;
[426]41bool patch_argb8888 = true;
[459]42bool patch_killvtune = true;
[466]43bool patch_getcmdline = true;
44bool patch_disablecmdline = true;
[347]45
46bool patch_safeprintf = true;
47bool patch_daodandisplayenum = true;
48bool patch_usegettickcount = true;
[348]49bool patch_cheatsenabled = true;
[473]50bool patch_usedaodangl = true;
51bool patch_windowhack = false;
[439]52bool patch_daodaninit = true;
[447]53bool patch_bsl = true;
[452]54bool patch_cheater = true;
[347]55
[474]56// bool patch_newweapon = true;
[473]57
[439]58bool opt_usedaodanbsl = true;
[468]59bool opt_border = true;
[474]60bool opt_shadow = false;
[468]61bool opt_topmost = false;
[439]62
[272]63bool DDrPatch_Init()
64{
[346]65 DDrStartupMessage("patching engine");
[342]66
[272]67 // Font texture cache doubled
[347]68 if (patch_fonttexturecache)
69 {
70 DDrPatch_Byte (OniExe + 0x00020ea7, 0x20);
71 DDrPatch_Byte (OniExe + 0x00020f4a, 0x40);
72 }
[272]73
74 // Now supports textures up to 512x512
[347]75 if (patch_largetextures)
76 DDrPatch_Byte (OniExe + 0x00005251, 0x10);
[272]77
78 // Non-"_Final" levels are now valid
[348]79 if (patch_levelplugins)
80 DDrPatch_Byte (OniExe + 0x000206a8, 0x01);
[272]81
82 // Pathfinding grid cache size x8
[347]83 if (patch_pathfinding)
84 {
85 DDrPatch_Byte (OniExe + 0x0010b03b, 0x20);
86 DDrPatch_Byte (OniExe + 0x0010b04c, 0x20);
87 }
[272]88
89 // Projectile awareness fixed
[347]90 if (patch_projaware)
91 {
92 DDrPatch_Byte (OniExe + 0x0009c07c, 0x6c);
93 DDrPatch_Byte (OniExe + 0x0009c080, 0x70);
94 DDrPatch_Byte (OniExe + 0x0009c084, 0x74);
95 DDrPatch_Byte (OniExe + 0x0009c110, 0x6c);
96 }
[272]97
98 // Forced DirectInput (for Windows NT)
[348]99 if (patch_directinput)
100 DDrPatch_Byte (OniExe + 0x00002e6d, 0xeb);
[272]101
[347]102 if (patch_wpfadetime)
103 {
104 // Makes wp_fadetime actually have a function
105 const char fadetime_patch[] = { 0x66, 0x8B, 0x1D, 0xC4, 0x7D, 0x62, 0x00, 0x66, 0x89, 0x5E, 0x46, 0x5B, 0x5E, 0x83, 0xC4, 0x14, 0xC3 };
106 DDrPatch_Const (OniExe + 0x0011a889, fadetime_patch);
107 DDrPatch_Byte (OniExe + 0x0011a560, 0x31);
108
109 // Sets the fadetime to 4800 by default
110 DDrPatch_Int16 (OniExe + 0x0011ab0e, 0x12c0);
111 }
[272]112
113
114 // Hackish fix for Konoko not kicking guns
[347]115 if (patch_kickguns)
116 {
117 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 };
118 DDrPatch_Const (OniExe + 0x000dc420, kickgun_patch);
119 }
[272]120
121 // Cooldown timer exploit fix ^_^
[347]122 if (patch_cooldowntimer)
123 {
124 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 };
125 DDrPatch_Const (OniExe + 0x0011a825, cooldown_patch);
126 }
[272]127
[347]128 if (patch_throwtest)
129 {
130 const char throwtest_patch[] = { 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 };
131 DDrPatch_Const(OniExe + 0x000dc190, throwtest_patch);
132 }
[272]133
[322]134 // 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.
[347]135 if (patch_alttab)
136 {
137 DDrPatch_Byte ((void*)UUrPlatform_Initialize, 0xC3);
138 DDrPatch_Byte ((void*)UUrPlatform_Terminate, 0xC3);
139 }
[322]140
141 // 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.)
[347]142 if (patch_particledisablebit)
143 DDrPatch_Int16 (OniExe + 0x001b184, 0x9090);
[322]144
[329]145 // Multi-byte patch (multiple language support)
[422]146 if (!patch_multibyte)
[347]147 {
148 DDrPatch_Byte (OniExe + 0x0002d8f8, 0xeb);
149 DDrPatch_Byte (OniExe + 0x0002d9ad, 0xeb);
150 DDrPatch_Byte (OniExe + 0x0002dbe2, 0xeb);
151 DDrPatch_Byte (OniExe + 0x0002dec3, 0xeb);
152 DDrPatch_Byte (OniExe + 0x0002e2ab, 0xeb);
153 DDrPatch_Byte (OniExe + 0x0002e2c4, 0xeb);
154 DDrPatch_Byte (OniExe + 0x0002e379, 0xeb);
155 DDrPatch_Byte (OniExe + 0x0002e48c, 0xeb);
156 DDrPatch_Byte (OniExe + 0x0002e4d0, 0xeb);
157 DDrPatch_Byte (OniExe + 0x0002e4f4, 0xeb);
158 DDrPatch_Byte (OniExe + 0x0002e646, 0xeb);
159 DDrPatch_Byte (OniExe + 0x0002e695, 0xeb);
160 DDrPatch_Byte (OniExe + 0x0002e944, 0xeb);
161 DDrPatch_Byte (OniExe + 0x0002e95d, 0xeb);
162 DDrPatch_Byte (OniExe + 0x0002e98e, 0xeb);
163 DDrPatch_Byte (OniExe + 0x0002e9dc, 0xeb);
164 }
[329]165
[339]166 // Cheat table patch
[347]167 if (patch_cheattable)
168 {
169 DDrPatch_Int32 (OniExe + 0x000f616b, (int)&DDr_CheatTable[0].name);
170 DDrPatch_Int32 (OniExe + 0x000f617a, (int)&DDr_CheatTable[0].message_on);
171 }
[339]172
[459]173 // ARGB8888 textures
[426]174 if (patch_argb8888)
175 {
176 DDrPatch_Byte (OniExe + 0x00135af0, 0x07);
177 DDrPatch_Byte (OniExe + 0x00135af4, 0x0B);
178 }
[473]179
180 //Test newweap patch
181// if (patch_newweapon) {
[476]182
183 //Makes it always say "Recieved weapon_name."
184 //Needs check for loc_4DFC66
185 DDrPatch_NOOP( OniExe + 0x000E4DF8,2);
186
187 //Adds Weapon name and ammo meter to pickup autoprompt
188 DDrPatch_NOOP( OniExe + 0x000FAC73, 9);
189 DDrPatch_NOOP( OniExe + 0x000FAC80, 5);
190 DDrPatch_MakeCall( OniExe + 0xFAC85, DDrWeapon2Message);
191
192 //Moves location of colors
193 DDrPatch_Int32( OniExe + 0x0002E3D5, (int)&DDrDSayColors[0].Char );
194 DDrPatch_Int32( OniExe + 0x0002E3DA, (int)&DDrDSayColors[0].Char );
[473]195// }
[426]196
[459]197 // Disable loading the vtuneapi.dll
198 if (patch_killvtune)
199 DDrPatch_Byte (OniExe + 0x00026340, 0xC3);
200
[466]201 // Disable Oni's internal CLrGetCommandLine function (to eventually replace it with our own)
202 if (patch_getcmdline)
203 DDrPatch_NOOP (OniExe + 0x000d3280, 51);
204
205 // Disable Oni's command line parser so it doesn't interfere with ours
206 if (patch_disablecmdline)
207 DDrPatch_Int32 (OniExe + 0x000d3570, 0xc3c03366);
208
[272]209 return true;
210}
211
[445]212enum {s_unknown, s_options, s_patch, s_bsl, s_language} ini_section;
[346]213
214bool DDrIniCallback(char* section, bool newsection, char* name, char* value)
215{
216 if (newsection)
217 {
[439]218 if (!stricmp(section, "options"))
219 ini_section = s_options;
220 else if (!stricmp(section, "patch"))
[347]221 ini_section = s_patch;
[445]222 else if (!stricmp(section, "bsl"))
223 ini_section = s_bsl;
[347]224 else if (!stricmp(section, "language"))
[346]225 ini_section = s_language;
226 else
227 {
228 ini_section = s_unknown;
[466]229 DDrStartupMessage("unrecognised section \"%s\"", section);
[346]230 }
231 }
232
233 switch (ini_section)
234 {
[439]235 case s_options:
236 if (!stricmp(name, "usedaodanbsl"))
[451]237 opt_usedaodanbsl = !stricmp(inifile_cleanstr(value), "true");
[468]238 else if (!stricmp(name, "border"))
239 opt_border = !stricmp(inifile_cleanstr(value), "true");
240 else if (!stricmp(name, "shadow"))
241 opt_shadow = !stricmp(inifile_cleanstr(value), "true");
242 else if (!stricmp(name, "topmost"))
243 opt_topmost = !stricmp(inifile_cleanstr(value), "true");
244 else if (!stricmp(name, "multibyte"))
245 patch_multibyte = !stricmp(inifile_cleanstr(value), "true");
[466]246 else if (!stricmp(name, "debug"))
247 AKgDebug_DebugMaps = !stricmp(inifile_cleanstr(value), "true");
248 else if (!stricmp(name, "debugfiles"))
249 BFgDebugFileEnable = !stricmp(inifile_cleanstr(value), "true");
250 else if (!stricmp(name, "findsounds"))
251 SSgSearchOnDisk = !stricmp(inifile_cleanstr(value), "true");
252 else if (!stricmp(name, "ignore_private_data"))
253 opt_ignore_private_data = !stricmp(inifile_cleanstr(value), "true");
254 else if (!stricmp(name, "sound"))
255 opt_sound = !stricmp(inifile_cleanstr(value), "true");
256 else if (!stricmp(name, "switch"))
257 M3gResolutionSwitch = !stricmp(inifile_cleanstr(value), "true");
258 else
259 DDrStartupMessage("unrecognised option \"%s\"", name);
[439]260 break;
[347]261 case s_patch:
262 if (!stricmp(name, "fonttexturecache"))
[451]263 patch_fonttexturecache = !stricmp(inifile_cleanstr(value), "true");
[347]264 else if (!stricmp(name, "largetextures"))
[451]265 patch_largetextures = !stricmp(inifile_cleanstr(value), "true");
[349]266 else if (!stricmp(name, "levelplugins"))
[451]267 patch_levelplugins = !stricmp(inifile_cleanstr(value), "true");
[347]268 else if (!stricmp(name, "pathfinding"))
[451]269 patch_pathfinding = !stricmp(inifile_cleanstr(value), "true");
[347]270 else if (!stricmp(name, "projaware"))
[451]271 patch_projaware = !stricmp(inifile_cleanstr(value), "true");
[348]272 else if (!stricmp(name, "directinput"))
[451]273 patch_directinput = !stricmp(inifile_cleanstr(value), "true");
[347]274 else if (!stricmp(name, "wpfadetime"))
[451]275 patch_wpfadetime = !stricmp(inifile_cleanstr(value), "true");
[347]276 else if (!stricmp(name, "kickguns"))
[451]277 patch_kickguns = !stricmp(inifile_cleanstr(value), "true");
[347]278 else if (!stricmp(name, "cooldowntimer"))
[451]279 patch_cooldowntimer = !stricmp(inifile_cleanstr(value), "true");
[347]280 else if (!stricmp(name, "throwtest"))
[451]281 patch_throwtest = !stricmp(inifile_cleanstr(value), "true");
[347]282 else if (!stricmp(name, "alttab"))
[451]283 patch_alttab = !stricmp(inifile_cleanstr(value), "true");
[347]284 else if (!stricmp(name, "particledisablebit"))
[451]285 patch_particledisablebit = !stricmp(inifile_cleanstr(value), "true");
[347]286 else if (!stricmp(name, "multibyte"))
[451]287 patch_multibyte = !stricmp(inifile_cleanstr(value), "true");
[347]288 else if (!stricmp(name, "cheattable"))
[451]289 patch_cheattable = !stricmp(inifile_cleanstr(value), "true");
[426]290 else if (!stricmp(name, "argb8888"))
[451]291 patch_argb8888 = !stricmp(inifile_cleanstr(value), "true");
[459]292 else if (!stricmp(name, "killvtune"))
293 patch_killvtune = !stricmp(inifile_cleanstr(value), "true");
[466]294 else if (!stricmp(name, "getcmdline"))
295 patch_getcmdline = !stricmp(inifile_cleanstr(value), "true");
296 else if (!stricmp(name, "disablecmdline"))
297 patch_disablecmdline = !stricmp(inifile_cleanstr(value), "true");
[347]298 else if (!stricmp(name, "safeprintf"))
[451]299 patch_safeprintf = !stricmp(inifile_cleanstr(value), "true");
[347]300 else if (!stricmp(name, "daodandisplayenum"))
[451]301 patch_daodandisplayenum = !stricmp(inifile_cleanstr(value), "true");
[347]302 else if (!stricmp(name, "usegettickcount"))
[451]303 patch_usegettickcount = !stricmp(inifile_cleanstr(value), "true");
[348]304 else if (!stricmp(name, "cheatsenabled"))
[451]305 patch_cheatsenabled = !stricmp(inifile_cleanstr(value), "true");
[347]306 else if (!stricmp(name, "usedaodangl"))
[451]307 patch_usedaodangl = !stricmp(inifile_cleanstr(value), "true");
[349]308 else if (!stricmp(name, "windowhack"))
[451]309 patch_windowhack = !stricmp(inifile_cleanstr(value), "true");
[439]310 else if (!stricmp(name, "daodaninit"))
[451]311 patch_daodaninit = !stricmp(inifile_cleanstr(value), "true");
[447]312 else if (!stricmp(name, "bsl"))
[451]313 patch_bsl = !stricmp(inifile_cleanstr(value), "true");
[452]314 else if (!stricmp(name, "cheater"))
315 patch_cheater = !stricmp(inifile_cleanstr(value), "true");
[347]316 else
317 DDrStartupMessage("unrecognised patch \"%s\"", name);
318 break;
[346]319 case s_language:
320 if (!stricmp(name, "savepoint"))
321 {
[347]322 char* str = strdup(value);
323 DDrPatch_Int32(OniExe + 0x000fd730, (int)str);
324 DDrPatch_Int32(OniExe + 0x000fd738, (int)str);
[346]325 }
326 else if (!stricmp(name, "syndicatewarehouse"))
327 {
[347]328 char* str = strdup(value);
329 DDrPatch_Int32(OniExe + 0x000fd71a, (int)str);
330 DDrPatch_Int32(OniExe + 0x0010ef75, (int)str);
[346]331 }
[347]332 else if (!stricmp(name, "damn"))
333 DDrPatch_StrDup(OniExe + 0x0010fb6e, value);
[346]334 else if (!stricmp(name, "blam"))
335 DDrPatch_StrDup(OniExe + 0x0010fb73, value);
[348]336 else if (!stricmp(name, "shapeshifter_on"))
337 DDr_CheatTable[0].message_on = strdup(value);
338 else if (!stricmp(name, "shapeshifter_off"))
339 DDr_CheatTable[0].message_off = strdup(value);
340 else if (!stricmp(name, "liveforever_on"))
341 DDr_CheatTable[1].message_on = strdup(value);
342 else if (!stricmp(name, "liveforever_off"))
343 DDr_CheatTable[1].message_off = strdup(value);
344 else if (!stricmp(name, "touchofdeath_on"))
345 DDr_CheatTable[2].message_on = strdup(value);
346 else if (!stricmp(name, "touchofdeath_off"))
347 DDr_CheatTable[2].message_off = strdup(value);
348 else if (!stricmp(name, "canttouchthis_on"))
349 DDr_CheatTable[3].message_on = strdup(value);
350 else if (!stricmp(name, "canttouchthis_off"))
351 DDr_CheatTable[3].message_off = strdup(value);
352 else if (!stricmp(name, "fatloot_on"))
[349]353 DDr_CheatTable[4].message_on = strdup(value);
354 else if (!stricmp(name, "glassworld_on"))
355 DDr_CheatTable[5].message_on = strdup(value);
356 else if (!stricmp(name, "glassworld_off"))
357 DDr_CheatTable[5].message_off = strdup(value);
358 else if (!stricmp(name, "winlevel_on"))
359 DDr_CheatTable[6].message_on = strdup(value);
360 else if (!stricmp(name, "loselevel_on"))
361 DDr_CheatTable[7].message_on = strdup(value);
362 else if (!stricmp(name, "bighead_on"))
363 DDr_CheatTable[8].message_on = strdup(value);
364 else if (!stricmp(name, "bighead_off"))
365 DDr_CheatTable[8].message_off = strdup(value);
366 else if (!stricmp(name, "minime_on"))
367 DDr_CheatTable[9].message_on = strdup(value);
368 else if (!stricmp(name, "minime_off"))
369 DDr_CheatTable[9].message_off = strdup(value);
370 else if (!stricmp(name, "superammo_on"))
371 DDr_CheatTable[10].message_on = strdup(value);
372 else if (!stricmp(name, "superammo_off"))
373 DDr_CheatTable[10].message_off = strdup(value);
374 else if (!stricmp(name, "devmode_on"))
375 {
376 char* str = strdup(value);
377 DDr_CheatTable[11].message_on = str;
[452]378 DDr_CheatTable[cheat_x].message_on = str;
[349]379 }
380 else if (!stricmp(name, "devmode_off"))
381 {
382 char* str = strdup(value);
383 DDr_CheatTable[11].message_off = str;
[452]384 DDr_CheatTable[cheat_x].message_off = str;
[349]385 }
386 else if (!stricmp(name, "reservoirdogs_on"))
387 DDr_CheatTable[12].message_on = strdup(value);
388 else if (!stricmp(name, "reservoirdogs_off"))
389 DDr_CheatTable[12].message_off = strdup(value);
390 else if (!stricmp(name, "roughjustice_on"))
391 DDr_CheatTable[13].message_on = strdup(value);
392 else if (!stricmp(name, "roughjustice_off"))
393 DDr_CheatTable[13].message_off = strdup(value);
394 else if (!stricmp(name, "chenille_on"))
395 DDr_CheatTable[14].message_on = strdup(value);
396 else if (!stricmp(name, "chenille_off"))
397 DDr_CheatTable[14].message_off = strdup(value);
398 else if (!stricmp(name, "behemoth_on"))
399 DDr_CheatTable[15].message_on = strdup(value);
400 else if (!stricmp(name, "behemoth_off"))
401 DDr_CheatTable[15].message_off = strdup(value);
402 else if (!stricmp(name, "elderrune_on"))
403 DDr_CheatTable[16].message_on = strdup(value);
404 else if (!stricmp(name, "elderrune_off"))
405 DDr_CheatTable[16].message_off = strdup(value);
406 else if (!stricmp(name, "moonshadow_on"))
407 DDr_CheatTable[17].message_on = strdup(value);
408 else if (!stricmp(name, "moonshadow_off"))
409 DDr_CheatTable[17].message_off = strdup(value);
410 else if (!stricmp(name, "munitionfrenzy_on"))
411 DDr_CheatTable[18].message_on = strdup(value);
412 else if (!stricmp(name, "fistsoflegend_on"))
413 DDr_CheatTable[19].message_on = strdup(value);
414 else if (!stricmp(name, "fistsoflegend_off"))
415 DDr_CheatTable[19].message_off = strdup(value);
416 else if (!stricmp(name, "killmequick_on"))
417 DDr_CheatTable[20].message_on = strdup(value);
418 else if (!stricmp(name, "killmequick_off"))
419 DDr_CheatTable[20].message_off = strdup(value);
420 else if (!stricmp(name, "carousel_on"))
421 DDr_CheatTable[21].message_on = strdup(value);
422 else if (!stricmp(name, "carousel_off"))
423 DDr_CheatTable[21].message_off = strdup(value);
[346]424 else
425 DDrStartupMessage("unrecognised language item \"%s\"", name);
426 break;
[451]427 case s_bsl:
[346]428 default:
429 break;
430 }
431
432 return true;
433}
434
435void DDrConfig()
436{
437 if (GetFileAttributes("daodan.ini") == INVALID_FILE_ATTRIBUTES)
438 {
439 DDrStartupMessage("daodan.ini doesn't exist, creating");
440 FILE* fp = fopen("daodan.ini", "w");
441 if (fp)
442 {
443 fputs("[Options]\n", fp);
444 fclose(fp);
445 }
446 }
447
448 DDrStartupMessage("parsing daodan.ini...");
449 if (!inifile_read("daodan.ini", DDrIniCallback))
450 DDrStartupMessage("error reading daodan.ini, check your syntax!");
451 DDrStartupMessage("finished parsing");
452}
453
[439]454void ONICALL DDrGame_Init()
455{
456 if (opt_usedaodanbsl)
457 SLrDaodan_Initalize();
458}
459
[274]460void __cdecl DDrMain(int argc, char* argv[])
[273]461{
[346]462 DDrStartupMessage("daodan attached!");
[466]463
464 opt_ignore_private_data = false;
465 opt_sound = true;
466
[346]467 DDrConfig();
[466]468 DDrStartupMessage("parsing command line...");
469 int i;
470 char* section;
471 char* option;
472 bool falseoption;
473 for (i = 1; i < argc; i ++)
474 {
475 if (argv[i][0] == '-')
476 {
477 section = argv[i] + 1;
478 if ((option = strchr(argv[i], '.')))
479 {
480 *option = '\0';
481 falseoption = (option[1] == 'n' || option[1] == 'N') && (option[2] = 'o' || option[2] == 'O');
482 if (i < (argc - 1) && argv[i + 1][0] != '-')
[467]483 DDrIniCallback(section, true, option + 1, argv[++i]);
[466]484 else
485 DDrIniCallback(section, true, option + (falseoption ? 3 : 1), (falseoption ? "false" : "true"));
486 *option = '.';
487 }
488 else
489 {
490 falseoption = (section[0] == 'n' || section[0] == 'N') && (section[1] = 'o' || section[1] == 'O');
491 ini_section = s_options;
492 if (i < (argc - 1) && argv[i + 1][0] != '-')
[467]493 DDrIniCallback(NULL, false, section, argv[++i]);
[466]494 else
495 DDrIniCallback(NULL, false, section + (falseoption ? 2 : 0), (falseoption ? "false" : "true"));
496 }
497 }
498 else
499 {
500 DDrStartupMessage("parse error \"%s\"", argv[i]);
501 break;
502 }
503 }
504 DDrStartupMessage("finished parsing");
[273]505 DDrPatch_Init();
506
507 // Safe startup message printer
[347]508 if (patch_safeprintf)
509 DDrPatch_MakeJump(UUrStartupMessage, DDrStartupMessage);
[273]510
[297]511 // Daodan device mode enumeration function
[347]512 if (patch_daodandisplayenum)
513 DDrPatch_MakeJump(gl_enumerate_valid_display_modes, daodan_enumerate_valid_display_modes);
[297]514
515 // Performance patch
[347]516 if (patch_usegettickcount)
517 {
518 DDrPatch_MakeJump(UUrMachineTime_High, DDrMachineTime_High);
519 DDrPatch_MakeJump(UUrMachineTime_High_Frequency, DDrMachineTime_High_Frequency);
520 DDrPatch_MakeJump(UUrMachineTime_Sixtieths, DDrMachineTime_Sixtieths);
521 }
[275]522
[339]523 // Cheats always enabled
[348]524 if (patch_cheatsenabled)
525 DDrPatch_MakeJump(ONrPersist_GetWonGame, DDrPersist_GetWonGame);
[339]526
[323]527 // Windowed mode
[347]528 if (patch_usedaodangl)
529 {
530 DDrPatch_MakeJump(ONrPlatform_Initialize, DDrPlatform_Initialize);
531 DDrPatch_MakeJump(gl_platform_initialize, daodangl_platform_initialize);
532 }
[323]533
[349]534 // Hacked windowed mode (for when daodangl isn't working properly)
535 if (patch_windowhack)
536 DDrWindowHack_Install();
537
[439]538 if (patch_daodaninit)
539 DDrPatch_MakeCall(OniExe + 0x000d345a, DDrGame_Init);
540
[447]541 // Patches for existing BSL functions
542 if (patch_bsl)
543 SLrDaodan_Patch();
544
[452]545 if (patch_cheater)
[455]546 {
[452]547 DDrPatch_MakeCall(OniExe + 0x000f618f, DDrCheater);
[455]548 DDrPatch_Int16(OniExe + 0x000deb45, 0x5590);
549 DDrPatch_MakeCall(OniExe + 0x000deb47, FallingFrames);
550 DDrPatch_MakeJump(OniExe + 0x0010f021, DDrCheater_LevelLoad);
551 }
[452]552
[340]553 init_daodan_gl();
[326]554
[273]555 ONiMain(argc, argv);
556}
[465]557/*
558void DDrWrongExe()
559{
560 switch (MessageBox(NULL, "This version of the Daodan DLL is incompatible with your Oni.exe.\n"
561 "Click OK for more information. To continue using Oni without the patch, replace the downloaded binkw32.dll with the original.", "Daodan", MB_OKCANCEL | MB_ICONERROR))
562 {
563 case IDOK:
564 {
565 STARTUPINFO si;
566 PROCESS_INFORMATION pi;
567 FillMemory(&si, 0, sizeof(si));
568 FillMemory(&pi, 0, sizeof(pi));
569 si.cb = sizeof(si);
570 if (!CreateProcess(NULL, "cmd /c \"start http://wiki.oni2.net/Daodan_DLL\"", NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
571 MessageBox(NULL, "", "", 0);
572 CloseHandle(pi.hProcess);
573 CloseHandle(pi.hThread);
574 }
575 default:
576 ExitProcess(0);
577 }
578}
579*/
[272]580BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved)
581{
582 switch (fdwReason)
583 {
584 case DLL_PROCESS_ATTACH:
585 DDrDLLModule = hinstDLL;
586 DDrONiModule = GetModuleHandle(NULL);
587
[465]588 if (*(uint32_t*)((void*)OniExe + 0x0011acd0) == 0x09d36852)
589 DDrPatch_MakeCall(OniExe + 0x0010fb49, DDrMain);
590 else
591 ExitProcess(0);
[272]592 break;
593 }
594 return TRUE;
595}
Note: See TracBrowser for help on using the repository browser.