From 8f9951e38dee42705a550f9cea4355e8b5245e51 Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Sun, 12 Jun 2005 04:22:16 +0000 Subject: [PATCH] less fragile attract sound logic --- stepmania/src/CommonMetrics.cpp | 1 + stepmania/src/CommonMetrics.h | 1 + stepmania/src/GameState.cpp | 18 ++++++++++-------- stepmania/src/GameState.h | 1 - 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/stepmania/src/CommonMetrics.cpp b/stepmania/src/CommonMetrics.cpp index f0219bc81b..cddeb1b796 100644 --- a/stepmania/src/CommonMetrics.cpp +++ b/stepmania/src/CommonMetrics.cpp @@ -10,6 +10,7 @@ CString PLAYER_COLOR_NAME( size_t p ) { return ssprintf("ColorP%d",int(p+1)); } ThemeMetric INITIAL_SCREEN ("Common","InitialScreen"); +ThemeMetric FIRST_ATTRACT_SCREEN ("Common","FirstAttractScreen"); ThemeMetric DEFAULT_MODIFIERS ("Common","DefaultModifiers" ); ThemeMetric DEFAULT_CPU_MODIFIERS ("Common","DefaultCpuModifiers" ); ThemeMetric1D PLAYER_COLOR ("Common",PLAYER_COLOR_NAME,NUM_PLAYERS); diff --git a/stepmania/src/CommonMetrics.h b/stepmania/src/CommonMetrics.h index c7c2655d83..88b1f0e092 100644 --- a/stepmania/src/CommonMetrics.h +++ b/stepmania/src/CommonMetrics.h @@ -53,6 +53,7 @@ public: // Metrics // extern ThemeMetric INITIAL_SCREEN; +extern ThemeMetric FIRST_ATTRACT_SCREEN; extern ThemeMetric DEFAULT_MODIFIERS; extern ThemeMetric DEFAULT_CPU_MODIFIERS; extern ThemeMetric1D PLAYER_COLOR; diff --git a/stepmania/src/GameState.cpp b/stepmania/src/GameState.cpp index bb9e3ff223..ef0ad490b8 100644 --- a/stepmania/src/GameState.cpp +++ b/stepmania/src/GameState.cpp @@ -1736,6 +1736,14 @@ bool GameState::OneIsHot() const bool GameState::IsTimeToPlayAttractSounds() const { + // m_iNumTimesThroughAttract will be -1 from the first attract screen after + // the end of a game until the next time FIRST_ATTRACT_SCREEN is reached. + // Play attract sounds for this sort span of time regardless of + // m_AttractSoundFrequency because it's awkward to have the machine go + // silent immediately after the end of a game. + if( m_iNumTimesThroughAttract == -1 ) + return true; + if( PREFSMAN->m_AttractSoundFrequency == PrefsManager::ASF_NEVER ) return false; @@ -1748,14 +1756,8 @@ bool GameState::IsTimeToPlayAttractSounds() const void GameState::VisitAttractScreen( const CString sScreenName ) { - bool bSeenThisScreenInThisLoop = m_vScreensSeenSoFarInThisAttractLoop.find( sScreenName ) != m_vScreensSeenSoFarInThisAttractLoop.end(); - if( bSeenThisScreenInThisLoop ) - { - m_vScreensSeenSoFarInThisAttractLoop.clear(); - GAMESTATE->m_iNumTimesThroughAttract++; - } - - m_vScreensSeenSoFarInThisAttractLoop.insert( sScreenName ); + if( sScreenName == FIRST_ATTRACT_SCREEN.GetValue() ) + m_iNumTimesThroughAttract++; } bool GameState::DifficultiesLocked() diff --git a/stepmania/src/GameState.h b/stepmania/src/GameState.h index 39937ee475..8bf262a8e8 100644 --- a/stepmania/src/GameState.h +++ b/stepmania/src/GameState.h @@ -272,7 +272,6 @@ public: // // Attract stuff // - set m_vScreensSeenSoFarInThisAttractLoop; int m_iNumTimesThroughAttract; // negative means play regardless of m_iAttractSoundFrequency setting bool IsTimeToPlayAttractSounds() const; void VisitAttractScreen( const CString sScreenName );