From b0590a0da17d10a69b028028bfa792d2150f68b5 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Fri, 11 Jun 2004 21:13:05 +0000 Subject: [PATCH] clear the trail cache automatically when the round seed changes --- stepmania/src/Course.cpp | 20 ++++++++++++++++++++ stepmania/src/Course.h | 1 + 2 files changed, 21 insertions(+) diff --git a/stepmania/src/Course.cpp b/stepmania/src/Course.cpp index d70f8454a9..b3a6ac444c 100644 --- a/stepmania/src/Course.cpp +++ b/stepmania/src/Course.cpp @@ -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 && iTrace("trail seed changed; regen? %i", bHaveRandom); + if( bHaveRandom ) + ZERO( m_TrailCacheValid ); + + m_iTrailCacheSeed = GAMESTATE->m_iRoundSeed; + } + // // Look in the Trail cache // diff --git a/stepmania/src/Course.h b/stepmania/src/Course.h index c0efc829e6..673f47995a 100644 --- a/stepmania/src/Course.h +++ b/stepmania/src/Course.h @@ -138,6 +138,7 @@ private: mutable Trail m_TrailCache[NUM_STEPS_TYPES][NUM_DIFFICULTIES]; mutable bool m_TrailCacheValid[NUM_STEPS_TYPES][NUM_DIFFICULTIES]; mutable bool m_TrailCacheNull[NUM_STEPS_TYPES][NUM_DIFFICULTIES]; + mutable int m_iTrailCacheSeed; }; #endif