2626#include < net/SyncStructures.h>
2727#include < ../Client/game_sa/CAnimBlendAssocGroupSA.h>
2828#include < ../Client/game_sa/CAnimBlendAssociationSA.h>
29+ #include < ../game_sa/CAnimBlendHierarchySA.h>
2930
3031SString StringZeroPadout ( const SString& strInput, uint uiPadoutSize )
3132{
@@ -270,7 +271,9 @@ CClientGame::CClientGame ( bool bLocalPlay )
270271 g_pMultiplayer->SetPreFxRenderHandler ( CClientGame::StaticPreFxRenderHandler );
271272 g_pMultiplayer->SetPreHudRenderHandler ( CClientGame::StaticPreHudRenderHandler );
272273 g_pMultiplayer->SetAddAnimationHandler ( CClientGame::StaticAddAnimationHandler );
273- g_pMultiplayer->SetBlendAnimationHandler ( CClientGame::StaticBlendAnimationHandler );
274+ g_pMultiplayer->SetAddAnimationAndSyncHandler ( CClientGame::StaticAddAnimationAndSyncHandler );
275+ g_pMultiplayer->SetAssocGroupCopyAnimationHandler ( CClientGame::StaticAssocGroupCopyAnimationHandler );
276+ g_pMultiplayer->SetBlendAnimationHierarchyHandler ( CClientGame::StaticBlendAnimationHierarchyHandler );
274277 g_pMultiplayer->SetProcessCollisionHandler ( CClientGame::StaticProcessCollisionHandler );
275278 g_pMultiplayer->SetVehicleCollisionHandler ( CClientGame::StaticVehicleCollisionHandler );
276279 g_pMultiplayer->SetVehicleDamageHandler ( CClientGame::StaticVehicleDamageHandler );
@@ -428,7 +431,9 @@ CClientGame::~CClientGame ( void )
428431 g_pMultiplayer->SetPreFxRenderHandler ( NULL );
429432 g_pMultiplayer->SetPreHudRenderHandler ( NULL );
430433 g_pMultiplayer->SetAddAnimationHandler ( NULL );
431- g_pMultiplayer->SetBlendAnimationHandler ( NULL );
434+ g_pMultiplayer->SetAddAnimationAndSyncHandler ( NULL );
435+ g_pMultiplayer->SetAssocGroupCopyAnimationHandler ( NULL );
436+ g_pMultiplayer->SetBlendAnimationHierarchyHandler ( NULL );
432437 g_pMultiplayer->SetProcessCollisionHandler ( NULL );
433438 g_pMultiplayer->SetVehicleCollisionHandler ( NULL );
434439 g_pMultiplayer->SetVehicleDamageHandler ( NULL );
@@ -3697,9 +3702,19 @@ CAnimBlendAssociationSAInterface * CClientGame::StaticAddAnimationHandler ( RpCl
36973702 return g_pClientGame->AddAnimationHandler ( pClump, animGroup, animID );
36983703}
36993704
3700- CAnimBlendHierarchySAInterface * CClientGame::StaticBlendAnimationHandler ( RpClump * pClump, CAnimBlendHierarchySAInterface * pAnimHierarchy, int flags, float fBlendDelta )
3705+ CAnimBlendAssociationSAInterface * CClientGame::StaticAddAnimationAndSyncHandler ( RpClump * pClump, CAnimBlendAssociationSAInterface * pAnimAssocToSyncWith, AssocGroupId animGroup, AnimationId animID )
37013706{
3702- return g_pClientGame->BlendAnimationHandler ( pClump, pAnimHierarchy, flags, fBlendDelta );
3707+ return g_pClientGame->AddAnimationAndSyncHandler ( pClump, pAnimAssocToSyncWith, animGroup, animID );
3708+ }
3709+
3710+ void CClientGame::StaticAssocGroupCopyAnimationHandler ( CAnimBlendStaticAssociationSAInterface * pOutAnimStaticAssoc, RpClump * pClump, CAnimBlendAssocGroupSAInterface * pAnimAssocGroup, AnimationId animID )
3711+ {
3712+ g_pClientGame->AssocGroupCopyAnimationHandler ( pOutAnimStaticAssoc, pClump, pAnimAssocGroup, animID );
3713+ }
3714+
3715+ CAnimBlendHierarchySAInterface * CClientGame::StaticBlendAnimationHierarchyHandler ( RpClump * pClump, CAnimBlendHierarchySAInterface * pAnimHierarchy, int flags, float fBlendDelta )
3716+ {
3717+ return g_pClientGame->BlendAnimationHierarchyHandler ( pClump, pAnimHierarchy, flags, fBlendDelta );
37033718}
37043719
37053720void CClientGame::StaticPreWorldProcessHandler ( void )
@@ -3983,113 +3998,55 @@ bool CClientGame::ChokingHandler ( unsigned char ucWeaponType )
39833998 return m_pLocalPlayer->CallEvent ( " onClientPlayerChoke" , Arguments, true );
39843999}
39854000
3986- #include < ../game_sa/CAnimBlendHierarchySA.h> // ---------------- REMOVE THIS LATER
4001+
4002+
39874003
39884004CAnimBlendAssociationSAInterface * CClientGame::AddAnimationHandler ( RpClump * pClump, AssocGroupId animGroup, AnimationId animID )
39894005{
39904006 printf ( " AddAnimationHandler called! pClump, GroupID, AnimID: %p, %d, %d\n " , (void *)pClump, animGroup, animID );
4007+ return nullptr ;
4008+ }
39914009
3992- CClientPed * pClientPed = GetClientPedByClump ( *pClump ); // pAnimationManager->GetPedPointerFromMap ( pClump ); //m_pRootEntity->GetClientPedByClump ( *pClump );
3993- if ( pClientPed != nullptr )
3994- {
3995- // pClientPed->setCurrentAnimationCustom ( false );
3996- }
3997- /*
3998- hCAnimBlendAssocGroup_CopyAnimation CAnimBlendAssocGroup_CopyAnimation = (hCAnimBlendAssocGroup_CopyAnimation)0x004CE130;
3999- hUncompressAnimation UncompressAnimation = (hUncompressAnimation)0x4d41c0;
4000- hCAnimBlendAssoc_Constructor_staticAssocRef OLD_CAnimBlendAssoc_Constructor_staticAssocRef = (hCAnimBlendAssoc_Constructor_staticAssocRef)0x4CF080;
4001- hCAnimBlendStaticAssoc_Constructor OLD_CAnimBlendStaticAssoc_Constructor = *(hCAnimBlendStaticAssoc_Constructor)0x4CE940;
4002- hCAnimBlendStaticAssoc_Init OLD_CAnimBlendStaticAssoc_Init = (hCAnimBlendStaticAssoc_Init)0x004CEC20;
4003-
4004- CAnimManager * pAnimationManager = g_pGame->GetAnimManager();
4005- auto pOriginalAnimStaticAssoc = pAnimationManager->GetAnimStaticAssociation ( animGroup, animID );
4006-
4007- CClientPed * pClientPed = pAnimationManager->GetPedPointerFromMap ( pClump );
4008- if ( pClientPed != nullptr )
4009- {
4010- printf("AddAnimationHandler: found client ped pointer from map\n");
4011-
4012- const SString & strBlockName = pClientPed->GetNextAnimationCustomBlockName ( );
4013- CClientIFP * pIFP = GetIFPPointerFromMap ( strBlockName );
4014- if ( pIFP )
4015- {
4016- printf("AddAnimationHandler: found IFP pointer from map\n");
4017-
4018- const SString & strAnimationName = pClientPed->GetNextAnimationCustomName ( );
4019- _CAnimBlendHierarchy * pCustomAnimBlendHierarchy = (_CAnimBlendHierarchy *)pIFP->GetAnimationHierarchy ( strAnimationName );
4020- if ( pCustomAnimBlendHierarchy != nullptr )
4021- {
4022- printf("AddAnimationHandler:got custom animation hierarchy\n");
4023-
4024- if ( animGroup == 0 && animID == 55 ) // if it's crouch animation
4025- {
4026- printf("AddAnimationHandler: Internal GTA Courch Animation Total Sequences: %d\n", pOriginalAnimStaticAssoc->pAnimHeirarchy->usNumSequences);
4027-
4028-
4029- auto pCrouchAnimStaticAssoc = pAnimationManager->GetAnimStaticAssociation ( 0, 55 ); // 0, 55 for crouch animation
4030-
4031- CAnimBlendStaticAssoc * pOriginalAnimStaticAssoc = (CAnimBlendStaticAssoc *)pCrouchAnimStaticAssoc;
4032-
4033- // let's play the original crouch animation instead for testing ^^
4034- pCustomAnimBlendHierarchy = pOriginalAnimStaticAssoc->m_pAnimBlendHier;
4010+ CAnimBlendAssociationSAInterface * CClientGame::AddAnimationAndSyncHandler ( RpClump * pClump, CAnimBlendAssociationSAInterface * pAnimAssocToSyncWith, AssocGroupId animGroup, AnimationId animID )
4011+ {
4012+ printf ( " AddAnimationAndSyncHandler called! pClump, GroupID, AnimID: %p, %d, %d\n " , (void *)pClump, animGroup, animID );
4013+ return nullptr ;
4014+ }
40354015
4036- pCustomAnimBlendHierarchy->m_hashKey = pOriginalAnimStaticAssoc->m_pAnimBlendHier->m_hashKey;
4037- pCustomAnimBlendHierarchy->m_nAnimBlockId = pOriginalAnimStaticAssoc->m_pAnimBlendHier->m_nAnimBlockId;
4038-
4039- CAnimBlendStaticAssoc CustomAnimStaticAssoc;
4040- OLD_CAnimBlendStaticAssoc_Constructor ( &CustomAnimStaticAssoc );
4016+ typedef void (__thiscall* hCAnimBlendStaticAssociation_Init)
4017+ (
4018+ CAnimBlendStaticAssociationSAInterface * pThis,
4019+ RpClump * Clump,
4020+ CAnimBlendHierarchySAInterface * pAnimBlendHierarchy
4021+ );
40414022
4042- CustomAnimStaticAssoc.m_nFlags = pOriginalAnimStaticAssoc->m_nFlags;
4023+ void CClientGame::AssocGroupCopyAnimationHandler ( CAnimBlendStaticAssociationSAInterface * pOutAnimStaticAssoc, RpClump * pClump, CAnimBlendAssocGroupSAInterface * pAnimAssocGroup, AnimationId animID )
4024+ {
4025+ printf (" AssocGroupCopyAnimationHandler called!\n " );
40434026
4044- OLD_CAnimBlendStaticAssoc_Init ( &CustomAnimStaticAssoc, pClump, pCustomAnimBlendHierarchy) ;
4027+ auto CAnimBlendStaticAssociation_Init = (hCAnimBlendStaticAssociation_Init) 0x4CEC20 ;
40454028
4046- CustomAnimStaticAssoc.m_nAnimGroup = pOriginalAnimStaticAssoc->m_nAnimGroup;
4047- CustomAnimStaticAssoc.m_nAnimID = pOriginalAnimStaticAssoc->m_nAnimID;
4048-
4049- UncompressAnimation ( CustomAnimStaticAssoc.m_pAnimBlendHier );
4050- CAnimBlendAssoc * pAnimAssoc = (CAnimBlendAssoc *)malloc(sizeof(CAnimBlendAssoc));
4051- OLD_CAnimBlendAssoc_Constructor_staticAssocRef ( pAnimAssoc, CustomAnimStaticAssoc);
4052-
4053- pAnimAssoc->m_nAnimGroup = pOriginalAnimStaticAssoc->m_nAnimGroup;
4054- pAnimAssoc->m_nFlags = pOriginalAnimStaticAssoc->m_nFlags;
4055-
4056- printf("AddAnimationHandler: returning pAnimAssoc\n");
4057- return (CAnimBlendAssociationSAInterface * ) pAnimAssoc;
4058- //auto pAnimStaticAssoc = pAnimationManager->GetAnimStaticAssociation ( 0, 55 ); // 0, 55 for crouch animation
4059- //return pAnimStaticAssoc->pAnimHeirarchy;
4060- }
4061- }
4062- else
4063- {
4064- printf ("AddAnimationHandler: could not find IFP animation hierarchy '%s'\n", strAnimationName.c_str());
4065- }
4066- }
4067- else
4068- {
4069- printf("AddAnimationHandler: could not find IFP block name '%s'\n", strBlockName.c_str());
4070- }
4071- }
4072-
4073- printf("AddAnimationHandler: executing normal flow instead of custom animation\n");
4074- */
4075- // normal flow
4076- std::unique_ptr < CAnimBlendAssocGroup > pAnimAssocGroup = g_pGame->CreateAnimBlendAssocGroup ( animGroup );
4077- CAnimBlendAssociationSAInterface * pAnimAssociation = pAnimAssocGroup->CopyAnimation ( animID );
4029+ CAnimManager * pAnimationManager = g_pGame->GetAnimManager ();
4030+ auto pOriginalAnimStaticAssoc = pAnimationManager->GetAnimStaticAssociation ( pAnimAssocGroup->groupID , animID );
40784031
4079- printf (" \n " );
4032+ CAnimBlendStaticAssociation_Init ( pOutAnimStaticAssoc, pClump, pOriginalAnimStaticAssoc->pAnimHeirarchy );
4033+ pOutAnimStaticAssoc->sAnimGroup = static_cast < short > ( pAnimAssocGroup->groupID );
4034+ pOutAnimStaticAssoc->sAnimID = static_cast < short > ( animID );
40804035
4081- return pAnimAssociation;
4036+ // Total bones in clump. GTA SA is using 32 bones for peds/players
4037+ pOutAnimStaticAssoc->nNumBlendNodes = pOriginalAnimStaticAssoc->nNumBlendNodes ;
4038+ pOutAnimStaticAssoc->sFlags = pOriginalAnimStaticAssoc->sFlags ;
40824039}
40834040
4084- CAnimBlendHierarchySAInterface * CClientGame::BlendAnimationHandler ( RpClump * pClump, CAnimBlendHierarchySAInterface * pAnimHierarchy, int flags, float fBlendDelta )
4041+ CAnimBlendHierarchySAInterface * CClientGame::BlendAnimationHierarchyHandler ( RpClump * pClump, CAnimBlendHierarchySAInterface * pAnimHierarchy, int flags, float fBlendDelta )
40854042{
4086- printf (" CClientGame::BlendAnimationHandler called | pClump: %p\n " , (void *)pClump);
4043+ printf (" CClientGame::BlendAnimationHierarchyHandler called | pClump: %p\n " , (void *)pClump);
40874044
40884045 CAnimManager * pAnimationManager = g_pGame->GetAnimManager ();
40894046 CClientPed * pClientPed = GetClientPedByClump ( *pClump ); // pAnimationManager->GetPedPointerFromMap ( pClump ); //m_pRootEntity->GetClientPedByClump ( *pClump );
40904047 if ( pClientPed != nullptr )
40914048 {
4092- printf (" BlendAnimationHandler : Found pClientPed\n " );
4049+ printf (" BlendAnimationHierarchyHandler : Found pClientPed\n " );
40934050 if ( pClientPed->isNextAnimationCustom () )
40944051 {
40954052 const SString & strBlockName = pClientPed->GetNextAnimationCustomBlockName ( );
@@ -4100,7 +4057,7 @@ CAnimBlendHierarchySAInterface * CClientGame::BlendAnimationHandler ( RpClump *
41004057 auto pCustomAnimBlendHierarchy = pIFP->GetAnimationHierarchy ( strAnimationName );
41014058 if ( pCustomAnimBlendHierarchy != nullptr )
41024059 {
4103- printf (" BlendAnimationHandler : Found Hierarchy, returning \n " );
4060+ printf (" BlendAnimationHierarchyHandler : Found Hierarchy, returning \n " );
41044061
41054062 pClientPed->setCurrentAnimationCustom ( true );
41064063
@@ -4113,12 +4070,12 @@ CAnimBlendHierarchySAInterface * CClientGame::BlendAnimationHandler ( RpClump *
41134070 }
41144071 else
41154072 {
4116- printf (" BlendAnimationHandler : could not find IFP animation hierarchy '%s'\n " , strAnimationName.c_str ());
4073+ printf (" BlendAnimationHierarchyHandler : could not find IFP animation hierarchy '%s'\n " , strAnimationName.c_str ());
41174074 }
41184075 }
41194076 else
41204077 {
4121- printf (" BlendAnimationHandler : could not find IFP block name '%s'\n " , strBlockName.c_str ());
4078+ printf (" BlendAnimationHierarchyHandler : could not find IFP block name '%s'\n " , strBlockName.c_str ());
41224079 }
41234080 }
41244081 else
0 commit comments