--- Daodan/src/Daodan.c 2009/06/09 12:42:24 347 +++ Daodan/src/Daodan.c 2009/08/10 11:46:16 455 @@ -6,6 +6,9 @@ #include "Daodan_Win32.h" #include "Daodan_Cheater.h" #include "Daodan_Persistence.h" +#include "Daodan_BSL.h" + +#include "Daodan_WindowHack.h" #include "Oni.h" #include "Oni_Persistence.h" @@ -22,21 +25,31 @@ HMODULE DDrONiModule; bool patch_fonttexturecache = true; bool patch_largetextures = true; +bool patch_levelplugins = true; bool patch_pathfinding = true; bool patch_projaware = true; +bool patch_directinput = true; bool patch_wpfadetime = true; bool patch_kickguns = false; bool patch_cooldowntimer = true; bool patch_throwtest = false; bool patch_alttab = true; bool patch_particledisablebit = false; -bool patch_multibyte = true; +bool patch_multibyte = false; bool patch_cheattable = true; +bool patch_argb8888 = true; bool patch_safeprintf = true; bool patch_daodandisplayenum = true; bool patch_usegettickcount = true; +bool patch_cheatsenabled = true; bool patch_usedaodangl = false; +bool patch_windowhack = true; +bool patch_daodaninit = true; +bool patch_bsl = true; +bool patch_cheater = true; + +bool opt_usedaodanbsl = true; bool DDrPatch_Init() { @@ -54,7 +67,8 @@ bool DDrPatch_Init() DDrPatch_Byte (OniExe + 0x00005251, 0x10); // Non-"_Final" levels are now valid - DDrPatch_Byte (OniExe + 0x000206a8, 0x01); + if (patch_levelplugins) + DDrPatch_Byte (OniExe + 0x000206a8, 0x01); // Pathfinding grid cache size x8 if (patch_pathfinding) @@ -73,7 +87,8 @@ bool DDrPatch_Init() } // Forced DirectInput (for Windows NT) - DDrPatch_Byte (OniExe + 0x00002e6d, 0xeb); + if (patch_directinput) + DDrPatch_Byte (OniExe + 0x00002e6d, 0xeb); if (patch_wpfadetime) { @@ -119,7 +134,7 @@ bool DDrPatch_Init() DDrPatch_Int16 (OniExe + 0x001b184, 0x9090); // Multi-byte patch (multiple language support) - if (patch_multibyte) + if (!patch_multibyte) { DDrPatch_Byte (OniExe + 0x0002d8f8, 0xeb); DDrPatch_Byte (OniExe + 0x0002d9ad, 0xeb); @@ -146,17 +161,27 @@ bool DDrPatch_Init() DDrPatch_Int32 (OniExe + 0x000f617a, (int)&DDr_CheatTable[0].message_on); } + if (patch_argb8888) + { + DDrPatch_Byte (OniExe + 0x00135af0, 0x07); + DDrPatch_Byte (OniExe + 0x00135af4, 0x0B); + } + return true; } -enum {s_unknown, s_patch, s_language} ini_section; +enum {s_unknown, s_options, s_patch, s_bsl, s_language} ini_section; bool DDrIniCallback(char* section, bool newsection, char* name, char* value) { if (newsection) { - if (!stricmp(section, "patch")) + if (!stricmp(section, "options")) + ini_section = s_options; + else if (!stricmp(section, "patch")) ini_section = s_patch; + else if (!stricmp(section, "bsl")) + ini_section = s_bsl; else if (!stricmp(section, "language")) ini_section = s_language; else @@ -168,39 +193,59 @@ bool DDrIniCallback(char* section, bool switch (ini_section) { + case s_options: + if (!stricmp(name, "usedaodanbsl")) + opt_usedaodanbsl = !stricmp(inifile_cleanstr(value), "true"); + break; case s_patch: if (!stricmp(name, "fonttexturecache")) - patch_fonttexturecache = !stricmp(value, "true"); + patch_fonttexturecache = !stricmp(inifile_cleanstr(value), "true"); else if (!stricmp(name, "largetextures")) - patch_largetextures = !stricmp(value, "true"); + 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(value, "true"); + patch_pathfinding = !stricmp(inifile_cleanstr(value), "true"); else if (!stricmp(name, "projaware")) - patch_projaware = !stricmp(value, "true"); + 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(value, "true"); + patch_wpfadetime = !stricmp(inifile_cleanstr(value), "true"); else if (!stricmp(name, "kickguns")) - patch_kickguns = !stricmp(value, "true"); + patch_kickguns = !stricmp(inifile_cleanstr(value), "true"); else if (!stricmp(name, "cooldowntimer")) - patch_cooldowntimer = !stricmp(value, "true"); + patch_cooldowntimer = !stricmp(inifile_cleanstr(value), "true"); else if (!stricmp(name, "throwtest")) - patch_throwtest = !stricmp(value, "true"); + patch_throwtest = !stricmp(inifile_cleanstr(value), "true"); else if (!stricmp(name, "alttab")) - patch_alttab = !stricmp(value, "true"); + patch_alttab = !stricmp(inifile_cleanstr(value), "true"); else if (!stricmp(name, "particledisablebit")) - patch_particledisablebit = !stricmp(value, "true"); + patch_particledisablebit = !stricmp(inifile_cleanstr(value), "true"); else if (!stricmp(name, "multibyte")) - patch_multibyte = !stricmp(value, "true"); + patch_multibyte = !stricmp(inifile_cleanstr(value), "true"); else if (!stricmp(name, "cheattable")) - patch_cheattable = !stricmp(value, "true"); + patch_cheattable = !stricmp(inifile_cleanstr(value), "true"); + else if (!stricmp(name, "argb8888")) + patch_argb8888 = !stricmp(inifile_cleanstr(value), "true"); else if (!stricmp(name, "safeprintf")) - patch_safeprintf = !stricmp(value, "true"); + patch_safeprintf = !stricmp(inifile_cleanstr(value), "true"); else if (!stricmp(name, "daodandisplayenum")) - patch_daodandisplayenum = !stricmp(value, "true"); + patch_daodandisplayenum = !stricmp(inifile_cleanstr(value), "true"); else if (!stricmp(name, "usegettickcount")) - patch_usegettickcount = !stricmp(value, "true"); + 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(value, "true"); + 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 DDrStartupMessage("unrecognised patch \"%s\"", name); break; @@ -221,9 +266,98 @@ bool DDrIniCallback(char* section, bool 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); + DDr_CheatTable[11].message_on = str; + DDr_CheatTable[cheat_x].message_on = str; + } + else if (!stricmp(name, "devmode_off")) + { + 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 DDrStartupMessage("unrecognised language item \"%s\"", name); break; + case s_bsl: default: break; } @@ -250,6 +384,12 @@ void DDrConfig() DDrStartupMessage("finished parsing"); } +void ONICALL DDrGame_Init() +{ + if (opt_usedaodanbsl) + SLrDaodan_Initalize(); +} + void __cdecl DDrMain(int argc, char* argv[]) { DDrStartupMessage("daodan attached!"); @@ -273,7 +413,8 @@ void __cdecl DDrMain(int argc, char* arg } // Cheats always enabled - DDrPatch_MakeJump(ONrPersist_GetWonGame, DDrPersist_GetWonGame); + if (patch_cheatsenabled) + DDrPatch_MakeJump(ONrPersist_GetWonGame, DDrPersist_GetWonGame); // Windowed mode if (patch_usedaodangl) @@ -282,6 +423,25 @@ void __cdecl DDrMain(int argc, char* arg DDrPatch_MakeJump(gl_platform_initialize, daodangl_platform_initialize); } + // Hacked windowed mode (for when daodangl isn't working properly) + if (patch_windowhack) + DDrWindowHack_Install(); + + if (patch_daodaninit) + DDrPatch_MakeCall(OniExe + 0x000d345a, DDrGame_Init); + + // Patches for existing BSL functions + if (patch_bsl) + SLrDaodan_Patch(); + + if (patch_cheater) + { + DDrPatch_MakeCall(OniExe + 0x000f618f, DDrCheater); + DDrPatch_Int16(OniExe + 0x000deb45, 0x5590); + DDrPatch_MakeCall(OniExe + 0x000deb47, FallingFrames); + DDrPatch_MakeJump(OniExe + 0x0010f021, DDrCheater_LevelLoad); + } + init_daodan_gl(); ONiMain(argc, argv);