Skip to content

Commit 3b1acd7

Browse files
committed
custom animation associations are kept in map for setPedAnimation
1 parent f85b8f5 commit 3b1acd7

File tree

4 files changed

+57
-17
lines changed

4 files changed

+57
-17
lines changed

Client/mods/deathmatch/logic/CClientGame.cpp

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3701,9 +3701,9 @@ bool CClientGame::StaticChokingHandler ( unsigned char ucWeaponType )
37013701
return g_pClientGame->ChokingHandler ( ucWeaponType );
37023702
}
37033703

3704-
void CClientGame::StaticCAnimBlendAssocHierConstructorHandler ( CAnimBlendAssociationSAInterface * pThis, RpClump * pClump, CAnimBlendHierarchySAInterface * pAnimHierarchy )
3704+
bool CClientGame::StaticCAnimBlendAssocHierConstructorHandler ( SIFPAnimations ** pOutIFPAnimations, CAnimBlendAssociationSAInterface * pThis, RpClump * pClump, CAnimBlendHierarchySAInterface * pAnimHierarchy )
37053705
{
3706-
g_pClientGame->CAnimBlendAssocHierConstructorHandler ( pThis, pClump, pAnimHierarchy );
3706+
return g_pClientGame->CAnimBlendAssocHierConstructorHandler ( pOutIFPAnimations, pThis, pClump, pAnimHierarchy );
37073707
}
37083708

37093709
void CClientGame::StaticCAnimBlendAssocDestructorHandler ( CAnimBlendAssociationSAInterface * pThis )
@@ -4013,9 +4013,24 @@ bool CClientGame::ChokingHandler ( unsigned char ucWeaponType )
40134013
}
40144014

40154015

4016-
void CClientGame::CAnimBlendAssocHierConstructorHandler ( CAnimBlendAssociationSAInterface * pThis, RpClump * pClump, CAnimBlendHierarchySAInterface * pAnimHierarchy )
4016+
bool CClientGame::CAnimBlendAssocHierConstructorHandler ( SIFPAnimations ** pOutIFPAnimations, CAnimBlendAssociationSAInterface * pThis, RpClump * pClump, CAnimBlendHierarchySAInterface * pAnimHierarchy )
40174017
{
40184018
printf("CClientGame::CAnimBlendAssocHierConstructorHandler called! sAnimID: %d\n", pThis->sAnimID);
4019+
bool isCustomAnimationToPlay = false;
4020+
4021+
CAnimManager * pAnimationManager = g_pGame->GetAnimManager();
4022+
CClientPed * pClientPed = GetClientPedByClump ( *pClump );
4023+
if ( pClientPed != nullptr )
4024+
{
4025+
printf("CAnimBlendAssocHierConstructorHandler: got pClientPed\n\n");
4026+
if ( pClientPed->IsCurrentAnimationCustom ( ) )
4027+
{
4028+
printf("CAnimBlendAssocHierConstructorHandler: current animation is custom\n\n");
4029+
*pOutIFPAnimations = pClientPed->GetIFPAnimationsPointer ();
4030+
isCustomAnimationToPlay = true;
4031+
}
4032+
}
4033+
return isCustomAnimationToPlay;
40194034
}
40204035

40214036

