From f2bb1b373f880341ac882d278c462ac2e7a014b2 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sun, 8 May 2005 11:55:56 +0000 Subject: [PATCH] steps locking fixes --- stepmania/src/Song.cpp | 6 +++++- stepmania/src/SongUtil.cpp | 12 +++++++----- stepmania/src/song.h | 2 +- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/stepmania/src/Song.cpp b/stepmania/src/Song.cpp index ad2d5d2e40..fa7a0959b4 100644 --- a/stepmania/src/Song.cpp +++ b/stepmania/src/Song.cpp @@ -23,6 +23,7 @@ #include "NoteDataUtil.h" #include "ProfileManager.h" #include "Foreach.h" +#include "UnlockManager.h" #include "NotesLoaderSM.h" #include "NotesLoaderDWI.h" @@ -931,7 +932,7 @@ Steps* Song::GetStepsByDescription( StepsType st, CString sDescription ) const } -Steps* Song::GetClosestNotes( StepsType st, Difficulty dc ) const +Steps* Song::GetClosestNotes( StepsType st, Difficulty dc, bool bIgnoreLocked ) const { ASSERT( dc != DIFFICULTY_INVALID ); @@ -944,6 +945,9 @@ Steps* Song::GetClosestNotes( StepsType st, Difficulty dc ) const if( pSteps->GetDifficulty() == DIFFICULTY_EDIT && dc != DIFFICULTY_EDIT ) continue; + if( bIgnoreLocked && UNLOCKMAN->StepsIsLocked(this, pSteps) ) + continue; + int iDistance = abs(dc - pSteps->GetDifficulty()); if( iDistance < iClosestDistance ) { diff --git a/stepmania/src/SongUtil.cpp b/stepmania/src/SongUtil.cpp index 452d5da372..f9f1ac99b9 100644 --- a/stepmania/src/SongUtil.cpp +++ b/stepmania/src/SongUtil.cpp @@ -10,6 +10,7 @@ #include "XmlFile.h" #include "PrefsManager.h" #include "Foreach.h" +#include "UnlockManager.h" ///////////////////////////////////// @@ -273,28 +274,28 @@ CString SongUtil::GetSectionNameFromSongAndSort( const Song* pSong, SortOrder so case SORT_EASY_METER: { Steps* pSteps = pSong->GetStepsByDifficulty(GAMESTATE->GetCurrentStyle()->m_StepsType,DIFFICULTY_EASY); - if( pSteps ) + if( pSteps && !UNLOCKMAN->StepsIsLocked(pSong,pSteps) ) return ssprintf("%02d", pSteps->GetMeter() ); return "N/A"; } case SORT_MEDIUM_METER: { Steps* pSteps = pSong->GetStepsByDifficulty(GAMESTATE->GetCurrentStyle()->m_StepsType,DIFFICULTY_MEDIUM); - if( pSteps ) + if( pSteps && !UNLOCKMAN->StepsIsLocked(pSong,pSteps) ) return ssprintf("%02d", pSteps->GetMeter() ); return "N/A"; } case SORT_HARD_METER: { Steps* pSteps = pSong->GetStepsByDifficulty(GAMESTATE->GetCurrentStyle()->m_StepsType,DIFFICULTY_HARD); - if( pSteps ) + if( pSteps && !UNLOCKMAN->StepsIsLocked(pSong,pSteps) ) return ssprintf("%02d", pSteps->GetMeter() ); return "N/A"; } case SORT_CHALLENGE_METER: { Steps* pSteps = pSong->GetStepsByDifficulty(GAMESTATE->GetCurrentStyle()->m_StepsType,DIFFICULTY_CHALLENGE); - if( pSteps ) + if( pSteps && !UNLOCKMAN->StepsIsLocked(pSong,pSteps) ) return ssprintf("%02d", pSteps->GetMeter() ); return "N/A"; } @@ -333,7 +334,8 @@ void SongUtil::SortSongPointerArrayByMeter( vector &vpSongsInOut, Difficu song_sort_val.clear(); for(unsigned i = 0; i < vpSongsInOut.size(); ++i) { - const Steps* pSteps = vpSongsInOut[i]->GetClosestNotes( GAMESTATE->GetCurrentStyle()->m_StepsType, dc ); + /* Ignore locked steps. */ + const Steps* pSteps = vpSongsInOut[i]->GetClosestNotes( GAMESTATE->GetCurrentStyle()->m_StepsType, dc, true ); CString &s = song_sort_val[vpSongsInOut[i]]; s = ssprintf("%03d", pSteps ? pSteps->GetMeter() : 0); diff --git a/stepmania/src/song.h b/stepmania/src/song.h index 3cb18ca7c0..c8db498201 100644 --- a/stepmania/src/song.h +++ b/stepmania/src/song.h @@ -203,7 +203,7 @@ public: Steps* GetStepsByDifficulty( StepsType st, Difficulty dc, bool bIncludeAutoGen = true ) const; Steps* GetStepsByMeter( StepsType st, int iMeterLow, int iMeterHigh ) const; Steps* GetStepsByDescription( StepsType st, CString sDescription ) const; - Steps* GetClosestNotes( StepsType st, Difficulty dc ) const; + Steps* GetClosestNotes( StepsType st, Difficulty dc, bool bIgnoreLocked=false ) const; bool IsEasy( StepsType st ) const; bool IsTutorial() const; bool HasEdits( StepsType st ) const;