[567] | 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 | #include "Daodan_Console.h"
|
---|
| 11 |
|
---|
[573] | 12 | #include "Flatline_BSL.h"
|
---|
| 13 | #include "Flatline_Hooks.h"
|
---|
[567] | 14 | #include "Daodan_WindowHack.h"
|
---|
| 15 |
|
---|
| 16 | #include "Oni.h"
|
---|
| 17 | #include "Oni_Persistence.h"
|
---|
| 18 |
|
---|
| 19 | #include "BFW_Utility.h"
|
---|
| 20 |
|
---|
| 21 | #include "oni_gl.h"
|
---|
| 22 | #include "daodan_gl.h"
|
---|
| 23 |
|
---|
| 24 | #include "inifile.h"
|
---|
| 25 |
|
---|
| 26 | HMODULE DDrDLLModule;
|
---|
| 27 | HMODULE DDrONiModule;
|
---|
| 28 |
|
---|
| 29 | bool patch_fonttexturecache = true;
|
---|
| 30 | bool patch_largetextures = true;
|
---|
| 31 | bool patch_levelplugins = true;
|
---|
| 32 | bool patch_pathfinding = true;
|
---|
| 33 | bool patch_projaware = true;
|
---|
| 34 | bool patch_directinput = true;
|
---|
| 35 | bool patch_wpfadetime = true;
|
---|
| 36 | bool patch_kickguns = false;
|
---|
| 37 | bool patch_cooldowntimer = true;
|
---|
| 38 | bool patch_throwtest = false;
|
---|
| 39 | bool patch_alttab = true;
|
---|
| 40 | bool patch_particledisablebit = false;
|
---|
| 41 | bool patch_multibyte = false;
|
---|
| 42 | bool patch_cheattable = true;
|
---|
| 43 | bool patch_argb8888 = true;
|
---|
| 44 | bool patch_killvtune = true;
|
---|
| 45 | bool patch_getcmdline = true;
|
---|
| 46 | bool patch_disablecmdline = true;
|
---|
| 47 |
|
---|
| 48 | bool patch_safeprintf = true;
|
---|
| 49 | bool patch_daodandisplayenum = true;
|
---|
| 50 | bool patch_usegettickcount = true;
|
---|
| 51 | bool patch_cheatsenabled = true;
|
---|
| 52 | bool patch_usedaodangl = true;
|
---|
| 53 | bool patch_windowhack = false;
|
---|
| 54 | bool patch_daodaninit = true;
|
---|
| 55 | bool patch_bsl = true;
|
---|
| 56 | bool patch_cheater = true;
|
---|
[572] | 57 | bool patch_newweapon = true;
|
---|
[567] | 58 | bool opt_usedaodanbsl = true;
|
---|
| 59 | bool opt_border = true;
|
---|
| 60 | bool opt_shadow = false;
|
---|
| 61 | bool opt_topmost = false;
|
---|
| 62 |
|
---|
| 63 | bool DDrPatch_Init()
|
---|
| 64 | {
|
---|
| 65 | DDrStartupMessage("patching engine");
|
---|
| 66 |
|
---|
| 67 | // Font texture cache doubled
|
---|
| 68 | if (patch_fonttexturecache)
|
---|
| 69 | {
|
---|
| 70 | DDrPatch_Byte(OniExe + 0x00020ea7, 0x20);
|
---|
| 71 | DDrPatch_Byte(OniExe + 0x00020f4a, 0x40);
|
---|
| 72 | }
|
---|
| 73 |
|
---|
| 74 | // Now supports textures up to 512x512
|
---|
| 75 | if (patch_largetextures)
|
---|
| 76 | DDrPatch_Byte (OniExe + 0x00005251, 0x10);
|
---|
| 77 |
|
---|
| 78 | // Non-"_Final" levels are now valid
|
---|
| 79 | if (patch_levelplugins)
|
---|
| 80 | DDrPatch_Byte (OniExe + 0x000206a8, 0x01);
|
---|
| 81 |
|
---|
| 82 | // Pathfinding grid cache size x8
|
---|
| 83 | if (patch_pathfinding)
|
---|
| 84 | {
|
---|
[569] | 85 | const char pathfinding[2] = {0x90 , 0xE9 };
|
---|
[567] | 86 | DDrPatch_Byte (OniExe + 0x0010b03b, 0x20);
|
---|
| 87 | DDrPatch_Byte (OniExe + 0x0010b04c, 0x20);
|
---|
[569] | 88 |
|
---|
| 89 | //other stuff
|
---|
| 90 | DDrPatch_Const(0x440789, pathfinding);
|
---|
[567] | 91 | }
|
---|
| 92 |
|
---|
| 93 | // Projectile awareness fixed
|
---|
| 94 | if (patch_projaware)
|
---|
| 95 | {
|
---|
| 96 | DDrPatch_Byte (OniExe + 0x0009c07c, 0x6c);
|
---|
| 97 | DDrPatch_Byte (OniExe + 0x0009c080, 0x70);
|
---|
| 98 | DDrPatch_Byte (OniExe + 0x0009c084, 0x74);
|
---|
| 99 | DDrPatch_Byte (OniExe + 0x0009c110, 0x6c);
|
---|
| 100 | }
|
---|
| 101 |
|
---|
| 102 | // Forced DirectInput (for Windows NT)
|
---|
| 103 | if (patch_directinput)
|
---|
| 104 | DDrPatch_Byte (OniExe + 0x00002e6d, 0xeb);
|
---|
[569] | 105 |
|
---|
[567] | 106 | if (patch_wpfadetime)
|
---|
| 107 | {
|
---|
| 108 | // Makes wp_fadetime actually have a function
|
---|
| 109 | const char fadetime_patch[] = { 0x66, 0x8B, 0x1D, 0xC4, 0x7D, 0x62, 0x00, 0x66, 0x89, 0x5E, 0x46, 0x5B, 0x5E, 0x83, 0xC4, 0x14, 0xC3 };
|
---|
| 110 | DDrPatch_Const (OniExe + 0x0011a889, fadetime_patch);
|
---|
| 111 | DDrPatch_Byte (OniExe + 0x0011a560, 0x31);
|
---|
| 112 |
|
---|
| 113 | // Sets the fadetime to 4800 by default
|
---|
| 114 | DDrPatch_Int16 ((OniExe + 0x0011ab0e), 0x12c0);
|
---|
| 115 | }
|
---|
| 116 |
|
---|
[569] | 117 | // FIXME: add switches
|
---|
| 118 | //pathfinding fix
|
---|
| 119 |
|
---|
[567] | 120 |
|
---|
[569] | 121 |
|
---|
| 122 |
|
---|
[567] | 123 | // Hackish fix for Konoko not kicking guns
|
---|
| 124 | // Don't use this, it breaks stairs.
|
---|
| 125 | if (patch_kickguns)
|
---|
| 126 | {
|
---|
| 127 | 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 };
|
---|
| 128 | DDrPatch_Const (OniExe + 0x000dc420, kickgun_patch);
|
---|
| 129 | }
|
---|
| 130 |
|
---|
| 131 | // Cooldown timer exploit fix ^_^
|
---|
| 132 | if (patch_cooldowntimer)
|
---|
| 133 | {
|
---|
| 134 | 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 };
|
---|
| 135 | DDrPatch_Const (OniExe + 0x0011a825, cooldown_patch);
|
---|
| 136 | }
|
---|
| 137 |
|
---|
| 138 | if (patch_throwtest)
|
---|
| 139 | {
|
---|
| 140 | const char throwtest_patch[] = { 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 };
|
---|
| 141 | DDrPatch_Const(OniExe + 0x000dc190, throwtest_patch);
|
---|
| 142 | }
|
---|
| 143 |
|
---|
| 144 | // 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.
|
---|
| 145 | if (patch_alttab)
|
---|
| 146 | {
|
---|
| 147 | DDrPatch_Byte ((void*)UUrPlatform_Initialize, 0xC3);
|
---|
| 148 | DDrPatch_Byte ((void*)UUrPlatform_Terminate, 0xC3);
|
---|
| 149 | }
|
---|
| 150 |
|
---|
| 151 | // 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.)
|
---|
| 152 | if (patch_particledisablebit)
|
---|
| 153 | DDrPatch_Int16 (OniExe + 0x001b184, 0x9090);
|
---|
| 154 |
|
---|
| 155 | // Multi-byte patch (multiple language support)
|
---|
| 156 | if (!patch_multibyte)
|
---|
| 157 | {
|
---|
| 158 | DDrPatch_Byte (OniExe + 0x0002d8f8, 0xeb);
|
---|
| 159 | DDrPatch_Byte (OniExe + 0x0002d9ad, 0xeb);
|
---|
| 160 | DDrPatch_Byte (OniExe + 0x0002dbe2, 0xeb);
|
---|
| 161 | DDrPatch_Byte (OniExe + 0x0002dec3, 0xeb);
|
---|
| 162 | DDrPatch_Byte (OniExe + 0x0002e2ab, 0xeb);
|
---|
| 163 | DDrPatch_Byte (OniExe + 0x0002e2c4, 0xeb);
|
---|
| 164 | DDrPatch_Byte (OniExe + 0x0002e379, 0xeb);
|
---|
| 165 | DDrPatch_Byte (OniExe + 0x0002e48c, 0xeb);
|
---|
| 166 | DDrPatch_Byte (OniExe + 0x0002e4d0, 0xeb);
|
---|
| 167 | DDrPatch_Byte (OniExe + 0x0002e4f4, 0xeb);
|
---|
| 168 | DDrPatch_Byte (OniExe + 0x0002e646, 0xeb);
|
---|
| 169 | DDrPatch_Byte (OniExe + 0x0002e695, 0xeb);
|
---|
| 170 | DDrPatch_Byte (OniExe + 0x0002e944, 0xeb);
|
---|
| 171 | DDrPatch_Byte (OniExe + 0x0002e95d, 0xeb);
|
---|
| 172 | DDrPatch_Byte (OniExe + 0x0002e98e, 0xeb);
|
---|
| 173 | DDrPatch_Byte (OniExe + 0x0002e9dc, 0xeb);
|
---|
| 174 | }
|
---|
| 175 |
|
---|
| 176 | // Cheat table patch
|
---|
| 177 | if (patch_cheattable)
|
---|
| 178 | {
|
---|
| 179 | DDrPatch_Int32 (0x004f616b, (int)&DDr_CheatTable[0].name);
|
---|
| 180 | DDrPatch_Int32 (OniExe + 0x000f617a, (int)&DDr_CheatTable[0].message_on);
|
---|
| 181 | }
|
---|
| 182 |
|
---|
| 183 | // ARGB8888 textures
|
---|
| 184 | if (patch_argb8888)
|
---|
| 185 | {
|
---|
| 186 | DDrPatch_Byte (OniExe + 0x00135af0, 0x07);
|
---|
| 187 | DDrPatch_Byte (OniExe + 0x00135af4, 0x0B);
|
---|
| 188 | }
|
---|
| 189 |
|
---|
| 190 | //Test newweap patch
|
---|
[572] | 191 | if (patch_newweapon) {
|
---|
[567] | 192 |
|
---|
| 193 | //Makes it always say "Recieved weapon_name."
|
---|
| 194 | //Needs check for loc_4DFC66
|
---|
[572] | 195 | //DDrPatch_NOOP( OniExe + 0x000E4DF8,2);
|
---|
[567] | 196 |
|
---|
| 197 | //Adds Weapon name and ammo meter to pickup autoprompt
|
---|
| 198 | DDrPatch_NOOP( OniExe + 0x000FAC73, 9);
|
---|
| 199 | DDrPatch_NOOP( OniExe + 0x000FAC80, 5);
|
---|
| 200 | DDrPatch_MakeCall( OniExe + 0xFAC85, DDrWeapon2Message);
|
---|
| 201 |
|
---|
| 202 | //Moves location of colors
|
---|
| 203 | //DDrPatch_Int32( 0x0042E3D5, (int)&DDrDSayColors );
|
---|
| 204 | //DDrPatch_Int32( 0x0042E3DA, (int)&DDrDSayColors );
|
---|
[572] | 205 | }
|
---|
[567] | 206 |
|
---|
| 207 | // Disable loading the vtuneapi.dll
|
---|
[574] | 208 | //if (patch_killvtune)
|
---|
| 209 | //DDrPatch_Byte (OniExe + 0x00026340, 0xC3);
|
---|
[567] | 210 |
|
---|
| 211 | // Disable Oni's internal CLrGetCommandLine function (to eventually replace it with our own)
|
---|
| 212 | if (patch_getcmdline)
|
---|
| 213 | DDrPatch_NOOP (OniExe + 0x000d3280, 51);
|
---|
| 214 |
|
---|
| 215 | // Disable Oni's command line parser so it doesn't interfere with ours
|
---|
| 216 | if (patch_disablecmdline)
|
---|
| 217 | DDrPatch_Int32 (OniExe + 0x000d3570, 0xc3c03366);
|
---|
| 218 |
|
---|
[569] | 219 | if (patch_bsl)
|
---|
| 220 | {
|
---|
| 221 | //Calculating the value of the needed offset is much more reliable when the compiler does it for you.
|
---|
| 222 |
|
---|
| 223 | //TODO: fix moonshadow.
|
---|
| 224 | Character * Chr = 0;
|
---|
| 225 | int NoPath = (int)&(Chr[0].RegenHax) & 0x000000FF;
|
---|
| 226 | const char regen_patch[] =
|
---|
| 227 | {0x90, 0x90, 0x90, 0x90, 0x90, // mov al, _WPgRegenerationCheat -> NOOP
|
---|
| 228 | 0x90, 0x90, // test al, al -> NOOP
|
---|
| 229 | 0x90, 0x90, // jz short loc_51BB98 -> NOOP
|
---|
| 230 | 0x8B, 0x86, (char)NoPath, 0x01, 0x00, 0x00, // mov eax, [esi+Character.field_1E8]
|
---|
| 231 | // -> mov eax, [esi+Character.RegenHax]
|
---|
| 232 | 0x85, 0xC0, // test eax, eax
|
---|
| 233 | 0x74, 0x21 // jnz 0x21 -> jz 0x21
|
---|
| 234 | };
|
---|
| 235 | DDrPatch_Const(0x0051BB64, regen_patch);
|
---|
| 236 | }
|
---|
[586] | 237 |
|
---|
| 238 | //Fix crappy ai2_shownames
|
---|
| 239 | if(1)
|
---|
| 240 | {
|
---|
| 241 | //Set distance above head to 4.0
|
---|
| 242 | DDrPatch_Int32(0x0048C998, 0x005296C8);
|
---|
| 243 | //texture height
|
---|
| 244 | DDrPatch_Byte( 0x0048C9DF, 0x3F );
|
---|
| 245 | //texture width
|
---|
| 246 | DDrPatch_NOOP( (char*)0x0048C9CA, 6 );
|
---|
| 247 | //Set the text color to whatever we like ;)
|
---|
| 248 | DDrPatch_NOOP( 0x0048C898, 6 );
|
---|
| 249 | DDrPatch_Byte( 0x0048C898, 0x8B );
|
---|
| 250 | DDrPatch_Byte( 0x0048C899, 0xCE );
|
---|
| 251 | DDrPatch_MakeCall( 0x0048C8A3, FLrHook_DebugNameShadeHack);
|
---|
| 252 |
|
---|
| 253 | //Make the background black for additive blending
|
---|
| 254 | DDrPatch_MakeCall( 0x0048C802, FLrHook_DebugNameTextureInit );
|
---|
| 255 | }
|
---|
| 256 |
|
---|
| 257 | if(1)
|
---|
| 258 | {
|
---|
| 259 | //DDrPatch_NOOP( 0x004E1957, 6 );
|
---|
| 260 | //DDrPatch_MakeCall( 0x004E17F6, FLrHook_Lasers );
|
---|
| 261 | }
|
---|
| 262 |
|
---|
[574] | 263 | //Flatline related stuff
|
---|
[573] | 264 | DDrPatch_MakeCall(0x004FBCEA, DDrText_Hook);
|
---|
[574] | 265 |
|
---|
[586] | 266 | DDrPatch_Int32( 0x004B24D2, FLrSpawnHack);
|
---|
[574] | 267 |
|
---|
[573] | 268 | DDrPatch_NOOP(0x004C26CB, 6);
|
---|
| 269 | DDrPatch_MakeCall( 0x004C26CB, FLrHook_DoorOpen);
|
---|
[574] | 270 | DDrPatch_MakeCall( 0x004EE3CF, FLrHook_ConsoleActivate);
|
---|
[567] | 271 | return true;
|
---|
| 272 | }
|
---|
| 273 |
|
---|
| 274 | enum {s_unknown, s_options, s_patch, s_bsl, s_language} ini_section;
|
---|
| 275 |
|
---|
| 276 | bool DDrIniCallback(char* section, bool newsection, char* name, char* value)
|
---|
| 277 | {
|
---|
| 278 | if (newsection)
|
---|
| 279 | {
|
---|
| 280 | if (!_stricmp(section, "options"))
|
---|
| 281 | ini_section = s_options;
|
---|
| 282 | else if (!_stricmp(section, "patch"))
|
---|
| 283 | ini_section = s_patch;
|
---|
| 284 | else if (!_stricmp(section, "bsl"))
|
---|
| 285 | ini_section = s_bsl;
|
---|
| 286 | else if (!_stricmp(section, "language"))
|
---|
| 287 | ini_section = s_language;
|
---|
| 288 | else
|
---|
| 289 | {
|
---|
| 290 | ini_section = s_unknown;
|
---|
| 291 | DDrStartupMessage("unrecognised section \"%s\"", section);
|
---|
| 292 | }
|
---|
| 293 | }
|
---|
| 294 |
|
---|
| 295 | switch (ini_section)
|
---|
| 296 | {
|
---|
| 297 | case s_options:
|
---|
| 298 | if (!_stricmp(name, "usedaodanbsl"))
|
---|
| 299 | opt_usedaodanbsl = !_stricmp(inifile_cleanstr(value), "true");
|
---|
| 300 | else if (!_stricmp(name, "border"))
|
---|
| 301 | opt_border = !_stricmp(inifile_cleanstr(value), "true");
|
---|
| 302 | else if (!_stricmp(name, "shadow"))
|
---|
| 303 | opt_shadow = !_stricmp(inifile_cleanstr(value), "true");
|
---|
| 304 | else if (!_stricmp(name, "topmost"))
|
---|
| 305 | opt_topmost = !_stricmp(inifile_cleanstr(value), "true");
|
---|
| 306 | else if (!_stricmp(name, "multibyte"))
|
---|
| 307 | patch_multibyte = !_stricmp(inifile_cleanstr(value), "true");
|
---|
| 308 | else if (!_stricmp(name, "debug"))
|
---|
| 309 | AKgDebug_DebugMaps = !_stricmp(inifile_cleanstr(value), "true");
|
---|
| 310 | else if (!_stricmp(name, "debugfiles"))
|
---|
| 311 | BFgDebugFileEnable = !_stricmp(inifile_cleanstr(value), "true");
|
---|
| 312 | else if (!_stricmp(name, "findsounds"))
|
---|
| 313 | SSgSearchOnDisk = !_stricmp(inifile_cleanstr(value), "true");
|
---|
| 314 | else if (!_stricmp(name, "ignore_private_data"))
|
---|
| 315 | opt_ignore_private_data = !_stricmp(inifile_cleanstr(value), "true");
|
---|
| 316 | else if (!_stricmp(name, "sound"))
|
---|
| 317 | opt_sound = !_stricmp(inifile_cleanstr(value), "true");
|
---|
| 318 | else if (!_stricmp(name, "switch"))
|
---|
| 319 | M3gResolutionSwitch = !_stricmp(inifile_cleanstr(value), "true");
|
---|
[572] | 320 | //else if (!_stricmp(name, "devmode"))
|
---|
| 321 | //turn_dev_mode_on = !_stricmp(inifile_cleanstr(value), "true");
|
---|
[567] | 322 | else
|
---|
| 323 | DDrStartupMessage("unrecognised option \"%s\"", name);
|
---|
| 324 | break;
|
---|
| 325 | case s_patch:
|
---|
| 326 | if (!_stricmp(name, "fonttexturecache"))
|
---|
| 327 | patch_fonttexturecache = !_stricmp(inifile_cleanstr(value), "true");
|
---|
| 328 | else if (!_stricmp(name, "largetextures"))
|
---|
| 329 | patch_largetextures = !_stricmp(inifile_cleanstr(value), "true");
|
---|
| 330 | else if (!_stricmp(name, "levelplugins"))
|
---|
| 331 | patch_levelplugins = !_stricmp(inifile_cleanstr(value), "true");
|
---|
| 332 | else if (!_stricmp(name, "pathfinding"))
|
---|
| 333 | patch_pathfinding = !_stricmp(inifile_cleanstr(value), "true");
|
---|
| 334 | else if (!_stricmp(name, "projaware"))
|
---|
| 335 | patch_projaware = !_stricmp(inifile_cleanstr(value), "true");
|
---|
| 336 | else if (!_stricmp(name, "directinput"))
|
---|
| 337 | patch_directinput = !_stricmp(inifile_cleanstr(value), "true");
|
---|
| 338 | else if (!_stricmp(name, "wpfadetime"))
|
---|
| 339 | patch_wpfadetime = !_stricmp(inifile_cleanstr(value), "true");
|
---|
| 340 | else if (!_stricmp(name, "kickguns"))
|
---|
| 341 | patch_kickguns = !_stricmp(inifile_cleanstr(value), "true");
|
---|
| 342 | else if (!_stricmp(name, "cooldowntimer"))
|
---|
| 343 | patch_cooldowntimer = !_stricmp(inifile_cleanstr(value), "true");
|
---|
| 344 | else if (!_stricmp(name, "throwtest"))
|
---|
| 345 | patch_throwtest = !_stricmp(inifile_cleanstr(value), "true");
|
---|
| 346 | else if (!_stricmp(name, "alttab"))
|
---|
| 347 | patch_alttab = !_stricmp(inifile_cleanstr(value), "true");
|
---|
| 348 | else if (!_stricmp(name, "particledisablebit"))
|
---|
| 349 | patch_particledisablebit = !_stricmp(inifile_cleanstr(value), "true");
|
---|
| 350 | else if (!_stricmp(name, "multibyte"))
|
---|
| 351 | patch_multibyte = !_stricmp(inifile_cleanstr(value), "true");
|
---|
| 352 | else if (!_stricmp(name, "cheattable"))
|
---|
| 353 | patch_cheattable = !_stricmp(inifile_cleanstr(value), "true");
|
---|
| 354 | else if (!_stricmp(name, "argb8888"))
|
---|
| 355 | patch_argb8888 = !_stricmp(inifile_cleanstr(value), "true");
|
---|
| 356 | else if (!_stricmp(name, "killvtune"))
|
---|
| 357 | patch_killvtune = !_stricmp(inifile_cleanstr(value), "true");
|
---|
| 358 | else if (!_stricmp(name, "getcmdline"))
|
---|
| 359 | patch_getcmdline = !_stricmp(inifile_cleanstr(value), "true");
|
---|
| 360 | else if (!_stricmp(name, "disablecmdline"))
|
---|
| 361 | patch_disablecmdline = !_stricmp(inifile_cleanstr(value), "true");
|
---|
| 362 | else if (!_stricmp(name, "safeprintf"))
|
---|
| 363 | patch_safeprintf = !_stricmp(inifile_cleanstr(value), "true");
|
---|
| 364 | else if (!_stricmp(name, "daodandisplayenum"))
|
---|
| 365 | patch_daodandisplayenum = !_stricmp(inifile_cleanstr(value), "true");
|
---|
| 366 | else if (!_stricmp(name, "usegettickcount"))
|
---|
| 367 | patch_usegettickcount = !_stricmp(inifile_cleanstr(value), "true");
|
---|
| 368 | else if (!_stricmp(name, "cheatsenabled"))
|
---|
| 369 | patch_cheatsenabled = !_stricmp(inifile_cleanstr(value), "true");
|
---|
| 370 | else if (!_stricmp(name, "usedaodangl"))
|
---|
| 371 | patch_usedaodangl = !_stricmp(inifile_cleanstr(value), "true");
|
---|
| 372 | else if (!_stricmp(name, "windowhack"))
|
---|
| 373 | patch_windowhack = !_stricmp(inifile_cleanstr(value), "true");
|
---|
| 374 | else if (!_stricmp(name, "daodaninit"))
|
---|
| 375 | patch_daodaninit = !_stricmp(inifile_cleanstr(value), "true");
|
---|
| 376 | else if (!_stricmp(name, "bsl"))
|
---|
| 377 | patch_bsl = !_stricmp(inifile_cleanstr(value), "true");
|
---|
| 378 | else if (!_stricmp(name, "cheater"))
|
---|
| 379 | patch_cheater = !_stricmp(inifile_cleanstr(value), "true");
|
---|
[572] | 380 | else if (!_stricmp(name, "newweap"))
|
---|
| 381 | patch_newweapon = !_stricmp(inifile_cleanstr(value), "true");
|
---|
[567] | 382 | else
|
---|
| 383 | DDrStartupMessage("unrecognised patch \"%s\"", name);
|
---|
| 384 | break;
|
---|
| 385 | case s_language:
|
---|
| 386 | if (!_stricmp(name, "savepoint"))
|
---|
| 387 | {
|
---|
| 388 | char* str = _strdup(value);
|
---|
| 389 | DDrPatch_Int32(OniExe + 0x000fd730, (int)str);
|
---|
| 390 | DDrPatch_Int32(OniExe + 0x000fd738, (int)str);
|
---|
| 391 | }
|
---|
| 392 | else if (!_stricmp(name, "syndicatewarehouse"))
|
---|
| 393 | {
|
---|
| 394 | char* str = _strdup(value);
|
---|
| 395 | DDrPatch_Int32(OniExe + 0x000fd71a, (int)str);
|
---|
| 396 | DDrPatch_Int32(OniExe + 0x0010ef75, (int)str);
|
---|
| 397 | }
|
---|
| 398 | else if (!_stricmp(name, "damn"))
|
---|
| 399 | DDrPatch__strdup(OniExe + 0x0010fb6e, value);
|
---|
| 400 | else if (!_stricmp(name, "blam"))
|
---|
| 401 | DDrPatch__strdup(OniExe + 0x0010fb73, value);
|
---|
| 402 | else if (!_stricmp(name, "shapeshifter_on"))
|
---|
| 403 | DDr_CheatTable[0].message_on = _strdup(value);
|
---|
| 404 | else if (!_stricmp(name, "shapeshifter_off"))
|
---|
| 405 | DDr_CheatTable[0].message_off = _strdup(value);
|
---|
| 406 | else if (!_stricmp(name, "liveforever_on"))
|
---|
| 407 | DDr_CheatTable[1].message_on = _strdup(value);
|
---|
| 408 | else if (!_stricmp(name, "liveforever_off"))
|
---|
| 409 | DDr_CheatTable[1].message_off = _strdup(value);
|
---|
| 410 | else if (!_stricmp(name, "touchofdeath_on"))
|
---|
| 411 | DDr_CheatTable[2].message_on = _strdup(value);
|
---|
| 412 | else if (!_stricmp(name, "touchofdeath_off"))
|
---|
| 413 | DDr_CheatTable[2].message_off = _strdup(value);
|
---|
| 414 | else if (!_stricmp(name, "canttouchthis_on"))
|
---|
| 415 | DDr_CheatTable[3].message_on = _strdup(value);
|
---|
| 416 | else if (!_stricmp(name, "canttouchthis_off"))
|
---|
| 417 | DDr_CheatTable[3].message_off = _strdup(value);
|
---|
| 418 | else if (!_stricmp(name, "fatloot_on"))
|
---|
| 419 | DDr_CheatTable[4].message_on = _strdup(value);
|
---|
| 420 | else if (!_stricmp(name, "glassworld_on"))
|
---|
| 421 | DDr_CheatTable[5].message_on = _strdup(value);
|
---|
| 422 | else if (!_stricmp(name, "glassworld_off"))
|
---|
| 423 | DDr_CheatTable[5].message_off = _strdup(value);
|
---|
| 424 | else if (!_stricmp(name, "winlevel_on"))
|
---|
| 425 | DDr_CheatTable[6].message_on = _strdup(value);
|
---|
| 426 | else if (!_stricmp(name, "loselevel_on"))
|
---|
| 427 | DDr_CheatTable[7].message_on = _strdup(value);
|
---|
| 428 | else if (!_stricmp(name, "bighead_on"))
|
---|
| 429 | DDr_CheatTable[8].message_on = _strdup(value);
|
---|
| 430 | else if (!_stricmp(name, "bighead_off"))
|
---|
| 431 | DDr_CheatTable[8].message_off = _strdup(value);
|
---|
| 432 | else if (!_stricmp(name, "minime_on"))
|
---|
| 433 | DDr_CheatTable[9].message_on = _strdup(value);
|
---|
| 434 | else if (!_stricmp(name, "minime_off"))
|
---|
| 435 | DDr_CheatTable[9].message_off = _strdup(value);
|
---|
| 436 | else if (!_stricmp(name, "superammo_on"))
|
---|
| 437 | DDr_CheatTable[10].message_on = _strdup(value);
|
---|
| 438 | else if (!_stricmp(name, "superammo_off"))
|
---|
| 439 | DDr_CheatTable[10].message_off = _strdup(value);
|
---|
| 440 | else if (!_stricmp(name, "devmode_on"))
|
---|
| 441 | {
|
---|
| 442 | char* str = _strdup(value);
|
---|
| 443 | DDr_CheatTable[11].message_on = str;
|
---|
| 444 | DDr_CheatTable[cheat_x].message_on = str;
|
---|
| 445 | }
|
---|
| 446 | else if (!_stricmp(name, "devmode_off"))
|
---|
| 447 | {
|
---|
| 448 | char* str = _strdup(value);
|
---|
| 449 | DDr_CheatTable[11].message_off = str;
|
---|
| 450 | DDr_CheatTable[cheat_x].message_off = str;
|
---|
| 451 | }
|
---|
| 452 | else if (!_stricmp(name, "reservoirdogs_on"))
|
---|
| 453 | DDr_CheatTable[12].message_on = _strdup(value);
|
---|
| 454 | else if (!_stricmp(name, "reservoirdogs_off"))
|
---|
| 455 | DDr_CheatTable[12].message_off = _strdup(value);
|
---|
| 456 | else if (!_stricmp(name, "roughjustice_on"))
|
---|
| 457 | DDr_CheatTable[13].message_on = _strdup(value);
|
---|
| 458 | else if (!_stricmp(name, "roughjustice_off"))
|
---|
| 459 | DDr_CheatTable[13].message_off = _strdup(value);
|
---|
| 460 | else if (!_stricmp(name, "chenille_on"))
|
---|
| 461 | DDr_CheatTable[14].message_on = _strdup(value);
|
---|
| 462 | else if (!_stricmp(name, "chenille_off"))
|
---|
| 463 | DDr_CheatTable[14].message_off = _strdup(value);
|
---|
| 464 | else if (!_stricmp(name, "behemoth_on"))
|
---|
| 465 | DDr_CheatTable[15].message_on = _strdup(value);
|
---|
| 466 | else if (!_stricmp(name, "behemoth_off"))
|
---|
| 467 | DDr_CheatTable[15].message_off = _strdup(value);
|
---|
| 468 | else if (!_stricmp(name, "elderrune_on"))
|
---|
| 469 | DDr_CheatTable[16].message_on = _strdup(value);
|
---|
| 470 | else if (!_stricmp(name, "elderrune_off"))
|
---|
| 471 | DDr_CheatTable[16].message_off = _strdup(value);
|
---|
| 472 | else if (!_stricmp(name, "moonshadow_on"))
|
---|
| 473 | DDr_CheatTable[17].message_on = _strdup(value);
|
---|
| 474 | else if (!_stricmp(name, "moonshadow_off"))
|
---|
| 475 | DDr_CheatTable[17].message_off = _strdup(value);
|
---|
| 476 | else if (!_stricmp(name, "munitionfrenzy_on"))
|
---|
| 477 | DDr_CheatTable[18].message_on = _strdup(value);
|
---|
| 478 | else if (!_stricmp(name, "fistsoflegend_on"))
|
---|
| 479 | DDr_CheatTable[19].message_on = _strdup(value);
|
---|
| 480 | else if (!_stricmp(name, "fistsoflegend_off"))
|
---|
| 481 | DDr_CheatTable[19].message_off = _strdup(value);
|
---|
| 482 | else if (!_stricmp(name, "killmequick_on"))
|
---|
| 483 | DDr_CheatTable[20].message_on = _strdup(value);
|
---|
| 484 | else if (!_stricmp(name, "killmequick_off"))
|
---|
| 485 | DDr_CheatTable[20].message_off = _strdup(value);
|
---|
| 486 | else if (!_stricmp(name, "carousel_on"))
|
---|
| 487 | DDr_CheatTable[21].message_on = _strdup(value);
|
---|
| 488 | else if (!_stricmp(name, "carousel_off"))
|
---|
| 489 | DDr_CheatTable[21].message_off = _strdup(value);
|
---|
| 490 | else
|
---|
| 491 | DDrStartupMessage("unrecognised language item \"%s\"", name);
|
---|
| 492 | break;
|
---|
| 493 | case s_bsl:
|
---|
| 494 | default:
|
---|
| 495 | break;
|
---|
| 496 | }
|
---|
| 497 |
|
---|
| 498 | return true;
|
---|
| 499 | }
|
---|
| 500 |
|
---|
| 501 | void DDrConfig()
|
---|
| 502 | {
|
---|
[572] | 503 |
|
---|
| 504 | if (GetFileAttributes("daodan.ini") == INVALID_FILE_ATTRIBUTES)
|
---|
[567] | 505 | {
|
---|
[572] | 506 | FILE* fp;
|
---|
[567] | 507 | DDrStartupMessage("daodan.ini doesn't exist, creating");
|
---|
[572] | 508 | fp = fopen("daodan.ini", "w");
|
---|
[567] | 509 | if (fp)
|
---|
| 510 | {
|
---|
| 511 | fputs("[Options]\n", fp);
|
---|
| 512 | fclose(fp);
|
---|
| 513 | }
|
---|
| 514 | }
|
---|
| 515 |
|
---|
| 516 | DDrStartupMessage("parsing daodan.ini...");
|
---|
| 517 | if (!inifile_read("daodan.ini", DDrIniCallback))
|
---|
[572] | 518 | DDrStartupMessage("error reading daodan.ini, check your syntax!");
|
---|
[567] | 519 | DDrStartupMessage("finished parsing");
|
---|
| 520 | }
|
---|
| 521 |
|
---|
| 522 | void ONICALL DDrGame_Init()
|
---|
| 523 | {
|
---|
| 524 | if (opt_usedaodanbsl)
|
---|
| 525 | SLrDaodan_Initalize();
|
---|
| 526 | }
|
---|
| 527 |
|
---|
| 528 | void DDrException() {
|
---|
| 529 | int* i = 0;
|
---|
| 530 | *i = 1;
|
---|
| 531 | }
|
---|
| 532 | #include <stdio.h>
|
---|
| 533 |
|
---|
| 534 | //this was broken
|
---|
| 535 | FILE** _UUgError_WarningFile = (FILE**)0x005711B4;
|
---|
| 536 | FILE *__fastcall DDrPrintWarning(int filename, int linenumber, unsigned __int16 errornum, int message)
|
---|
| 537 | {
|
---|
| 538 |
|
---|
| 539 | FILE *v4; // eax@1
|
---|
| 540 | FILE *result; // eax@4
|
---|
| 541 | char v6[512]; // [sp+0h] [bp-100h]@1
|
---|
| 542 | FILE* UUgError_WarningFile = *_UUgError_WarningFile;
|
---|
| 543 | sprintf_s(
|
---|
| 544 | v6, 512,
|
---|
| 545 | "Error %x reported from File: %s, Line: %d (message follows) \r\n%s",
|
---|
| 546 | errornum,
|
---|
| 547 | filename,
|
---|
| 548 | linenumber,
|
---|
| 549 | message);
|
---|
| 550 |
|
---|
| 551 | if ( UUgError_WarningFile
|
---|
| 552 | || (UUgError_WarningFile = oni_fopen("debugger.txt", "wb"), UUgError_WarningFile ) )
|
---|
| 553 | {
|
---|
| 554 | oni_fprintf(UUgError_WarningFile, "%s\r\n", v6);
|
---|
| 555 | oni_fflush(UUgError_WarningFile);
|
---|
| 556 | }
|
---|
| 557 | //oni_fprintf(stdout, v6);
|
---|
| 558 | //sprintf(&v6, "%s", message);
|
---|
| 559 | *_UUgError_WarningFile = UUgError_WarningFile;
|
---|
| 560 | result = UUgError_WarningFile;
|
---|
| 561 | return result;
|
---|
| 562 | }
|
---|
| 563 |
|
---|
| 564 | void __cdecl DDrMain(int argc, char* argv[])
|
---|
| 565 | {
|
---|
| 566 | int i;
|
---|
| 567 | char* section;
|
---|
| 568 | char* option;
|
---|
| 569 | bool falseoption;
|
---|
| 570 |
|
---|
| 571 | DDrStartupMessage("daodan attached!");
|
---|
| 572 |
|
---|
| 573 | opt_ignore_private_data = false;
|
---|
| 574 | opt_sound = true;
|
---|
| 575 |
|
---|
| 576 | DDrConfig();
|
---|
| 577 | DDrStartupMessage("parsing command line...");
|
---|
| 578 | for (i = 1; i < argc; i ++)
|
---|
| 579 | {
|
---|
| 580 | if (argv[i][0] == '-')
|
---|
| 581 | {
|
---|
| 582 | section = argv[i] + 1;
|
---|
| 583 | if ((option = strchr(argv[i], '.')))
|
---|
| 584 | {
|
---|
| 585 | *option = '\0';
|
---|
| 586 | falseoption = (option[1] == 'n' || option[1] == 'N') && (option[2] = 'o' || option[2] == 'O');
|
---|
| 587 | if (i < (argc - 1) && argv[i + 1][0] != '-')
|
---|
| 588 | DDrIniCallback(section, true, option + 1, argv[++i]);
|
---|
| 589 | else
|
---|
| 590 | DDrIniCallback(section, true, option + (falseoption ? 3 : 1), (falseoption ? "false" : "true"));
|
---|
| 591 | *option = '.';
|
---|
| 592 | }
|
---|
| 593 | else
|
---|
| 594 | {
|
---|
| 595 | falseoption = (section[0] == 'n' || section[0] == 'N') && (section[1] = 'o' || section[1] == 'O');
|
---|
| 596 | ini_section = s_options;
|
---|
| 597 | if (i < (argc - 1) && argv[i + 1][0] != '-')
|
---|
| 598 | DDrIniCallback(NULL, false, section, argv[++i]);
|
---|
| 599 | else
|
---|
| 600 | DDrIniCallback(NULL, false, section + (falseoption ? 2 : 0), (falseoption ? "false" : "true"));
|
---|
| 601 | }
|
---|
| 602 | }
|
---|
| 603 | else
|
---|
| 604 | {
|
---|
| 605 | DDrStartupMessage("parse error \"%s\"", argv[i]);
|
---|
| 606 | break;
|
---|
| 607 | }
|
---|
| 608 | }
|
---|
| 609 | DDrStartupMessage("finished parsing");
|
---|
| 610 | DDrPatch_Init();
|
---|
| 611 |
|
---|
| 612 | // Safe startup message printer
|
---|
| 613 | if (patch_safeprintf)
|
---|
| 614 | DDrPatch_MakeJump(UUrStartupMessage, DDrStartupMessage);
|
---|
| 615 |
|
---|
| 616 | // Daodan device mode enumeration function
|
---|
| 617 | if (patch_daodandisplayenum)
|
---|
| 618 | DDrPatch_MakeJump(gl_enumerate_valid_display_modes, daodan_enumerate_valid_display_modes);
|
---|
| 619 |
|
---|
| 620 | // Performance patch
|
---|
| 621 | if (patch_usegettickcount)
|
---|
| 622 | {
|
---|
| 623 | DDrPatch_MakeJump(UUrMachineTime_High, DDrMachineTime_High);
|
---|
| 624 | DDrPatch_MakeJump(UUrMachineTime_High_Frequency, DDrMachineTime_High_Frequency);
|
---|
| 625 | DDrPatch_MakeJump(UUrMachineTime_Sixtieths, DDrMachineTime_Sixtieths);
|
---|
| 626 | }
|
---|
| 627 |
|
---|
| 628 | // Cheats always enabled
|
---|
| 629 | if (patch_cheatsenabled)
|
---|
| 630 | DDrPatch_MakeJump(ONrPersist_GetWonGame, DDrPersist_GetWonGame);
|
---|
[572] | 631 |
|
---|
[567] | 632 | // Windowed mode
|
---|
[572] | 633 | if (patch_usedaodangl)
|
---|
[567] | 634 | {
|
---|
[569] | 635 | DDrPatch_NOOP((char*)0x004032B7, 6);
|
---|
| 636 | DDrPatch_MakeCall((char*)0x004032B7, LIiP_SetCursorPosHook);
|
---|
| 637 |
|
---|
| 638 | DDrPatch_NOOP((char*)0x00403349, 6);
|
---|
| 639 | DDrPatch_MakeCall((char*)0x00403349, LIiP_SetCursorPosHook);
|
---|
[567] | 640 | DDrPatch_MakeJump(ONrPlatform_Initialize, DDrPlatform_Initialize);
|
---|
| 641 | DDrPatch_MakeJump(gl_platform_initialize, daodangl_platform_initialize);
|
---|
| 642 | }
|
---|
| 643 | // Hacked windowed mode (for when daodangl isn't working properly)
|
---|
[572] | 644 | else if (patch_windowhack)
|
---|
| 645 | DDrWindowHack_Install();
|
---|
[567] | 646 |
|
---|
| 647 | if (patch_daodaninit)
|
---|
| 648 | DDrPatch_MakeCall(OniExe + 0x000d345a, DDrGame_Init);
|
---|
| 649 |
|
---|
| 650 | // Patches for existing BSL functions
|
---|
| 651 | if (patch_bsl)
|
---|
| 652 | SLrDaodan_Patch();
|
---|
| 653 |
|
---|
| 654 | if (patch_cheater)
|
---|
| 655 | {
|
---|
| 656 | DDrPatch_MakeCall(OniExe + 0x000f618f, DDrCheater);
|
---|
| 657 | DDrPatch_Int16(OniExe + 0x000deb45, 0x5590);
|
---|
| 658 | #if 0
|
---|
| 659 | DDrPatch_MakeCall(OniExe + 0x000deb47, FallingFrames);
|
---|
| 660 | #endif
|
---|
| 661 | DDrPatch_MakeJump(OniExe + 0x0010f021, DDrCheater_LevelLoad);
|
---|
| 662 | }
|
---|
| 663 |
|
---|
| 664 | //DDrPatch_MakeJump(0x004378c0, DDrException);
|
---|
| 665 | DDrPatch_MakeJump(0x004245A0, DDrPrintWarning);
|
---|
| 666 | //init_daodan_gl();
|
---|
| 667 |
|
---|
| 668 | ONiMain(argc, argv);
|
---|
| 669 | }
|
---|
| 670 | /*
|
---|
| 671 | void DDrWrongExe()
|
---|
| 672 | {
|
---|
| 673 | switch (MessageBox(NULL, "This version of the Daodan DLL is incompatible with your Oni.exe.\n"
|
---|
| 674 | "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))
|
---|
| 675 | {
|
---|
| 676 | case IDOK:
|
---|
| 677 | {
|
---|
| 678 | STARTUPINFO si;
|
---|
| 679 | PROCESS_INFORMATION pi;
|
---|
| 680 | FillMemory(&si, 0, sizeof(si));
|
---|
| 681 | FillMemory(&pi, 0, sizeof(pi));
|
---|
| 682 | si.cb = sizeof(si);
|
---|
| 683 | if (!CreateProcess(NULL, "cmd /c \"start http://wiki.oni2.net/Daodan_DLL\"", NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
|
---|
| 684 | MessageBox(NULL, "", "", 0);
|
---|
| 685 | CloseHandle(pi.hProcess);
|
---|
| 686 | CloseHandle(pi.hThread);
|
---|
| 687 | }
|
---|
| 688 | default:
|
---|
| 689 | ExitProcess(0);
|
---|
| 690 | }
|
---|
| 691 | }
|
---|
| 692 | */
|
---|
| 693 | BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved)
|
---|
| 694 | {
|
---|
| 695 | switch (fdwReason)
|
---|
| 696 | {
|
---|
| 697 | case DLL_PROCESS_ATTACH:
|
---|
| 698 | DDrDLLModule = hinstDLL;
|
---|
| 699 | DDrONiModule = GetModuleHandle(NULL);
|
---|
| 700 |
|
---|
| 701 | if (*(uint32_t*)(OniExe + 0x0011acd0) == 0x09d36852)
|
---|
| 702 | DDrPatch_MakeCall(OniExe + 0x0010fb49, DDrMain);
|
---|
| 703 | else
|
---|
| 704 | ExitProcess(0);
|
---|
| 705 | break;
|
---|
| 706 | }
|
---|
| 707 | return TRUE;
|
---|
| 708 | }
|
---|