From 743d2b96972732c77edf672d49163c7051d21d6e Mon Sep 17 00:00:00 2001 From: Steve Checkoway Date: Fri, 14 Jul 2006 04:19:30 +0000 Subject: [PATCH] Change the api to take a NoteData and a row. Let the score keepers decide what they want to do with the row. --- stepmania/src/Player.cpp | 14 ++++---- stepmania/src/ScoreKeeper.cpp | 50 +++++++++++++++++++++++++++++ stepmania/src/ScoreKeeper.h | 9 ++++-- stepmania/src/ScoreKeeperNormal.cpp | 10 ++++-- stepmania/src/ScoreKeeperNormal.h | 2 +- stepmania/src/ScoreKeeperRave.cpp | 9 ++++-- stepmania/src/ScoreKeeperRave.h | 2 +- stepmania/src/ScoreKeeperShared.cpp | 5 ++- stepmania/src/ScoreKeeperShared.h | 2 +- 9 files changed, 82 insertions(+), 21 deletions(-) create mode 100644 stepmania/src/ScoreKeeper.cpp diff --git a/stepmania/src/Player.cpp b/stepmania/src/Player.cpp index 2a50ecddf0..8e1dfde834 100644 --- a/stepmania/src/Player.cpp +++ b/stepmania/src/Player.cpp @@ -1366,9 +1366,9 @@ void Player::OnRowCompletelyJudged( int iIndexThatWasSteppedOn ) TapNoteResult tnr = NoteDataWithScoring::LastTapNoteWithResult( m_NoteData, iIndexThatWasSteppedOn ).result; TapNoteScore score = tnr.tns; - ASSERT(score != TNS_None); - ASSERT(score != TNS_HitMine); - ASSERT(score != TNS_AvoidMine); + ASSERT( score != TNS_None ); + ASSERT( score != TNS_HitMine ); + ASSERT( score != TNS_AvoidMine ); /* If the whole row was hit with perfects or greats, remove the row * from the NoteField, so it disappears. */ @@ -1572,15 +1572,13 @@ void Player::HandleTapRowScore( unsigned row ) { const TapNote &lastTN = NoteDataWithScoring::LastTapNoteWithResult( m_NoteData, row ); TapNoteScore scoreOfLastTap = lastTN.result.tns; - int iNumTapsInRow = m_NoteData.GetNumTracksWithTapOrHoldHead(row); - ASSERT_M( iNumTapsInRow > 0, ssprintf("%d, %u",iNumTapsInRow,row) ); bool NoCheating = true; #ifdef DEBUG NoCheating = false; #endif - if(GAMESTATE->m_bDemonstrationOrJukebox) + if( GAMESTATE->m_bDemonstrationOrJukebox ) NoCheating = false; // don't accumulate points if AutoPlay is on. if( NoCheating && m_pPlayerState->m_PlayerController == PC_AUTOPLAY ) @@ -1621,9 +1619,9 @@ void Player::HandleTapRowScore( unsigned row ) const int iOldCombo = iCurCombo; if( m_pPrimaryScoreKeeper != NULL ) - m_pPrimaryScoreKeeper->HandleTapRowScore( lastTN, iNumTapsInRow ); + m_pPrimaryScoreKeeper->HandleTapRowScore( m_NoteData, row ); if( m_pSecondaryScoreKeeper != NULL ) - m_pSecondaryScoreKeeper->HandleTapRowScore( lastTN, iNumTapsInRow ); + m_pSecondaryScoreKeeper->HandleTapRowScore( m_NoteData, row ); if( m_pPlayerStageStats ) { diff --git a/stepmania/src/ScoreKeeper.cpp b/stepmania/src/ScoreKeeper.cpp new file mode 100644 index 0000000000..ba1feaab2a --- /dev/null +++ b/stepmania/src/ScoreKeeper.cpp @@ -0,0 +1,50 @@ +#include "global.h" +#include "ScoreKeeper.h" +#include "NoteData.h" +#include "PlayerState.h" +#include "NoteDataWithScoring.h" + +void ScoreKeeper::GetScoreOfLastTapInRow( const NoteData &nd, int iRow, + TapNoteScore &tnsOut, int &iNumTapsInRowOut ) +{ + PlayerNumber pn = m_pPlayerState->m_PlayerNumber; + int iNum = 0; + + for( int track = 0; track < nd.GetNumTracks(); ++track ) + { + const TapNote &tn = nd.GetTapNote( track, iRow ); + + if( tn.pn != PLAYER_INVALID && tn.pn != pn ) + continue; + if( tn.type != TapNote::tap && tn.type != TapNote::hold_head ) + continue; + ++iNum; + } + tnsOut = NoteDataWithScoring::LastTapNoteWithResult( nd, iRow, pn ).result.tns; + iNumTapsInRowOut = iNum; +} + +/* + * (c) 2006 Steve Checkoway + * All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, and/or sell copies of the Software, and to permit persons to + * whom the Software is furnished to do so, provided that the above + * copyright notice(s) and this permission notice appear in all copies of + * the Software and that both the above copyright notice(s) and this + * permission notice appear in supporting documentation. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT + * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS + * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ diff --git a/stepmania/src/ScoreKeeper.h b/stepmania/src/ScoreKeeper.h index d3a9799e89..21a854718c 100644 --- a/stepmania/src/ScoreKeeper.h +++ b/stepmania/src/ScoreKeeper.h @@ -11,6 +11,8 @@ * Results are injected directly into GameState. */ +#include "GameConstantsAndTypes.h" + class NoteData; class Inventory; class Song; @@ -47,14 +49,17 @@ public: virtual void OnNextSong( int iSongInCourseIndex, const Steps* pSteps, const NoteData* pNoteData ) = 0; // before a song plays (called multiple times if course) virtual void HandleTapScore( const TapNote &tn ) = 0; - virtual void HandleTapRowScore( const TapNote &lastTN, int iNumTapsInRow ) = 0; + virtual void HandleTapRowScore( const NoteData &nd, int iRow ) = 0; virtual void HandleHoldScore( const TapNote &tn ) = 0; + +protected: + void GetScoreOfLastTapInRow( const NoteData &nd, int iRow, TapNoteScore &tnsOut, int &iNumTapsInRowOut ); }; #endif /* - * (c) 2001-2004 Chris Danford, Glenn Maynard + * (c) 2001-2006 Chris Danford, Glenn Maynard, Steve Checkoway * All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a diff --git a/stepmania/src/ScoreKeeperNormal.cpp b/stepmania/src/ScoreKeeperNormal.cpp index 7e4505cf95..e37fa9c073 100644 --- a/stepmania/src/ScoreKeeperNormal.cpp +++ b/stepmania/src/ScoreKeeperNormal.cpp @@ -348,10 +348,14 @@ void ScoreKeeperNormal::HandleTapScore( const TapNote &tn ) } } -void ScoreKeeperNormal::HandleTapRowScore( const TapNote &lastTN, int iNumTapsInRow ) +void ScoreKeeperNormal::HandleTapRowScore( const NoteData &nd, int iRow ) { - ASSERT( iNumTapsInRow >= 1 ); - TapNoteScore scoreOfLastTap = lastTN.result.tns; + TapNoteScore scoreOfLastTap; + int iNumTapsInRow; + GetScoreOfLastTapInRow( nd, iRow, scoreOfLastTap, iNumTapsInRow ); + + if( iNumTapsInRow <= 0 ) + return; // Update dance points. if( !m_pPlayerStageStats->bFailed ) diff --git a/stepmania/src/ScoreKeeperNormal.h b/stepmania/src/ScoreKeeperNormal.h index f510ec61ed..c16099fdb8 100644 --- a/stepmania/src/ScoreKeeperNormal.h +++ b/stepmania/src/ScoreKeeperNormal.h @@ -53,7 +53,7 @@ public: void OnNextSong( int iSongInCourseIndex, const Steps* pSteps, const NoteData* pNoteData ); void HandleTapScore( const TapNote &tn ); - void HandleTapRowScore( const TapNote &lastTN, int iNumTapsInRow ); + void HandleTapRowScore( const NoteData &nd, int iRow ); void HandleHoldScore( const TapNote &tn ); // This must be calculated using only cached radar values so that we can diff --git a/stepmania/src/ScoreKeeperRave.cpp b/stepmania/src/ScoreKeeperRave.cpp index 5d1c62ae89..c6cda9d9a3 100644 --- a/stepmania/src/ScoreKeeperRave.cpp +++ b/stepmania/src/ScoreKeeperRave.cpp @@ -37,10 +37,15 @@ void ScoreKeeperRave::HandleTapScore( const TapNote &tn ) #define CROSSED( val ) (fOld < val && fNew >= val) #define CROSSED_ATTACK_LEVEL( level ) CROSSED(1.f/NUM_ATTACK_LEVELS*(level+1)) -void ScoreKeeperRave::HandleTapRowScore( const TapNote &lastTN, int iNumTapsInRow ) +void ScoreKeeperRave::HandleTapRowScore( const NoteData &nd, int iRow ) { - TapNoteScore scoreOfLastTap = lastTN.result.tns; + TapNoteScore scoreOfLastTap; + int iNumTapsInRow; float fPercentToMove; + + GetScoreOfLastTapInRow( nd, iRow, scoreOfLastTap, iNumTapsInRow ); + if( iNumTapsInRow <= 0 ) + return; switch( scoreOfLastTap ) { DEFAULT_FAIL( scoreOfLastTap ); diff --git a/stepmania/src/ScoreKeeperRave.h b/stepmania/src/ScoreKeeperRave.h index 93b484d3c0..ac5b5abb55 100644 --- a/stepmania/src/ScoreKeeperRave.h +++ b/stepmania/src/ScoreKeeperRave.h @@ -14,7 +14,7 @@ public: virtual ~ScoreKeeperRave() { } void OnNextSong( int iSongInCourseIndex, const Steps* pSteps, const NoteData* pNoteData ); // before a song plays (called multiple times if course) void HandleTapScore( const TapNote &tn ); - void HandleTapRowScore( const TapNote &lastTN, int iNumTapsInRow ); + void HandleTapRowScore( const NoteData &nd, int iRow ); void HandleHoldScore( const TapNote &tn ); protected: diff --git a/stepmania/src/ScoreKeeperShared.cpp b/stepmania/src/ScoreKeeperShared.cpp index ae8da9636f..a013d060bd 100644 --- a/stepmania/src/ScoreKeeperShared.cpp +++ b/stepmania/src/ScoreKeeperShared.cpp @@ -57,10 +57,9 @@ void ScoreKeeperShared::HandleTapScore( const TapNote &tn ) m_pScoreKeepers[tn.pn]->HandleTapScore( tn ); } -void ScoreKeeperShared::HandleTapRowScore( const TapNote &lastTN, int iNumTapsInRow ) +void ScoreKeeperShared::HandleTapRowScore( const NoteData &nd, int row ) { - // XXX Each player should probaby have this for just their own notes. - CALL( HandleTapRowScore(lastTN, iNumTapsInRow) ); + CALL( HandleTapRowScore(nd, row) ); } void ScoreKeeperShared::HandleHoldScore( const TapNote &tn ) diff --git a/stepmania/src/ScoreKeeperShared.h b/stepmania/src/ScoreKeeperShared.h index 4f8f6f04d6..f7fdaa44a3 100644 --- a/stepmania/src/ScoreKeeperShared.h +++ b/stepmania/src/ScoreKeeperShared.h @@ -17,7 +17,7 @@ public: void Update( float fDelta ); void OnNextSong( int iSongInCourseIndex, const Steps* pSteps, const NoteData* pNoteData ); void HandleTapScore( const TapNote &tn ); - void HandleTapRowScore( const TapNote &lastTN, int iNumTapsInRow ); + void HandleTapRowScore( const NoteData &nd, int row ); void HandleHoldScore( const TapNote &tn ); }; #endif