diff --git a/stepmania/src/NotesLoaderSM.cpp b/stepmania/src/NotesLoaderSM.cpp index 8c2704f184..92dc859dae 100644 --- a/stepmania/src/NotesLoaderSM.cpp +++ b/stepmania/src/NotesLoaderSM.cpp @@ -115,11 +115,27 @@ bool SMLoader::LoadFromSMFile( CString sPath, Song &out ) else if( 0==stricmp(sValueName,"MUSICLENGTH") ) out.m_fMusicLengthSeconds = (float)atof( sParams[1] ); + /* We calculate these. Some SMs in circulation have bogus values for + * these, so make sure we always calculate it ourself. */ else if( 0==stricmp(sValueName,"FIRSTBEAT") ) + { + if(!FromCache) + { + LOG->Trace("Ignored #FIRSTBEAT (cache only)"); + continue; + } out.m_fFirstBeat = (float)atof( sParams[1] ); + } else if( 0==stricmp(sValueName,"LASTBEAT") ) + { + if(!FromCache) + { + LOG->Trace("Ignored #LASTBEAT (cache only)"); + continue; + } out.m_fLastBeat = (float)atof( sParams[1] ); + } else if( 0==stricmp(sValueName,"SAMPLESTART") ) out.m_fMusicSampleStartSeconds = TimeToSeconds( sParams[1] ); diff --git a/stepmania/src/NotesLoaderSM.h b/stepmania/src/NotesLoaderSM.h index 59bae42543..0478a1caa7 100644 --- a/stepmania/src/NotesLoaderSM.h +++ b/stepmania/src/NotesLoaderSM.h @@ -15,8 +15,16 @@ class SMLoader: public NotesLoader { CString sNoteData, Notes &out); + bool FromCache; + public: + SMLoader() { FromCache = false; } bool LoadFromSMFile( CString sPath, Song &out ); + bool LoadFromSMFile( CString sPath, Song &out, bool cache ) + { + FromCache=cache; + return LoadFromSMFile( sPath, out ); + } void GetApplicableFiles( CString sPath, CStringArray &out ); bool LoadFromDir( CString sPath, Song &out ); diff --git a/stepmania/src/Song.cpp b/stepmania/src/Song.cpp index 3e5a9ac790..960d56abb3 100644 --- a/stepmania/src/Song.cpp +++ b/stepmania/src/Song.cpp @@ -313,7 +313,7 @@ bool Song::LoadFromSongDir( CString sDir ) { // LOG->Trace( "Loading '%s' from cache file '%s'.", m_sSongDir.GetString(), GetCacheFilePath().GetString() ); SMLoader ld; - ld.LoadFromSMFile( GetCacheFilePath(), *this ); + ld.LoadFromSMFile( GetCacheFilePath(), *this, true ); } else {