--- Daodan/src/Daodan.c 2009/11/03 10:38:47 476 +++ Daodan/src/Daodan.c 2013/03/02 23:46:33 677 @@ -8,7 +8,6 @@ #include "Daodan_Persistence.h" #include "Daodan_BSL.h" #include "Daodan_Console.h" - #include "Daodan_WindowHack.h" #include "Oni.h" @@ -47,19 +46,19 @@ bool patch_safeprintf = true; bool patch_daodandisplayenum = true; bool patch_usegettickcount = true; bool patch_cheatsenabled = true; -bool patch_usedaodangl = true; -bool patch_windowhack = false; +bool patch_usedaodangl = false; +bool patch_windowhack = true; bool patch_daodaninit = true; bool patch_bsl = true; bool patch_cheater = true; - -// bool patch_newweapon = true; - +bool patch_newweapon = true; bool opt_usedaodanbsl = true; bool opt_border = true; bool opt_shadow = false; bool opt_topmost = false; +typedef int (__cdecl *CHINESEPROC)(DWORD WINAPI); +bool patch_chinese = false; bool DDrPatch_Init() { DDrStartupMessage("patching engine"); @@ -67,8 +66,8 @@ bool DDrPatch_Init() // Font texture cache doubled if (patch_fonttexturecache) { - DDrPatch_Byte (OniExe + 0x00020ea7, 0x20); - DDrPatch_Byte (OniExe + 0x00020f4a, 0x40); + DDrPatch_Byte(OniExe + 0x00020ea7, 0x20); + DDrPatch_Byte(OniExe + 0x00020f4a, 0x40); } // Now supports textures up to 512x512 @@ -82,8 +81,12 @@ bool DDrPatch_Init() // Pathfinding grid cache size x8 if (patch_pathfinding) { + const char pathfinding[2] = {0x90 , 0xE9 }; DDrPatch_Byte (OniExe + 0x0010b03b, 0x20); DDrPatch_Byte (OniExe + 0x0010b04c, 0x20); + + //other stuff + DDrPatch_Const(0x440789, pathfinding); } // Projectile awareness fixed @@ -98,7 +101,7 @@ bool DDrPatch_Init() // Forced DirectInput (for Windows NT) if (patch_directinput) DDrPatch_Byte (OniExe + 0x00002e6d, 0xeb); - + if (patch_wpfadetime) { // Makes wp_fadetime actually have a function @@ -107,11 +110,17 @@ bool DDrPatch_Init() DDrPatch_Byte (OniExe + 0x0011a560, 0x31); // Sets the fadetime to 4800 by default - DDrPatch_Int16 (OniExe + 0x0011ab0e, 0x12c0); + DDrPatch_Int16 ((OniExe + 0x0011ab0e), 0x12c0); } + // FIXME: add switches + //pathfinding fix + + + // Hackish fix for Konoko not kicking guns + // Don't use this, it breaks stairs. if (patch_kickguns) { 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 }; @@ -166,7 +175,7 @@ bool DDrPatch_Init() // Cheat table patch if (patch_cheattable) { - DDrPatch_Int32 (OniExe + 0x000f616b, (int)&DDr_CheatTable[0].name); + DDrPatch_Int32 (0x004f616b, (int)&DDr_CheatTable[0].name); DDrPatch_Int32 (OniExe + 0x000f617a, (int)&DDr_CheatTable[0].message_on); } @@ -178,11 +187,11 @@ bool DDrPatch_Init() } //Test newweap patch -// if (patch_newweapon) { + if (patch_newweapon) { //Makes it always say "Recieved weapon_name." //Needs check for loc_4DFC66 - DDrPatch_NOOP( OniExe + 0x000E4DF8,2); + //DDrPatch_NOOP( OniExe + 0x000E4DF8,2); //Adds Weapon name and ammo meter to pickup autoprompt DDrPatch_NOOP( OniExe + 0x000FAC73, 9); @@ -190,13 +199,13 @@ bool DDrPatch_Init() DDrPatch_MakeCall( OniExe + 0xFAC85, DDrWeapon2Message); //Moves location of colors - DDrPatch_Int32( OniExe + 0x0002E3D5, (int)&DDrDSayColors[0].Char ); - DDrPatch_Int32( OniExe + 0x0002E3DA, (int)&DDrDSayColors[0].Char ); -// } + //DDrPatch_Int32( 0x0042E3D5, (int)&DDrDSayColors ); + //DDrPatch_Int32( 0x0042E3DA, (int)&DDrDSayColors ); + } // Disable loading the vtuneapi.dll - if (patch_killvtune) - DDrPatch_Byte (OniExe + 0x00026340, 0xC3); + //if (patch_killvtune) + //DDrPatch_Byte (OniExe + 0x00026340, 0xC3); // Disable Oni's internal CLrGetCommandLine function (to eventually replace it with our own) if (patch_getcmdline) @@ -206,6 +215,72 @@ bool DDrPatch_Init() if (patch_disablecmdline) DDrPatch_Int32 (OniExe + 0x000d3570, 0xc3c03366); + if (patch_bsl) + { + //Calculating the value of the needed offset is much more reliable when the compiler does it for you. + + //TODO: fix moonshadow. + Character * Chr = 0; + int NoPath = (int)&(Chr[0].RegenHax) & 0x000000FF; + const char regen_patch[] = + {0x90, 0x90, 0x90, 0x90, 0x90, // mov al, _WPgRegenerationCheat -> NOOP + 0x90, 0x90, // test al, al -> NOOP + 0x90, 0x90, // jz short loc_51BB98 -> NOOP + 0x8B, 0x86, (char)NoPath, 0x01, 0x00, 0x00, // mov eax, [esi+Character.field_1E8] + // -> mov eax, [esi+Character.RegenHax] + 0x85, 0xC0, // test eax, eax + 0x74, 0x21 // jnz 0x21 -> jz 0x21 + }; + DDrPatch_Const(0x0051BB64, regen_patch); + } + + if(patch_chinese) + { + HMODULE dll = LoadLibrary("xfhsm_oni.dll"); + if( dll ) + { + void* proc = GetProcAddress( dll, "InstallHook" ); + if(proc) + { + ((CHINESEPROC)proc)(GetCurrentThreadId()); + } + } + } + + //Fix crappy ai2_shownames + if(1) + { + //Set distance above head to 4.0 + DDrPatch_Int32(0x0048C998, 0x005296C8); + //texture height + DDrPatch_Byte( 0x0048C9DF, 0x3F ); + //texture width + DDrPatch_NOOP( (char*)0x0048C9CA, 6 ); + //Set the text color to whatever we like ;) + DDrPatch_NOOP( 0x0048C898, 6 ); + DDrPatch_Byte( 0x0048C898, 0x8B ); + DDrPatch_Byte( 0x0048C899, 0xCE ); +//FLATLINE? DDrPatch_MakeCall( 0x0048C8A3, FLrHook_DebugNameShadeHack); + + //Make the background black for additive blending +//FLATLINE? DDrPatch_MakeCall( 0x0048C802, FLrHook_DebugNameTextureInit ); + } + + if(1) + { + //DDrPatch_NOOP( 0x004E1957, 6 ); + //DDrPatch_MakeCall( 0x004E17F6, FLrHook_Lasers ); + } + + //Flatline related stuff +// DDrPatch_MakeCall(0x004FBCEA, DDrText_Hook); + +//FLATLINE? DDrPatch_Int32( 0x004B24D2, FLrSpawnHack); + +//FLATLINE? DDrPatch_NOOP(0x004C26CB, 6); + +//FLATLINE? DDrPatch_MakeCall( 0x004C26CB, FLrHook_DoorOpen); +//FLATLINE? DDrPatch_MakeCall( 0x004EE3CF, FLrHook_ConsoleActivate); return true; } @@ -215,13 +290,13 @@ bool DDrIniCallback(char* section, bool { if (newsection) { - if (!stricmp(section, "options")) + if (!_stricmp(section, "options")) ini_section = s_options; - else if (!stricmp(section, "patch")) + else if (!_stricmp(section, "patch")) ini_section = s_patch; - else if (!stricmp(section, "bsl")) + else if (!_stricmp(section, "bsl")) ini_section = s_bsl; - else if (!stricmp(section, "language")) + else if (!_stricmp(section, "language")) ini_section = s_language; else { @@ -233,194 +308,200 @@ bool DDrIniCallback(char* section, bool switch (ini_section) { case s_options: - if (!stricmp(name, "usedaodanbsl")) - opt_usedaodanbsl = !stricmp(inifile_cleanstr(value), "true"); - else if (!stricmp(name, "border")) - opt_border = !stricmp(inifile_cleanstr(value), "true"); - else if (!stricmp(name, "shadow")) - opt_shadow = !stricmp(inifile_cleanstr(value), "true"); - else if (!stricmp(name, "topmost")) - opt_topmost = !stricmp(inifile_cleanstr(value), "true"); - else if (!stricmp(name, "multibyte")) - patch_multibyte = !stricmp(inifile_cleanstr(value), "true"); - else if (!stricmp(name, "debug")) - AKgDebug_DebugMaps = !stricmp(inifile_cleanstr(value), "true"); - else if (!stricmp(name, "debugfiles")) - BFgDebugFileEnable = !stricmp(inifile_cleanstr(value), "true"); - else if (!stricmp(name, "findsounds")) - SSgSearchOnDisk = !stricmp(inifile_cleanstr(value), "true"); - else if (!stricmp(name, "ignore_private_data")) - opt_ignore_private_data = !stricmp(inifile_cleanstr(value), "true"); - else if (!stricmp(name, "sound")) - opt_sound = !stricmp(inifile_cleanstr(value), "true"); - else if (!stricmp(name, "switch")) - M3gResolutionSwitch = !stricmp(inifile_cleanstr(value), "true"); + if (!_stricmp(name, "usedaodanbsl")) + opt_usedaodanbsl = !_stricmp(inifile_cleanstr(value), "true"); + else if (!_stricmp(name, "border")) + opt_border = !_stricmp(inifile_cleanstr(value), "true"); + else if (!_stricmp(name, "shadow")) + opt_shadow = !_stricmp(inifile_cleanstr(value), "true"); + else if (!_stricmp(name, "topmost")) + opt_topmost = !_stricmp(inifile_cleanstr(value), "true"); + else if (!_stricmp(name, "multibyte")) + patch_multibyte = !_stricmp(inifile_cleanstr(value), "true"); + else if (!_stricmp(name, "debug")) + AKgDebug_DebugMaps = !_stricmp(inifile_cleanstr(value), "true"); + else if (!_stricmp(name, "debugfiles")) + BFgDebugFileEnable = !_stricmp(inifile_cleanstr(value), "true"); + else if (!_stricmp(name, "findsounds")) + SSgSearchOnDisk = !_stricmp(inifile_cleanstr(value), "true"); + else if (!_stricmp(name, "ignore_private_data")) + opt_ignore_private_data = !_stricmp(inifile_cleanstr(value), "true"); + else if (!_stricmp(name, "sound")) + opt_sound = !_stricmp(inifile_cleanstr(value), "true"); + else if (!_stricmp(name, "switch")) + M3gResolutionSwitch = !_stricmp(inifile_cleanstr(value), "true"); + //else if (!_stricmp(name, "devmode")) + //turn_dev_mode_on = !_stricmp(inifile_cleanstr(value), "true"); else DDrStartupMessage("unrecognised option \"%s\"", name); break; case s_patch: - if (!stricmp(name, "fonttexturecache")) - patch_fonttexturecache = !stricmp(inifile_cleanstr(value), "true"); - else if (!stricmp(name, "largetextures")) - patch_largetextures = !stricmp(inifile_cleanstr(value), "true"); - else if (!stricmp(name, "levelplugins")) - patch_levelplugins = !stricmp(inifile_cleanstr(value), "true"); - else if (!stricmp(name, "pathfinding")) - patch_pathfinding = !stricmp(inifile_cleanstr(value), "true"); - else if (!stricmp(name, "projaware")) - patch_projaware = !stricmp(inifile_cleanstr(value), "true"); - else if (!stricmp(name, "directinput")) - patch_directinput = !stricmp(inifile_cleanstr(value), "true"); - else if (!stricmp(name, "wpfadetime")) - patch_wpfadetime = !stricmp(inifile_cleanstr(value), "true"); - else if (!stricmp(name, "kickguns")) - patch_kickguns = !stricmp(inifile_cleanstr(value), "true"); - else if (!stricmp(name, "cooldowntimer")) - patch_cooldowntimer = !stricmp(inifile_cleanstr(value), "true"); - else if (!stricmp(name, "throwtest")) - patch_throwtest = !stricmp(inifile_cleanstr(value), "true"); - else if (!stricmp(name, "alttab")) - patch_alttab = !stricmp(inifile_cleanstr(value), "true"); - else if (!stricmp(name, "particledisablebit")) - patch_particledisablebit = !stricmp(inifile_cleanstr(value), "true"); - else if (!stricmp(name, "multibyte")) - patch_multibyte = !stricmp(inifile_cleanstr(value), "true"); - else if (!stricmp(name, "cheattable")) - patch_cheattable = !stricmp(inifile_cleanstr(value), "true"); - else if (!stricmp(name, "argb8888")) - patch_argb8888 = !stricmp(inifile_cleanstr(value), "true"); - else if (!stricmp(name, "killvtune")) - patch_killvtune = !stricmp(inifile_cleanstr(value), "true"); - else if (!stricmp(name, "getcmdline")) - patch_getcmdline = !stricmp(inifile_cleanstr(value), "true"); - else if (!stricmp(name, "disablecmdline")) - patch_disablecmdline = !stricmp(inifile_cleanstr(value), "true"); - else if (!stricmp(name, "safeprintf")) - patch_safeprintf = !stricmp(inifile_cleanstr(value), "true"); - else if (!stricmp(name, "daodandisplayenum")) - patch_daodandisplayenum = !stricmp(inifile_cleanstr(value), "true"); - else if (!stricmp(name, "usegettickcount")) - patch_usegettickcount = !stricmp(inifile_cleanstr(value), "true"); - else if (!stricmp(name, "cheatsenabled")) - patch_cheatsenabled = !stricmp(inifile_cleanstr(value), "true"); - else if (!stricmp(name, "usedaodangl")) - patch_usedaodangl = !stricmp(inifile_cleanstr(value), "true"); - else if (!stricmp(name, "windowhack")) - patch_windowhack = !stricmp(inifile_cleanstr(value), "true"); - else if (!stricmp(name, "daodaninit")) - patch_daodaninit = !stricmp(inifile_cleanstr(value), "true"); - else if (!stricmp(name, "bsl")) - patch_bsl = !stricmp(inifile_cleanstr(value), "true"); - else if (!stricmp(name, "cheater")) - patch_cheater = !stricmp(inifile_cleanstr(value), "true"); + if (!_stricmp(name, "fonttexturecache")) + patch_fonttexturecache = !_stricmp(inifile_cleanstr(value), "true"); + else if (!_stricmp(name, "largetextures")) + patch_largetextures = !_stricmp(inifile_cleanstr(value), "true"); + else if (!_stricmp(name, "levelplugins")) + patch_levelplugins = !_stricmp(inifile_cleanstr(value), "true"); + else if (!_stricmp(name, "pathfinding")) + patch_pathfinding = !_stricmp(inifile_cleanstr(value), "true"); + else if (!_stricmp(name, "projaware")) + patch_projaware = !_stricmp(inifile_cleanstr(value), "true"); + else if (!_stricmp(name, "directinput")) + patch_directinput = !_stricmp(inifile_cleanstr(value), "true"); + else if (!_stricmp(name, "wpfadetime")) + patch_wpfadetime = !_stricmp(inifile_cleanstr(value), "true"); + else if (!_stricmp(name, "kickguns")) + patch_kickguns = !_stricmp(inifile_cleanstr(value), "true"); + else if (!_stricmp(name, "cooldowntimer")) + patch_cooldowntimer = !_stricmp(inifile_cleanstr(value), "true"); + else if (!_stricmp(name, "throwtest")) + patch_throwtest = !_stricmp(inifile_cleanstr(value), "true"); + else if (!_stricmp(name, "alttab")) + patch_alttab = !_stricmp(inifile_cleanstr(value), "true"); + else if (!_stricmp(name, "particledisablebit")) + patch_particledisablebit = !_stricmp(inifile_cleanstr(value), "true"); + else if (!_stricmp(name, "multibyte")) + patch_multibyte = !_stricmp(inifile_cleanstr(value), "true"); + else if (!_stricmp(name, "cheattable")) + patch_cheattable = !_stricmp(inifile_cleanstr(value), "true"); + else if (!_stricmp(name, "argb8888")) + patch_argb8888 = !_stricmp(inifile_cleanstr(value), "true"); + else if (!_stricmp(name, "killvtune")) + patch_killvtune = !_stricmp(inifile_cleanstr(value), "true"); + else if (!_stricmp(name, "getcmdline")) + patch_getcmdline = !_stricmp(inifile_cleanstr(value), "true"); + else if (!_stricmp(name, "disablecmdline")) + patch_disablecmdline = !_stricmp(inifile_cleanstr(value), "true"); + else if (!_stricmp(name, "safeprintf")) + patch_safeprintf = !_stricmp(inifile_cleanstr(value), "true"); + else if (!_stricmp(name, "daodandisplayenum")) + patch_daodandisplayenum = !_stricmp(inifile_cleanstr(value), "true"); + else if (!_stricmp(name, "usegettickcount")) + patch_usegettickcount = !_stricmp(inifile_cleanstr(value), "true"); + else if (!_stricmp(name, "cheatsenabled")) + patch_cheatsenabled = !_stricmp(inifile_cleanstr(value), "true"); + else if (!_stricmp(name, "usedaodangl")) + patch_usedaodangl = !_stricmp(inifile_cleanstr(value), "true"); + else if (!_stricmp(name, "windowhack")) + patch_windowhack = !_stricmp(inifile_cleanstr(value), "true"); + else if (!_stricmp(name, "daodaninit")) + patch_daodaninit = !_stricmp(inifile_cleanstr(value), "true"); + else if (!_stricmp(name, "bsl")) + patch_bsl = !_stricmp(inifile_cleanstr(value), "true"); + else if (!_stricmp(name, "cheater")) + patch_cheater = !_stricmp(inifile_cleanstr(value), "true"); + else if (!_stricmp(name, "newweap")) + patch_newweapon = !_stricmp(inifile_cleanstr(value), "true"); else DDrStartupMessage("unrecognised patch \"%s\"", name); break; case s_language: - if (!stricmp(name, "savepoint")) + if (!_stricmp(name, "chinese")) + patch_chinese = true; + else if (!_stricmp(name, "savepoint")) { - char* str = strdup(value); + char* str = _strdup(value); DDrPatch_Int32(OniExe + 0x000fd730, (int)str); DDrPatch_Int32(OniExe + 0x000fd738, (int)str); } - else if (!stricmp(name, "syndicatewarehouse")) + else if (!_stricmp(name, "syndicatewarehouse")) { - char* str = strdup(value); + char* str = _strdup(value); DDrPatch_Int32(OniExe + 0x000fd71a, (int)str); DDrPatch_Int32(OniExe + 0x0010ef75, (int)str); } - else if (!stricmp(name, "damn")) - DDrPatch_StrDup(OniExe + 0x0010fb6e, value); - else if (!stricmp(name, "blam")) - DDrPatch_StrDup(OniExe + 0x0010fb73, value); - else if (!stricmp(name, "shapeshifter_on")) - DDr_CheatTable[0].message_on = strdup(value); - else if (!stricmp(name, "shapeshifter_off")) - DDr_CheatTable[0].message_off = strdup(value); - else if (!stricmp(name, "liveforever_on")) - DDr_CheatTable[1].message_on = strdup(value); - else if (!stricmp(name, "liveforever_off")) - DDr_CheatTable[1].message_off = strdup(value); - else if (!stricmp(name, "touchofdeath_on")) - DDr_CheatTable[2].message_on = strdup(value); - else if (!stricmp(name, "touchofdeath_off")) - DDr_CheatTable[2].message_off = strdup(value); - else if (!stricmp(name, "canttouchthis_on")) - DDr_CheatTable[3].message_on = strdup(value); - else if (!stricmp(name, "canttouchthis_off")) - DDr_CheatTable[3].message_off = strdup(value); - else if (!stricmp(name, "fatloot_on")) - DDr_CheatTable[4].message_on = strdup(value); - else if (!stricmp(name, "glassworld_on")) - DDr_CheatTable[5].message_on = strdup(value); - else if (!stricmp(name, "glassworld_off")) - DDr_CheatTable[5].message_off = strdup(value); - else if (!stricmp(name, "winlevel_on")) - DDr_CheatTable[6].message_on = strdup(value); - else if (!stricmp(name, "loselevel_on")) - DDr_CheatTable[7].message_on = strdup(value); - else if (!stricmp(name, "bighead_on")) - DDr_CheatTable[8].message_on = strdup(value); - else if (!stricmp(name, "bighead_off")) - DDr_CheatTable[8].message_off = strdup(value); - else if (!stricmp(name, "minime_on")) - DDr_CheatTable[9].message_on = strdup(value); - else if (!stricmp(name, "minime_off")) - DDr_CheatTable[9].message_off = strdup(value); - else if (!stricmp(name, "superammo_on")) - DDr_CheatTable[10].message_on = strdup(value); - else if (!stricmp(name, "superammo_off")) - DDr_CheatTable[10].message_off = strdup(value); - else if (!stricmp(name, "devmode_on")) + else if (!_stricmp(name, "damn")) + DDrPatch__strdup(OniExe + 0x0010fb6e, value); + else if (!_stricmp(name, "blam")) + DDrPatch__strdup(OniExe + 0x0010fb73, value); + else if (!_stricmp(name, "shapeshifter_on")) + DDr_CheatTable[0].message_on = _strdup(value); + else if (!_stricmp(name, "shapeshifter_off")) + DDr_CheatTable[0].message_off = _strdup(value); + else if (!_stricmp(name, "liveforever_on")) + DDr_CheatTable[1].message_on = _strdup(value); + else if (!_stricmp(name, "liveforever_off")) + DDr_CheatTable[1].message_off = _strdup(value); + else if (!_stricmp(name, "touchofdeath_on")) + DDr_CheatTable[2].message_on = _strdup(value); + else if (!_stricmp(name, "touchofdeath_off")) + DDr_CheatTable[2].message_off = _strdup(value); + else if (!_stricmp(name, "canttouchthis_on")) + DDr_CheatTable[3].message_on = _strdup(value); + else if (!_stricmp(name, "canttouchthis_off")) + DDr_CheatTable[3].message_off = _strdup(value); + else if (!_stricmp(name, "fatloot_on")) + DDr_CheatTable[4].message_on = _strdup(value); + else if (!_stricmp(name, "glassworld_on")) + DDr_CheatTable[5].message_on = _strdup(value); + else if (!_stricmp(name, "glassworld_off")) + DDr_CheatTable[5].message_off = _strdup(value); + else if (!_stricmp(name, "winlevel_on")) + DDr_CheatTable[6].message_on = _strdup(value); + else if (!_stricmp(name, "loselevel_on")) + DDr_CheatTable[7].message_on = _strdup(value); + else if (!_stricmp(name, "bighead_on")) + DDr_CheatTable[8].message_on = _strdup(value); + else if (!_stricmp(name, "bighead_off")) + DDr_CheatTable[8].message_off = _strdup(value); + else if (!_stricmp(name, "minime_on")) + DDr_CheatTable[9].message_on = _strdup(value); + else if (!_stricmp(name, "minime_off")) + DDr_CheatTable[9].message_off = _strdup(value); + else if (!_stricmp(name, "superammo_on")) + DDr_CheatTable[10].message_on = _strdup(value); + else if (!_stricmp(name, "superammo_off")) + DDr_CheatTable[10].message_off = _strdup(value); + else if (!_stricmp(name, "devmode_on")) { - char* str = strdup(value); + char* str = _strdup(value); DDr_CheatTable[11].message_on = str; DDr_CheatTable[cheat_x].message_on = str; } - else if (!stricmp(name, "devmode_off")) + else if (!_stricmp(name, "devmode_off")) { - char* str = strdup(value); + char* str = _strdup(value); DDr_CheatTable[11].message_off = str; DDr_CheatTable[cheat_x].message_off = str; } - else if (!stricmp(name, "reservoirdogs_on")) - DDr_CheatTable[12].message_on = strdup(value); - else if (!stricmp(name, "reservoirdogs_off")) - DDr_CheatTable[12].message_off = strdup(value); - else if (!stricmp(name, "roughjustice_on")) - DDr_CheatTable[13].message_on = strdup(value); - else if (!stricmp(name, "roughjustice_off")) - DDr_CheatTable[13].message_off = strdup(value); - else if (!stricmp(name, "chenille_on")) - DDr_CheatTable[14].message_on = strdup(value); - else if (!stricmp(name, "chenille_off")) - DDr_CheatTable[14].message_off = strdup(value); - else if (!stricmp(name, "behemoth_on")) - DDr_CheatTable[15].message_on = strdup(value); - else if (!stricmp(name, "behemoth_off")) - DDr_CheatTable[15].message_off = strdup(value); - else if (!stricmp(name, "elderrune_on")) - DDr_CheatTable[16].message_on = strdup(value); - else if (!stricmp(name, "elderrune_off")) - DDr_CheatTable[16].message_off = strdup(value); - else if (!stricmp(name, "moonshadow_on")) - DDr_CheatTable[17].message_on = strdup(value); - else if (!stricmp(name, "moonshadow_off")) - DDr_CheatTable[17].message_off = strdup(value); - else if (!stricmp(name, "munitionfrenzy_on")) - DDr_CheatTable[18].message_on = strdup(value); - else if (!stricmp(name, "fistsoflegend_on")) - DDr_CheatTable[19].message_on = strdup(value); - else if (!stricmp(name, "fistsoflegend_off")) - DDr_CheatTable[19].message_off = strdup(value); - else if (!stricmp(name, "killmequick_on")) - DDr_CheatTable[20].message_on = strdup(value); - else if (!stricmp(name, "killmequick_off")) - DDr_CheatTable[20].message_off = strdup(value); - else if (!stricmp(name, "carousel_on")) - DDr_CheatTable[21].message_on = strdup(value); - else if (!stricmp(name, "carousel_off")) - DDr_CheatTable[21].message_off = strdup(value); + else if (!_stricmp(name, "reservoirdogs_on")) + DDr_CheatTable[12].message_on = _strdup(value); + else if (!_stricmp(name, "reservoirdogs_off")) + DDr_CheatTable[12].message_off = _strdup(value); + else if (!_stricmp(name, "roughjustice_on")) + DDr_CheatTable[13].message_on = _strdup(value); + else if (!_stricmp(name, "roughjustice_off")) + DDr_CheatTable[13].message_off = _strdup(value); + else if (!_stricmp(name, "chenille_on")) + DDr_CheatTable[14].message_on = _strdup(value); + else if (!_stricmp(name, "chenille_off")) + DDr_CheatTable[14].message_off = _strdup(value); + else if (!_stricmp(name, "behemoth_on")) + DDr_CheatTable[15].message_on = _strdup(value); + else if (!_stricmp(name, "behemoth_off")) + DDr_CheatTable[15].message_off = _strdup(value); + else if (!_stricmp(name, "elderrune_on")) + DDr_CheatTable[16].message_on = _strdup(value); + else if (!_stricmp(name, "elderrune_off")) + DDr_CheatTable[16].message_off = _strdup(value); + else if (!_stricmp(name, "moonshadow_on")) + DDr_CheatTable[17].message_on = _strdup(value); + else if (!_stricmp(name, "moonshadow_off")) + DDr_CheatTable[17].message_off = _strdup(value); + else if (!_stricmp(name, "munitionfrenzy_on")) + DDr_CheatTable[18].message_on = _strdup(value); + else if (!_stricmp(name, "fistsoflegend_on")) + DDr_CheatTable[19].message_on = _strdup(value); + else if (!_stricmp(name, "fistsoflegend_off")) + DDr_CheatTable[19].message_off = _strdup(value); + else if (!_stricmp(name, "killmequick_on")) + DDr_CheatTable[20].message_on = _strdup(value); + else if (!_stricmp(name, "killmequick_off")) + DDr_CheatTable[20].message_off = _strdup(value); + else if (!_stricmp(name, "carousel_on")) + DDr_CheatTable[21].message_on = _strdup(value); + else if (!_stricmp(name, "carousel_off")) + DDr_CheatTable[21].message_off = _strdup(value); else DDrStartupMessage("unrecognised language item \"%s\"", name); break; @@ -434,10 +515,12 @@ bool DDrIniCallback(char* section, bool void DDrConfig() { + if (GetFileAttributes("daodan.ini") == INVALID_FILE_ATTRIBUTES) { + FILE* fp; DDrStartupMessage("daodan.ini doesn't exist, creating"); - FILE* fp = fopen("daodan.ini", "w"); + fp = fopen("daodan.ini", "w"); if (fp) { fputs("[Options]\n", fp); @@ -457,8 +540,49 @@ void ONICALL DDrGame_Init() SLrDaodan_Initalize(); } +void DDrException() { + int* i = 0; + *i = 1; +} +#include + +//this was broken +FILE** _UUgError_WarningFile = (FILE**)0x005711B4; +FILE *__fastcall DDrPrintWarning(int filename, int linenumber, unsigned __int16 errornum, int message) +{ + + FILE *v4; // eax@1 + FILE *result; // eax@4 + char v6[512]; // [sp+0h] [bp-100h]@1 + FILE* UUgError_WarningFile = *_UUgError_WarningFile; + sprintf_s( + v6, 512, + "Error %x reported from File: %s, Line: %d (message follows) \r\n%s", + errornum, + filename, + linenumber, + message); + + if ( UUgError_WarningFile + || (UUgError_WarningFile = oni_fopen("debugger.txt", "wb"), UUgError_WarningFile ) ) + { + oni_fprintf(UUgError_WarningFile, "%s\r\n", v6); + oni_fflush(UUgError_WarningFile); + } + //oni_fprintf(stdout, v6); + //sprintf(&v6, "%s", message); + *_UUgError_WarningFile = UUgError_WarningFile; + result = UUgError_WarningFile; + return result; +} + void __cdecl DDrMain(int argc, char* argv[]) { + int i; + char* section; + char* option; + bool falseoption; + DDrStartupMessage("daodan attached!"); opt_ignore_private_data = false; @@ -466,10 +590,6 @@ void __cdecl DDrMain(int argc, char* arg DDrConfig(); DDrStartupMessage("parsing command line..."); - int i; - char* section; - char* option; - bool falseoption; for (i = 1; i < argc; i ++) { if (argv[i][0] == '-') @@ -519,20 +639,24 @@ void __cdecl DDrMain(int argc, char* arg DDrPatch_MakeJump(UUrMachineTime_High_Frequency, DDrMachineTime_High_Frequency); DDrPatch_MakeJump(UUrMachineTime_Sixtieths, DDrMachineTime_Sixtieths); } - + // Cheats always enabled if (patch_cheatsenabled) DDrPatch_MakeJump(ONrPersist_GetWonGame, DDrPersist_GetWonGame); - + // Windowed mode if (patch_usedaodangl) { + DDrPatch_NOOP((char*)0x004032B7, 6); + DDrPatch_MakeCall((char*)0x004032B7, LIiP_SetCursorPosHook); + + DDrPatch_NOOP((char*)0x00403349, 6); + DDrPatch_MakeCall((char*)0x00403349, LIiP_SetCursorPosHook); DDrPatch_MakeJump(ONrPlatform_Initialize, DDrPlatform_Initialize); DDrPatch_MakeJump(gl_platform_initialize, daodangl_platform_initialize); } - // Hacked windowed mode (for when daodangl isn't working properly) - if (patch_windowhack) + else if (patch_windowhack) DDrWindowHack_Install(); if (patch_daodaninit) @@ -541,18 +665,22 @@ void __cdecl DDrMain(int argc, char* arg // Patches for existing BSL functions if (patch_bsl) SLrDaodan_Patch(); - + if (patch_cheater) { DDrPatch_MakeCall(OniExe + 0x000f618f, DDrCheater); DDrPatch_Int16(OniExe + 0x000deb45, 0x5590); +#if 1 DDrPatch_MakeCall(OniExe + 0x000deb47, FallingFrames); +#endif DDrPatch_MakeJump(OniExe + 0x0010f021, DDrCheater_LevelLoad); } + + //DDrPatch_MakeJump(0x004378c0, DDrException); + DDrPatch_MakeJump(0x004245A0, DDrPrintWarning); + //init_daodan_gl(); - init_daodan_gl(); - - ONiMain(argc, argv); + ONiMain(argc, argv); } /* void DDrWrongExe() @@ -585,7 +713,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DDrDLLModule = hinstDLL; DDrONiModule = GetModuleHandle(NULL); - if (*(uint32_t*)((void*)OniExe + 0x0011acd0) == 0x09d36852) + if (*(uint32_t*)(OniExe + 0x0011acd0) == 0x09d36852) DDrPatch_MakeCall(OniExe + 0x0010fb49, DDrMain); else ExitProcess(0);