From 9f1bb1e16fff188e67f747d585e985165d6a870a Mon Sep 17 00:00:00 2001 From: Steve Checkoway Date: Fri, 21 Jul 2006 08:01:28 +0000 Subject: [PATCH] Simplify. --- stepmania/src/NoteDataWithScoring.cpp | 14 +-- stepmania/src/Player.cpp | 166 ++++++++++++-------------- 2 files changed, 79 insertions(+), 101 deletions(-) diff --git a/stepmania/src/NoteDataWithScoring.cpp b/stepmania/src/NoteDataWithScoring.cpp index 9c9cce55cf..f731993985 100644 --- a/stepmania/src/NoteDataWithScoring.cpp +++ b/stepmania/src/NoteDataWithScoring.cpp @@ -62,19 +62,13 @@ int GetNumHoldNotesWithScore( const NoteData &in, TapNote::SubType subType, Hold return iNumSuccessfulHolds; } +bool AvoidedMines( const TapNote &tn ) { return tn.type == TapNote::mine && tn.result.tns == TNS_AvoidMine; } int GetSuccessfulMines( const NoteData &in, int iStartIndex = 0, int iEndIndex = MAX_NOTE_ROW ) { int iNumSuccessfulMinesNotes = 0; - FOREACH_NONEMPTY_ROW_ALL_TRACKS_RANGE( in, i, iStartIndex, iEndIndex ) - { - for( int t=0; tm_PlayerNumber ) + continue; + if( tn.type == TapNote::mine ) { - /* XXX: cleaner to pick the things we do want to apply misses to, instead of - * the things we don't? */ - const TapNote &tn = m_NoteData.GetTapNote( t, r ); - switch( tn.type ) - { - case TapNote::empty: - case TapNote::attack: - continue; /* no note here */ - } - if( tn.result.tns != TNS_None ) /* note here is already hit */ - continue; - if( tn.pn != PLAYER_INVALID && tn.pn != m_pPlayerState->m_PlayerNumber ) - continue; - - // A normal note. Penalize for not stepping on it. - TapNote tn2 = tn; + tn.result.tns = TNS_AvoidMine; - if( tn.type == TapNote::mine ) - { - tn2.result.tns = TNS_AvoidMine; - - //Let the server know we avoided a mine - //Hit mines are sent to the server in HandleTapScore - NSMAN->ReportScore( m_pPlayerState->m_PlayerNumber, TNS_AvoidMine, - m_pPlayerStageStats->iScore, - m_pPlayerStageStats->iCurCombo ); - /* The only real way to tell if a mine has been scored is if it has disappeared - * but this only works for hit mines so update the scores for avoided mines here. */ - if( m_pPrimaryScoreKeeper ) - m_pPrimaryScoreKeeper->HandleTapScore( tn2 ); - if( m_pSecondaryScoreKeeper ) - m_pSecondaryScoreKeeper->HandleTapScore( tn2 ); - } - else - { - MissedNoteOnThisRow = true; - tn2.result.tns = TNS_Miss; - } - - m_NoteData.SetTapNote( t, r, tn2 ); + //Let the server know we avoided a mine + //Hit mines are sent to the server in HandleTapScore + NSMAN->ReportScore( m_pPlayerState->m_PlayerNumber, TNS_AvoidMine, + m_pPlayerStageStats->iScore, + m_pPlayerStageStats->iCurCombo ); + /* The only real way to tell if a mine has been scored is if it has disappeared + * but this only works for hit mines so update the scores for avoided mines here. */ + if( m_pPrimaryScoreKeeper ) + m_pPrimaryScoreKeeper->HandleTapScore( tn ); + if( m_pSecondaryScoreKeeper ) + m_pSecondaryScoreKeeper->HandleTapScore( tn ); } - - if( MissedNoteOnThisRow ) + else + { bMisses = true; + tn.result.tns = TNS_Miss; + } } + if( bMisses ) SetJudgment( TNS_Miss, false ); } +static bool MinesNotHidden( const TapNote &tn ) +{ + return tn.type == TapNote::mine && !tn.result.bHidden; +} + void Player::UpdateJudgedRows() { const int iEndRow = BeatToNoteRow( GAMESTATE->m_fSongBeat ); @@ -1417,57 +1407,51 @@ void Player::UpdateJudgedRows() OnRowCompletelyJudged( iRow ); } - for( int iRow = m_iMineRowLastJudged+1; iRow <= iEndRow; ++iRow ) + NoteData::all_tracks_iterator iter = m_NoteData.GetTapNoteRangeAllTracks( m_iMineRowLastJudged+1, iEndRow, MinesNotHidden ); + + bAllJudged = true; + for( ; !iter.IsAtEnd(); ++iter ) { - for( int iTrack = 0; iTrack < m_NoteData.GetNumTracks(); ++iTrack ) + TapNote &tn = *iter; + + switch( tn.result.tns ) { - const TapNote &tn = m_NoteData.GetTapNote( iTrack, iRow ); - - if( tn.type != TapNote::mine ) - continue; - - switch( tn.result.tns ) - { - case TNS_None: bAllJudged = false; - case TNS_AvoidMine: continue; - case TNS_HitMine: break; - DEFAULT_FAIL( tn.result.tns ); - } - - if( tn.result.bHidden ) - continue; - if( m_pNoteField ) - m_pNoteField->DidTapNote( iTrack, tn.result.tns, false ); - - if( tn.pn != PLAYER_INVALID && tn.pn != pn ) - continue; - if( tn.bKeysound && tn.iKeysoundIndex < (int) m_vKeysounds.size() ) - m_vKeysounds[tn.iKeysoundIndex].Play(); - else - m_soundMine.Play(); - - if( m_pLifeMeter ) - m_pLifeMeter->ChangeLife( tn.result.tns ); - if( m_pScoreDisplay ) - m_pScoreDisplay->OnJudgment( tn.result.tns ); - if( m_pSecondaryScoreDisplay ) - m_pSecondaryScoreDisplay->OnJudgment( tn.result.tns ); - if( m_pCombinedLifeMeter ) - m_pCombinedLifeMeter->ChangeLife( pn, tn.result.tns ); - - //Make sure hit mines affect the dance points - if( m_pPrimaryScoreKeeper ) - m_pPrimaryScoreKeeper->HandleTapScore( tn ); - if( m_pSecondaryScoreKeeper ) - m_pSecondaryScoreKeeper->HandleTapScore( tn ); - - TapNote tn2 = tn; - tn2.result.bHidden = true; - m_NoteData.SetTapNote( iTrack, iRow, tn2 ); + case TNS_None: bAllJudged = false; + case TNS_AvoidMine: continue; + case TNS_HitMine: break; + DEFAULT_FAIL( tn.result.tns ); } - if( bAllJudged ) - ++m_iMineRowLastJudged; + if( m_pNoteField ) + m_pNoteField->DidTapNote( iter.Track(), tn.result.tns, false ); + + if( tn.pn != PLAYER_INVALID && tn.pn != pn ) + continue; + if( tn.bKeysound && tn.iKeysoundIndex < (int) m_vKeysounds.size() ) + m_vKeysounds[tn.iKeysoundIndex].Play(); + else + m_soundMine.Play(); + + if( m_pLifeMeter ) + m_pLifeMeter->ChangeLife( tn.result.tns ); + if( m_pScoreDisplay ) + m_pScoreDisplay->OnJudgment( tn.result.tns ); + if( m_pSecondaryScoreDisplay ) + m_pSecondaryScoreDisplay->OnJudgment( tn.result.tns ); + if( m_pCombinedLifeMeter ) + m_pCombinedLifeMeter->ChangeLife( pn, tn.result.tns ); + + //Make sure hit mines affect the dance points + if( m_pPrimaryScoreKeeper ) + m_pPrimaryScoreKeeper->HandleTapScore( tn ); + if( m_pSecondaryScoreKeeper ) + m_pSecondaryScoreKeeper->HandleTapScore( tn ); + tn.result.bHidden = true; + // Subtract one to ensure that we have actually completed the row. + if( bAllJudged && iter.Row() - 1 > m_iMineRowLastJudged ) + m_iMineRowLastJudged = iter.Row() - 1; } + if( bAllJudged ) + m_iMineRowLastJudged = iEndRow; } void Player::CrossedRow( int iNoteRow )