@@ -13,29 +13,22 @@ CClientIFP::CClientIFP(class CClientManager* pManager, ElementID ID) : CClientEn
1313 m_u32Hashkey = 0 ;
1414}
1515
16- CClientIFP::~CClientIFP (void )
17- {
18- // g_pCore->GetConsole ()->Printf( "CClientIFP::~CClientIFP called! BlockName: %s", m_strBlockName.c_str ( ) );
19- }
20-
21- bool CClientIFP::LoadIFP (const char * szFilePath, const SString& strBlockName)
16+ bool CClientIFP::LoadIFP (const SString& strFilePath, const SString& strBlockName)
2217{
2318 m_strBlockName = strBlockName;
2419 m_pVecAnimations = &m_pIFPAnimations->vecAnimations ;
2520
26- if (LoadIFPFile (szFilePath ))
21+ if (LoadIFPFile (strFilePath ))
2722 {
2823 m_u32Hashkey = HashString (strBlockName.ToLower ());
2924 return true ;
3025 }
3126 return false ;
3227}
3328
34- bool CClientIFP::LoadIFPFile (const char * szFilePath )
29+ bool CClientIFP::LoadIFPFile (const SString& strFilePath )
3530{
36- CreateLoader (szFilePath);
37-
38- if (LoadFile ())
31+ if (LoadFileToMemory (strFilePath))
3932 {
4033 char Version[4 ];
4134 ReadBytes (Version, sizeof (Version));
@@ -53,9 +46,9 @@ bool CClientIFP::LoadIFPFile(const char* szFilePath)
5346 ReadIFPVersion1 ();
5447 }
5548
56- // We are unloading the data because we don't need to read it anymore.
49+ // We are freeing the file reader memory because we don't need to read it anymore.
5750 // This function does not unload IFP, to unload ifp, use destroyElement from Lua
58- UnloadFile ();
51+ FreeFileReaderMemory ();
5952 }
6053 else
6154 {
@@ -279,7 +272,7 @@ void CClientIFP::ReadAnimationNameVersion1(SAnimation& IfpAnimation)
279272 RoundSize (Name.Base .Size );
280273
281274 char szAnimationName[24 ];
282- ReadCString (szAnimationName, Name.Base .Size );
275+ ReadStringNullTerminated (szAnimationName, Name.Base .Size );
283276 IfpAnimation.Name = szAnimationName;
284277 IfpAnimation.u32NameHash = HashString (IfpAnimation.Name .ToLower ());
285278}
@@ -301,7 +294,7 @@ CClientIFP::eFrameType CClientIFP::ReadKfrm(void)
301294
302295void CClientIFP::ReadAnimationHeaderVersion2 (SAnimationHeaderV2& AnimationNode, bool bAnp3)
303296{
304- ReadCString ((char *)&AnimationNode.Name , sizeof (SAnimationHeaderV2::Name));
297+ ReadStringNullTerminated ((char *)&AnimationNode.Name , sizeof (SAnimationHeaderV2::Name));
305298 ReadBuffer<int32_t >(&AnimationNode.TotalObjects );
306299 if (bAnp3)
307300 {
@@ -354,9 +347,7 @@ void CClientIFP::ReadKrtsFramesAsCompressed(std::unique_ptr<CAnimBlendSequence>&
354347 CompressedKrt0->Rotation .Y = static_cast <int16_t >(((-Krts.Rotation .Y ) * 4096 .0f ));
355348 CompressedKrt0->Rotation .Z = static_cast <int16_t >(((-Krts.Rotation .Z ) * 4096 .0f ));
356349 CompressedKrt0->Rotation .W = static_cast <int16_t >((Krts.Rotation .W * 4096 .0f ));
357-
358350 CompressedKrt0->Time = static_cast <int16_t >((Krts.Time * 60 .0f + 0 .5f ));
359-
360351 CompressedKrt0->Translation .X = static_cast <int16_t >((Krts.Translation .X * 1024 .0f ));
361352 CompressedKrt0->Translation .Y = static_cast <int16_t >((Krts.Translation .Y * 1024 .0f ));
362353 CompressedKrt0->Translation .Z = static_cast <int16_t >((Krts.Translation .Z * 1024 .0f ));
@@ -375,9 +366,7 @@ void CClientIFP::ReadKrt0FramesAsCompressed(std::unique_ptr<CAnimBlendSequence>&
375366 CompressedKrt0->Rotation .Y = static_cast <int16_t >(((-Krt0.Rotation .Y ) * 4096 .0f ));
376367 CompressedKrt0->Rotation .Z = static_cast <int16_t >(((-Krt0.Rotation .Z ) * 4096 .0f ));
377368 CompressedKrt0->Rotation .W = static_cast <int16_t >((Krt0.Rotation .W * 4096 .0f ));
378-
379369 CompressedKrt0->Time = static_cast <int16_t >((Krt0.Time * 60 .0f + 0 .5f ));
380-
381370 CompressedKrt0->Translation .X = static_cast <int16_t >((Krt0.Translation .X * 1024 .0f ));
382371 CompressedKrt0->Translation .Y = static_cast <int16_t >((Krt0.Translation .Y * 1024 .0f ));
383372 CompressedKrt0->Translation .Z = static_cast <int16_t >((Krt0.Translation .Z * 1024 .0f ));
@@ -396,7 +385,6 @@ void CClientIFP::ReadKr00FramesAsCompressed(std::unique_ptr<CAnimBlendSequence>&
396385 CompressedKr00->Rotation .Y = static_cast <int16_t >(((-Kr00.Rotation .Y ) * 4096 .0f ));
397386 CompressedKr00->Rotation .Z = static_cast <int16_t >(((-Kr00.Rotation .Z ) * 4096 .0f ));
398387 CompressedKr00->Rotation .W = static_cast <int16_t >((Kr00.Rotation .W * 4096 .0f ));
399-
400388 CompressedKr00->Time = static_cast <int16_t >((Kr00.Time * 60 .0f + 0 .5f ));
401389 }
402390}
0 commit comments