@@ -270,7 +270,8 @@ CClientGame::CClientGame ( bool bLocalPlay )
270270 g_pMultiplayer->SetPreFxRenderHandler ( CClientGame::StaticPreFxRenderHandler );
271271 g_pMultiplayer->SetPreHudRenderHandler ( CClientGame::StaticPreHudRenderHandler );
272272 g_pMultiplayer->SetAddAnimationHandler ( CClientGame::StaticAddAnimationHandler );
273- g_pMultiplayer->SetBlendAnimationHandler ( CClientGame::StaticBlendAnimationHandler );
273+ g_pMultiplayer->SetAddAnimationAndSyncHandler ( CClientGame::StaticAddAnimationAndSyncHandler );
274+ g_pMultiplayer->SetBlendAnimationHierarchyHandler ( CClientGame::StaticBlendAnimationHierarchyHandler );
274275 g_pMultiplayer->SetProcessCollisionHandler ( CClientGame::StaticProcessCollisionHandler );
275276 g_pMultiplayer->SetVehicleCollisionHandler ( CClientGame::StaticVehicleCollisionHandler );
276277 g_pMultiplayer->SetVehicleDamageHandler ( CClientGame::StaticVehicleDamageHandler );
@@ -428,7 +429,8 @@ CClientGame::~CClientGame ( void )
428429 g_pMultiplayer->SetPreFxRenderHandler ( NULL );
429430 g_pMultiplayer->SetPreHudRenderHandler ( NULL );
430431 g_pMultiplayer->SetAddAnimationHandler ( NULL );
431- g_pMultiplayer->SetBlendAnimationHandler ( NULL );
432+ g_pMultiplayer->SetAddAnimationAndSyncHandler ( NULL );
433+ g_pMultiplayer->SetBlendAnimationHierarchyHandler ( NULL );
432434 g_pMultiplayer->SetProcessCollisionHandler ( NULL );
433435 g_pMultiplayer->SetVehicleCollisionHandler ( NULL );
434436 g_pMultiplayer->SetVehicleDamageHandler ( NULL );
@@ -3697,9 +3699,14 @@ CAnimBlendAssociationSAInterface * CClientGame::StaticAddAnimationHandler ( RpCl
36973699 return g_pClientGame->AddAnimationHandler ( pClump, animGroup, animID );
36983700}
36993701
3700- CAnimBlendHierarchySAInterface * CClientGame::StaticBlendAnimationHandler ( RpClump * pClump, CAnimBlendHierarchySAInterface * pAnimHierarchy, int flags, float fBlendDelta )
3702+ CAnimBlendAssociationSAInterface * CClientGame::StaticAddAnimationAndSyncHandler ( RpClump * pClump, CAnimBlendAssociationSAInterface * pAnimAssocToSyncWith, AssocGroupId animGroup, AnimationId animID )
37013703{
3702- return g_pClientGame->BlendAnimationHandler ( pClump, pAnimHierarchy, flags, fBlendDelta );
3704+ return g_pClientGame->AddAnimationAndSyncHandler ( pClump, pAnimAssocToSyncWith, animGroup, animID );
3705+ }
3706+
3707+ CAnimBlendHierarchySAInterface * CClientGame::StaticBlendAnimationHierarchyHandler ( RpClump * pClump, CAnimBlendHierarchySAInterface * pAnimHierarchy, int flags, float fBlendDelta )
3708+ {
3709+ return g_pClientGame->BlendAnimationHierarchyHandler ( pClump, pAnimHierarchy, flags, fBlendDelta );
37033710}
37043711
37053712void CClientGame::StaticPreWorldProcessHandler ( void )
@@ -4002,7 +4009,15 @@ CAnimBlendAssociationSAInterface * CClientGame::AddAnimationHandler ( RpClump *
40024009 int *next; // eax
40034010 DWORD *tempAssoc; // eax
40044011 int *nextAssoc; // ecx
4005- // We need to remove this line and add some code here for running animations simultaneously
4012+
4013+ CAnimManager * pAnimationManager = g_pGame->GetAnimManager ();
4014+ CAnimBlendStaticAssoc * pAnimOriginalStaticAssoc = (CAnimBlendStaticAssoc *)pAnimationManager->GetAnimStaticAssociation ( animGroup, animID );
4015+
4016+ UncompressAnimation ( pAnimOriginalStaticAssoc->m_pAnimBlendHier );
4017+ pAnimAssoc = (CAnimBlendAssoc *)malloc (sizeof (CAnimBlendAssoc));
4018+ OLD_CAnimBlendAssoc_Constructor_staticAssocRef ( pAnimAssoc, *pAnimOriginalStaticAssoc);
4019+
4020+ // We need to remove this line and add some code here for running animations simultaneously
40064021 pAnimAssoc = CAnimBlendAssocGroup_CopyAnimation ((DWORD *) (*(DWORD*)0x00B4EA34 ) + 5 * animGroup, animID);
40074022
40084023 // //ofs << "Done calling CAnimBlendAssocGroup_CopyAnimation " << std::endl;
@@ -4050,15 +4065,62 @@ CAnimBlendAssociationSAInterface * CClientGame::AddAnimationHandler ( RpClump *
40504065 return (CAnimBlendAssociationSAInterface *)pAnimAssoc;
40514066}
40524067
4053- CAnimBlendHierarchySAInterface * CClientGame::BlendAnimationHandler ( RpClump * pClump, CAnimBlendHierarchySAInterface * pAnimHierarchy, int flags, float fBlendDelta )
4068+ CAnimBlendAssociationSAInterface * CClientGame::AddAnimationAndSyncHandler ( RpClump * pClump, CAnimBlendAssociationSAInterface * pAnimAssocToSyncWith, AssocGroupId animGroup, AnimationId animID )
4069+ {
4070+ printf ( " AddAnimationAndSyncHandler called! pClump, GroupID, AnimID: %p, %d, %d\n " , (void *)pClump, animGroup, animID );
4071+
4072+ hCAnimBlendAssocGroup_CopyAnimation CAnimBlendAssocGroup_CopyAnimation = (hCAnimBlendAssocGroup_CopyAnimation)0x004CE130 ;
4073+ hUncompressAnimation UncompressAnimation = (hUncompressAnimation)0x4d41c0 ;
4074+ hCAnimBlendAssoc_Constructor_staticAssocRef OLD_CAnimBlendAssoc_Constructor_staticAssocRef = (hCAnimBlendAssoc_Constructor_staticAssocRef)0x4CF080 ;
4075+ hCAnimBlendStaticAssoc_Constructor OLD_CAnimBlendStaticAssoc_Constructor = *(hCAnimBlendStaticAssoc_Constructor)0x4CE940 ;
4076+ hCAnimBlendStaticAssoc_Init OLD_CAnimBlendStaticAssoc_Init = (hCAnimBlendStaticAssoc_Init)0x004CEC20 ;
4077+ hCAnimBlendAssoc_SyncAnimation CAnimBlendAssoc_SyncAnimation = (hCAnimBlendAssoc_SyncAnimation)0x004CEB40 ;
4078+ hCAnimBlendAssoc_Start CAnimBlendAssoc_Start = (hCAnimBlendAssoc_Start)0x004CEB70 ;
4079+
4080+ CAnimBlendAssoc * pAnimAssocToSyncWith2 = (CAnimBlendAssoc *)pAnimAssocToSyncWith;
4081+ CAnimBlendAssoc *pAnimAssoc; // esi
4082+ int *pClumpData; // edi
4083+ DWORD *tempAssoc; // eax
4084+ int nextAssoc; // ecx
4085+
4086+ pAnimAssoc = CAnimBlendAssocGroup_CopyAnimation ((DWORD *) (*(DWORD*)0x00B4EA34 ) + 5 * animGroup, animID);
4087+ pClumpData = *(int **)( (*(DWORD*)0xB5F878 ) + (int )pClump);
4088+ if ( (*((BYTE *)pAnimAssoc + 46 ) >> 5 ) & 1 && pAnimAssocToSyncWith2 )
4089+ {
4090+ CAnimBlendAssoc_SyncAnimation ( pAnimAssoc, pAnimAssocToSyncWith2);
4091+ *((BYTE *)pAnimAssoc + 46 ) |= 1u ;
4092+ }
4093+ else
4094+ {
4095+ CAnimBlendAssoc_Start ( pAnimAssoc, 0 );
4096+ }
4097+
4098+ tempAssoc = ((DWORD*)pAnimAssoc) + 1 ;
4099+
4100+ if ( *pClumpData )
4101+ *(DWORD *)(*pClumpData + 4 ) = (DWORD)tempAssoc;
4102+
4103+ nextAssoc = *pClumpData;
4104+
4105+ DWORD * dwpAnimAssoc = (DWORD*) pAnimAssoc;
4106+
4107+ dwpAnimAssoc[2 ] = (DWORD)pClumpData;
4108+
4109+ *tempAssoc = nextAssoc;
4110+
4111+ *pClumpData = (int )tempAssoc;
4112+ return (CAnimBlendAssociationSAInterface *)pAnimAssoc;
4113+ }
4114+
4115+ CAnimBlendHierarchySAInterface * CClientGame::BlendAnimationHierarchyHandler ( RpClump * pClump, CAnimBlendHierarchySAInterface * pAnimHierarchy, int flags, float fBlendDelta )
40544116{
4055- printf (" CClientGame::BlendAnimationHandler called | pClump: %p\n " , (void *)pClump);
4117+ printf (" CClientGame::BlendAnimationHierarchyHandler called | pClump: %p\n " , (void *)pClump);
40564118
40574119 CAnimManager * pAnimationManager = g_pGame->GetAnimManager ();
40584120 CClientPed * pClientPed = GetClientPedByClump ( *pClump ); // pAnimationManager->GetPedPointerFromMap ( pClump ); //m_pRootEntity->GetClientPedByClump ( *pClump );
40594121 if ( pClientPed != nullptr )
40604122 {
4061- printf (" BlendAnimationHandler : Found pClientPed\n " );
4123+ printf (" BlendAnimationHierarchyHandler : Found pClientPed\n " );
40624124 if ( pClientPed->isNextAnimationCustom () )
40634125 {
40644126 const SString & strBlockName = pClientPed->GetNextAnimationCustomBlockName ( );
@@ -4069,7 +4131,7 @@ CAnimBlendHierarchySAInterface * CClientGame::BlendAnimationHandler ( RpClump *
40694131 auto pCustomAnimBlendHierarchy = pIFP->GetAnimationHierarchy ( strAnimationName );
40704132 if ( pCustomAnimBlendHierarchy != nullptr )
40714133 {
4072- printf (" BlendAnimationHandler : Found Hierarchy, returning \n " );
4134+ printf (" BlendAnimationHierarchyHandler : Found Hierarchy, returning \n " );
40734135
40744136 pClientPed->setCurrentAnimationCustom ( true );
40754137
@@ -4082,12 +4144,12 @@ CAnimBlendHierarchySAInterface * CClientGame::BlendAnimationHandler ( RpClump *
40824144 }
40834145 else
40844146 {
4085- printf (" BlendAnimationHandler : could not find IFP animation hierarchy '%s'\n " , strAnimationName.c_str ());
4147+ printf (" BlendAnimationHierarchyHandler : could not find IFP animation hierarchy '%s'\n " , strAnimationName.c_str ());
40864148 }
40874149 }
40884150 else
40894151 {
4090- printf (" BlendAnimationHandler : could not find IFP block name '%s'\n " , strBlockName.c_str ());
4152+ printf (" BlendAnimationHierarchyHandler : could not find IFP block name '%s'\n " , strBlockName.c_str ());
40914153 }
40924154 }
40934155 else
0 commit comments