Changed the check for unavailable hooks

* easier to backport more discontinuous hooks if needed.
This commit is contained in:
NovaRain
2022-10-19 10:59:17 +08:00
parent 5429217c0a
commit f1626e846a
3 changed files with 13 additions and 9 deletions
+7 -3
View File
@@ -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) {
+1 -1
View File
@@ -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);
+5 -5
View File
@@ -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<HookScript>::iterator it = hooks[id].begin(); it != hooks[id].end(); ++it) {
if (it->prog.ptr == script) {
if (procNum == 0) hooks[id].erase(it); // unregister