diff --git a/stepmania/src/MusicWheel.cpp b/stepmania/src/MusicWheel.cpp index 73913eba53..c41ec8fe4b 100644 --- a/stepmania/src/MusicWheel.cpp +++ b/stepmania/src/MusicWheel.cpp @@ -314,9 +314,8 @@ void MusicWheel::GetSongList(vector &arraySongs, SongSortOrder so, CStrin /* Hide songs that asked to be hidden via #SELECTABLE. */ if( so!=SORT_ROULETTE && !pSong->NormallyDisplayed() ) continue; - if( so==SORT_ROULETTE && !pSong->RouletteDisplayed() ) - continue; - if( so==SORT_ROULETTE && GAMESTATE->m_pUnlockingSys->SongIsRoulette( pSong ) ) + if( so==SORT_ROULETTE && !(pSong->RouletteDisplayed() + || GAMESTATE->m_pUnlockingSys->SongIsRoulette( pSong )) ) continue; } @@ -326,7 +325,7 @@ void MusicWheel::GetSongList(vector &arraySongs, SongSortOrder so, CStrin if( !arraySteps.empty() ) { // If we're using unlocks, check it here to prevent from being shown - if( PREFSMAN->m_bUseUnlockSystem ) + if( PREFSMAN->m_bUseUnlockSystem && so!=SORT_ROULETTE ) { pSong->m_bIsLocked = GAMESTATE->m_pUnlockingSys->SongIsLocked( pSong ); if( pSong->m_bIsLocked ) { continue; } @@ -1109,13 +1108,16 @@ bool MusicWheel::Select() // return true if this selection ends the screen SetOpenGroup(m_sExpandedSectionName); } return false; - case TYPE_ROULETTE: + case TYPE_ROULETTE: StartRoulette(); return false; case TYPE_RANDOM: StartRandom(); return false; case TYPE_SONG: + if (PREFSMAN->m_bUseUnlockSystem) + GAMESTATE->m_pUnlockingSys->RouletteUnlock( m_CurWheelItemData[m_iSelection]->m_pSong ); + // fall-through - we want to check for unlocking only if its a song case TYPE_COURSE: return true; case TYPE_SORT: diff --git a/stepmania/src/UnlockSystem.cpp b/stepmania/src/UnlockSystem.cpp index 80784d8e35..8a9e823580 100644 --- a/stepmania/src/UnlockSystem.cpp +++ b/stepmania/src/UnlockSystem.cpp @@ -28,17 +28,48 @@ UnlockSystem::UnlockSystem() { } +bool UnlockSystem::RouletteUnlock( const Song *song ) +{ + SongEntry *p = FindSong( song ); + if (p->m_iRouletteSeed == 0) return false; // already unlocked + + PREFSMAN->m_RouletteSeeds[p->m_iRouletteSeed] = '1'; + return true; +} + + bool UnlockSystem::SongIsLocked( const Song *song ) { SongEntry *p = FindSong( song ); + + CString tmp; + + if (p) + { + p->updateLocked(); + + if (!p->isLocked) tmp = "un"; + + LOG->Trace( "UnlockSystem entry: %s", (p->m_sSongName).c_str() ); + LOG->Trace( "current status: %slocked", tmp.c_str() ); + } + return p && p->isLocked; } bool UnlockSystem::SongIsRoulette( const Song *song ) { SongEntry *p = FindSong( song ); - return p && p->m_iRouletteSeed != 0; + + CString item; + + if (p && (p->m_iRouletteSeed != 0)) + LOG->Trace("Item %s is roulettable."); + else + LOG->Trace("Item %s is not roulettable."); + + return p && (p->m_iRouletteSeed != 0) ; } SongEntry *UnlockSystem::FindSong( const Song *pSong ) @@ -116,7 +147,7 @@ bool UnlockSystem::ParseRow(CString text, CString &type, float &qty, bool SongEntry::updateLocked() { - if (!isLocked) return true; // if its already true + if (!(isLocked)) return true; // if its already true if (m_fArcadePointsRequired != 0) isLocked = (PREFSMAN->m_fArcadePointsAccumulated < m_fArcadePointsRequired); @@ -140,7 +171,18 @@ bool SongEntry::updateLocked() isLocked = (PREFSMAN->m_fTotalToastysSeen < m_fToastysSeen); if (m_iRouletteSeed != 0) - isLocked = (PREFSMAN->m_RouletteSeeds[m_iRouletteSeed] == '0'); + { + CString tmp = PREFSMAN->m_RouletteSeeds; + + LOG->Trace("Seed in question: %d Roulette seeds: %s", + m_iRouletteSeed, tmp.c_str() ); + isLocked = (tmp[m_iRouletteSeed] != '1'); + + if (isLocked) + LOG->Trace("Song is currently LOCKED"); + else + LOG->Trace("Song is currently UNLOCKED"); + } return !isLocked; } @@ -216,7 +258,7 @@ bool UnlockSystem::LoadFromDATFile( CString sPath ) if (unlock_type == "RO") { current.m_iRouletteSeed = (int)datavalue; - current.isLocked = (PREFSMAN->m_fArcadePointsAccumulated < datavalue); + current.isLocked = ((PREFSMAN->m_RouletteSeeds)[(int)datavalue] != '1'); } m_SongEntries.push_back(current); @@ -225,10 +267,13 @@ bool UnlockSystem::LoadFromDATFile( CString sPath ) sort( m_SongEntries.begin(), m_SongEntries.end(), CompareSongEntries ); for(unsigned i=0; i < m_SongEntries.size(); i++) + { + CString tmp = " "; + if (!m_SongEntries[i].isLocked) tmp = "un"; LOG->Trace( "UnlockSystem entry: %s", m_SongEntries[i].m_sSongName.c_str() ); + LOG->Trace( "Initial status:%slocked", tmp.c_str() ); + } - - return true; } diff --git a/stepmania/src/UnlockSystem.h b/stepmania/src/UnlockSystem.h index 5d7af44606..a8a65a4f96 100644 --- a/stepmania/src/UnlockSystem.h +++ b/stepmania/src/UnlockSystem.h @@ -67,7 +67,7 @@ public: float UnlockFailExtraStage(); float UnlockClearStage(); float UnlockToasty(); - bool UnlockRouletteSeed(int seed); + bool RouletteUnlock( const Song *song ); private: void SortSongEntriesArray(); // sorts unlocks