From 54ab1e13823cf2263a2de33b66196cbe4e97ed11 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sun, 2 Nov 2003 17:05:11 +0000 Subject: [PATCH] Add GetMaxCombo. Store combo rollover separately in the combo record. --- stepmania/src/StageStats.cpp | 28 +++++++++++++++++++++++++++- stepmania/src/StageStats.h | 6 +++++- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/stepmania/src/StageStats.cpp b/stepmania/src/StageStats.cpp index 60017b39a4..dfecef28f5 100644 --- a/stepmania/src/StageStats.cpp +++ b/stepmania/src/StageStats.cpp @@ -183,7 +183,7 @@ void StageStats::UpdateComboList( PlayerNumber pn, float pos ) fFirstPos[pn] = min( pos, fFirstPos[pn] ); fLastPos[pn] = max( pos, fLastPos[pn] ); - const int cnt = iCurCombo[pn]; + int cnt = iCurCombo[pn]; if( !cnt ) return; /* no combo */ @@ -193,6 +193,15 @@ void StageStats::UpdateComboList( PlayerNumber pn, float pos ) Combo_t NewCombo; NewCombo.start = pos; ComboList[pn].push_back( NewCombo ); + + /* If this is the first combo, and the current combo is greater than 1, + * then that extra part of the combo must have come from a previous song. + * Remember it separately. */ + if( ComboList[pn].size() == 1 ) + { + ComboList[pn][0].rollover = cnt-1; + cnt = 1; + } } Combo_t &combo = ComboList[pn].back(); @@ -200,6 +209,23 @@ void StageStats::UpdateComboList( PlayerNumber pn, float pos ) combo.cnt = cnt; } +/* This returns the largest combo contained within the song, as if + * m_bComboContinuesBetweenSongs is turned off. */ +StageStats::Combo_t StageStats::GetMaxCombo( PlayerNumber pn ) const +{ + if( ComboList[pn].size() == 0 ) + return Combo_t(); + + int m = 0; + for( unsigned i = 1; i < ComboList[pn].size(); ++i ) + { + if( ComboList[pn][i].cnt > ComboList[pn][m].cnt ) + m = i; + } + + return ComboList[pn][m]; +} + /* SetLifeRecord and UpdateComboList take a percentage (0..1) in pos, but the values * will actually be somewhat off as they're based on Song::m_fFirstBeat and m_fLastBeat, * which are per-song, not per-Steps. Scale and shift our records so that they're diff --git a/stepmania/src/StageStats.h b/stepmania/src/StageStats.h index 0540b4dc78..d7e1152888 100644 --- a/stepmania/src/StageStats.h +++ b/stepmania/src/StageStats.h @@ -73,13 +73,17 @@ struct StageStats /* Combo size, in steps. */ int cnt; - Combo_t(): start(-1), size(-1), cnt(-1) { } + /* Combo rollover from the last song (see UpdateComboList for details). */ + int rollover; + + Combo_t(): start(0), size(0), cnt(0), rollover(0) { } bool IsZero() const { return start < 0; } }; float fFirstPos[NUM_PLAYERS], fLastPos[NUM_PLAYERS]; bool FullCombo( PlayerNumber pn ) const; void UpdateComboList( PlayerNumber pn, float pos ); + Combo_t GetMaxCombo( PlayerNumber pn ) const; void Finish(); vector ComboList[NUM_PLAYERS];