26
26
#include < net/SyncStructures.h>
27
27
#include < ../Client/game_sa/CAnimBlendAssocGroupSA.h>
28
28
#include < ../Client/game_sa/CAnimBlendAssociationSA.h>
29
+ #include < ../game_sa/CAnimBlendHierarchySA.h>
29
30
30
31
SString StringZeroPadout ( const SString& strInput, uint uiPadoutSize )
31
32
{
@@ -270,7 +271,9 @@ CClientGame::CClientGame ( bool bLocalPlay )
270
271
g_pMultiplayer->SetPreFxRenderHandler ( CClientGame::StaticPreFxRenderHandler );
271
272
g_pMultiplayer->SetPreHudRenderHandler ( CClientGame::StaticPreHudRenderHandler );
272
273
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 );
274
277
g_pMultiplayer->SetProcessCollisionHandler ( CClientGame::StaticProcessCollisionHandler );
275
278
g_pMultiplayer->SetVehicleCollisionHandler ( CClientGame::StaticVehicleCollisionHandler );
276
279
g_pMultiplayer->SetVehicleDamageHandler ( CClientGame::StaticVehicleDamageHandler );
@@ -428,7 +431,9 @@ CClientGame::~CClientGame ( void )
428
431
g_pMultiplayer->SetPreFxRenderHandler ( NULL );
429
432
g_pMultiplayer->SetPreHudRenderHandler ( NULL );
430
433
g_pMultiplayer->SetAddAnimationHandler ( NULL );
431
- g_pMultiplayer->SetBlendAnimationHandler ( NULL );
434
+ g_pMultiplayer->SetAddAnimationAndSyncHandler ( NULL );
435
+ g_pMultiplayer->SetAssocGroupCopyAnimationHandler ( NULL );
436
+ g_pMultiplayer->SetBlendAnimationHierarchyHandler ( NULL );
432
437
g_pMultiplayer->SetProcessCollisionHandler ( NULL );
433
438
g_pMultiplayer->SetVehicleCollisionHandler ( NULL );
434
439
g_pMultiplayer->SetVehicleDamageHandler ( NULL );
@@ -3697,9 +3702,19 @@ CAnimBlendAssociationSAInterface * CClientGame::StaticAddAnimationHandler ( RpCl
3697
3702
return g_pClientGame->AddAnimationHandler ( pClump, animGroup, animID );
3698
3703
}
3699
3704
3700
- CAnimBlendHierarchySAInterface * CClientGame::StaticBlendAnimationHandler ( RpClump * pClump, CAnimBlendHierarchySAInterface * pAnimHierarchy, int flags, float fBlendDelta )
3705
+ CAnimBlendAssociationSAInterface * CClientGame::StaticAddAnimationAndSyncHandler ( RpClump * pClump, CAnimBlendAssociationSAInterface * pAnimAssocToSyncWith, AssocGroupId animGroup, AnimationId animID )
3701
3706
{
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 );
3703
3718
}
3704
3719
3705
3720
void CClientGame::StaticPreWorldProcessHandler ( void )
@@ -3983,113 +3998,55 @@ bool CClientGame::ChokingHandler ( unsigned char ucWeaponType )
3983
3998
return m_pLocalPlayer->CallEvent ( " onClientPlayerChoke" , Arguments, true );
3984
3999
}
3985
4000
3986
- #include < ../game_sa/CAnimBlendHierarchySA.h> // ---------------- REMOVE THIS LATER
4001
+
4002
+
3987
4003
3988
4004
CAnimBlendAssociationSAInterface * CClientGame::AddAnimationHandler ( RpClump * pClump, AssocGroupId animGroup, AnimationId animID )
3989
4005
{
3990
4006
printf ( " AddAnimationHandler called! pClump, GroupID, AnimID: %p, %d, %d\n " , (void *)pClump, animGroup, animID );
4007
+ return nullptr ;
4008
+ }
3991
4009
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
+ }
4035
4015
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
+ );
4041
4022
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 " );
4043
4026
4044
- OLD_CAnimBlendStaticAssoc_Init ( &CustomAnimStaticAssoc, pClump, pCustomAnimBlendHierarchy) ;
4027
+ auto CAnimBlendStaticAssociation_Init = (hCAnimBlendStaticAssociation_Init) 0x4CEC20 ;
4045
4028
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 );
4078
4031
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 );
4080
4035
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 ;
4082
4039
}
4083
4040
4084
- CAnimBlendHierarchySAInterface * CClientGame::BlendAnimationHandler ( RpClump * pClump, CAnimBlendHierarchySAInterface * pAnimHierarchy, int flags, float fBlendDelta )
4041
+ CAnimBlendHierarchySAInterface * CClientGame::BlendAnimationHierarchyHandler ( RpClump * pClump, CAnimBlendHierarchySAInterface * pAnimHierarchy, int flags, float fBlendDelta )
4085
4042
{
4086
- printf (" CClientGame::BlendAnimationHandler called | pClump: %p\n " , (void *)pClump);
4043
+ printf (" CClientGame::BlendAnimationHierarchyHandler called | pClump: %p\n " , (void *)pClump);
4087
4044
4088
4045
CAnimManager * pAnimationManager = g_pGame->GetAnimManager ();
4089
4046
CClientPed * pClientPed = GetClientPedByClump ( *pClump ); // pAnimationManager->GetPedPointerFromMap ( pClump ); //m_pRootEntity->GetClientPedByClump ( *pClump );
4090
4047
if ( pClientPed != nullptr )
4091
4048
{
4092
- printf (" BlendAnimationHandler : Found pClientPed\n " );
4049
+ printf (" BlendAnimationHierarchyHandler : Found pClientPed\n " );
4093
4050
if ( pClientPed->isNextAnimationCustom () )
4094
4051
{
4095
4052
const SString & strBlockName = pClientPed->GetNextAnimationCustomBlockName ( );
@@ -4100,7 +4057,7 @@ CAnimBlendHierarchySAInterface * CClientGame::BlendAnimationHandler ( RpClump *
4100
4057
auto pCustomAnimBlendHierarchy = pIFP->GetAnimationHierarchy ( strAnimationName );
4101
4058
if ( pCustomAnimBlendHierarchy != nullptr )
4102
4059
{
4103
- printf (" BlendAnimationHandler : Found Hierarchy, returning \n " );
4060
+ printf (" BlendAnimationHierarchyHandler : Found Hierarchy, returning \n " );
4104
4061
4105
4062
pClientPed->setCurrentAnimationCustom ( true );
4106
4063
@@ -4113,12 +4070,12 @@ CAnimBlendHierarchySAInterface * CClientGame::BlendAnimationHandler ( RpClump *
4113
4070
}
4114
4071
else
4115
4072
{
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 ());
4117
4074
}
4118
4075
}
4119
4076
else
4120
4077
{
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 ());
4122
4079
}
4123
4080
}
4124
4081
else
0 commit comments