@@ -4076,20 +4076,21 @@ bool CClientGame::AssocGroupCopyAnimationHandler ( CAnimBlendStaticAssociationSA
4076
4076
auto pReplacedAnimation = pClientPed->getReplacedAnimation ( pOriginalAnimStaticAssoc->pAnimHeirarchy );
4077
4077
if ( pReplacedAnimation != nullptr )
4078
4078
{
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
+ }
4089
4088
}
4090
4089
}
4091
- else
4092
- { // Play default internal animation
4090
+
4091
+ if ( !isCustomAnimationToPlay )
4092
+ {
4093
+ // Play default internal animation
4093
4094
CAnimBlendStaticAssociation_Init ( pOutAnimStaticAssoc, pClump, pOriginalAnimStaticAssoc->pAnimHeirarchy );
4094
4095
}
4095
4096
@@ -4124,15 +4125,22 @@ CAnimBlendHierarchySAInterface * CClientGame::BlendAnimationHierarchyHandler ( R
4124
4125
auto pCustomAnimBlendHierarchy = pIFP->GetAnimationHierarchy ( strAnimationName );
4125
4126
if ( pCustomAnimBlendHierarchy != nullptr )
4126
4127
{
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
+ }
4136
4144
}
4137
4145
else
4138
4146
{
@@ -6953,7 +6961,7 @@ void CClientGame::OnClientIFPUnload ( const CClientIFP & IFP )
6953
6961
}
6954
6962
}
6955
6963
6956
- void CClientGame::UnloadIFPAnimations ( SIFPAnimations * pIFPAnimations )
6964
+ void CClientGame::DeleteIFPAnimations ( SIFPAnimations * pIFPAnimations )
6957
6965
{
6958
6966
if ( pIFPAnimations->iReferences == 0 )
6959
6967
{
@@ -6990,6 +6998,7 @@ void CClientGame::UnloadIFPAnimations ( SIFPAnimations * pIFPAnimations )
6990
6998
}
6991
6999
delete ifpAnimation->pSequencesMemory ;
6992
7000
}
7001
+ delete pIFPAnimations;
6993
7002
printf (" CClientGame::UnloadIFPAnimations (): IFP Animations have been unloaded successfully!\n " );
6994
7003
}
6995
7004
}
0 commit comments