diff --git a/stepmania/src/GameState.cpp b/stepmania/src/GameState.cpp index f39a839058..fed408b9ce 100644 --- a/stepmania/src/GameState.cpp +++ b/stepmania/src/GameState.cpp @@ -594,7 +594,7 @@ void GameState::Update( float fDelta ) } if( bRebuildPlayerOptions ) - RebuildPlayerOptionsFromActiveAttacks( p ); + m_pPlayerState[p]->RebuildPlayerOptionsFromActiveAttacks(); if( m_pPlayerState[p]->m_fSecondsUntilAttacksPhasedOut > 0 ) m_pPlayerState[p]->m_fSecondsUntilAttacksPhasedOut = max( 0, m_pPlayerState[p]->m_fSecondsUntilAttacksPhasedOut - fDelta ); @@ -1223,7 +1223,7 @@ void GameState::LaunchAttack( PlayerNumber target, const Attack& a ) attack.fStartSecond = this->m_fMusicSeconds; m_pPlayerState[target]->m_ActiveAttacks.push_back( attack ); - this->RebuildPlayerOptionsFromActiveAttacks( target ); + m_pPlayerState[target]->RebuildPlayerOptionsFromActiveAttacks(); } void GameState::RemoveActiveAttacksForPlayer( PlayerNumber pn, AttackLevel al ) @@ -1235,7 +1235,7 @@ void GameState::RemoveActiveAttacksForPlayer( PlayerNumber pn, AttackLevel al ) m_pPlayerState[pn]->m_ActiveAttacks.erase( m_pPlayerState[pn]->m_ActiveAttacks.begin()+s, m_pPlayerState[pn]->m_ActiveAttacks.begin()+s+1 ); --s; } - RebuildPlayerOptionsFromActiveAttacks( pn ); + m_pPlayerState[pn]->RebuildPlayerOptionsFromActiveAttacks(); } void GameState::EndActiveAttacksForPlayer( PlayerNumber pn ) @@ -1256,32 +1256,6 @@ void GameState::RemoveAllInventory() } } -void GameState::RebuildPlayerOptionsFromActiveAttacks( PlayerNumber pn ) -{ - // rebuild player options - PlayerOptions po = m_pPlayerState[pn]->m_StoredPlayerOptions; - for( unsigned s=0; sm_ActiveAttacks.size(); s++ ) - { - if( !m_pPlayerState[pn]->m_ActiveAttacks[s].bOn ) - continue; /* hasn't started yet */ - po.FromString( m_pPlayerState[pn]->m_ActiveAttacks[s].sModifiers ); - } - m_pPlayerState[pn]->m_PlayerOptions = po; - - - int iSumOfAttackLevels = m_pPlayerState[pn]->GetSumOfActiveAttackLevels(); - if( iSumOfAttackLevels > 0 ) - { - m_pPlayerState[pn]->m_iLastPositiveSumOfAttackLevels = iSumOfAttackLevels; - m_pPlayerState[pn]->m_fSecondsUntilAttacksPhasedOut = 10000; // any positive number that won't run out before the attacks - } - else - { - // don't change! m_iLastPositiveSumOfAttackLevels[p] = iSumOfAttackLevels; - m_pPlayerState[pn]->m_fSecondsUntilAttacksPhasedOut = 2; // 2 seconds to phase out - } -} - void GameState::RemoveAllActiveAttacks() // called on end of song { FOREACH_PlayerNumber( p ) diff --git a/stepmania/src/GameState.h b/stepmania/src/GameState.h index 9fe6c16563..4747586a56 100644 --- a/stepmania/src/GameState.h +++ b/stepmania/src/GameState.h @@ -192,12 +192,10 @@ public: void GetUndisplayedBeats( const PlayerState* pPlayerState, float TotalSeconds, float &StartBeat, float &EndBeat ) const; // only meaningful when a NoteField is in use void LaunchAttack( PlayerNumber target, const Attack& a ); - void RebuildPlayerOptionsFromActiveAttacks( PlayerNumber pn ); void RemoveAllActiveAttacks(); // called on end of song void RemoveActiveAttacksForPlayer( PlayerNumber pn, AttackLevel al=NUM_ATTACK_LEVELS /*all*/ ); void EndActiveAttacksForPlayer( PlayerNumber pn ); void RemoveAllInventory(); - int GetSumOfActiveAttackLevels( PlayerNumber pn ) const; PlayerNumber GetBestPlayer() const; StageResult GetStageResult( PlayerNumber pn ) const; diff --git a/stepmania/src/PlayerState.cpp b/stepmania/src/PlayerState.cpp index 0923b56882..a002ee4078 100644 --- a/stepmania/src/PlayerState.cpp +++ b/stepmania/src/PlayerState.cpp @@ -12,13 +12,39 @@ void PlayerState::Update( float fDelta ) m_CurrentPlayerOptions.Approach( m_PlayerOptions, fDelta ); } +void PlayerState::RebuildPlayerOptionsFromActiveAttacks() +{ + // rebuild player options + PlayerOptions po = m_StoredPlayerOptions; + for( unsigned s=0; s 0 ) + { + m_iLastPositiveSumOfAttackLevels = iSumOfAttackLevels; + m_fSecondsUntilAttacksPhasedOut = 10000; // any positive number that won't run out before the attacks + } + else + { + // don't change! m_iLastPositiveSumOfAttackLevels[p] = iSumOfAttackLevels; + m_fSecondsUntilAttacksPhasedOut = 2; // 2 seconds to phase out + } +} + int PlayerState::GetSumOfActiveAttackLevels() const { int iSum = 0; for( unsigned s=0; s 0 && m_ActiveAttacks[s].level != NUM_ATTACK_LEVELS ) - iSum += m_pPlayerState[pn]m_ActiveAttacks[s].level; + iSum += m_ActiveAttacks[s].level; return iSum; } diff --git a/stepmania/src/PlayerState.h b/stepmania/src/PlayerState.h index 4c3a2a354c..0287805255 100644 --- a/stepmania/src/PlayerState.h +++ b/stepmania/src/PlayerState.h @@ -71,6 +71,7 @@ struct PlayerState // // Used in Battle and Rave // + void RebuildPlayerOptionsFromActiveAttacks(); int GetSumOfActiveAttackLevels() const; int m_iCpuSkill; // only used when m_PlayerController is PC_CPU // Attacks take a while to transition out of use. Account for this in PlayerAI diff --git a/stepmania/src/ScreenEdit.cpp b/stepmania/src/ScreenEdit.cpp index 63b43a5af2..88e878490c 100644 --- a/stepmania/src/ScreenEdit.cpp +++ b/stepmania/src/ScreenEdit.cpp @@ -1610,7 +1610,7 @@ void ScreenEdit::TransitionEditState( EditState em ) /* Stop displaying course attacks, if any. */ GAMESTATE->RemoveAllActiveAttacks(); - GAMESTATE->RebuildPlayerOptionsFromActiveAttacks( PLAYER_1 ); + GAMESTATE->m_pPlayerState[PLAYER_1]->RebuildPlayerOptionsFromActiveAttacks(); GAMESTATE->m_pPlayerState[PLAYER_1]->m_CurrentPlayerOptions = GAMESTATE->m_pPlayerState[PLAYER_1]->m_PlayerOptions; if( old == STATE_RECORDING ) @@ -2820,7 +2820,7 @@ void ScreenEdit::SetupCourseAttacks() for( unsigned i=0; iLaunchAttack( PLAYER_1, Attacks[i] ); } - GAMESTATE->RebuildPlayerOptionsFromActiveAttacks( PLAYER_1 ); + GAMESTATE->m_pPlayerState[PLAYER_1]->RebuildPlayerOptionsFromActiveAttacks(); } void ScreenEdit::CopyToLastSave()