add CheckSongCacheOnLoad

This commit is contained in:
Glenn Maynard
2003-12-30 04:26:39 +00:00
parent 90980b048d
commit cb8057a5c3
5 changed files with 26 additions and 5 deletions
+3
View File
@@ -95,6 +95,7 @@ PrefsManager::PrefsManager()
m_bTexturePreload = false;
m_bDelayedScreenLoad = false;
m_BannerCache = BNCACHE_LOW_RES;
m_bCheckSongCacheOnLoad = true;
m_MusicWheelUsesSections = ALWAYS;
m_iMusicWheelSwitchSpeed = 10;
m_bEasterEggs = true;
@@ -298,6 +299,7 @@ void PrefsManager::ReadGlobalPrefsFromDisk()
ini.GetValue( "Options", "TexturePreload", m_bTexturePreload );
ini.GetValue( "Options", "DelayedScreenLoad", m_bDelayedScreenLoad );
ini.GetValue( "Options", "BannerCache", (int&)m_BannerCache );
ini.GetValue( "Options", "CheckSongCacheOnLoad", m_bCheckSongCacheOnLoad );
ini.GetValue( "Options", "MusicWheelUsesSections", (int&)m_MusicWheelUsesSections );
ini.GetValue( "Options", "MusicWheelSwitchSpeed", m_iMusicWheelSwitchSpeed );
ini.GetValue( "Options", "SoundDrivers", m_sSoundDrivers );
@@ -463,6 +465,7 @@ void PrefsManager::SaveGlobalPrefsToDisk() const
ini.SetValue( "Options", "TexturePreload", m_bTexturePreload );
ini.SetValue( "Options", "DelayedScreenLoad", m_bDelayedScreenLoad );
ini.SetValue( "Options", "BannerCache", m_BannerCache );
ini.SetValue( "Options", "CheckSongCacheOnLoad", m_bCheckSongCacheOnLoad );
ini.SetValue( "Options", "MusicWheelUsesSections", m_MusicWheelUsesSections );
ini.SetValue( "Options", "MusicWheelSwitchSpeed", m_iMusicWheelSwitchSpeed );
ini.SetValue( "Options", "EasterEggs", m_bEasterEggs );
+1
View File
@@ -48,6 +48,7 @@ public:
bool m_bDelayedScreenLoad;
enum BannerCacheMode { BNCACHE_OFF, BNCACHE_LOW_RES, BNCACHE_FULL };
BannerCacheMode m_BannerCache;
bool m_bCheckSongCacheOnLoad;
bool m_bOnlyDedicatedMenuButtons;
bool m_bMenuTimer;
+15 -4
View File
@@ -189,7 +189,14 @@ NotesLoader *Song::MakeLoader( CString sDir ) const
* pull in <set> into Song.h, which is heavily used. */
static set<istring> BlacklistedImages;
bool Song::LoadFromSongDir( CString sDir, bool bAllowCache )
/*
* If PREFSMAN->m_bCheckSongCacheOnLoad is false, always load from cache if possible.
* Don't load the contents of sDir if we can avoid it. That means we can't call HasMusic(),
* HasBanner() or GetHashForDirectory().
*
* If true, check the directory hash and reload the song from scratch if it's changed.
*/
bool Song::LoadFromSongDir( CString sDir )
{
// LOG->Trace( "Song::LoadFromSongDir(%s)", sDir.c_str() );
ASSERT( sDir != "" );
@@ -212,9 +219,13 @@ bool Song::LoadFromSongDir( CString sDir, bool bAllowCache )
// First look in the cache for this song (without loading NoteData)
//
unsigned uDirHash = SONGINDEX->GetCacheHash(m_sSongDir);
if( bAllowCache &&
GetHashForDirectory(m_sSongDir) == uDirHash && // this cache is up to date
DoesFileExist(GetCacheFilePath()))
bool bUseCache = true;
if( !DoesFileExist(GetCacheFilePath()) )
bUseCache = false;
if( PREFSMAN->m_bCheckSongCacheOnLoad && GetHashForDirectory(m_sSongDir) != uDirHash )
bUseCache = false; // this cache is out of date
if( bUseCache )
{
// LOG->Trace( "Loading '%s' from cache file '%s'.", m_sSongDir.c_str(), GetCacheFilePath().c_str() );
SMLoader ld;
+6
View File
@@ -98,10 +98,16 @@ void SongManager::Reload()
m_sGroupNames.clear();
m_sGroupBannerPaths.clear();
/* Always do m_bCheckSongCacheOnLoad. */
const bool OldVal = PREFSMAN->m_bCheckSongCacheOnLoad;
PREFSMAN->m_bCheckSongCacheOnLoad = true;
InitSongsFromDisk(NULL);
InitCoursesFromDisk(NULL);
InitAutogenCourses();
PROFILEMAN->InitMachineScoresFromDisk();
PREFSMAN->m_bCheckSongCacheOnLoad = OldVal;
}
void SongManager::InitSongsFromDisk( LoadingWindow *ld )
+1 -1
View File
@@ -64,7 +64,7 @@ public:
NotesLoader *MakeLoader( CString sDir ) const;
bool LoadFromSongDir( CString sDir, bool bAllowCache = true );
bool LoadFromSongDir( CString sDir );
void RevertFromDisk();
void TidyUpData(); // call after loading to clean up invalid data