From b4d174d91bf83f283123443204d983819261eb63 Mon Sep 17 00:00:00 2001 From: NovaRain Date: Fri, 13 Apr 2018 11:09:37 +0800 Subject: [PATCH] Fixed a bug when using HOOK_ITEMDAMAGE and calling item_w_damage_ engine function at the same time. It would result in player self-damaging when attacking targets. Set DataLoadOrderPatch to be enabled by default, for preventing partial of a game crash issue due to unusual game folders setup. #136 --- artifacts/ddraw.ini | 4 ++-- sfall/HookScripts.cpp | 12 ++++++------ sfall/main.cpp | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/artifacts/ddraw.ini b/artifacts/ddraw.ini index 44a01145..aad1ae49 100644 --- a/artifacts/ddraw.ini +++ b/artifacts/ddraw.ini @@ -200,10 +200,10 @@ WorldMapSlots=0 ;PatchFile=patch%03d.dat ;MultiPatches=0 -;Set to 1 to enable the modified data load order for the engine to find game data +;Set to 1 to use the modified data load order for the engine to find game data ;Original: patchXXX.dat > critter_patches > critter_dat > f2_res_patches > f2_res_dat > master_patches > master_dat ;Modified: master_patches > critter_patches > patchXXX.dat > critter_dat > f2_res_patches > f2_res_dat > master_dat -DataLoadOrderPatch=0 +DataLoadOrderPatch=1 ;To change the default and starting player models, uncomment the next four lines. ;The default models can also be changed ingame via script diff --git a/sfall/HookScripts.cpp b/sfall/HookScripts.cpp index 35e9a63b..e31028f9 100644 --- a/sfall/HookScripts.cpp +++ b/sfall/HookScripts.cpp @@ -689,13 +689,13 @@ static void __declspec(naked) ItemDamageHook() { mov args[0], eax; //min mov args[4], edx; //max mov args[8], edi; //weapon - mov args[12], ecx; //critter - mov args[16], esi; //type - mov args[20], ebp; //non-zero for weapon melee attack - test edi, edi; - jnz skip; - add args[16], 8; + mov args[12], ecx; //source + test edi, edi; //has a weapon in hand? + jnz skip; //yes + add esi, 8; //edit hit_mode skip: + mov args[16], esi; //hit_mode + mov args[20], ebp; //non-zero for weapon melee attack pushad; push HOOK_ITEMDAMAGE; call RunHookScript; diff --git a/sfall/main.cpp b/sfall/main.cpp index a8faaae8..1b9daed5 100644 --- a/sfall/main.cpp +++ b/sfall/main.cpp @@ -1145,7 +1145,7 @@ static void DllMain2() { dlogr(" Done", DL_INIT); } - if (GetPrivateProfileIntA("Misc", "DataLoadOrderPatch", 0, ini)) { + if (GetPrivateProfileIntA("Misc", "DataLoadOrderPatch", 1, ini)) { dlog("Applying data load order patch.", DL_INIT); MakeCall(0x444259, game_init_databases_hack1); MakeCall(0x4442F1, game_init_databases_hack2);