1
1
#include < StdInc.h>
2
2
#include " ../game_sa/CAnimBlendSequenceSA.h"
3
3
4
- hCMemoryMgr_Malloc OLD_CMemoryMgr_Malloc = (hCMemoryMgr_Malloc)0x0072F420 ;
5
- hCMemoryMgr_Free OLD_CMemoryMgr_Free = (hCMemoryMgr_Free)0x0072F430 ;
6
-
7
- extern DWORD BoneIds[];
8
- extern char BoneNames[][24 ];
9
-
10
4
CClientIFP::CClientIFP ( class CClientManager * pManager, ElementID ID ) : CClientEntity ( ID )
11
5
{
12
6
// Init
@@ -21,7 +15,7 @@ CClientIFP::~CClientIFP ( void )
21
15
{
22
16
}
23
17
24
- bool CClientIFP::LoadIFP ( const char * szFilePath, SString strBlockName )
18
+ bool CClientIFP::LoadIFP ( const char * szFilePath, const SString & strBlockName )
25
19
{
26
20
printf (" \n CClientIFP::LoadIFP: szFilePath %s\n szBlockName: %s\n\n " , szFilePath, strBlockName.c_str ());
27
21
@@ -37,14 +31,14 @@ bool CClientIFP::LoadIFP ( const char* szFilePath, SString strBlockName )
37
31
38
32
bool CClientIFP::LoadIFPFile ( const char * szFilePath )
39
33
{
40
- createLoader ( szFilePath );
34
+ CreateLoader ( szFilePath );
41
35
42
- if ( loadFile ( ) )
36
+ if ( LoadFile ( ) )
43
37
{
44
38
printf (" IfpLoader: File loaded. Parsing it now.\n " );
45
39
46
40
char Version [ 4 ];
47
- readBytes ( Version, sizeof ( Version ) );
41
+ ReadBytes ( Version, sizeof ( Version ) );
48
42
49
43
bool bAnp3 = strncmp ( Version, " ANP3" , sizeof ( Version ) ) == 0 ;
50
44
bool bAnp2 = strncmp ( Version, " ANP2" , sizeof ( Version ) ) == 0 ;
@@ -61,7 +55,7 @@ bool CClientIFP::LoadIFPFile ( const char * szFilePath )
61
55
62
56
// We are unloading the data because we don't need to read it anymore.
63
57
// This function does not unload IFP, to unload ifp call unloadIFP function
64
- unloadFile ( );
58
+ UnloadFile ( );
65
59
}
66
60
else
67
61
{
@@ -80,11 +74,9 @@ void CClientIFP::ReadIFPVersion1 ( )
80
74
ReadHeaderVersion1 ( Info );
81
75
82
76
m_pVecAnimations->resize ( Info.Entries );
83
-
84
77
for ( auto it = m_pVecAnimations->begin (); it != m_pVecAnimations->end (); ++it )
85
78
{
86
79
ReadAnimationNameVersion1 ( it->Name );
87
-
88
80
printf (" Animation Name: %s \n " , it->Name .c_str ( ) );
89
81
90
82
IFP_DGAN Dgan;
@@ -104,7 +96,7 @@ void CClientIFP::ReadIFPVersion1 ( )
104
96
void CClientIFP::ReadIFPVersion2 ( bool bAnp3 )
105
97
{
106
98
IFPHeaderV2 Header;
107
- readBuffer < IFPHeaderV2 > ( &Header );
99
+ ReadBuffer < IFPHeaderV2 > ( &Header );
108
100
109
101
m_pVecAnimations->resize ( Header.TotalAnimations );
110
102
for ( auto it = m_pVecAnimations->begin (); it != m_pVecAnimations->end (); ++it )
@@ -218,11 +210,11 @@ WORD CClientIFP::ReadSequencesVersion2 ( std::unique_ptr < CAnimBlendHierarchy >
218
210
int32_t CClientIFP::ReadSequenceVersion1 ( IFP_ANIM & Anim )
219
211
{
220
212
IFP_CPAN Cpan;
221
- readBuffer < IFP_CPAN > ( &Cpan );
213
+ ReadBuffer < IFP_CPAN > ( &Cpan );
222
214
RoundSize ( Cpan.Base .Size );
223
- readBytes ( &Anim, sizeof ( IFP_BASE ) );
215
+ ReadBytes ( &Anim, sizeof ( IFP_BASE ) );
224
216
RoundSize ( Anim.Base .Size );
225
- readBytes ( &Anim.Name , Anim.Base .Size );
217
+ ReadBytes ( &Anim.Name , Anim.Base .Size );
226
218
227
219
int32_t iBoneID = -1 ;
228
220
if ( Anim.Base .Size == 0x2C )
@@ -240,7 +232,7 @@ int32_t CClientIFP::ReadSequenceVersion1 ( IFP_ANIM & Anim )
240
232
241
233
void CClientIFP::ReadSequenceVersion2 ( Object & ObjectNode )
242
234
{
243
- readBuffer < Object > ( &ObjectNode );
235
+ ReadBuffer < Object > ( &ObjectNode );
244
236
std::string BoneName = ConvertStringToMapKey ( ObjectNode.Name );
245
237
std::string strCorrectBoneName;
246
238
if (ObjectNode.BoneID == -1 )
@@ -266,7 +258,7 @@ bool CClientIFP::ReadSequenceKeyFrames ( std::unique_ptr < CAnimBlendSequence >
266
258
size_t iCompressedFrameSize = GetSizeOfCompressedFrame ( iFrameType );
267
259
if ( iCompressedFrameSize )
268
260
{
269
- BYTE * pKeyFrames = static_cast < BYTE * > ( OLD_CMemoryMgr_Malloc ( iCompressedFrameSize * iFrames ) );
261
+ BYTE * pKeyFrames = m_pAnimManager-> AllocateKeyFramesMemory ( iCompressedFrameSize * iFrames );
270
262
pAnimationSequence->SetKeyFrames ( iFrames, IsKeyFramesTypeRoot ( iFrameType ), m_kbAllKeyFramesCompressed, pKeyFrames );
271
263
ReadKeyFramesAsCompressed ( iFrameType, pKeyFrames, iFrames );
272
264
return true ;
@@ -277,47 +269,47 @@ bool CClientIFP::ReadSequenceKeyFrames ( std::unique_ptr < CAnimBlendSequence >
277
269
void CClientIFP::ReadHeaderVersion1 ( IFP_INFO & Info )
278
270
{
279
271
uint32_t OffsetEOF;
280
- readBuffer < uint32_t > ( &OffsetEOF );
272
+ ReadBuffer < uint32_t > ( &OffsetEOF );
281
273
RoundSize ( OffsetEOF );
282
- readBytes ( &Info, sizeof ( IFP_BASE ) );
274
+ ReadBytes ( &Info, sizeof ( IFP_BASE ) );
283
275
RoundSize ( Info.Base .Size );
284
- readBytes ( &Info.Entries , Info.Base .Size );
276
+ ReadBytes ( &Info.Entries , Info.Base .Size );
285
277
}
286
278
287
279
void CClientIFP::ReadAnimationNameVersion1 ( SString & strAnimationName )
288
280
{
289
281
IFP_NAME Name;
290
- readBuffer < IFP_NAME > ( &Name );
282
+ ReadBuffer < IFP_NAME > ( &Name );
291
283
RoundSize ( Name.Base .Size );
292
284
293
285
char szAnimationName [ 24 ];
294
- readCString ( szAnimationName, Name.Base .Size );
286
+ ReadCString ( szAnimationName, Name.Base .Size );
295
287
strAnimationName = szAnimationName;
296
288
}
297
289
298
290
void CClientIFP::ReadDgan ( IFP_DGAN & Dgan )
299
291
{
300
- readBytes ( &Dgan, sizeof ( IFP_BASE ) * 2 );
292
+ ReadBytes ( &Dgan, sizeof ( IFP_BASE ) * 2 );
301
293
RoundSize ( Dgan.Base .Size );
302
294
RoundSize ( Dgan.Info .Base .Size );
303
- readBytes ( &Dgan.Info .Entries , Dgan.Info .Base .Size );
295
+ ReadBytes ( &Dgan.Info .Entries , Dgan.Info .Base .Size );
304
296
}
305
297
306
298
CClientIFP::IFP_FrameType CClientIFP::ReadKfrm ( void )
307
299
{
308
300
IFP_KFRM Kfrm;
309
- readBuffer < IFP_KFRM > ( &Kfrm );
301
+ ReadBuffer < IFP_KFRM > ( &Kfrm );
310
302
return GetFrameTypeFromFourCC ( Kfrm.Base .FourCC );
311
303
}
312
304
313
305
void CClientIFP::ReadAnimationHeaderVersion2 ( Animation & AnimationNode, bool bAnp3 )
314
306
{
315
- readCString ( ( char * ) &AnimationNode.Name , sizeof ( Animation::Name ) );
316
- readBuffer < int32_t > ( &AnimationNode.TotalObjects );
307
+ ReadCString ( ( char * ) &AnimationNode.Name , sizeof ( Animation::Name ) );
308
+ ReadBuffer < int32_t > ( &AnimationNode.TotalObjects );
317
309
if ( bAnp3 )
318
310
{
319
- readBuffer < int32_t > ( &AnimationNode.FrameSize );
320
- readBuffer < int32_t > ( &AnimationNode.isCompressed );
311
+ ReadBuffer < int32_t > ( &AnimationNode.FrameSize );
312
+ ReadBuffer < int32_t > ( &AnimationNode.isCompressed );
321
313
}
322
314
}
323
315
@@ -360,7 +352,7 @@ void CClientIFP::ReadKrtsFramesAsCompressed ( BYTE * pKeyFrames, int32_t TotalF
360
352
IFP_Compressed_KRT0 * CompressedKrt0 = (IFP_Compressed_KRT0 *)((BYTE*)pKeyFrames + sizeof (IFP_Compressed_KRT0) * FrameIndex);
361
353
362
354
IFP_KRTS Krts;
363
- readBuffer < IFP_KRTS >(&Krts);
355
+ ReadBuffer < IFP_KRTS >(&Krts);
364
356
365
357
CompressedKrt0->Rotation .X = static_cast < int16_t > ( ((-Krts.Rotation .X ) * 4096 .0f ) );
366
358
CompressedKrt0->Rotation .Y = static_cast < int16_t > ( ((-Krts.Rotation .Y ) * 4096 .0f ) );
@@ -382,7 +374,7 @@ void CClientIFP::ReadKrt0FramesAsCompressed ( BYTE * pKeyFrames, int32_t TotalF
382
374
IFP_Compressed_KRT0 * CompressedKrt0 = (IFP_Compressed_KRT0 *)((BYTE*)pKeyFrames + sizeof (IFP_Compressed_KRT0) * FrameIndex);
383
375
384
376
IFP_KRT0 Krt0;
385
- readBuffer < IFP_KRT0 > ( &Krt0 );
377
+ ReadBuffer < IFP_KRT0 > ( &Krt0 );
386
378
387
379
CompressedKrt0->Rotation .X = static_cast < int16_t > ( ((-Krt0.Rotation .X ) * 4096 .0f ) );
388
380
CompressedKrt0->Rotation .Y = static_cast < int16_t > ( ((-Krt0.Rotation .Y ) * 4096 .0f ) );
@@ -404,7 +396,7 @@ void CClientIFP::ReadKr00FramesAsCompressed ( BYTE * pKeyFrames, int32_t TotalF
404
396
IFP_Compressed_KR00 * CompressedKr00 = (IFP_Compressed_KR00 *)((BYTE*)pKeyFrames + sizeof (IFP_Compressed_KR00) * FrameIndex);
405
397
406
398
IFP_KR00 Kr00;
407
- readBuffer < IFP_KR00 > ( &Kr00 );
399
+ ReadBuffer < IFP_KR00 > ( &Kr00 );
408
400
409
401
CompressedKr00->Rotation .X = static_cast < int16_t > ( ((-Kr00.Rotation .X ) * 4096 .0f ) );
410
402
CompressedKr00->Rotation .Y = static_cast < int16_t > ( ((-Kr00.Rotation .Y ) * 4096 .0f ) );
@@ -418,13 +410,13 @@ void CClientIFP::ReadKr00FramesAsCompressed ( BYTE * pKeyFrames, int32_t TotalF
418
410
void CClientIFP::ReadKr00CompressedFrames ( BYTE * pKeyFrames, int32_t TotalFrames )
419
411
{
420
412
size_t iSizeInBytes = sizeof ( IFP_Compressed_KR00 ) * TotalFrames;
421
- readBytes ( pKeyFrames, iSizeInBytes );
413
+ ReadBytes ( pKeyFrames, iSizeInBytes );
422
414
}
423
415
424
416
void CClientIFP::ReadKrt0CompressedFrames ( BYTE * pKeyFrames, int32_t TotalFrames )
425
417
{
426
418
size_t iSizeInBytes = sizeof ( IFP_Compressed_KRT0 ) * TotalFrames;
427
- readBytes ( pKeyFrames, iSizeInBytes );
419
+ ReadBytes ( pKeyFrames, iSizeInBytes );
428
420
}
429
421
430
422
size_t CClientIFP::GetSizeOfCompressedFrame ( IFP_FrameType iFrameType )
@@ -484,8 +476,8 @@ void CClientIFP::CopySequencesWithDummies ( std::unique_ptr < CAnimBlendHierarch
484
476
{
485
477
for (size_t SequenceIndex = 0 ; SequenceIndex < m_kcIFPSequences; SequenceIndex++)
486
478
{
487
- std::string BoneName = BoneNames [SequenceIndex];
488
- DWORD BoneID = BoneIds [SequenceIndex];
479
+ std::string BoneName = m_karrstrBoneNames [SequenceIndex];
480
+ DWORD BoneID = m_karruBoneIds [SequenceIndex];
489
481
490
482
CAnimBlendSequenceSAInterface * pAnimationSequenceInterface = pAnimationHierarchy->GetSequence ( SequenceIndex );
491
483
auto it = mapOfSequences.find ( BoneID );
@@ -507,17 +499,17 @@ BYTE * CClientIFP::AllocateSequencesMemory ( std::unique_ptr < CAnimBlendHierarc
507
499
return static_cast < BYTE * > ( operator new ( 12 * cMaxSequences + 4 ) );
508
500
}
509
501
510
- CClientIFP::IFP_FrameType CClientIFP::GetFrameTypeFromFourCC ( char * FourCC )
502
+ CClientIFP::IFP_FrameType CClientIFP::GetFrameTypeFromFourCC ( const char * szFourCC )
511
503
{
512
- if (strncmp (FourCC , " KRTS" , 4 ) == 0 )
504
+ if ( strncmp ( szFourCC , " KRTS" , 4 ) == 0 )
513
505
{
514
506
return IFP_FrameType::KRTS;
515
507
}
516
- else if (strncmp (FourCC , " KRT0" , 4 ) == 0 )
508
+ else if ( strncmp ( szFourCC , " KRT0" , 4 ) == 0 )
517
509
{
518
510
return IFP_FrameType::KRT0;
519
511
}
520
- else if (strncmp (FourCC , " KR00" , 4 ) == 0 )
512
+ else if ( strncmp ( szFourCC , " KR00" , 4 ) == 0 )
521
513
{
522
514
return IFP_FrameType::KR00;
523
515
}
@@ -549,7 +541,7 @@ void CClientIFP::InsertAnimationDummySequence ( std::unique_ptr < CAnimBlendSequ
549
541
}
550
542
551
543
const size_t FramesDataSizeInBytes = FrameSize * cKeyFrames;
552
- BYTE * pKeyFrames = static_cast < BYTE * > ( OLD_CMemoryMgr_Malloc ( FramesDataSizeInBytes ) );
544
+ BYTE * pKeyFrames = m_pAnimManager-> AllocateKeyFramesMemory ( FramesDataSizeInBytes );
553
545
pAnimationSequence->SetKeyFrames ( cKeyFrames, bHasTranslationValues, bKeyFrameCompressed, pKeyFrames );
554
546
CopyDummyKeyFrameByBoneID ( pKeyFrames, dwBoneID );
555
547
}
@@ -769,7 +761,7 @@ std::string CClientIFP::ConvertStringToMapKey ( const char * szString )
769
761
770
762
constexpr void CClientIFP::RoundSize ( uint32_t & u32Size )
771
763
{
772
- if ( u32Size & 3 )
764
+ if ( u32Size & 3 )
773
765
{
774
766
u32Size += 4 - ( u32Size & 3 );
775
767
}
0 commit comments