Simplify.

This commit is contained in:
Steve Checkoway
2006-07-21 08:01:28 +00:00
parent c299a7a4f7
commit 9f1bb1e16f
2 changed files with 79 additions and 101 deletions
+4 -10
View File
@@ -62,19 +62,13 @@ int GetNumHoldNotesWithScore( const NoteData &in, TapNote::SubType subType, Hold
return iNumSuccessfulHolds; 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 GetSuccessfulMines( const NoteData &in, int iStartIndex = 0, int iEndIndex = MAX_NOTE_ROW )
{ {
int iNumSuccessfulMinesNotes = 0; int iNumSuccessfulMinesNotes = 0;
FOREACH_NONEMPTY_ROW_ALL_TRACKS_RANGE( in, i, iStartIndex, iEndIndex ) NoteData::all_tracks_const_iterator iter = in.GetTapNoteRangeAllTracks( iStartIndex, iEndIndex, AvoidedMines );
{ for( ; !iter.IsAtEnd(); ++iter )
for( int t=0; t<in.GetNumTracks(); t++ ) ++iNumSuccessfulMinesNotes;
{
const TapNote &tn = in.GetTapNote(t,i);
if( tn.type == TapNote::mine && tn.result.tns == TNS_AvoidMine )
iNumSuccessfulMinesNotes++;
}
}
return iNumSuccessfulMinesNotes; return iNumSuccessfulMinesNotes;
} }
+31 -47
View File
@@ -1315,6 +1315,10 @@ void Player::OnRowCompletelyJudged( int iIndexThatWasSteppedOn )
HandleTapRowScore( iIndexThatWasSteppedOn ); // update score HandleTapRowScore( iIndexThatWasSteppedOn ); // update score
} }
static bool Unjudged( const TapNote &tn )
{
return IteratorCondition::TapsHoldsAndMines( tn ) && tn.result.tns == TNS_None;
}
void Player::UpdateTapNotesMissedOlderThan( float fMissIfOlderThanSeconds ) void Player::UpdateTapNotesMissedOlderThan( float fMissIfOlderThanSeconds )
{ {
@@ -1342,31 +1346,17 @@ void Player::UpdateTapNotesMissedOlderThan( float fMissIfOlderThanSeconds )
const int iStartIndex = min( m_iRowLastJudged, m_iMineRowLastJudged ) + 1; const int iStartIndex = min( m_iRowLastJudged, m_iMineRowLastJudged ) + 1;
bool bMisses = false; bool bMisses = false;
FOREACH_NONEMPTY_ROW_ALL_TRACKS_RANGE( m_NoteData, r, iStartIndex, iMissIfOlderThanThisIndex-1 ) NoteData::all_tracks_iterator iter = m_NoteData.GetTapNoteRangeAllTracks( iStartIndex, iMissIfOlderThanThisIndex-1, Unjudged );
for( ; !iter.IsAtEnd(); ++iter )
{ {
bool MissedNoteOnThisRow = false; TapNote &tn = *iter;
for( int t=0; t<m_NoteData.GetNumTracks(); t++ )
{
/* 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 ) if( tn.pn != PLAYER_INVALID && tn.pn != m_pPlayerState->m_PlayerNumber )
continue; continue;
// A normal note. Penalize for not stepping on it.
TapNote tn2 = tn;
if( tn.type == TapNote::mine ) if( tn.type == TapNote::mine )
{ {
tn2.result.tns = TNS_AvoidMine; tn.result.tns = TNS_AvoidMine;
//Let the server know we avoided a mine //Let the server know we avoided a mine
//Hit mines are sent to the server in HandleTapScore //Hit mines are sent to the server in HandleTapScore
@@ -1376,26 +1366,26 @@ void Player::UpdateTapNotesMissedOlderThan( float fMissIfOlderThanSeconds )
/* The only real way to tell if a mine has been scored is if it has disappeared /* 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. */ * but this only works for hit mines so update the scores for avoided mines here. */
if( m_pPrimaryScoreKeeper ) if( m_pPrimaryScoreKeeper )
m_pPrimaryScoreKeeper->HandleTapScore( tn2 ); m_pPrimaryScoreKeeper->HandleTapScore( tn );
if( m_pSecondaryScoreKeeper ) if( m_pSecondaryScoreKeeper )
m_pSecondaryScoreKeeper->HandleTapScore( tn2 ); m_pSecondaryScoreKeeper->HandleTapScore( tn );
} }
else else
{ {
MissedNoteOnThisRow = true;
tn2.result.tns = TNS_Miss;
}
m_NoteData.SetTapNote( t, r, tn2 );
}
if( MissedNoteOnThisRow )
bMisses = true; bMisses = true;
tn.result.tns = TNS_Miss;
} }
}
if( bMisses ) if( bMisses )
SetJudgment( TNS_Miss, false ); SetJudgment( TNS_Miss, false );
} }
static bool MinesNotHidden( const TapNote &tn )
{
return tn.type == TapNote::mine && !tn.result.bHidden;
}
void Player::UpdateJudgedRows() void Player::UpdateJudgedRows()
{ {
const int iEndRow = BeatToNoteRow( GAMESTATE->m_fSongBeat ); const int iEndRow = BeatToNoteRow( GAMESTATE->m_fSongBeat );
@@ -1417,14 +1407,12 @@ void Player::UpdateJudgedRows()
OnRowCompletelyJudged( iRow ); OnRowCompletelyJudged( iRow );
} }
for( int iRow = m_iMineRowLastJudged+1; iRow <= iEndRow; ++iRow ) NoteData::all_tracks_iterator iter = m_NoteData.GetTapNoteRangeAllTracks( m_iMineRowLastJudged+1, iEndRow, MinesNotHidden );
{
for( int iTrack = 0; iTrack < m_NoteData.GetNumTracks(); ++iTrack )
{
const TapNote &tn = m_NoteData.GetTapNote( iTrack, iRow );
if( tn.type != TapNote::mine ) bAllJudged = true;
continue; for( ; !iter.IsAtEnd(); ++iter )
{
TapNote &tn = *iter;
switch( tn.result.tns ) switch( tn.result.tns )
{ {
@@ -1433,11 +1421,8 @@ void Player::UpdateJudgedRows()
case TNS_HitMine: break; case TNS_HitMine: break;
DEFAULT_FAIL( tn.result.tns ); DEFAULT_FAIL( tn.result.tns );
} }
if( tn.result.bHidden )
continue;
if( m_pNoteField ) if( m_pNoteField )
m_pNoteField->DidTapNote( iTrack, tn.result.tns, false ); m_pNoteField->DidTapNote( iter.Track(), tn.result.tns, false );
if( tn.pn != PLAYER_INVALID && tn.pn != pn ) if( tn.pn != PLAYER_INVALID && tn.pn != pn )
continue; continue;
@@ -1460,14 +1445,13 @@ void Player::UpdateJudgedRows()
m_pPrimaryScoreKeeper->HandleTapScore( tn ); m_pPrimaryScoreKeeper->HandleTapScore( tn );
if( m_pSecondaryScoreKeeper ) if( m_pSecondaryScoreKeeper )
m_pSecondaryScoreKeeper->HandleTapScore( tn ); m_pSecondaryScoreKeeper->HandleTapScore( tn );
tn.result.bHidden = true;
TapNote tn2 = tn; // Subtract one to ensure that we have actually completed the row.
tn2.result.bHidden = true; if( bAllJudged && iter.Row() - 1 > m_iMineRowLastJudged )
m_NoteData.SetTapNote( iTrack, iRow, tn2 ); m_iMineRowLastJudged = iter.Row() - 1;
} }
if( bAllJudged ) if( bAllJudged )
++m_iMineRowLastJudged; m_iMineRowLastJudged = iEndRow;
}
} }
void Player::CrossedRow( int iNoteRow ) void Player::CrossedRow( int iNoteRow )