From 13e1d04d24cc242804f01c7dc6a5fd3c1a6b2c1b Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Tue, 12 Jul 2005 03:49:19 +0000 Subject: [PATCH] pull stuff out from GameState --- stepmania/src/GameState.cpp | 41 ---------------------------------- stepmania/src/PlayerState.cpp | 42 +++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 41 deletions(-) diff --git a/stepmania/src/GameState.cpp b/stepmania/src/GameState.cpp index ec5e564a82..909663fe92 100644 --- a/stepmania/src/GameState.cpp +++ b/stepmania/src/GameState.cpp @@ -560,47 +560,6 @@ void GameState::Update( float fDelta ) { m_pPlayerState[p]->Update( fDelta ); - // TRICKY: GAMESTATE->Update is run before any of the Screen update's, - // so we'll clear these flags here and let them get turned on later - m_pPlayerState[p]->m_bAttackBeganThisUpdate = false; - m_pPlayerState[p]->m_bAttackEndedThisUpdate = false; - - bool bRebuildPlayerOptions = false; - - /* See if any delayed attacks are starting or ending. */ - for( unsigned s=0; sm_ActiveAttacks.size(); s++ ) - { - Attack &attack = m_pPlayerState[p]->m_ActiveAttacks[s]; - - // -1 is the "starts now" sentinel value. You must add the attack - // by calling GameState::LaunchAttack, or else the -1 won't be - // converted into the current music time. - ASSERT( attack.fStartSecond != -1 ); - - bool bCurrentlyEnabled = - attack.bGlobal || - ( attack.fStartSecond < this->m_fMusicSeconds && - m_fMusicSeconds < attack.fStartSecond+attack.fSecsRemaining ); - - if( m_pPlayerState[p]->m_ActiveAttacks[s].bOn == bCurrentlyEnabled ) - continue; /* OK */ - - if( m_pPlayerState[p]->m_ActiveAttacks[s].bOn && !bCurrentlyEnabled ) - m_pPlayerState[p]->m_bAttackEndedThisUpdate = true; - else if( !m_pPlayerState[p]->m_ActiveAttacks[s].bOn && bCurrentlyEnabled ) - m_pPlayerState[p]->m_bAttackBeganThisUpdate = true; - - bRebuildPlayerOptions = true; - - m_pPlayerState[p]->m_ActiveAttacks[s].bOn = bCurrentlyEnabled; - } - - if( bRebuildPlayerOptions ) - m_pPlayerState[p]->RebuildPlayerOptionsFromActiveAttacks(); - - if( m_pPlayerState[p]->m_fSecondsUntilAttacksPhasedOut > 0 ) - m_pPlayerState[p]->m_fSecondsUntilAttacksPhasedOut = max( 0, m_pPlayerState[p]->m_fSecondsUntilAttacksPhasedOut - fDelta ); - if( !m_bGoalComplete[p] && IsGoalComplete(p) ) { m_bGoalComplete[p] = true; diff --git a/stepmania/src/PlayerState.cpp b/stepmania/src/PlayerState.cpp index a002ee4078..f0ee940294 100644 --- a/stepmania/src/PlayerState.cpp +++ b/stepmania/src/PlayerState.cpp @@ -1,5 +1,6 @@ #include "global.h" #include "PlayerState.h" +#include "GameState.h" void PlayerState::ResetNoteSkins() { @@ -10,6 +11,47 @@ void PlayerState::ResetNoteSkins() void PlayerState::Update( float fDelta ) { m_CurrentPlayerOptions.Approach( m_PlayerOptions, fDelta ); + + // TRICKY: GAMESTATE->Update is run before any of the Screen update's, + // so we'll clear these flags here and let them get turned on later + m_bAttackBeganThisUpdate = false; + m_bAttackEndedThisUpdate = false; + + bool bRebuildPlayerOptions = false; + + /* See if any delayed attacks are starting or ending. */ + for( unsigned s=0; sm_fMusicSeconds && + GAMESTATE->m_fMusicSeconds < attack.fStartSecond+attack.fSecsRemaining ); + + if( m_ActiveAttacks[s].bOn == bCurrentlyEnabled ) + continue; /* OK */ + + if( m_ActiveAttacks[s].bOn && !bCurrentlyEnabled ) + m_bAttackEndedThisUpdate = true; + else if( !m_ActiveAttacks[s].bOn && bCurrentlyEnabled ) + m_bAttackBeganThisUpdate = true; + + bRebuildPlayerOptions = true; + + m_ActiveAttacks[s].bOn = bCurrentlyEnabled; + } + + if( bRebuildPlayerOptions ) + RebuildPlayerOptionsFromActiveAttacks(); + + if( m_fSecondsUntilAttacksPhasedOut > 0 ) + m_fSecondsUntilAttacksPhasedOut = max( 0, m_fSecondsUntilAttacksPhasedOut - fDelta ); } void PlayerState::RebuildPlayerOptionsFromActiveAttacks()