@@ -6845,8 +6845,15 @@ void CClientGame::RestreamModel ( unsigned short usModel )
6845
6845
6846
6846
}
6847
6847
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
+
6848
6854
std::shared_ptr < CClientIFP > CClientGame::GetIFPPointerFromMap ( const unsigned int u32BlockNameHash )
6849
6855
{
6856
+ std::lock_guard < std::mutex > mutexGuardedLock ( m_MutexOfIfpPointersMap );
6850
6857
auto it = m_mapOfIfpPointers.find ( u32BlockNameHash );
6851
6858
if ( it != m_mapOfIfpPointers.end ( ) )
6852
6859
{
@@ -6855,19 +6862,39 @@ std::shared_ptr < CClientIFP > CClientGame::GetIFPPointerFromMap ( const unsigne
6855
6862
return nullptr ;
6856
6863
}
6857
6864
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
+
6858
6884
CClientPed * CClientGame::GetClientPedByClump ( const RpClump & Clump )
6859
6885
{
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++ )
6861
6888
{
6862
- CEntity * pEntity = it-> first ->GetGameEntity ();
6889
+ CEntity * pEntity = (*it) ->GetGameEntity ();
6863
6890
if ( pEntity != nullptr )
6864
6891
{
6865
- if ( pEntity->GetRpClump () != nullptr )
6892
+ if ( pEntity->GetRpClump () != nullptr )
6866
6893
{
6867
6894
const RpClump & entityClump = *pEntity->GetRpClump ();
6868
6895
if ( std::addressof ( entityClump ) == std::addressof ( Clump ) )
6869
6896
{
6870
- return it-> first ;
6897
+ return *it ;
6871
6898
}
6872
6899
}
6873
6900
}
@@ -6877,38 +6904,41 @@ CClientPed * CClientGame::GetClientPedByClump ( const RpClump & Clump )
6877
6904
6878
6905
void CClientGame::OnClientIFPUnload ( const std::shared_ptr < CClientIFP > & IFP )
6879
6906
{
6907
+ std::lock_guard < std::mutex > mutexGuardedLock ( m_MutexOfPedPointersSet );
6880
6908
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++ )
6882
6910
{
6883
6911
// Remove IFP animations from replaced animations of peds/players
6884
- it-> first ->RestoreAnimations ( IFP );
6912
+ (*it) ->RestoreAnimations ( IFP );
6885
6913
6886
6914
// Make sure that streamed in pulses or changing model does not accidently
6887
6915
// play our custom animation. We can do that by making the custom animation
6888
6916
// untriggerable
6889
- if ( it-> first ->GetCustomAnimationBlockNameHash ( ) == IFP->GetBlockNameHash ( ) )
6917
+ if ( (*it) ->GetCustomAnimationBlockNameHash ( ) == IFP->GetBlockNameHash ( ) )
6890
6918
{
6891
- if ( it-> first ->IsCustomAnimationPlaying ( ) )
6919
+ if ( (*it) ->IsCustomAnimationPlaying ( ) )
6892
6920
{
6893
- it-> first ->SetCustomAnimationUntriggerable ( );
6921
+ (*it) ->SetCustomAnimationUntriggerable ( );
6894
6922
}
6895
6923
6896
6924
// Important! As we are using a shared_ptr, we need to decrement the reference counter
6897
6925
// 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 ( ) )
6899
6927
{
6900
- it-> first ->DereferenceCustomAnimationBlock ();
6928
+ (*it) ->DereferenceCustomAnimationBlock ();
6901
6929
}
6902
6930
}
6903
6931
}
6904
6932
}
6905
6933
6906
6934
void CClientGame::InsertAnimationAssociationToMap ( CAnimBlendAssociationSAInterface * pAnimAssociation, const std::shared_ptr < CIFPAnimations > & pIFPAnimations )
6907
6935
{
6936
+ std::lock_guard < std::mutex > mutexGuardedLock ( m_MutexOfAnimationAssociationsMap );
6908
6937
m_mapOfCustomAnimationAssociations [ pAnimAssociation ] = pIFPAnimations;
6909
6938
}
6910
6939
6911
6940
void CClientGame::RemoveAnimationAssociationFromMap ( CAnimBlendAssociationSAInterface * pAnimAssociation )
6912
6941
{
6942
+ std::lock_guard < std::mutex > mutexGuardedLock ( m_MutexOfAnimationAssociationsMap );
6913
6943
m_mapOfCustomAnimationAssociations.erase ( pAnimAssociation );
6914
6944
}
0 commit comments