@@ -3714,14 +3714,14 @@ CAnimBlendAssociationSAInterface * CClientGame::StaticAddAnimationAndSyncHandler
3714
3714
return g_pClientGame->AddAnimationAndSyncHandler ( pClump, pAnimAssocToSyncWith, animGroup, animID );
3715
3715
}
3716
3716
3717
- bool CClientGame::StaticAssocGroupCopyAnimationHandler ( CAnimBlendStaticAssociationSAInterface * pOutAnimStaticAssoc, SIFPAnimations ** pOutIFPAnimations , RpClump * pClump, CAnimBlendAssocGroupSAInterface * pAnimAssocGroup, AnimationId animID )
3717
+ bool CClientGame::StaticAssocGroupCopyAnimationHandler ( CAnimBlendStaticAssociationSAInterface * pOutAnimStaticAssoc, CAnimBlendAssociationSAInterface * pAnimAssoc , RpClump * pClump, CAnimBlendAssocGroupSAInterface * pAnimAssocGroup, AnimationId animID )
3718
3718
{
3719
- return g_pClientGame->AssocGroupCopyAnimationHandler ( pOutAnimStaticAssoc, pOutIFPAnimations , pClump, pAnimAssocGroup, animID );
3719
+ return g_pClientGame->AssocGroupCopyAnimationHandler ( pOutAnimStaticAssoc, pAnimAssoc , pClump, pAnimAssocGroup, animID );
3720
3720
}
3721
3721
3722
- bool CClientGame::StaticBlendAnimationHierarchyHandler ( SIFPAnimations ** pOutIFPAnimations , CAnimBlendHierarchySAInterface ** pOutAnimHierarchy, RpClump * pClump )
3722
+ bool CClientGame::StaticBlendAnimationHierarchyHandler ( CAnimBlendAssociationSAInterface * pAnimAssoc , CAnimBlendHierarchySAInterface ** pOutAnimHierarchy, RpClump * pClump )
3723
3723
{
3724
- return g_pClientGame->BlendAnimationHierarchyHandler ( pOutIFPAnimations , pOutAnimHierarchy, pClump );
3724
+ return g_pClientGame->BlendAnimationHierarchyHandler ( pAnimAssoc , pOutAnimHierarchy, pClump );
3725
3725
}
3726
3726
3727
3727
void CClientGame::StaticPreWorldProcessHandler ( void )
@@ -4009,6 +4009,7 @@ bool CClientGame::ChokingHandler ( unsigned char ucWeaponType )
4009
4009
void CClientGame::CAnimBlendAssocDestructorHandler ( CAnimBlendAssociationSAInterface * pThis )
4010
4010
{
4011
4011
// printf("CClientGame::CAnimBlendAssocDestructorHandler called! sAnimID: %d\n", pThis->sAnimID);
4012
+ RemoveAnimationAssociationFromMap ( pThis );
4012
4013
}
4013
4014
4014
4015
@@ -4034,11 +4035,12 @@ typedef void (__thiscall* hCAnimBlendStaticAssociation_Init)
4034
4035
);
4035
4036
4036
4037
4037
- bool CClientGame::AssocGroupCopyAnimationHandler ( CAnimBlendStaticAssociationSAInterface * pOutAnimStaticAssoc, SIFPAnimations ** pOutIFPAnimations , RpClump * pClump, CAnimBlendAssocGroupSAInterface * pAnimAssocGroup, AnimationId animID )
4038
+ bool CClientGame::AssocGroupCopyAnimationHandler ( CAnimBlendStaticAssociationSAInterface * pOutAnimStaticAssoc, CAnimBlendAssociationSAInterface * pAnimAssoc , RpClump * pClump, CAnimBlendAssocGroupSAInterface * pAnimAssocGroup, AnimationId animID )
4038
4039
{
4039
4040
auto CAnimBlendStaticAssociation_Init = (hCAnimBlendStaticAssociation_Init)0x4CEC20 ;
4040
4041
4041
4042
bool isCustomAnimationToPlay = false ;
4043
+
4042
4044
CAnimManager * pAnimationManager = g_pGame->GetAnimManager ();
4043
4045
auto pOriginalAnimStaticAssoc = pAnimationManager->GetAnimStaticAssociation ( pAnimAssocGroup->groupID , animID );
4044
4046
@@ -4050,10 +4052,10 @@ bool CClientGame::AssocGroupCopyAnimationHandler ( CAnimBlendStaticAssociationSA
4050
4052
{
4051
4053
if ( pReplacedAnimation->pIFP ->isIFPLoaded ( ) )
4052
4054
{
4053
- SIFPAnimations * pIFPAnimations = pReplacedAnimation->pIFP ->GetIFPAnimationsPointer ();
4054
- pIFPAnimations->iReferences ++;
4055
+ std::shared_ptr < CIFPAnimations > pIFPAnimations = pReplacedAnimation->pIFP ->GetIFPAnimationsPointer ();
4056
+ InsertAnimationAssociationToMap ( pAnimAssoc, pIFPAnimations );
4057
+
4055
4058
// Play our custom animation instead of default
4056
- *pOutIFPAnimations = pIFPAnimations;
4057
4059
CAnimBlendStaticAssociation_Init ( pOutAnimStaticAssoc, pClump, pReplacedAnimation->pAnimationHierarchy );
4058
4060
isCustomAnimationToPlay = true ;
4059
4061
}
@@ -4074,13 +4076,14 @@ bool CClientGame::AssocGroupCopyAnimationHandler ( CAnimBlendStaticAssociationSA
4074
4076
pOutAnimStaticAssoc->sFlags = pOriginalAnimStaticAssoc->sFlags ;
4075
4077
4076
4078
printf (" CClientGame::AssocGroupCopyAnimationHandler: About to return sAnimGroup: %d | sAnimID: %d !\n " , pOutAnimStaticAssoc->sAnimGroup , pOutAnimStaticAssoc->sAnimID );
4079
+
4077
4080
return isCustomAnimationToPlay;
4078
4081
}
4079
4082
4080
4083
4081
- bool CClientGame::BlendAnimationHierarchyHandler ( SIFPAnimations ** pOutIFPAnimations , CAnimBlendHierarchySAInterface ** pOutAnimHierarchy, RpClump * pClump )
4084
+ bool CClientGame::BlendAnimationHierarchyHandler ( CAnimBlendAssociationSAInterface * pAnimAssoc , CAnimBlendHierarchySAInterface ** pOutAnimHierarchy, RpClump * pClump )
4082
4085
{
4083
- bool isCustomAnimationToPlay = false ;
4086
+ bool isCustomAnimationToPlay = false ;
4084
4087
4085
4088
CAnimManager * pAnimationManager = g_pGame->GetAnimManager ();
4086
4089
CClientPed * pClientPed = GetClientPedByClump ( *pClump );
@@ -4099,13 +4102,12 @@ bool CClientGame::BlendAnimationHierarchyHandler ( SIFPAnimations ** pOutIFPAni
4099
4102
{
4100
4103
if ( pIFP->isIFPLoaded ( ) )
4101
4104
{
4102
- SIFPAnimations * pIFPAnimations = pIFP->GetIFPAnimationsPointer ();
4103
- pIFPAnimations-> iReferences ++ ;
4105
+ std::shared_ptr < CIFPAnimations > pIFPAnimations = pIFP->GetIFPAnimationsPointer ();
4106
+ InsertAnimationAssociationToMap ( pAnimAssoc, pIFPAnimations ) ;
4104
4107
4105
4108
pClientPed->setCurrentAnimationCustom ( true );
4106
4109
pClientPed->setNextAnimationNormal ( );
4107
4110
4108
- *pOutIFPAnimations = pIFPAnimations;
4109
4111
*pOutAnimHierarchy = pCustomAnimBlendHierarchy;
4110
4112
isCustomAnimationToPlay = true ;
4111
4113
return isCustomAnimationToPlay;
@@ -6931,44 +6933,12 @@ void CClientGame::OnClientIFPUnload ( const std::shared_ptr < CClientIFP > & IFP
6931
6933
}
6932
6934
}
6933
6935
6934
- void CClientGame::DeleteIFPAnimations ( SIFPAnimations * pIFPAnimations )
6936
+ void CClientGame::InsertAnimationAssociationToMap ( CAnimBlendAssociationSAInterface * pAnimAssociation, const std::shared_ptr < CIFPAnimations > & pIFPAnimations )
6935
6937
{
6936
- if ( pIFPAnimations->iReferences == 0 )
6937
- {
6938
- printf (" CClientGame::UnloadIFPAnimations (): iReferences are Zero\n " );
6939
-
6940
- hCMemoryMgr_Free OLD_CMemoryMgr_Free = (hCMemoryMgr_Free)0x0072F430 ;
6941
- auto OLD_CAnimBlendHierarchy_RemoveFromUncompressedCache = (hCAnimBlendHierarchy_RemoveFromUncompressedCache)0x004D42A0 ;
6942
-
6943
- for ( size_t i = 0 ; i < pIFPAnimations->vecAnimations .size (); i++ )
6944
- {
6945
- IFP_Animation * ifpAnimation = &pIFPAnimations->vecAnimations [i];
6946
-
6947
- OLD_CAnimBlendHierarchy_RemoveFromUncompressedCache ( (int )&ifpAnimation->Hierarchy );
6948
-
6949
- for (unsigned short SequenceIndex = 0 ; SequenceIndex < ifpAnimation->Hierarchy .m_nSeqCount ; SequenceIndex++)
6950
- {
6951
- _CAnimBlendSequence * pSequence = (_CAnimBlendSequence*)((BYTE*)ifpAnimation->Hierarchy .m_pSequences + (sizeof (_CAnimBlendSequence) * SequenceIndex));
6938
+ m_mapOfCustomAnimationAssociations [ pAnimAssociation ] = pIFPAnimations;
6939
+ }
6952
6940
6953
- if ( !( (pSequence->m_nFlags >> 3 ) & 1 ) ) // If ( !OneBigChunkForAllSequences )
6954
- {
6955
- OLD_CMemoryMgr_Free ( pSequence->m_pFrames ); // *(void **)(pThis + 8)); //pSequence->m_pFrames );
6956
- }
6957
- else
6958
- {
6959
- if ( SequenceIndex == 0 )
6960
- {
6961
- // All frames of all sequences are allocated on one memory block, so free that one
6962
- // and break the loop
6963
- OLD_CMemoryMgr_Free ( pSequence->m_pFrames );
6964
- break ;
6965
- }
6966
- }
6967
-
6968
- }
6969
- delete ifpAnimation->pSequencesMemory ;
6970
- }
6971
- delete pIFPAnimations;
6972
- printf (" CClientGame::UnloadIFPAnimations (): IFP Animations have been unloaded successfully!\n " );
6973
- }
6941
+ void CClientGame::RemoveAnimationAssociationFromMap ( CAnimBlendAssociationSAInterface * pAnimAssociation )
6942
+ {
6943
+ m_mapOfCustomAnimationAssociations.erase ( pAnimAssociation );
6974
6944
}
0 commit comments