Skip to content

Commit

Permalink
Fix #1757 extinguishFire in onClientVehicleDamage causes MTA crash (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
FileEX authored Jul 15, 2024
1 parent 8580364 commit d6ae4e9
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions Client/multiplayer_sa/CMultiplayerSA_CrashFixHacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2062,6 +2062,38 @@ static void _declspec(naked) HOOK_FxPrim_c__Enable()
}

////////////////////////////////////////////////////////////////////////
// CFire::ProcessFire
//
// GitHub #1757 (https://github.com/multitheftauto/mtasa-blue/issues/1757)
//
// Null pointer to the attachedTo field in the CFire structure
////////////////////////////////////////////////////////////////////////
#define HOOKPOS_CFire_ProcessFire 0x53A6FC
#define HOOKSIZE_CFire_ProcessFire 9
static DWORD CONTINUE_CFire_ProcessFire = 0x53A705;
static void _declspec(naked) HOOK_CFire_ProcessFire()
{
_asm
{
test byte ptr [esi], 4
// If the beingExtinguished flag has been set, we skip processing this fire instance
jnz skip

mov ecx, [esi+10h]
mov eax, [ecx+590h]
jmp CONTINUE_CFire_ProcessFire

skip:
pop edi
pop esi
pop ebp
pop ebx
add esp, 2Ch
retn
}
}

//////////////////////////////////////////////////////////////////////////////////////////
//
// Setup hooks for CrashFixHacks
//
Expand Down Expand Up @@ -2121,6 +2153,7 @@ void CMultiplayerSA::InitHooks_CrashFixHacks()
EZHookInstall(CAnimManager__BlendAnimation);
EZHookInstall(FxSystemBP_c__Load);
EZHookInstall(FxPrim_c__Enable);
EZHookInstall(CFire_ProcessFire);

// Install train crossing crashfix (the temporary variable is required for the template logic)
void (*temp)() = HOOK_TrainCrossingBarrierCrashFix<RETURN_CObject_Destructor_TrainCrossing_Check, RETURN_CObject_Destructor_TrainCrossing_Invalid>;
Expand Down

0 comments on commit d6ae4e9

Please sign in to comment.