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