Skip to content

Commit c529467

Browse files
committed
Added new functions for finding CClientPed by clump and used it in BlendAnimationHandler
1 parent f131323 commit c529467

File tree

2 files changed

+58
-3
lines changed

2 files changed

+58
-3
lines changed

Client/mods/deathmatch/logic/CClientGame.cpp

Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3988,6 +3988,12 @@ bool CClientGame::ChokingHandler ( unsigned char ucWeaponType )
39883988
CAnimBlendAssociationSAInterface * CClientGame::AddAnimationHandler ( RpClump * pClump, AssocGroupId animGroup, AnimationId animID )
39893989
{
39903990
printf ( "AddAnimationHandler called! pClump, GroupID, AnimID: %p, %d, %d\n", (void*)pClump, animGroup, animID );
3991+
3992+
CClientPed * pClientPed = GetClientPedByClump ( *pClump ); //pAnimationManager->GetPedPointerFromMap ( pClump ); //m_pRootEntity->GetClientPedByClump ( *pClump );
3993+
if ( pClientPed != nullptr )
3994+
{
3995+
//pClientPed->setCurrentAnimationCustom ( false );
3996+
}
39913997
/*
39923998
hCAnimBlendAssocGroup_CopyAnimation CAnimBlendAssocGroup_CopyAnimation = (hCAnimBlendAssocGroup_CopyAnimation)0x004CE130;
39933999
hUncompressAnimation UncompressAnimation = (hUncompressAnimation)0x4d41c0;
@@ -4077,12 +4083,13 @@ CAnimBlendAssociationSAInterface * CClientGame::AddAnimationHandler ( RpClump *
40774083

40784084
CAnimBlendHierarchySAInterface * CClientGame::BlendAnimationHandler ( RpClump * pClump, CAnimBlendHierarchySAInterface * pAnimHierarchy, int flags, float fBlendDelta )
40794085
{
4080-
printf("CClientGame::BlendAnimationHandler called\n");
4086+
printf("CClientGame::BlendAnimationHandler called | pClump: %p\n", (void*)pClump);
40814087

40824088
CAnimManager * pAnimationManager = g_pGame->GetAnimManager();
4083-
CClientPed * pClientPed = pAnimationManager->GetPedPointerFromMap ( pClump );
4089+
CClientPed * pClientPed = GetClientPedByClump ( *pClump ); //pAnimationManager->GetPedPointerFromMap ( pClump ); //m_pRootEntity->GetClientPedByClump ( *pClump );
40844090
if ( pClientPed != nullptr )
40854091
{
4092+
printf ("BlendAnimationHandler: Found pClientPed\n");
40864093
if ( pClientPed->isNextAnimationCustom () )
40874094
{
40884095
const SString & strBlockName = pClientPed->GetNextAnimationCustomBlockName ( );
@@ -4093,6 +4100,10 @@ CAnimBlendHierarchySAInterface * CClientGame::BlendAnimationHandler ( RpClump *
40934100
auto pCustomAnimBlendHierarchy = pIFP->GetAnimationHierarchy ( strAnimationName );
40944101
if ( pCustomAnimBlendHierarchy != nullptr )
40954102
{
4103+
printf ("BlendAnimationHandler: Found Hierarchy, returning \n");
4104+
4105+
pClientPed->setCurrentAnimationCustom ( true );
4106+
40964107
// Modifying a hierarchy like this is just bad, it's much better to create a new CAnimBlendHierarchySAInterface for every animation
40974108
// and then delete it once animation is over
40984109
pCustomAnimBlendHierarchy->iHashKey = pAnimHierarchy->iHashKey;
@@ -4110,7 +4121,11 @@ CAnimBlendHierarchySAInterface * CClientGame::BlendAnimationHandler ( RpClump *
41104121
printf("BlendAnimationHandler: could not find IFP block name '%s'\n", strBlockName.c_str());
41114122
}
41124123
}
4113-
pClientPed->setNextAnimationNormal ( );;
4124+
else
4125+
{
4126+
pClientPed->setCurrentAnimationCustom ( false );
4127+
}
4128+
pClientPed->setNextAnimationNormal ( );
41144129
}
41154130
return pAnimHierarchy;
41164131
}
@@ -6869,3 +6884,36 @@ CClientIFP * CClientGame::GetIFPPointerFromMap ( const SString & strBlockName )
68696884
}
68706885
return nullptr;
68716886
}
6887+
6888+
void CClientGame::InsertPedPointerToMap ( CClientPed * pPed )
6889+
{
6890+
if ( m_mapOfPedPointers.count ( pPed ) == 0 )
6891+
{
6892+
m_mapOfPedPointers [ pPed ] = true;
6893+
}
6894+
}
6895+
6896+
void CClientGame::RemovePedPointerFromMap ( CClientPed * pPed )
6897+
{
6898+
m_mapOfPedPointers.erase ( pPed );
6899+
}
6900+
6901+
CClientPed * CClientGame::GetClientPedByClump ( const RpClump & Clump )
6902+
{
6903+
for ( auto it = m_mapOfPedPointers.begin(); it != m_mapOfPedPointers.end(); it++ )
6904+
{
6905+
CEntity * pEntity = it->first->GetGameEntity();
6906+
if ( pEntity != nullptr )
6907+
{
6908+
if ( pEntity->GetRpClump() != nullptr)
6909+
{
6910+
const RpClump & entityClump = *pEntity->GetRpClump();
6911+
if ( std::addressof ( entityClump ) == std::addressof ( Clump ) )
6912+
{
6913+
return it->first;
6914+
}
6915+
}
6916+
}
6917+
}
6918+
return nullptr;
6919+
}

Client/mods/deathmatch/logic/CClientGame.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,11 @@ class CClientGame
590590
void RemoveIFPPointerFromMap ( const SString & strBlockName );
591591
CClientIFP * GetIFPPointerFromMap ( const SString & strBlockName );
592592

593+
void InsertPedPointerToMap ( CClientPed * pPed );
594+
void RemovePedPointerFromMap ( CClientPed * pPed );
595+
CClientPed * GetClientPedByClump ( const RpClump & Clump );
596+
597+
593598
private:
594599
eStatus m_Status;
595600
eServerType m_ServerType;
@@ -805,6 +810,8 @@ class CClientGame
805810

806811
// (SString) Key is custom block name that is supplied to engineLoadIFP
807812
std::map < SString, CClientIFP * > m_mapOfIfpPointers;
813+
814+
std::map < CClientPed *, bool > m_mapOfPedPointers;
808815
};
809816

810817
extern CClientGame* g_pClientGame;

0 commit comments

Comments
 (0)