Skip to content

Commit e122684

Browse files
authored
Merge pull request #7 from saml1er/custom_ifp_animations
Custom ifp animations ( Everything is complete )
2 parents 1dfadb5 + dae8c85 commit e122684

35 files changed

+704
-626
lines changed

Client/game_sa/CAnimBlendSequenceSA.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,8 @@ void CAnimBlendSequenceSA::SetKeyFrames ( size_t cKeyFrames, bool bRoot, bool bC
5858
call dwFunc
5959
}
6060
}
61+
62+
void * CAnimBlendSequenceSA::GetKeyFrame ( size_t iFrame, uint32_t u32FrameSizeInBytes )
63+
{
64+
return ( m_pInterface->pKeyFrames + u32FrameSizeInBytes * iFrame );
65+
}

Client/game_sa/CAnimBlendSequenceSA.h

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,24 @@ class CAnimBlendSequenceSAInterface
2929
};
3030
unsigned short sFlags;
3131
unsigned short sNumKeyFrames;
32-
void * pKeyFrames;
32+
BYTE * pKeyFrames;
3333
};
3434

3535
class CAnimBlendSequenceSA : public CAnimBlendSequence
3636
{
3737
public:
38-
CAnimBlendSequenceSA ( CAnimBlendSequenceSAInterface * pInterface ) { m_pInterface = pInterface; }
39-
void Initialize ( void );
40-
void SetName ( const char * szName );
41-
void SetBoneTag ( int32_t i32BoneID );
42-
void SetKeyFrames ( size_t cKeyFrames, bool bRoot, bool bCompressed, void * pKeyFrames );
43-
uint32_t GetHash ( void ) { return m_pInterface->m_hash; }
44-
uint16_t GetBoneTag ( void ) { return m_pInterface->m_boneId; }
45-
void * GetKeyFrames ( void ) { return m_pInterface->pKeyFrames; }
46-
unsigned short GetKeyFramesCount ( void ) { return m_pInterface->sNumKeyFrames; }
47-
CAnimBlendSequenceSAInterface * GetInterface ( void ) { return m_pInterface; }
38+
CAnimBlendSequenceSA ( CAnimBlendSequenceSAInterface * pInterface ) { m_pInterface = pInterface; }
39+
void Initialize ( void );
40+
void SetName ( const char * szName );
41+
void SetBoneTag ( int32_t i32BoneID );
42+
void SetKeyFrames ( size_t cKeyFrames, bool bRoot, bool bCompressed, void * pKeyFrames );
43+
void * GetKeyFrame ( size_t iFrame, uint32_t u32FrameSizeInBytes );
44+
uint32_t GetHash ( void ) { return m_pInterface->m_hash; }
45+
uint16_t GetBoneTag ( void ) { return m_pInterface->m_boneId; }
46+
BYTE * GetKeyFrames ( void ) { return m_pInterface->pKeyFrames; }
47+
unsigned short GetKeyFramesCount ( void ) { return m_pInterface->sNumKeyFrames; }
48+
bool IsBigChunkForAllSequences ( void ) { return ( ( m_pInterface->sFlags >> 3) & 1 ); }
49+
CAnimBlendSequenceSAInterface * GetInterface ( void ) { return m_pInterface; }
4850

4951
protected:
5052
CAnimBlendSequenceSAInterface * m_pInterface;

Client/game_sa/CAnimBlendStaticAssociationSA.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,15 @@
1212

1313
#include "StdInc.h"
1414

15-
CAnimBlendHierarchy * CAnimBlendStaticAssociationSA::GetAnimHierachy ( void )
15+
void CAnimBlendStaticAssociationSA::Initialize ( RpClump * pClump, CAnimBlendHierarchySAInterface * pAnimBlendHierarchyInterface )
1616
{
17-
return NULL;
17+
DWORD dwThis = ( DWORD ) m_pInterface;
18+
DWORD dwFunc = FUNC_CAnimBlendStaticAssociation_Initialize;
19+
_asm
20+
{
21+
push pAnimBlendHierarchyInterface
22+
push pClump
23+
mov ecx, dwThis
24+
call dwFunc
25+
}
1826
}

Client/game_sa/CAnimBlendStaticAssociationSA.h

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
#include <game/CAnimBlendStaticAssociation.h>
1919
#include "Common.h"
2020

21+
#define FUNC_CAnimBlendStaticAssociation_Initialize 0x4CEC20
22+
2123
class CAnimBlendAssocGroupSA;
2224
class CAnimBlendHierarchySAInterface;
2325
class CAnimBlendHierarchy;
@@ -39,8 +41,17 @@ class CAnimBlendStaticAssociationSA : public CAnimBlendStaticAssociation
3941
{
4042
public:
4143
CAnimBlendStaticAssociationSA ( CAnimBlendStaticAssociationSAInterface * pInterface ) { m_pInterface = pInterface; }
42-
43-
CAnimBlendHierarchy * GetAnimHierachy ( void );
44+
void Initialize ( RpClump * pClump, CAnimBlendHierarchySAInterface * pAnimBlendHierarchyInterface );
45+
void SetNumBlendNodes ( unsigned short nNumBlendNodes ) { m_pInterface->nNumBlendNodes = nNumBlendNodes; };
46+
void SetAnimID ( short sAnimID ) { m_pInterface->sAnimID = sAnimID; }
47+
void SetAnimGroup ( short sAnimGroup ) { m_pInterface->sAnimGroup = sAnimGroup; }
48+
void SetFlags ( short sFlags ) { m_pInterface->sFlags = sFlags; }
49+
50+
unsigned short GetNumBlendNodes ( void ) { return m_pInterface->nNumBlendNodes; };
51+
short GetAnimID ( void ) { return m_pInterface->sAnimID; }
52+
short GetAnimGroup ( void ) { return m_pInterface->sAnimGroup; }
53+
short GetFlags ( void ) { return m_pInterface->sFlags; }
54+
CAnimBlendHierarchySAInterface * GetAnimHierachyInterface ( void ) { return m_pInterface->pAnimHeirarchy; }
4455

4556
protected:
4657
CAnimBlendStaticAssociationSAInterface * m_pInterface;

Client/game_sa/CAnimBlockSA.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,14 @@ void CAnimBlockSA::Request ( EModelRequestType requestType, bool bAllowBlockingF
4545
AddRef ();
4646
}
4747
}
48+
49+
CAnimBlendHierarchySAInterface * CAnimBlockSA::GetAnimationHierarchyInterface ( size_t iAnimation )
50+
{
51+
if ( !IsLoaded ( ) )
52+
return nullptr;
53+
54+
iAnimation += m_pInterface->idOffset;
55+
BYTE * arrAnimations = reinterpret_cast < BYTE * > ( ARRAY_CAnimManager_Animations );
56+
return reinterpret_cast < CAnimBlendHierarchySAInterface * > ( arrAnimations + sizeof ( CAnimBlendHierarchySAInterface ) * iAnimation );
57+
}
58+

Client/game_sa/CAnimBlockSA.h

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,18 @@ class CAnimBlockSA : public CAnimBlock
3636
{
3737
friend class CAnimBlendAssocGroupSA;
3838
public:
39-
CAnimBlockSA ( CAnimBlockSAInterface * pInterface ) { m_pInterface = pInterface; }
40-
41-
CAnimBlockSAInterface * GetInterface ( void ) { return m_pInterface; }
42-
char * GetName ( void ) { return m_pInterface->szName; }
43-
int GetIndex ( void ) { return m_pInterface->GetIndex (); }
44-
void AddRef ( void ) { m_pInterface->usRefs++; }
45-
unsigned short GetRefs ( void ) { return m_pInterface->usRefs; }
46-
void Request ( EModelRequestType requestType, bool bAllowBlockingFail = false );
47-
bool IsLoaded ( void ) { return m_pInterface->bLoaded; }
39+
CAnimBlockSA ( CAnimBlockSAInterface * pInterface ) { m_pInterface = pInterface; }
40+
41+
CAnimBlockSAInterface * GetInterface ( void ) { return m_pInterface; }
42+
char * GetName ( void ) { return m_pInterface->szName; }
43+
int GetIndex ( void ) { return m_pInterface->GetIndex (); }
44+
void AddRef ( void ) { m_pInterface->usRefs++; }
45+
unsigned short GetRefs ( void ) { return m_pInterface->usRefs; }
46+
bool IsLoaded ( void ) { return m_pInterface->bLoaded; }
47+
int GetIDOffset ( void ) { return m_pInterface->idOffset; }
48+
size_t GetAnimationCount ( void ) { return m_pInterface->nAnimations;}
49+
void Request ( EModelRequestType requestType, bool bAllowBlockingFail = false );
50+
CAnimBlendHierarchySAInterface * GetAnimationHierarchyInterface ( size_t iAnimation );
4851

4952
protected:
5053
CAnimBlockSAInterface * m_pInterface;

Client/game_sa/CAnimManagerSA.cpp

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ CAnimBlendAssociation * CAnimManagerSA::CreateAnimAssociation ( AssocGroupId ani
256256
}
257257

258258

259-
CAnimBlendStaticAssociationSAInterface * CAnimManagerSA::GetAnimStaticAssociation ( AssocGroupId animGroup, AnimationId animID )
259+
CAnimManagerSA::StaticAssocIntface_type CAnimManagerSA::GetAnimStaticAssociation ( AssocGroupId animGroup, AnimationId animID )
260260
{
261261
CAnimBlendStaticAssociationSAInterface * pInterface = nullptr;
262262
DWORD dwFunc = FUNC_CAnimManager_GetAnimAssociation;
@@ -268,7 +268,7 @@ CAnimBlendStaticAssociationSAInterface * CAnimManagerSA::GetAnimStaticAssociatio
268268
mov pInterface, eax
269269
add esp, 0x8
270270
}
271-
return pInterface;
271+
return std::make_unique < CAnimBlendStaticAssociationSA > ( pInterface );
272272
}
273273

274274

@@ -798,6 +798,11 @@ CAnimBlendHierarchy * CAnimManagerSA::GetAnimBlendHierarchy ( CAnimBlendHierarch
798798
return NULL;
799799
}
800800

801+
CAnimManagerSA::StaticAssocIntface_type CAnimManagerSA::GetAnimStaticAssociation ( CAnimBlendStaticAssociationSAInterface * pInterface )
802+
{
803+
return std::make_unique < CAnimBlendStaticAssociationSA > ( pInterface );
804+
}
805+
801806
std::unique_ptr < CAnimBlendHierarchy > CAnimManagerSA::GetCustomAnimBlendHierarchy ( CAnimBlendHierarchySAInterface * pInterface )
802807
{
803808
return std::make_unique < CAnimBlendHierarchySA > ( pInterface );
@@ -813,13 +818,3 @@ bool CAnimManagerSA::isGateWayAnimationHierarchy ( CAnimBlendHierarchySAInterfac
813818
return pGame->GetKeyGen()->GetUppercaseKey ( m_kGateWayAnimationName.c_str ( ) ) == pInterface->iHashKey;
814819
}
815820

816-
const SString & CAnimManagerSA::GetGateWayBlockName ( void )
817-
{
818-
return m_kGateWayBlockName;
819-
}
820-
821-
const SString & CAnimManagerSA::GetGateWayAnimationName ( void )
822-
{
823-
return m_kGateWayAnimationName;
824-
}
825-

Client/game_sa/CAnimManagerSA.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class CAnimManagerSAInterface
8181

8282
class CAnimManagerSA : public CAnimManager
8383
{
84-
typedef CAnimBlendStaticAssociationSAInterface * StaticAssocIntface_type;
84+
typedef std::unique_ptr < CAnimBlendStaticAssociation > StaticAssocIntface_type;
8585

8686
public:
8787
CAnimManagerSA ( void );
@@ -154,13 +154,15 @@ class CAnimManagerSA : public CAnimManager
154154
CAnimBlock * GetAnimBlock ( CAnimBlockSAInterface * pInterface );
155155
CAnimBlendHierarchy * GetAnimBlendHierarchy ( CAnimBlendHierarchySAInterface * pInterface );
156156

157+
StaticAssocIntface_type GetAnimStaticAssociation ( CAnimBlendStaticAssociationSAInterface * pInterface );
158+
157159
// MTA members, but use this strictly for custom animations only
158-
std::unique_ptr < CAnimBlendHierarchy > GetCustomAnimBlendHierarchy ( CAnimBlendHierarchySAInterface * pInterface );
159-
std::unique_ptr < CAnimBlendSequence > GetCustomAnimBlendSequence ( CAnimBlendSequenceSAInterface * pInterface );
160+
std::unique_ptr < CAnimBlendHierarchy > GetCustomAnimBlendHierarchy ( CAnimBlendHierarchySAInterface * pInterface );
161+
std::unique_ptr < CAnimBlendSequence > GetCustomAnimBlendSequence ( CAnimBlendSequenceSAInterface * pInterface );
160162

161163
bool isGateWayAnimationHierarchy ( CAnimBlendHierarchySAInterface * pInterface );
162-
const SString & GetGateWayBlockName ( void );
163-
const SString & GetGateWayAnimationName ( void );
164+
const SString & GetGateWayBlockName ( void ) { return m_kGateWayBlockName; };
165+
const SString & GetGateWayAnimationName ( void ) { return m_kGateWayAnimationName; };
164166

165167
private:
166168
CAnimBlendAssocGroup * m_pAnimAssocGroups [ MAX_ANIM_GROUPS ];

Client/game_sa/CGameSA.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -857,16 +857,3 @@ CPed* CGameSA::GetPedContext ( void )
857857
m_pPedContext = pGame->GetPools ()->GetPedFromRef ( (DWORD)1 );
858858
return m_pPedContext;
859859
}
860-
861-
constexpr
862-
CAnimBlendAssocGroupSAInterface * CGameSA::getAnimAssocGroupInterface ( AssocGroupId animGroup )
863-
{
864-
DWORD * pAnimAssocGroupsArray = reinterpret_cast < DWORD * > ( *(DWORD*)ARRAY_CAnimManager_AnimAssocGroups );
865-
return reinterpret_cast < CAnimBlendAssocGroupSAInterface * > ( pAnimAssocGroupsArray + 5 * animGroup );
866-
}
867-
868-
CGameSA::AssocGroup_type CGameSA::CreateAnimBlendAssocGroup ( AssocGroupId animGroup )
869-
{
870-
auto pAnimAssocGroupInterface = getAnimAssocGroupInterface ( animGroup );
871-
return std::make_unique < CAnimBlendAssocGroupSA > ( pAnimAssocGroupInterface );
872-
}

Client/game_sa/CGameSA.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -257,10 +257,6 @@ class CGameSA : public CGame
257257
void SetPostWeaponFireHandler ( PostWeaponFireHandler* pPostWeaponFireHandler ) { m_pPostWeaponFireHandler = pPostWeaponFireHandler; }
258258
void SetTaskSimpleBeHitHandler ( TaskSimpleBeHitHandler* pTaskSimpleBeHitHandler ) { m_pTaskSimpleBeHitHandler = pTaskSimpleBeHitHandler; }
259259

260-
constexpr
261-
CAnimBlendAssocGroupSAInterface * getAnimAssocGroupInterface ( AssocGroupId animGroup );
262-
AssocGroup_type CreateAnimBlendAssocGroup ( AssocGroupId animGroup );
263-
264260
PreWeaponFireHandler* m_pPreWeaponFireHandler;
265261
PostWeaponFireHandler* m_pPostWeaponFireHandler;
266262
TaskSimpleBeHitHandler* m_pTaskSimpleBeHitHandler;

Client/mods/deathmatch/StdInc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@
9494
#include <CLogger.h>
9595
#include <CMapEventManager.h>
9696
#include <CModelNames.h>
97+
#include <CIFPEngine.h>
9798
#include <CScriptFile.h>
9899
#include <CWeaponNames.h>
99100
#include <CVehicleNames.h>

Client/mods/deathmatch/logic/CClientEntity.cpp

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1490,43 +1490,6 @@ void CClientEntity::GetEntitiesFromRoot ( unsigned int uiTypeHash, lua_State* lu
14901490
}
14911491
}
14921492

1493-
CClientPed * CClientEntity::GetClientPedByClump ( const RpClump & Clump )
1494-
{
1495-
SString arrstrEntityTypes [2] = { "player", "ped" };
1496-
1497-
for ( size_t uiTypeIndex = 0;
1498-
uiTypeIndex < sizeof ( arrstrEntityTypes);
1499-
uiTypeIndex ++ )
1500-
{
1501-
unsigned int uiTypeHash = HashString ( arrstrEntityTypes [ uiTypeIndex ].c_str ( ) );
1502-
1503-
t_mapEntitiesFromRoot::iterator find = ms_mapEntitiesFromRoot.find ( uiTypeHash );
1504-
if ( find != ms_mapEntitiesFromRoot.end () )
1505-
{
1506-
CFromRootListType& listEntities = find->second;
1507-
CClientEntity* pEntity;
1508-
unsigned int uiIndex = 0;
1509-
1510-
for ( CFromRootListType::reverse_iterator i = listEntities.rbegin ();
1511-
i != listEntities.rend ();
1512-
++i )
1513-
{
1514-
pEntity = *i;
1515-
1516-
if ( !pEntity->IsBeingDeleted ( ) )
1517-
{
1518-
const RpClump & entityClump = *pEntity->GetClump ();
1519-
if ( std::addressof ( entityClump ) == std::addressof ( Clump ) )
1520-
{
1521-
return static_cast < CClientPed * > ( pEntity );
1522-
}
1523-
}
1524-
}
1525-
}
1526-
}
1527-
return nullptr;
1528-
}
1529-
15301493
#if CHECK_ENTITIES_FROM_ROOT
15311494

15321495
//

Client/mods/deathmatch/logic/CClientEntity.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,6 @@ class CClientEntity : public CClientEntityBase
326326
bool IsCallPropagationEnabled ( void ) { return m_bCallPropagationEnabled; }
327327
virtual void SetCallPropagationEnabled ( bool bEnabled ) { m_bCallPropagationEnabled = bEnabled; }
328328

329-
CClientPed * GetClientPedByClump ( const RpClump & Clump );
330-
331329
protected:
332330
CClientManager* m_pManager;
333331
CClientEntity* m_pParent;

0 commit comments

Comments
 (0)