Skip to content

Commit 9af78ea

Browse files
committed
[FIX] Memory was not being freed properly for IFP Version 2, fixed it by adding a check. Also the loop for sequences in unloadIFP was incorrect, fixed that as well. Tested by checking the pointers and frees the memory properly now
1 parent d64f8b3 commit 9af78ea

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

Client/mods/deathmatch/logic/CClientIFP.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,20 @@ void CClientIFP::UnloadIFP ( void )
4545
for ( size_t i = 0; i < m_Animations.size(); i++ )
4646
{
4747
IFP_Animation * ifpAnimation = &m_Animations[i];
48-
for (unsigned short SequenceIndex = 0; i < ifpAnimation->Hierarchy.m_nSeqCount; i++)
48+
if ( isVersion1 )
49+
{
50+
for (unsigned short SequenceIndex = 0; SequenceIndex < ifpAnimation->Hierarchy.m_nSeqCount; SequenceIndex++)
51+
{
52+
53+
_CAnimBlendSequence * pSequence = (_CAnimBlendSequence*)((BYTE*)ifpAnimation->Hierarchy.m_pSequences + (sizeof(_CAnimBlendSequence) * SequenceIndex));
54+
free ( pSequence->m_pFrames );
55+
}
56+
}
57+
else
4958
{
50-
_CAnimBlendSequence * pSequence = (_CAnimBlendSequence*)((BYTE*)(ifpAnimation->Hierarchy.m_pSequences) + (sizeof(_CAnimBlendSequence) * SequenceIndex));
51-
free ( pSequence->m_pFrames );
59+
free ( ifpAnimation->pFramesMemoryVersion2 );
5260
}
61+
5362
delete ifpAnimation->pSequencesMemory;
5463
}
5564

@@ -135,6 +144,8 @@ void CClientIFP::ReadIFPVersion2( bool anp3)
135144
pAnimHierarchy->m_bRunningCompressed = AnimationNode.isCompressed & 1;
136145

137146
pKeyFrames = (unsigned char*)malloc(AnimationNode.FrameSize);
147+
148+
ifpAnimation.pFramesMemoryVersion2 = pKeyFrames;
138149
}
139150

140151
OLD__CAnimBlendHierarchy_SetName(pAnimHierarchy, AnimationNode.Name);

Client/mods/deathmatch/logic/IFP/IFPLoader.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ struct IFP_Animation
137137
_CAnimBlendHierarchy Hierarchy;
138138
//std::vector <_CAnimBlendSequence> Sequences;
139139
char * pSequencesMemory;
140+
unsigned char* pFramesMemoryVersion2; // only for IFP version 2;
140141
};
141142

142143
struct Animation

0 commit comments

Comments
 (0)