Use SONGMAN->FindSong

This commit is contained in:
Glenn Maynard
2003-07-09 05:01:37 +00:00
parent 4602901bbd
commit fc88d69fca
2 changed files with 17 additions and 23 deletions
+14 -19
View File
@@ -17,6 +17,7 @@
#include "RageException.h" #include "RageException.h"
#include "RageUtil.h" #include "RageUtil.h"
#include "UnlockSystem.h" #include "UnlockSystem.h"
#include "SongManager.h"
#include <fstream> #include <fstream>
using namespace std; using namespace std;
@@ -30,36 +31,25 @@ UnlockSystem::UnlockSystem()
bool UnlockSystem::SongIsLocked( const Song *song ) bool UnlockSystem::SongIsLocked( const Song *song )
{ {
return SongIsLocked( song->GetFullTranslitTitle() ); SongEntry *p = FindSong( song );
return p && p->isLocked;
} }
bool UnlockSystem::SongIsRoulette( const Song *song ) 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++) for(unsigned i = 0; i < m_SongEntries.size(); i++)
if (m_SongEntries[i].m_sSongName == sSongName) if (m_SongEntries[i].GetSong() == pSong )
return m_SongEntries[i].isLocked; return &m_SongEntries[i];
return false; 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() SongEntry::SongEntry()
{ {
@@ -270,3 +260,8 @@ float UnlockSystem::NumPointsUntilNextUnlock()
if (fSmallestPoints == 400000000) return 0; // no match found if (fSmallestPoints == 400000000) return 0; // no match found
return fSmallestPoints - PREFSMAN->m_fDancePointsAccumulated; return fSmallestPoints - PREFSMAN->m_fDancePointsAccumulated;
} }
Song *SongEntry::GetSong() const
{
return SONGMAN->FindSong( "", m_sSongName );
}
+2 -3
View File
@@ -44,7 +44,7 @@ struct SongEntry
bool SelectableRoulette(); bool SelectableRoulette();
bool updateLocked(); //updates isLocked flag bool updateLocked(); //updates isLocked flag
Song *GetSong() const;
}; };
class UnlockSystem class UnlockSystem
@@ -70,8 +70,7 @@ public:
private: private:
void SortSongEntriesArray(); // sorts unlocks void SortSongEntriesArray(); // sorts unlocks
bool ParseRow(CString text, CString &type, float &qty, CString &songname); bool ParseRow(CString text, CString &type, float &qty, CString &songname);
bool SongIsLocked( CString sSongName ); SongEntry *FindSong( const Song *pSong );
bool SongIsRoulette( CString sSongName );
}; };