From f1626e846abd370f814cda0e7c4f4d88d3ba1bd8 Mon Sep 17 00:00:00 2001 From: NovaRain Date: Wed, 19 Oct 2022 09:32:00 +0800 Subject: [PATCH] Changed the check for unavailable hooks * easier to backport more discontinuous hooks if needed. --- sfall/FalloutEngine/Functions.cpp | 10 +++++++--- sfall/FalloutEngine/Functions.h | 2 +- sfall/Modules/HookScripts.cpp | 10 +++++----- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/sfall/FalloutEngine/Functions.cpp b/sfall/FalloutEngine/Functions.cpp index fa55b16c..3a713c4b 100644 --- a/sfall/FalloutEngine/Functions.cpp +++ b/sfall/FalloutEngine/Functions.cpp @@ -145,9 +145,13 @@ void __declspec(naked) interpretError(const char* fmt, ...) { __asm jmp fo::funcoffs::interpretError_; } -long __fastcall db_init(const char* path_dat, const char* path_patches) { - __asm mov ebx, edx; // don't delete - WRAP_WATCOM_FCALL2(db_init_, path_dat, path_patches); +long __stdcall db_init(const char* path_dat, const char* path_patches) { + __asm { + mov ebx, path_patches; + mov eax, path_dat; + xor edx, edx; + call fo::funcoffs::db_init_; + } } long __stdcall tile_num(long x, long y) { diff --git a/sfall/FalloutEngine/Functions.h b/sfall/FalloutEngine/Functions.h index 1655fc2b..e11f8d12 100644 --- a/sfall/FalloutEngine/Functions.h +++ b/sfall/FalloutEngine/Functions.h @@ -50,7 +50,7 @@ void interpretReturnValue(Program* scriptPtr, DWORD val, DWORD valType); // USE WITH CAUTION void __declspec() interpretError(const char* fmt, ...); -long __fastcall db_init(const char* path_dat, const char* path_patches); +long __stdcall db_init(const char* path_dat, const char* path_patches); long __stdcall tile_num(long x, long y); diff --git a/sfall/Modules/HookScripts.cpp b/sfall/Modules/HookScripts.cpp index 304e4d6d..e4f87a93 100644 --- a/sfall/Modules/HookScripts.cpp +++ b/sfall/Modules/HookScripts.cpp @@ -89,10 +89,10 @@ static HooksInjectInfo injectHooks[] = { {HOOK_INVENTORYMOVE, Inject_InventoryMoveHook, false}, {HOOK_INVENWIELD, Inject_InvenWieldHook, false}, {HOOK_ADJUSTFID, nullptr, true}, // always embedded to the engine - {-1, nullptr, true}, // dummy - {-1, nullptr, true}, // dummy - {-1, nullptr, true}, // dummy - {-1, nullptr, true}, // dummy + {-1, nullptr, false}, // dummy + {-1, nullptr, false}, // dummy + {-1, nullptr, false}, // dummy + {-1, nullptr, false}, // dummy {HOOK_GAMEMODECHANGE, nullptr, true}, // always embedded to the engine }; @@ -113,7 +113,7 @@ bool HookScripts::HookHasScript(int hookId) { } void HookScripts::RegisterHook(fo::Program* script, int id, int procNum, bool specReg) { - if (id >= numHooks || (id > HOOK_ADJUSTFID && id < HOOK_GAMEMODECHANGE)) return; + if (id >= numHooks || injectHooks[id].id < 0) return; for (std::vector::iterator it = hooks[id].begin(); it != hooks[id].end(); ++it) { if (it->prog.ptr == script) { if (procNum == 0) hooks[id].erase(it); // unregister