From 024a13c6a8fb61e74a292dcc4edbbfe1a891204f Mon Sep 17 00:00:00 2001 From: NovaRain Date: Wed, 30 Nov 2022 14:27:46 +0800 Subject: [PATCH] Minor edits to code and documents --- artifacts/ddraw.ini | 2 +- artifacts/scripting/hooks.yml | 4 ++-- artifacts/scripting/hookscripts.md | 4 ++-- sfall/Modules/HookScripts.cpp | 4 ++-- sfall/Modules/HookScripts.h | 2 -- sfall/Modules/HookScripts/Common.cpp | 2 +- sfall/Modules/HookScripts/Common.h | 2 +- sfall/Modules/HookScripts/MiscHs.cpp | 11 +++++++---- sfall/Modules/MiscPatches.cpp | 8 ++++---- sfall/Modules/Scripting/Handlers/Worldmap.cpp | 2 +- 10 files changed, 21 insertions(+), 20 deletions(-) diff --git a/artifacts/ddraw.ini b/artifacts/ddraw.ini index 36e51ff0..a07deb1c 100644 --- a/artifacts/ddraw.ini +++ b/artifacts/ddraw.ini @@ -752,7 +752,7 @@ AIBestWeaponFix=1 AIDrugUsePerfFix=0 ;Set to 1 to fix the bug of using First Aid/Doctor skills when using them on the player -;This will cause the party member to apply his/her skills when you use First Aid/Doctor skills on the player, but only if +;This will cause the party member to perform First Aid/Doctor skills when you use them on the player, but only if ;the player is standing next to the party member ;Note that because the related engine function is not fully implemented, enabling this option without a global script ;that overrides First Aid/Doctor functions has very limited usefulness diff --git a/artifacts/scripting/hooks.yml b/artifacts/scripting/hooks.yml index eba64f89..7f47fa4f 100644 --- a/artifacts/scripting/hooks.yml +++ b/artifacts/scripting/hooks.yml @@ -603,7 +603,7 @@ ``` Obj arg0 - the object - int ret0 - a pointer to the new text received by using "get_string_pointer" function + int ret0 - a pointer to the new text received by using the get_string_pointer function ``` - name: UseSkillOn @@ -619,7 +619,7 @@ int arg2 - skill being used int ret0 - a new critter to override the user critter. Pass -1 to cancel the skill use, pass 0 to skip this return value - int ret1 - pass 1 to allow the skill being used in combat (only for dude_obj or critter being controlled by the player) + int ret1 - pass 1 to allow the skill to be used in combat (only for dude_obj or critter being controlled by the player) ``` - name: OnExplosion diff --git a/artifacts/scripting/hookscripts.md b/artifacts/scripting/hookscripts.md index 16191be6..cc693557 100644 --- a/artifacts/scripting/hookscripts.md +++ b/artifacts/scripting/hookscripts.md @@ -692,7 +692,7 @@ Does not run if the script of the object overrides the description. ``` Obj arg0 - the object -int ret0 - a pointer to the new text received by using get_string_pointer function +int ret0 - a pointer to the new text received by using the get_string_pointer function ``` ------------------------------------------- @@ -709,7 +709,7 @@ Obj arg1 - the target object/critter int arg2 - skill being used int ret0 - a new critter to override the user critter. Pass -1 to cancel the skill use, pass 0 to skip this return value -int ret1 - pass 1 to allow the skill being used in combat (only for dude_obj or critter being controlled by the player) +int ret1 - pass 1 to allow the skill to be used in combat (only for dude_obj or critter being controlled by the player) ``` ------------------------------------------- diff --git a/sfall/Modules/HookScripts.cpp b/sfall/Modules/HookScripts.cpp index 27a2e7e9..b1e158e7 100644 --- a/sfall/Modules/HookScripts.cpp +++ b/sfall/Modules/HookScripts.cpp @@ -184,7 +184,7 @@ void HookScripts::LoadHookScript(const char* name, int id) { } } -void HookScripts::InitHookScriptFile(const char* name, int id) { +static void InitHookScriptFile(const char* name, int id) { ScriptProgram prog; dlog("> ", DL_HOOK); dlog(name, DL_HOOK); @@ -231,7 +231,7 @@ void HookScripts::InitHookScripts() { dlogr("Running hook scripts...", DL_HOOK); for (auto& hook : HookScripts::hookScriptFilesList) { - HookScripts::InitHookScriptFile(hook.name.c_str(), hook.id); + InitHookScriptFile(hook.name.c_str(), hook.id); } initingHookScripts = 1; diff --git a/sfall/Modules/HookScripts.h b/sfall/Modules/HookScripts.h index fa069ebd..b51f7f9c 100644 --- a/sfall/Modules/HookScripts.h +++ b/sfall/Modules/HookScripts.h @@ -85,7 +85,6 @@ struct HookFile { }; class HookScripts : public Module { - public: const char* name() { return "HookScripts"; } void init(); @@ -95,7 +94,6 @@ public: static std::vector hookScriptFilesList; static void LoadHookScript(const char* name, int id); - static void InitHookScriptFile(const char* name, int id); static void LoadHookScripts(); static void InitHookScripts(); static void HookScriptClear(); diff --git a/sfall/Modules/HookScripts/Common.cpp b/sfall/Modules/HookScripts/Common.cpp index 766a46fb..b504af5d 100644 --- a/sfall/Modules/HookScripts/Common.cpp +++ b/sfall/Modules/HookScripts/Common.cpp @@ -164,7 +164,7 @@ void __stdcall EndHook() { } // BEGIN HOOKS -void HookCommon::KeyPressHook(DWORD* dxKey, bool pressed, DWORD vKey) { +void __stdcall HookCommon::KeyPressHook(DWORD* dxKey, bool pressed, DWORD vKey) { if (!IsGameLoaded() || !HookScripts::HookHasScript(HOOK_KEYPRESS)) { return; } diff --git a/sfall/Modules/HookScripts/Common.h b/sfall/Modules/HookScripts/Common.h index 436335b1..a093849d 100644 --- a/sfall/Modules/HookScripts/Common.h +++ b/sfall/Modules/HookScripts/Common.h @@ -18,7 +18,7 @@ public: static void __stdcall SetHSReturn(DWORD d); static void GameModeChangeHook(DWORD exit); - static void KeyPressHook(DWORD* dxKey, bool pressed, DWORD vKey); + static void __stdcall KeyPressHook(DWORD* dxKey, bool pressed, DWORD vKey); static void __stdcall MouseClickHook(DWORD button, bool pressed); static void Reset(); diff --git a/sfall/Modules/HookScripts/MiscHs.cpp b/sfall/Modules/HookScripts/MiscHs.cpp index e30c618f..2c6221b6 100644 --- a/sfall/Modules/HookScripts/MiscHs.cpp +++ b/sfall/Modules/HookScripts/MiscHs.cpp @@ -99,6 +99,7 @@ void SourceUseSkillOnInit() { sourceSkillOn = fo::var::obj_dude; } static char resultSkillOn; // -1 - cancel handler, 1 - replace user static long bakupCombatState; + static void __fastcall UseSkillOnHook_Script(DWORD source, DWORD target, register DWORD skillId) { BeginHook(); argCount = 3; @@ -612,7 +613,7 @@ blinkIcon: jmp fo::funcoffs::wmInterfaceRefresh_; break: mov eax, hkEncounterMapID; - cmp ds:[FO_VAR_Move_on_Car], 0; + cmp dword ptr ds:[FO_VAR_Move_on_Car], 0; je noCar; mov edx, FO_VAR_carCurrentArea; call fo::funcoffs::wmMatchAreaContainingMapIdx_; @@ -623,7 +624,7 @@ noCar: mov hkEncounterMapID, -1; cancelEnc: inc eax; // 0 - continue movement, 1 - interrupt - mov ds:[FO_VAR_wmEncounterIconShow], 0; + mov dword ptr ds:[FO_VAR_wmEncounterIconShow], 0; add esp, 4; mov ebx, 0x4C0BC7; jmp ebx; @@ -739,8 +740,10 @@ void Inject_UseSkillOnHook() { MakeCalls(skill_use_hack, {0x4AB05D, 0x4AB558, 0x4ABA60}); // fix checking obj_dude's target // replace _obj_dude with source skill user (skill_use_ function) - SafeWriteBatch((DWORD)&sourceSkillOn, {0x4AAF47, 0x4AB051, 0x4AB3FB, 0x4AB550, 0x4AB8FA, 0x4ABA54}); - SafeWriteBatch((DWORD)&sourceSkillOn, {0x4AB0EF, 0x4AB5C0, 0x4ABAF2}); // fix for time + SafeWriteBatch((DWORD)&sourceSkillOn, { + 0x4AAF47, 0x4AB051, 0x4AB3FB, 0x4AB550, 0x4AB8FA, 0x4ABA54, + 0x4AB0EF, 0x4AB5C0, 0x4ABAF2 // fix for time increment + }); } void Inject_EncounterHook() { diff --git a/sfall/Modules/MiscPatches.cpp b/sfall/Modules/MiscPatches.cpp index 8dec44ee..617e77f0 100644 --- a/sfall/Modules/MiscPatches.cpp +++ b/sfall/Modules/MiscPatches.cpp @@ -40,7 +40,7 @@ static void __declspec(naked) GNW95_process_message_hack() { __asm { push idle; call Sleep; - cmp ds:[FO_VAR_GNW95_isActive], 0; + cmp dword ptr ds:[FO_VAR_GNW95_isActive], 0; retn; } } @@ -727,12 +727,12 @@ static void KeepSelectModePatch() { } static void PartyMemberSkillPatch() { - // Fixed getting distance from source to target when using skills - // Note: this will cause the party member to apply his/her skill when you use First Aid/Doctor skill on the player, but only if + // Fix getting distance from source to target when using skills + // Note: this will cause the party member to perform First Aid/Doctor skills when you use them on the player, but only if // the player is standing next to the party member. Because the related engine function is not fully implemented, enabling // this option without a global script that overrides First Aid/Doctor functions has very limited usefulness if (IniReader::GetConfigInt("Misc", "PartyMemberSkillFix", 0)) { - dlog("Applying party member using First Aid/Doctor skill patch.", DL_INIT); + dlog("Applying First Aid/Doctor skill use patch for party members.", DL_INIT); HookCall(0x412836, action_use_skill_on_hook); dlogr(" Done", DL_INIT); } diff --git a/sfall/Modules/Scripting/Handlers/Worldmap.cpp b/sfall/Modules/Scripting/Handlers/Worldmap.cpp index 4dd2bab6..52b1810d 100644 --- a/sfall/Modules/Scripting/Handlers/Worldmap.cpp +++ b/sfall/Modules/Scripting/Handlers/Worldmap.cpp @@ -73,7 +73,7 @@ static void __declspec(naked) wmRndEncounterOccurred_hack() { __asm { test ForceEncounterFlags, 0x1; // _NoCar flag jnz noCar; - cmp ds:[FO_VAR_Move_on_Car], 0; + cmp dword ptr ds:[FO_VAR_Move_on_Car], 0; jz noCar; mov edx, FO_VAR_carCurrentArea; mov eax, ForceEncounterMapID;