From 29f0affd725e48c5aa71f2241936b14c465606b0 Mon Sep 17 00:00:00 2001 From: NovaRain Date: Tue, 26 Nov 2019 07:49:31 +0800 Subject: [PATCH] Re-fixed commit e62b5c0 (correct variant) --- sfall/FalloutEngine.cpp | 15 +++++++++++++++ sfall/FalloutEngine.h | 2 ++ sfall/Interface.cpp | 13 ++----------- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/sfall/FalloutEngine.cpp b/sfall/FalloutEngine.cpp index 49830e98..57f4b8d4 100644 --- a/sfall/FalloutEngine.cpp +++ b/sfall/FalloutEngine.cpp @@ -881,6 +881,21 @@ long GetScriptLocalVars(long sid) { return (script) ? script->num_local_vars : 0; } +// Returns window ID by x/y coordinate (hidden windows are ignored) +long __fastcall GetTopWindowID(long xPos, long yPos) { + WINinfo* win = nullptr; + long countWin = *(DWORD*)_num_windows - 1; + for (int n = countWin; n >= 0; n--) { + win = (WINinfo*)ptr_window[n]; + if (xPos >= win->wRect.left && xPos <= win->wRect.right && yPos >= win->wRect.top && yPos <= win->wRect.bottom) { + if (!(win->flags & WIN_Hidden)) { + break; + } + } + } + return win->wID; +} + void __fastcall RegisterObjectCall(long* target, long* source, void* func, long delay) { __asm { mov eax, ecx; diff --git a/sfall/FalloutEngine.h b/sfall/FalloutEngine.h index 46f17858..46740a5b 100644 --- a/sfall/FalloutEngine.h +++ b/sfall/FalloutEngine.h @@ -1045,6 +1045,8 @@ long __stdcall ScrPtr(long scriptId, TScript** scriptPtr); // Returns the number of local variables of the object script long GetScriptLocalVars(long sid); +long __fastcall GetTopWindowID(long xPos, long yPos); + void __fastcall RegisterObjectCall(long* target, long* source, void* func, long delay); long __fastcall ScrGetLocalVar(long sid, long varId, long* value); diff --git a/sfall/Interface.cpp b/sfall/Interface.cpp index cf532d57..9668f116 100644 --- a/sfall/Interface.cpp +++ b/sfall/Interface.cpp @@ -228,17 +228,8 @@ static long __stdcall gmouse_handle_event_hook() { static void __declspec(naked) gmouse_bk_process_hook() { __asm { - call win_get_top_win_; - cmp eax, ds:[_display_win]; - jnz checkFlag; - retn; -checkFlag: - call GNW_find_; - test [eax + 4], WIN_Hidden; // window flags - jz skip; - mov eax, ds:[_display_win]; // window is hidden, so return the number of the display_win -skip: - retn; + mov ecx, eax; + jmp GetTopWindowID; } }