Skip to content

Commit 6b6cff2

Browse files
committed
Modified AddAnimation hook to skip CopyAnimation function call, if m_pAddanimationHandler is nullptr/NULL then normal function flow executes to avoid crash
1 parent 8fe6bc4 commit 6b6cff2

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

Client/multiplayer_sa/CMultiplayerSA.cpp

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ DWORD RETURN_CEventHandler_ComputeKnockOffBikeResponse = 0x4BA076;
157157

158158
#define HOOKPOS_CAnimManager_AddAnimation 0x4d3aa0
159159
DWORD RETURN_CAnimManager_AddAnimation = 0x4D3AAA;
160+
DWORD RETURN_CAnimManager_AddAnimation_SkipCopyAnimation = 0x4D3ABC;
160161
#define HOOKPOS_CAnimManager_BlendAnimation 0x4D4610
161162
DWORD RETURN_CAnimManager_BlendAnimation = 0x4D4617;
162163

@@ -5328,6 +5329,7 @@ void _declspec(naked) HOOK_CEventHandler_ComputeKnockOffBikeResponse ()
53285329
RpClump * animationClump = NULL;
53295330
AssocGroupId animationGroup = 0;
53305331
AnimationId animationID = 0;
5332+
CAnimBlendAssociationSAInterface * pAnimAssociation = nullptr;
53315333
void _declspec(naked) HOOK_CAnimManager_AddAnimation ()
53325334
{
53335335
_asm
@@ -5343,16 +5345,33 @@ void _declspec(naked) HOOK_CAnimManager_AddAnimation ()
53435345

53445346
if ( m_pAddAnimationHandler )
53455347
{
5346-
m_pAddAnimationHandler ( animationClump, animationGroup, animationID );
5348+
pAnimAssociation = m_pAddAnimationHandler ( animationClump, animationGroup, animationID );
5349+
}
5350+
else
5351+
{
5352+
// This will avoid crash if m_pAddAnimationHandler is removed
5353+
// continue the normal flow of AddAnimation function, instead of skipping CopyAnimation
5354+
5355+
_asm
5356+
{
5357+
popad
5358+
mov eax,dword ptr [esp+0Ch]
5359+
mov edx,dword ptr ds:[0B4EA34h]
5360+
jmp RETURN_CAnimManager_AddAnimation
5361+
}
53475362
}
53485363

5364+
// As we are manually creating animation association, so skip CopyAnimation call
53495365
_asm
53505366
{
53515367
popad
5352-
mov eax,dword ptr [esp+0Ch]
5353-
mov edx,dword ptr ds:[0B4EA34h]
5354-
jmp RETURN_CAnimManager_AddAnimation
5355-
}
5368+
mov eax, dword ptr [esp+0Ch]
5369+
mov edx, dword ptr ds:[0B4EA34h]
5370+
push esi
5371+
push edi
5372+
mov eax, pAnimAssociation
5373+
jmp RETURN_CAnimManager_AddAnimation_SkipCopyAnimation
5374+
}
53565375
}
53575376

53585377
float animationBlendDelta;

0 commit comments

Comments
 (0)