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