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;
} }
+75 -91
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,60 +1346,46 @@ 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++ )
if( tn.pn != PLAYER_INVALID && tn.pn != m_pPlayerState->m_PlayerNumber )
continue;
if( tn.type == TapNote::mine )
{ {
/* XXX: cleaner to pick the things we do want to apply misses to, instead of tn.result.tns = TNS_AvoidMine;
* 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. //Let the server know we avoided a mine
TapNote tn2 = tn; //Hit mines are sent to the server in HandleTapScore
NSMAN->ReportScore( m_pPlayerState->m_PlayerNumber, TNS_AvoidMine,
if( tn.type == TapNote::mine ) m_pPlayerStageStats->iScore,
{ m_pPlayerStageStats->iCurCombo );
tn2.result.tns = TNS_AvoidMine; /* 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. */
//Let the server know we avoided a mine if( m_pPrimaryScoreKeeper )
//Hit mines are sent to the server in HandleTapScore m_pPrimaryScoreKeeper->HandleTapScore( tn );
NSMAN->ReportScore( m_pPlayerState->m_PlayerNumber, TNS_AvoidMine, if( m_pSecondaryScoreKeeper )
m_pPlayerStageStats->iScore, m_pSecondaryScoreKeeper->HandleTapScore( tn );
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 );
} }
else
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,57 +1407,51 @@ 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 );
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 ); case TNS_None: bAllJudged = false;
case TNS_AvoidMine: continue;
if( tn.type != TapNote::mine ) case TNS_HitMine: break;
continue; DEFAULT_FAIL( tn.result.tns );
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 );
} }
if( bAllJudged ) if( m_pNoteField )
++m_iMineRowLastJudged; 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 ) void Player::CrossedRow( int iNoteRow )