From 19d8a3de4c38103f63cd1000e737bd7c9f0b0dd7 Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Tue, 8 Jul 2003 20:56:25 +0000 Subject: [PATCH] fix crash on step if NULL life meter --- stepmania/src/Player.cpp | 8 ++++---- stepmania/src/ScoreKeeper.h | 4 ++-- stepmania/src/ScoreKeeperMAX2.cpp | 19 ++++++++++++------- stepmania/src/ScoreKeeperMAX2.h | 6 +++--- stepmania/src/ScoreKeeperRave.cpp | 4 ++-- stepmania/src/ScoreKeeperRave.h | 4 ++-- 6 files changed, 25 insertions(+), 20 deletions(-) diff --git a/stepmania/src/Player.cpp b/stepmania/src/Player.cpp index 312a2c66ab..75d9f04bb6 100644 --- a/stepmania/src/Player.cpp +++ b/stepmania/src/Player.cpp @@ -665,10 +665,10 @@ void Player::HandleTapRowScore( unsigned row ) return; if(m_pPrimaryScoreKeeper) - m_pPrimaryScoreKeeper->HandleTapRowScore(scoreOfLastTap, iNumTapsInRow, m_pLifeMeter->FailedEarlier() ); + m_pPrimaryScoreKeeper->HandleTapRowScore(scoreOfLastTap, iNumTapsInRow ); if(m_pSecondaryScoreKeeper) - m_pSecondaryScoreKeeper->HandleTapRowScore(scoreOfLastTap, iNumTapsInRow, m_pLifeMeter->FailedEarlier() ); + m_pSecondaryScoreKeeper->HandleTapRowScore(scoreOfLastTap, iNumTapsInRow ); if (m_pScore) m_pScore->SetScore(GAMESTATE->m_CurStageStats.iScore[m_PlayerNumber]); @@ -698,9 +698,9 @@ void Player::HandleHoldScore( HoldNoteScore holdScore, TapNoteScore tapScore ) return; if(m_pPrimaryScoreKeeper) - m_pPrimaryScoreKeeper->HandleHoldScore(holdScore, tapScore, m_pLifeMeter->FailedEarlier()); + m_pPrimaryScoreKeeper->HandleHoldScore(holdScore, tapScore ); if(m_pSecondaryScoreKeeper) - m_pSecondaryScoreKeeper->HandleHoldScore(holdScore, tapScore, m_pLifeMeter->FailedEarlier()); + m_pSecondaryScoreKeeper->HandleHoldScore(holdScore, tapScore ); if (m_pScore) m_pScore->SetScore(GAMESTATE->m_CurStageStats.iScore[m_PlayerNumber]); diff --git a/stepmania/src/ScoreKeeper.h b/stepmania/src/ScoreKeeper.h index f03315faf5..6343097426 100644 --- a/stepmania/src/ScoreKeeper.h +++ b/stepmania/src/ScoreKeeper.h @@ -44,8 +44,8 @@ public: virtual void OnNextSong( int iSongInCourseIndex, Notes* pNotes ) = 0; // before a song plays (called multiple times if course) - virtual void HandleTapRowScore( TapNoteScore scoreOfLastTap, int iNumTapsInRow, bool failed) = 0; - virtual void HandleHoldScore( HoldNoteScore holdScore, TapNoteScore tapScore, bool failed ) = 0; + virtual void HandleTapRowScore( TapNoteScore scoreOfLastTap, int iNumTapsInRow ) = 0; + virtual void HandleHoldScore( HoldNoteScore holdScore, TapNoteScore tapScore ) = 0; virtual int TapNoteScoreToDancePoints( TapNoteScore tns ) = 0; virtual int HoldNoteScoreToDancePoints( HoldNoteScore hns ) = 0; diff --git a/stepmania/src/ScoreKeeperMAX2.cpp b/stepmania/src/ScoreKeeperMAX2.cpp index a0da54be39..bf93c2440a 100644 --- a/stepmania/src/ScoreKeeperMAX2.cpp +++ b/stepmania/src/ScoreKeeperMAX2.cpp @@ -164,7 +164,7 @@ static int GetScore(int p, int B, int S, int n) } -void ScoreKeeperMAX2::AddScore( TapNoteScore score, bool failed) +void ScoreKeeperMAX2::AddScore( TapNoteScore score ) { /* http://www.aaroninjapan.com/ddr2.html @@ -198,7 +198,11 @@ void ScoreKeeperMAX2::AddScore( TapNoteScore score, bool failed) int iScoreMultiplier = (m_iMaxPossiblePoints / (10*sum)); ASSERT( iScoreMultiplier >= 0 ); - if (failed) + // What does this do? "Don't use a multiplier if + // the player has failed"? + // Also, why does this switch on score again instead + // of just adding p? -Chris + if( GAMESTATE->m_CurStageStats.bFailed[m_PlayerNumber] ) switch( score ) { case TNS_MARVELOUS: m_iScore += 10; break; @@ -213,7 +217,8 @@ void ScoreKeeperMAX2::AddScore( TapNoteScore score, bool failed) if ( m_iTapNotesHit == m_iNumTapsAndHolds && score >= TNS_PERFECT ) { - if (!failed) m_iScore += m_iPointBonus; + if (!GAMESTATE->m_CurStageStats.bFailed[m_PlayerNumber]) + m_iScore += m_iPointBonus; if ( m_bIsLastSongInCourse ) { m_iScore += 100000000 - m_iMaxScoreSoFar; @@ -231,7 +236,7 @@ void ScoreKeeperMAX2::AddScore( TapNoteScore score, bool failed) GAMESTATE->m_CurStageStats.iScore[m_PlayerNumber] = m_iScore; } -void ScoreKeeperMAX2::HandleTapRowScore( TapNoteScore scoreOfLastTap, int iNumTapsInRow, bool failed ) +void ScoreKeeperMAX2::HandleTapRowScore( TapNoteScore scoreOfLastTap, int iNumTapsInRow ) { ASSERT( iNumTapsInRow >= 1 ); @@ -276,7 +281,7 @@ void ScoreKeeperMAX2::HandleTapRowScore( TapNoteScore scoreOfLastTap, int iNumTa Note: if you got all Perfect on this song, you would get (p=10)*B, which is 80,000,000. In fact, the maximum possible score for any song is the number of feet difficulty X 10,000,000. */ - AddScore( scoreOfLastTap, failed ); // only score once per row + AddScore( scoreOfLastTap ); // only score once per row // @@ -394,14 +399,14 @@ void ScoreKeeperMAX2::HandleTapRowScore( TapNoteScore scoreOfLastTap, int iNumTa } -void ScoreKeeperMAX2::HandleHoldScore( HoldNoteScore holdScore, TapNoteScore tapScore, bool failed) +void ScoreKeeperMAX2::HandleHoldScore( HoldNoteScore holdScore, TapNoteScore tapScore ) { // update dance points totals GAMESTATE->m_CurStageStats.iHoldNoteScores[m_PlayerNumber][holdScore] ++; GAMESTATE->m_CurStageStats.iActualDancePoints[m_PlayerNumber] += HoldNoteScoreToDancePoints( holdScore ); if( holdScore == HNS_OK ) - AddScore( TNS_MARVELOUS , failed); + AddScore( TNS_MARVELOUS ); } diff --git a/stepmania/src/ScoreKeeperMAX2.h b/stepmania/src/ScoreKeeperMAX2.h index b962d1b6c2..7599e86dc9 100644 --- a/stepmania/src/ScoreKeeperMAX2.h +++ b/stepmania/src/ScoreKeeperMAX2.h @@ -30,15 +30,15 @@ class ScoreKeeperMAX2: public ScoreKeeper const vector& apNotes; - void AddScore( TapNoteScore score, bool failed); + void AddScore( TapNoteScore score ); public: ScoreKeeperMAX2( const vector& apNotes, PlayerNumber pn); void OnNextSong( int iSongInCourseIndex, Notes* pNotes ); // before a song plays (called multiple times if course) - void HandleTapRowScore( TapNoteScore scoreOfLastTap, int iNumTapsInRow, bool failed ); - void HandleHoldScore( HoldNoteScore holdScore, TapNoteScore tapScore, bool failed ); + void HandleTapRowScore( TapNoteScore scoreOfLastTap, int iNumTapsInRow ); + void HandleHoldScore( HoldNoteScore holdScore, TapNoteScore tapScore ); int TapNoteScoreToDancePoints( TapNoteScore tns ); int HoldNoteScoreToDancePoints( HoldNoteScore hns ); diff --git a/stepmania/src/ScoreKeeperRave.cpp b/stepmania/src/ScoreKeeperRave.cpp index 5c4147a0c5..335dc94517 100644 --- a/stepmania/src/ScoreKeeperRave.cpp +++ b/stepmania/src/ScoreKeeperRave.cpp @@ -36,7 +36,7 @@ void ScoreKeeperRave::OnNextSong( int iSongInCourseIndex, Notes* pNotes ) #define CROSSED( val ) (fOld < val && fNew >= val) #define CROSSED_ATTACK_LEVEL( level ) CROSSED(1.f/NUM_ATTACK_LEVELS*(level+1)) -void ScoreKeeperRave::HandleTapRowScore( TapNoteScore scoreOfLastTap, int iNumTapsInRow, bool failed) +void ScoreKeeperRave::HandleTapRowScore( TapNoteScore scoreOfLastTap, int iNumTapsInRow ) { AttackLevel oldAL = (AttackLevel)(int)GAMESTATE->m_fSuperMeter[m_PlayerNumber]; @@ -65,7 +65,7 @@ void ScoreKeeperRave::HandleTapRowScore( TapNoteScore scoreOfLastTap, int iNumTa } } -void ScoreKeeperRave::HandleHoldScore( HoldNoteScore holdScore, TapNoteScore tapScore, bool failed ) +void ScoreKeeperRave::HandleHoldScore( HoldNoteScore holdScore, TapNoteScore tapScore ) { } diff --git a/stepmania/src/ScoreKeeperRave.h b/stepmania/src/ScoreKeeperRave.h index 3395641e5f..0e4fb5fde3 100644 --- a/stepmania/src/ScoreKeeperRave.h +++ b/stepmania/src/ScoreKeeperRave.h @@ -23,8 +23,8 @@ public: ScoreKeeperRave(PlayerNumber pn); virtual void Update( float fDelta ); virtual void OnNextSong( int iSongInCourseIndex, Notes* pNotes ); // before a song plays (called multiple times if course) - virtual void HandleTapRowScore( TapNoteScore scoreOfLastTap, int iNumTapsInRow, bool failed); - virtual void HandleHoldScore( HoldNoteScore holdScore, TapNoteScore tapScore, bool failed ); + virtual void HandleTapRowScore( TapNoteScore scoreOfLastTap, int iNumTapsInRow ); + virtual void HandleHoldScore( HoldNoteScore holdScore, TapNoteScore tapScore ); virtual int TapNoteScoreToDancePoints( TapNoteScore tns ) { return 0; }; virtual int HoldNoteScoreToDancePoints( HoldNoteScore hns ) { return 0; }; virtual int GetPossibleDancePoints( const NoteData* pNoteData ) { return 0; };