Fix songinprogress write crashing on marathons
authorinfamouspat <itgpmc@gmail.com>
Sun, 26 Feb 2012 00:31:37 +0000 (16:31 -0800)
committerCarl Myers <cmyers@cmyers.org>
Tue, 3 Apr 2012 07:35:02 +0000 (00:35 -0700)
src/GameState.cpp
src/GameState.h
src/ScreenGameplay.cpp

index 33f8d69..7e9d306 100755 (executable)
@@ -309,10 +309,10 @@ int GameState::GetCoinsNeededToJoin() const
        return iCoinsToCharge;
 }
 
-void GameState::SetSongInProgress( bool bInProgress )
+void GameState::SetSongInProgress( const CString &sWriteOut )
 {
        CString sLockFile = "Data/songinprogress";
-       CString sWriteOut = (bInProgress) ? this->m_pCurSong->GetSongDir() : "(none)";
+       LOG->Debug("GameState::SetSongInProgress( %s )", sWriteOut.c_str());
 
        RageFile f;
        f.Open(sLockFile, RageFile::WRITE);
index 7abc190..76b122e 100755 (executable)
@@ -42,7 +42,7 @@ public:
        void EndGame(); // called on ScreenGameOver, ScreenMusicScroll, ScreenCredits
        void SaveCurrentSettingsToProfile( PlayerNumber pn ); // called at the beginning of each stage
 
-       void SetSongInProgress( bool bInProgress );
+       void SetSongInProgress( const CString &sWriteOut );
 
        void Update( float fDelta );
 
index 77d5db9..f282a7e 100755 (executable)
@@ -120,7 +120,6 @@ void ScreenGameplay::Init()
        if( !GAMESTATE->m_bDemonstrationOrJukebox )\r
        {       \r
                MEMCARDMAN->PauseMountingThread();\r
-               GAMESTATE->SetSongInProgress(true);\r
        }\r
 \r
        m_pSoundMusic = NULL;\r
@@ -885,6 +884,7 @@ void ScreenGameplay::LoadNextSong()
        int iPlaySongIndex = GAMESTATE->GetCourseSongIndex();\r
        iPlaySongIndex %= m_apSongsQueue.size();\r
        GAMESTATE->m_pCurSong.Set( m_apSongsQueue[iPlaySongIndex] );\r
+       GAMESTATE->SetSongInProgress( GAMESTATE->m_pCurSong->GetSongDir() );\r
        STATSMAN->m_CurStageStats.vpPlayedSongs.push_back( GAMESTATE->m_pCurSong );\r
 \r
        // No need to do this here.  We do it in SongFinished().\r
@@ -1976,10 +1976,12 @@ void ScreenGameplay::BackOutFromGameplay()
 \r
 void ScreenGameplay::AbortGiveUp( bool bShowText )\r
 {\r
-       GAMESTATE->SetSongInProgress(false);\r
        if( m_GiveUpTimer.IsZero() )\r
                return;\r
 \r
+       if ( !bShowText )\r
+               GAMESTATE->SetSongInProgress("(none)");\r
+\r
        m_textDebug.StopTweening();\r
        if( bShowText )\r
                m_textDebug.SetText( GIVE_UP_ABORTED_TEXT );\r
@@ -2129,6 +2131,7 @@ void ScreenGameplay::SongFinished()
 \r
        /* Extremely important: if we don't remove attacks before moving on to the next\r
         * screen, they'll still be turned on eventually. */\r
+       GAMESTATE->SetSongInProgress("(none)");\r
        GAMESTATE->RemoveAllActiveAttacks();\r
        FOREACH_EnabledPlayer( p )\r
                m_ActiveAttackList[p].Refresh();\r