Added a tweak to op_use_obj_on_obj_hack in BugFixes (from Mr.Stalin)

Minor edits to code/documents.
This commit is contained in:
NovaRain
2019-05-14 07:16:23 +08:00
parent 6ac9949feb
commit 6a226aef34
7 changed files with 20 additions and 14 deletions
+1 -1
View File
@@ -594,7 +594,7 @@ Some utility/math functions are available:
Optional arguments:
- frame: frame number, the first frame starts from zero
- x/y: offset relative to the top-left corner of the window
- width/height: image size, used to scale the image when displaying it. Pass -1 to either width or height to keep aspect ratio when scaling
- width/height: image size, used to scale the image when displaying it. Pass -1 to either width or height to keep the aspect ratio when scaling
- noTransparent: pass true to display an image without transparent background
- NOTE: to omit optional arguments starting from the right, call the functions with different sfall_funcX (e.g. sfall_func4("draw_image", pathFile, frame, x, y))
- if draw_image_scaled is called without x/y/width/height arguments, the image will be scaled to fit the window without transparent background
+1 -1
View File
@@ -88,7 +88,7 @@ int __fastcall GetItemType(GameObject* item) {
return fo::func::item_get_type(item);
}
_declspec(noinline) GameObject* GetItemPtrSlot(GameObject* critter, InvenType slot) {
__declspec(noinline) GameObject* GetItemPtrSlot(GameObject* critter, InvenType slot) {
GameObject* itemPtr = nullptr;
switch (slot) {
case fo::INVEN_TYPE_LEFT_HAND:
+1 -1
View File
@@ -54,7 +54,7 @@ void SkillSetTags(long* tags, long num);
int __fastcall GetItemType(GameObject* item);
_declspec(noinline) GameObject* GetItemPtrSlot(GameObject* critter, InvenType slot);
__declspec(noinline) GameObject* GetItemPtrSlot(GameObject* critter, InvenType slot);
long& GetActiveItemMode();
+6
View File
@@ -1879,6 +1879,10 @@ static void __declspec(naked) op_use_obj_on_obj_hack() {
jz fail;
mov edx, [eax + protoId];
shr edx, 24;
cmp dword ptr [esp + 4], eax; // target != source
jne skip;
xor edx, edx; // for calling obj_use_item_on_ instead of action_use_an_item_on_object_
skip:
retn;
fail:
add esp, 4;
@@ -2567,6 +2571,8 @@ void BugFixes::init()
}
// Fix crash when calling use_obj/use_obj_on_obj without using set_self in global scripts
// also change the behavior of use_obj_on_obj function
// if the object uses the item on itself, then another function is called (not a bug fix)
MakeCall(0x45C376, op_use_obj_on_obj_hack, 1);
MakeCall(0x456A92, op_use_obj_hack, 1);
+3 -3
View File
@@ -340,7 +340,7 @@ skip:
}
// hooks combat_turn function
static void _declspec(naked) CombatTurnHook() {
static void __declspec(naked) CombatTurnHook() {
__asm {
HookBegin;
mov args[0], 1; // turn begin
@@ -380,7 +380,7 @@ static void _declspec(naked) CombatTurnHook() {
// hack to exit from combat_add_noncoms function without crashing when you load game during NPC turn
static const DWORD CombatHack_add_noncoms_back = 0x422359;
static void _declspec(naked) CombatAddNoncoms_CombatTurnHack() {
static void __declspec(naked) CombatAddNoncoms_CombatTurnHack() {
__asm {
call CombatTurnHook;
cmp eax, -1;
@@ -415,7 +415,7 @@ fo::GameObject* __fastcall ComputeExplosionOnExtrasHook_Script(fo::GameObject* o
return result;
}
static void _declspec(naked) ComputeExplosionOnExtrasHook() {
static void __declspec(naked) ComputeExplosionOnExtrasHook() {
__asm {
cmp dword ptr [esp + 0x34 + 4], 0x429533; // skip hook when AI assesses the situation in choosing the best weapon
jz end;
+7 -7
View File
@@ -92,7 +92,7 @@ static int __fastcall SwitchHandHook_Script(fo::GameObject* item, fo::GameObject
This hook is called every time an item is placed into either hand slot via inventory screen drag&drop
If switch_hand_ function is not called, item is not placed anywhere (it remains in main inventory)
*/
static void _declspec(naked) SwitchHandHook() {
static void __declspec(naked) SwitchHandHook() {
__asm {
pushadc;
mov ecx, eax; // item being moved
@@ -129,7 +129,7 @@ static int __fastcall InventoryMoveHook_Script(DWORD itemReplace, DWORD item, in
static const DWORD UseArmorHack_back = 0x4713AF; // normal operation (old 0x4713A9)
static const DWORD UseArmorHack_skip = 0x471481; // skip code, prevent wearing armor
// This hack is called when an armor is dropped into the armor slot at inventory screen
static void _declspec(naked) UseArmorHack() {
static void __declspec(naked) UseArmorHack() {
__asm {
mov ecx, ds:[FO_VAR_i_worn]; // replacement item (override code)
mov edx, [esp + 0x58 - 0x40]; // item
@@ -145,7 +145,7 @@ skip:
}
}
static void _declspec(naked) MoveInventoryHook() {
static void __declspec(naked) MoveInventoryHook() {
__asm {
pushadc;
xor eax, eax;
@@ -266,7 +266,7 @@ static void __declspec(naked) DropIntoContainerHandSlotHack() {
//static const DWORD DropAmmoIntoWeaponHack_back = 0x47658D; // proceed with reloading
static const DWORD DropAmmoIntoWeaponHack_return = 0x476643;
static void _declspec(naked) DropAmmoIntoWeaponHook() {
static void __declspec(naked) DropAmmoIntoWeaponHook() {
__asm {
pushadc;
mov ecx, ebp; // weapon ptr
@@ -341,7 +341,7 @@ static bool InvenWieldHook_Script(int flag) {
return result; // True - use engine handler
}
static void _declspec(naked) InvenWieldFuncHook() {
static void __declspec(naked) InvenWieldFuncHook() {
using namespace fo;
__asm {
HookBegin;
@@ -370,7 +370,7 @@ skip:
}
// called when unwielding weapons
static void _declspec(naked) InvenUnwieldFuncHook() {
static void __declspec(naked) InvenUnwieldFuncHook() {
__asm {
HookBegin;
mov args[0], eax; // critter
@@ -397,7 +397,7 @@ skip:
}
}
static void _declspec(naked) CorrectFidForRemovedItemHook() {
static void __declspec(naked) CorrectFidForRemovedItemHook() {
__asm {
HookBegin;
mov args[0], eax; // critter
+1 -1
View File
@@ -498,7 +498,7 @@ static int __fastcall ExplosiveTimerHook_Script(DWORD &type, DWORD item, DWORD t
return time;
}
static void _declspec(naked) ExplosiveTimerHook() {
static void __declspec(naked) ExplosiveTimerHook() {
__asm {
push eax; // time in ticks for queue_add_
push edx;