@@ -4076,20 +4076,21 @@ bool CClientGame::AssocGroupCopyAnimationHandler ( CAnimBlendStaticAssociationSA
40764076 auto pReplacedAnimation = pClientPed->getReplacedAnimation ( pOriginalAnimStaticAssoc->pAnimHeirarchy );
40774077 if ( pReplacedAnimation != nullptr )
40784078 {
4079- SIFPAnimations * pIFPAnimations = pReplacedAnimation->pIFP ->GetIFPAnimationsPointer ();
4080- printf (" \n AssocGroupCopyAnimationHandler: pIFPAnimations: %p\n\n " , pIFPAnimations);
4081- // Play our custom animation instead of default
4082- *pOutIFPAnimations = pIFPAnimations;
4083- CAnimBlendStaticAssociation_Init ( pOutAnimStaticAssoc, pClump, pReplacedAnimation->pAnimationHierarchy );
4084- isCustomAnimationToPlay = true ;
4085- }
4086- else
4087- { // Play default internal animation
4088- CAnimBlendStaticAssociation_Init ( pOutAnimStaticAssoc, pClump, pOriginalAnimStaticAssoc->pAnimHeirarchy );
4079+ if ( pReplacedAnimation->pIFP ->isIFPLoaded ( ) )
4080+ {
4081+ SIFPAnimations * pIFPAnimations = pReplacedAnimation->pIFP ->GetIFPAnimationsPointer ();
4082+ pIFPAnimations->iReferences ++;
4083+ // Play our custom animation instead of default
4084+ *pOutIFPAnimations = pIFPAnimations;
4085+ CAnimBlendStaticAssociation_Init ( pOutAnimStaticAssoc, pClump, pReplacedAnimation->pAnimationHierarchy );
4086+ isCustomAnimationToPlay = true ;
4087+ }
40894088 }
40904089 }
4091- else
4092- { // Play default internal animation
4090+
4091+ if ( !isCustomAnimationToPlay )
4092+ {
4093+ // Play default internal animation
40934094 CAnimBlendStaticAssociation_Init ( pOutAnimStaticAssoc, pClump, pOriginalAnimStaticAssoc->pAnimHeirarchy );
40944095 }
40954096
@@ -4124,15 +4125,22 @@ CAnimBlendHierarchySAInterface * CClientGame::BlendAnimationHierarchyHandler ( R
41244125 auto pCustomAnimBlendHierarchy = pIFP->GetAnimationHierarchy ( strAnimationName );
41254126 if ( pCustomAnimBlendHierarchy != nullptr )
41264127 {
4127- pClientPed->setCurrentAnimationCustom ( true );
4128- pClientPed->SetIFPAnimationsPointer ( pIFP->GetIFPAnimationsPointer () );
4129- // Modifying a hierarchy like this is just bad, it's much better to create a new CAnimBlendHierarchySAInterface for every animation
4130- // and then delete it once animation is over
4131- pCustomAnimBlendHierarchy->iHashKey = pAnimHierarchy->iHashKey ;
4132- pCustomAnimBlendHierarchy->iAnimBlockID = pAnimHierarchy->iAnimBlockID ;
4133- pClientPed->setNextAnimationNormal ( );
4134- printf (" BlendAnimationHierarchyHandler: Found Hierarchy, returning \n " );
4135- return pCustomAnimBlendHierarchy;
4128+ if ( pIFP->isIFPLoaded ( ) )
4129+ {
4130+ SIFPAnimations * pIFPAnimations = pIFP->GetIFPAnimationsPointer ();
4131+ pIFPAnimations->iReferences ++;
4132+
4133+ 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 ;
4139+ pClientPed->setNextAnimationNormal ( );
4140+
4141+ printf (" BlendAnimationHierarchyHandler: Found Hierarchy, returning \n " );
4142+ return pCustomAnimBlendHierarchy;
4143+ }
41364144 }
41374145 else
41384146 {
@@ -6953,7 +6961,7 @@ void CClientGame::OnClientIFPUnload ( const CClientIFP & IFP )
69536961 }
69546962}
69556963
6956- void CClientGame::UnloadIFPAnimations ( SIFPAnimations * pIFPAnimations )
6964+ void CClientGame::DeleteIFPAnimations ( SIFPAnimations * pIFPAnimations )
69576965{
69586966 if ( pIFPAnimations->iReferences == 0 )
69596967 {
@@ -6990,6 +6998,7 @@ void CClientGame::UnloadIFPAnimations ( SIFPAnimations * pIFPAnimations )
69906998 }
69916999 delete ifpAnimation->pSequencesMemory ;
69927000 }
7001+ delete pIFPAnimations;
69937002 printf (" CClientGame::UnloadIFPAnimations (): IFP Animations have been unloaded successfully!\n " );
69947003 }
69957004}
0 commit comments