@@ -3707,9 +3707,9 @@ CAnimBlendAssociationSAInterface * CClientGame::StaticAddAnimationAndSyncHandler
3707
3707
return g_pClientGame->AddAnimationAndSyncHandler ( pClump, pAnimAssocToSyncWith, animGroup, animID );
3708
3708
}
3709
3709
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 )
3711
3711
{
3712
- g_pClientGame->AssocGroupCopyAnimationHandler ( pOutAnimStaticAssoc, pClump, pAnimAssocGroup, animID );
3712
+ return g_pClientGame->AssocGroupCopyAnimationHandler ( pOutAnimStaticAssoc, pOutIFPAnimations , pClump, pAnimAssocGroup, animID );
3713
3713
}
3714
3714
3715
3715
CAnimBlendHierarchySAInterface * CClientGame::StaticBlendAnimationHierarchyHandler ( RpClump * pClump, CAnimBlendHierarchySAInterface * pAnimHierarchy, int flags, float fBlendDelta )
@@ -4003,13 +4003,13 @@ bool CClientGame::ChokingHandler ( unsigned char ucWeaponType )
4003
4003
4004
4004
CAnimBlendAssociationSAInterface * CClientGame::AddAnimationHandler ( RpClump * pClump, AssocGroupId animGroup, AnimationId animID )
4005
4005
{
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 );
4007
4007
return nullptr ;
4008
4008
}
4009
4009
4010
4010
CAnimBlendAssociationSAInterface * CClientGame::AddAnimationAndSyncHandler ( RpClump * pClump, CAnimBlendAssociationSAInterface * pAnimAssocToSyncWith, AssocGroupId animGroup, AnimationId animID )
4011
4011
{
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 );
4013
4013
return nullptr ;
4014
4014
}
4015
4015
@@ -4020,12 +4020,12 @@ typedef void (__thiscall* hCAnimBlendStaticAssociation_Init)
4020
4020
CAnimBlendHierarchySAInterface * pAnimBlendHierarchy
4021
4021
);
4022
4022
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 )
4024
4024
{
4025
4025
printf (" AssocGroupCopyAnimationHandler called!\n " );
4026
-
4027
4026
auto CAnimBlendStaticAssociation_Init = (hCAnimBlendStaticAssociation_Init)0x4CEC20 ;
4028
4027
4028
+ bool isCustomAnimationToPlay = false ;
4029
4029
CAnimManager * pAnimationManager = g_pGame->GetAnimManager ();
4030
4030
auto pOriginalAnimStaticAssoc = pAnimationManager->GetAnimStaticAssociation ( pAnimAssocGroup->groupID , animID );
4031
4031
@@ -4036,6 +4036,7 @@ void CClientGame::AssocGroupCopyAnimationHandler ( CAnimBlendStaticAssociationSA
4036
4036
if ( pReplacedAnimHeirarchyInterface != nullptr )
4037
4037
{ // Play our custom animation instead of default
4038
4038
CAnimBlendStaticAssociation_Init ( pOutAnimStaticAssoc, pClump, pReplacedAnimHeirarchyInterface );
4039
+ isCustomAnimationToPlay = true ;
4039
4040
}
4040
4041
else
4041
4042
{ // Play default internal animation
@@ -4053,6 +4054,9 @@ void CClientGame::AssocGroupCopyAnimationHandler ( CAnimBlendStaticAssociationSA
4053
4054
// Total bones in clump. GTA SA is using 32 bones for peds/players
4054
4055
pOutAnimStaticAssoc->nNumBlendNodes = pOriginalAnimStaticAssoc->nNumBlendNodes ;
4055
4056
pOutAnimStaticAssoc->sFlags = pOriginalAnimStaticAssoc->sFlags ;
4057
+
4058
+ printf (" CClientGame::AssocGroupCopyAnimationHandler: About to return!\n " );
4059
+ return isCustomAnimationToPlay;
4056
4060
}
4057
4061
4058
4062
CAnimBlendHierarchySAInterface * CClientGame::BlendAnimationHierarchyHandler ( RpClump * pClump, CAnimBlendHierarchySAInterface * pAnimHierarchy, int flags, float fBlendDelta )
@@ -6892,7 +6896,7 @@ CClientPed * CClientGame::GetClientPedByClump ( const RpClump & Clump )
6892
6896
return nullptr ;
6893
6897
}
6894
6898
6895
- void CClientGame::onClientIFPUnload ( const CClientIFP & IFP )
6899
+ void CClientGame::OnClientIFPUnload ( const CClientIFP & IFP )
6896
6900
{
6897
6901
// remove IFP animations from replaced animations of peds/players
6898
6902
for ( auto it = m_mapOfPedPointers.begin (); it != m_mapOfPedPointers.end (); it++ )
@@ -6904,3 +6908,44 @@ void CClientGame::onClientIFPUnload ( const CClientIFP & IFP )
6904
6908
}
6905
6909
}
6906
6910
}
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