@@ -4109,15 +4124,14 @@ CAnimBlendHierarchySAInterface * CClientGame::BlendAnimationHierarchyHandler ( R
41094124
auto pCustomAnimBlendHierarchy = pIFP->GetAnimationHierarchy ( strAnimationName );
41104125
if ( pCustomAnimBlendHierarchy != nullptr )
41114126
{
4112-
printf ("BlendAnimationHierarchyHandler: Found Hierarchy, returning \n");
4113-
41144127
pClientPed->setCurrentAnimationCustom ( true );
4115-
4128+
pClientPed->SetIFPAnimationsPointer ( pIFP->GetIFPAnimationsPointer () );
41164129
// Modifying a hierarchy like this is just bad, it's much better to create a new CAnimBlendHierarchySAInterface for every animation
41174130
// and then delete it once animation is over
41184131
pCustomAnimBlendHierarchy->iHashKey = pAnimHierarchy->iHashKey;
41194132
pCustomAnimBlendHierarchy->iAnimBlockID = pAnimHierarchy->iAnimBlockID;
41204133
pClientPed->setNextAnimationNormal ( );
4134+
printf ("BlendAnimationHierarchyHandler: Found Hierarchy, returning \n");
41214135
return pCustomAnimBlendHierarchy;
41224136
}
41234137
else
@@ -4130,10 +4144,8 @@ CAnimBlendHierarchySAInterface * CClientGame::BlendAnimationHierarchyHandler ( R
41304144
printf("BlendAnimationHierarchyHandler: could not find IFP block name '%s'\n", strBlockName.c_str());
41314145
}
41324146
}
4133-
else
4134-
{
4135-
pClientPed->setCurrentAnimationCustom ( false );
4136-
}
4147+
4148+
pClientPed->setCurrentAnimationCustom ( false );
41374149
pClientPed->setNextAnimationNormal ( );
41384150
}
41394151
return pAnimHierarchy;

Client/mods/deathmatch/logic/CClientGame.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ class CClientGame
503503
static void StaticPostWorldProcessHandler ( void );
504504
static void StaticPreFxRenderHandler ( void );
505505
static void StaticPreHudRenderHandler ( void );
506-
static void StaticCAnimBlendAssocHierConstructorHandler ( CAnimBlendAssociationSAInterface * pThis, RpClump * pClump, CAnimBlendHierarchySAInterface * pAnimHierarchy );
506+
static bool StaticCAnimBlendAssocHierConstructorHandler ( SIFPAnimations ** pOutIFPAnimations, CAnimBlendAssociationSAInterface * pThis, RpClump * pClump, CAnimBlendHierarchySAInterface * pAnimHierarchy );
507507
static void StaticCAnimBlendAssocDestructorHandler ( CAnimBlendAssociationSAInterface * pThis );
508508
static CAnimBlendAssociationSAInterface * StaticAddAnimationHandler ( RpClump * pClump, AssocGroupId animGroup, AnimationId animID );
509509
static CAnimBlendAssociationSAInterface * StaticAddAnimationAndSyncHandler( RpClump * pClump, CAnimBlendAssociationSAInterface * pAnimAssocToSyncWith, AssocGroupId animGroup, AnimationId animID );
@@ -538,7 +538,7 @@ class CClientGame
538538
bool ChokingHandler ( unsigned char ucWeaponType );
539539
void PreWorldProcessHandler ( void );
540540
void PostWorldProcessHandler ( void );
541-
void CAnimBlendAssocHierConstructorHandler ( CAnimBlendAssociationSAInterface * pThis, RpClump * pClump, CAnimBlendHierarchySAInterface * pAnimHierarchy );
541+
bool CAnimBlendAssocHierConstructorHandler ( SIFPAnimations ** pOutIFPAnimations, CAnimBlendAssociationSAInterface * pThis, RpClump * pClump, CAnimBlendHierarchySAInterface * pAnimHierarchy );
542542
void CAnimBlendAssocDestructorHandler ( CAnimBlendAssociationSAInterface * pThis );
543543
CAnimBlendAssociationSAInterface * AddAnimationHandler ( RpClump * pClump, AssocGroupId animGroup, AnimationId animID );
544544
CAnimBlendAssociationSAInterface * AddAnimationAndSyncHandler ( RpClump * pClump, CAnimBlendAssociationSAInterface * pAnimAssocToSyncWith, AssocGroupId animGroup, AnimationId animID );

Client/multiplayer_sa/CMultiplayerSA_CustomAnimations.cpp

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ void InsertAnimationAssociationToMap ( CAnimBlendAssociationSAInterface * pAnimA
6565
// We don't increment pIFPAnimations->iReferences here because it's done
6666
// in custom animation handler functions in CClientGame.cpp
6767
//mapOfCustomAnimationAssociations [ pAnimAssociation ] = pIFPAnimations;
68-
//printf("InsertAnimationAssociationToMap: sAnimID: %d | iReferences: %d \n", pAnimAssociation->sAnimID, pIFPAnimations->iReferences);
68+
printf("InsertAnimationAssociationToMap: sAnimID: %d | iReferences: %d \n", pAnimAssociation->sAnimID, pIFPAnimations->iReferences);
6969
}
7070

