void CCombatCharVisCache::FrameUpdatePreEntityThink() { // Msg( "test: %d/%d\n", m_nHitCount, m_nTestCount ); // Lazy retirement of vis cache // NOTE: 256 was chosen heuristically based on a playthrough where 200 // was the max # in the viscache where nothing could be retired. if ( m_VisCache.Count() < 256 ) return; int nMaxIndex = m_VisCache.MaxElement() - 1; for ( int i = 0; i < 8; ++i ) { int n = RandomInt( 0, nMaxIndex ); if ( !m_VisCache.IsValidIndex( n ) ) continue; const VisCacheEntry_t &entry = m_VisCache[n]; if ( !entry.m_hEntity1.IsValid() || !entry.m_hEntity2.IsValid() || ( gpGlobals->curtime - entry.m_flTime > 10.0f ) ) { m_VisCache.RemoveAt( n ); } } }