| 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 |  | 
 
 
 
 
 | 10 | #include "Daodan_WindowHack.h" | 
 
 
 
 
 | 11 |  | 
 
 
 
 
 | 12 | #include "Oni.h" | 
 
 
 
 
 | 13 | #include "Oni_Persistence.h" | 
 
 
 
 
 | 14 |  | 
 
 
 
 
 | 15 | #include "BFW_Utility.h" | 
 
 
 
 
 | 16 |  | 
 
 
 
 
 | 17 | #include "oni_gl.h" | 
 
 
 
 
 | 18 | #include "daodan_gl.h" | 
 
 
 
 
 | 19 |  | 
 
 
 
 
 | 20 | #include "inifile.h" | 
 
 
 
 
 | 21 |  | 
 
 
 
 
 | 22 | HMODULE DDrDLLModule; | 
 
 
 
 
 | 23 | HMODULE DDrONiModule; | 
 
 
 
 
 | 24 |  | 
 
 
 
 
 | 25 | bool patch_fonttexturecache = true; | 
 
 
 
 
 | 26 | bool patch_largetextures = true; | 
 
 
 
 
 | 27 | bool patch_levelplugins = true; | 
 
 
 
 
 | 28 | bool patch_pathfinding = true; | 
 
 
 
 
 | 29 | bool patch_projaware = true; | 
 
 
 
 
 | 30 | bool patch_directinput = true; | 
 
 
 
 
 | 31 | bool patch_wpfadetime = true; | 
 
 
 
 
 | 32 | bool patch_kickguns = false; | 
 
 
 
 
 | 33 | bool patch_cooldowntimer = true; | 
 
 
 
 
 | 34 | bool patch_throwtest = false; | 
 
 
 
 
 | 35 | bool patch_alttab = true; | 
 
 
 
 
 | 36 | bool patch_particledisablebit = false; | 
 
 
 
 
 | 37 | bool patch_multibyte = false; | 
 
 
 
 
 | 38 | bool patch_cheattable = true; | 
 
 
 
 
 | 39 | bool patch_argb8888 = true; | 
 
 
 
 
 | 40 |  | 
 
 
 
 
 | 41 | bool patch_safeprintf = true; | 
 
 
 
 
 | 42 | bool patch_daodandisplayenum = true; | 
 
 
 
 
 | 43 | bool patch_usegettickcount = true; | 
 
 
 
 
 | 44 | bool patch_cheatsenabled = true; | 
 
 
 
 
 | 45 | bool patch_usedaodangl = false; | 
 
 
 
 
 | 46 | bool patch_windowhack = true; | 
 
 
 
 
 | 47 |  | 
 
 
 
 
 | 48 | bool DDrPatch_Init() | 
 
 
 
 
 | 49 | { | 
 
 
 
 
 | 50 | DDrStartupMessage("patching engine"); | 
 
 
 
 
 | 51 |  | 
 
 
 
 
 | 52 | // Font texture cache doubled | 
 
 
 
 
 | 53 | if (patch_fonttexturecache) | 
 
 
 
 
 | 54 | { | 
 
 
 
 
 | 55 | DDrPatch_Byte  (OniExe + 0x00020ea7, 0x20); | 
 
 
 
 
 | 56 | DDrPatch_Byte  (OniExe + 0x00020f4a, 0x40); | 
 
 
 
 
 | 57 | } | 
 
 
 
 
 | 58 |  | 
 
 
 
 
 | 59 | // Now supports textures up to 512x512 | 
 
 
 
 
 | 60 | if (patch_largetextures) | 
 
 
 
 
 | 61 | DDrPatch_Byte  (OniExe + 0x00005251, 0x10); | 
 
 
 
 
 | 62 |  | 
 
 
 
 
 | 63 | // Non-"_Final" levels are now valid | 
 
 
 
 
 | 64 | if (patch_levelplugins) | 
 
 
 
 
 | 65 | DDrPatch_Byte  (OniExe + 0x000206a8, 0x01); | 
 
 
 
 
 | 66 |  | 
 
 
 
 
 | 67 | // Pathfinding grid cache size x8 | 
 
 
 
 
 | 68 | if (patch_pathfinding) | 
 
 
 
 
 | 69 | { | 
 
 
 
 
 | 70 | DDrPatch_Byte  (OniExe + 0x0010b03b, 0x20); | 
 
 
 
 
 | 71 | DDrPatch_Byte  (OniExe + 0x0010b04c, 0x20); | 
 
 
 
 
 | 72 | } | 
 
 
 
 
 | 73 |  | 
 
 
 
 
 | 74 | // Projectile awareness fixed | 
 
 
 
 
 | 75 | if (patch_projaware) | 
 
 
 
 
 | 76 | { | 
 
 
 
 
 | 77 | DDrPatch_Byte  (OniExe + 0x0009c07c, 0x6c); | 
 
 
 
 
 | 78 | DDrPatch_Byte  (OniExe + 0x0009c080, 0x70); | 
 
 
 
 
 | 79 | DDrPatch_Byte  (OniExe + 0x0009c084, 0x74); | 
 
 
 
 
 | 80 | DDrPatch_Byte  (OniExe + 0x0009c110, 0x6c); | 
 
 
 
 
 | 81 | } | 
 
 
 
 
 | 82 |  | 
 
 
 
 
 | 83 | // Forced DirectInput (for Windows NT) | 
 
 
 
 
 | 84 | if (patch_directinput) | 
 
 
 
 
 | 85 | DDrPatch_Byte  (OniExe + 0x00002e6d, 0xeb); | 
 
 
 
 
 | 86 |  | 
 
 
 
 
 | 87 | if (patch_wpfadetime) | 
 
 
 
 
 | 88 | { | 
 
 
 
 
 | 89 | // Makes wp_fadetime actually have a function | 
 
 
 
 
 | 90 | const char fadetime_patch[] = { 0x66, 0x8B, 0x1D, 0xC4, 0x7D, 0x62, 0x00, 0x66, 0x89, 0x5E, 0x46, 0x5B, 0x5E, 0x83, 0xC4, 0x14, 0xC3 }; | 
 
 
 
 
 | 91 | DDrPatch_Const (OniExe + 0x0011a889, fadetime_patch); | 
 
 
 
 
 | 92 | DDrPatch_Byte  (OniExe + 0x0011a560, 0x31); | 
 
 
 
 
 | 93 |  | 
 
 
 
 
 | 94 | // Sets the fadetime to 4800 by default | 
 
 
 
 
 | 95 | DDrPatch_Int16 (OniExe + 0x0011ab0e, 0x12c0); | 
 
 
 
 
 | 96 | } | 
 
 
 
 
 | 97 |  | 
 
 
 
 
 | 98 |  | 
 
 
 
 
 | 99 | // Hackish fix for Konoko not kicking guns | 
 
 
 
 
 | 100 | if (patch_kickguns) | 
 
 
 
 
 | 101 | { | 
 
 
 
 
 | 102 | 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 }; | 
 
 
 
 
 | 103 | DDrPatch_Const (OniExe + 0x000dc420, kickgun_patch); | 
 
 
 
 
 | 104 | } | 
 
 
 
 
 | 105 |  | 
 
 
 
 
 | 106 | // Cooldown timer exploit fix ^_^ | 
 
 
 
 
 | 107 | if (patch_cooldowntimer) | 
 
 
 
 
 | 108 | { | 
 
 
 
 
 | 109 | 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 }; | 
 
 
 
 
 | 110 | DDrPatch_Const (OniExe + 0x0011a825, cooldown_patch); | 
 
 
 
 
 | 111 | } | 
 
 
 
 
 | 112 |  | 
 
 
 
 
 | 113 | if (patch_throwtest) | 
 
 
 
 
 | 114 | { | 
 
 
 
 
 | 115 | const char throwtest_patch[] = { 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 }; | 
 
 
 
 
 | 116 | DDrPatch_Const(OniExe + 0x000dc190, throwtest_patch); | 
 
 
 
 
 | 117 | } | 
 
 
 
 
 | 118 |  | 
 
 
 
 
 | 119 | // 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. | 
 
 
 
 
 | 120 | if (patch_alttab) | 
 
 
 
 
 | 121 | { | 
 
 
 
 
 | 122 | DDrPatch_Byte  ((void*)UUrPlatform_Initialize, 0xC3); | 
 
 
 
 
 | 123 | DDrPatch_Byte  ((void*)UUrPlatform_Terminate, 0xC3); | 
 
 
 
 
 | 124 | } | 
 
 
 
 
 | 125 |  | 
 
 
 
 
 | 126 | // 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.) | 
 
 
 
 
 | 127 | if (patch_particledisablebit) | 
 
 
 
 
 | 128 | DDrPatch_Int16 (OniExe + 0x001b184, 0x9090); | 
 
 
 
 
 | 129 |  | 
 
 
 
 
 | 130 | // Multi-byte patch (multiple language support) | 
 
 
 
 
 | 131 | if (!patch_multibyte) | 
 
 
 
 
 | 132 | { | 
 
 
 
 
 | 133 | DDrPatch_Byte  (OniExe + 0x0002d8f8, 0xeb); | 
 
 
 
 
 | 134 | DDrPatch_Byte  (OniExe + 0x0002d9ad, 0xeb); | 
 
 
 
 
 | 135 | DDrPatch_Byte  (OniExe + 0x0002dbe2, 0xeb); | 
 
 
 
 
 | 136 | DDrPatch_Byte  (OniExe + 0x0002dec3, 0xeb); | 
 
 
 
 
 | 137 | DDrPatch_Byte  (OniExe + 0x0002e2ab, 0xeb); | 
 
 
 
 
 | 138 | DDrPatch_Byte  (OniExe + 0x0002e2c4, 0xeb); | 
 
 
 
 
 | 139 | DDrPatch_Byte  (OniExe + 0x0002e379, 0xeb); | 
 
 
 
 
 | 140 | DDrPatch_Byte  (OniExe + 0x0002e48c, 0xeb); | 
 
 
 
 
 | 141 | DDrPatch_Byte  (OniExe + 0x0002e4d0, 0xeb); | 
 
 
 
 
 | 142 | DDrPatch_Byte  (OniExe + 0x0002e4f4, 0xeb); | 
 
 
 
 
 | 143 | DDrPatch_Byte  (OniExe + 0x0002e646, 0xeb); | 
 
 
 
 
 | 144 | DDrPatch_Byte  (OniExe + 0x0002e695, 0xeb); | 
 
 
 
 
 | 145 | DDrPatch_Byte  (OniExe + 0x0002e944, 0xeb); | 
 
 
 
 
 | 146 | DDrPatch_Byte  (OniExe + 0x0002e95d, 0xeb); | 
 
 
 
 
 | 147 | DDrPatch_Byte  (OniExe + 0x0002e98e, 0xeb); | 
 
 
 
 
 | 148 | DDrPatch_Byte  (OniExe + 0x0002e9dc, 0xeb); | 
 
 
 
 
 | 149 | } | 
 
 
 
 
 | 150 |  | 
 
 
 
 
 | 151 | // Cheat table patch | 
 
 
 
 
 | 152 | if (patch_cheattable) | 
 
 
 
 
 | 153 | { | 
 
 
 
 
 | 154 | DDrPatch_Int32 (OniExe + 0x000f616b, (int)&DDr_CheatTable[0].name); | 
 
 
 
 
 | 155 | DDrPatch_Int32 (OniExe + 0x000f617a, (int)&DDr_CheatTable[0].message_on); | 
 
 
 
 
 | 156 | } | 
 
 
 
 
 | 157 |  | 
 
 
 
 
 | 158 | if (patch_argb8888) | 
 
 
 
 
 | 159 | { | 
 
 
 
 
 | 160 | DDrPatch_Byte  (OniExe + 0x00135af0, 0x07); | 
 
 
 
 
 | 161 | DDrPatch_Byte  (OniExe + 0x00135af4, 0x0B); | 
 
 
 
 
 | 162 | } | 
 
 
 
 
 | 163 |  | 
 
 
 
 
 | 164 | return true; | 
 
 
 
 
 | 165 | } | 
 
 
 
 
 | 166 |  | 
 
 
 
 
 | 167 | enum {s_unknown, s_patch, s_language} ini_section; | 
 
 
 
 
 | 168 |  | 
 
 
 
 
 | 169 | bool DDrIniCallback(char* section, bool newsection, char* name, char* value) | 
 
 
 
 
 | 170 | { | 
 
 
 
 
 | 171 | if (newsection) | 
 
 
 
 
 | 172 | { | 
 
 
 
 
 | 173 | if (!stricmp(section, "patch")) | 
 
 
 
 
 | 174 | ini_section = s_patch; | 
 
 
 
 
 | 175 | else if (!stricmp(section, "language")) | 
 
 
 
 
 | 176 | ini_section = s_language; | 
 
 
 
 
 | 177 | else | 
 
 
 
 
 | 178 | { | 
 
 
 
 
 | 179 | ini_section = s_unknown; | 
 
 
 
 
 | 180 | DDrStartupMessage("unrecognised ini section \"%s\"", section); | 
 
 
 
 
 | 181 | } | 
 
 
 
 
 | 182 | } | 
 
 
 
 
 | 183 |  | 
 
 
 
 
 | 184 | switch (ini_section) | 
 
 
 
 
 | 185 | { | 
 
 
 
 
 | 186 | case s_patch: | 
 
 
 
 
 | 187 | if (!stricmp(name, "fonttexturecache")) | 
 
 
 
 
 | 188 | patch_fonttexturecache = !stricmp(value, "true"); | 
 
 
 
 
 | 189 | else if (!stricmp(name, "largetextures")) | 
 
 
 
 
 | 190 | patch_largetextures = !stricmp(value, "true"); | 
 
 
 
 
 | 191 | else if (!stricmp(name, "levelplugins")) | 
 
 
 
 
 | 192 | patch_levelplugins = !stricmp(value, "true"); | 
 
 
 
 
 | 193 | else if (!stricmp(name, "pathfinding")) | 
 
 
 
 
 | 194 | patch_pathfinding = !stricmp(value, "true"); | 
 
 
 
 
 | 195 | else if (!stricmp(name, "projaware")) | 
 
 
 
 
 | 196 | patch_projaware = !stricmp(value, "true"); | 
 
 
 
 
 | 197 | else if (!stricmp(name, "directinput")) | 
 
 
 
 
 | 198 | patch_directinput = !stricmp(value, "true"); | 
 
 
 
 
 | 199 | else if (!stricmp(name, "wpfadetime")) | 
 
 
 
 
 | 200 | patch_wpfadetime = !stricmp(value, "true"); | 
 
 
 
 
 | 201 | else if (!stricmp(name, "kickguns")) | 
 
 
 
 
 | 202 | patch_kickguns = !stricmp(value, "true"); | 
 
 
 
 
 | 203 | else if (!stricmp(name, "cooldowntimer")) | 
 
 
 
 
 | 204 | patch_cooldowntimer = !stricmp(value, "true"); | 
 
 
 
 
 | 205 | else if (!stricmp(name, "throwtest")) | 
 
 
 
 
 | 206 | patch_throwtest = !stricmp(value, "true"); | 
 
 
 
 
 | 207 | else if (!stricmp(name, "alttab")) | 
 
 
 
 
 | 208 | patch_alttab = !stricmp(value, "true"); | 
 
 
 
 
 | 209 | else if (!stricmp(name, "particledisablebit")) | 
 
 
 
 
 | 210 | patch_particledisablebit = !stricmp(value, "true"); | 
 
 
 
 
 | 211 | else if (!stricmp(name, "multibyte")) | 
 
 
 
 
 | 212 | patch_multibyte = !stricmp(value, "true"); | 
 
 
 
 
 | 213 | else if (!stricmp(name, "cheattable")) | 
 
 
 
 
 | 214 | patch_cheattable = !stricmp(value, "true"); | 
 
 
 
 
 | 215 | else if (!stricmp(name, "argb8888")) | 
 
 
 
 
 | 216 | patch_argb8888 = !stricmp(value, "true"); | 
 
 
 
 
 | 217 | else if (!stricmp(name, "safeprintf")) | 
 
 
 
 
 | 218 | patch_safeprintf = !stricmp(value, "true"); | 
 
 
 
 
 | 219 | else if (!stricmp(name, "daodandisplayenum")) | 
 
 
 
 
 | 220 | patch_daodandisplayenum = !stricmp(value, "true"); | 
 
 
 
 
 | 221 | else if (!stricmp(name, "usegettickcount")) | 
 
 
 
 
 | 222 | patch_usegettickcount = !stricmp(value, "true"); | 
 
 
 
 
 | 223 | else if (!stricmp(name, "cheatsenabled")) | 
 
 
 
 
 | 224 | patch_cheatsenabled = !stricmp(value, "true"); | 
 
 
 
 
 | 225 | else if (!stricmp(name, "usedaodangl")) | 
 
 
 
 
 | 226 | patch_usedaodangl = !stricmp(value, "true"); | 
 
 
 
 
 | 227 | else if (!stricmp(name, "windowhack")) | 
 
 
 
 
 | 228 | patch_windowhack = !stricmp(value, "true"); | 
 
 
 
 
 | 229 | else | 
 
 
 
 
 | 230 | DDrStartupMessage("unrecognised patch \"%s\"", name); | 
 
 
 
 
 | 231 | break; | 
 
 
 
 
 | 232 | case s_language: | 
 
 
 
 
 | 233 | if (!stricmp(name, "savepoint")) | 
 
 
 
 
 | 234 | { | 
 
 
 
 
 | 235 | char* str = strdup(value); | 
 
 
 
 
 | 236 | DDrPatch_Int32(OniExe + 0x000fd730, (int)str); | 
 
 
 
 
 | 237 | DDrPatch_Int32(OniExe + 0x000fd738, (int)str); | 
 
 
 
 
 | 238 | } | 
 
 
 
 
 | 239 | else if (!stricmp(name, "syndicatewarehouse")) | 
 
 
 
 
 | 240 | { | 
 
 
 
 
 | 241 | char* str = strdup(value); | 
 
 
 
 
 | 242 | DDrPatch_Int32(OniExe + 0x000fd71a, (int)str); | 
 
 
 
 
 | 243 | DDrPatch_Int32(OniExe + 0x0010ef75, (int)str); | 
 
 
 
 
 | 244 | } | 
 
 
 
 
 | 245 | else if (!stricmp(name, "damn")) | 
 
 
 
 
 | 246 | DDrPatch_StrDup(OniExe + 0x0010fb6e, value); | 
 
 
 
 
 | 247 | else if (!stricmp(name, "blam")) | 
 
 
 
 
 | 248 | DDrPatch_StrDup(OniExe + 0x0010fb73, value); | 
 
 
 
 
 | 249 | else if (!stricmp(name, "shapeshifter_on")) | 
 
 
 
 
 | 250 | DDr_CheatTable[0].message_on = strdup(value); | 
 
 
 
 
 | 251 | else if (!stricmp(name, "shapeshifter_off")) | 
 
 
 
 
 | 252 | DDr_CheatTable[0].message_off = strdup(value); | 
 
 
 
 
 | 253 | else if (!stricmp(name, "liveforever_on")) | 
 
 
 
 
 | 254 | DDr_CheatTable[1].message_on = strdup(value); | 
 
 
 
 
 | 255 | else if (!stricmp(name, "liveforever_off")) | 
 
 
 
 
 | 256 | DDr_CheatTable[1].message_off = strdup(value); | 
 
 
 
 
 | 257 | else if (!stricmp(name, "touchofdeath_on")) | 
 
 
 
 
 | 258 | DDr_CheatTable[2].message_on = strdup(value); | 
 
 
 
 
 | 259 | else if (!stricmp(name, "touchofdeath_off")) | 
 
 
 
 
 | 260 | DDr_CheatTable[2].message_off = strdup(value); | 
 
 
 
 
 | 261 | else if (!stricmp(name, "canttouchthis_on")) | 
 
 
 
 
 | 262 | DDr_CheatTable[3].message_on = strdup(value); | 
 
 
 
 
 | 263 | else if (!stricmp(name, "canttouchthis_off")) | 
 
 
 
 
 | 264 | DDr_CheatTable[3].message_off = strdup(value); | 
 
 
 
 
 | 265 | else if (!stricmp(name, "fatloot_on")) | 
 
 
 
 
 | 266 | DDr_CheatTable[4].message_on = strdup(value); | 
 
 
 
 
 | 267 | else if (!stricmp(name, "glassworld_on")) | 
 
 
 
 
 | 268 | DDr_CheatTable[5].message_on = strdup(value); | 
 
 
 
 
 | 269 | else if (!stricmp(name, "glassworld_off")) | 
 
 
 
 
 | 270 | DDr_CheatTable[5].message_off = strdup(value); | 
 
 
 
 
 | 271 | else if (!stricmp(name, "winlevel_on")) | 
 
 
 
 
 | 272 | DDr_CheatTable[6].message_on = strdup(value); | 
 
 
 
 
 | 273 | else if (!stricmp(name, "loselevel_on")) | 
 
 
 
 
 | 274 | DDr_CheatTable[7].message_on = strdup(value); | 
 
 
 
 
 | 275 | else if (!stricmp(name, "bighead_on")) | 
 
 
 
 
 | 276 | DDr_CheatTable[8].message_on = strdup(value); | 
 
 
 
 
 | 277 | else if (!stricmp(name, "bighead_off")) | 
 
 
 
 
 | 278 | DDr_CheatTable[8].message_off = strdup(value); | 
 
 
 
 
 | 279 | else if (!stricmp(name, "minime_on")) | 
 
 
 
 
 | 280 | DDr_CheatTable[9].message_on = strdup(value); | 
 
 
 
 
 | 281 | else if (!stricmp(name, "minime_off")) | 
 
 
 
 
 | 282 | DDr_CheatTable[9].message_off = strdup(value); | 
 
 
 
 
 | 283 | else if (!stricmp(name, "superammo_on")) | 
 
 
 
 
 | 284 | DDr_CheatTable[10].message_on = strdup(value); | 
 
 
 
 
 | 285 | else if (!stricmp(name, "superammo_off")) | 
 
 
 
 
 | 286 | DDr_CheatTable[10].message_off = strdup(value); | 
 
 
 
 
 | 287 | else if (!stricmp(name, "devmode_on")) | 
 
 
 
 
 | 288 | { | 
 
 
 
 
 | 289 | char* str = strdup(value); | 
 
 
 
 
 | 290 | DDr_CheatTable[11].message_on = str; | 
 
 
 
 
 | 291 | DDr_CheatTable[cheat_devmodex].message_on = str; | 
 
 
 
 
 | 292 | } | 
 
 
 
 
 | 293 | else if (!stricmp(name, "devmode_off")) | 
 
 
 
 
 | 294 | { | 
 
 
 
 
 | 295 | char* str = strdup(value); | 
 
 
 
 
 | 296 | DDr_CheatTable[11].message_off = str; | 
 
 
 
 
 | 297 | DDr_CheatTable[cheat_devmodex].message_off = str; | 
 
 
 
 
 | 298 | } | 
 
 
 
 
 | 299 | else if (!stricmp(name, "reservoirdogs_on")) | 
 
 
 
 
 | 300 | DDr_CheatTable[12].message_on = strdup(value); | 
 
 
 
 
 | 301 | else if (!stricmp(name, "reservoirdogs_off")) | 
 
 
 
 
 | 302 | DDr_CheatTable[12].message_off = strdup(value); | 
 
 
 
 
 | 303 | else if (!stricmp(name, "roughjustice_on")) | 
 
 
 
 
 | 304 | DDr_CheatTable[13].message_on = strdup(value); | 
 
 
 
 
 | 305 | else if (!stricmp(name, "roughjustice_off")) | 
 
 
 
 
 | 306 | DDr_CheatTable[13].message_off = strdup(value); | 
 
 
 
 
 | 307 | else if (!stricmp(name, "chenille_on")) | 
 
 
 
 
 | 308 | DDr_CheatTable[14].message_on = strdup(value); | 
 
 
 
 
 | 309 | else if (!stricmp(name, "chenille_off")) | 
 
 
 
 
 | 310 | DDr_CheatTable[14].message_off = strdup(value); | 
 
 
 
 
 | 311 | else if (!stricmp(name, "behemoth_on")) | 
 
 
 
 
 | 312 | DDr_CheatTable[15].message_on = strdup(value); | 
 
 
 
 
 | 313 | else if (!stricmp(name, "behemoth_off")) | 
 
 
 
 
 | 314 | DDr_CheatTable[15].message_off = strdup(value); | 
 
 
 
 
 | 315 | else if (!stricmp(name, "elderrune_on")) | 
 
 
 
 
 | 316 | DDr_CheatTable[16].message_on = strdup(value); | 
 
 
 
 
 | 317 | else if (!stricmp(name, "elderrune_off")) | 
 
 
 
 
 | 318 | DDr_CheatTable[16].message_off = strdup(value); | 
 
 
 
 
 | 319 | else if (!stricmp(name, "moonshadow_on")) | 
 
 
 
 
 | 320 | DDr_CheatTable[17].message_on = strdup(value); | 
 
 
 
 
 | 321 | else if (!stricmp(name, "moonshadow_off")) | 
 
 
 
 
 | 322 | DDr_CheatTable[17].message_off = strdup(value); | 
 
 
 
 
 | 323 | else if (!stricmp(name, "munitionfrenzy_on")) | 
 
 
 
 
 | 324 | DDr_CheatTable[18].message_on = strdup(value); | 
 
 
 
 
 | 325 | else if (!stricmp(name, "fistsoflegend_on")) | 
 
 
 
 
 | 326 | DDr_CheatTable[19].message_on = strdup(value); | 
 
 
 
 
 | 327 | else if (!stricmp(name, "fistsoflegend_off")) | 
 
 
 
 
 | 328 | DDr_CheatTable[19].message_off = strdup(value); | 
 
 
 
 
 | 329 | else if (!stricmp(name, "killmequick_on")) | 
 
 
 
 
 | 330 | DDr_CheatTable[20].message_on = strdup(value); | 
 
 
 
 
 | 331 | else if (!stricmp(name, "killmequick_off")) | 
 
 
 
 
 | 332 | DDr_CheatTable[20].message_off = strdup(value); | 
 
 
 
 
 | 333 | else if (!stricmp(name, "carousel_on")) | 
 
 
 
 
 | 334 | DDr_CheatTable[21].message_on = strdup(value); | 
 
 
 
 
 | 335 | else if (!stricmp(name, "carousel_off")) | 
 
 
 
 
 | 336 | DDr_CheatTable[21].message_off = strdup(value); | 
 
 
 
 
 | 337 | else | 
 
 
 
 
 | 338 | DDrStartupMessage("unrecognised language item \"%s\"", name); | 
 
 
 
 
 | 339 | break; | 
 
 
 
 
 | 340 | default: | 
 
 
 
 
 | 341 | break; | 
 
 
 
 
 | 342 | } | 
 
 
 
 
 | 343 |  | 
 
 
 
 
 | 344 | return true; | 
 
 
 
 
 | 345 | } | 
 
 
 
 
 | 346 |  | 
 
 
 
 
 | 347 | void DDrConfig() | 
 
 
 
 
 | 348 | { | 
 
 
 
 
 | 349 | if (GetFileAttributes("daodan.ini") == INVALID_FILE_ATTRIBUTES) | 
 
 
 
 
 | 350 | { | 
 
 
 
 
 | 351 | DDrStartupMessage("daodan.ini doesn't exist, creating"); | 
 
 
 
 
 | 352 | FILE* fp = fopen("daodan.ini", "w"); | 
 
 
 
 
 | 353 | if (fp) | 
 
 
 
 
 | 354 | { | 
 
 
 
 
 | 355 | fputs("[Options]\n", fp); | 
 
 
 
 
 | 356 | fclose(fp); | 
 
 
 
 
 | 357 | } | 
 
 
 
 
 | 358 | } | 
 
 
 
 
 | 359 |  | 
 
 
 
 
 | 360 | DDrStartupMessage("parsing daodan.ini..."); | 
 
 
 
 
 | 361 | if (!inifile_read("daodan.ini", DDrIniCallback)) | 
 
 
 
 
 | 362 | DDrStartupMessage("error reading daodan.ini, check your syntax!"); | 
 
 
 
 
 | 363 | DDrStartupMessage("finished parsing"); | 
 
 
 
 
 | 364 | } | 
 
 
 
 
 | 365 |  | 
 
 
 
 
 | 366 | void __cdecl DDrMain(int argc, char* argv[]) | 
 
 
 
 
 | 367 | { | 
 
 
 
 
 | 368 | DDrStartupMessage("daodan attached!"); | 
 
 
 
 
 | 369 | DDrConfig(); | 
 
 
 
 
 | 370 | DDrPatch_Init(); | 
 
 
 
 
 | 371 |  | 
 
 
 
 
 | 372 | // Safe startup message printer | 
 
 
 
 
 | 373 | if (patch_safeprintf) | 
 
 
 
 
 | 374 | DDrPatch_MakeJump(UUrStartupMessage, DDrStartupMessage); | 
 
 
 
 
 | 375 |  | 
 
 
 
 
 | 376 | // Daodan device mode enumeration function | 
 
 
 
 
 | 377 | if (patch_daodandisplayenum) | 
 
 
 
 
 | 378 | DDrPatch_MakeJump(gl_enumerate_valid_display_modes, daodan_enumerate_valid_display_modes); | 
 
 
 
 
 | 379 |  | 
 
 
 
 
 | 380 | // Performance patch | 
 
 
 
 
 | 381 | if (patch_usegettickcount) | 
 
 
 
 
 | 382 | { | 
 
 
 
 
 | 383 | DDrPatch_MakeJump(UUrMachineTime_High, DDrMachineTime_High); | 
 
 
 
 
 | 384 | DDrPatch_MakeJump(UUrMachineTime_High_Frequency, DDrMachineTime_High_Frequency); | 
 
 
 
 
 | 385 | DDrPatch_MakeJump(UUrMachineTime_Sixtieths, DDrMachineTime_Sixtieths); | 
 
 
 
 
 | 386 | } | 
 
 
 
 
 | 387 |  | 
 
 
 
 
 | 388 | // Cheats always enabled | 
 
 
 
 
 | 389 | if (patch_cheatsenabled) | 
 
 
 
 
 | 390 | DDrPatch_MakeJump(ONrPersist_GetWonGame, DDrPersist_GetWonGame); | 
 
 
 
 
 | 391 |  | 
 
 
 
 
 | 392 | // Windowed mode | 
 
 
 
 
 | 393 | if (patch_usedaodangl) | 
 
 
 
 
 | 394 | { | 
 
 
 
 
 | 395 | DDrPatch_MakeJump(ONrPlatform_Initialize, DDrPlatform_Initialize); | 
 
 
 
 
 | 396 | DDrPatch_MakeJump(gl_platform_initialize, daodangl_platform_initialize); | 
 
 
 
 
 | 397 | } | 
 
 
 
 
 | 398 |  | 
 
 
 
 
 | 399 | // Hacked windowed mode (for when daodangl isn't working properly) | 
 
 
 
 
 | 400 | if (patch_windowhack) | 
 
 
 
 
 | 401 | DDrWindowHack_Install(); | 
 
 
 
 
 | 402 |  | 
 
 
 
 
 | 403 | init_daodan_gl(); | 
 
 
 
 
 | 404 |  | 
 
 
 
 
 | 405 | ONiMain(argc, argv); | 
 
 
 
 
 | 406 | } | 
 
 
 
 
 | 407 |  | 
 
 
 
 
 | 408 | BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) | 
 
 
 
 
 | 409 | { | 
 
 
 
 
 | 410 | switch (fdwReason) | 
 
 
 
 
 | 411 | { | 
 
 
 
 
 | 412 | case DLL_PROCESS_ATTACH: | 
 
 
 
 
 | 413 | DDrDLLModule = hinstDLL; | 
 
 
 
 
 | 414 | DDrONiModule = GetModuleHandle(NULL); | 
 
 
 
 
 | 415 |  | 
 
 
 
 
 | 416 | DDrPatch_MakeCall(OniExe + 0x0010fb49, DDrMain); | 
 
 
 
 
 | 417 |  | 
 
 
 
 
 | 418 | break; | 
 
 
 
 
 | 419 | } | 
 
 
 
 
 | 420 | return TRUE; | 
 
 
 
 
 | 421 | } |