7171
void RemoveAnimationAssociationFromMap ( CAnimBlendAssociationSAInterface * pAnimAssociation )
@@ -96,15 +96,43 @@ void _declspec(naked) HOOK_CAnimBlendAssoc_Hierarchy_Constructor ()
9696
_asm
9797
{
9898
popad
99+
push edx
99100
push ecx
100-
mov eax, dword ptr [esp+0Ch] // pAnimHierarchy
101+
102+
push ebp
103+
mov ebp, esp
104+
sub esp, 4
105+
106+
mov eax, dword ptr [esp+18h] // pAnimHierarchy [esp+0Ch]
101107
push eax
102-
mov eax, dword ptr [esp+0Ch] // pClump
108+
mov eax, dword ptr [esp+18h] // pClump [esp+0Ch]
103109
push eax
104110
push ecx // this
111+
lea edx, [ebp-4]
112+
push edx
105113
call m_pCAnimBlendAssocHierConstructorHandler
106-
add esp, 0Ch
114+
add esp, 10h
115+
116+
// It's a custom animation, store it in a map
117+
mov edx, [ebp-4]
118+
119+
add esp, 4 // remove space for local var
120+
mov esp, ebp
121+
pop ebp
122+
123+
// Check if it's a custom animation or not
124+
cmp eax, 00
125+
je NOT_CUSTOM_ANIMATION_CAnimBlendAssoc_Hierarchy_Constructor
126+
127+
push edx // pIFPAnimations
128+
mov ecx, [esp]
129+
push ecx // pAnimAssociation
130+
call InsertAnimationAssociationToMap
131+
add esp, 8
132+
133+
NOT_CUSTOM_ANIMATION_CAnimBlendAssoc_Hierarchy_Constructor:
107134
pop ecx
135+
pop edx
108136
pushad
109137
jmp NORMAL_FLOW_CAnimBlendAssoc_Hierarchy_Constructor
110138
}

Client/sdk/multiplayer/CMultiplayer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ typedef void ( PreFxRenderHandler ) ( void );
7272
typedef void ( PreHudRenderHandler ) ( void );
7373
typedef CAnimBlendAssociationSAInterface * ( AddAnimationHandler ) ( RpClump * pClump, AssocGroupId animGroup, AnimationId animID );
7474
typedef CAnimBlendAssociationSAInterface * ( AddAnimationAndSyncHandler ) ( RpClump * pClump, CAnimBlendAssociationSAInterface * pAnimAssocToSyncWith, AssocGroupId animGroup, AnimationId animID );
75-
typedef void ( CAnimBlendAssocHierConstructorHandler ) ( CAnimBlendAssociationSAInterface * pThis, RpClump * pClump, CAnimBlendHierarchySAInterface * pAnimHierarchy );
75+
typedef bool ( CAnimBlendAssocHierConstructorHandler ) ( SIFPAnimations ** pOutIFPAnimations, CAnimBlendAssociationSAInterface * pThis, RpClump * pClump, CAnimBlendHierarchySAInterface * pAnimHierarchy );
7676
typedef void ( CAnimBlendAssocDestructorHandler ) ( CAnimBlendAssociationSAInterface * pThis );
7777
typedef bool ( AssocGroupCopyAnimationHandler ) ( CAnimBlendStaticAssociationSAInterface * pOutAnimStaticAssoc, SIFPAnimations ** pOutIFPAnimations, RpClump * pClump, CAnimBlendAssocGroupSAInterface * pAnimAssocGroup, AnimationId animID );
7878
typedef CAnimBlendHierarchySAInterface * ( BlendAnimationHierarchyHandler ) ( RpClump * pClump, CAnimBlendHierarchySAInterface * pAnimHierarchy, int flags, float fBlendDelta );

0 commit comments

Comments
 (0)