@@ -3714,14 +3714,14 @@ CAnimBlendAssociationSAInterface * CClientGame::StaticAddAnimationAndSyncHandler
37143714 return g_pClientGame->AddAnimationAndSyncHandler ( pClump, pAnimAssocToSyncWith, animGroup, animID );
37153715}
37163716
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 )
37183718{
3719- return g_pClientGame->AssocGroupCopyAnimationHandler ( pOutAnimStaticAssoc, pOutIFPAnimations , pClump, pAnimAssocGroup, animID );
3719+ return g_pClientGame->AssocGroupCopyAnimationHandler ( pOutAnimStaticAssoc, pAnimAssoc , pClump, pAnimAssocGroup, animID );
37203720}
37213721
3722- bool CClientGame::StaticBlendAnimationHierarchyHandler ( SIFPAnimations ** pOutIFPAnimations , CAnimBlendHierarchySAInterface ** pOutAnimHierarchy, RpClump * pClump )
3722+ bool CClientGame::StaticBlendAnimationHierarchyHandler ( CAnimBlendAssociationSAInterface * pAnimAssoc , CAnimBlendHierarchySAInterface ** pOutAnimHierarchy, RpClump * pClump )
37233723{
3724- return g_pClientGame->BlendAnimationHierarchyHandler ( pOutIFPAnimations , pOutAnimHierarchy, pClump );
3724+ return g_pClientGame->BlendAnimationHierarchyHandler ( pAnimAssoc , pOutAnimHierarchy, pClump );
37253725}
37263726
37273727void CClientGame::StaticPreWorldProcessHandler ( void )
@@ -4009,6 +4009,7 @@ bool CClientGame::ChokingHandler ( unsigned char ucWeaponType )
40094009void CClientGame::CAnimBlendAssocDestructorHandler ( CAnimBlendAssociationSAInterface * pThis )
40104010{
40114011 // printf("CClientGame::CAnimBlendAssocDestructorHandler called! sAnimID: %d\n", pThis->sAnimID);
4012+ RemoveAnimationAssociationFromMap ( pThis );
40124013}
40134014
40144015
@@ -4034,11 +4035,12 @@ typedef void (__thiscall* hCAnimBlendStaticAssociation_Init)
40344035);
40354036
40364037
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 )
40384039{
40394040 auto CAnimBlendStaticAssociation_Init = (hCAnimBlendStaticAssociation_Init)0x4CEC20 ;
40404041
40414042 bool isCustomAnimationToPlay = false ;
4043+
40424044 CAnimManager * pAnimationManager = g_pGame->GetAnimManager ();
40434045 auto pOriginalAnimStaticAssoc = pAnimationManager->GetAnimStaticAssociation ( pAnimAssocGroup->groupID , animID );
40444046
@@ -4050,10 +4052,10 @@ bool CClientGame::AssocGroupCopyAnimationHandler ( CAnimBlendStaticAssociationSA
40504052 {
40514053 if ( pReplacedAnimation->pIFP ->isIFPLoaded ( ) )
40524054 {
4053- SIFPAnimations * pIFPAnimations = pReplacedAnimation->pIFP ->GetIFPAnimationsPointer ();
4054- pIFPAnimations->iReferences ++;
4055+ std::shared_ptr < CIFPAnimations > pIFPAnimations = pReplacedAnimation->pIFP ->GetIFPAnimationsPointer ();
4056+ InsertAnimationAssociationToMap ( pAnimAssoc, pIFPAnimations );
4057+
40554058 // Play our custom animation instead of default
4056- *pOutIFPAnimations = pIFPAnimations;
40574059 CAnimBlendStaticAssociation_Init ( pOutAnimStaticAssoc, pClump, pReplacedAnimation->pAnimationHierarchy );
40584060 isCustomAnimationToPlay = true ;
40594061 }
@@ -4074,13 +4076,14 @@ bool CClientGame::AssocGroupCopyAnimationHandler ( CAnimBlendStaticAssociationSA
40744076 pOutAnimStaticAssoc->sFlags = pOriginalAnimStaticAssoc->sFlags ;
40754077
40764078 printf (" CClientGame::AssocGroupCopyAnimationHandler: About to return sAnimGroup: %d | sAnimID: %d !\n " , pOutAnimStaticAssoc->sAnimGroup , pOutAnimStaticAssoc->sAnimID );
4079+
40774080 return isCustomAnimationToPlay;
40784081}
40794082
40804083
4081- bool CClientGame::BlendAnimationHierarchyHandler ( SIFPAnimations ** pOutIFPAnimations , CAnimBlendHierarchySAInterface ** pOutAnimHierarchy, RpClump * pClump )
4084+ bool CClientGame::BlendAnimationHierarchyHandler ( CAnimBlendAssociationSAInterface * pAnimAssoc , CAnimBlendHierarchySAInterface ** pOutAnimHierarchy, RpClump * pClump )
40824085{
4083- bool isCustomAnimationToPlay = false ;
4086+ bool isCustomAnimationToPlay = false ;
40844087
40854088 CAnimManager * pAnimationManager = g_pGame->GetAnimManager ();
40864089 CClientPed * pClientPed = GetClientPedByClump ( *pClump );
@@ -4099,13 +4102,12 @@ bool CClientGame::BlendAnimationHierarchyHandler ( SIFPAnimations ** pOutIFPAni
40994102 {
41004103 if ( pIFP->isIFPLoaded ( ) )
41014104 {
4102- SIFPAnimations * pIFPAnimations = pIFP->GetIFPAnimationsPointer ();
4103- pIFPAnimations-> iReferences ++ ;
4105+ std::shared_ptr < CIFPAnimations > pIFPAnimations = pIFP->GetIFPAnimationsPointer ();
4106+ InsertAnimationAssociationToMap ( pAnimAssoc, pIFPAnimations ) ;
41044107
41054108 pClientPed->setCurrentAnimationCustom ( true );
41064109 pClientPed->setNextAnimationNormal ( );
41074110
4108- *pOutIFPAnimations = pIFPAnimations;
41094111 *pOutAnimHierarchy = pCustomAnimBlendHierarchy;
41104112 isCustomAnimationToPlay = true ;
41114113 return isCustomAnimationToPlay;
@@ -6931,44 +6933,12 @@ void CClientGame::OnClientIFPUnload ( const std::shared_ptr < CClientIFP > & IFP
69316933 }
69326934}
69336935
6934- void CClientGame::DeleteIFPAnimations ( SIFPAnimations * pIFPAnimations )
6936+ void CClientGame::InsertAnimationAssociationToMap ( CAnimBlendAssociationSAInterface * pAnimAssociation, const std::shared_ptr < CIFPAnimations > & pIFPAnimations )
69356937{
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+ }
69526940
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 );
69746944}
0 commit comments