@@ -3707,9 +3707,9 @@ CAnimBlendAssociationSAInterface * CClientGame::StaticAddAnimationAndSyncHandler
37073707 return g_pClientGame->AddAnimationAndSyncHandler ( pClump, pAnimAssocToSyncWith, animGroup, animID );
37083708}
37093709
3710- void CClientGame::StaticAssocGroupCopyAnimationHandler ( CAnimBlendStaticAssociationSAInterface * pOutAnimStaticAssoc, RpClump * pClump, CAnimBlendAssocGroupSAInterface * pAnimAssocGroup, AnimationId animID )
3710+ bool CClientGame::StaticAssocGroupCopyAnimationHandler ( CAnimBlendStaticAssociationSAInterface * pOutAnimStaticAssoc, SIFPAnimations ** pOutIFPAnimations , RpClump * pClump, CAnimBlendAssocGroupSAInterface * pAnimAssocGroup, AnimationId animID )
37113711{
3712- g_pClientGame->AssocGroupCopyAnimationHandler ( pOutAnimStaticAssoc, pClump, pAnimAssocGroup, animID );
3712+ return g_pClientGame->AssocGroupCopyAnimationHandler ( pOutAnimStaticAssoc, pOutIFPAnimations , pClump, pAnimAssocGroup, animID );
37133713}
37143714
37153715CAnimBlendHierarchySAInterface * CClientGame::StaticBlendAnimationHierarchyHandler ( RpClump * pClump, CAnimBlendHierarchySAInterface * pAnimHierarchy, int flags, float fBlendDelta )
@@ -4003,13 +4003,13 @@ bool CClientGame::ChokingHandler ( unsigned char ucWeaponType )
40034003
40044004CAnimBlendAssociationSAInterface * CClientGame::AddAnimationHandler ( RpClump * pClump, AssocGroupId animGroup, AnimationId animID )
40054005{
4006- printf ( " AddAnimationHandler called! pClump, GroupID, AnimID: %p, %d, %d\n " , (void *)pClump, animGroup, animID );
4006+ // printf ( "AddAnimationHandler called! pClump, GroupID, AnimID: %p, %d, %d\n", (void*)pClump, animGroup, animID );
40074007 return nullptr ;
40084008}
40094009
40104010CAnimBlendAssociationSAInterface * CClientGame::AddAnimationAndSyncHandler ( RpClump * pClump, CAnimBlendAssociationSAInterface * pAnimAssocToSyncWith, AssocGroupId animGroup, AnimationId animID )
40114011{
4012- printf ( " AddAnimationAndSyncHandler called! pClump, GroupID, AnimID: %p, %d, %d\n " , (void *)pClump, animGroup, animID );
4012+ // printf ( "AddAnimationAndSyncHandler called! pClump, GroupID, AnimID: %p, %d, %d\n", (void*)pClump, animGroup, animID );
40134013 return nullptr ;
40144014}
40154015
@@ -4020,12 +4020,12 @@ typedef void (__thiscall* hCAnimBlendStaticAssociation_Init)
40204020 CAnimBlendHierarchySAInterface * pAnimBlendHierarchy
40214021);
40224022
4023- void CClientGame::AssocGroupCopyAnimationHandler ( CAnimBlendStaticAssociationSAInterface * pOutAnimStaticAssoc, RpClump * pClump, CAnimBlendAssocGroupSAInterface * pAnimAssocGroup, AnimationId animID )
4023+ bool CClientGame::AssocGroupCopyAnimationHandler ( CAnimBlendStaticAssociationSAInterface * pOutAnimStaticAssoc, SIFPAnimations ** pOutIFPAnimations , RpClump * pClump, CAnimBlendAssocGroupSAInterface * pAnimAssocGroup, AnimationId animID )
40244024{
40254025 printf (" AssocGroupCopyAnimationHandler called!\n " );
4026-
40274026 auto CAnimBlendStaticAssociation_Init = (hCAnimBlendStaticAssociation_Init)0x4CEC20 ;
40284027
4028+ bool isCustomAnimationToPlay = false ;
40294029 CAnimManager * pAnimationManager = g_pGame->GetAnimManager ();
40304030 auto pOriginalAnimStaticAssoc = pAnimationManager->GetAnimStaticAssociation ( pAnimAssocGroup->groupID , animID );
40314031
@@ -4036,6 +4036,7 @@ void CClientGame::AssocGroupCopyAnimationHandler ( CAnimBlendStaticAssociationSA
40364036 if ( pReplacedAnimHeirarchyInterface != nullptr )
40374037 { // Play our custom animation instead of default
40384038 CAnimBlendStaticAssociation_Init ( pOutAnimStaticAssoc, pClump, pReplacedAnimHeirarchyInterface );
4039+ isCustomAnimationToPlay = true ;
40394040 }
40404041 else
40414042 { // Play default internal animation
@@ -4053,6 +4054,9 @@ void CClientGame::AssocGroupCopyAnimationHandler ( CAnimBlendStaticAssociationSA
40534054 // Total bones in clump. GTA SA is using 32 bones for peds/players
40544055 pOutAnimStaticAssoc->nNumBlendNodes = pOriginalAnimStaticAssoc->nNumBlendNodes ;
40554056 pOutAnimStaticAssoc->sFlags = pOriginalAnimStaticAssoc->sFlags ;
4057+
4058+ printf (" CClientGame::AssocGroupCopyAnimationHandler: About to return!\n " );
4059+ return isCustomAnimationToPlay;
40564060}
40574061
40584062CAnimBlendHierarchySAInterface * CClientGame::BlendAnimationHierarchyHandler ( RpClump * pClump, CAnimBlendHierarchySAInterface * pAnimHierarchy, int flags, float fBlendDelta )
@@ -6892,7 +6896,7 @@ CClientPed * CClientGame::GetClientPedByClump ( const RpClump & Clump )
68926896 return nullptr ;
68936897}
68946898
6895- void CClientGame::onClientIFPUnload ( const CClientIFP & IFP )
6899+ void CClientGame::OnClientIFPUnload ( const CClientIFP & IFP )
68966900{
68976901 // remove IFP animations from replaced animations of peds/players
68986902 for ( auto it = m_mapOfPedPointers.begin (); it != m_mapOfPedPointers.end (); it++ )
@@ -6904,3 +6908,44 @@ void CClientGame::onClientIFPUnload ( const CClientIFP & IFP )
69046908 }
69056909 }
69066910}
6911+
6912+ void CClientGame::UnloadIFPAnimations ( SIFPAnimations * pIFPAnimations )
6913+ {
6914+ if ( pIFPAnimations->iReferences == 0 )
6915+ {
6916+ printf (" CClientGame::UnloadIFPAnimations (): iReferences are Zero\n " );
6917+
6918+ hCMemoryMgr_Free OLD_CMemoryMgr_Free = (hCMemoryMgr_Free)0x0072F430 ;
6919+ auto OLD_CAnimBlendHierarchy_RemoveFromUncompressedCache = (hCAnimBlendHierarchy_RemoveFromUncompressedCache)0x004D42A0 ;
6920+
6921+ for ( size_t i = 0 ; i < pIFPAnimations->vecAnimations .size (); i++ )
6922+ {
6923+ IFP_Animation * ifpAnimation = &pIFPAnimations->vecAnimations [i];
6924+
6925+ OLD_CAnimBlendHierarchy_RemoveFromUncompressedCache ( (int )&ifpAnimation->Hierarchy );
6926+
6927+ for (unsigned short SequenceIndex = 0 ; SequenceIndex < ifpAnimation->Hierarchy .m_nSeqCount ; SequenceIndex++)
6928+ {
6929+ _CAnimBlendSequence * pSequence = (_CAnimBlendSequence*)((BYTE*)ifpAnimation->Hierarchy .m_pSequences + (sizeof (_CAnimBlendSequence) * SequenceIndex));
6930+
6931+ if ( !( (pSequence->m_nFlags >> 3 ) & 1 ) ) // If ( !OneBigChunkForAllSequences )
6932+ {
6933+ OLD_CMemoryMgr_Free ( pSequence->m_pFrames ); // *(void **)(pThis + 8)); //pSequence->m_pFrames );
6934+ }
6935+ else
6936+ {
6937+ if ( SequenceIndex == 0 )
6938+ {
6939+ // All frames of all sequences are allocated on one memory block, so free that one
6940+ // and break the loop
6941+ OLD_CMemoryMgr_Free ( pSequence->m_pFrames );
6942+ break ;
6943+ }
6944+ }
6945+
6946+ }
6947+ delete ifpAnimation->pSequencesMemory ;
6948+ }
6949+ printf (" CClientGame::UnloadIFPAnimations (): IFP Animations have been unloaded successfully!\n " );
6950+ }
6951+ }
0 commit comments