diff --git a/artifacts/ddraw.ini b/artifacts/ddraw.ini index 6b50a5c5..b30c358a 100644 --- a/artifacts/ddraw.ini +++ b/artifacts/ddraw.ini @@ -1,5 +1,5 @@ ;sfall configuration settings -;v4.0.5 +;v4.0.6 [Main] ;Change to 1 if you want to use command line args to tell sfall to use another ini file. diff --git a/sfall/Modules/HookScripts/Common.h b/sfall/Modules/HookScripts/Common.h index b11b317f..a81dcfc2 100644 --- a/sfall/Modules/HookScripts/Common.h +++ b/sfall/Modules/HookScripts/Common.h @@ -42,6 +42,8 @@ void _stdcall BeginHook(); void _stdcall RunHookScript(DWORD hook); void _stdcall EndHook(); +#define HookBegin __asm pushad __asm call BeginHook __asm popad + #define hookbegin(a) __asm pushad __asm call BeginHook __asm popad __asm mov argCount, a #define hookend __asm pushad __asm call EndHook __asm popad diff --git a/sfall/Modules/HookScripts/InventoryHs.cpp b/sfall/Modules/HookScripts/InventoryHs.cpp index 6e5f3eef..a920deff 100644 --- a/sfall/Modules/HookScripts/InventoryHs.cpp +++ b/sfall/Modules/HookScripts/InventoryHs.cpp @@ -15,6 +15,7 @@ static const DWORD RemoveObjHookRet = 0x477497; static void __declspec(naked) RemoveObjHook() { __asm { mov ecx, [esp + 8]; // call addr + HookBegin; mov args[0], eax; mov args[4], edx; mov args[8], ebx; @@ -22,7 +23,6 @@ static void __declspec(naked) RemoveObjHook() { pushad; } - BeginHook(); argCount = 4; RunHookScript(HOOK_REMOVEINVENOBJ); EndHook(); @@ -38,6 +38,7 @@ static void __declspec(naked) RemoveObjHook() { static void __declspec(naked) MoveCostHook() { __asm { + HookBegin; mov args[0], eax; mov args[4], edx; call fo::funcoffs::critter_compute_ap_from_distance_ @@ -45,7 +46,6 @@ static void __declspec(naked) MoveCostHook() { pushad; } - BeginHook(); argCount = 3; RunHookScript(HOOK_MOVECOST); EndHook(); @@ -78,16 +78,19 @@ static int __fastcall SwitchHandHook_Script(fo::GameObject* item, fo::GameObject if (itemReplaced && fo::GetItemType(itemReplaced) == fo::item_type_weapon && fo::GetItemType(item) == fo::item_type_ammo) { return -1; // to prevent inappropriate hook call after dropping ammo on weapon } + BeginHook(); argCount = 3; + args[0] = (addr < 0x47136D) ? 1 : 2; // slot: 1 - left, 2 - right args[1] = (DWORD)item; args[2] = (DWORD)itemReplaced; + RunHookScript(HOOK_INVENTORYMOVE); - int tmp = PartyControl::SwitchHandHook(item); - if (tmp != -1) { + int result = PartyControl::SwitchHandHook(item); + if (result != -1) { cRetTmp = 0; - SetHSReturn(tmp); + SetHSReturn(result); } EndHook(); @@ -255,7 +258,7 @@ donothing: /* Common InvenWield hook */ static void InvenWieldHook_Script(int flag) { - BeginHook(); + argCount = 4; args[3] = flag; // invenwield flag RunHookScript(HOOK_INVENWIELD); @@ -265,6 +268,7 @@ static void InvenWieldHook_Script(int flag) { static void _declspec(naked) InvenWieldFuncHook() { using namespace fo; __asm { + HookBegin; mov args[0], eax; // critter mov args[4], edx; // item mov args[8], ebx; // slot @@ -288,6 +292,7 @@ static void _declspec(naked) InvenWieldFuncHook() { // called when unwielding weapons static void _declspec(naked) InvenUnwieldFuncHook() { __asm { + HookBegin; mov args[0], eax; // critter mov args[8], edx; // slot pushad; @@ -310,6 +315,7 @@ static void _declspec(naked) InvenUnwieldFuncHook() { static void _declspec(naked) CorrectFidForRemovedItemHook() { __asm { + HookBegin; mov args[0], eax; // critter mov args[4], edx; // item mov args[8], ebx; // item flag diff --git a/sfall/version.h b/sfall/version.h index 7357e338..04bf710e 100644 --- a/sfall/version.h +++ b/sfall/version.h @@ -24,13 +24,13 @@ #define VERSION_MAJOR 4 #define VERSION_MINOR 0 -#define VERSION_BUILD 5 +#define VERSION_BUILD 6 #define VERSION_REV 0 #ifdef WIN2K -#define VERSION_STRING "4.0.5 win2k" +#define VERSION_STRING "4.0.6 win2k" #else -#define VERSION_STRING "4.0.5" +#define VERSION_STRING "4.0.6" #endif #define CHECK_VAL (4)