|
| 1 | +/***************************************************************************** |
| 2 | + * |
| 3 | + * PROJECT: Multi Theft Auto |
| 4 | + * LICENSE: See LICENSE in the top level directory |
| 5 | + * FILE: multiplayer_sa/CMultiplayerSA_Tasks.cpp |
| 6 | + * |
| 7 | + * Multi Theft Auto is available from https://www.multitheftauto.com/ |
| 8 | + * |
| 9 | + *****************************************************************************/ |
| 10 | +#include "StdInc.h" |
| 11 | + |
| 12 | +////////////////////////////////////////////////////////////////////////////////////////// |
| 13 | +// |
| 14 | +// CTaskSimplePlayerOnFoot::MakeAbortable |
| 15 | +// |
| 16 | +// If ignorefirestate is enabled, we need this hook to avoid tweaking the aiming animation |
| 17 | +// and the chainsaw turning off when entering fire |
| 18 | +// |
| 19 | +////////////////////////////////////////////////////////////////////////////////////////// |
| 20 | +static bool __IsIgnoreFireStateEnabled() |
| 21 | +{ |
| 22 | + return pGameInterface->IsIgnoreFireStateEnabled(); |
| 23 | +} |
| 24 | + |
| 25 | +#define HOOKPOS_CTaskSimplePlayerOnFoot__MakeAbortable 0x68584D |
| 26 | +#define HOOKSIZE_CTaskSimplePlayerOnFoot__MakeAbortable 6 |
| 27 | +static constexpr std::uintptr_t RETURN_CTaskSimplePlayerOnFoot__MakeAbortable = 0x68585F; |
| 28 | +static constexpr std::uintptr_t SKIP_CTaskSimplePlayerOnFoot__MakeAbortable = 0x685855; |
| 29 | +static void _declspec(naked) HOOK_CTaskSimplePlayerOnFoot__MakeAbortable() |
| 30 | +{ |
| 31 | + _asm |
| 32 | + { |
| 33 | + // return false and keep task alive |
| 34 | + call dword ptr [eax+8] |
| 35 | + cmp eax, 3Dh |
| 36 | + jl skip |
| 37 | + |
| 38 | + // if eventPriority == 66 (EventOnFire) && IsIgnoreFireStateEnabled() |
| 39 | + cmp eax, 42h |
| 40 | + jne continue_logic |
| 41 | + |
| 42 | + call __IsIgnoreFireStateEnabled |
| 43 | + test al, al |
| 44 | + jz continue_logic |
| 45 | + |
| 46 | + // return true but keep task alive |
| 47 | + pop edi |
| 48 | + pop esi |
| 49 | + pop ebx |
| 50 | + mov al, 1 |
| 51 | + retn 0Ch |
| 52 | + |
| 53 | + continue_logic: |
| 54 | + jmp RETURN_CTaskSimplePlayerOnFoot__MakeAbortable |
| 55 | + |
| 56 | + skip: |
| 57 | + jmp SKIP_CTaskSimplePlayerOnFoot__MakeAbortable |
| 58 | + } |
| 59 | +} |
| 60 | + |
| 61 | +////////////////////////////////////////////////////////////////////////////////////////// |
| 62 | +// |
| 63 | +// CMultiplayerSA::InitHooks_Tasks |
| 64 | +// |
| 65 | +// Setup hooks |
| 66 | +// |
| 67 | +////////////////////////////////////////////////////////////////////////////////////////// |
| 68 | +void CMultiplayerSA::InitHooks_Tasks() |
| 69 | +{ |
| 70 | + EZHookInstall(CTaskSimplePlayerOnFoot__MakeAbortable); |
| 71 | +} |
0 commit comments