| 1 |
+ |
#include <windows.h> |
| 2 |
|
#include <string.h> |
| 3 |
+ |
#include <stdio.h> |
| 4 |
|
|
| 5 |
|
#include "Daodan.h" |
| 6 |
|
#include "Daodan_Patch.h" |
| 10 |
|
#include "Daodan_Persistence.h" |
| 11 |
|
#include "Daodan_BSL.h" |
| 12 |
|
#include "Daodan_Console.h" |
| 13 |
< |
#include "Daodan_WindowHack.h" |
| 13 |
> |
#include "Daodan_Config.h" |
| 14 |
|
|
| 15 |
|
#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" |
| 16 |
|
|
| 17 |
< |
#include "inifile.h" |
| 17 |
> |
#include "Oni_GL.h" |
| 18 |
> |
#include "Daodan_GL.h" |
| 19 |
|
|
| 20 |
|
HMODULE DDrDLLModule; |
| 21 |
|
HMODULE DDrONiModule; |
| 22 |
|
|
| 23 |
< |
bool patch_fonttexturecache = true; |
| 24 |
< |
bool patch_largetextures = true; |
| 25 |
< |
bool patch_levelplugins = true; |
| 26 |
< |
bool patch_pathfinding = true; |
| 27 |
< |
bool patch_projaware = true; |
| 28 |
< |
bool patch_directinput = true; |
| 29 |
< |
bool patch_wpfadetime = true; |
| 30 |
< |
bool patch_kickguns = false; |
| 31 |
< |
bool patch_cooldowntimer = true; |
| 32 |
< |
bool patch_throwtest = false; |
| 33 |
< |
bool patch_alttab = true; |
| 34 |
< |
bool patch_particledisablebit = false; |
| 35 |
< |
bool patch_multibyte = false; |
| 36 |
< |
bool patch_cheattable = true; |
| 37 |
< |
bool patch_argb8888 = true; |
| 38 |
< |
bool patch_killvtune = true; |
| 39 |
< |
bool patch_getcmdline = true; |
| 40 |
< |
bool patch_disablecmdline = 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 |
< |
bool patch_cheater = true; |
| 51 |
< |
bool patch_newweapon = true; |
| 52 |
< |
bool opt_usedaodanbsl = true; |
| 53 |
< |
bool opt_border = true; |
| 54 |
< |
bool opt_shadow = false; |
| 55 |
< |
bool opt_topmost = false; |
| 23 |
> |
typedef int (__cdecl *CHINESEPROC)(DWORD ThreadId); |
| 24 |
> |
|
| 25 |
> |
// Hooked WMrSlider_SetRange() in ONiOGU_Options_InitDialog. Disables a gamma |
| 26 |
> |
// slider in windowed mode. |
| 27 |
> |
static void ONICALL DD_ONiOGU_GammaSlider_SetRange(WMtWindow* window, int min_value, int max_value) |
| 28 |
> |
{ |
| 29 |
> |
WMrWindow_SetEnabled(window, M3gResolutionSwitch && opt_gamma); |
| 30 |
> |
WMrSlider_SetRange(window, min_value, max_value); |
| 31 |
> |
} |
| 32 |
> |
|
| 33 |
> |
void ONICALL DDrShowResumeButton(WMtWindow* window, int visibility) |
| 34 |
> |
{ |
| 35 |
> |
if (visibility) |
| 36 |
> |
WMrWindow_SetLocation(window, 150, 350); |
| 37 |
> |
WMrWindow_SetVisible(window, visibility); |
| 38 |
> |
} |
| 39 |
> |
|
| 40 |
> |
|
| 41 |
> |
/* Options always visible patch */ |
| 42 |
> |
void ONICALL DDrShowOptionsButton(WMtWindow* window, int visibility) |
| 43 |
> |
{ |
| 44 |
> |
WMrWindow_SetVisible(window, 1); |
| 45 |
> |
} |
| 46 |
> |
|
| 47 |
> |
void ONICALL DDrGame_Init() |
| 48 |
> |
{ |
| 49 |
> |
if (opt_usedaodanbsl) |
| 50 |
> |
SLrDaodan_Initialize(); |
| 51 |
> |
} |
| 52 |
> |
|
| 53 |
> |
|
| 54 |
> |
//this was broken |
| 55 |
> |
FILE** _UUgError_WarningFile = (FILE**)0x005711B4; |
| 56 |
> |
FILE *__fastcall DDrPrintWarning(int filename, int linenumber, unsigned __int16 errornum, int message) |
| 57 |
> |
{ |
| 58 |
> |
|
| 59 |
> |
FILE *v4; // eax@1 |
| 60 |
> |
FILE *result; // eax@4 |
| 61 |
> |
char v6[512]; // [sp+0h] [bp-100h]@1 |
| 62 |
> |
FILE* UUgError_WarningFile = *_UUgError_WarningFile; |
| 63 |
> |
|
| 64 |
> |
if (filename && message && (strlen((const char*)filename)+strlen((const char*)message))<420) { |
| 65 |
> |
sprintf( |
| 66 |
> |
v6, |
| 67 |
> |
"Error %x reported from File: %s, Line: %d (message follows) \r\n%s", |
| 68 |
> |
errornum, |
| 69 |
> |
(const char*)filename, |
| 70 |
> |
linenumber, |
| 71 |
> |
(const char*)message); |
| 72 |
> |
|
| 73 |
> |
if ( UUgError_WarningFile |
| 74 |
> |
|| (UUgError_WarningFile = oni_fopen("debugger.txt", "wb"), UUgError_WarningFile ) ) |
| 75 |
> |
{ |
| 76 |
> |
oni_fprintf(UUgError_WarningFile, "%s\r\n", v6); |
| 77 |
> |
oni_fflush(UUgError_WarningFile); |
| 78 |
> |
} |
| 79 |
> |
} |
| 80 |
> |
//oni_fprintf(stdout, v6); |
| 81 |
> |
//sprintf(&v6, "%s", message); |
| 82 |
> |
*_UUgError_WarningFile = UUgError_WarningFile; |
| 83 |
> |
result = UUgError_WarningFile; |
| 84 |
> |
return result; |
| 85 |
> |
} |
| 86 |
> |
|
| 87 |
|
|
| 60 |
– |
typedef int (__cdecl *CHINESEPROC)(DWORD WINAPI); |
| 61 |
– |
bool patch_chinese = false; |
| 88 |
|
bool DDrPatch_Init() |
| 89 |
|
{ |
| 90 |
< |
DDrStartupMessage("patching engine"); |
| 90 |
> |
DDrStartupMessage("Daodan: Patching engine"); |
| 91 |
|
|
| 92 |
|
// Font texture cache doubled |
| 93 |
|
if (patch_fonttexturecache) |
| 169 |
|
// 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. |
| 170 |
|
if (patch_alttab) |
| 171 |
|
{ |
| 172 |
+ |
// 0xC3 = ret, so makes those functions just have a "ret" instruction at their start |
| 173 |
|
DDrPatch_Byte ((char*)UUrPlatform_Initialize, 0xC3); |
| 174 |
|
DDrPatch_Byte ((char*)UUrPlatform_Terminate, 0xC3); |
| 175 |
|
} |
| 216 |
|
//Test newweap patch |
| 217 |
|
if (patch_newweapon) { |
| 218 |
|
|
| 219 |
< |
//Makes it always say "Recieved weapon_name." |
| 219 |
> |
//Makes it always say "Received weapon_name." |
| 220 |
|
//Needs check for loc_4DFC66 |
| 221 |
|
//DDrPatch_NOOP((char*)(OniExe + 0x000E4DF8),2); |
| 222 |
|
|
| 263 |
|
|
| 264 |
|
if(patch_chinese) |
| 265 |
|
{ |
| 266 |
< |
HMODULE dll = LoadLibrary("xfhsm_oni.dll"); |
| 240 |
< |
if( dll ) |
| 266 |
> |
if (GetFileAttributes("xfhsm_oni.dll") != INVALID_FILE_ATTRIBUTES) |
| 267 |
|
{ |
| 268 |
< |
void* proc = GetProcAddress( dll, "InstallHook" ); |
| 269 |
< |
if(proc) |
| 268 |
> |
HMODULE dll; |
| 269 |
> |
DWORD err; |
| 270 |
> |
|
| 271 |
> |
DDrStartupMessage("Daodan: Loading chinese DLL"); |
| 272 |
> |
dll = LoadLibrary("xfhsm_oni.dll"); |
| 273 |
> |
err = GetLastError(); |
| 274 |
> |
if( dll ) |
| 275 |
|
{ |
| 276 |
< |
((CHINESEPROC)proc)(GetCurrentThreadId()); |
| 276 |
> |
void* proc = GetProcAddress( dll, "InstallHook" ); |
| 277 |
> |
if(proc) |
| 278 |
> |
{ |
| 279 |
> |
((CHINESEPROC)proc)(GetCurrentThreadId()); |
| 280 |
> |
} |
| 281 |
> |
} else { |
| 282 |
> |
char msg[100]; |
| 283 |
> |
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, err, 0, msg, 100, NULL); |
| 284 |
> |
DDrStartupMessage("Daodan: Loading DLL failed with error %i: %s", err, msg); |
| 285 |
|
} |
| 286 |
|
} |
| 287 |
|
} |
| 320 |
|
|
| 321 |
|
//FLATLINE? DDrPatch_MakeCall((void*)(OniExe + 0x000C26CB), FLrHook_DoorOpen); |
| 322 |
|
//FLATLINE? DDrPatch_MakeCall((void*)(OniExe + 0x000EE3CF), FLrHook_ConsoleActivate); |
| 284 |
– |
return true; |
| 285 |
– |
} |
| 323 |
|
|
| 287 |
– |
enum {s_unknown, s_options, s_patch, s_bsl, s_language} ini_section; |
| 324 |
|
|
| 325 |
< |
bool DDrIniCallback(char* section, bool newsection, char* name, char* value) |
| 326 |
< |
{ |
| 291 |
< |
if (newsection) |
| 292 |
< |
{ |
| 293 |
< |
if (!_stricmp(section, "options")) |
| 294 |
< |
ini_section = s_options; |
| 295 |
< |
else if (!_stricmp(section, "patch")) |
| 296 |
< |
ini_section = s_patch; |
| 297 |
< |
else if (!_stricmp(section, "bsl")) |
| 298 |
< |
ini_section = s_bsl; |
| 299 |
< |
else if (!_stricmp(section, "language")) |
| 300 |
< |
ini_section = s_language; |
| 301 |
< |
else |
| 302 |
< |
{ |
| 303 |
< |
ini_section = s_unknown; |
| 304 |
< |
DDrStartupMessage("unrecognised section \"%s\"", section); |
| 305 |
< |
} |
| 306 |
< |
} |
| 307 |
< |
|
| 308 |
< |
switch (ini_section) |
| 325 |
> |
// Fix options not visible in main menu when a game was started |
| 326 |
> |
if(patch_optionsvisible) |
| 327 |
|
{ |
| 328 |
< |
case s_options: |
| 329 |
< |
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"); |
| 335 |
< |
else |
| 336 |
< |
DDrStartupMessage("unrecognised option \"%s\"", name); |
| 337 |
< |
break; |
| 338 |
< |
case s_patch: |
| 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"); |
| 395 |
< |
else |
| 396 |
< |
DDrStartupMessage("unrecognised patch \"%s\"", name); |
| 397 |
< |
break; |
| 398 |
< |
case s_language: |
| 399 |
< |
if (!_stricmp(name, "chinese")) |
| 400 |
< |
patch_chinese = true; |
| 401 |
< |
else if (!_stricmp(name, "savepoint")) |
| 402 |
< |
{ |
| 403 |
< |
char* str = _strdup(value); |
| 404 |
< |
DDrPatch_Int32((int*)(OniExe + 0x000fd730), (int)str); |
| 405 |
< |
DDrPatch_Int32((int*)(OniExe + 0x000fd738), (int)str); |
| 406 |
< |
} |
| 407 |
< |
else if (!_stricmp(name, "syndicatewarehouse")) |
| 408 |
< |
{ |
| 409 |
< |
char* str = _strdup(value); |
| 410 |
< |
DDrPatch_Int32((int*)(OniExe + 0x000fd71a), (int)str); |
| 411 |
< |
DDrPatch_Int32((int*)(OniExe + 0x0010ef75), (int)str); |
| 412 |
< |
} |
| 413 |
< |
else if (!_stricmp(name, "damn")) |
| 414 |
< |
DDrPatch__strdup((int*)(OniExe + 0x0010fb6e), value); |
| 415 |
< |
else if (!_stricmp(name, "blam")) |
| 416 |
< |
DDrPatch__strdup((int*)(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")) |
| 456 |
< |
{ |
| 457 |
< |
char* str = _strdup(value); |
| 458 |
< |
DDr_CheatTable[11].message_on = str; |
| 459 |
< |
DDr_CheatTable[cheat_x].message_on = str; |
| 460 |
< |
} |
| 461 |
< |
else if (!_stricmp(name, "devmode_off")) |
| 462 |
< |
{ |
| 463 |
< |
char* str = _strdup(value); |
| 464 |
< |
DDr_CheatTable[11].message_off = str; |
| 465 |
< |
DDr_CheatTable[cheat_x].message_off = str; |
| 466 |
< |
} |
| 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); |
| 505 |
< |
else |
| 506 |
< |
DDrStartupMessage("unrecognised language item \"%s\"", name); |
| 507 |
< |
break; |
| 508 |
< |
case s_bsl: |
| 509 |
< |
default: |
| 510 |
< |
break; |
| 328 |
> |
DDrPatch_MakeCall((void*)(OniExe + 0x000d2d2d), DDrShowOptionsButton); |
| 329 |
> |
DDrPatch_MakeCall((void*)(OniExe + 0x000d2d43), DDrShowResumeButton); |
| 330 |
|
} |
| 512 |
– |
|
| 513 |
– |
return true; |
| 514 |
– |
} |
| 331 |
|
|
| 332 |
< |
void DDrConfig() |
| 333 |
< |
{ |
| 334 |
< |
|
| 335 |
< |
if (GetFileAttributes("daodan.ini") == INVALID_FILE_ATTRIBUTES) |
| 332 |
> |
// Fix BinkBufferInit() call in BKrMovie_Play() to use GDI (DIB) blitting |
| 333 |
> |
// instead of DirectDraw; patch ONiRunGame to use the same method to play |
| 334 |
> |
// outro (ie., BKrMovie_Play() instead of ONrMovie_Play_Hardware() as the |
| 335 |
> |
// latter has problems on WINE). |
| 336 |
> |
if (patch_binkplay) |
| 337 |
|
{ |
| 338 |
< |
FILE* fp; |
| 339 |
< |
DDrStartupMessage("daodan.ini doesn't exist, creating"); |
| 340 |
< |
fp = fopen("daodan.ini", "w"); |
| 341 |
< |
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 |
< |
|
| 537 |
< |
void ONICALL DDrGame_Init() |
| 538 |
< |
{ |
| 539 |
< |
if (opt_usedaodanbsl) |
| 540 |
< |
SLrDaodan_Initalize(); |
| 541 |
< |
} |
| 542 |
< |
|
| 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 |
< |
|
| 559 |
< |
if (filename && message && (strlen((const char*)filename)+strlen((const char*)message))<420) { |
| 560 |
< |
sprintf( |
| 561 |
< |
v6, |
| 562 |
< |
"Error %x reported from File: %s, Line: %d (message follows) \r\n%s", |
| 563 |
< |
errornum, |
| 564 |
< |
(const char*)filename, |
| 565 |
< |
linenumber, |
| 566 |
< |
(const char*)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 |
< |
} |
| 338 |
> |
// push BINKBUFFERAUTO -> push BINKBUFFERDIBSECTION. |
| 339 |
> |
DDrPatch_Byte((void*)(OniExe + 0x0008829b + 1), 0x02); |
| 340 |
> |
// call ONrMovie_Play_Hardware -> call ONrMovie_Play |
| 341 |
> |
DDrPatch_MakeCall((void*)(OniExe + 0x000d496f), ONrMovie_Play); |
| 342 |
|
} |
| 575 |
– |
//oni_fprintf(stdout, v6); |
| 576 |
– |
//sprintf(&v6, "%s", message); |
| 577 |
– |
*_UUgError_WarningFile = UUgError_WarningFile; |
| 578 |
– |
result = UUgError_WarningFile; |
| 579 |
– |
return result; |
| 580 |
– |
} |
| 343 |
|
|
| 344 |
< |
void __cdecl DDrMain(int argc, char* argv[]) |
| 345 |
< |
{ |
| 346 |
< |
int i; |
| 347 |
< |
char* section; |
| 586 |
< |
char* option; |
| 587 |
< |
bool falseoption; |
| 344 |
> |
// Patch a gamma slider in Options dialog (unconditionally). |
| 345 |
> |
// ONiOGU_Options_InitDialog: replace WMrSlider_SetRange(gammaSliderWindow, ...) |
| 346 |
> |
// call with our hook function. |
| 347 |
> |
DDrPatch_MakeCall((void*)(OniExe + 0x000d262c), (void*)DD_ONiOGU_GammaSlider_SetRange); |
| 348 |
|
|
| 589 |
– |
DDrStartupMessage("daodan attached!"); |
| 590 |
– |
|
| 591 |
– |
opt_ignore_private_data = false; |
| 592 |
– |
opt_sound = true; |
| 593 |
– |
|
| 594 |
– |
DDrConfig(); |
| 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] != '-') |
| 606 |
– |
DDrIniCallback(section, true, option + 1, argv[++i]); |
| 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] != '-') |
| 616 |
– |
DDrIniCallback(NULL, false, section, argv[++i]); |
| 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"); |
| 628 |
– |
DDrPatch_Init(); |
| 629 |
– |
|
| 349 |
|
// Safe startup message printer |
| 350 |
|
if (patch_safeprintf) |
| 351 |
|
DDrPatch_MakeJump((void*)UUrStartupMessage, (void*)DDrStartupMessage); |
| 352 |
|
|
| 353 |
|
// Daodan device mode enumeration function |
| 354 |
|
if (patch_daodandisplayenum) |
| 355 |
< |
DDrPatch_MakeJump((void*)gl_enumerate_valid_display_modes, (void*)daodan_enumerate_valid_display_modes); |
| 355 |
> |
DDrPatch_MakeJump((void*)gl_enumerate_valid_display_modes, (void*)DD_GLrEnumerateDisplayModes); |
| 356 |
|
|
| 357 |
|
// Performance patch |
| 358 |
|
if (patch_usegettickcount) |
| 366 |
|
if (patch_cheatsenabled) |
| 367 |
|
DDrPatch_MakeJump((void*)ONrPersist_GetWonGame, (void*)DDrPersist_GetWonGame); |
| 368 |
|
|
| 369 |
< |
// Windowed mode |
| 369 |
> |
// DaodanGL with windowed mode support. |
| 370 |
|
if (patch_usedaodangl) |
| 371 |
|
{ |
| 372 |
< |
DDrPatch_NOOP((char*)(OniExe + 0x000032B7), 6); |
| 373 |
< |
DDrPatch_MakeCall((void*)(OniExe + 0x000032B7), (void*)LIiP_SetCursorPosHook); |
| 374 |
< |
|
| 375 |
< |
DDrPatch_NOOP((char*)(OniExe + 0x00003349), 6); |
| 376 |
< |
DDrPatch_MakeCall((void*)(OniExe + 0x00003349), (void*)LIiP_SetCursorPosHook); |
| 377 |
< |
DDrPatch_MakeJump((void*)ONrPlatform_Initialize, (void*)DDrPlatform_Initialize); |
| 378 |
< |
DDrPatch_MakeJump((void*)gl_platform_initialize, (void*)daodangl_platform_initialize); |
| 379 |
< |
} |
| 380 |
< |
// Hacked windowed mode (for when daodangl isn't working properly) |
| 381 |
< |
else if (patch_windowhack) |
| 382 |
< |
DDrWindowHack_Install(); |
| 372 |
> |
// LIrPlatform_Mode_Set: GetWindowRect -> GetClientRect. |
| 373 |
> |
DDrPatch_NOOP((char*) OniExe + 0x00002dd6, 6); |
| 374 |
> |
DDrPatch_MakeCall((char*) OniExe + 0x00002dd6, (void*) GetClientRect); |
| 375 |
> |
|
| 376 |
> |
// UUrWindow_GetSize: GetWindowRect -> GetClientRect. |
| 377 |
> |
DDrPatch_NOOP((char*) OniExe + 0x0002651c, 6); |
| 378 |
> |
DDrPatch_MakeCall((char*) OniExe + 0x0002651c, (void*) GetClientRect); |
| 379 |
> |
|
| 380 |
> |
// LIrPlatform_PollInputForAction: fix GetCursorPos call to return client coordinates. |
| 381 |
> |
DDrPatch_NOOP((char*) OniExe + 0x000032cc, 6); |
| 382 |
> |
DDrPatch_MakeCall((char*) OniExe + 0x000032cc, (void*) DD_GetCursorPos); |
| 383 |
> |
|
| 384 |
> |
// LIrPlatform_InputEvent_GetMouse: fix GetCursorPos call to return client coordinates. |
| 385 |
> |
DDrPatch_NOOP((char*) OniExe + 0x00002cc2, 6); |
| 386 |
> |
DDrPatch_MakeCall((char*) OniExe + 0x00002cc2, (void*) DD_GetCursorPos); |
| 387 |
> |
|
| 388 |
> |
// LIrPlatform_PollInputForAction: translate SetCursorPos position to screen coordinates. |
| 389 |
> |
DDrPatch_NOOP((char*) OniExe + 0x000032b7, 6); |
| 390 |
> |
DDrPatch_MakeCall((char*) OniExe + 0x000032b7, (void*) DD_SetCursorPos); |
| 391 |
> |
|
| 392 |
> |
// LIrPlatform_PollInputForAction: translate SetCursorPos position to screen coordinates. |
| 393 |
> |
DDrPatch_NOOP((char*) OniExe + 0x00003349, 6); |
| 394 |
> |
DDrPatch_MakeCall((char*) OniExe + 0x00003349, (void*) DD_SetCursorPos); |
| 395 |
> |
|
| 396 |
> |
// Replace ONrPlatformInitialize. |
| 397 |
> |
DDrPatch_MakeJump((void*) ONrPlatform_Initialize, (void*) DD_ONrPlatform_Initialize); |
| 398 |
> |
|
| 399 |
> |
// Replace gl_platform_initialize. |
| 400 |
> |
DDrPatch_MakeJump((void*) gl_platform_initialize, (void*) DD_GLrPlatform_Initialize); |
| 401 |
> |
|
| 402 |
> |
// Replace gl_platform_dispose. |
| 403 |
> |
DDrPatch_MakeJump((void *) gl_platform_dispose, (void*) DD_GLrPlatform_Dispose); |
| 404 |
> |
} |
| 405 |
> |
|
| 406 |
> |
if (patch_clipcursor) |
| 407 |
> |
{ |
| 408 |
> |
// LIrMode_Set: replace LIrPlatform_Mode_Set call with our hook. |
| 409 |
> |
DDrPatch_MakeCall((void*)(OniExe + 0x00003f9f), (void*) DD_LIrPlatform_Mode_Set); |
| 410 |
> |
|
| 411 |
> |
// LIrMode_Set_Internal: replace LIrPlatform_Mode_Set call with our hook. |
| 412 |
> |
DDrPatch_MakeCall((void*)(OniExe + 0x00003fff), (void*) DD_LIrPlatform_Mode_Set); |
| 413 |
> |
|
| 414 |
> |
// LIrTermiante: replace LIrPlatform_Terminate call with our hook. |
| 415 |
> |
DDrPatch_MakeCall((void*)(OniExe + 0x000004cb8), (void*) DD_LIrPlatform_Terminate); |
| 416 |
> |
} |
| 417 |
> |
|
| 418 |
|
|
| 419 |
|
if (patch_daodaninit) |
| 420 |
|
DDrPatch_MakeCall((void*)(OniExe + 0x000d345a), (void*)DDrGame_Init); |
| 433 |
|
DDrPatch_MakeJump((void*)(OniExe + 0x0010f021), (void*)DDrCheater_LevelLoad); |
| 434 |
|
} |
| 435 |
|
|
| 682 |
– |
//DDrPatch_MakeJump((void*)(OniExe + 0x000378c0, (void*)DDrException); |
| 436 |
|
DDrPatch_MakeJump((void*)(OniExe + 0x000245A0), (void*)DDrPrintWarning); |
| 437 |
< |
//init_daodan_gl(); |
| 437 |
> |
|
| 438 |
> |
|
| 439 |
> |
return true; |
| 440 |
> |
} |
| 441 |
> |
|
| 442 |
> |
|
| 443 |
> |
void DDrException() { |
| 444 |
> |
int* i = 0; |
| 445 |
> |
*i = 1; |
| 446 |
> |
} |
| 447 |
> |
|
| 448 |
> |
void __cdecl DDrMain(int argc, char* argv[]) |
| 449 |
> |
{ |
| 450 |
> |
DDrStartupMessage("Daodan: Daodan attached!"); |
| 451 |
> |
|
| 452 |
> |
// Tell Oni to not load non levelX_final-files by default: |
| 453 |
> |
opt_ignore_private_data = false; |
| 454 |
> |
|
| 455 |
> |
// Enable sound by default: |
| 456 |
> |
opt_sound = true; |
| 457 |
> |
|
| 458 |
> |
DDrConfig(argc, argv); |
| 459 |
> |
|
| 460 |
> |
DDrPatch_Init(); |
| 461 |
> |
|
| 462 |
|
|
| 463 |
< |
ONiMain(argc, argv); |
| 463 |
> |
ONiMain(argc, argv); |
| 464 |
|
} |
| 465 |
|
/* |
| 466 |
|
void DDrWrongExe() |