@@ -6845,8 +6845,15 @@ void CClientGame::RestreamModel ( unsigned short usModel )
68456845
68466846}
68476847
6848+ void CClientGame::InsertIFPPointerToMap ( const unsigned int u32BlockNameHash, const std::shared_ptr < CClientIFP > & pIFP )
6849+ {
6850+ std::lock_guard < std::mutex > mutexGuardedLock ( m_MutexOfIfpPointersMap );
6851+ m_mapOfIfpPointers [ u32BlockNameHash ] = pIFP;
6852+ }
6853+
68486854std::shared_ptr < CClientIFP > CClientGame::GetIFPPointerFromMap ( const unsigned int u32BlockNameHash )
68496855{
6856+ std::lock_guard < std::mutex > mutexGuardedLock ( m_MutexOfIfpPointersMap );
68506857 auto it = m_mapOfIfpPointers.find ( u32BlockNameHash );
68516858 if ( it != m_mapOfIfpPointers.end ( ) )
68526859 {
@@ -6855,19 +6862,39 @@ std::shared_ptr < CClientIFP > CClientGame::GetIFPPointerFromMap ( const unsigne
68556862 return nullptr ;
68566863}
68576864
6865+ void CClientGame::RemoveIFPPointerFromMap ( const unsigned int u32BlockNameHash )
6866+ {
6867+ std::lock_guard < std::mutex > mutexGuardedLock ( m_MutexOfIfpPointersMap );
6868+ m_mapOfIfpPointers.erase ( u32BlockNameHash );
6869+ }
6870+
6871+
6872+ void CClientGame::InsertPedPointerToSet ( CClientPed * pPed )
6873+ {
6874+ std::lock_guard < std::mutex > mutexGuardedLock ( m_MutexOfPedPointersSet );
6875+ m_setOfPedPointers.insert ( pPed );
6876+ }
6877+
6878+ void CClientGame::RemovePedPointerFromSet ( CClientPed * pPed )
6879+ {
6880+ std::lock_guard < std::mutex > mutexGuardedLock ( m_MutexOfPedPointersSet );
6881+ m_setOfPedPointers.erase ( pPed );
6882+ }
6883+
68586884CClientPed * CClientGame::GetClientPedByClump ( const RpClump & Clump )
68596885{
6860- for ( auto it = m_mapOfPedPointers.begin (); it != m_mapOfPedPointers.end (); it++ )
6886+ std::lock_guard < std::mutex > mutexGuardedLock ( m_MutexOfPedPointersSet );
6887+ for ( auto it = m_setOfPedPointers.begin ( ); it != m_setOfPedPointers.end ( ); it++ )
68616888 {
6862- CEntity * pEntity = it-> first ->GetGameEntity ();
6889+ CEntity * pEntity = (*it) ->GetGameEntity ();
68636890 if ( pEntity != nullptr )
68646891 {
6865- if ( pEntity->GetRpClump () != nullptr )
6892+ if ( pEntity->GetRpClump () != nullptr )
68666893 {
68676894 const RpClump & entityClump = *pEntity->GetRpClump ();
68686895 if ( std::addressof ( entityClump ) == std::addressof ( Clump ) )
68696896 {
6870- return it-> first ;
6897+ return *it ;
68716898 }
68726899 }
68736900 }
@@ -6877,38 +6904,41 @@ CClientPed * CClientGame::GetClientPedByClump ( const RpClump & Clump )
68776904
68786905void CClientGame::OnClientIFPUnload ( const std::shared_ptr < CClientIFP > & IFP )
68796906{
6907+ std::lock_guard < std::mutex > mutexGuardedLock ( m_MutexOfPedPointersSet );
68806908 IFP->MarkAsUnloading ( );
6881- for ( auto it = m_mapOfPedPointers .begin ( ); it != m_mapOfPedPointers .end ( ); it++ )
6909+ for ( auto it = m_setOfPedPointers .begin ( ); it != m_setOfPedPointers .end ( ); it++ )
68826910 {
68836911 // Remove IFP animations from replaced animations of peds/players
6884- it-> first ->RestoreAnimations ( IFP );
6912+ (*it) ->RestoreAnimations ( IFP );
68856913
68866914 // Make sure that streamed in pulses or changing model does not accidently
68876915 // play our custom animation. We can do that by making the custom animation
68886916 // untriggerable
6889- if ( it-> first ->GetCustomAnimationBlockNameHash ( ) == IFP->GetBlockNameHash ( ) )
6917+ if ( (*it) ->GetCustomAnimationBlockNameHash ( ) == IFP->GetBlockNameHash ( ) )
68906918 {
6891- if ( it-> first ->IsCustomAnimationPlaying ( ) )
6919+ if ( (*it) ->IsCustomAnimationPlaying ( ) )
68926920 {
6893- it-> first ->SetCustomAnimationUntriggerable ( );
6921+ (*it) ->SetCustomAnimationUntriggerable ( );
68946922 }
68956923
68966924 // Important! As we are using a shared_ptr, we need to decrement the reference counter
68976925 // by setting the shared_ptr to nullptr, this will avoid memory leak
6898- if ( !it-> first -> IsNextAnimationCustom ( ) && it-> first ->IsCurrentAnimationCustom ( ) )
6926+ if ( !(*it)-> IsNextAnimationCustom ( ) && (*it) ->IsCurrentAnimationCustom ( ) )
68996927 {
6900- it-> first ->DereferenceCustomAnimationBlock ();
6928+ (*it) ->DereferenceCustomAnimationBlock ();
69016929 }
69026930 }
69036931 }
69046932}
69056933
69066934void CClientGame::InsertAnimationAssociationToMap ( CAnimBlendAssociationSAInterface * pAnimAssociation, const std::shared_ptr < CIFPAnimations > & pIFPAnimations )
69076935{
6936+ std::lock_guard < std::mutex > mutexGuardedLock ( m_MutexOfAnimationAssociationsMap );
69086937 m_mapOfCustomAnimationAssociations [ pAnimAssociation ] = pIFPAnimations;
69096938}
69106939
69116940void CClientGame::RemoveAnimationAssociationFromMap ( CAnimBlendAssociationSAInterface * pAnimAssociation )
69126941{
6942+ std::lock_guard < std::mutex > mutexGuardedLock ( m_MutexOfAnimationAssociationsMap );
69136943 m_mapOfCustomAnimationAssociations.erase ( pAnimAssociation );
69146944}
0 commit comments