diff --git a/src/Banner.cpp b/src/Banner.cpp index 57faff90af..fbe0a02f71 100644 --- a/src/Banner.cpp +++ b/src/Banner.cpp @@ -9,7 +9,6 @@ #include "ThemeMetric.h" #include "CharacterManager.h" #include "ActorUtil.h" -#include "UnlockManager.h" #include "PrefsManager.h" REGISTER_ACTOR_CLASS( Banner ); @@ -147,30 +146,6 @@ void Banner::LoadIconFromCharacter( const Character *pCharacter ) m_bScrolling = false; } -void Banner::LoadBannerFromUnlockEntry( const UnlockEntry* pUE ) -{ - if( pUE == NULL ) - LoadFallback(); - else - { - RString sFile = pUE->GetBannerFile(); - Load( sFile ); - m_bScrolling = false; - } -} - -void Banner::LoadBackgroundFromUnlockEntry( const UnlockEntry* pUE ) -{ - if( pUE == NULL ) - LoadFallback(); - else - { - RString sFile = pUE->GetBackgroundFile(); - Load( sFile ); - m_bScrolling = false; - } -} - void Banner::LoadFallback() { Load( THEME->GetPathG("Common","fallback banner") ); @@ -254,18 +229,6 @@ class LunaBanner: public Luna else { Character *pC = Luna::check(L,1); p->LoadIconFromCharacter( pC ); } COMMON_RETURN_SELF; } - static int LoadBannerFromUnlockEntry( T* p, lua_State *L ) - { - if( lua_isnil(L,1) ) { p->LoadBannerFromUnlockEntry( NULL ); } - else { UnlockEntry *pUE = Luna::check(L,1); p->LoadBannerFromUnlockEntry( pUE ); } - COMMON_RETURN_SELF; - } - static int LoadBackgroundFromUnlockEntry( T* p, lua_State *L ) - { - if( lua_isnil(L,1) ) { p->LoadBackgroundFromUnlockEntry( NULL ); } - else { UnlockEntry *pUE = Luna::check(L,1); p->LoadBackgroundFromUnlockEntry( pUE ); } - COMMON_RETURN_SELF; - } static int LoadFromSongGroup( T* p, lua_State *L ) { p->LoadFromSongGroup( SArg(1) ); @@ -293,8 +256,6 @@ class LunaBanner: public Luna ADD_METHOD( LoadFromCachedBanner ); ADD_METHOD( LoadIconFromCharacter ); ADD_METHOD( LoadCardFromCharacter ); - ADD_METHOD( LoadBannerFromUnlockEntry ); - ADD_METHOD( LoadBackgroundFromUnlockEntry ); ADD_METHOD( LoadFromSongGroup ); ADD_METHOD( LoadFromSortOrder ); ADD_METHOD( GetScrolling ); diff --git a/src/Banner.h b/src/Banner.h index 4dee740244..4751916620 100644 --- a/src/Banner.h +++ b/src/Banner.h @@ -8,7 +8,6 @@ #include "GameConstantsAndTypes.h" class Song; class Character; -class UnlockEntry; /** @brief The characteristics of a Banner */ class Banner : public Sprite @@ -33,8 +32,6 @@ class Banner : public Sprite void LoadFromSongGroup( const RString &sSongGroup ); void LoadCardFromCharacter( const Character *pCharacter ); void LoadIconFromCharacter( const Character *pCharacter ); - void LoadBannerFromUnlockEntry( const UnlockEntry* pUE ); - void LoadBackgroundFromUnlockEntry( const UnlockEntry* pUE ); void LoadRoulette(); void LoadRandom(); void LoadFromSortOrder( SortOrder so ); diff --git a/src/FadingBanner.cpp b/src/FadingBanner.cpp index 693d1f8fa5..c6db394380 100644 --- a/src/FadingBanner.cpp +++ b/src/FadingBanner.cpp @@ -199,12 +199,6 @@ void FadingBanner::LoadIconFromCharacter( Character* pCharacter ) m_Banner[m_iIndexLatest].LoadIconFromCharacter( pCharacter ); } -void FadingBanner::LoadBannerFromUnlockEntry( const UnlockEntry* pUE ) -{ - BeforeChange(); - m_Banner[m_iIndexLatest].LoadBannerFromUnlockEntry( pUE ); -} - void FadingBanner::LoadRoulette() { BeforeChange(); diff --git a/src/FadingBanner.h b/src/FadingBanner.h index 0741748425..85e787e536 100644 --- a/src/FadingBanner.h +++ b/src/FadingBanner.h @@ -22,7 +22,6 @@ class FadingBanner : public ActorFrame void LoadMode(); void LoadFromSongGroup( const RString &sSongGroup ); void LoadIconFromCharacter( Character* pCharacter ); - void LoadBannerFromUnlockEntry( const UnlockEntry* pUE ); void LoadRoulette(); void LoadRandom(); void LoadFromSortOrder( SortOrder so ); diff --git a/src/GameCommand.cpp b/src/GameCommand.cpp index bb7320a9f0..d98c5d4922 100644 --- a/src/GameCommand.cpp +++ b/src/GameCommand.cpp @@ -18,7 +18,6 @@ #include "PlayerState.h" #include "SongManager.h" #include "Song.h" -#include "UnlockManager.h" #include "LocalizedString.h" #include "arch/ArchHooks/ArchHooks.h" #include "ScreenPrompt.h" @@ -549,27 +548,6 @@ bool GameCommand::IsPlayable( RString *why ) const return false; } } - - if( !m_sPreferredModifiers.empty() ) - { - // TODO: Split this and check each modifier individually - if( UNLOCKMAN->ModifierIsLocked(m_sPreferredModifiers) ) - { if( why ) - *why = "Modifier is locked"; - return false; - } - } - - if( !m_sStageModifiers.empty() ) - { - // TODO: Split this and check each modifier individually - if( UNLOCKMAN->ModifierIsLocked(m_sStageModifiers) ) - { if( why ) - *why = "Modifier is locked"; - return false; - } - } - return true; } diff --git a/src/GameConstantsAndTypes.cpp b/src/GameConstantsAndTypes.cpp index ea90d1700a..2ed674e57d 100644 --- a/src/GameConstantsAndTypes.cpp +++ b/src/GameConstantsAndTypes.cpp @@ -324,7 +324,6 @@ LuaXType( TapNoteScoreJudgeType ); static const char *ProfileSlotNames[] = { "Player1", "Player2", - "Machine", }; XToString( ProfileSlot ); LuaXType( ProfileSlot ); diff --git a/src/GameConstantsAndTypes.h b/src/GameConstantsAndTypes.h index 6c626c18c7..b0a9151a43 100644 --- a/src/GameConstantsAndTypes.h +++ b/src/GameConstantsAndTypes.h @@ -333,7 +333,6 @@ enum ProfileSlot { ProfileSlot_Player1, ProfileSlot_Player2, - ProfileSlot_Machine, NUM_ProfileSlot, ProfileSlot_Invalid }; diff --git a/src/GameState.cpp b/src/GameState.cpp index ee03201b2c..93cdbd289d 100644 --- a/src/GameState.cpp +++ b/src/GameState.cpp @@ -35,7 +35,6 @@ #include "Steps.h" #include "Style.h" #include "ThemeManager.h" -#include "UnlockManager.h" #include "ScreenManager.h" #include "Screen.h" @@ -392,12 +391,6 @@ void GameState::JoinPlayer( PlayerNumber pn ) if( GetNumSidesJoined() == 1 ) BeginGame(); - // Count each player join as a play. - { - Profile* pMachineProfile = PROFILEMAN->GetMachineProfile(); - pMachineProfile->m_iTotalSessions++; - } - // Set the current style to something appropriate for the new number of joined players. // beat gametype's versus styles use a different stepstype from its single // styles, so when GameCommand tries to join both players for a versus @@ -653,7 +646,6 @@ bool GameState::HaveProfileToSave() void GameState::SaveLocalData() { BOOKKEEPER->WriteToDisk(); - PROFILEMAN->SaveMachineProfile(); } int GameState::GetNumStagesMultiplierForSong( const Song* pSong ) @@ -758,9 +750,6 @@ void GameState::CommitStageStats() // Update TotalPlaySeconds. int iPlaySeconds = max( 0, (int) m_timeGameStarted.GetDeltaTime() ); - Profile* pMachineProfile = PROFILEMAN->GetMachineProfile(); - pMachineProfile->m_iTotalSessionSeconds += iPlaySeconds; - FOREACH_HumanPlayer( p ) { Profile* pPlayerProfile = PROFILEMAN->GetProfile( p ); @@ -814,7 +803,6 @@ void GameState::FinishStage() if( iOldStageIndex/iSaveProfileEvery < m_iCurrentStageIndex/iSaveProfileEvery ) { LOG->Trace( "Played %i stages; saving profiles ...", iSaveProfileEvery ); - PROFILEMAN->SaveMachineProfile(); this->SavePlayerProfiles(); } } @@ -1842,33 +1830,6 @@ void GameState::GetRankingFeats( PlayerNumber pn, vector &asFeatsOu Song* pSong = vSongAndSteps[i].pSong; Steps* pSteps = vSongAndSteps[i].pSteps; - // Find Machine Records - { - HighScoreList &hsl = PROFILEMAN->GetMachineProfile()->GetStepsHighScoreList(pSong,pSteps); - for( unsigned j=0; jGetTranslitMainTitle().c_str(), DifficultyToString(pSteps->GetDifficulty()).c_str() ); - feat.pStringToFill = hs.GetNameMutable(); - feat.grade = hs.GetGrade(); - feat.fPercentDP = hs.GetPercentDP(); - feat.iScore = hs.GetScore(); - - if( pSong->HasBanner() ) - feat.Banner = pSong->GetBannerPath(); - - asFeatsOut.push_back( feat ); - } - } - // Find Personal Records if( pProf && PROFILE_RECORD_FEATS ) { @@ -1906,30 +1867,6 @@ void GameState::GetRankingFeats( PlayerNumber pn, vector &asFeatsOu StageStats stats; STATSMAN->GetFinalEvalStageStats( stats ); - - // Find Machine Category Records - FOREACH_ENUM( RankingCategory, rc ) - { - if( !CATEGORY_RECORD_FEATS ) - continue; - HighScoreList &hsl = PROFILEMAN->GetMachineProfile()->GetCategoryHighScoreList( st, rc ); - for( unsigned j=0; jGetMachineProfile(); - - if( !PREFSMAN->m_bAllowMultipleHighScoreWithSameName ) - { - // erase all but the highest score for each name - FOREACHM( SongID, Profile::HighScoresForASong, pProfile->m_SongHighScores, iter ) - FOREACHM( StepsID, Profile::HighScoresForASteps, iter->second.m_StepsHighScores, iter2 ) - iter2->second.hsl.RemoveAllButOneOfEachName(); - } - - // clamp high score sizes - FOREACHM( SongID, Profile::HighScoresForASong, pProfile->m_SongHighScores, iter ) - FOREACHM( StepsID, Profile::HighScoresForASteps, iter->second.m_StepsHighScores, iter2 ) - iter2->second.hsl.ClampSize( true ); } bool GameState::AllAreInDangerOrWorse() const diff --git a/src/MusicWheel.cpp b/src/MusicWheel.cpp index bf19e7d37c..6403955e86 100644 --- a/src/MusicWheel.cpp +++ b/src/MusicWheel.cpp @@ -11,7 +11,6 @@ #include "NetworkSyncManager.h" #include "Song.h" #include "Steps.h" -#include "UnlockManager.h" #include "GameCommand.h" #include "ActorUtil.h" #include "SongUtil.h" @@ -408,25 +407,6 @@ void MusicWheel::GetSongList( vector &arraySongs, SortOrder so ) { Song* pSong = apAllSongs[i]; - int iLocked = UNLOCKMAN->SongIsLocked( pSong ); - if( iLocked & LOCKED_DISABLED ) - continue; - - // If we're on an extra stage, and this song is selected, ignore #SELECTABLE. - if( pSong != GAMESTATE->m_pCurSong || !GAMESTATE->IsAnExtraStage() ) - { - // Hide songs that asked to be hidden via #SELECTABLE. - if( iLocked & LOCKED_SELECTABLE ) - continue; - if( so != SORT_ROULETTE && iLocked & LOCKED_ROULETTE ) - continue; - } - - /* Hide locked songs. If RANDOM_PICKS_LOCKED_SONGS, hide in Roulette - * and Random, too. */ - if( (so!=SORT_ROULETTE || !RANDOM_PICKS_LOCKED_SONGS) && iLocked ) - continue; - if( PREFSMAN->m_bOnlyPreferredDifficulties ) { // if the song has steps that fit the preferred difficulty of the default player @@ -737,8 +717,7 @@ void MusicWheel::BuildWheelItemDatas( vector &arrayWheelIt SongUtil::SortSongPointerArrayByGenre( arraySongs ); break; case SORT_RECENT: - SongUtil::SortByMostRecentlyPlayedForMachine( arraySongs ); - if( (int) arraySongs.size() > RECENT_SONGS_TO_SHOW ) + if( static_cast(arraySongs.size()) > RECENT_SONGS_TO_SHOW ) arraySongs.erase( arraySongs.begin()+RECENT_SONGS_TO_SHOW, arraySongs.end() ); bUseSections = false; break; @@ -988,37 +967,6 @@ void MusicWheel::FilterWheelItemDatas(vector &aUnFilteredD continue; } - int iLocked = UNLOCKMAN->SongIsLocked( pSong ); - if( iLocked & LOCKED_DISABLED ) - { - aiRemove[i] = true; - continue; - } - - /* If we're on an extra stage, and this song is selected, ignore #SELECTABLE. */ - if( pSong != GAMESTATE->m_pCurSong || !GAMESTATE->IsAnExtraStage() ) - { - /* Hide songs that asked to be hidden via #SELECTABLE. */ - if( iLocked & LOCKED_SELECTABLE ) - { - aiRemove[i] = true; - continue; - } - if( so != SORT_ROULETTE && iLocked & LOCKED_ROULETTE ) - { - aiRemove[i] = true; - continue; - } - } - - /* Hide locked songs. If RANDOM_PICKS_LOCKED_SONGS, hide in Roulette and Random, - * too. */ - if( (so!=SORT_ROULETTE || !RANDOM_PICKS_LOCKED_SONGS) && iLocked ) - { - aiRemove[i] = true; - continue; - } - /* If the song has no steps for the current style, remove it. */ if( !CommonMetrics::AUTO_SET_STYLE && !pSong->HasStepsType(GAMESTATE->GetCurrentStyle(PLAYER_INVALID)->m_StepsType) ) { diff --git a/src/MusicWheelItem.cpp b/src/MusicWheelItem.cpp index 89d6cb875b..7eb4bda73b 100644 --- a/src/MusicWheelItem.cpp +++ b/src/MusicWheelItem.cpp @@ -316,8 +316,6 @@ void MusicWheelItem::RefreshGrades() ProfileSlot ps; if( PROFILEMAN->IsPersistentProfile(p) ) ps = (ProfileSlot)p; - else if( GRADES_SHOW_MACHINE ) - ps = ProfileSlot_Machine; else continue; diff --git a/src/NotesWriterSM.cpp b/src/NotesWriterSM.cpp index fe00c46493..2a1dbab167 100644 --- a/src/NotesWriterSM.cpp +++ b/src/NotesWriterSM.cpp @@ -307,46 +307,6 @@ RString NotesWriterSM::GetEditFileName( const Song *pSong, const Steps *pSteps ) static LocalizedString DESTINATION_ALREADY_EXISTS ("NotesWriterSM", "Error renaming file. Destination file '%s' already exists."); static LocalizedString ERROR_WRITING_FILE ("NotesWriterSM", "Error writing file '%s'."); -bool NotesWriterSM::WriteEditFileToMachine( const Song *pSong, Steps *pSteps, RString &sErrorOut ) -{ - RString sDir = PROFILEMAN->GetProfileDir( ProfileSlot_Machine ) + EDIT_STEPS_SUBDIR; - - RString sPath = sDir + GetEditFileName(pSong,pSteps); - - // Check to make sure that we're not clobering an existing file before opening. - bool bFileNameChanging = - pSteps->GetSavedToDisk() && - pSteps->GetFilename() != sPath; - if( bFileNameChanging && DoesFileExist(sPath) ) - { - sErrorOut = ssprintf( DESTINATION_ALREADY_EXISTS.GetValue(), sPath.c_str() ); - return false; - } - - RageFile f; - if( !f.Open(sPath, RageFile::WRITE | RageFile::SLOW_FLUSH) ) - { - sErrorOut = ssprintf( ERROR_WRITING_FILE.GetValue(), sPath.c_str() ); - return false; - } - - RString sTag; - GetEditFileContents( pSong, pSteps, sTag ); - if( f.PutLine(sTag) == -1 || f.Flush() == -1 ) - { - sErrorOut = ssprintf( ERROR_WRITING_FILE.GetValue(), sPath.c_str() ); - return false; - } - - /* If the file name of the edit has changed since the last save, then delete the old - * file after saving the new one. If we delete it first, then we'll lose data on error. */ - - if( bFileNameChanging ) - FILEMAN->Remove( pSteps->GetFilename() ); - pSteps->SetFilename( sPath ); - - return true; -} /* * (c) 2001-2004 Chris Danford, Glenn Maynard diff --git a/src/NotesWriterSSC.cpp b/src/NotesWriterSSC.cpp index bdb3677545..8eeb5565df 100644 --- a/src/NotesWriterSSC.cpp +++ b/src/NotesWriterSSC.cpp @@ -528,46 +528,6 @@ RString NotesWriterSSC::GetEditFileName( const Song *pSong, const Steps *pSteps static LocalizedString DESTINATION_ALREADY_EXISTS ("NotesWriterSSC", "Error renaming file. Destination file '%s' already exists."); static LocalizedString ERROR_WRITING_FILE ("NotesWriterSSC", "Error writing file '%s'."); -bool NotesWriterSSC::WriteEditFileToMachine( const Song *pSong, Steps *pSteps, RString &sErrorOut ) -{ - RString sDir = PROFILEMAN->GetProfileDir( ProfileSlot_Machine ) + EDIT_STEPS_SUBDIR; - - RString sPath = sDir + GetEditFileName(pSong,pSteps); - - // Check to make sure that we're not clobering an existing file before opening. - bool bFileNameChanging = - pSteps->GetSavedToDisk() && - pSteps->GetFilename() != sPath; - if( bFileNameChanging && DoesFileExist(sPath) ) - { - sErrorOut = ssprintf( DESTINATION_ALREADY_EXISTS.GetValue(), sPath.c_str() ); - return false; - } - - RageFile f; - if( !f.Open(sPath, RageFile::WRITE | RageFile::SLOW_FLUSH) ) - { - sErrorOut = ssprintf( ERROR_WRITING_FILE.GetValue(), sPath.c_str() ); - return false; - } - - RString sTag; - GetEditFileContents( pSong, pSteps, sTag ); - if( f.PutLine(sTag) == -1 || f.Flush() == -1 ) - { - sErrorOut = ssprintf( ERROR_WRITING_FILE.GetValue(), sPath.c_str() ); - return false; - } - - /* If the file name of the edit has changed since the last save, then delete the old - * file after saving the new one. If we delete it first, then we'll lose data on error. */ - - if( bFileNameChanging ) - FILEMAN->Remove( pSteps->GetFilename() ); - pSteps->SetFilename( sPath ); - - return true; -} /* * (c) 2011 Jason Felds diff --git a/src/OptionRowHandler.cpp b/src/OptionRowHandler.cpp index 1ada5ed2d0..e70bc54877 100644 --- a/src/OptionRowHandler.cpp +++ b/src/OptionRowHandler.cpp @@ -441,7 +441,6 @@ class OptionRowHandlerListSteps : public OptionRowHandlerList vector vpSteps; Song *pSong = GAMESTATE->m_pCurSong; SongUtil::GetSteps( pSong, vpSteps, GAMESTATE->GetCurrentStyle(GAMESTATE->GetMasterPlayerNumber())->m_StepsType ); - StepsUtil::RemoveLockedSteps( pSong, vpSteps ); StepsUtil::SortNotesArrayByDifficulty( vpSteps ); for( unsigned i=0; i SHOW_COIN_DATA( "Profile", "ShowCoinData" ); static Preference g_bProfileDataCompress( "ProfileDataCompress", false ); -static ThemeMetric UNLOCK_AUTH_STRING( "Profile", "UnlockAuthString" ); #define GUID_SIZE_BYTES 8 #define MAX_EDITABLE_INI_SIZE_BYTES 2*1024 // 2KB @@ -128,7 +126,6 @@ void Profile::InitGeneralData() m_iNumExtraStagesPassed = 0; m_iNumExtraStagesFailed = 0; m_iNumToasties = 0; - m_UnlockedEntryIDs.clear(); m_sLastPlayedMachineGuid = ""; m_LastPlayedDate.Init(); m_iTotalTapsAndHolds = 0; @@ -214,9 +211,6 @@ int Profile::GetTotalStepsWithTopGrade( StepsType st, Difficulty d, Grade g ) co FOREACH_CONST( Song*, SONGMAN->GetAllSongs(), pSong ) { - if( !(*pSong)->NormallyDisplayed() ) - continue; // skip - FOREACH_CONST( Steps*, (*pSong)->GetAllSteps(), pSteps ) { if( (*pSteps)->m_StepsType != st ) @@ -246,9 +240,6 @@ float Profile::GetSongsPossible( StepsType st, Difficulty dc ) const for( unsigned i=0; iNormallyDisplayed() ) - continue; // skip vector vSteps = pSong->GetAllSteps(); for( unsigned j=0; jNormallyDisplayed() ) - continue; // skip - CHECKPOINT_M( ssprintf("Profile::GetSongsActual: song %s", pSong->GetSongDir().c_str()) ); const HighScoresForASong &hsfas = i->second; @@ -380,12 +368,6 @@ void Profile::SetDefaultModifiers( const Game* pGameType, const RString &sModifi m_sDefaultModifiers[pGameType->m_szName] = sModifiers; } -bool Profile::IsCodeUnlocked( const RString &sUnlockEntryID ) const -{ - return m_UnlockedEntryIDs.find( sUnlockEntryID ) != m_UnlockedEntryIDs.end(); -} - - Song *Profile::GetMostPopularSong() const { int iMaxNumTimesPlayed = 0; @@ -406,7 +388,7 @@ Song *Profile::GetMostPopularSong() const // Steps high scores void Profile::AddStepsHighScore( const Song* pSong, const Steps* pSteps, HighScore hs, int &iIndexOut ) { - GetStepsHighScoreList(pSong,pSteps).AddHighScore( hs, iIndexOut, IsMachine() ); + GetStepsHighScoreList(pSong,pSteps).AddHighScore( hs, iIndexOut, false ); } const HighScoreList& Profile::GetStepsHighScoreList( const Song* pSong, const Steps* pSteps ) const @@ -611,7 +593,7 @@ void Profile::MergeScoresFromOtherProfile(Profile* other, bool skip_totals, } \ else \ { \ - this_sub->second.hsl.MergeFromOtherHSL(sub_entry->second.hsl, IsMachine()); \ + this_sub->second.hsl.MergeFromOtherHSL(sub_entry->second.hsl, false); \ } \ } \ } \ @@ -626,32 +608,29 @@ void Profile::MergeScoresFromOtherProfile(Profile* other, bool skip_totals, // In the case where two local profiles are being merged together, the user // is probably planning to delete the old profile after the merge, so we // want to copy the screenshots over. -Kyz - if(!IsMachine()) - { - // The old screenshot count is stored so we know where to start in the - // list when copying the screenshot images. - size_t old_count= m_vScreenshots.size(); - m_vScreenshots.insert(m_vScreenshots.end(), - other->m_vScreenshots.begin(), other->m_vScreenshots.end()); - for(size_t sid= old_count; sid < m_vScreenshots.size(); ++sid) + // The old screenshot count is stored so we know where to start in the + // list when copying the screenshot images. + size_t old_count = m_vScreenshots.size(); + m_vScreenshots.insert(m_vScreenshots.end(), + other->m_vScreenshots.begin(), other->m_vScreenshots.end()); + for (size_t sid = old_count; sid < m_vScreenshots.size(); ++sid) + { + RString old_path = from_dir + "Screenshots/" + m_vScreenshots[sid].sFileName; + RString new_path = to_dir + "Screenshots/" + m_vScreenshots[sid].sFileName; + // Only move the old screenshot over if it exists and won't stomp an + // existing screenshot. + if (FILEMAN->DoesFileExist(old_path) && (!FILEMAN->DoesFileExist(new_path))) { - RString old_path= from_dir + "Screenshots/" + m_vScreenshots[sid].sFileName; - RString new_path= to_dir + "Screenshots/" + m_vScreenshots[sid].sFileName; - // Only move the old screenshot over if it exists and won't stomp an - // existing screenshot. - if(FILEMAN->DoesFileExist(old_path) && (!FILEMAN->DoesFileExist(new_path))) - { - FILEMAN->Move(old_path, new_path); - } + FILEMAN->Move(old_path, new_path); } - // The screenshots are kept sorted by date for ease of use, and - // duplicates are removed because they come from the user mistakenly - // merging a second time. -Kyz - std::sort(m_vScreenshots.begin(), m_vScreenshots.end()); - vector::iterator unique_end= - std::unique(m_vScreenshots.begin(), m_vScreenshots.end()); - m_vScreenshots.erase(unique_end, m_vScreenshots.end()); } + // The screenshots are kept sorted by date for ease of use, and + // duplicates are removed because they come from the user mistakenly + // merging a second time. -Kyz + std::sort(m_vScreenshots.begin(), m_vScreenshots.end()); + vector::iterator unique_end = + std::unique(m_vScreenshots.begin(), m_vScreenshots.end()); + m_vScreenshots.erase(unique_end, m_vScreenshots.end()); } void Profile::swap(Profile& other) @@ -686,7 +665,6 @@ void Profile::swap(Profile& other) SWAP_GENERAL(m_iTotalHands); SWAP_GENERAL(m_iTotalLifts); SWAP_GENERAL(m_bNewProfile); - SWAP_STR_MEMBER(m_UnlockedEntryIDs); SWAP_STR_MEMBER(m_sLastPlayedMachineGuid); SWAP_GENERAL(m_LastPlayedDate); SWAP_ARRAY(m_iNumSongsPlayedByPlayMode, NUM_PlayMode); @@ -711,7 +689,7 @@ void Profile::swap(Profile& other) // Category high scores void Profile::AddCategoryHighScore( StepsType st, RankingCategory rc, HighScore hs, int &iIndexOut ) { - m_CategoryHighScores[st][rc].AddHighScore( hs, iIndexOut, IsMachine() ); + m_CategoryHighScores[st][rc].AddHighScore( hs, iIndexOut, false ); } const HighScoreList& Profile::GetCategoryHighScoreList( StepsType st, RankingCategory rc ) const @@ -890,17 +868,6 @@ ProfileLoadResult Profile::LoadStatsFromDir(RString dir, bool require_signature) pFile.reset(pInflate); } - // Don't load unreasonably large stats.xml files. - if(!IsMachine()) // only check stats coming from the player - { - int iBytes = pFile->GetFileSize(); - if(iBytes > 5 * MAX_PLAYER_STATS_XML_SIZE_BYTES) - { - LuaHelpers::ReportScriptErrorFmt("The file '%s' is unreasonably large. It won't be loaded.", fn.c_str()); - return ProfileLoadResult_FailedTampered; - } - } - if(require_signature) { RString sStatsXmlSigFile = fn+SIGNATURE_APPEND; @@ -1059,7 +1026,6 @@ ProfileLoadResult Profile::LoadEttXmlFromNode(const XNode *xml) { bool Profile::SaveAllToDir( const RString &sDir, bool bSignData ) const { - m_sLastPlayedMachineGuid = PROFILEMAN->GetMachineProfile()->m_sGuid; m_LastPlayedDate = DateTime::GetNowDate(); SaveTypeToDir(sDir); @@ -1107,8 +1073,6 @@ XNode *Profile::SaveStatsXmlCreateNode() const xml->AppendChild( SaveSongScoresCreateNode() ); xml->AppendChild( SaveCategoryScoresCreateNode() ); xml->AppendChild( SaveScreenshotDataCreateNode() ); - if( SHOW_COIN_DATA.GetValue() && IsMachine() ) - xml->AppendChild( SaveCoinDataCreateNode() ); return xml; } @@ -1253,9 +1217,6 @@ XNode* Profile::SaveGeneralDataCreateNode() const pGeneralDataNode->AppendChild( "DisplayName", GetDisplayNameOrHighScoreName() ); pGeneralDataNode->AppendChild( "CharacterID", m_sCharacterID ); pGeneralDataNode->AppendChild( "LastUsedHighScoreName", m_sLastUsedHighScoreName ); - - pGeneralDataNode->AppendChild( "IsMachine", IsMachine() ); - pGeneralDataNode->AppendChild( "Guid", m_sGuid ); pGeneralDataNode->AppendChild( "SortOrder", SortOrderToString(m_SortOrder) ); pGeneralDataNode->AppendChild( "LastDifficulty", DifficultyToString(m_LastDifficulty) ); @@ -1303,21 +1264,6 @@ XNode* Profile::SaveGeneralDataCreateNode() const pPlayerSkillsets->AppendChild(SkillsetToString(ss), m_fPlayerSkillsets[ss]); } - { - XNode* pUnlocks = pGeneralDataNode->AppendChild("Unlocks"); - FOREACHS_CONST( RString, m_UnlockedEntryIDs, it ) - { - XNode *pEntry = pUnlocks->AppendChild("UnlockEntry"); - RString sUnlockEntry = it->c_str(); - pEntry->AppendAttr( "UnlockEntryID", sUnlockEntry ); - if( !UNLOCK_AUTH_STRING.GetValue().empty() ) - { - RString sUnlockAuth = BinaryToHex( CRYPTMAN->GetMD5ForString(sUnlockEntry + UNLOCK_AUTH_STRING.GetValue()) ); - pEntry->AppendAttr( "Auth", sUnlockAuth ); - } - } - } - { XNode* pNumSongsPlayedByPlayMode = pGeneralDataNode->AppendChild("NumSongsPlayedByPlayMode"); FOREACH_ENUM( PlayMode, pm ) @@ -1387,7 +1333,7 @@ XNode* Profile::SaveGeneralDataCreateNode() const } // Load Lua UserTable from profile - if( !IsMachine() && m_UserTable.IsSet() ) + if( m_UserTable.IsSet() ) { Lua *L = LUA->Get(); m_UserTable.PushSelf( L ); @@ -1503,32 +1449,6 @@ void Profile::LoadGeneralDataFromNode( const XNode* pNode ) } } - { - const XNode* pUnlocks = pNode->GetChild("Unlocks"); - if( pUnlocks ) - { - FOREACH_CONST_Child( pUnlocks, unlock ) - { - RString sUnlockEntryID; - if( !unlock->GetAttrValue("UnlockEntryID",sUnlockEntryID) ) - continue; - - if( !UNLOCK_AUTH_STRING.GetValue().empty() ) - { - RString sUnlockAuth; - if( !unlock->GetAttrValue("Auth", sUnlockAuth) ) - continue; - - RString sExpectedUnlockAuth = BinaryToHex( CRYPTMAN->GetMD5ForString(sUnlockEntryID + UNLOCK_AUTH_STRING.GetValue()) ); - if( sUnlockAuth != sExpectedUnlockAuth ) - continue; - } - - m_UnlockedEntryIDs.insert( sUnlockEntryID ); - } - } - } - { const XNode* pNumSongsPlayedByPlayMode = pNode->GetChild("NumSongsPlayedByPlayMode"); if( pNumSongsPlayedByPlayMode ) @@ -1587,22 +1507,18 @@ void Profile::LoadGeneralDataFromNode( const XNode* pNode ) } - // Build the custom data table from the existing XNode. - if( !IsMachine() ) - { - const XNode *pUserTable = pNode->GetChild( "UserTable" ); + const XNode *pUserTable = pNode->GetChild("UserTable"); - Lua *L = LUA->Get(); + Lua *L = LUA->Get(); - // If we have custom data, load it. Otherwise, make a blank table. - if( pUserTable ) - LuaHelpers::CreateTableFromXNode( L, pUserTable ); - else - lua_newtable( L ); + // If we have custom data, load it. Otherwise, make a blank table. + if (pUserTable) + LuaHelpers::CreateTableFromXNode(L, pUserTable); + else + lua_newtable(L); - m_UserTable.SetFromStack( L ); - LUA->Release( L ); - } + m_UserTable.SetFromStack(L); + LUA->Release(L); } @@ -2073,12 +1989,6 @@ const Profile::HighScoresForASong *Profile::GetHighScoresForASong( const SongID& return &it->second; } -bool Profile::IsMachine() const -{ - // TODO: Think of a better way to handle this - return this == PROFILEMAN->GetMachineProfile(); -} - XNode* Profile::SaveCoinDataCreateNode() const { @@ -2283,7 +2193,6 @@ class LunaProfile : public Luna static int GetCharacter(T* p, lua_State *L) { p->GetCharacter()->PushSelf(L); return 1; } static int SetCharacter(T* p, lua_State *L) { p->SetCharacter(SArg(1)); COMMON_RETURN_SELF; } static int GetTotalNumSongsPlayed(T* p, lua_State *L) { lua_pushnumber(L, p->m_iNumTotalSongsPlayed); return 1; } - static int IsCodeUnlocked(T* p, lua_State *L) { lua_pushboolean(L, p->IsCodeUnlocked(SArg(1))); return 1; } static int GetSongsActual(T* p, lua_State *L) { lua_pushnumber(L, p->GetSongsActual(Enum::Check(L, 1), Enum::Check(L, 2))); return 1; } static int GetSongsPossible(T* p, lua_State *L) { lua_pushnumber(L, p->GetSongsPossible(Enum::Check(L, 1), Enum::Check(L, 2))); return 1; } static int GetSongsPercentComplete(T* p, lua_State *L) { lua_pushnumber(L, p->GetSongsPercentComplete(Enum::Check(L, 1), Enum::Check(L, 2))); return 1; } @@ -2388,7 +2297,6 @@ class LunaProfile : public Luna ADD_METHOD( GetCharacter ); ADD_METHOD( SetCharacter ); ADD_METHOD( GetTotalNumSongsPlayed ); - ADD_METHOD( IsCodeUnlocked ); ADD_METHOD( GetSongsActual ); ADD_METHOD( GetSongsPossible ); ADD_METHOD( GetSongsPercentComplete ); diff --git a/src/Profile.h b/src/Profile.h index b0f2ba3aea..1bfd774e1f 100644 --- a/src/Profile.h +++ b/src/Profile.h @@ -131,7 +131,7 @@ class Profile m_iNumToasties(0), m_iTotalTapsAndHolds(0), m_iTotalJumps(0), m_iTotalHolds(0), m_iTotalRolls(0), m_iTotalMines(0), m_iTotalHands(0), m_iTotalLifts(0), m_bNewProfile(false), - m_UnlockedEntryIDs(), m_sLastPlayedMachineGuid(""), + m_sLastPlayedMachineGuid(""), m_LastPlayedDate(),m_iNumSongsPlayedByStyle(), m_iNumTotalSongsPlayed(0), m_UserTable(), m_SongHighScores(), m_vScreenshots(), @@ -169,14 +169,11 @@ class Profile float GetSongsAndCoursesPercentCompleteAllDifficulties( StepsType st ) const; bool GetDefaultModifiers( const Game* pGameType, RString &sModifiersOut ) const; void SetDefaultModifiers( const Game* pGameType, const RString &sModifiers ); - bool IsCodeUnlocked( const RString &sUnlockEntryID ) const; Song *GetMostPopularSong() const; void AddStepTotals( int iNumTapsAndHolds, int iNumJumps, int iNumHolds, int iNumRolls, int iNumMines, int iNumHands, int iNumLifts ); - bool IsMachine() const; - ProfileType m_Type; // Profiles of the same type and priority are sorted by dir name. int m_ListPriority; @@ -223,8 +220,6 @@ class Profile // seriously why is this not a thing -mina string profiledir; bool IsEtternaProfile; - - set m_UnlockedEntryIDs; /** * @brief Which machine did we play on last, based on the Guid? * diff --git a/src/ProfileManager.cpp b/src/ProfileManager.cpp index 94c30e6a70..19de7e9172 100644 --- a/src/ProfileManager.cpp +++ b/src/ProfileManager.cpp @@ -44,7 +44,6 @@ Preference1D ProfileManager::m_sDefaultLocalProfileID( DefaultLocalProf const RString NEW_MEM_CARD_NAME = ""; const RString USER_PROFILES_DIR = "/Save/LocalProfiles/"; -const RString MACHINE_PROFILE_DIR = "/Save/MachineProfile/"; const RString LAST_GOOD_SUBDIR = "LastGood/"; @@ -76,10 +75,8 @@ static ThemeMetric NUM_FIXED_PROFILES ( "ProfileManager", "NumFixedProfile ProfileManager::ProfileManager() :m_stats_prefix("") { - m_pMachineProfile = new Profile; FOREACH_PlayerNumber(pn) - m_pMemoryCardProfile[pn] = new Profile; - + m_pMemoryCardProfile[pn] = new Profile; // Register with Lua. { Lua *L = LUA->Get(); @@ -95,7 +92,6 @@ ProfileManager::~ProfileManager() // Unregister with Lua. LUA->UnsetGlobal( "PROFILEMAN" ); - SAFE_DELETE( m_pMachineProfile ); FOREACH_PlayerNumber(pn) SAFE_DELETE( m_pMemoryCardProfile[pn] ); } @@ -111,8 +107,6 @@ void ProfileManager::Init() m_bNewProfile[p] = false; } - LoadMachineProfile(); - RefreshLocalProfilesFromDisk(); if( FIXED_PROFILES ) @@ -661,37 +655,6 @@ bool ProfileManager::DeleteLocalProfile( const RString &sProfileID ) return false; } -void ProfileManager::SaveMachineProfile() const -{ - // If the machine name has changed, make sure we use the new name. - // It's important that this name be applied before the Player profiles - // are saved, so that the Player's profiles show the right machine name. - const_cast (this)->m_pMachineProfile->m_sDisplayName = PREFSMAN->m_sMachineName; - - m_pMachineProfile->SaveAllToDir( MACHINE_PROFILE_DIR, false ); /* don't sign machine profiles */ -} - -void ProfileManager::LoadMachineProfile() -{ - ProfileLoadResult lr = m_pMachineProfile->LoadAllFromDir(MACHINE_PROFILE_DIR, false); - if( lr == ProfileLoadResult_FailedNoProfile ) - { - m_pMachineProfile->InitAll(); - m_pMachineProfile->SaveAllToDir( MACHINE_PROFILE_DIR, false ); /* don't sign machine profiles */ - } - - // If the machine name has changed, make sure we use the new name - m_pMachineProfile->m_sDisplayName = PREFSMAN->m_sMachineName; - - LoadMachineProfileEdits(); -} - -void ProfileManager::LoadMachineProfileEdits() -{ - SONGMAN->FreeAllLoadedFromProfile( ProfileSlot_Machine ); - SONGMAN->LoadStepEditsFromProfileDir( MACHINE_PROFILE_DIR, ProfileSlot_Machine ); -} - bool ProfileManager::ProfileWasLoadedFromMemoryCard( PlayerNumber pn ) const { return !m_sProfileDir[pn].empty() && m_bWasLoadedFromMemoryCard[pn]; @@ -719,8 +682,6 @@ const RString& ProfileManager::GetProfileDir( ProfileSlot slot ) const case ProfileSlot_Player1: case ProfileSlot_Player2: return m_sProfileDir[slot]; - case ProfileSlot_Machine: - return MACHINE_PROFILE_DIR; default: FAIL_M("Invalid profile slot chosen: unable to get the directory!"); } @@ -733,8 +694,6 @@ RString ProfileManager::GetProfileDirImportedFrom( ProfileSlot slot ) const case ProfileSlot_Player1: case ProfileSlot_Player2: return m_sProfileDirImportedFrom[slot]; - case ProfileSlot_Machine: - return RString(); default: FAIL_M("Invalid profile slot chosen: unable to get the directory!"); } @@ -747,8 +706,6 @@ const Profile* ProfileManager::GetProfile( ProfileSlot slot ) const case ProfileSlot_Player1: case ProfileSlot_Player2: return GetProfile( (PlayerNumber)slot ); - case ProfileSlot_Machine: - return m_pMachineProfile; default: FAIL_M("Invalid profile slot chosen: unable to get the profile!"); } @@ -766,17 +723,6 @@ void ProfileManager::MergeLocalProfiles(RString const& from_id, RString const& t LocalProfileIDToDir(from_id), LocalProfileIDToDir(to_id)); } -void ProfileManager::MergeLocalProfileIntoMachine(RString const& from_id, bool skip_totals) -{ - Profile* from= GetLocalProfile(from_id); - if(from == NULL) - { - return; - } - GetMachineProfile()->MergeScoresFromOtherProfile(from, skip_totals, - LocalProfileIDToDir(from_id), MACHINE_PROFILE_DIR); -} - void ProfileManager::ChangeProfileType(int index, ProfileType new_type) { if(index < 0 || static_cast(index) >= g_vLocalProfile.size()) @@ -836,14 +782,12 @@ void ProfileManager::IncrementToastiesCount( PlayerNumber pn ) { if( IsPersistentProfile(pn) ) ++GetProfile(pn)->m_iNumToasties; - ++GetMachineProfile()->m_iNumToasties; } void ProfileManager::AddStepTotals( PlayerNumber pn, int iNumTapsAndHolds, int iNumJumps, int iNumHolds, int iNumRolls, int iNumMines, int iNumHands, int iNumLifts) { if( IsPersistentProfile(pn) ) GetProfile(pn)->AddStepTotals( iNumTapsAndHolds, iNumJumps, iNumHolds, iNumRolls, iNumMines, iNumHands, iNumLifts); - GetMachineProfile()->AddStepTotals( iNumTapsAndHolds, iNumJumps, iNumHolds, iNumRolls, iNumMines, iNumHands, iNumLifts); } // @@ -882,29 +826,12 @@ void ProfileManager::AddStepsScore( const Song* pSong, const Steps* pSteps, Play // if( IsPersistentProfile(pn) ) GetProfile(pn)->AddStepsHighScore( pSong, pSteps, hs, iPersonalIndexOut ); - - // don't save machine scores for a failed song - if( hs.GetPercentDP() >= PREFSMAN->m_fMinPercentageForMachineSongHighScore && - hs.GetGrade() != Grade_Failed ) - { - // don't leave machine high scores for edits loaded from the player's card - if( !pSteps->IsAPlayerEdit() ) - GetMachineProfile()->AddStepsHighScore( pSong, pSteps, hs, iMachineIndexOut ); - } - - /* - // save recent score - if( IsPersistentProfile(pn) ) - GetProfile(pn)->SaveStepsRecentScore( pSong, pSteps, hs ); - GetMachineProfile()->SaveStepsRecentScore( pSong, pSteps, hs ); - */ } void ProfileManager::IncrementStepsPlayCount( const Song* pSong, const Steps* pSteps, PlayerNumber pn ) { if( IsPersistentProfile(pn) ) GetProfile(pn)->IncrementStepsPlayCount( pSong, pSteps ); - GetMachineProfile()->IncrementStepsPlayCount( pSong, pSteps ); } // Category stats @@ -914,15 +841,12 @@ void ProfileManager::AddCategoryScore( StepsType st, RankingCategory rc, PlayerN hs.SetName( RANKING_TO_FILL_IN_MARKER[pn] ); if( IsPersistentProfile(pn) ) GetProfile(pn)->AddCategoryHighScore( st, rc, hs, iPersonalIndexOut ); - if( hs.GetPercentDP() > PREFSMAN->m_fMinPercentageForMachineSongHighScore ) - GetMachineProfile()->AddCategoryHighScore( st, rc, hs, iMachineIndexOut ); } void ProfileManager::IncrementCategoryPlayCount( StepsType st, RankingCategory rc, PlayerNumber pn ) { if( IsPersistentProfile(pn) ) GetProfile(pn)->IncrementCategoryPlayCount( st, rc ); - GetMachineProfile()->IncrementCategoryPlayCount( st, rc ); } bool ProfileManager::IsPersistentProfile( ProfileSlot slot ) const @@ -932,8 +856,6 @@ bool ProfileManager::IsPersistentProfile( ProfileSlot slot ) const case ProfileSlot_Player1: case ProfileSlot_Player2: return GAMESTATE->IsHumanPlayer((PlayerNumber)slot) && !m_sProfileDir[slot].empty(); - case ProfileSlot_Machine: - return true; default: FAIL_M("Invalid profile slot chosen: unable to get profile info!"); } @@ -998,7 +920,6 @@ void ProfileManager::SetStatsPrefix(RString const& prefix) GetProfile(pn)->HandleStatsPrefixChange(m_sProfileDir[pn], PREFSMAN->m_bSignProfileData); } } - m_pMachineProfile->HandleStatsPrefixChange(MACHINE_PROFILE_DIR, false); } // lua start @@ -1021,8 +942,6 @@ class LunaProfileManager: public Luna } static int IsPersistentProfile( T* p, lua_State *L ) { lua_pushboolean(L, p->IsPersistentProfile(Enum::Check(L, 1)) ); return 1; } static int GetProfile( T* p, lua_State *L ) { PlayerNumber pn = Enum::Check(L, 1); Profile* pP = p->GetProfile(pn); ASSERT(pP != NULL); pP->PushSelf(L); return 1; } - static int GetMachineProfile( T* p, lua_State *L ) { p->GetMachineProfile()->PushSelf(L); return 1; } - static int SaveMachineProfile( T* p, lua_State * ) { p->SaveMachineProfile(); return 0; } static int GetLocalProfile( T* p, lua_State *L ) { Profile *pProfile = p->GetLocalProfile(SArg(1)); @@ -1101,8 +1020,6 @@ class LunaProfileManager: public Luna ADD_METHOD(SetStatsPrefix); ADD_METHOD( IsPersistentProfile ); ADD_METHOD( GetProfile ); - ADD_METHOD( GetMachineProfile ); - ADD_METHOD( SaveMachineProfile ); ADD_METHOD( GetLocalProfile ); ADD_METHOD( GetLocalProfileFromIndex ); ADD_METHOD( GetLocalProfileIDFromIndex ); diff --git a/src/ProfileManager.h b/src/ProfileManager.h index 966e6c3107..ab82dc6a93 100644 --- a/src/ProfileManager.h +++ b/src/ProfileManager.h @@ -54,7 +54,6 @@ class ProfileManager void UnloadProfile( PlayerNumber pn ); void MergeLocalProfiles(RString const& from_id, RString const& to_id); - void MergeLocalProfileIntoMachine(RString const& from_id, bool skip_totals); void ChangeProfileType(int index, ProfileType new_type); void MoveProfilePriority(int index, bool up); @@ -62,11 +61,6 @@ class ProfileManager void IncrementToastiesCount( PlayerNumber pn ); void AddStepTotals( PlayerNumber pn, int iNumTapsAndHolds, int iNumJumps, int iNumHolds, int iNumRolls, int iNumMines, int iNumHands, int iNumLifts); - // High scores - void LoadMachineProfile(); // including edits - void LoadMachineProfileEdits(); - void SaveMachineProfile() const; - bool IsPersistentProfile( PlayerNumber pn ) const { return !m_sProfileDir[pn].empty(); } bool IsPersistentProfile( ProfileSlot slot ) const; @@ -79,8 +73,6 @@ class ProfileManager const RString& GetProfileDir( ProfileSlot slot ) const; RString GetProfileDirImportedFrom( ProfileSlot slot ) const; - Profile* GetMachineProfile() { return m_pMachineProfile; } - RString GetPlayerName( PlayerNumber pn ) const; bool ProfileWasLoadedFromMemoryCard( PlayerNumber pn ) const; bool ProfileFromMemoryCardIsNew( PlayerNumber pn ) const; @@ -89,7 +81,7 @@ class ProfileManager // Song stats int GetSongNumTimesPlayed( const Song* pSong, ProfileSlot card ) const; - bool IsSongNew( const Song* pSong ) const { return GetSongNumTimesPlayed(pSong,ProfileSlot_Machine)==0; } + bool IsSongNew( const Song* pSong ) const { return GetSongNumTimesPlayed(pSong,ProfileSlot_Player1)==0; } void AddStepsScore( const Song* pSong, const Steps* pSteps , PlayerNumber pn, const HighScore &hs, int &iPersonalIndexOut, int &iMachineIndexOut ); void IncrementStepsPlayCount( const Song* pSong, const Steps* pSteps, PlayerNumber pn ); @@ -126,7 +118,6 @@ class ProfileManager bool m_bNewProfile[NUM_PLAYERS]; Profile *m_pMemoryCardProfile[NUM_PLAYERS]; // holds Profile for the currently inserted card - Profile *m_pMachineProfile; }; extern ProfileManager* PROFILEMAN; // global and accessible from anywhere in our program diff --git a/src/ScreenBookkeeping.cpp b/src/ScreenBookkeeping.cpp index d03857a19e..f2833e0fe7 100644 --- a/src/ScreenBookkeeping.cpp +++ b/src/ScreenBookkeeping.cpp @@ -10,7 +10,6 @@ #include "LocalizedString.h" #include "Song.h" #include "SongManager.h" -#include "UnlockManager.h" #include "ProfileManager.h" #include "Profile.h" @@ -143,15 +142,13 @@ void ScreenBookkeeping::UpdateView() { case BookkeepingView_SongPlays: { - Profile *pProfile = PROFILEMAN->GetMachineProfile(); + Profile *pProfile = PROFILEMAN->GetProfile(PLAYER_1); vector vpSongs; int iCount = 0; FOREACH_CONST( Song *, SONGMAN->GetAllSongs(), s ) { Song *pSong = *s; - if( UNLOCKMAN->SongIsLocked(pSong) & ~LOCKED_DISABLED ) - continue; iCount += pProfile->GetSongNumTimesPlayed( pSong ); vpSongs.push_back( pSong ); } diff --git a/src/ScreenDebugOverlay.cpp b/src/ScreenDebugOverlay.cpp index b0824989ad..555183148f 100644 --- a/src/ScreenDebugOverlay.cpp +++ b/src/ScreenDebugOverlay.cpp @@ -796,11 +796,9 @@ class DebugLineShowMasks : public IDebugLine } }; -static ProfileSlot g_ProfileSlot = ProfileSlot_Machine; +static ProfileSlot g_ProfileSlot = ProfileSlot_Player1; static bool IsSelectProfilePersistent() { - if( g_ProfileSlot == ProfileSlot_Machine ) - return true; return PROFILEMAN->IsPersistentProfile( (PlayerNumber) g_ProfileSlot ); } @@ -811,7 +809,6 @@ class DebugLineProfileSlot : public IDebugLine { switch( g_ProfileSlot ) { - case ProfileSlot_Machine: return "Machine"; case ProfileSlot_Player1: return "Player 1"; case ProfileSlot_Player2: return "Player 2"; default: return RString(); @@ -887,9 +884,7 @@ static void FillProfileStats( Profile *pProfile ) s_iCount = (s_iCount+1)%2; - int iCount = pProfile->IsMachine()? - PREFSMAN->m_iMaxHighScoresPerListForMachine.Get(): - PREFSMAN->m_iMaxHighScoresPerListForPlayer.Get(); + int iCount = PREFSMAN->m_iMaxHighScoresPerListForPlayer.Get(); vector vpAllSongs = SONGMAN->GetAllSongs(); FOREACH( Song*, vpAllSongs, pSong ) @@ -1123,19 +1118,12 @@ class DebugLineWriteProfiles : public IDebugLine virtual RString GetDisplayValue() { return RString(); } virtual bool IsEnabled() { return IsSelectProfilePersistent(); } virtual RString GetPageName() const { return "Profiles"; } - virtual void DoAndLog( RString &sMessageOut ) + virtual void DoAndLog(RString &sMessageOut) { - // Also save bookkeeping and profile info for debugging - // so we don't have to play through a whole song to get new output. - if( g_ProfileSlot == ProfileSlot_Machine ) - GAMESTATE->SaveLocalData(); - else - { - PlayerNumber pn = (PlayerNumber) g_ProfileSlot; - GAMESTATE->SaveCurrentSettingsToProfile(pn); - GAMESTATE->SavePlayerProfile( pn ); - } - IDebugLine::DoAndLog( sMessageOut ); + PlayerNumber pn = (PlayerNumber)g_ProfileSlot; + GAMESTATE->SaveCurrentSettingsToProfile(pn); + GAMESTATE->SavePlayerProfile(pn); + IDebugLine::DoAndLog(sMessageOut); } }; diff --git a/src/ScreenGameplay.cpp b/src/ScreenGameplay.cpp index dc6a453c1f..e9df9c45ce 100644 --- a/src/ScreenGameplay.cpp +++ b/src/ScreenGameplay.cpp @@ -31,7 +31,6 @@ #include "CombinedLifeMeterTug.h" #include "Inventory.h" #include "NoteDataUtil.h" -#include "UnlockManager.h" #include "ProfileManager.h" #include "StatsManager.h" #include "PlayerAI.h" // for NUM_SKILL_LEVELS diff --git a/src/ScreenOptionsManageProfiles.cpp b/src/ScreenOptionsManageProfiles.cpp index c508b5c547..ba16099dd2 100644 --- a/src/ScreenOptionsManageProfiles.cpp +++ b/src/ScreenOptionsManageProfiles.cpp @@ -329,12 +329,8 @@ void ScreenOptionsManageProfiles::HandleScreenMessage( const ScreenMessage SM ) } break; case ProfileAction_MergeToMachine: - PROFILEMAN->MergeLocalProfileIntoMachine( - GetLocalProfileIDWithFocus(), false); break; case ProfileAction_MergeToMachineSkipTotal: - PROFILEMAN->MergeLocalProfileIntoMachine( - GetLocalProfileIDWithFocus(), true); break; case ProfileAction_MergeToP1: PROFILEMAN->MergeLocalProfiles(GetLocalProfileIDWithFocus(), diff --git a/src/ScreenOptionsToggleSongs.cpp b/src/ScreenOptionsToggleSongs.cpp index f3b42b6aed..e9552ad15f 100644 --- a/src/ScreenOptionsToggleSongs.cpp +++ b/src/ScreenOptionsToggleSongs.cpp @@ -5,7 +5,6 @@ #include "ScreenManager.h" #include "Song.h" #include "SongManager.h" -#include "UnlockManager.h" #include "PrefsManager.h" #include "MessageManager.h" @@ -79,9 +78,6 @@ void ScreenOptionsToggleSongsSubPage::BeginScreen() FOREACH_CONST( Song *, apAllSongs , s ) { Song *pSong = *s; - if( UNLOCKMAN->SongIsLocked(pSong) & ~LOCKED_DISABLED ) - continue; - vHands.push_back( OptionRowHandlerUtil::MakeNull() ); OptionRowDefinition &def = vHands.back()->m_Def; diff --git a/src/ScreenRanking.cpp b/src/ScreenRanking.cpp index c84ade7d98..f2b36f3715 100644 --- a/src/ScreenRanking.cpp +++ b/src/ScreenRanking.cpp @@ -204,40 +204,6 @@ float ScreenRanking::SetPage(const PageToShow &pts) { m_textCategory.SetText(ssprintf("Type %c", 'A' + pts.category)); - for (int l = 0; lGetMachineProfile()->GetCategoryHighScoreList(st, pts.category); - HighScore hs; - bool bRecentHighScore = false; - if (l < (int)hsl.vHighScores.size()) - { - hs = hsl.vHighScores[l]; - RString *psName = hsl.vHighScores[l].GetNameMutable(); - bRecentHighScore = find(GAMESTATE->m_vpsNamesThatWereFilled.begin(), GAMESTATE->m_vpsNamesThatWereFilled.end(), psName) != GAMESTATE->m_vpsNamesThatWereFilled.end(); - } - else - { - hs.SetName(NO_SCORE_NAME); - } - - m_textNames[l].SetText(hs.GetDisplayName()); - m_textScores[l].SetText(ssprintf("%09i", hs.GetScore())); - m_textNames[l].SetDiffuseColor(STEPS_TYPE_COLOR.GetValue(pts.colorIndex)); - m_textScores[l].SetDiffuseColor(STEPS_TYPE_COLOR.GetValue(pts.colorIndex)); - - if (bRecentHighScore) - { - m_textNames[l].SetEffectGlowBlink(0.1f, RageColor(1, 1, 1, 0.2f), RageColor(1, 1, 1, 0.8f)); - m_textScores[l].SetEffectGlowBlink(0.1f, RageColor(1, 1, 1, 0.2f), RageColor(1, 1, 1, 0.8f)); - } - else - { - m_textNames[l].StopEffect(); - m_textScores[l].StopEffect(); - } - } } return SECONDS_PER_PAGE; return SECONDS_PER_PAGE; diff --git a/src/ScreenSelectMusic.cpp b/src/ScreenSelectMusic.cpp index 25a909a58e..3e402ad746 100644 --- a/src/ScreenSelectMusic.cpp +++ b/src/ScreenSelectMusic.cpp @@ -1480,7 +1480,7 @@ void ScreenSelectMusic::AfterStepsOrTrailChange( const vector &vpn int iScore = 0; if( pSteps ) { - const Profile *pProfile = PROFILEMAN->IsPersistentProfile(pn) ? PROFILEMAN->GetProfile(pn) : PROFILEMAN->GetMachineProfile(); + const Profile *pProfile = PROFILEMAN->GetProfile(pn); iScore = pProfile->GetStepsHighScoreList(pSong,pSteps).GetTopScore().GetScore(); } diff --git a/src/ScreenServiceAction.cpp b/src/ScreenServiceAction.cpp index 0e311ccba9..70b582dbd0 100644 --- a/src/ScreenServiceAction.cpp +++ b/src/ScreenServiceAction.cpp @@ -26,37 +26,7 @@ static RString ClearBookkeepingData() } static LocalizedString MACHINE_STATS_CLEARED( "ScreenServiceAction", "Machine stats cleared." ); -RString ClearMachineStats() -{ - Profile* pProfile = PROFILEMAN->GetMachineProfile(); - pProfile->ClearStats(); - PROFILEMAN->SaveMachineProfile(); - return MACHINE_STATS_CLEARED.GetValue(); -} - static LocalizedString MACHINE_EDITS_CLEARED( "ScreenServiceAction", "%d edits cleared, %d errors." ); -static RString ClearMachineEdits() -{ - int iNumAttempted = 0; - int iNumSuccessful = 0; - - vector vsEditFiles; - GetDirListing( PROFILEMAN->GetProfileDir(ProfileSlot_Machine)+EDIT_STEPS_SUBDIR+"*.edit", vsEditFiles, false, true ); - FOREACH_CONST( RString, vsEditFiles, i ) - { - iNumAttempted++; - bool bSuccess = FILEMAN->Remove( *i ); - if( bSuccess ) - iNumSuccessful++; - } - - // reload the machine profile - PROFILEMAN->SaveMachineProfile(); - PROFILEMAN->LoadMachineProfile(); - - int iNumErrors = iNumAttempted-iNumSuccessful; - return ssprintf(MACHINE_EDITS_CLEARED.GetValue(),iNumSuccessful,iNumErrors); -} static PlayerNumber GetFirstReadyMemoryCard() { @@ -107,69 +77,10 @@ static RString ClearMemoryCardEdits() static LocalizedString STATS_NOT_SAVED ( "ScreenServiceAction", "Stats not saved - No memory cards ready." ); static LocalizedString MACHINE_STATS_SAVED ( "ScreenServiceAction", "Machine stats saved to P%d card." ); static LocalizedString ERROR_SAVING_MACHINE_STATS ( "ScreenServiceAction", "Error saving machine stats to P%d card." ); -static RString TransferStatsMachineToMemoryCard() -{ - PlayerNumber pn = GetFirstReadyMemoryCard(); - if( pn == PLAYER_INVALID ) - return STATS_NOT_SAVED.GetValue(); - - if( !MEMCARDMAN->IsMounted(pn) ) - MEMCARDMAN->MountCard(pn); - - RString sDir = MEM_CARD_MOUNT_POINT[pn]; - sDir += "MachineProfile/"; - - bool bSaved = PROFILEMAN->GetMachineProfile()->SaveAllToDir( sDir, PREFSMAN->m_bSignProfileData ); - - MEMCARDMAN->UnmountCard(pn); - - if( bSaved ) - return ssprintf(MACHINE_STATS_SAVED.GetValue(),pn+1); - else - return ssprintf(ERROR_SAVING_MACHINE_STATS.GetValue(),pn+1); -} - static LocalizedString STATS_NOT_LOADED ( "ScreenServiceAction", "Stats not loaded - No memory cards ready." ); static LocalizedString MACHINE_STATS_LOADED ( "ScreenServiceAction", "Machine stats loaded from P%d card." ); static LocalizedString THERE_IS_NO_PROFILE ( "ScreenServiceAction", "There is no machine profile on P%d card." ); static LocalizedString PROFILE_CORRUPT ( "ScreenServiceAction", "The profile on P%d card contains corrupt or tampered data." ); -static RString TransferStatsMemoryCardToMachine() -{ - PlayerNumber pn = GetFirstReadyMemoryCard(); - if( pn == PLAYER_INVALID ) - return STATS_NOT_LOADED.GetValue(); - - if( !MEMCARDMAN->IsMounted(pn) ) - MEMCARDMAN->MountCard(pn); - - RString sDir = MEM_CARD_MOUNT_POINT[pn]; - sDir += "MachineProfile/"; - - Profile backup = *PROFILEMAN->GetMachineProfile(); - - ProfileLoadResult lr = PROFILEMAN->GetMachineProfile()->LoadAllFromDir( sDir, PREFSMAN->m_bSignProfileData ); - RString s; - switch( lr ) - { - case ProfileLoadResult_Success: - s = ssprintf(MACHINE_STATS_LOADED.GetValue(),pn+1); - break; - case ProfileLoadResult_FailedNoProfile: - *PROFILEMAN->GetMachineProfile() = backup; - s = ssprintf(THERE_IS_NO_PROFILE.GetValue(),pn+1); - break; - case ProfileLoadResult_FailedTampered: - *PROFILEMAN->GetMachineProfile() = backup; - s = ssprintf(PROFILE_CORRUPT.GetValue(),pn+1); - break; - default: - FAIL_M(ssprintf("Invalid profile load result: %i", lr)); - } - - MEMCARDMAN->UnmountCard(pn); - - return s; -} static void CopyEdits( const RString &sFromProfileDir, const RString &sToProfileDir, int &iNumSucceeded, int &iNumOverwritten, int &iNumIgnored, int &iNumErrored ) { @@ -193,14 +104,6 @@ static void CopyEdits( const RString &sFromProfileDir, const RString &sToProfile iNumSucceeded++; else iNumErrored++; - - // Test whether the song we need for this edit is present and ignore this edit if not present. - SSCLoader loaderSSC; - if( !loaderSSC.LoadEditFromFile( sFromDir+*i, ProfileSlot_Machine, false ) ) - { - iNumIgnored++; - continue; - } } } } @@ -285,90 +188,7 @@ static void SyncEdits( const RString &sFromDir, const RString &sToDir, int &iNum SyncFiles( sFromDir + EDIT_STEPS_SUBDIR, sToDir + EDIT_STEPS_SUBDIR, "*.edit", iNumAdded, iNumDeleted, iNumOverwritten, iNumFailed ); } -static RString CopyEditsMachineToMemoryCard() -{ - PlayerNumber pn = GetFirstReadyMemoryCard(); - if( pn == PLAYER_INVALID ) - return EDITS_NOT_COPIED.GetValue(); - - if( !MEMCARDMAN->IsMounted(pn) ) - MEMCARDMAN->MountCard(pn); - - RString sFromDir = PROFILEMAN->GetProfileDir(ProfileSlot_Machine); - RString sToDir = MEM_CARD_MOUNT_POINT[pn] + (RString)PREFSMAN->m_sMemoryCardProfileSubdir + "/"; - - vector vs; - vs.push_back( ssprintf( COPIED_TO_CARD.GetValue(), pn+1 ) ); - RString s = CopyEdits( sFromDir, sToDir, PREFSMAN->m_sMemoryCardProfileSubdir ); - vs.push_back( s ); - - MEMCARDMAN->UnmountCard(pn); - - return join("\n\n",vs); -} - -static RString SyncEditsMachineToMemoryCard() -{ - PlayerNumber pn = GetFirstReadyMemoryCard(); - if( pn == PLAYER_INVALID ) - return EDITS_NOT_COPIED.GetValue(); - - if( !MEMCARDMAN->IsMounted(pn) ) - MEMCARDMAN->MountCard(pn); - - int iNumAdded = 0; - int iNumDeleted = 0; - int iNumOverwritten = 0; - int iNumFailed = 0; - - RString sFromDir = PROFILEMAN->GetProfileDir(ProfileSlot_Machine); - RString sToDir = MEM_CARD_MOUNT_POINT[pn] + (RString)PREFSMAN->m_sMemoryCardProfileSubdir + "/"; - SyncEdits( sFromDir, sToDir, iNumAdded, iNumDeleted, iNumOverwritten, iNumFailed ); - - MEMCARDMAN->UnmountCard(pn); - - RString sRet = ssprintf( COPIED_TO_CARD.GetValue(), pn+1 ) + " "; - sRet += ssprintf( ADDED.GetValue(), iNumAdded ) + ", " + ssprintf( OVERWRITTEN.GetValue(), iNumOverwritten ); - if( iNumDeleted ) - sRet += RString(" ") + ssprintf( DELETED.GetValue(), iNumDeleted ); - if( iNumFailed ) - sRet += RString("; ") + ssprintf( FAILED.GetValue(), iNumFailed ); - return sRet; -} - static LocalizedString COPIED_FROM_CARD( "ScreenServiceAction", "Copied from P%d card:" ); -static RString CopyEditsMemoryCardToMachine() -{ - PlayerNumber pn = GetFirstReadyMemoryCard(); - if( pn == PLAYER_INVALID ) - return EDITS_NOT_COPIED.GetValue(); - - if( !MEMCARDMAN->IsMounted(pn) ) - MEMCARDMAN->MountCard(pn); - - vector vsSubDirs; - ProfileManager::GetMemoryCardProfileDirectoriesToTry( vsSubDirs ); - - vector vs; - vs.push_back( ssprintf( COPIED_FROM_CARD.GetValue(), pn+1 ) ); - - FOREACH_CONST( RString, vsSubDirs, sSubDir ) - { - RString sFromDir = MEM_CARD_MOUNT_POINT[pn] + (RString)(*sSubDir) + "/"; - RString sToDir = PROFILEMAN->GetProfileDir(ProfileSlot_Machine); - - RString s = CopyEdits( sFromDir, sToDir, *sSubDir ); - vs.push_back( s ); - } - - MEMCARDMAN->UnmountCard(pn); - - // reload the machine profile - PROFILEMAN->SaveMachineProfile(); - PROFILEMAN->LoadMachineProfile(); - - return join("\n\n",vs); -} static LocalizedString PREFERENCES_RESET( "ScreenServiceAction", "Preferences reset." ); static RString ResetPreferences() @@ -392,14 +212,7 @@ void ScreenServiceAction::BeginScreen() RString (*pfn)() = NULL; if( *s == "ClearBookkeepingData" ) pfn = ClearBookkeepingData; - else if( *s == "ClearMachineStats" ) pfn = ClearMachineStats; - else if( *s == "ClearMachineEdits" ) pfn = ClearMachineEdits; else if( *s == "ClearMemoryCardEdits" ) pfn = ClearMemoryCardEdits; - else if( *s == "TransferStatsMachineToMemoryCard" ) pfn = TransferStatsMachineToMemoryCard; - else if( *s == "TransferStatsMemoryCardToMachine" ) pfn = TransferStatsMemoryCardToMachine; - else if( *s == "CopyEditsMachineToMemoryCard" ) pfn = CopyEditsMachineToMemoryCard; - else if( *s == "CopyEditsMemoryCardToMachine" ) pfn = CopyEditsMemoryCardToMachine; - else if( *s == "SyncEditsMachineToMemoryCard" ) pfn = SyncEditsMachineToMemoryCard; else if( *s == "ResetPreferences" ) pfn = ResetPreferences; ASSERT_M( pfn != NULL, *s ); diff --git a/src/ScreenServiceAction.h b/src/ScreenServiceAction.h index 174d80e57e..35011f0106 100644 --- a/src/ScreenServiceAction.h +++ b/src/ScreenServiceAction.h @@ -5,8 +5,6 @@ #include "ScreenPrompt.h" -RString ClearMachineStats(); - class ScreenServiceAction : public ScreenPrompt { public: diff --git a/src/ScreenUnlockBrowse.cpp b/src/ScreenUnlockBrowse.cpp index 20219bcc72..e69de29bb2 100644 --- a/src/ScreenUnlockBrowse.cpp +++ b/src/ScreenUnlockBrowse.cpp @@ -1,94 +0,0 @@ -#include "global.h" -#include "ScreenUnlockBrowse.h" -#include "UnlockManager.h" - - -REGISTER_SCREEN_CLASS( ScreenUnlockBrowse ); - -void ScreenUnlockBrowse::Init() -{ - // fill m_aGameCommands before calling Init() - FOREACH_CONST( UnlockEntry, UNLOCKMAN->m_UnlockEntries, ue ) - { - GameCommand gc; - UnlockEntryStatus st = ue->GetUnlockEntryStatus(); - switch( st ) - { - default: - FAIL_M(ssprintf("Invalid UnlockEntryStatus: %i", st)); - case UnlockEntryStatus_RequirementsMet: - case UnlockEntryStatus_Unlocked: - gc.m_bInvalid = false; - break; - case UnlockEntryStatus_RequrementsNotMet: - break; - } - gc.m_iIndex = ue - UNLOCKMAN->m_UnlockEntries.begin(); - // gc.m_sUnlockEntryID = ue->m_sEntryID; - gc.m_sName = ssprintf("%d",gc.m_iIndex); - - m_aGameCommands.push_back( gc ); - } - - ScreenSelectMaster::Init(); - - m_banner.SetName( "Banner" ); - LOAD_ALL_COMMANDS_AND_SET_XY( m_banner ); - this->AddChild( &m_banner ); - - this->SubscribeToMessage( Message_MenuSelectionChanged ); -} - -void ScreenUnlockBrowse::BeginScreen() -{ - ScreenSelectMaster::BeginScreen(); - - HandleMessage( Message(MessageIDToString(Message_MenuSelectionChanged)) ); -} - -bool ScreenUnlockBrowse::MenuStart( const InputEventPlus &input ) -{ - m_soundStart.Play(true); - this->PostScreenMessage( SM_BeginFadingOut, 0 ); - return true; -} - -void ScreenUnlockBrowse::HandleMessage( const Message &msg ) -{ - if( msg == Message_MenuSelectionChanged ) - { - int iSelection = this->GetSelectionIndex(PLAYER_1); - const UnlockEntry &ue = UNLOCKMAN->m_UnlockEntries[ iSelection ]; - if( ue.IsLocked() ) - m_banner.LoadFallback(); - else - m_banner.LoadBannerFromUnlockEntry( &ue ); - } - - ScreenSelectMaster::HandleMessage( msg ); -} - -/* - * (c) 2006 Chris Danford - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons to - * whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF - * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS - * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT - * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS - * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR - * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ diff --git a/src/ScreenUnlockBrowse.h b/src/ScreenUnlockBrowse.h index 9c5457f9e3..e69de29bb2 100644 --- a/src/ScreenUnlockBrowse.h +++ b/src/ScreenUnlockBrowse.h @@ -1,45 +0,0 @@ -#ifndef ScreenUnlockBrowse_H -#define ScreenUnlockBrowse_H - -#include "ScreenSelectMaster.h" -#include "FadingBanner.h" - -class ScreenUnlockBrowse : public ScreenSelectMaster -{ -public: - virtual void Init(); - virtual void BeginScreen(); - virtual bool MenuStart( const InputEventPlus &input ); - - virtual void HandleMessage( const Message &msg ); - -protected: - FadingBanner m_banner; -}; - -#endif - -/* - * (c) 2006 Chris Danford - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons to - * whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF - * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS - * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT - * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS - * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR - * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ diff --git a/src/ScreenUnlockCelebrate.cpp b/src/ScreenUnlockCelebrate.cpp index fd14390384..e69de29bb2 100644 --- a/src/ScreenUnlockCelebrate.cpp +++ b/src/ScreenUnlockCelebrate.cpp @@ -1,51 +0,0 @@ -#include "global.h" -#include "ScreenUnlockCelebrate.h" -#include "UnlockManager.h" -#include "LuaManager.h" -#include "GameState.h" - - -REGISTER_SCREEN_CLASS( ScreenUnlockCelebrate ); - -static int g_iUnlockEntryIndexToCelebrate = 0; - -LuaFunction( GetUnlockEntryIndexToCelebrate, g_iUnlockEntryIndexToCelebrate ); - -void ScreenUnlockCelebrate::Init() -{ - // We shouldn't be called if there aren't any unlocks to celebrate - ASSERT( UNLOCKMAN->AnyUnlocksToCelebrate() ); - - g_iUnlockEntryIndexToCelebrate = UNLOCKMAN->GetUnlockEntryIndexToCelebrate(); - UNLOCKMAN->UnlockEntryIndex( g_iUnlockEntryIndexToCelebrate ); - Song* pSong = UNLOCKMAN->m_UnlockEntries[ g_iUnlockEntryIndexToCelebrate ].m_Song.ToSong(); - if( pSong ) - GAMESTATE->m_pCurSong.Set( pSong ); - - ScreenUnlockBrowse::Init(); -} - -/* - * (c) 2006 Chris Danford - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons to - * whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF - * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS - * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT - * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS - * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR - * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ diff --git a/src/ScreenUnlockCelebrate.h b/src/ScreenUnlockCelebrate.h index 75c9e398b6..e69de29bb2 100644 --- a/src/ScreenUnlockCelebrate.h +++ b/src/ScreenUnlockCelebrate.h @@ -1,43 +0,0 @@ -#ifndef ScreenUnlockCelebrate_H -#define ScreenUnlockCelebrate_H - -#include "ScreenUnlockBrowse.h" - -class ScreenUnlockCelebrate : public ScreenUnlockBrowse -{ -public: - virtual void Init(); - virtual bool MenuLeft( const InputEventPlus &input ) { return false; } - virtual bool MenuRight( const InputEventPlus &input ) { return false; } - virtual bool MenuUp( const InputEventPlus &input ) { return false; } - virtual bool MenuDown( const InputEventPlus &input ) { return false; } - virtual bool MenuBack( const InputEventPlus &input ) { return MenuStart( input ); } -protected: -}; - -#endif - -/* - * (c) 2006 Chris Danford - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons to - * whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF - * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS - * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT - * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS - * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR - * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ diff --git a/src/ScreenUnlockStatus.cpp b/src/ScreenUnlockStatus.cpp index c05e0242a7..e69de29bb2 100644 --- a/src/ScreenUnlockStatus.cpp +++ b/src/ScreenUnlockStatus.cpp @@ -1,348 +0,0 @@ -#include "global.h" -#include "PrefsManager.h" -#include "ScreenUnlockStatus.h" -#include "ThemeManager.h" -#include "GameState.h" -#include "RageLog.h" -#include "UnlockManager.h" -#include "SongManager.h" -#include "ActorUtil.h" -#include "Song.h" - -#define UNLOCK_TEXT_SCROLL_X THEME->GetMetricF("ScreenUnlockStatus","UnlockTextScrollX"); -#define UNLOCK_TEXT_SCROLL_START_Y THEME->GetMetricF("ScreenUnlockStatus","UnlockTextScrollStartY") -#define UNLOCK_TEXT_SCROLL_END_Y THEME->GetMetricF("ScreenUnlockStatus","UnlockTextScrollEndY") -#define UNLOCK_TEXT_SCROLL_ZOOM THEME->GetMetricF("ScreenUnlockStatus","UnlockTextScrollZoom") -#define UNLOCK_TEXT_SCROLL_ROWS THEME->GetMetricF("ScreenUnlockStatus","UnlockTextScrollRows") -#define UNLOCK_TEXT_SCROLL_MAX_WIDTH THEME->GetMetricF("ScreenUnlockStatus","UnlockTextScrollMaxWidth") -#define UNLOCK_TEXT_SCROLL_ICON_X THEME->GetMetricF("ScreenUnlockStatus","UnlockTextScrollIconX") -#define UNLOCK_TEXT_SCROLL_ICON_SIZE THEME->GetMetricF("ScreenUnlockStatus","UnlockTextScrollIconSize") -#define UNLOCK_TEXT_SCROLL THEME->GetMetricI("ScreenUnlockStatus","UnlockTextScroll") -#define TYPE_TO_DISPLAY THEME->GetMetric ("ScreenUnlockStatus","TypeOfPointsToDisplay") -#define ICON_COMMAND THEME->GetMetricA("ScreenUnlockStatus","UnlockIconCommand") -#define TIME_TO_DISPLAY THEME->GetMetricF("ScreenUnlockStatus","TimeToDisplay") -#define POINTS_ZOOM THEME->GetMetricF("ScreenUnlockStatus","PointsZoom") - -REGISTER_SCREEN_CLASS( ScreenUnlockStatus ); - -void ScreenUnlockStatus::Init() -{ - ScreenAttract::Init(); - - unsigned iNumUnlocks = UNLOCKMAN->m_UnlockEntries.size(); - - if( !PREFSMAN->m_bUseUnlockSystem || iNumUnlocks == 0 ) - { - this->PostScreenMessage( SM_GoToNextScreen, 0 ); - return; - } - - unsigned NumUnlocks = UNLOCKMAN->m_UnlockEntries.size(); - - PointsUntilNextUnlock.LoadFromFont( THEME->GetPathF("Common","normal") ); - PointsUntilNextUnlock.SetHorizAlign( align_left ); - - apActorCommands IconCommand = ICON_COMMAND; - for( unsigned i=1; i <= NumUnlocks; i++ ) - { - // get pertaining UnlockEntry - const UnlockEntry &entry = UNLOCKMAN->m_UnlockEntries[i-1]; - const Song *pSong = entry.m_Song.ToSong(); - - if( pSong == NULL) - continue; - - Sprite* pSpr = new Sprite; - - // new unlock graphic - pSpr->Load( THEME->GetPathG("ScreenUnlockStatus",ssprintf("%04d icon", i)) ); - - // set graphic location - pSpr->SetName( ssprintf("Unlock%04d",i) ); - LOAD_ALL_COMMANDS_AND_SET_XY( pSpr ); - - pSpr->RunCommands(IconCommand); - Unlocks.push_back(pSpr); - - if ( !entry.IsLocked() ) - this->AddChild(Unlocks[Unlocks.size() - 1]); - } - - // scrolling text - if (UNLOCK_TEXT_SCROLL != 0) - { - float ScrollingTextX = UNLOCK_TEXT_SCROLL_X; - float ScrollingTextStartY = UNLOCK_TEXT_SCROLL_START_Y; - float ScrollingTextEndY = UNLOCK_TEXT_SCROLL_END_Y; - float ScrollingTextZoom = UNLOCK_TEXT_SCROLL_ZOOM; - float ScrollingTextRows = UNLOCK_TEXT_SCROLL_ROWS; - float MaxWidth = UNLOCK_TEXT_SCROLL_MAX_WIDTH; - - float SecondsToScroll = TIME_TO_DISPLAY; - - if (SecondsToScroll > 2) SecondsToScroll--; - - float SECS_PER_CYCLE = 0; - - if (UNLOCK_TEXT_SCROLL != 3) - SECS_PER_CYCLE = (float)SecondsToScroll/(ScrollingTextRows + NumUnlocks); - else - SECS_PER_CYCLE = (float)SecondsToScroll/(ScrollingTextRows * 3 + NumUnlocks + 4); - - for(unsigned i = 1; i <= NumUnlocks; i++) - { - const UnlockEntry &entry = UNLOCKMAN->m_UnlockEntries[i-1]; - - BitmapText* text = new BitmapText; - - text->LoadFromFont( THEME->GetPathF("ScreenUnlockStatus","text") ); - text->SetHorizAlign( align_left ); - text->SetZoom(ScrollingTextZoom); - - switch( entry.m_Type ) - { - case UnlockRewardType_Song: - { - const Song *pSong = entry.m_Song.ToSong(); - ASSERT( pSong != NULL ); - - RString title = pSong->GetDisplayMainTitle(); - RString subtitle = pSong->GetDisplaySubTitle(); - if( subtitle != "" ) - title = title + "\n" + subtitle; - text->SetMaxWidth( MaxWidth ); - text->SetText( title ); - } - break; - default: - text->SetText( "" ); - text->SetDiffuse( RageColor(0.5f,0,0,1) ); - break; - } - - if( entry.IsLocked() ) - { - text->SetText("???"); - text->SetZoomX(1); - } - else - { - // unlocked. change color - const Song *pSong = entry.m_Song.ToSong(); - RageColor color = RageColor(1,1,1,1); - if( pSong ) - color = SONGMAN->GetSongGroupColor(pSong->m_sGroupName); - text->SetGlobalDiffuseColor(color); - } - - text->SetXY( ScrollingTextX, ScrollingTextStartY ); - - if (UNLOCK_TEXT_SCROLL == 3 && UNLOCK_TEXT_SCROLL_ROWS + i > NumUnlocks) - { // special command for last unlocks when scrolling is in effect - float TargetRow = -0.5f + i + UNLOCK_TEXT_SCROLL_ROWS - NumUnlocks; - float StopOffPoint = ScrollingTextEndY - TargetRow / UNLOCK_TEXT_SCROLL_ROWS * (ScrollingTextEndY - ScrollingTextStartY); - float FirstCycleTime = (UNLOCK_TEXT_SCROLL_ROWS - TargetRow) * SECS_PER_CYCLE; - float SecondCycleTime = (6 + TargetRow) * SECS_PER_CYCLE - FirstCycleTime; - //LOG->Trace("Target Row: %f", TargetRow); - //LOG->Trace("command for icon %d: %s", i, ssprintf("diffusealpha,0;sleep,%f;diffusealpha,1;linear,%f;y,%f;linear,%f;y,%f;linear,0.1;diffusealpha,0", SECS_PER_CYCLE * (i - 1), FirstCycleTime, StopOffPoint, SecondCycleTime * 2, ScrollingTextEndY).c_str() ); - RString sCommand = ssprintf("diffusealpha,0;sleep,%f;diffusealpha,1;linear,%f;y,%f;linear,%f;y,%f;linear,0.1;diffusealpha,0", SECS_PER_CYCLE * (i - 1), FirstCycleTime, StopOffPoint, SecondCycleTime, ScrollingTextEndY); - text->RunCommands( ActorUtil::ParseActorCommands(sCommand) ); - } - else - { - RString sCommand = ssprintf("diffusealpha,0;sleep,%f;diffusealpha,1;linear,%f;y,%f;linear,0.1;diffusealpha,0", SECS_PER_CYCLE * (i - 1), SECS_PER_CYCLE * (ScrollingTextRows), ScrollingTextEndY); - text->RunCommands( ActorUtil::ParseActorCommands(sCommand) ); - } - - item.push_back(text); - - if (UNLOCK_TEXT_SCROLL >= 2) - { - Sprite* IconCount = new Sprite; - - // new unlock graphic - IconCount->Load( THEME->GetPathG("ScreenUnlockStatus",ssprintf("%04d icon", i)) ); - - // set graphic location - IconCount->SetXY( UNLOCK_TEXT_SCROLL_ICON_X, ScrollingTextStartY); - - IconCount->SetHeight(UNLOCK_TEXT_SCROLL_ICON_SIZE); - IconCount->SetWidth(UNLOCK_TEXT_SCROLL_ICON_SIZE); - - if (UNLOCK_TEXT_SCROLL == 3 && UNLOCK_TEXT_SCROLL_ROWS + i > NumUnlocks) - { - float TargetRow = -0.5f + i + UNLOCK_TEXT_SCROLL_ROWS - NumUnlocks; - float StopOffPoint = ScrollingTextEndY - TargetRow / UNLOCK_TEXT_SCROLL_ROWS * (ScrollingTextEndY - ScrollingTextStartY); - float FirstCycleTime = (UNLOCK_TEXT_SCROLL_ROWS - TargetRow) * SECS_PER_CYCLE; - float SecondCycleTime = (6 + TargetRow) * SECS_PER_CYCLE - FirstCycleTime; - //LOG->Trace("Target Row: %f", TargetRow); - //LOG->Trace("command for icon %d: %s", i, ssprintf("diffusealpha,0;sleep,%f;diffusealpha,1;linear,%f;y,%f;linear,%f;y,%f;linear,0.1;diffusealpha,0", SECS_PER_CYCLE * (i - 1), FirstCycleTime, StopOffPoint, SecondCycleTime * 2, ScrollingTextEndY).c_str() ); - RString sCommand = ssprintf("diffusealpha,0;sleep,%f;diffusealpha,1;linear,%f;y,%f;linear,%f;y,%f;linear,0.1;diffusealpha,0", SECS_PER_CYCLE * (i - 1), FirstCycleTime, StopOffPoint, SecondCycleTime, ScrollingTextEndY); - IconCount->RunCommands( ActorUtil::ParseActorCommands(sCommand) ); - } - else - { - RString sCommand = ssprintf("diffusealpha,0;sleep,%f;diffusealpha,1;linear,%f;y,%f;linear,0.1;diffusealpha,0", SECS_PER_CYCLE * (i - 1), SECS_PER_CYCLE * (ScrollingTextRows), ScrollingTextEndY); - IconCount->RunCommands( ActorUtil::ParseActorCommands(sCommand) ); - } - - ItemIcons.push_back(IconCount); - - //LOG->Trace("Added unlock text %d", i); - - if (UNLOCK_TEXT_SCROLL == 3) - { - if ( !entry.IsLocked() ) - LastUnlocks.push_back(i); - } - } - } - } - - if (UNLOCK_TEXT_SCROLL == 3) - { - float ScrollingTextX = UNLOCK_TEXT_SCROLL_X; - float ScrollingTextStartY = UNLOCK_TEXT_SCROLL_START_Y; - float ScrollingTextEndY = UNLOCK_TEXT_SCROLL_END_Y; - float ScrollingTextRows = UNLOCK_TEXT_SCROLL_ROWS; - float MaxWidth = UNLOCK_TEXT_SCROLL_MAX_WIDTH; - float SecondsToScroll = TIME_TO_DISPLAY - 1; - float SECS_PER_CYCLE = (float)SecondsToScroll/(ScrollingTextRows * 3 + NumUnlocks + 4); - - for(unsigned i=1; i <= UNLOCK_TEXT_SCROLL_ROWS; i++) - { - if (i > LastUnlocks.size()) - continue; - - unsigned NextIcon = LastUnlocks[LastUnlocks.size() - i]; - - const UnlockEntry &entry = UNLOCKMAN->m_UnlockEntries[NextIcon-1]; - const Song *pSong = entry.m_Song.ToSong(); - if( pSong == NULL ) - continue; - - BitmapText* NewText = new BitmapText; - - NewText->LoadFromFont( THEME->GetPathF("ScreenUnlockStatus","text") ); - NewText->SetHorizAlign( align_left ); - - RString title = pSong->GetDisplayMainTitle(); - RString subtitle = pSong->GetDisplaySubTitle(); - - if( subtitle != "" ) - title = title + "\n" + subtitle; - NewText->SetZoom(UNLOCK_TEXT_SCROLL_ZOOM); - NewText->SetMaxWidth( MaxWidth ); - NewText->SetText( title ); - - RageColor color = SONGMAN->GetSongGroupColor(pSong->m_sGroupName); - NewText->SetGlobalDiffuseColor(color); - - NewText->SetXY(ScrollingTextX, ScrollingTextStartY); - { - RString sCommand = ssprintf("diffusealpha,0;sleep,%f;diffusealpha,1;linear,%f;y,%f;", SECS_PER_CYCLE * (NumUnlocks + 2 * i - 2), SECS_PER_CYCLE * ((ScrollingTextRows - i) * 2 + 1 ), (ScrollingTextStartY + (ScrollingTextEndY - ScrollingTextStartY) * (ScrollingTextRows - i + 0.5) / ScrollingTextRows )); - NewText->RunCommands( ActorUtil::ParseActorCommands(sCommand) ); - } - - // new unlock graphic - Sprite* NewIcon = new Sprite; - NewIcon->Load( THEME->GetPathG("ScreenUnlockStatus",ssprintf("%04d icon", NextIcon)) ); - NewIcon->SetXY( UNLOCK_TEXT_SCROLL_ICON_X, ScrollingTextStartY); - NewIcon->SetHeight(UNLOCK_TEXT_SCROLL_ICON_SIZE); - NewIcon->SetWidth(UNLOCK_TEXT_SCROLL_ICON_SIZE); - { - RString sCommand = ssprintf("diffusealpha,0;sleep,%f;diffusealpha,1;linear,%f;y,%f;", SECS_PER_CYCLE * (NumUnlocks + 2 * i - 2), SECS_PER_CYCLE * ((ScrollingTextRows - i) * 2 + 1 ), (ScrollingTextStartY + (ScrollingTextEndY - ScrollingTextStartY) * (ScrollingTextRows - i + 0.5) / ScrollingTextRows )); - NewIcon->RunCommands( ActorUtil::ParseActorCommands(sCommand) ); - } - - ItemIcons.push_back(NewIcon); - item.push_back(NewText); - } - } - - // NOTE: the following two loops require the iterator to - // be ints because if you decrement an unsigned when it - // equals zero, you get the maximum value of an unsigned, - // which is still greater than 0. By typecasting it as - // an integer, you can achieve -1, which exits the loop. - - for(int i = item.size() - 1; (int)i >= 0; i--) - this->AddChild(item[i]); - - for(int i = ItemIcons.size() - 1; (int)i >= 0; i--) - this->AddChild(ItemIcons[i]); - - PointsUntilNextUnlock.SetName( "PointsDisplay" ); - - RString PointDisplay = TYPE_TO_DISPLAY; - if (PointDisplay == "DP" || PointDisplay == "Dance") - { - RString sDP = ssprintf( "%d", (int)UNLOCKMAN->PointsUntilNextUnlock(UnlockRequirement_DancePoints) ); - PointsUntilNextUnlock.SetText( sDP ); - } - else if (PointDisplay == "AP" || PointDisplay == "Arcade") - { - RString sAP = ssprintf( "%d", (int)UNLOCKMAN->PointsUntilNextUnlock(UnlockRequirement_ArcadePoints) ); - PointsUntilNextUnlock.SetText( sAP ); - } - else if (PointDisplay == "SP" || PointDisplay == "Song") - { - RString sSP = ssprintf( "%d", (int)UNLOCKMAN->PointsUntilNextUnlock(UnlockRequirement_SongPoints) ); - PointsUntilNextUnlock.SetText( sSP ); - } - - PointsUntilNextUnlock.SetZoom( POINTS_ZOOM ); - LOAD_ALL_COMMANDS_AND_SET_XY( PointsUntilNextUnlock ); - this->AddChild( &PointsUntilNextUnlock ); - - this->ClearMessageQueue( SM_BeginFadingOut ); // ignore ScreenAttract's SecsToShow - - this->PostScreenMessage( SM_BeginFadingOut, TIME_TO_DISPLAY ); -} - -ScreenUnlockStatus::~ScreenUnlockStatus() -{ - while (Unlocks.size() > 0) - { - Sprite* entry = Unlocks[Unlocks.size()-1]; - SAFE_DELETE(entry); - Unlocks.pop_back(); - } - while (item.size() > 0) - { - BitmapText* entry = item[item.size()-1]; - SAFE_DELETE(entry); - item.pop_back(); - } - while (ItemIcons.size() > 0) - { - Sprite* entry = ItemIcons[ItemIcons.size()-1]; - SAFE_DELETE(entry); - ItemIcons.pop_back(); - } -} - -/* - * (c) 2003 Andrew Wong - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons to - * whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF - * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS - * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT - * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS - * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR - * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ diff --git a/src/ScreenUnlockStatus.h b/src/ScreenUnlockStatus.h index 933237adb1..e69de29bb2 100644 --- a/src/ScreenUnlockStatus.h +++ b/src/ScreenUnlockStatus.h @@ -1,48 +0,0 @@ -#ifndef ScreenUnlockStatus_H -#define ScreenUnlockStatus_H - -#include "ScreenAttract.h" -#include "Sprite.h" -#include "BitmapText.h" - -class ScreenUnlockStatus : public ScreenAttract -{ -public: - virtual void Init(); - ~ScreenUnlockStatus(); - -protected: - BitmapText PointsUntilNextUnlock; - vector Unlocks; - vector item; // scrolling text - vector ItemIcons; // icons for scrolling text - - vector LastUnlocks; // used for "last few" method -}; - -#endif - -/* - * (c) 2003 Andrew Wong - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons to - * whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF - * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS - * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT - * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS - * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR - * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ diff --git a/src/Song.cpp b/src/Song.cpp index a29fe34a52..b8a3c7f2a3 100644 --- a/src/Song.cpp +++ b/src/Song.cpp @@ -32,7 +32,6 @@ #include "NotesWriterJson.h" #include "NotesWriterSM.h" #include "NotesWriterSSC.h" -#include "UnlockManager.h" #include "LyricsLoader.h" #include "ActorUtil.h" @@ -1420,12 +1419,7 @@ bool Song::HasEdits( StepsType st ) const return false; } -bool Song::NormallyDisplayed() const -{ - return UNLOCKMAN == NULL || !UNLOCKMAN->SongIsLocked(this); -} - -bool Song::ShowInDemonstrationAndRanking() const { return !IsTutorial() && NormallyDisplayed(); } +bool Song::ShowInDemonstrationAndRanking() const { return !IsTutorial(); } // Hack: see Song::TidyUpData comments. @@ -2190,11 +2184,6 @@ class LunaSong: public Luna lua_pushnumber(L, p->GetStepsSeconds()); return 1; } - static int NormallyDisplayed( T* p, lua_State *L ) - { - lua_pushboolean(L, p->NormallyDisplayed()); - return 1; - } static int ShowInDemonstrationAndRanking( T* p, lua_State *L ) { lua_pushboolean(L, p->ShowInDemonstrationAndRanking()); @@ -2321,7 +2310,6 @@ class LunaSong: public Luna ADD_METHOD( IsEasy ); ADD_METHOD( IsFavorited ); ADD_METHOD( GetStepsSeconds ); - ADD_METHOD( NormallyDisplayed ); ADD_METHOD( GetFirstBeat ); ADD_METHOD( GetFirstSecond ); ADD_METHOD( GetLastBeat ); diff --git a/src/Song.h b/src/Song.h index 3a548301b5..6b089c04a9 100644 --- a/src/Song.h +++ b/src/Song.h @@ -424,12 +424,7 @@ class Song void SetEnabled( bool b ) { m_bEnabled = b; } bool GetEnabled() const { return m_bEnabled; } - /** - * @brief Determine if the song should be shown on the MusicWheel normally. - * Songs that are not displayed normally may still be available during - * random selection, extra stages, or other special conditions. - * @return true if displayed normally, false otherwise. */ - bool NormallyDisplayed() const; + bool ShowInDemonstrationAndRanking() const; /** diff --git a/src/SongManager.cpp b/src/SongManager.cpp index c24e2b5f95..84a24b9a54 100644 --- a/src/SongManager.cpp +++ b/src/SongManager.cpp @@ -31,7 +31,6 @@ #include "Style.h" #include "ThemeManager.h" #include "TitleSubstitution.h" -#include "UnlockManager.h" #include "SpecialFiles.h" SongManager* SONGMAN = NULL; // global and accessible from anywhere in our program @@ -45,9 +44,6 @@ const RString ATTACK_FILE = "/Data/RandomAttacks.txt"; static const ThemeMetric EXTRA_COLOR ( "SongManager", "ExtraColor" ); static const ThemeMetric EXTRA_COLOR_METER ( "SongManager", "ExtraColorMeter" ); static const ThemeMetric USE_PREFERRED_SORT_COLOR ( "SongManager", "UsePreferredSortColor" ); -static const ThemeMetric USE_UNLOCK_COLOR ( "SongManager", "UseUnlockColor" ); -static const ThemeMetric UNLOCK_COLOR ( "SongManager", "UnlockColor" ); -static const ThemeMetric MOVE_UNLOCKS_TO_BOTTOM_OF_PREFERRED_SORT ( "SongManager", "MoveUnlocksToBottomOfPreferredSort" ); static const ThemeMetric EXTRA_STAGE2_DIFFICULTY_MAX ( "SongManager", "ExtraStage2DifficultyMax" ); static Preference g_sDisabledSongs( "DisabledSongs", "" ); @@ -108,7 +104,6 @@ void SongManager::Reload( bool bAllowFastLoad, LoadingWindow *ld ) ld->SetText( RELOADING ); // save scores before unloading songs, or the scores will be lost - PROFILEMAN->SaveMachineProfile(); if( ld ) ld->SetText( UNLOADING_SONGS ); @@ -121,10 +116,6 @@ void SongManager::Reload( bool bAllowFastLoad, LoadingWindow *ld ) InitAll( ld ); - // reload scores and unlocks afterward - PROFILEMAN->LoadMachineProfile(); - UNLOCKMAN->Reload(); - if( !bAllowFastLoad ) PREFSMAN->m_bFastLoad.Set( OldVal ); @@ -575,11 +566,6 @@ RageColor SongManager::GetSongGroupColor( const RString &sSongGroup ) const RageColor SongManager::GetSongColor( const Song* pSong ) const { ASSERT( pSong != NULL ); - - // Use unlock color if applicable - if( USE_UNLOCK_COLOR.GetValue() && UNLOCKMAN->FindSong(pSong)) - return UNLOCK_COLOR.GetValue(); - if( USE_PREFERRED_SORT_COLOR ) { FOREACH_CONST( PreferredSortSection, m_vPreferredSongSort, v ) @@ -692,44 +678,6 @@ int SongManager::GetNumSongs() const return m_pSongs.size(); } -int SongManager::GetNumLockedSongs() const -{ - int iNum = 0; - FOREACH_CONST( Song*, m_pSongs, i ) - { - // If locked for any reason, regardless of how it's locked. - if( UNLOCKMAN->SongIsLocked(*i) ) - ++iNum; - } - return iNum; -} - -int SongManager::GetNumUnlockedSongs() const -{ - int iNum = 0; - FOREACH_CONST( Song*, m_pSongs, i ) - { - // If locked for any reason other than LOCKED_LOCK: - if( UNLOCKMAN->SongIsLocked(*i) & ~LOCKED_LOCK ) - continue; - ++iNum; - } - return iNum; -} - -int SongManager::GetNumSelectableAndUnlockedSongs() const -{ - int iNum = 0; - FOREACH_CONST( Song*, m_pSongs, i ) - { - // If locked for any reason other than LOCKED_LOCK or LOCKED_SELECTABLE: - if( UNLOCKMAN->SongIsLocked(*i) & ~(LOCKED_LOCK|LOCKED_SELECTABLE) ) - continue; - ++iNum; - } - return iNum; -} - int SongManager::GetNumAdditionalSongs() const { int iNum = 0; @@ -982,8 +930,6 @@ Song* SongManager::GetRandomSong() Song *pSong = m_pShuffledSongs[ i ]; if( pSong->IsTutorial() ) continue; - if( !pSong->NormallyDisplayed() ) - continue; return pSong; } @@ -1050,21 +996,6 @@ void SongManager::UpdatePopular() { // update players best vector apBestSongs = m_pSongs; - for ( unsigned j=0; j < apBestSongs.size() ; ++j ) - { - bool bFiltered = false; - // Filter out locked songs. - if( !apBestSongs[j]->NormallyDisplayed() ) - bFiltered = true; - if( !bFiltered ) - continue; - - // Remove it. - swap( apBestSongs[j], apBestSongs.back() ); - apBestSongs.erase( apBestSongs.end()-1 ); - --j; - } - SongUtil::SortSongPointerArrayByTitle( apBestSongs ); } @@ -1077,8 +1008,6 @@ void SongManager::UpdateShuffled() void SongManager::UpdatePreferredSort(const RString &sPreferredSongs, const RString &sPreferredCourses) { - ASSERT( UNLOCKMAN != NULL ); - { m_vPreferredSongSort.clear(); @@ -1121,8 +1050,6 @@ void SongManager::UpdatePreferredSort(const RString &sPreferredSongs, const RStr const vector &vSongs = GetSongs( group ); FOREACH_CONST( Song*, vSongs, song ) { - if( UNLOCKMAN->SongIsLocked(*song) & LOCKED_SELECTABLE ) - continue; section.vpSongs.push_back( *song ); } } @@ -1131,8 +1058,6 @@ void SongManager::UpdatePreferredSort(const RString &sPreferredSongs, const RStr Song *pSong = FindSong( sLine ); if( pSong == NULL ) continue; - if( UNLOCKMAN->SongIsLocked(pSong) & LOCKED_SELECTABLE ) - continue; section.vpSongs.push_back( pSong ); } } @@ -1143,36 +1068,6 @@ void SongManager::UpdatePreferredSort(const RString &sPreferredSongs, const RStr section = PreferredSortSection(); } - if( MOVE_UNLOCKS_TO_BOTTOM_OF_PREFERRED_SORT.GetValue() ) - { - // move all unlock songs to a group at the bottom - PreferredSortSection PFSection; - PFSection.sName = "Unlocks"; - FOREACH( UnlockEntry, UNLOCKMAN->m_UnlockEntries, ue ) - { - if( ue->m_Type == UnlockRewardType_Song ) - { - Song *pSong = ue->m_Song.ToSong(); - if( pSong ) - PFSection.vpSongs.push_back( pSong ); - } - } - - FOREACH( PreferredSortSection, m_vPreferredSongSort, v ) - { - for( int i=v->vpSongs.size()-1; i>=0; i-- ) - { - Song *pSong = v->vpSongs[i]; - if( find(PFSection.vpSongs.begin(),PFSection.vpSongs.end(),pSong) != PFSection.vpSongs.end() ) - { - v->vpSongs.erase( v->vpSongs.begin()+i ); - } - } - } - - m_vPreferredSongSort.push_back( PFSection ); - } - // prune empty groups for( int i=m_vPreferredSongSort.size()-1; i>=0; i-- ) if( m_vPreferredSongSort[i].vpSongs.empty() ) @@ -1364,9 +1259,6 @@ class LunaSongManager: public Luna static int FindSong( T* p, lua_State *L ) { Song *pS = p->FindSong(SArg(1)); if(pS) pS->PushSelf(L); else lua_pushnil(L); return 1; } static int GetRandomSong( T* p, lua_State *L ) { Song *pS = p->GetRandomSong(); if(pS) pS->PushSelf(L); else lua_pushnil(L); return 1; } static int GetNumSongs( T* p, lua_State *L ) { lua_pushnumber( L, p->GetNumSongs() ); return 1; } - static int GetNumLockedSongs( T* p, lua_State *L ) { lua_pushnumber( L, p->GetNumLockedSongs() ); return 1; } - static int GetNumUnlockedSongs( T* p, lua_State *L ) { lua_pushnumber( L, p->GetNumUnlockedSongs() ); return 1; } - static int GetNumSelectableAndUnlockedSongs( T* p, lua_State *L ) { lua_pushnumber( L, p->GetNumSelectableAndUnlockedSongs() ); return 1; } static int GetNumAdditionalSongs( T* p, lua_State *L ) { lua_pushnumber( L, p->GetNumAdditionalSongs() ); return 1; } static int GetNumSongGroups( T* p, lua_State *L ) { lua_pushnumber( L, p->GetNumSongGroups() ); return 1; } /* Note: this could now be implemented as Luna::GetSong */ @@ -1477,9 +1369,6 @@ class LunaSongManager: public Luna ADD_METHOD( FindSong ); ADD_METHOD( GetRandomSong ); ADD_METHOD( GetNumSongs ); - ADD_METHOD( GetNumLockedSongs ); - ADD_METHOD( GetNumUnlockedSongs ); - ADD_METHOD( GetNumSelectableAndUnlockedSongs ); ADD_METHOD( GetNumAdditionalSongs ); ADD_METHOD( GetNumSongGroups ); ADD_METHOD( GetSongFromSteps ); diff --git a/src/SongUtil.cpp b/src/SongUtil.cpp index ce91345dd0..2f5ec26585 100644 --- a/src/SongUtil.cpp +++ b/src/SongUtil.cpp @@ -10,7 +10,6 @@ #include "SongManager.h" #include "XmlFile.h" #include "Foreach.h" -#include "UnlockManager.h" #include "ThemeMetric.h" #include "LocalizedString.h" #include "RageLog.h" @@ -27,9 +26,6 @@ bool SongCriteria::Matches( const Song *pSong ) const if( !m_sGroupName.empty() && m_sGroupName != pSong->m_sGroupName ) return false; - if( UNLOCKMAN->SongIsLocked(pSong) & LOCKED_DISABLED ) - return false; - if( m_bUseSongGenreAllowedList ) { if( find(m_vsSongGenreAllowedList.begin(),m_vsSongGenreAllowedList.end(),pSong->m_sGenre) == m_vsSongGenreAllowedList.end() ) @@ -40,12 +36,8 @@ bool SongCriteria::Matches( const Song *pSong ) const { DEFAULT_FAIL(m_Selectable); case Selectable_Yes: - if( UNLOCKMAN && UNLOCKMAN->SongIsLocked(pSong) & LOCKED_SELECTABLE ) - return false; break; case Selectable_No: - if( UNLOCKMAN && !(UNLOCKMAN->SongIsLocked(pSong) & LOCKED_SELECTABLE) ) - return false; break; case Selectable_DontCare: break; @@ -79,12 +71,8 @@ bool SongCriteria::Matches( const Song *pSong ) const { DEFAULT_FAIL(m_Locked); case Locked_Locked: - if( UNLOCKMAN && !(UNLOCKMAN->SongIsLocked(pSong) & LOCKED_LOCK) ) - return false; break; case Locked_Unlocked: - if( UNLOCKMAN && UNLOCKMAN->SongIsLocked(pSong) & LOCKED_LOCK ) - return false; break; case Locked_DontCare: break; @@ -227,8 +215,6 @@ Steps* SongUtil::GetClosestNotes( const Song *pSong, StepsType st, Difficulty dc if( pSteps->GetDifficulty() == Difficulty_Edit && dc != Difficulty_Edit ) continue; - if( bIgnoreLocked && UNLOCKMAN->StepsIsLocked(pSong,pSteps) ) - continue; int iDistance = abs(dc - pSteps->GetDifficulty()); if( iDistance < iClosestDistance ) @@ -470,7 +456,7 @@ void SongUtil::SortSongPointerArrayByGrades( vector &vpSongsInOut, bool b Song *pSong = vpSongsInOut[i]; int iCounts[NUM_Grade]; - const Profile *pProfile = PROFILEMAN->GetMachineProfile(); + const Profile *pProfile = PROFILEMAN->GetProfile(PLAYER_1); ASSERT( pProfile != NULL ); pProfile->GetGrades( pSong, GAMESTATE->GetCurrentStyle(GAMESTATE->GetMasterPlayerNumber())->m_StepsType, iCounts ); @@ -614,8 +600,6 @@ RString SongUtil::GetSectionNameFromSongAndSort( const Song* pSong, SortOrder so case SORT_TOP_GRADES: { int iCounts[NUM_Grade]; - PROFILEMAN->GetMachineProfile()->GetGrades( pSong, GAMESTATE->GetCurrentStyle(GAMESTATE->GetMasterPlayerNumber())->m_StepsType, iCounts ); - for( int i=Grade_Tier01; iStepsIsLocked(pSong,pSteps) ) - return ssprintf("%02d", pSteps->GetMeter() ); return SORT_NOT_AVAILABLE.GetValue(); } case SORT_MODE_MENU: @@ -691,21 +673,6 @@ void SongUtil::SortSongPointerArrayByStepsTypeAndMeter( vector &vpSongsIn stable_sort( vpSongsInOut.begin(), vpSongsInOut.end(), CompareSongPointersBySortValueAscending ); } -void SongUtil::SortByMostRecentlyPlayedForMachine( vector &vpSongsInOut ) -{ - Profile *pProfile = PROFILEMAN->GetMachineProfile(); - - FOREACH_CONST( Song*, vpSongsInOut, s ) - { - int iNumTimesPlayed = pProfile->GetSongNumTimesPlayed( *s ); - RString val = iNumTimesPlayed ? pProfile->GetSongLastPlayedDateTime(*s).GetString() : "0"; - g_mapSongSortVal[*s] = val; - } - - stable_sort( vpSongsInOut.begin(), vpSongsInOut.end(), CompareSongPointersBySortValueDescending ); - g_mapSongSortVal.clear(); -} - bool SongUtil::IsEditDescriptionUnique( const Song* pSong, StepsType st, const RString &sPreferredDescription, const Steps *pExclude ) { FOREACH_CONST( Steps*, pSong->GetAllSteps(), s ) @@ -1000,7 +967,6 @@ void SongUtil::GetPlayableSteps( const Song *pSong, vector &vOut ) FOREACHS( StepsType, vStepsType, st ) SongUtil::GetSteps( pSong, vOut, *st ); - StepsUtil::RemoveLockedSteps( pSong, vOut ); StepsUtil::SortNotesArrayByDifficulty( vOut ); StepsUtil::SortStepsByTypeAndDifficulty( vOut ); } diff --git a/src/SongUtil.h b/src/SongUtil.h index f144dedccf..70385ddbd7 100644 --- a/src/SongUtil.h +++ b/src/SongUtil.h @@ -145,7 +145,6 @@ namespace SongUtil void SortSongPointerArrayByStepsTypeAndMeter( vector &vpSongsInOut, StepsType st, Difficulty dc ); RString GetSectionNameFromSongAndSort( const Song *pSong, SortOrder so ); void SortSongPointerArrayBySectionName( vector &vpSongsInOut, SortOrder so ); - void SortByMostRecentlyPlayedForMachine( vector &vpSongsInOut ); void SortSongPointerArrayByLength( vector &vpSongsInOut ); int CompareSongPointersByGroup(const Song *pSong1, const Song *pSong2); diff --git a/src/StageStats.cpp b/src/StageStats.cpp index 07f778a6a5..16052b912f 100644 --- a/src/StageStats.cpp +++ b/src/StageStats.cpp @@ -192,7 +192,6 @@ static HighScore FillInHighScore(const PlayerStageStats &pss, const PlayerState hs.SetDateTime( DateTime::GetNowDateTime() ); hs.SetPlayerGuid( sPlayerGuid ); - hs.SetMachineGuid( PROFILEMAN->GetMachineProfile()->m_sGuid ); hs.SetProductID( PREFSMAN->m_iProductID ); FOREACH_ENUM( TapNoteScore, tns ) hs.SetTapNoteScore( tns, pss.m_iTapNoteScores[tns] ); @@ -305,37 +304,6 @@ void StageStats::FinalizeScores( bool bSummary ) } } - // If both players get a machine high score in the same HighScoreList, - // then one player's score may have bumped the other player. Look in - // the HighScoreList and re-get the high score index. - FOREACH_HumanPlayer( p ) - { - if( m_player[p].m_iMachineHighScoreIndex == -1 ) // no record - continue; // skip - - HighScore &hs = m_player[p].m_HighScore; - Profile* pProfile = PROFILEMAN->GetMachineProfile(); - StepsType st = GAMESTATE->GetCurrentStyle(p)->m_StepsType; - - const HighScoreList *pHSL = NULL; - if( bSummary ) - { - pHSL = &pProfile->GetCategoryHighScoreList( st, m_player[p].m_rc ); - } - else - { - Song* pSong = GAMESTATE->m_pCurSong; - Steps* pSteps = GAMESTATE->m_pCurSteps[p]; - pHSL = &pProfile->GetStepsHighScoreList( pSong, pSteps ); - } - - vector::const_iterator iter = find( pHSL->vHighScores.begin(), pHSL->vHighScores.end(), hs ); - if( iter == pHSL->vHighScores.end() ) - m_player[p].m_iMachineHighScoreIndex = -1; - else - m_player[p].m_iMachineHighScoreIndex = iter - pHSL->vHighScores.begin(); - } - LOG->Trace( "done saving stats and high scores" ); } @@ -348,7 +316,7 @@ bool StageStats::PlayerHasHighScore( PlayerNumber pn ) const if( pSong->IsTutorial() == Song::SHOW_NEVER ) return false; - const HighScoreList &hsl = PROFILEMAN->GetMachineProfile()->GetStepsHighScoreList(pSong, pSteps); + const HighScoreList &hsl = PROFILEMAN->GetProfile(pn)->GetStepsHighScoreList(pSong, pSteps); int iScore = m_player[pn].m_iScore; float fPercentDP = m_player[pn].GetPercentDancePoints(); diff --git a/src/StatsManager.cpp b/src/StatsManager.cpp index a0f700ec60..b7f80bcd6d 100644 --- a/src/StatsManager.cpp +++ b/src/StatsManager.cpp @@ -142,11 +142,8 @@ void AddPlayerStatsToProfile( Profile *pProfile, const StageStats &ss, PlayerNum pProfile->m_iNumStagesPassedByGrade[ss.m_player[pn].GetGrade()] ++; } - if (!pProfile->IsMachine()) { - SCOREMAN->RecalculateSSRs(); - SCOREMAN->CalcPlayerRating(pProfile->m_fPlayerRating, pProfile->m_fPlayerSkillsets); - } - + SCOREMAN->RecalculateSSRs(); + SCOREMAN->CalcPlayerRating(pProfile->m_fPlayerRating, pProfile->m_fPlayerSkillsets); } void StatsManager::CommitStatsToProfiles( const StageStats *pSS ) @@ -167,13 +164,8 @@ void StatsManager::CommitStatsToProfiles( const StageStats *pSS ) } // Update profile stats - Profile* pMachineProfile = PROFILEMAN->GetMachineProfile(); - int iGameplaySeconds = (int)truncf(pSS->m_fGameplaySeconds); - pMachineProfile->m_iTotalGameplaySeconds += iGameplaySeconds; - pMachineProfile->m_iNumTotalSongsPlayed += pSS->m_vpPlayedSongs.size(); - if( !GAMESTATE->m_bMultiplayer ) // FIXME { FOREACH_HumanPlayer( pn ) @@ -185,9 +177,6 @@ void StatsManager::CommitStatsToProfiles( const StageStats *pSS ) pPlayerProfile->m_iNumTotalSongsPlayed += pSS->m_vpPlayedSongs.size(); } - LOG->Trace("Adding stats to machine profile..."); - AddPlayerStatsToProfile( pMachineProfile, *pSS, pn ); - if( pPlayerProfile ) { LOG->Trace("Adding stats to player profile..."); diff --git a/src/StdString.h b/src/StdString.h index 17f7946dc9..7b5006518d 100644 --- a/src/StdString.h +++ b/src/StdString.h @@ -627,10 +627,10 @@ class CStdStr : public std::basic_string #else #define EMP_TEMP <> #endif - friend MYTYPE operator+ EMP_TEMP(const MYTYPE& str1, const MYTYPE& str2); - friend MYTYPE operator+ EMP_TEMP(const MYTYPE& str, CT t); - friend MYTYPE operator+ EMP_TEMP(const MYTYPE& str, PCSTR sz); - friend MYTYPE operator+ EMP_TEMP(PCSTR pA, const MYTYPE& str); + //friend MYTYPE operator+ EMP_TEMP(const MYTYPE& str1, const MYTYPE& str2); + //friend MYTYPE operator+ EMP_TEMP(const MYTYPE& str, CT t); + //friend MYTYPE operator+ EMP_TEMP(const MYTYPE& str, PCSTR sz); + //friend MYTYPE operator+ EMP_TEMP(PCSTR pA, const MYTYPE& str); // ------------------------------------------------------------------------- // Case changing functions diff --git a/src/StepMania.cpp b/src/StepMania.cpp index c89a844bea..1c573a5f9d 100644 --- a/src/StepMania.cpp +++ b/src/StepMania.cpp @@ -58,7 +58,6 @@ #include "FilterManager.h" #include "ScoreManager.h" //#include "BackgroundCache.h" -#include "UnlockManager.h" #include "RageFileManager.h" #include "Bookkeeper.h" #include "ModelManager.h" @@ -293,7 +292,6 @@ void ShutdownGame() SAFE_DELETE( MODELMAN ); SAFE_DELETE( PROFILEMAN ); // PROFILEMAN needs the songs still loaded SAFE_DELETE( CHARMAN ); - SAFE_DELETE( UNLOCKMAN ); SAFE_DELETE( CRYPTMAN ); SAFE_DELETE( MEMCARDMAN ); SAFE_DELETE( SONGMAN ); @@ -1168,7 +1166,6 @@ int sm_main(int argc, char* argv[]) SCOREMAN = new ScoreManager; PROFILEMAN = new ProfileManager; PROFILEMAN->Init(); // must load after SONGMAN - UNLOCKMAN = new UnlockManager; SONGMAN->UpdatePopular(); SONGMAN->UpdatePreferredSort(); NSMAN = new NetworkSyncManager( pLoadingWindow ); diff --git a/src/Steps.h b/src/Steps.h index af0e540ce7..0f551a552d 100644 --- a/src/Steps.h +++ b/src/Steps.h @@ -74,7 +74,7 @@ class Steps * * Player edits also have to be loaded from a player's profile slot, not the machine. * @return true if this is a player edit, false otherwise. */ - bool IsAPlayerEdit() const { return IsAnEdit() && GetLoadedFromProfileSlot() < ProfileSlot_Machine; } + bool IsAPlayerEdit() const { return IsAnEdit(); } /** * @brief Determine if these steps were loaded from a player's profile. * @return true if they were from a player profile, false otherwise. diff --git a/src/StepsUtil.cpp b/src/StepsUtil.cpp index 79b9c0d8ad..8ad5ed1c34 100644 --- a/src/StepsUtil.cpp +++ b/src/StepsUtil.cpp @@ -7,7 +7,6 @@ #include "SongManager.h" #include "GameManager.h" #include "XmlFile.h" -#include "UnlockManager.h" #include "SongUtil.h" bool StepsCriteria::Matches( const Song *pSong, const Steps *pSteps ) const @@ -20,20 +19,6 @@ bool StepsCriteria::Matches( const Song *pSong, const Steps *pSteps ) const return false; if( m_st != StepsType_Invalid && pSteps->m_StepsType != m_st ) return false; - switch( m_Locked ) - { - DEFAULT_FAIL(m_Locked); - case Locked_Locked: - if( UNLOCKMAN && !UNLOCKMAN->StepsIsLocked(pSong,pSteps) ) - return false; - break; - case Locked_Unlocked: - if( UNLOCKMAN && UNLOCKMAN->StepsIsLocked(pSong,pSteps) ) - return false; - break; - case Locked_DontCare: - break; - } return true; } @@ -229,16 +214,6 @@ void StepsUtil::SortStepsByDescription( vector &arraySongPointers ) sort( arraySongPointers.begin(), arraySongPointers.end(), CompareStepsPointersByDescription ); } -void StepsUtil::RemoveLockedSteps( const Song *pSong, vector &vpSteps ) -{ - for( int i=vpSteps.size()-1; i>=0; i-- ) - { - if( UNLOCKMAN->StepsIsLocked(pSong, vpSteps[i]) ) - vpSteps.erase( vpSteps.begin()+i ); - } -} - - //////////////////////////////// // StepsID //////////////////////////////// diff --git a/src/StepsUtil.h b/src/StepsUtil.h index 6e0d8427ab..8bc084909e 100644 --- a/src/StepsUtil.h +++ b/src/StepsUtil.h @@ -39,18 +39,10 @@ class StepsCriteria * * Don't filter here if the StepsType is StepsType_Invalid. */ StepsType m_st; - /** @brief Check a song's locked status for searching. */ - enum Locked - { - Locked_Locked, /**< We want songs that are locked. */ - Locked_Unlocked, /**< We want songs that are unlocked. */ - Locked_DontCare /**< We don't care if the songs are locked or not. */ - } /** @brief The Song's locked status. */ m_Locked; - /** @brief Set up the initial criteria. */ StepsCriteria(): m_difficulty(Difficulty_Invalid), m_iLowMeter(-1), m_iHighMeter(-1), - m_st(StepsType_Invalid), m_Locked(Locked_DontCare) + m_st(StepsType_Invalid) { //m_fLowBPM = -1; //m_fHighBPM = -1; @@ -70,7 +62,7 @@ class StepsCriteria bool operator==( const StepsCriteria &other ) const { #define X(x) (x == other.x) - return X(m_difficulty) && X(m_iLowMeter) && X(m_iHighMeter) && X(m_st) && X(m_Locked); + return X(m_difficulty) && X(m_iLowMeter) && X(m_iHighMeter) && X(m_st); #undef X } /** @@ -158,7 +150,6 @@ namespace StepsUtil void SortStepsPointerArrayByNumPlays( vector &vpStepsInOut, const Profile* pProfile, bool bDescending ); bool CompareStepsPointersByDescription(const Steps *pStep1, const Steps *pStep2); void SortStepsByDescription( vector &vpStepsInOut ); - void RemoveLockedSteps( const Song *pSong, vector &vpStepsInOut ); }; class StepsID diff --git a/src/ThemeManager.cpp b/src/ThemeManager.cpp index 2f34e63640..ba01ac2635 100644 --- a/src/ThemeManager.cpp +++ b/src/ThemeManager.cpp @@ -454,13 +454,6 @@ void ThemeManager::SwitchThemeAndLanguage( const RString &sThemeName_, const RSt * globals first; it's Lua's job to explicitly update cached metrics that it * uses. */ UpdateLuaGlobals(); - - // Reload MachineProfile with new theme's CustomLoadFunction - if( PROFILEMAN != NULL ) - { - Profile* pProfile = PROFILEMAN->GetMachineProfile(); - pProfile->LoadCustomFunction( "/Save/MachineProfile/" ); - } } // Use theme metrics for localization. diff --git a/src/UnlockManager.cpp b/src/UnlockManager.cpp index dae877e01a..e69de29bb2 100644 --- a/src/UnlockManager.cpp +++ b/src/UnlockManager.cpp @@ -1,937 +0,0 @@ -#include "global.h" -#include "UnlockManager.h" -#include "PrefsManager.h" -#include "RageLog.h" -#include "Song.h" -#include "RageUtil.h" -#include "SongManager.h" -#include "GameState.h" -#include "GameConstantsAndTypes.h" // StepsTypeToString -#include "ProfileManager.h" -#include "Profile.h" -#include "ThemeManager.h" -#include "Foreach.h" -#include "Steps.h" -#include -#include "CommonMetrics.h" -#include "LuaManager.h" -#include "GameManager.h" -#include "Style.h" - -UnlockManager* UNLOCKMAN = NULL; // global and accessible from anywhere in our program - -#define UNLOCK_NAMES THEME->GetMetric ("UnlockManager","UnlockNames") -#define UNLOCK(x) THEME->GetMetricR("UnlockManager", ssprintf("Unlock%sCommand",x.c_str())); - -static ThemeMetric AUTO_LOCK_CHALLENGE_STEPS( "UnlockManager", "AutoLockChallengeSteps" ); -static ThemeMetric AUTO_LOCK_EDIT_STEPS( "UnlockManager", "AutoLockEditSteps" ); -static ThemeMetric SONGS_NOT_ADDITIONAL( "UnlockManager", "SongsNotAdditional" ); - -static const char *UnlockRequirementNames[] = -{ - "ArcadePoints", - "DancePoints", - "SongPoints", - "ExtraCleared", - "ExtraFailed", - "Toasties", - "StagesCleared", - "NumberUnlocked" -}; -XToString( UnlockRequirement ); -StringToX( UnlockRequirement ); -LuaXType( UnlockRequirement ); - -static const char *UnlockRewardTypeNames[] = -{ - "Song", - "Steps", - "StepsType", - "Modifier", -}; -XToString( UnlockRewardType ); -XToLocalizedString( UnlockRewardType ); -LuaXType( UnlockRewardType ); -LuaFunction( UnlockRewardTypeToLocalizedString, UnlockRewardTypeToLocalizedString(Enum::Check(L, 1)) ); - -UnlockManager::UnlockManager() -{ - // Register with Lua. - { - Lua *L = LUA->Get(); - lua_pushstring( L, "UNLOCKMAN" ); - this->PushSelf( L ); - lua_settable( L, LUA_GLOBALSINDEX ); - LUA->Release( L ); - } - - UNLOCKMAN = this; - - Load(); -} - -UnlockManager::~UnlockManager() -{ - // Unregister with Lua. - LUA->UnsetGlobal( "UNLOCKMAN" ); -} - -void UnlockManager::UnlockSong( const Song *song ) -{ - const UnlockEntry *p = FindSong( song ); - if( !p ) - return; // does not exist - if( p->m_sEntryID.empty() ) - return; - - UnlockEntryID( p->m_sEntryID ); -} - -RString UnlockManager::FindEntryID( const RString &sName ) const -{ - const UnlockEntry *pEntry = NULL; - - const Song *pSong = SONGMAN->FindSong( sName ); - if( pSong != NULL ) - pEntry = FindSong( pSong ); - - if( pEntry == NULL ) - pEntry = FindModifier( sName ); - - if( pEntry == NULL ) - { - LuaHelpers::ReportScriptErrorFmt( "Couldn't find locked entry \"%s\"", sName.c_str() ); - return ""; - } - - return pEntry->m_sEntryID; -} - -int UnlockManager::SongIsLocked( const Song *pSong ) const -{ - int iRet = 0; - if( PREFSMAN->m_bUseUnlockSystem ) - { - const UnlockEntry *p = FindSong( pSong ); - if( p != NULL && p->IsLocked() ) - { - iRet |= LOCKED_LOCK; - if( !p->m_sEntryID.empty() && m_RouletteCodes.find( p->m_sEntryID ) != m_RouletteCodes.end() ) - iRet |= LOCKED_ROULETTE; - } - } - if( PREFSMAN->m_bHiddenSongs && pSong->m_SelectionDisplay == Song::SHOW_NEVER ) - iRet |= LOCKED_SELECTABLE; - - if( !pSong->m_bEnabled ) - iRet |= LOCKED_DISABLED; - - return iRet; -} - -bool UnlockManager::StepsIsLocked( const Song *pSong, const Steps *pSteps ) const -{ - if( !PREFSMAN->m_bUseUnlockSystem ) - return false; - - const UnlockEntry *p = FindSteps( pSong, pSteps ); - if( p == NULL ) - return false; - - return p->IsLocked(); -} - -bool UnlockManager::StepsTypeIsLocked(const Song *pSong, const Steps *pSteps, const StepsType *pSType) const -{ - if( !PREFSMAN->m_bUseUnlockSystem ) - return false; - - const UnlockEntry *p = FindStepsType( pSong, pSteps, pSType ); - if( p == NULL ) - return false; - - return p->IsLocked(); -} - -bool UnlockManager::ModifierIsLocked( const RString &sOneMod ) const -{ - if( !PREFSMAN->m_bUseUnlockSystem ) - return false; - - const UnlockEntry *p = FindModifier( sOneMod ); - if( p == NULL ) - return false; - - return p->IsLocked(); -} - -const UnlockEntry *UnlockManager::FindSong( const Song *pSong ) const -{ - FOREACH_CONST( UnlockEntry, m_UnlockEntries, e ) - if( e->m_Song.ToSong() == pSong && e->m_dc == Difficulty_Invalid ) - return &(*e); - return NULL; -} - -const UnlockEntry *UnlockManager::FindSteps( const Song *pSong, const Steps *pSteps ) const -{ - ASSERT( pSong && pSteps ); - FOREACH_CONST( UnlockEntry, m_UnlockEntries, e ) - if( e->m_Song.ToSong() == pSong && e->m_dc == pSteps->GetDifficulty() ) - return &(*e); - return NULL; -} - -const UnlockEntry *UnlockManager::FindStepsType(const Song *pSong, - const Steps *pSteps, - const StepsType *pSType ) const -{ - ASSERT( pSong && pSteps && pSType ); - FOREACH_CONST( UnlockEntry, m_UnlockEntries, e ) - if(e->m_Song.ToSong() == pSong && - e->m_dc == pSteps->GetDifficulty() && - e->m_StepsType == pSteps->m_StepsType) - return &(*e); - return NULL; -} - -const UnlockEntry *UnlockManager::FindModifier( const RString &sOneMod ) const -{ - FOREACH_CONST( UnlockEntry, m_UnlockEntries, e ) - if( e->GetModifier().CompareNoCase(sOneMod) == 0 ) - return &(*e); - return NULL; -} - -static float GetArcadePoints( const Profile *pProfile ) -{ - float fAP = 0; - - FOREACH_ENUM( Grade, g ) - { - switch(g) - { - case Grade_Tier01: - case Grade_Tier02: fAP += 9 * pProfile->m_iNumStagesPassedByGrade[g]; break; - default: fAP += 1 * pProfile->m_iNumStagesPassedByGrade[g]; break; - - case Grade_Failed: - case Grade_NoData: - ; // no points - break; - } - } - return fAP; -} - -// TODO: Make this more flexible for games with many grade tiers. Lua-ize it? -Wolfman2000 -static float GetSongPoints( const Profile *pProfile ) -{ - float fSP = 0; - - FOREACH_ENUM( Grade, g ) - { - switch( g ) - { - case Grade_Tier01:/*AAAA*/ fSP += 20 * pProfile->m_iNumStagesPassedByGrade[g]; break; - case Grade_Tier02:/*AAA*/ fSP += 10* pProfile->m_iNumStagesPassedByGrade[g]; break; - case Grade_Tier03:/*AA*/ fSP += 5* pProfile->m_iNumStagesPassedByGrade[g]; break; - case Grade_Tier04:/*A*/ fSP += 4* pProfile->m_iNumStagesPassedByGrade[g]; break; - case Grade_Tier05:/*B*/ fSP += 3* pProfile->m_iNumStagesPassedByGrade[g]; break; - case Grade_Tier06:/*C*/ fSP += 2* pProfile->m_iNumStagesPassedByGrade[g]; break; - case Grade_Tier07:/*D*/ fSP += 1* pProfile->m_iNumStagesPassedByGrade[g]; break; - case Grade_Failed: - case Grade_NoData: - default: - ; // no points - break; - } - } - return fSP; -} - -void UnlockManager::GetPoints( const Profile *pProfile, float fScores[NUM_UnlockRequirement] ) const -{ - fScores[UnlockRequirement_ArcadePoints] = GetArcadePoints( pProfile ); - fScores[UnlockRequirement_SongPoints] = GetSongPoints( pProfile ); - fScores[UnlockRequirement_DancePoints] = (float) pProfile->m_iTotalDancePoints; - fScores[UnlockRequirement_StagesCleared] = (float) pProfile->GetTotalNumSongsPassed(); - //fScores[UnlockRequirement_NumUnlocked] = (float) GetNumUnlocked(); -} - -/* Return true if all songs and/or courses referenced by an unlock are available. */ -bool UnlockEntry::IsValid() const -{ - switch( m_Type ) - { - case UnlockRewardType_Song: - return m_Song.IsValid(); - - case UnlockRewardType_Steps: - return m_Song.IsValid() && m_dc != Difficulty_Invalid; - - case UnlockRewardType_Steps_Type: - { - return m_Song.IsValid() && m_dc != Difficulty_Invalid && m_StepsType != StepsType_Invalid; - } - - case UnlockRewardType_Modifier: - return true; - - default: - WARN( ssprintf("%i", m_Type) ); - return false; - } -} - -UnlockEntryStatus UnlockEntry::GetUnlockEntryStatus() const -{ - set &ids = PROFILEMAN->GetMachineProfile()->m_UnlockedEntryIDs; - if(!m_sEntryID.empty() && - ids.find(m_sEntryID) != ids.end() ) - return UnlockEntryStatus_Unlocked; - - float fScores[NUM_UnlockRequirement]; - UNLOCKMAN->GetPoints( PROFILEMAN->GetMachineProfile(), fScores ); - - for( int i = 0; i < NUM_UnlockRequirement; ++i ) - { - if( i == UnlockRequirement_NumUnlocked ) - continue; - - if( m_fRequirement[i] && fScores[i] >= m_fRequirement[i] ) - return UnlockEntryStatus_RequirementsMet; - } - - if( m_bRequirePassHardSteps && m_Song.IsValid() ) - { - Song *pSong = m_Song.ToSong(); - vector vp; - SongUtil::GetSteps( - pSong, - vp, - StepsType_Invalid, - Difficulty_Hard - ); - FOREACH_CONST( Steps*, vp, s ) - if( PROFILEMAN->GetMachineProfile()->HasPassedSteps(pSong, *s) ) - return UnlockEntryStatus_Unlocked; - } - - if (m_bRequirePassChallengeSteps && m_Song.IsValid()) - { - Song *pSong = m_Song.ToSong(); - vector vp; - SongUtil::GetSteps(pSong, - vp, - StepsType_Invalid, - Difficulty_Challenge); - FOREACH_CONST(Steps*, vp, s) - { - if (PROFILEMAN->GetMachineProfile()->HasPassedSteps(pSong, *s)) - return UnlockEntryStatus_Unlocked; - } - } - - return UnlockEntryStatus_RequrementsNotMet; -} - -RString UnlockEntry::GetDescription() const -{ - Song *pSong = m_Song.ToSong(); - switch( m_Type ) - { - default: - FAIL_M(ssprintf("Invalid UnlockRewardType: %i", m_Type)); - case UnlockRewardType_Song: - return pSong ? pSong->GetDisplayFullTitle() : ""; - case UnlockRewardType_Steps: - { - StepsType st = GAMEMAN->GetHowToPlayStyleForGame( GAMESTATE->m_pCurGame )->m_StepsType; // TODO: Is this the best thing we can do here? - return (pSong ? pSong->GetDisplayFullTitle() : "") + ", " + CustomDifficultyToLocalizedString( GetCustomDifficulty(st, m_dc) ); - } - case UnlockRewardType_Steps_Type: - { - RString ret = (pSong ? pSong->GetDisplayFullTitle() : ""); - ret += "," + CustomDifficultyToLocalizedString( GetCustomDifficulty(m_StepsType, m_dc) ); - return ret + "," + StringConversion::ToString(m_StepsType); // yeah, bit strange. - } - case UnlockRewardType_Modifier: - return CommonMetrics::LocalizeOptionItem( GetModifier(), false ); - } -} - -RString UnlockEntry::GetBannerFile() const -{ - Song *pSong = m_Song.ToSong(); - switch( m_Type ) - { - default: - FAIL_M(ssprintf("Invalid UnlockRewardType: %i", m_Type)); - case UnlockRewardType_Song: - case UnlockRewardType_Steps: - case UnlockRewardType_Steps_Type: - return pSong ? pSong->GetBannerPath() : ""; - case UnlockRewardType_Modifier: - return ""; - } -} - -RString UnlockEntry::GetBackgroundFile() const -{ - Song *pSong = m_Song.ToSong(); - switch( m_Type ) - { - default: - FAIL_M(ssprintf("Invalid UnlockRewardType: %i", m_Type)); - case UnlockRewardType_Song: - case UnlockRewardType_Steps: - case UnlockRewardType_Steps_Type: - return pSong ? pSong->GetBackgroundPath() : ""; - case UnlockRewardType_Modifier: - return ""; - } -} - -///////////////////////////////////////////////////////// - -void UnlockManager::Load() -{ - LOG->Trace( "UnlockManager::Load()" ); - - vector asUnlockNames; - split( UNLOCK_NAMES, ",", asUnlockNames ); - - Lua *L = LUA->Get(); - for( unsigned i = 0; i < asUnlockNames.size(); ++i ) - { - const RString &sUnlockName = asUnlockNames[i]; - - LuaReference cmds = UNLOCK( sUnlockName ); - - UnlockEntry current; - current.m_sEntryID = sUnlockName; // default - - // function - cmds.PushSelf( L ); - ASSERT( !lua_isnil(L, -1) ); - - // 1st parameter - current.PushSelf( L ); - - // call function with 1 argument and 0 results - RString error= "Lua error in command: "; - LuaHelpers::RunScriptOnStack(L, error, 1, 0, true); - - if( current.m_bRoulette ) - m_RouletteCodes.insert( current.m_sEntryID ); - - m_UnlockEntries.push_back( current ); - } - LUA->Release(L); - - if( AUTO_LOCK_CHALLENGE_STEPS ) - { - FOREACH_CONST( Song*, SONGMAN->GetAllSongs(), s ) - { - // If no hard steps to play to unlock, skip - if( SongUtil::GetOneSteps(*s, StepsType_Invalid, Difficulty_Hard) == NULL ) - continue; - - // If no challenge steps to unlock, skip - if( SongUtil::GetOneSteps(*s, StepsType_Invalid, Difficulty_Challenge) == NULL ) - continue; - - if( SONGS_NOT_ADDITIONAL && SONGMAN->WasLoadedFromAdditionalSongs(*s) ) - continue; - - UnlockEntry ue; - ue.m_sEntryID = "_challenge_" + (*s)->GetSongDir(); - ue.m_Type = UnlockRewardType_Steps; - ue.m_cmd.Load( (*s)->m_sGroupName+"/"+(*s)->GetTranslitFullTitle()+",expert" ); - ue.m_bRequirePassHardSteps = true; - - m_UnlockEntries.push_back( ue ); - } - } - - if (AUTO_LOCK_EDIT_STEPS) - { - FOREACH_CONST( Song*, SONGMAN->GetAllSongs(), s ) - { - // no challenge steps to play: skip. - if (SongUtil::GetOneSteps(*s, StepsType_Invalid, Difficulty_Challenge) == NULL) - continue; - - // no edit steps to unlock: skip. - if (SongUtil::GetOneSteps(*s, StepsType_Invalid, Difficulty_Edit) == NULL) - continue; - - // don't add additional songs. - if (SONGS_NOT_ADDITIONAL && SONGMAN->WasLoadedFromAdditionalSongs(*s)) - continue; - - UnlockEntry ue; - ue.m_sEntryID = "_edit_" + (*s)->GetSongDir(); - ue.m_Type = UnlockRewardType_Steps; - ue.m_cmd.Load( (*s)->m_sGroupName+"/"+(*s)->GetTranslitFullTitle()+",edit" ); - ue.m_bRequirePassChallengeSteps = true; - - m_UnlockEntries.push_back(ue); - - } - } - - // Make sure that we don't have duplicate unlock IDs. This can cause problems - // with UnlockCelebrate and with codes. - FOREACH_CONST( UnlockEntry, m_UnlockEntries, ue ) - FOREACH_CONST( UnlockEntry, m_UnlockEntries, ue2 ) - if( ue != ue2 ) - ASSERT_M( ue->m_sEntryID != ue2->m_sEntryID, ssprintf("duplicate unlock entry id %s",ue->m_sEntryID.c_str()) ); - - FOREACH( UnlockEntry, m_UnlockEntries, e ) - { - switch( e->m_Type ) - { - case UnlockRewardType_Song: - e->m_Song.FromSong( SONGMAN->FindSong( e->m_cmd.GetArg(0).s ) ); - if( !e->m_Song.IsValid() ) - LuaHelpers::ReportScriptErrorFmt( "Unlock: Cannot find song matching \"%s\"", e->m_cmd.GetArg(0).s.c_str() ); - break; - case UnlockRewardType_Steps: - e->m_Song.FromSong( SONGMAN->FindSong( e->m_cmd.GetArg(0).s ) ); - if( !e->m_Song.IsValid() ) - { - LuaHelpers::ReportScriptErrorFmt( "Unlock: Cannot find song matching \"%s\"", e->m_cmd.GetArg(0).s.c_str() ); - break; - } - - e->m_dc = StringToDifficulty( e->m_cmd.GetArg(1).s ); - if( e->m_dc == Difficulty_Invalid ) - { - LuaHelpers::ReportScriptErrorFmt( "Unlock: Invalid difficulty \"%s\"", e->m_cmd.GetArg(1).s.c_str() ); - break; - } - - break; - case UnlockRewardType_Steps_Type: - { - e->m_Song.FromSong( SONGMAN->FindSong( e->m_cmd.GetArg(0).s ) ); - if( !e->m_Song.IsValid() ) - { - LuaHelpers::ReportScriptErrorFmt( "Unlock: Cannot find song matching \"%s\"", e->m_cmd.GetArg(0).s.c_str() ); - break; - } - - e->m_dc = StringToDifficulty( e->m_cmd.GetArg(1).s ); - if( e->m_dc == Difficulty_Invalid ) - { - LuaHelpers::ReportScriptErrorFmt( "Unlock: Invalid difficulty \"%s\"", e->m_cmd.GetArg(1).s.c_str() ); - break; - } - - e->m_StepsType = GAMEMAN->StringToStepsType(e->m_cmd.GetArg(2).s); - if (e->m_StepsType == StepsType_Invalid) - { - LuaHelpers::ReportScriptErrorFmt( "Unlock: Invalid steps type \"%s\"", e->m_cmd.GetArg(2).s.c_str() ); - break; - } - break; - } - case UnlockRewardType_Modifier: - // nothing to cache - break; - default: - FAIL_M(ssprintf("Invalid UnlockRewardType: %i", e->m_Type)); - } - } - - // Log unlocks - FOREACH_CONST( UnlockEntry, m_UnlockEntries, e ) - { - RString str = ssprintf( "Unlock: %s; ", join("\n",e->m_cmd.m_vsArgs).c_str() ); - FOREACH_ENUM( UnlockRequirement, j ) - if( e->m_fRequirement[j] ) - str += ssprintf( "%s = %f; ", UnlockRequirementToString(j).c_str(), e->m_fRequirement[j] ); - if( e->m_bRequirePassHardSteps ) - str += "RequirePassHardSteps; "; - if (e->m_bRequirePassChallengeSteps) - str += "RequirePassChallengeSteps; "; - - str += ssprintf( "entryID = %s ", e->m_sEntryID.c_str() ); - str += e->IsLocked()? "locked":"unlocked"; - if( e->m_Song.IsValid() ) - str += ( " (found song)" ); - LOG->Trace( "%s", str.c_str() ); - } - - return; -} - - -void UnlockManager::Reload() -{ - // clear old data, if any - m_UnlockEntries.clear(); - m_RouletteCodes.clear(); - - Load(); -} - -float UnlockManager::PointsUntilNextUnlock( UnlockRequirement t ) const -{ - float fScores[NUM_UnlockRequirement]; - ZERO( fScores ); - GetPoints( PROFILEMAN->GetMachineProfile(), fScores ); - - float fSmallestPoints = FLT_MAX; // or an arbitrarily large value - for( unsigned a=0; a fScores[t] ) - fSmallestPoints = min( fSmallestPoints, m_UnlockEntries[a].m_fRequirement[t] ); - - if( fSmallestPoints == FLT_MAX ) - return 0; // no match found - return fSmallestPoints - fScores[t]; -} - -void UnlockManager::UnlockEntryID( const RString &sEntryID ) -{ - PROFILEMAN->GetMachineProfile()->m_UnlockedEntryIDs.insert( sEntryID ); -} - -void UnlockManager::UnlockEntryIndex( int iEntryIndex ) -{ - RString sEntryID = m_UnlockEntries[iEntryIndex].m_sEntryID; - UnlockEntryID( sEntryID ); -} - -void UnlockManager::LockEntryID( RString entryID ) -{ - PROFILEMAN->GetMachineProfile()->m_UnlockedEntryIDs.erase( entryID ); -} - -void UnlockManager::LockEntryIndex( int entryIndex ) -{ - RString entryID = m_UnlockEntries[entryIndex].m_sEntryID; - LockEntryID( entryID ); -} - -void UnlockManager::PreferUnlockEntryID( const RString &sUnlockEntryID ) -{ - for( unsigned i = 0; i < m_UnlockEntries.size(); ++i ) - { - UnlockEntry &pEntry = m_UnlockEntries[i]; - if( pEntry.m_sEntryID != sUnlockEntryID ) - continue; - - if( pEntry.m_Song.ToSong() != NULL ) - GAMESTATE->m_pPreferredSong = pEntry.m_Song.ToSong(); - } -} - -int UnlockManager::GetNumUnlocks() const -{ - return m_UnlockEntries.size(); -} - -int UnlockManager::GetNumUnlocked() const -{ - int count = 0; - FOREACH_CONST( UnlockEntry, m_UnlockEntries, ue ) - { - if( !ue->IsLocked() ) - count++; - } - return count; -} - -int UnlockManager::GetUnlockEntryIndexToCelebrate() const -{ - FOREACH_CONST( UnlockEntry, m_UnlockEntries, ue ) - { - if( ue->GetUnlockEntryStatus() == UnlockEntryStatus_RequirementsMet ) - return ue - m_UnlockEntries.begin(); - } - return -1; -} - -bool UnlockManager::AnyUnlocksToCelebrate() const -{ - return GetUnlockEntryIndexToCelebrate() != -1; -} - -void UnlockManager::GetUnlocksByType( UnlockRewardType t, vector &apEntries ) -{ - for( unsigned i = 0; i < m_UnlockEntries.size(); ++i ) - if( m_UnlockEntries[i].IsValid() && m_UnlockEntries[i].m_Type == t ) - apEntries.push_back( &m_UnlockEntries[i] ); -} - -void UnlockManager::GetSongsUnlockedByEntryID( vector &apSongsOut, RString sUnlockEntryID ) -{ - vector apEntries; - GetUnlocksByType( UnlockRewardType_Song, apEntries ); - - for( unsigned i = 0; i < apEntries.size(); ++i ) - if( apEntries[i]->m_sEntryID == sUnlockEntryID ) - apSongsOut.push_back( apEntries[i]->m_Song.ToSong() ); -} - -void UnlockManager::GetStepsUnlockedByEntryID( vector &apSongsOut, vector &apDifficultyOut, const RString &sUnlockEntryID ) -{ - vector apEntries; - GetUnlocksByType( UnlockRewardType_Steps, apEntries ); - - for( unsigned i = 0; i < apEntries.size(); ++i ) - { - if( apEntries[i]->m_sEntryID == sUnlockEntryID ) - { - apSongsOut.push_back( apEntries[i]->m_Song.ToSong() ); - apDifficultyOut.push_back( apEntries[i]->m_dc ); - } - } -} - - -// lua start -#include "LuaBinding.h" - -/** @brief Allow Lua to have access to the UnlockEntry. */ -class LunaUnlockEntry: public Luna -{ -public: - static int IsLocked( T* p, lua_State *L ) { lua_pushboolean(L, p->IsLocked() ); return 1; } - static int GetDescription( T* p, lua_State *L ) { lua_pushstring(L, p->GetDescription() ); return 1; } - static int GetUnlockRewardType( T* p, lua_State *L ) { lua_pushnumber(L, p->m_Type ); return 1; } - static int GetRequirement( T* p, lua_State *L ) { UnlockRequirement i = Enum::Check( L, 1 ); lua_pushnumber(L, p->m_fRequirement[i] ); return 1; } - static int GetRequirePassHardSteps( T* p, lua_State *L ){ lua_pushboolean(L, p->m_bRequirePassHardSteps); return 1; } - static int GetRequirePassChallengeSteps( T* p, lua_State *L ) - { - lua_pushboolean(L, p->m_bRequirePassChallengeSteps); - return 1; - } - static int GetSong( T* p, lua_State *L ) - { - Song *pSong = p->m_Song.ToSong(); - if( pSong ) { pSong->PushSelf(L); return 1; } - return 0; - } - // Get all of the steps locked based on difficulty (similar to In The Groove 2). - static int GetStepOfAllTypes( T* p, lua_State *L ) - { - Song *pSong = p->m_Song.ToSong(); - if (pSong) - { - const vector& allSteps = pSong->GetAllSteps(); - vector toRet; - FOREACH_CONST(Steps*, allSteps, step) - { - if ((*step)->GetDifficulty() == p->m_dc) - { - toRet.push_back(*step); - } - } - LuaHelpers::CreateTableFromArray( toRet, L ); - return 1; - } - return 0; - } - - // TODO: Add a function to just get all steps. - static int GetStepByStepsType( T* p, lua_State *L ) - { - Song *pSong = p->m_Song.ToSong(); - if (pSong) - { - const vector& allStepsType = pSong->GetStepsByStepsType(p->m_StepsType); - FOREACH_CONST(Steps*, allStepsType, step) - { - if ((*step)->GetDifficulty() == p->m_dc) - { - (*step)->PushSelf(L); return 1; - } - } - } - return 0; - } - - static int GetCode( T* p, lua_State *L ) - { - lua_pushstring( L, p->m_sEntryID ); - return 1; - } - - // internal - static int GetArgs( T* p, lua_State *L ) - { - Command cmd; - for( int i = 1; i <= lua_gettop(L); ++i ) - cmd.m_vsArgs.push_back( SArg(i) ); - p->m_cmd = cmd; - return 0; - } - - static int song( T* p, lua_State *L ) { GetArgs( p, L ); p->m_Type = UnlockRewardType_Song; return 0; } - static int steps( T* p, lua_State *L ) { GetArgs( p, L ); p->m_Type = UnlockRewardType_Steps; return 0; } - static int steps_type(T* p, lua_State *L) { GetArgs(p, L); p->m_Type = UnlockRewardType_Steps_Type; return 0; } - static int mod( T* p, lua_State *L ) { GetArgs( p, L ); p->m_Type = UnlockRewardType_Modifier; return 0; } - static int code( T* p, lua_State *L ) { p->m_sEntryID = SArg(1); return 0; } - static int roulette( T* p, lua_State *L ) { p->m_bRoulette = true; return 0; } - static int requirepasshardsteps( T* p, lua_State *L ) { p->m_bRequirePassHardSteps = true; return 0; } - static int requirepasschallengesteps( T* p, lua_State *L ) { p->m_bRequirePassChallengeSteps = true; return 0; } - static int require( T* p, lua_State *L ) - { - const UnlockRequirement ut = Enum::Check( L, 1 ); - if( ut != UnlockRequirement_Invalid ) - p->m_fRequirement[ut] = FArg(2); - return 0; - } - - LunaUnlockEntry() - { - ADD_METHOD( IsLocked ); - ADD_METHOD( GetCode ); - ADD_METHOD( GetDescription ); - ADD_METHOD( GetUnlockRewardType ); - ADD_METHOD( GetRequirement ); - ADD_METHOD( GetRequirePassHardSteps ); - ADD_METHOD( GetRequirePassChallengeSteps ); - ADD_METHOD( GetSong ); - ADD_METHOD( GetStepOfAllTypes ); - ADD_METHOD( GetStepByStepsType ); - ADD_METHOD( song ); - ADD_METHOD( steps ); - ADD_METHOD( steps_type ); - ADD_METHOD( mod ); - ADD_METHOD( code ); - ADD_METHOD( roulette ); - ADD_METHOD( requirepasshardsteps ); - ADD_METHOD( requirepasschallengesteps ); - ADD_METHOD( require ); - } -}; - -LUA_REGISTER_CLASS( UnlockEntry ) - -/** @brief Allow Lua to have access to the UnlockManager. */ -class LunaUnlockManager: public Luna -{ -public: - static int GetPointsUntilNextUnlock( T* p, lua_State *L ) - { - const UnlockRequirement ut = Enum::Check( L, 1 ); - lua_pushnumber( L, p->PointsUntilNextUnlock(ut) ); - return 1; - } - static int FindEntryID( T* p, lua_State *L ) { RString sName = SArg(1); RString s = p->FindEntryID(sName); if( s.empty() ) lua_pushnil(L); else lua_pushstring(L, s); return 1; } - static int UnlockEntryID( T* p, lua_State *L ) { RString sUnlockEntryID = SArg(1); p->UnlockEntryID(sUnlockEntryID); COMMON_RETURN_SELF; } - static int UnlockEntryIndex( T* p, lua_State *L ) { int iUnlockEntryID = IArg(1); p->UnlockEntryIndex(iUnlockEntryID); COMMON_RETURN_SELF; } - static int LockEntryID( T * p, lua_State * L) - { - RString entryID = SArg(1); - p->LockEntryID( entryID ); - COMMON_RETURN_SELF; - } - static int LockEntryIndex( T * p, lua_State * L) - { - int entryIndex = IArg(1); - p->LockEntryIndex( entryIndex ); - COMMON_RETURN_SELF; - } - static int PreferUnlockEntryID( T* p, lua_State *L ) { RString sUnlockEntryID = SArg(1); p->PreferUnlockEntryID(sUnlockEntryID); COMMON_RETURN_SELF; } - static int GetNumUnlocks( T* p, lua_State *L ) { lua_pushnumber( L, p->GetNumUnlocks() ); return 1; } - static int GetNumUnlocked( T* p, lua_State *L ) { lua_pushnumber( L, p->GetNumUnlocked() ); return 1; } - static int GetUnlockEntryIndexToCelebrate( T* p, lua_State *L ) { lua_pushnumber( L, p->GetUnlockEntryIndexToCelebrate() ); return 1; } - static int AnyUnlocksToCelebrate( T* p, lua_State *L ) { lua_pushboolean( L, p->AnyUnlocksToCelebrate() ); return 1; } - static int GetUnlockEntry( T* p, lua_State *L ) { unsigned iIndex = IArg(1); if( iIndex >= p->m_UnlockEntries.size() ) return 0; p->m_UnlockEntries[iIndex].PushSelf(L); return 1; } - static int GetSongsUnlockedByEntryID( T* p, lua_State *L ) - { - vector apSongs; - UNLOCKMAN->GetSongsUnlockedByEntryID( apSongs, SArg(1) ); - LuaHelpers::CreateTableFromArray( apSongs, L ); - return 1; - } - - static int GetStepsUnlockedByEntryID( T* p, lua_State *L ) - { - // Return the Song each Steps are associated with, too. - vector apSongs; - vector apDifficulty; - UNLOCKMAN->GetStepsUnlockedByEntryID( apSongs, apDifficulty, SArg(1) ); - LuaHelpers::CreateTableFromArray( apSongs, L ); - LuaHelpers::CreateTableFromArray( apDifficulty, L ); - return 2; - } - - static int GetPoints( T* p, lua_State *L ) { - float fScores[NUM_UnlockRequirement]; - UNLOCKMAN->GetPoints( PROFILEMAN->GetMachineProfile(), fScores ); - lua_pushnumber( L, fScores[Enum::Check(L, 1)] ); - return 1; - } - - static int GetPointsForProfile( T* p, lua_State *L ) { - float fScores[NUM_UnlockRequirement]; - UNLOCKMAN->GetPoints( Luna::check(L,1), fScores ); - lua_pushnumber( L, fScores[Enum::Check(L, 2)] ); - return 1; - } - - static int IsSongLocked( T* p, lua_State *L ) - { - Song *pSong = Luna::check(L,1); - lua_pushnumber( L, UNLOCKMAN->SongIsLocked(pSong)); - return 1; - } - - LunaUnlockManager() - { - ADD_METHOD( AnyUnlocksToCelebrate ); - ADD_METHOD( FindEntryID ); - ADD_METHOD( GetNumUnlocks ); - ADD_METHOD( GetNumUnlocked ); - ADD_METHOD( GetPoints ); - ADD_METHOD( GetPointsForProfile ); - ADD_METHOD( GetPointsUntilNextUnlock ); - ADD_METHOD( GetSongsUnlockedByEntryID ); - ADD_METHOD( GetStepsUnlockedByEntryID ); - ADD_METHOD( GetUnlockEntry ); - ADD_METHOD( GetUnlockEntryIndexToCelebrate ); - ADD_METHOD( PreferUnlockEntryID ); - ADD_METHOD( UnlockEntryID ); - ADD_METHOD( UnlockEntryIndex ); - ADD_METHOD( LockEntryID ); - ADD_METHOD( LockEntryIndex ); - ADD_METHOD( IsSongLocked ); - //ADD_METHOD( UnlockSong ); - //ADD_METHOD( GetUnlocksByType ); - } -}; - -LUA_REGISTER_CLASS( UnlockManager ) -// lua end - -/* - * (c) 2001-2004 Kevin Slaughter, Andrew Wong, Glenn Maynard - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons to - * whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF - * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS - * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT - * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS - * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR - * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ diff --git a/src/UnlockManager.h b/src/UnlockManager.h index 00c05db643..e69de29bb2 100644 --- a/src/UnlockManager.h +++ b/src/UnlockManager.h @@ -1,203 +0,0 @@ -/* UnlockManager - Unlocks handling. */ - -#ifndef UNLOCK_MANAGER_H -#define UNLOCK_MANAGER_H - -#include "Grade.h" -#include "Command.h" -#include -#include "Difficulty.h" -#include "SongUtil.h" - -class Song; -class Steps; -class Profile; -struct lua_State; - -/** @brief What is needed to unlock an item? */ -enum UnlockRequirement -{ - UnlockRequirement_ArcadePoints, /**< Get a certain number of arcade points. */ - UnlockRequirement_DancePoints, /**< Get a certain number of dance points. */ - UnlockRequirement_SongPoints, /**< Get a certain number of song points. */ - UnlockRequirement_ExtraCleared, /**< Pass the extra stage. */ - UnlockRequirement_ExtraFailed, /**< Fail the extra stage. */ - UnlockRequirement_Toasties, /**< Get a number of toasties. */ - UnlockRequirement_StagesCleared, /**< Clear a number of stages. */ - UnlockRequirement_NumUnlocked, /**< Have a number of locked items already unlocked. */ - NUM_UnlockRequirement, - UnlockRequirement_Invalid, -}; -LuaDeclareType( UnlockRequirement ); - - -enum UnlockRewardType { - UnlockRewardType_Song, /**< A song is unlocked. */ - UnlockRewardType_Steps, /**< A step pattern for all styles is unlocked. */ - UnlockRewardType_Steps_Type, /**< A step pattern for a specific style is unlocked. */ - UnlockRewardType_Modifier, /**< A modifier is unlocked. */ - NUM_UnlockRewardType, - UnlockRewardType_Invalid -}; -const RString& UnlockRewardTypeToString( UnlockRewardType i ); -const RString& UnlockRewardTypeToLocalizedString( UnlockRewardType i ); -LuaDeclareType( UnlockRewardType ); - -enum UnlockEntryStatus { - UnlockEntryStatus_RequrementsNotMet, - UnlockEntryStatus_RequirementsMet, - UnlockEntryStatus_Unlocked, -}; - -class UnlockEntry -{ -public: - /** - * @brief Set up the UnlockEntry with default values. - * - * m_sEntryID starts as an empty string. It will be filled automatically - * if not specified. */ - UnlockEntry(): m_Type(UnlockRewardType_Invalid), m_cmd(), - m_Song(), m_dc(Difficulty_Invalid), - m_StepsType(StepsType_Invalid), m_bRequirePassHardSteps(false), - m_bRequirePassChallengeSteps(false), m_bRoulette(false), - m_sEntryID(RString("")) - { - ZERO( m_fRequirement ); - } - - UnlockRewardType m_Type; - Command m_cmd; - - /* A cached pointer to the song or course this entry refers to. Only one of - * these will be non-NULL. */ - SongID m_Song; - Difficulty m_dc; - StepsType m_StepsType; - - float m_fRequirement[NUM_UnlockRequirement]; // unlocked if any of of these are met - /** @brief Must the hard steps be passed to unlock a higher level? */ - bool m_bRequirePassHardSteps; - /** @brief Must the challenge steps be passed to unlock a higher level? */ - bool m_bRequirePassChallengeSteps; - bool m_bRoulette; - RString m_sEntryID; - - bool IsValid() const; - bool IsLocked() const { return GetUnlockEntryStatus() != UnlockEntryStatus_Unlocked; } - UnlockEntryStatus GetUnlockEntryStatus() const; - RString GetModifier() const { return m_cmd.GetArg(1).s; } - RString GetDescription() const; - RString GetBannerFile() const; - RString GetBackgroundFile() const; - - // Lua - void PushSelf( lua_State *L ); -}; - -// Option is locked due to an unsatisfied unlock entry. -#define LOCKED_LOCK 0x1 - -// Option is only available in random selections. -#define LOCKED_ROULETTE 0x2 - -// Option is locked due to a #SELECTABLE tag. -#define LOCKED_SELECTABLE 0x4 - -// Option is disabled by the operator. (For courses, this means that a song in the -// course is disabled.) -#define LOCKED_DISABLED 0x8 - -class UnlockManager -{ - friend class UnlockEntry; - -public: - UnlockManager(); - ~UnlockManager(); - void Reload(); - - float PointsUntilNextUnlock( UnlockRequirement t ) const; - int SongIsLocked( const Song *pSong ) const; - bool StepsIsLocked( const Song *pSong, const Steps *pSteps ) const; - bool StepsTypeIsLocked( const Song *pSong, const Steps *pSteps, const StepsType *pSType ) const; - bool ModifierIsLocked( const RString &sOneMod ) const; - - // Gets number of unlocks for title screen - int GetNumUnlocks() const; - int GetNumUnlocked() const; - int GetUnlockEntryIndexToCelebrate() const; - bool AnyUnlocksToCelebrate() const; - - void GetPoints( const Profile *pProfile, float fScores[NUM_UnlockRequirement] ) const; - - // Unlock an entry by code. - void UnlockEntryID( const RString &sEntryID ); - void UnlockEntryIndex( int iEntryIndex ); - - // Lock an entry by code. - void LockEntryID( RString entryID ); - void LockEntryIndex( int entryIndex ); - - /* - * If a code is associated with at least one song or course, set the preferred song - * and/or course in GAMESTATE to them. - */ - void PreferUnlockEntryID( const RString &sEntryID ); - - // Unlocks a song. - void UnlockSong( const Song *pSong ); - - // Return the associated EntryID. - RString FindEntryID( const RString &sName ) const; - - // All locked songs are stored here - vector m_UnlockEntries; - - void GetUnlocksByType( UnlockRewardType t, vector &apEntries ); - void GetSongsUnlockedByEntryID( vector &apSongsOut, RString sEntryID ); - void GetStepsUnlockedByEntryID( vector &apSongsOut, vector &apStepsOut, const RString &sEntryID ); - - const UnlockEntry *FindSong( const Song *pSong ) const; - const UnlockEntry *FindSteps( const Song *pSong, const Steps *pSteps ) const; - const UnlockEntry *FindStepsType( const Song *pSong, const Steps *pSteps, const StepsType *pSType ) const; - const UnlockEntry *FindModifier( const RString &sOneMod ) const; - - // Lua - void PushSelf( lua_State *L ); - -private: - // read unlocks - void Load(); - - set m_RouletteCodes; // "codes" which are available in roulette and which unlock if rouletted -}; - -extern UnlockManager* UNLOCKMAN; // global and accessible from anywhere in program - -#endif - -/* - * (c) 2001-2004 Kevin Slaughter, Andrew Wong, Glenn Maynard - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons to - * whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF - * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS - * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT - * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS - * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR - * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */