1616
1717#define CLOTHES_REF_TEST 1 // Debug clothes geometry refs
1818
19+ static constexpr uint DEFAULT_CACHE_TIME = 1000 ;
20+
1921// //////////////////////////////////////////////
2022//
2123// class CPedClothesDesc
@@ -126,7 +128,7 @@ class CClumpStore
126128 {
127129 memset (&m_Stats, 0 , sizeof (m_Stats));
128130 m_uiMaxSize = 4 ;
129- m_uiMinCacheTime = 1000 ;
131+ m_uiMinCacheTime = DEFAULT_CACHE_TIME ;
130132 m_iCacheRevision = 1 ;
131133 }
132134
@@ -138,30 +140,34 @@ class CClumpStore
138140 uint GetNumCached ()
139141 {
140142 uint uiNumCached = 0 ;
141- for (std::vector<SSavedClumpInfo>::iterator iter = savedClumpList.begin (); iter != savedClumpList.end (); ++iter)
143+
144+ if (m_uiMinCacheTime > 0 )
142145 {
143- SSavedClumpInfo& info = *iter;
144- RpGeometry* pGeometry = ((RpAtomic*)((info.pClump ->atomics .root .next ) - 0x8 ))->geometry ;
145- #ifdef CLOTHES_REF_TEST
146- if (pGeometry->refs < 21 )
146+ for (std::vector<SSavedClumpInfo>::iterator iter = savedClumpList.begin (); iter != savedClumpList.end (); ++iter)
147147 {
148- AddReportLog (7521 , SString (" Clothes geometry refs below expected value: %d" , pGeometry->refs ));
149- pGeometry->refs = 21 ;
150- }
151- if (pGeometry->refs == 21 )
148+ SSavedClumpInfo& info = *iter;
149+ RpGeometry* pGeometry = ((RpAtomic*)((info.pClump ->atomics .root .next ) - 0x8 ))->geometry ;
150+ #ifdef CLOTHES_REF_TEST
151+ if (pGeometry->refs < 21 )
152+ {
153+ AddReportLog (7521 , SString (" Clothes geometry refs below expected value: %d" , pGeometry->refs ));
154+ pGeometry->refs = 21 ;
155+ }
156+ if (pGeometry->refs == 21 )
152157#else
153- if (pGeometry->refs == 1 )
158+ if (pGeometry->refs == 1 )
154159#endif
155- {
156- uiNumCached++;
157- if (!info.bUnused )
158160 {
159- info.timeUnused = CTickCount::Now ();
160- info.bUnused = true ;
161+ uiNumCached++;
162+ if (!info.bUnused )
163+ {
164+ info.timeUnused = CTickCount::Now ();
165+ info.bUnused = true ;
166+ }
161167 }
168+ else
169+ info.bUnused = false ;
162170 }
163- else
164- info.bUnused = false ;
165171 }
166172
167173 m_Stats.uiNumTotal = savedClumpList.size ();
@@ -402,6 +408,34 @@ void CMultiplayerSA::GetClothesCacheStats(SClothesCacheStats& outStats)
402408 outStats = ms_clumpStore.m_Stats ;
403409}
404410
411+ // ////////////////////////////////////////////////////////////////////////////////////////
412+ //
413+ // CMultiplayerSA::SetClothingCacheTime
414+ //
415+ //
416+ // ////////////////////////////////////////////////////////////////////////////////////////
417+ bool CMultiplayerSA::SetClothingCacheTime (uint timeInMs)
418+ {
419+ if (timeInMs == ms_clumpStore.m_uiMinCacheTime )
420+ return false ;
421+
422+ ms_clumpStore.savedClumpList .clear ();
423+ ms_clumpStore.m_uiMinCacheTime = timeInMs;
424+
425+ return true ;
426+ }
427+
428+ // ////////////////////////////////////////////////////////////////////////////////////////
429+ //
430+ // CMultiplayerSA::ResetClothingCacheTime
431+ //
432+ //
433+ // ////////////////////////////////////////////////////////////////////////////////////////
434+ void CMultiplayerSA::ResetClothingCacheTime ()
435+ {
436+ SetClothingCacheTime (DEFAULT_CACHE_TIME);
437+ }
438+
405439// ////////////////////////////////////////////////////////////////////////////////////////
406440//
407441// CMultiplayerSA::InitHooks_ClothesCache
0 commit comments