clear the trail cache automatically when the round seed changes

This commit is contained in:
Glenn Maynard
2004-06-11 21:13:05 +00:00
parent c8ec4937ec
commit b0590a0da1
2 changed files with 21 additions and 0 deletions
+20
View File
@@ -268,6 +268,7 @@ void Course::Init()
m_entries.clear();
m_sPath = m_sName = m_sNameTranslit = m_sBannerPath = m_sCDTitlePath = "";
ZERO( m_TrailCacheValid );
m_iTrailCacheSeed = 0;
}
void Course::Save()
@@ -540,6 +541,25 @@ Trail* Course::GetTrail( StepsType st, CourseDifficulty cd ) const
{
ASSERT( cd != DIFFICULTY_INVALID );
//
// Check to see if the Trail cache is out of date
//
if( m_iTrailCacheSeed != GAMESTATE->m_iRoundSeed )
{
/* If we have any random entries (so that the seed matters), invalidate the cache. */
bool bHaveRandom = false;
for( unsigned i=0; !bHaveRandom && i<m_entries.size(); i++ )
if( m_entries[i].type == COURSE_ENTRY_RANDOM ||
m_entries[i].type == COURSE_ENTRY_RANDOM_WITHIN_GROUP )
bHaveRandom = true;
LOG->Trace("trail seed changed; regen? %i", bHaveRandom);
if( bHaveRandom )
ZERO( m_TrailCacheValid );
m_iTrailCacheSeed = GAMESTATE->m_iRoundSeed;
}
//
// Look in the Trail cache
//