Skip to content

Commit 6343316

Browse files
lopezlooJusonex
authored andcommitted
Fix #8458 (setObjectBreakable - Melee problem) (#137)
1 parent 1a1d04d commit 6343316

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

Client/multiplayer_sa/CMultiplayerSA.cpp

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,8 @@ DWORD RETURN_CObject_ProcessCollision = 0x548DD1;
282282
DWORD JMP_DynamicObject_Cond_Zero = 0x548E98;
283283
#define HOOKPOS_CGlass_WindowRespondsToCollision 0x71BC40
284284
DWORD RETURN_CGlass_WindowRespondsToCollision = 0x71BC48;
285+
#define HOOKPOS_CGlass__BreakGlassPhysically 0x71D14B
286+
DWORD RETURN_CGlass__BreakGlassPhysically = 0x71D150;
285287

286288
#define HOOKPOS_FxManager_c__DestroyFxSystem 0x4A989A
287289

@@ -499,6 +501,7 @@ void HOOK_CObject_ProcessDamage ();
499501
void HOOK_CObject_ProcessBreak ();
500502
void HOOK_CObject_ProcessCollision ();
501503
void HOOK_CGlass_WindowRespondsToCollision ();
504+
void HOOK_CGlass__BreakGlassPhysically ();
502505

503506
void HOOK_FxManager_c__DestroyFxSystem ();
504507

@@ -706,6 +709,7 @@ void CMultiplayerSA::InitHooks()
706709
HookInstall ( HOOKPOS_CObject_ProcessBreak, (DWORD)HOOK_CObject_ProcessBreak, 5 );
707710
HookInstall ( HOOKPOS_CObject_ProcessCollision, (DWORD)HOOK_CObject_ProcessCollision, 10 );
708711
HookInstall ( HOOKPOS_CGlass_WindowRespondsToCollision, (DWORD)HOOK_CGlass_WindowRespondsToCollision, 8 );
712+
HookInstall ( HOOKPOS_CGlass__BreakGlassPhysically, (DWORD)HOOK_CGlass__BreakGlassPhysically, 5 );
709713

710714
// Post-destruction hook for FxSystems
711715
HookInstall ( HOOKPOS_FxManager_c__DestroyFxSystem, (DWORD)HOOK_FxManager_c__DestroyFxSystem, 5);
@@ -6609,6 +6613,41 @@ void _declspec(naked) HOOK_CGlass_WindowRespondsToCollision ()
66096613
}
66106614
}
66116615

6616+
// Called when glass object is being broken by ped melee attack
6617+
DWORD dummy_404350 = 0x404350;
6618+
void _declspec(naked) HOOK_CGlass__BreakGlassPhysically ()
6619+
{
6620+
_asm
6621+
{
6622+
mov pDamagedObject, esi
6623+
}
6624+
// we can't get attacker from here
6625+
pObjectAttacker = NULL;
6626+
6627+
if ( TriggerObjectBreakEvent () )
6628+
{
6629+
_asm
6630+
{
6631+
// restore replaced part
6632+
push dummy_404350
6633+
// jump outside of the hook
6634+
jmp RETURN_CGlass__BreakGlassPhysically
6635+
}
6636+
}
6637+
else
6638+
{
6639+
_asm
6640+
{
6641+
pop edi
6642+
pop esi
6643+
pop ebp
6644+
pop ebx
6645+
add esp, 0BCh
6646+
retn
6647+
}
6648+
}
6649+
}
6650+
66126651
void * pFxSystemToBeDestroyed;
66136652
void FxManager_c__DestroyFxSystem()
66146653
{

0 commit comments

Comments
 (0)