@@ -3701,9 +3701,9 @@ bool CClientGame::StaticChokingHandler ( unsigned char ucWeaponType )
37013701 return g_pClientGame->ChokingHandler ( ucWeaponType );
37023702}
37033703
3704- bool CClientGame::StaticCAnimBlendAssocHierConstructorHandler ( SIFPAnimations ** pOutIFPAnimations, CAnimBlendAssociationSAInterface * pThis, RpClump * pClump, CAnimBlendHierarchySAInterface * pAnimHierarchy )
3704+ bool CClientGame::StaticCAnimBlendAssocHierConstructorHandler ( SIFPAnimations ** pOutIFPAnimations, CAnimBlendAssociationSAInterface * pThis, RpClump * pClump, CAnimBlendHierarchySAInterface ** pOutAnimHierarchy )
37053705{
3706- return g_pClientGame->CAnimBlendAssocHierConstructorHandler ( pOutIFPAnimations, pThis, pClump, pAnimHierarchy );
3706+ return g_pClientGame->CAnimBlendAssocHierConstructorHandler ( pOutIFPAnimations, pThis, pClump, pOutAnimHierarchy );
37073707}
37083708
37093709void CClientGame::StaticCAnimBlendAssocDestructorHandler ( CAnimBlendAssociationSAInterface * pThis )
@@ -3726,9 +3726,9 @@ bool CClientGame::StaticAssocGroupCopyAnimationHandler ( CAnimBlendStaticAssocia
37263726 return g_pClientGame->AssocGroupCopyAnimationHandler ( pOutAnimStaticAssoc, pOutIFPAnimations, pClump, pAnimAssocGroup, animID );
37273727}
37283728
3729- CAnimBlendHierarchySAInterface * CClientGame::StaticBlendAnimationHierarchyHandler ( RpClump * pClump , CAnimBlendHierarchySAInterface * pAnimHierarchy, int flags, float fBlendDelta )
3729+ bool CClientGame::StaticBlendAnimationHierarchyHandler ( SIFPAnimations ** pOutIFPAnimations , CAnimBlendHierarchySAInterface ** pOutAnimHierarchy, RpClump * pClump )
37303730{
3731- return g_pClientGame->BlendAnimationHierarchyHandler ( pClump, pAnimHierarchy, flags, fBlendDelta );
3731+ return g_pClientGame->BlendAnimationHierarchyHandler ( pOutIFPAnimations, pOutAnimHierarchy, pClump );
37323732}
37333733
37343734void CClientGame::StaticPreWorldProcessHandler ( void )
@@ -4013,23 +4013,58 @@ bool CClientGame::ChokingHandler ( unsigned char ucWeaponType )
40134013}
40144014
40154015
4016- bool CClientGame::CAnimBlendAssocHierConstructorHandler ( SIFPAnimations ** pOutIFPAnimations, CAnimBlendAssociationSAInterface * pThis, RpClump * pClump, CAnimBlendHierarchySAInterface * pAnimHierarchy )
4016+ bool CClientGame::CAnimBlendAssocHierConstructorHandler ( SIFPAnimations ** pOutIFPAnimations, CAnimBlendAssociationSAInterface * pThis, RpClump * pClump, CAnimBlendHierarchySAInterface ** pOutAnimHierarchy )
40174017{
4018- printf (" CClientGame::CAnimBlendAssocHierConstructorHandler called! sAnimID: %d\n " , pThis->sAnimID );
40194018 bool isCustomAnimationToPlay = false ;
40204019
4020+ CAnimBlendHierarchySAInterface * pAnimHierarchy = *pOutAnimHierarchy;
4021+
4022+ printf (" pAnimHierarchy->usNumSequences: %d\n " , pAnimHierarchy->usNumSequences );
4023+
40214024 CAnimManager * pAnimationManager = g_pGame->GetAnimManager ();
40224025 CClientPed * pClientPed = GetClientPedByClump ( *pClump );
40234026 if ( pClientPed != nullptr )
40244027 {
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 ;
4028+ printf (" CAnimBlendAssocHierConstructorHandler: Found pClientPed\n " );
4029+ if ( pClientPed->isNextAnimationCustom () )
4030+ {
4031+ const SString & strBlockName = pClientPed->GetNextAnimationCustomBlockName ( );
4032+ CClientIFP * pIFP = GetIFPPointerFromMap ( strBlockName );
4033+ if ( pIFP )
4034+ {
4035+ const SString & strAnimationName = pClientPed->GetNextAnimationCustomName ( );
4036+ auto pCustomAnimBlendHierarchy = pIFP->GetAnimationHierarchy ( strAnimationName );
4037+ if ( pCustomAnimBlendHierarchy != nullptr )
4038+ {
4039+ if ( pIFP->isIFPLoaded ( ) )
4040+ {
4041+ SIFPAnimations * pIFPAnimations = pIFP->GetIFPAnimationsPointer ();
4042+ pIFPAnimations->iReferences ++;
4043+
4044+ pClientPed->setCurrentAnimationCustom ( true );
4045+ pClientPed->setNextAnimationNormal ( );
4046+
4047+ *pOutIFPAnimations = pIFPAnimations;
4048+ *pOutAnimHierarchy = pCustomAnimBlendHierarchy;
4049+ isCustomAnimationToPlay = true ;
4050+ return isCustomAnimationToPlay;
4051+ }
4052+ }
4053+ else
4054+ {
4055+ printf (" CAnimBlendAssocHierConstructorHandler: could not find IFP animation hierarchy '%s'\n " , strAnimationName.c_str ());
4056+ }
4057+ }
4058+ else
4059+ {
4060+ printf (" CAnimBlendAssocHierConstructorHandler: could not find IFP block name '%s'\n " , strBlockName.c_str ());
4061+ }
40314062 }
4063+
4064+ pClientPed->setCurrentAnimationCustom ( false );
4065+ pClientPed->setNextAnimationNormal ( );
40324066 }
4067+ printf (" CClientGame::CAnimBlendAssocHierConstructorHandler RETURNING! sAnimID: %d\n " , pThis->sAnimID );
40334068 return isCustomAnimationToPlay;
40344069}
40354070
@@ -4106,15 +4141,15 @@ bool CClientGame::AssocGroupCopyAnimationHandler ( CAnimBlendStaticAssociationSA
41064141}
41074142
41084143
4109- CAnimBlendHierarchySAInterface * CClientGame::BlendAnimationHierarchyHandler ( RpClump * pClump , CAnimBlendHierarchySAInterface * pAnimHierarchy, int flags, float fBlendDelta )
4144+ bool CClientGame::BlendAnimationHierarchyHandler ( SIFPAnimations ** pOutIFPAnimations , CAnimBlendHierarchySAInterface ** pOutAnimHierarchy, RpClump * pClump )
41104145{
4111- printf ( " CClientGame::BlendAnimationHierarchyHandler called | pClump: %p \n " , ( void *)pClump) ;
4146+ bool isCustomAnimationToPlay = false ;
41124147
41134148 CAnimManager * pAnimationManager = g_pGame->GetAnimManager ();
4114- CClientPed * pClientPed = GetClientPedByClump ( *pClump ); // pAnimationManager->GetPedPointerFromMap ( pClump ); //m_pRootEntity->GetClientPedByClump ( *pClump );
4149+ CClientPed * pClientPed = GetClientPedByClump ( *pClump );
41154150 if ( pClientPed != nullptr )
41164151 {
4117- printf (" BlendAnimationHierarchyHandler : Found pClientPed\n " );
4152+ printf (" CAnimBlendAssocHierConstructorHandler : Found pClientPed\n " );
41184153 if ( pClientPed->isNextAnimationCustom () )
41194154 {
41204155 const SString & strBlockName = pClientPed->GetNextAnimationCustomBlockName ( );
@@ -4131,32 +4166,29 @@ CAnimBlendHierarchySAInterface * CClientGame::BlendAnimationHierarchyHandler ( R
41314166 pIFPAnimations->iReferences ++;
41324167
41334168 pClientPed->setCurrentAnimationCustom ( true );
4134- pClientPed->SetIFPAnimationsPointer ( pIFPAnimations );
4135- // Modifying a hierarchy like this is just bad, it's much better to create a new CAnimBlendHierarchySAInterface for every animation
4136- // and then delete it once animation is over
4137- pCustomAnimBlendHierarchy->iHashKey = pAnimHierarchy->iHashKey ;
4138- pCustomAnimBlendHierarchy->iAnimBlockID = pAnimHierarchy->iAnimBlockID ;
41394169 pClientPed->setNextAnimationNormal ( );
41404170
4141- printf (" BlendAnimationHierarchyHandler: Found Hierarchy, returning \n " );
4142- return pCustomAnimBlendHierarchy;
4171+ *pOutIFPAnimations = pIFPAnimations;
4172+ *pOutAnimHierarchy = pCustomAnimBlendHierarchy;
4173+ isCustomAnimationToPlay = true ;
4174+ return isCustomAnimationToPlay;
41434175 }
41444176 }
41454177 else
41464178 {
4147- printf (" BlendAnimationHierarchyHandler : could not find IFP animation hierarchy '%s'\n " , strAnimationName.c_str ());
4179+ printf (" CAnimBlendAssocHierConstructorHandler : could not find IFP animation hierarchy '%s'\n " , strAnimationName.c_str ());
41484180 }
41494181 }
41504182 else
41514183 {
4152- printf (" BlendAnimationHierarchyHandler : could not find IFP block name '%s'\n " , strBlockName.c_str ());
4184+ printf (" CAnimBlendAssocHierConstructorHandler : could not find IFP block name '%s'\n " , strBlockName.c_str ());
41534185 }
41544186 }
41554187
41564188 pClientPed->setCurrentAnimationCustom ( false );
41574189 pClientPed->setNextAnimationNormal ( );
41584190 }
4159- return pAnimHierarchy ;
4191+ return isCustomAnimationToPlay ;
41604192}
41614193
41624194
0 commit comments