From fc88d69fca58bb4e940091321e969d7b0fc7d221 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Wed, 9 Jul 2003 05:01:37 +0000 Subject: [PATCH] Use SONGMAN->FindSong --- stepmania/src/UnlockSystem.cpp | 35 +++++++++++++++------------------- stepmania/src/UnlockSystem.h | 5 ++--- 2 files changed, 17 insertions(+), 23 deletions(-) diff --git a/stepmania/src/UnlockSystem.cpp b/stepmania/src/UnlockSystem.cpp index b36d0eb786..a901a330bb 100644 --- a/stepmania/src/UnlockSystem.cpp +++ b/stepmania/src/UnlockSystem.cpp @@ -17,6 +17,7 @@ #include "RageException.h" #include "RageUtil.h" #include "UnlockSystem.h" +#include "SongManager.h" #include using namespace std; @@ -30,36 +31,25 @@ UnlockSystem::UnlockSystem() bool UnlockSystem::SongIsLocked( const Song *song ) { - return SongIsLocked( song->GetFullTranslitTitle() ); + SongEntry *p = FindSong( song ); + return p && p->isLocked; } bool UnlockSystem::SongIsRoulette( const Song *song ) { - return SongIsRoulette( song->GetFullTranslitTitle() ); + SongEntry *p = FindSong( song ); + return p && p->m_iRouletteSeed != 0; } -bool UnlockSystem::SongIsLocked( CString sSongName ) +SongEntry *UnlockSystem::FindSong( const Song *pSong ) { - sSongName.MakeUpper(); //Avoid case-sensitive problems - - // searches for song in unlock list for(unsigned i = 0; i < m_SongEntries.size(); i++) - if (m_SongEntries[i].m_sSongName == sSongName) - return m_SongEntries[i].isLocked; - - return false; + if (m_SongEntries[i].GetSong() == pSong ) + return &m_SongEntries[i]; + + return NULL; } -bool UnlockSystem::SongIsRoulette( CString sSongName ) -{ - sSongName.MakeUpper(); //Avoid case-sensitive problems - - for(unsigned i = 0; i < m_SongEntries.size(); i++) - if (m_SongEntries[i].m_sSongName == sSongName) - return (m_SongEntries[i].m_iRouletteSeed != 0); - - return false; -} SongEntry::SongEntry() { @@ -270,3 +260,8 @@ float UnlockSystem::NumPointsUntilNextUnlock() if (fSmallestPoints == 400000000) return 0; // no match found return fSmallestPoints - PREFSMAN->m_fDancePointsAccumulated; } + +Song *SongEntry::GetSong() const +{ + return SONGMAN->FindSong( "", m_sSongName ); +} diff --git a/stepmania/src/UnlockSystem.h b/stepmania/src/UnlockSystem.h index 0acfa19005..372ed8d157 100644 --- a/stepmania/src/UnlockSystem.h +++ b/stepmania/src/UnlockSystem.h @@ -44,7 +44,7 @@ struct SongEntry bool SelectableRoulette(); bool updateLocked(); //updates isLocked flag - + Song *GetSong() const; }; class UnlockSystem @@ -70,8 +70,7 @@ public: private: void SortSongEntriesArray(); // sorts unlocks bool ParseRow(CString text, CString &type, float &qty, CString &songname); - bool SongIsLocked( CString sSongName ); - bool SongIsRoulette( CString sSongName ); + SongEntry *FindSong( const Song *pSong ); };