From 326b1d4df059995c6af5950d497511eebb055ad2 Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Mon, 16 Sep 2002 00:56:30 +0000 Subject: [PATCH] Missing a music file is no longer a fatal error. --- stepmania/src/NotesLoaderBMS.cpp | 10 ++++++---- stepmania/src/NotesLoaderDWI.cpp | 2 +- stepmania/src/ScreenEditMenu.cpp | 10 +++++++++- stepmania/src/ScreenHowToPlay.cpp | 1 + stepmania/src/ScreenPrompt.cpp | 6 ++++-- stepmania/src/ScreenSelectMusic.cpp | 2 +- stepmania/src/Song.cpp | 18 +++++++++++++----- stepmania/src/SongManager.cpp | 10 +++++++--- 8 files changed, 42 insertions(+), 17 deletions(-) diff --git a/stepmania/src/NotesLoaderBMS.cpp b/stepmania/src/NotesLoaderBMS.cpp index ec3c1544f7..e29ee36c59 100644 --- a/stepmania/src/NotesLoaderBMS.cpp +++ b/stepmania/src/NotesLoaderBMS.cpp @@ -69,7 +69,7 @@ bool BMSLoader::LoadFromBMSFile( const CString &sPath, Notes &out ) CStdioFile file; if( !file.Open( sPath, CFile::modeRead|CFile::shareDenyNone ) ) - throw RageException( "Failed to open %s.", sPath ); + throw RageException( "Failed to open %s for reading.", sPath ); CString line; while( file.ReadString(line) ) // foreach line @@ -115,6 +115,8 @@ bool BMSLoader::LoadFromBMSFile( const CString &sPath, Notes &out ) case 3: // double out.m_NotesType = NOTES_TYPE_DANCE_DOUBLE; break; + default: + throw RageException( "Invalid value '%d' for '#player'", atoi(value_data) ); } } if( -1 != value_name.Find("#title") ) @@ -285,7 +287,7 @@ bool BMSLoader::LoadFromDir( CString sDir, Song &out ) CStdioFile file; if( !file.Open( sPath, CFile::modeRead|CFile::shareDenyNone ) ) - throw RageException( "Failed to open %s.", sPath ); + throw RageException( "Failed to open %s for reading.", sPath ); CString line; while( file.ReadString(line) ) // foreach line @@ -422,7 +424,7 @@ bool BMSLoader::LoadFromDir( CString sDir, Song &out ) // open the song file again and and look for this tag's value CStdioFile file; if( !file.Open( sPath, CFile::modeRead|CFile::shareDenyNone ) ) - throw RageException( "Failed to open %s.", sPath ); + throw RageException( "Failed to open %s for reading.", sPath ); CString line; while( file.ReadString(line) ) // foreach line @@ -484,7 +486,7 @@ bool BMSLoader::LoadFromDir( CString sDir, Song &out ) // open the song file again and and look for this tag's value CStdioFile file; if( !file.Open( sPath, CFile::modeRead|CFile::shareDenyNone ) ) - throw RageException( "Failed to open %s.", sPath ); + throw RageException( "Failed to open %s for reading.", sPath ); CString line; while( file.ReadString(line) ) // foreach line diff --git a/stepmania/src/NotesLoaderDWI.cpp b/stepmania/src/NotesLoaderDWI.cpp index 166a5a7400..c7e272619a 100644 --- a/stepmania/src/NotesLoaderDWI.cpp +++ b/stepmania/src/NotesLoaderDWI.cpp @@ -250,7 +250,7 @@ bool DWILoader::LoadFromDWIFile( CString sPath, Song &out ) MsdFile msd; bool bResult = msd.ReadFile( sPath ); if( !bResult ) - throw RageException( "Error opening file '%s'.", sPath ); + throw RageException( "Error opening file '%s' for reading.", sPath ); for( int i=0; im_pCurSong = Selector.GetSelectedSong(); + + if( !GAMESTATE->m_pCurSong->HasMusic() ) + { + SCREENMAN->SystemMessage( "This song is missing a music file and cannot be edited" ); + SOUND->PlayOnceStreamed( THEME->GetPathTo("Sounds","menu invalid") ); + return; + } + MUSIC->Stop(); - GAMESTATE->m_pCurSong = Selector.GetSelectedSong(); // get the style GAMESTATE->m_CurStyle = Selector.GetSelectedStyle(); diff --git a/stepmania/src/ScreenHowToPlay.cpp b/stepmania/src/ScreenHowToPlay.cpp index 2f6e110e45..6753d6a17d 100644 --- a/stepmania/src/ScreenHowToPlay.cpp +++ b/stepmania/src/ScreenHowToPlay.cpp @@ -142,6 +142,7 @@ void ScreenHowToPlay::MenuStart( PlayerNumber pn ) { m_Menu.TweenOffScreenToMenu( SM_GoToNextScreen ); + m_sprHowToPlay.StopTweening(); m_sprHowToPlay.BeginTweening( 0.3f, Actor::TWEEN_BIAS_END ); m_sprHowToPlay.SetTweenX( SCREEN_RIGHT+m_sprHowToPlay.GetUnzoomedWidth()/2 ); } diff --git a/stepmania/src/ScreenPrompt.cpp b/stepmania/src/ScreenPrompt.cpp index 8d849ae52e..3d4d0b2dd0 100644 --- a/stepmania/src/ScreenPrompt.cpp +++ b/stepmania/src/ScreenPrompt.cpp @@ -157,9 +157,11 @@ void ScreenPrompt::MenuStart( PlayerNumber pn ) SOUND->PlayOnceStreamed( THEME->GetPathTo("Sounds","menu start") ); if( m_bAnswer ) - m_pOnYes(); + if( m_pOnYes ) + m_pOnYes(); else - m_pOnNo(); + if( m_pOnNo ) + m_pOnNo(); } void ScreenPrompt::MenuBack( PlayerNumber pn ) diff --git a/stepmania/src/ScreenSelectMusic.cpp b/stepmania/src/ScreenSelectMusic.cpp index a3f009c564..a40a1cc5b4 100644 --- a/stepmania/src/ScreenSelectMusic.cpp +++ b/stepmania/src/ScreenSelectMusic.cpp @@ -771,7 +771,7 @@ void ScreenSelectMusic::PlayMusicSample() //LOG->Trace( "ScreenSelectSong::PlaySONGample()" ); Song* pSong = m_MusicWheel.GetSelectedSong(); - if( pSong ) + if( pSong && pSong->HasMusic() ) { MUSIC->Stop(); MUSIC->Load( pSong->GetMusicPath() ); diff --git a/stepmania/src/Song.cpp b/stepmania/src/Song.cpp index dc0fd99506..c04ed9ca52 100644 --- a/stepmania/src/Song.cpp +++ b/stepmania/src/Song.cpp @@ -384,13 +384,21 @@ void Song::TidyUpData() if( arrayPossibleMusic.GetSize() > 0 ) // we found a match m_sMusicFile = arrayPossibleMusic[0]; - else - throw RageException( "The song in '%s' is missing a music file. You must place a music file in the song folder or remove the song", m_sSongDir ); + // Chris: Don't throw on missing music +// else +// throw RageException( "The song in '%s' is missing a music file. You must place a music file in the song folder or remove the song", m_sSongDir ); } - RageSoundStream sound; - sound.Load( GetMusicPath() ); - m_fMusicLengthSeconds = sound.GetLengthSeconds(); + if( HasMusic() ) + { + RageSoundStream sound; + sound.Load( GetMusicPath() ); + m_fMusicLengthSeconds = sound.GetLengthSeconds(); + } + else // ! HasMusic() + { + m_fMusicLengthSeconds = 100; // guess + } // We're going to try and do something intelligent here... diff --git a/stepmania/src/SongManager.cpp b/stepmania/src/SongManager.cpp index ded5b131ce..bbdfe5ebad 100644 --- a/stepmania/src/SongManager.cpp +++ b/stepmania/src/SongManager.cpp @@ -600,11 +600,15 @@ bool SongManager::ChooseRandomSong() for( i=0; i<600; i++ ) // try 600 times { Song* pSong = m_pSongs[ rand()%m_pSongs.GetSize() ]; + + if( pSong->m_apNotes.GetSize() == 0 ) + continue; // skip + + if( !pSong->HasMusic() ) + continue; // skip + for( int j=0; j<3; j++ ) // try 3 times { - if( pSong->m_apNotes.GetSize() == 0 ) - continue; - /* XXX: This assumes we're set to a style that doesn't use separate * notes for each player, such as VERSUS. */ Notes* pNotes = pSong->m_apNotes[ rand()%pSong->m_apNotes.GetSize() ];