Skip to content

Commit bdbb59c

Browse files
committed
Possible crash fix for random thing
1 parent 8d3f43b commit bdbb59c

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

MTA10/multiplayer_sa/CMultiplayerSA_HookDestructors.cpp

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,45 @@ void _declspec(naked) HOOK_CProjectileDestructor()
270270
}
271271

272272

273+
////////////////////////////////////////////////////////////////////////////////////////////////
274+
//
275+
void _cdecl OnCPhysicalDestructor ( DWORD calledFrom, CPhysicalSAInterface* pEntity )
276+
{
277+
// This should be null
278+
if ( pEntity->m_pMovingList )
279+
{
280+
AddReportLog( 8640, SString( "Removing CPhysical type %d from moving list", pEntity->nType ) );
281+
DWORD dwFunc = FUNC_CPhysical_RemoveFromMovingList;
282+
_asm
283+
{
284+
mov ecx, pEntity
285+
call dwFunc
286+
}
287+
}
288+
}
289+
290+
291+
// Hook info
292+
#define HOOKPOS_CPhysicalDestructor 0x0542457
293+
#define HOOKSIZE_CPhysicalDestructor 6
294+
DWORD RETURN_CPhysicalDestructor = 0x054245D;
295+
void _declspec(naked) HOOK_CPhysicalDestructor()
296+
{
297+
_asm
298+
{
299+
pushad
300+
push ecx
301+
push [esp+32+4*1+8]
302+
call OnCPhysicalDestructor
303+
add esp, 4*2
304+
popad
305+
306+
mov eax,dword ptr fs:[00000000h]
307+
jmp RETURN_CPhysicalDestructor
308+
}
309+
}
310+
311+
273312
////////////////////////////////////////////////////////////////////////////////////////////////
274313
//
275314
void _cdecl OnCEntityDestructor ( DWORD calledFrom, CEntitySAInterface* pEntity )
@@ -512,6 +551,7 @@ void CMultiplayerSA::InitHooks_HookDestructors ( void )
512551
EZHookInstall ( CVehicleDestructor );
513552
EZHookInstall ( CProjectileDestructor );
514553
EZHookInstall ( CPlayerPedDestructor );
554+
EZHookInstall ( CPhysicalDestructor );
515555
EZHookInstall ( CEntityDestructor );
516556
EZHookInstall ( CStreamingRemoveModel );
517557
EZHookInstall ( CEntityAddMid1 );

0 commit comments

Comments
 (0)