@@ -9,6 +9,7 @@ CClientIFP::CClientIFP ( class CClientManager* pManager, ElementID ID ) : CClien
99 m_pIFPAnimations = std::make_shared < CIFPAnimations > ();
1010 m_pAnimManager = g_pGame->GetAnimManager ( );
1111 m_bVersion1 = false ;
12+ m_u32Hashkey = 0 ;
1213}
1314
1415CClientIFP::~CClientIFP ( void )
@@ -24,6 +25,7 @@ bool CClientIFP::LoadIFP ( const char* szFilePath, const SString & strBlockName
2425
2526 if ( LoadIFPFile ( szFilePath ) )
2627 {
28+ m_u32Hashkey = g_pGame->GetKeyGen ()->GetUppercaseKey ( strBlockName );
2729 return true ;
2830 }
2931 return false ;
@@ -246,7 +248,6 @@ void CClientIFP::ReadSequenceVersion2 ( Object & ObjectNode )
246248 if ( strCorrectBoneName.size ( ) == 0 )
247249 {
248250 strCorrectBoneName = GetCorrectBoneNameFromName ( BoneName );
249- printf (" yes, size is zero\n " );
250251 }
251252 }
252253
@@ -260,7 +261,7 @@ bool CClientIFP::ReadSequenceKeyFrames ( std::unique_ptr < CAnimBlendSequence >
260261 {
261262 BYTE * pKeyFrames = m_pAnimManager->AllocateKeyFramesMemory ( iCompressedFrameSize * iFrames );
262263 pAnimationSequence->SetKeyFrames ( iFrames, IsKeyFramesTypeRoot ( iFrameType ), m_kbAllKeyFramesCompressed, pKeyFrames );
263- ReadKeyFramesAsCompressed ( iFrameType, pKeyFrames , iFrames );
264+ ReadKeyFramesAsCompressed ( pAnimationSequence, iFrameType , iFrames );
264265 return true ;
265266 }
266267 return false ;
@@ -313,112 +314,97 @@ void CClientIFP::ReadAnimationHeaderVersion2 ( Animation & AnimationNode, bool b
313314 }
314315}
315316
316- void CClientIFP::ReadKeyFramesAsCompressed ( IFP_FrameType iFrameType, BYTE * pKeyFrames , int32_t iFrames )
317+ void CClientIFP::ReadKeyFramesAsCompressed ( std::unique_ptr < CAnimBlendSequence > & pAnimationSequence, IFP_FrameType iFrameType , int32_t iFrames )
317318{
318319 switch ( iFrameType )
319320 {
320321 case IFP_FrameType::KRTS:
321322 {
322- ReadKrtsFramesAsCompressed ( pKeyFrames , iFrames );
323+ ReadKrtsFramesAsCompressed ( pAnimationSequence , iFrames );
323324 break ;
324325 }
325326 case IFP_FrameType::KRT0:
326327 {
327- ReadKrt0FramesAsCompressed ( pKeyFrames , iFrames );
328+ ReadKrt0FramesAsCompressed ( pAnimationSequence , iFrames );
328329 break ;
329330 }
330331 case IFP_FrameType::KR00:
331332 {
332- ReadKr00FramesAsCompressed ( pKeyFrames , iFrames );
333+ ReadKr00FramesAsCompressed ( pAnimationSequence , iFrames );
333334 break ;
334335 }
335336 case IFP_FrameType::KR00_COMPRESSED:
336337 {
337- ReadKr00CompressedFrames ( pKeyFrames , iFrames );
338+ ReadCompressedFrames < IFP_Compressed_KR00 > ( pAnimationSequence , iFrames );
338339 break ;
339340 }
340341 case IFP_FrameType::KRT0_COMPRESSED:
341342 {
342- ReadKrt0CompressedFrames ( pKeyFrames , iFrames );
343+ ReadCompressedFrames < IFP_Compressed_KRT0 > ( pAnimationSequence , iFrames );
343344 break ;
344345 }
345346 }
346347}
347348
348- void CClientIFP::ReadKrtsFramesAsCompressed ( BYTE * pKeyFrames , int32_t TotalFrames )
349+ void CClientIFP::ReadKrtsFramesAsCompressed ( std::unique_ptr < CAnimBlendSequence > & pAnimationSequence , int32_t TotalFrames )
349350{
350- for (int32_t FrameIndex = 0 ; FrameIndex < TotalFrames; FrameIndex++)
351+ for ( int32_t FrameIndex = 0 ; FrameIndex < TotalFrames; FrameIndex++ )
351352 {
352- IFP_Compressed_KRT0 * CompressedKrt0 = (IFP_Compressed_KRT0 *)((BYTE*)pKeyFrames + sizeof (IFP_Compressed_KRT0) * FrameIndex);
353-
353+ IFP_Compressed_KRT0 * CompressedKrt0 = static_cast < IFP_Compressed_KRT0 * > ( pAnimationSequence->GetKeyFrame ( FrameIndex, sizeof ( IFP_Compressed_KRT0 ) ) );
354354 IFP_KRTS Krts;
355- ReadBuffer < IFP_KRTS >( &Krts);
355+ ReadBuffer < IFP_KRTS > ( &Krts );
356356
357- CompressedKrt0->Rotation .X = static_cast < int16_t > ( (( -Krts.Rotation .X ) * 4096 .0f ) );
358- CompressedKrt0->Rotation .Y = static_cast < int16_t > ( (( -Krts.Rotation .Y ) * 4096 .0f ) );
359- CompressedKrt0->Rotation .Z = static_cast < int16_t > ( (( -Krts.Rotation .Z ) * 4096 .0f ) );
360- CompressedKrt0->Rotation .W = static_cast < int16_t > ( (Krts.Rotation .W * 4096 .0f ) );
357+ CompressedKrt0->Rotation .X = static_cast < int16_t > ( ( ( -Krts.Rotation .X ) * 4096 .0f ) );
358+ CompressedKrt0->Rotation .Y = static_cast < int16_t > ( ( ( -Krts.Rotation .Y ) * 4096 .0f ) );
359+ CompressedKrt0->Rotation .Z = static_cast < int16_t > ( ( ( -Krts.Rotation .Z ) * 4096 .0f ) );
360+ CompressedKrt0->Rotation .W = static_cast < int16_t > ( ( Krts.Rotation .W * 4096 .0f ) );
361361
362- CompressedKrt0->Time = static_cast < int16_t > ( (Krts.Time * 60 .0f + 0 .5f ) );
362+ CompressedKrt0->Time = static_cast < int16_t > ( ( Krts.Time * 60 .0f + 0 .5f ) );
363363
364- CompressedKrt0->Translation .X = static_cast < int16_t > ( (Krts.Translation .X * 1024 .0f ) );
365- CompressedKrt0->Translation .Y = static_cast < int16_t > ( (Krts.Translation .Y * 1024 .0f ) );
366- CompressedKrt0->Translation .Z = static_cast < int16_t > ( (Krts.Translation .Z * 1024 .0f ) );
364+ CompressedKrt0->Translation .X = static_cast < int16_t > ( ( Krts.Translation .X * 1024 .0f ) );
365+ CompressedKrt0->Translation .Y = static_cast < int16_t > ( ( Krts.Translation .Y * 1024 .0f ) );
366+ CompressedKrt0->Translation .Z = static_cast < int16_t > ( ( Krts.Translation .Z * 1024 .0f ) );
367367 }
368368}
369369
370- void CClientIFP::ReadKrt0FramesAsCompressed ( BYTE * pKeyFrames , int32_t TotalFrames )
370+ void CClientIFP::ReadKrt0FramesAsCompressed ( std::unique_ptr < CAnimBlendSequence > & pAnimationSequence , int32_t TotalFrames )
371371{
372- for (int32_t FrameIndex = 0 ; FrameIndex < TotalFrames; FrameIndex++)
372+ for ( int32_t FrameIndex = 0 ; FrameIndex < TotalFrames; FrameIndex++ )
373373 {
374- IFP_Compressed_KRT0 * CompressedKrt0 = (IFP_Compressed_KRT0 *)((BYTE*)pKeyFrames + sizeof (IFP_Compressed_KRT0) * FrameIndex);
375-
374+ IFP_Compressed_KRT0 * CompressedKrt0 = static_cast < IFP_Compressed_KRT0 * > ( pAnimationSequence->GetKeyFrame ( FrameIndex, sizeof ( IFP_Compressed_KRT0 ) ) );
376375 IFP_KRT0 Krt0;
377376 ReadBuffer < IFP_KRT0 > ( &Krt0 );
378377
379- CompressedKrt0->Rotation .X = static_cast < int16_t > ( (( -Krt0.Rotation .X ) * 4096 .0f ) );
380- CompressedKrt0->Rotation .Y = static_cast < int16_t > ( (( -Krt0.Rotation .Y ) * 4096 .0f ) );
381- CompressedKrt0->Rotation .Z = static_cast < int16_t > ( (( -Krt0.Rotation .Z ) * 4096 .0f ) );
382- CompressedKrt0->Rotation .W = static_cast < int16_t > ( (Krt0.Rotation .W * 4096 .0f ) );
378+ CompressedKrt0->Rotation .X = static_cast < int16_t > ( ( ( -Krt0.Rotation .X ) * 4096 .0f ) );
379+ CompressedKrt0->Rotation .Y = static_cast < int16_t > ( ( ( -Krt0.Rotation .Y ) * 4096 .0f ) );
380+ CompressedKrt0->Rotation .Z = static_cast < int16_t > ( ( ( -Krt0.Rotation .Z ) * 4096 .0f ) );
381+ CompressedKrt0->Rotation .W = static_cast < int16_t > ( ( Krt0.Rotation .W * 4096 .0f ) );
383382
384- CompressedKrt0->Time = static_cast < int16_t > ( (Krt0.Time * 60 .0f + 0 .5f ) );
383+ CompressedKrt0->Time = static_cast < int16_t > ( ( Krt0.Time * 60 .0f + 0 .5f ) );
385384
386- CompressedKrt0->Translation .X = static_cast < int16_t > ( (Krt0.Translation .X * 1024 .0f ) );
387- CompressedKrt0->Translation .Y = static_cast < int16_t > ( (Krt0.Translation .Y * 1024 .0f ) );
388- CompressedKrt0->Translation .Z = static_cast < int16_t > ( (Krt0.Translation .Z * 1024 .0f ) );
385+ CompressedKrt0->Translation .X = static_cast < int16_t > ( ( Krt0.Translation .X * 1024 .0f ) );
386+ CompressedKrt0->Translation .Y = static_cast < int16_t > ( ( Krt0.Translation .Y * 1024 .0f ) );
387+ CompressedKrt0->Translation .Z = static_cast < int16_t > ( ( Krt0.Translation .Z * 1024 .0f ) );
389388 }
390389}
391390
392- void CClientIFP::ReadKr00FramesAsCompressed ( BYTE * pKeyFrames , int32_t TotalFrames )
391+ void CClientIFP::ReadKr00FramesAsCompressed ( std::unique_ptr < CAnimBlendSequence > & pAnimationSequence , int32_t TotalFrames )
393392{
394- for (int32_t FrameIndex = 0 ; FrameIndex < TotalFrames; FrameIndex++)
393+ for ( int32_t FrameIndex = 0 ; FrameIndex < TotalFrames; FrameIndex++ )
395394 {
396- IFP_Compressed_KR00 * CompressedKr00 = (IFP_Compressed_KR00 *)((BYTE*)pKeyFrames + sizeof (IFP_Compressed_KR00) * FrameIndex);
397-
395+ IFP_Compressed_KR00 * CompressedKr00 = static_cast < IFP_Compressed_KR00 * > ( pAnimationSequence->GetKeyFrame ( FrameIndex, sizeof ( IFP_Compressed_KR00 ) ) );
398396 IFP_KR00 Kr00;
399397 ReadBuffer < IFP_KR00 > ( &Kr00 );
400398
401- CompressedKr00->Rotation .X = static_cast < int16_t > ( (( -Kr00.Rotation .X ) * 4096 .0f ) );
402- CompressedKr00->Rotation .Y = static_cast < int16_t > ( (( -Kr00.Rotation .Y ) * 4096 .0f ) );
403- CompressedKr00->Rotation .Z = static_cast < int16_t > ( (( -Kr00.Rotation .Z ) * 4096 .0f ) );
404- CompressedKr00->Rotation .W = static_cast < int16_t > ( (Kr00.Rotation .W * 4096 .0f ) );
399+ CompressedKr00->Rotation .X = static_cast < int16_t > ( ( ( -Kr00.Rotation .X ) * 4096 .0f ) );
400+ CompressedKr00->Rotation .Y = static_cast < int16_t > ( ( ( -Kr00.Rotation .Y ) * 4096 .0f ) );
401+ CompressedKr00->Rotation .Z = static_cast < int16_t > ( ( ( -Kr00.Rotation .Z ) * 4096 .0f ) );
402+ CompressedKr00->Rotation .W = static_cast < int16_t > ( ( Kr00.Rotation .W * 4096 .0f ) );
405403
406404 CompressedKr00->Time = static_cast < int16_t > ( (Kr00.Time * 60 .0f + 0 .5f ) );
407405 }
408406}
409407
410- inline void CClientIFP::ReadKr00CompressedFrames ( BYTE * pKeyFrames, int32_t TotalFrames )
411- {
412- size_t iSizeInBytes = sizeof ( IFP_Compressed_KR00 ) * TotalFrames;
413- ReadBytes ( pKeyFrames, iSizeInBytes );
414- }
415-
416- inline void CClientIFP::ReadKrt0CompressedFrames ( BYTE * pKeyFrames, int32_t TotalFrames )
417- {
418- size_t iSizeInBytes = sizeof ( IFP_Compressed_KRT0 ) * TotalFrames;
419- ReadBytes ( pKeyFrames, iSizeInBytes );
420- }
421-
422408size_t CClientIFP::GetSizeOfCompressedFrame ( IFP_FrameType iFrameType )
423409{
424410 switch ( iFrameType )
0 commit comments