From 2423d68e0a5b734843924743fe6729f842c07ca9 Mon Sep 17 00:00:00 2001 From: Guus Waals <_@guusw.nl> Date: Sun, 1 Jun 2025 23:30:20 +0800 Subject: [PATCH] Add fix --- game_re/gh_fix/r3_restore.cxx | 120 +++++++++++++++++++++++ game_re/gh_fix/r3_windowLockCursor.cxx | 39 ++++++++ game_re/gh_fix/r3_windowUnlockCursor.cxx | 25 +++++ 3 files changed, 184 insertions(+) create mode 100644 game_re/gh_fix/r3_restore.cxx create mode 100644 game_re/gh_fix/r3_windowLockCursor.cxx create mode 100644 game_re/gh_fix/r3_windowUnlockCursor.cxx diff --git a/game_re/gh_fix/r3_restore.cxx b/game_re/gh_fix/r3_restore.cxx new file mode 100644 index 00000000..4977a27b --- /dev/null +++ b/game_re/gh_fix/r3_restore.cxx @@ -0,0 +1,120 @@ +// AUTO-GENERATED FILE, MOVE TO 'gh_fix' FOLDER PREVENT OVERWRITING!!!!! + +#include +#include + +extern "C" { +undefined IPT_fn_vActivateAllEntryElements(void); // 00505490 // IPT_fn_vActivateAllEntryElements // cdecl // Params: | Types: | Return: undefined +undefined FUN_00443120(undefined4 param_1); // 00443120 // FUN_00443120 // cdecl // Params: param_1 | Types: undefined4 | Return: undefined +undefined FUN_004fb300(void); // 004fb300 // FUN_004fb300 // cdecl // Params: | Types: | Return: undefined +undefined FUN_0047bae0(void); // 0047bae0 // FUN_0047bae0 // cdecl // Params: | Types: | Return: undefined +void r3_noop(void * p_cTxt1, void * p_cTxt2); // 00401100 // r3_noop // stdcall // Params: p_cTxt1;p_cTxt2 | Types: void *;void * | Return: void +undefined r3_load_textures_2(void); // 00471760 // r3_load_textures_2 // cdecl // Params: | Types: | Return: undefined +undefined gfx_init2(void); // 00470be0 // gfx_init2 // cdecl // Params: | Types: | Return: undefined +undefined FUN_00402470(undefined4 param_1); // 00402470 // FUN_00402470 // cdecl // Params: param_1 | Types: undefined4 | Return: undefined +undefined FUN_00470410(void); // 00470410 // FUN_00470410 // cdecl // Params: | Types: | Return: undefined +undefined FUN_00445460(void); // 00445460 // FUN_00445460 // cdecl // Params: | Types: | Return: undefined +undefined FUN_00442c50(void); // 00442c50 // FUN_00442c50 // cdecl // Params: | Types: | Return: undefined +undefined FUN_0051a7a0(short hGLDDevice, undefined4 param_2); // 0051a7a0 // FUN_0051a7a0 // cdecl // Params: hGLDDevice;param_2 | Types: short;undefined4 | Return: undefined +undefined r3_closeConcatTextureFile(void); // 004711d0 // r3_closeConcatTextureFile // cdecl // Params: | Types: | Return: undefined +undefined r3_processInput1(void); // 00446f10 // r3_processInput1 // cdecl // Params: | Types: | Return: undefined +undefined SND_fn_vResumeSound(void); // 0040a1e0 // SND_fn_vResumeSound // cdecl // Params: | Types: | Return: undefined +undefined FUN_004fa650(void); // 004fa650 // FUN_004fa650 // cdecl // Params: | Types: | Return: undefined +undefined FUN_00445440(void); // 00445440 // FUN_00445440 // cdecl // Params: | Types: | Return: undefined +undefined FUN_004725a0(void); // 004725a0 // FUN_004725a0 // cdecl // Params: | Types: | Return: undefined +undefined FUN_00470db0(void); // 00470db0 // FUN_00470db0 // cdecl // Params: | Types: | Return: undefined +undefined r3_windowLockCursor(void); // 00401320 // r3_windowLockCursor // cdecl // Params: | Types: | Return: undefined +undefined FUN_00442f70(undefined4 param_1); // 00442f70 // FUN_00442f70 // cdecl // Params: param_1 | Types: undefined4 | Return: undefined +undefined FUN_00470350(void); // 00470350 // FUN_00470350 // cdecl // Params: | Types: | Return: undefined +undefined FUN_00503710(void); // 00503710 // FUN_00503710 // cdecl // Params: | Types: | Return: undefined +undefined FUN_00472150(void); // 00472150 // FUN_00472150 // cdecl // Params: | Types: | Return: undefined +undefined FUN_0051a900(short hGLDDevice); // 0051a900 // FUN_0051a900 // cdecl // Params: hGLDDevice | Types: short | Return: undefined +undefined level_displayFn(void); // 00446fc0 // level_displayFn // cdecl // Params: | Types: | Return: undefined +undefined FUN_005038e0(void); // 005038e0 // FUN_005038e0 // cdecl // Params: | Types: | Return: undefined + +// 00401490 // r3_restore(stdcall) +// Parameters: param_1 | Types: undefined4 | Return: undefined4 + +/* WARNING: Inlined function: r3_get_engine_mode */ + +undefined4 __stdcall r3_restore(undefined4 param_1) + +{ + HWND hWnd; + int iVar1; + DWORD DVar2; + + hWnd = g_gameHWND; + if (g_engineRunning != 0) { + return 0; + } + if (g_gameHWND == (HWND)0x0) { + return 0; + } + SetWindowTextA(g_gameHWND,g_windowTitleRestoring); + UpdateWindow(hWnd); + SetForegroundWindow(hWnd); + if ((code *)p_fn_vDisplayAll == r3_noop) { + /* Set window callback? */ + p_fn_vDisplayAll = level_displayFn; + } + if ((code *)PTR_r3_processInput1_005bdb1c == r3_noop) { + PTR_r3_processInput1_005bdb1c = r3_processInput1; + IPT_fn_vActivateAllEntryElements(); + } + iVar1 = FUN_0047bae0(); + if (iVar1 == 0) goto LAB_004015f7; + DVar2 = WaitForSingleObject(g_drawSemaphore,500); + if (DVar2 == 0x102) { + return 0; + } + FUN_004725a0(); + if (g_currentBinkMovie + Field<32, 4>() == 0) { + FUN_00470410(); + } + FUN_0051a900(g_stEngineStructure.hGLDDevice); + FUN_005038e0(); + FUN_00503710(); + FUN_004fb300(); + FUN_00472150(); + FUN_00470db0(); + FUN_00445440(); + gfx_init2(); + FUN_00445460(); + FUN_00402470(hWnd); + FUN_0051a7a0(g_stEngineStructure.hGLDDevice,0); + if (g_currentBinkMovie + Field<32, 4>() == 0) { + FUN_00442f70(0); + FUN_00443120(0); + FUN_00442f70(1); + FUN_00443120(1); + FUN_00470350(); + if (g_currentBinkMovie + Field<32, 4>() != 0) goto LAB_004015bc; + } + else { +LAB_004015bc: + FUN_00445440(); + } + r3_load_textures_2(); + if (((g_stEngineStructure.eEngineMode == E_EM_ModeStartingProgram) || + (g_stEngineStructure.eEngineMode == E_EM_ModeEnterGame)) || + (g_stEngineStructure.eEngineMode == E_EM_ModeEnterLevel)) { + FUN_004fa650(); + } + r3_closeConcatTextureFile(); + ReleaseSemaphore(g_drawSemaphore,1,(LPLONG)0x0); +LAB_004015f7: + g_stEngineStructure + Field<91, 1>() = 0; + SetWindowTextA(hWnd,g_windowTitle); + UpdateWindow(hWnd); + SetForegroundWindow(hWnd); + FUN_00442c50(); + SND_fn_vResumeSound(); + r3_windowLockCursor(); + /* Keep suspended + */ + return 0; +} + +} + diff --git a/game_re/gh_fix/r3_windowLockCursor.cxx b/game_re/gh_fix/r3_windowLockCursor.cxx new file mode 100644 index 00000000..d2a79d76 --- /dev/null +++ b/game_re/gh_fix/r3_windowLockCursor.cxx @@ -0,0 +1,39 @@ +// AUTO-GENERATED FILE, MOVE TO 'gh_fix' FOLDER PREVENT OVERWRITING!!!!! + +#include +#include + +extern "C" { +HWND getHWND(void); // 00401300 // getHWND // stdcall // Params: | Types: | Return: typedef HWND HWND__ * + +// 00401320 // r3_windowLockCursor(cdecl) +// Parameters: | Types: | Return: undefined + +void unknown r3_windowLockCursor(void) + +{ + HWND pHVar1; + tagRECT *ptVar2; + RECT RStack_30; + tagRECT local_20; + tagRECT tStack_10; + + if (g_initVar0 != '\0') { + ptVar2 = &local_20; + pHVar1 = getHWND(); + GetWindowRect(pHVar1,ptVar2); + ptVar2 = &tStack_10; + pHVar1 = getHWND(); + GetClientRect(pHVar1,ptVar2); + RStack_30.left = local_20.left + 5; + RStack_30.top = local_20.bottom - tStack_10.bottom; + RStack_30.right = tStack_10.right + -5 + RStack_30.left; + RStack_30.bottom = RStack_30.top + -5 + tStack_10.bottom; + ClipCursor(&RStack_30); + ShowCursor(0); + } + return; +} + +} + diff --git a/game_re/gh_fix/r3_windowUnlockCursor.cxx b/game_re/gh_fix/r3_windowUnlockCursor.cxx new file mode 100644 index 00000000..13dbb7fe --- /dev/null +++ b/game_re/gh_fix/r3_windowUnlockCursor.cxx @@ -0,0 +1,25 @@ +// AUTO-GENERATED FILE, MOVE TO 'gh_fix' FOLDER PREVENT OVERWRITING!!!!! + +#include +#include + +extern "C" { + +// 004013a0 // r3_windowUnlockCursor(cdecl) +// Parameters: | Types: | Return: void + +void default r3_windowUnlockCursor(void) + +{ + HCURSOR hCursor; + + /* IDC_ARROW */ + hCursor = LoadCursorA((HINSTANCE)0x0,(LPCSTR)0x7f00); + SetCursor(hCursor); + ClipCursor((RECT *)0x0); + ShowCursor(1); + return; +} + +} +