Fixed premature assignment of arguments before the beginning of the hooks in InventoryHs.cpp. (#173)

(cherry picked from commit fff48407c3)
Updated version number.
This commit is contained in:
NovaRain
2018-06-24 12:36:01 +08:00
parent 8c2483a289
commit 1b3b5dc523
4 changed files with 18 additions and 10 deletions
+1 -1
View File
@@ -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.
+2
View File
@@ -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
+12 -6
View File
@@ -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
+3 -3
View File
@@ -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)