Skip to content

Commit 65fdfe7

Browse files
committed
s_iAnimationSearchReferences is checked before unloading IFP anims
1 parent 44121e8 commit 65fdfe7

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

Client/mods/deathmatch/logic/CClientIFP.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ h_CAnimBlendHierarchy_CalcTotalTime OLD__CAnimBlendHierarchy_CalcTotalTi
1616
extern DWORD BoneIds[];
1717
extern char BoneNames[][24];
1818

19+
DWORD CClientIFP::s_iAnimationSearchReferences = 0;
20+
1921
CClientIFP::CClientIFP ( class CClientManager* pManager, ElementID ID ) : CClientEntity ( ID )
2022
{
2123
// Init
@@ -68,7 +70,7 @@ void CClientIFP::UnloadIFP ( void )
6870
m_pIFPAnimations->bUnloadOnZeroReferences = true;
6971

7072
// unload IFP animations, if reference count is zero
71-
if ( m_pIFPAnimations->iReferences == 0 )
73+
if ( ( m_pIFPAnimations->iReferences == 0 ) && ( s_iAnimationSearchReferences == 0 ) )
7274
{
7375
g_pClientGame->UnloadIFPAnimations ( m_pIFPAnimations );
7476

@@ -1161,17 +1163,20 @@ std::string CClientIFP::getCorrectBoneNameFromName(std::string const& BoneName)
11611163

11621164
CAnimBlendHierarchySAInterface * CClientIFP::GetAnimationHierarchy ( const SString & strAnimationName )
11631165
{
1166+
CAnimBlendHierarchySAInterface * pAnimHierarchyInterface = nullptr;
11641167
if ( m_bisIFPLoaded )
11651168
{
1169+
s_iAnimationSearchReferences ++;
11661170
for (auto it = m_pVecAnimations->begin(); it != m_pVecAnimations->end(); ++it)
11671171
{
11681172
if (strAnimationName.ToLower() == it->Name.ToLower())
11691173
{
1170-
return (CAnimBlendHierarchySAInterface *)&it->Hierarchy;
1174+
pAnimHierarchyInterface = (CAnimBlendHierarchySAInterface *)&it->Hierarchy;
11711175
}
11721176
}
1177+
s_iAnimationSearchReferences --;
11731178
}
1174-
return nullptr;
1179+
return pAnimHierarchyInterface;
11751180
}
11761181

11771182
// ----------------------------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)