diff --git a/src/NotesLoaderBMS.cpp b/src/NotesLoaderBMS.cpp index 4fd1ccc054..b1a2d44836 100644 --- a/src/NotesLoaderBMS.cpp +++ b/src/NotesLoaderBMS.cpp @@ -1243,7 +1243,7 @@ void BMSSongLoader::AddToSong() bool BMSLoader::LoadNoteDataFromSimfile( const RString & cachePath, Steps & out ) { - Song *pSong = SONGMAN->GetSongFromSteps( &out ); + Song *pSong = out.m_pSong; // before doing anything else, load the chart first! BMSChart chart; diff --git a/src/ScreenOptionsManageEditSteps.cpp b/src/ScreenOptionsManageEditSteps.cpp index f009ff6cbb..3a6b646bcb 100644 --- a/src/ScreenOptionsManageEditSteps.cpp +++ b/src/ScreenOptionsManageEditSteps.cpp @@ -87,7 +87,7 @@ void ScreenOptionsManageEditSteps::BeginScreen() vHands.push_back( OptionRowHandlerUtil::MakeNull() ); OptionRowDefinition &def = vHands.back()->m_Def; - Song *pSong = SONGMAN->GetSongFromSteps( *s ); + Song *pSong = (*s)->m_pSong; def.m_sName = pSong->GetTranslitFullTitle() + " - " + (*s)->GetDescription(); def.m_bAllowThemeTitle = false; // not themable @@ -153,7 +153,7 @@ void ScreenOptionsManageEditSteps::HandleScreenMessage( const ScreenMessage SM ) ASSERT( ScreenTextEntry::s_sLastAnswer != "" ); // validate should have assured this Steps *pSteps = GAMESTATE->m_pCurSteps[PLAYER_1]; - Song *pSong = SONGMAN->GetSongFromSteps( pSteps ); + Song *pSong = pSteps->m_pSong; RString sOldDescription = pSteps->GetDescription(); pSteps->SetDescription( ScreenTextEntry::s_sLastAnswer ); @@ -190,7 +190,7 @@ void ScreenOptionsManageEditSteps::HandleScreenMessage( const ScreenMessage SM ) case StepsEditAction_Edit: { Steps *pSteps = GetStepsWithFocus(); - Song *pSong = SONGMAN->GetSongFromSteps( pSteps ); + Song *pSong = pSteps->m_pSong; GAMESTATE->m_pCurSong.Set( pSong ); GAMESTATE->m_pCurSteps[PLAYER_1].Set( pSteps ); @@ -230,7 +230,7 @@ void ScreenOptionsManageEditSteps::HandleScreenMessage( const ScreenMessage SM ) void ScreenOptionsManageEditSteps::AfterChangeRow( PlayerNumber pn ) { Steps *pSteps = GetStepsWithFocus(); - Song *pSong = pSteps ? SONGMAN->GetSongFromSteps( pSteps ) : NULL; + Song *pSong = pSteps ? pSteps->m_pSong : NULL; GAMESTATE->m_pCurSong.Set( pSong ); GAMESTATE->m_pCurSteps[PLAYER_1].Set( pSteps ); diff --git a/src/SongManager.cpp b/src/SongManager.cpp index 0558824d46..4450f1db85 100644 --- a/src/SongManager.cpp +++ b/src/SongManager.cpp @@ -1127,30 +1127,9 @@ void SongManager::GetStepsLoadedFromProfile( vector &AddTo, ProfileSlot } } -Song *SongManager::GetSongFromSteps( Steps *pSteps ) const -{ - ASSERT( pSteps != NULL ); - const vector &vSongs = GetAllSongs(); - FOREACH_CONST( Song*, vSongs, song ) - { - vector vSteps; - SongUtil::GetSteps( *song, vSteps ); - - FOREACH_CONST( Steps*, vSteps, steps ) - { - if( *steps == pSteps ) - { - return *song; - } - } - } - FAIL_M("No song found for steps"); -} - void SongManager::DeleteSteps( Steps *pSteps ) { - Song *pSong = GetSongFromSteps( pSteps ); - pSong->DeleteSteps( pSteps ); + pSteps->m_pSong->DeleteSteps( pSteps ); } bool SongManager::WasLoadedFromAdditionalSongs( const Song *pSong ) const @@ -1942,11 +1921,12 @@ public: static int GetNumCourses( T* p, lua_State *L ) { lua_pushnumber( L, p->GetNumCourses() ); return 1; } static int GetNumAdditionalCourses( T* p, lua_State *L ){ lua_pushnumber( L, p->GetNumAdditionalCourses() ); return 1; } static int GetNumCourseGroups( T* p, lua_State *L ) { lua_pushnumber( L, p->GetNumCourseGroups() ); return 1; } + /* Note: this could now be implemented as Luna::GetSong */ static int GetSongFromSteps( T* p, lua_State *L ) { Song *pSong = NULL; - if( lua_isnil(L,1) ) { pSong = p->GetSongFromSteps( NULL ); } - else { Steps *pSteps = Luna::check(L,1); pSong = p->GetSongFromSteps( pSteps ); } + if( lua_isnil(L,1) ) { pSong = NULL; } + else { Steps *pSteps = Luna::check(L,1); pSong = pSteps->m_pSong; } if(pSong) pSong->PushSelf(L); else lua_pushnil(L); return 1; diff --git a/src/SongManager.h b/src/SongManager.h index 2ad3ff6ace..0ddb5bd69a 100644 --- a/src/SongManager.h +++ b/src/SongManager.h @@ -144,7 +144,6 @@ public: int GetSongRank(Song* pSong); void GetStepsLoadedFromProfile( vector &AddTo, ProfileSlot slot ) const; - Song *GetSongFromSteps( Steps *pSteps ) const; void DeleteSteps( Steps *pSteps ); // transfers ownership of pSteps bool WasLoadedFromAdditionalSongs( const Song *pSong ) const; bool WasLoadedFromAdditionalCourses( const Course *pCourse ) const; diff --git a/src/SongUtil.cpp b/src/SongUtil.cpp index 8b03b31233..eb57e74288 100644 --- a/src/SongUtil.cpp +++ b/src/SongUtil.cpp @@ -795,7 +795,7 @@ static LocalizedString EDIT_NAME_CANNOT_CONTAIN ( "SongUtil", "The edit name can bool SongUtil::ValidateCurrentEditStepsDescription( const RString &sAnswer, RString &sErrorOut ) { Steps *pSteps = GAMESTATE->m_pCurSteps[PLAYER_1]; - Song *pSong = SONGMAN->GetSongFromSteps( pSteps ); + Song *pSong = pSteps->m_pSong; ASSERT( pSteps->IsAnEdit() );