From 0c37abf4000a0da0d574009e9336e3f5dacdfb9e Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Sun, 27 Mar 2005 11:52:04 +0000 Subject: [PATCH] ignore locked and tutorial songs when choosing songs for random CourseEntries --- stepmania/src/CatalogXml.cpp | 5 ++++ stepmania/src/Course.cpp | 56 +++++++++++++++++++++++++----------- stepmania/src/Course.h | 2 ++ 3 files changed, 46 insertions(+), 17 deletions(-) diff --git a/stepmania/src/CatalogXml.cpp b/stepmania/src/CatalogXml.cpp index 09e1b4a8d8..2844b67310 100644 --- a/stepmania/src/CatalogXml.cpp +++ b/stepmania/src/CatalogXml.cpp @@ -92,6 +92,11 @@ void SaveCatalogXml() { Course* pCourse = vpCourses[i]; + // skip non-fixed courses. We don't have any stable data for them other than + // the title. + if( !pCourse->IsFixed() ) + continue; + CourseID courseID; courseID.FromCourse( pCourse ); diff --git a/stepmania/src/Course.cpp b/stepmania/src/Course.cpp index d46b9d23f7..d4c44353ab 100644 --- a/stepmania/src/Course.cpp +++ b/stepmania/src/Course.cpp @@ -19,7 +19,7 @@ #include "ThemeManager.h" #include "ProfileManager.h" #include "Foreach.h" - +#include "UnlockManager.h" #include /* Amount to increase meter ranges to make them difficult: */ @@ -74,8 +74,10 @@ void Course::LoadFromCRSFile( CString sPath ) sPath = sCacheFile.c_str(); } else + { LOG->Trace( "Course::LoadFromCRSFile(\"%s\")", sPath.c_str() ); - + } + MsdFile msd; if( !msd.ReadFile(sPath) ) RageException::Throw( "Error opening CRS file '%s'.", sPath.c_str() ); @@ -298,18 +300,7 @@ void Course::LoadFromCRSFile( CString sPath ) * don't have to do it at runtime. */ if( !bUseCache ) { - FOREACH_StepsType( st ) - { - FOREACH_CourseDifficulty( cd ) - { - Trail *pTrail = GetTrail( st, cd ); - if( pTrail == NULL ) - continue; - - RadarValues rv = pTrail->GetRadarValues(); - m_RadarCache[CacheEntry(st, cd)] = rv; - } - } + CalculateRadarValues(); /* If we have any cache data, write the cache file. */ if( m_RadarCache.size() ) @@ -871,9 +862,17 @@ bool Course::GetTrailUnsorted( StepsType st, CourseDifficulty cd, Trail &trail ) ASSERT( pSong ); CurSong = (CurSong+1) % AllSongsShuffled.size(); - if(e.type == COURSE_ENTRY_RANDOM_WITHIN_GROUP && - pSong->m_sGroupName.CompareNoCase(e.group_name)) - continue; /* wrong group */ + // Ignore locked songs when choosing randomly + if( UNLOCKMAN->SongIsLocked(pSong) ) + continue; + + // Ignore boring tutorial songs + if( pSong->IsTutorial() ) + continue; + + if( e.type == COURSE_ENTRY_RANDOM_WITHIN_GROUP && + pSong->m_sGroupName.CompareNoCase(e.group_name)) + continue; /* wrong group */ if( e.difficulty == DIFFICULTY_INVALID ) pSteps = pSong->GetStepsByMeter( st, low_meter, high_meter ); @@ -1254,6 +1253,29 @@ bool Course::ShowInDemonstrationAndRanking() const return true; } +void Course::CalculateRadarValues() +{ + FOREACH_StepsType( st ) + { + FOREACH_CourseDifficulty( cd ) + { + // For courses that aren't fixed, the radar values are meaningless. + // Makes non-fixed courses have unknown radar values. + if( IsFixed() ) + { + Trail *pTrail = GetTrail( st, cd ); + if( pTrail == NULL ) + continue; + RadarValues rv = pTrail->GetRadarValues(); + m_RadarCache[CacheEntry(st, cd)] = rv; + } + else + { + m_RadarCache[CacheEntry(st, cd)] = RadarValues(); + } + } + } +} // lua start #include "LuaBinding.h" diff --git a/stepmania/src/Course.h b/stepmania/src/Course.h index 5f44a0c9b8..03d2b738ef 100644 --- a/stepmania/src/Course.h +++ b/stepmania/src/Course.h @@ -161,6 +161,8 @@ public: void PushSelf( lua_State *L ); private: + void CalculateRadarValues(); + bool GetTrailUnsorted( StepsType st, CourseDifficulty cd, Trail &trail ) const; bool GetTrailSorted( StepsType st, CourseDifficulty cd, Trail &trail ) const;