From 43b7c4ac7d6c156a91700d590b0e1cadaa3c05ec Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Thu, 9 Nov 2006 06:10:19 +0000 Subject: [PATCH] m_HealthState is confusing; it's updated from other stats, and then the original stats as well as m_HealthState are used for control logic. Simplify; remove AllAreFailing, and figure it out directly. --- stepmania/src/GameState.cpp | 8 -------- stepmania/src/GameState.h | 1 - stepmania/src/ScreenGameplay.cpp | 17 ++++++++++++----- stepmania/src/ScreenGameplay.h | 1 + 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/stepmania/src/GameState.cpp b/stepmania/src/GameState.cpp index 82364ae2a9..c1621959fb 100644 --- a/stepmania/src/GameState.cpp +++ b/stepmania/src/GameState.cpp @@ -1556,14 +1556,6 @@ bool GameState::AllAreInDangerOrWorse() const return true; } -bool GameState::AllAreDead() const -{ - FOREACH_EnabledPlayer( p ) - if( m_pPlayerState[p]->m_HealthState < PlayerState::DEAD ) - return false; - return true; -} - bool GameState::AllHumanHaveComboOf30OrMoreMisses() const { FOREACH_HumanPlayer( p ) diff --git a/stepmania/src/GameState.h b/stepmania/src/GameState.h index 39adfd2b5d..e37d3a7ac5 100644 --- a/stepmania/src/GameState.h +++ b/stepmania/src/GameState.h @@ -179,7 +179,6 @@ public: bool IsPlayerInDanger( const PlayerState *pPlayerState ) const; bool IsPlayerDead( const PlayerState *pPlayerState ) const; bool AllAreInDangerOrWorse() const; - bool AllAreDead() const; bool AllHumanHaveComboOf30OrMoreMisses() const; bool OneIsHot() const; diff --git a/stepmania/src/ScreenGameplay.cpp b/stepmania/src/ScreenGameplay.cpp index 3b5df00182..3ddeb3a2df 100644 --- a/stepmania/src/ScreenGameplay.cpp +++ b/stepmania/src/ScreenGameplay.cpp @@ -1513,6 +1513,16 @@ void ScreenGameplay::BeginScreen() } } +bool ScreenGameplay::AllAreFailing() +{ + FOREACH_EnabledPlayerInfo( m_vPlayerInfo, pi ) + { + if( pi->m_pLifeMeter && !pi->m_pLifeMeter->IsFailing() ) + return false; + } + return true; +} + void ScreenGameplay::Update( float fDeltaTime ) { if( GAMESTATE->m_pCurSong == NULL ) @@ -1562,8 +1572,6 @@ void ScreenGameplay::Update( float fDeltaTime ) // FOREACH_EnabledPlayerInfo( m_vPlayerInfo, pi ) { - PlayerNumber pn = pi->GetStepsAndTrailIndex(); - if( pi->m_pLifeMeter && pi->m_pLifeMeter->IsFailing() ) { pi->GetPlayerState()->m_HealthState = PlayerState::DEAD; @@ -1606,8 +1614,7 @@ void ScreenGameplay::Update( float fDeltaTime ) /* If recovery is enabled, only set fail if both are failing. * There's no way to recover mid-song in battery mode. */ - if( lt != SongOptions::LIFE_BATTERY && - g_bTwoPlayerRecovery && !GAMESTATE->AllAreDead() ) + if( lt != SongOptions::LIFE_BATTERY && g_bTwoPlayerRecovery && !AllAreFailing() ) continue; LOG->Trace("Player %d failed", (int)pn); @@ -1643,7 +1650,7 @@ void ScreenGameplay::Update( float fDeltaTime ) switch( ft ) { case SongOptions::FAIL_IMMEDIATE: - if( pi->GetPlayerState()->m_HealthState < PlayerState::DEAD ) + if( pi->m_pLifeMeter && !pi->m_pLifeMeter->IsFailing() ) bAllFailed = false; break; case SongOptions::FAIL_END_OF_SONG: diff --git a/stepmania/src/ScreenGameplay.h b/stepmania/src/ScreenGameplay.h index 014b09bab3..0aa6885c29 100644 --- a/stepmania/src/ScreenGameplay.h +++ b/stepmania/src/ScreenGameplay.h @@ -156,6 +156,7 @@ protected: virtual void SaveStats(); void StageFinished( bool bBackedOut ); void SaveReplay(); + bool AllAreFailing(); virtual void InitSongQueues();