From 420988148dcefdd622e9b97e52abe4f96503bc18 Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Sun, 19 Oct 2003 21:38:11 +0000 Subject: [PATCH] fixing high score bugs --- stepmania/src/GameState.cpp | 80 +++++++++++++++++++++++++----- stepmania/src/ScreenAttract.cpp | 2 + stepmania/src/ScreenEvaluation.cpp | 32 ++++++++---- stepmania/src/ScreenEvaluation.h | 3 +- stepmania/src/ScreenNameEntry.cpp | 2 + stepmania/src/Steps.cpp | 6 +-- stepmania/src/Steps.h | 2 +- 7 files changed, 99 insertions(+), 28 deletions(-) diff --git a/stepmania/src/GameState.cpp b/stepmania/src/GameState.cpp index 56a5e42d9e..19e7239e21 100644 --- a/stepmania/src/GameState.cpp +++ b/stepmania/src/GameState.cpp @@ -760,6 +760,14 @@ Character* GameState::GetDefaultCharacter() return NULL; } +struct SongAndSteps +{ + Song* pSong; + Steps* pSteps; + bool operator==( const SongAndSteps& other ) { return pSong==other.pSong && pSteps==other.pSteps; } + bool operator<( const SongAndSteps& other ) { return pSong<=other.pSong && pSteps<=other.pSteps; } +}; + void GameState::GetRankingFeats( PlayerNumber pn, vector &asFeatsOut ) { if( !IsHumanPlayer(pn) ) @@ -769,27 +777,50 @@ void GameState::GetRankingFeats( PlayerNumber pn, vector &asFeatsO { case PLAY_MODE_ARCADE: { - int i; + unsigned i, j; StepsType nt = GAMESTATE->GetCurrentStyleDef()->m_StepsType; + + // + // Find unique Song and Steps combinations that were played. + // We must keep only the unique combination or else we'll double-count + // high score markers. + // + vector vSongAndSteps; + for( i=0; i<(int)m_vPlayedStageStats.size(); i++ ) { - Song* pSong = m_vPlayedStageStats[i].pSong; - ASSERT( pSong ); - Steps* pSteps = m_vPlayedStageStats[i].pSteps[pn]; - ASSERT( pSteps ); - vector &vHighScores = pSteps->m_MemCardDatas[MEMORY_CARD_MACHINE].vHighScores; - for( unsigned j=0; j::iterator toDelete = unique( vSongAndSteps.begin(), vSongAndSteps.end() ); + vSongAndSteps.erase(toDelete, vSongAndSteps.end()); + + for( i=0; i<(int)vSongAndSteps.size(); i++ ) + { + Song* pSong = vSongAndSteps[i].pSong; + Steps* pSteps = vSongAndSteps[i].pSteps; + + // Find Machine Records + vector &vMachineHighScores = pSteps->m_MemCardDatas[MEMORY_CARD_MACHINE].vHighScores; + for( j=0; jGetFullTranslitTitle().c_str() ); - feat.pStringToFill = &vHighScores[j].sName; - feat.g = vHighScores[j].grade; - feat.Score = vHighScores[j].fScore; + feat.Feat = ssprintf("MR #%d in %s %s", j+1, pSong->GetTranslitMainTitle().c_str(), DifficultyToString(pSteps->GetDifficulty()).c_str() ); + feat.pStringToFill = &vMachineHighScores[j].sName; + feat.g = vMachineHighScores[j].grade; + feat.Score = vMachineHighScores[j].fScore; // XXX: temporary hack if( pSong->HasBackground() ) @@ -799,6 +830,29 @@ void GameState::GetRankingFeats( PlayerNumber pn, vector &asFeatsO asFeatsOut.push_back( feat ); } + + // Find Personal Records + vector &vPersonalHighScores = pSteps->m_MemCardDatas[pn].vHighScores; + for( j=0; jGetTranslitMainTitle().c_str(), DifficultyToString(pSteps->GetDifficulty()).c_str() ); + feat.pStringToFill = &vPersonalHighScores[j].sName; + feat.g = vPersonalHighScores[j].grade; + feat.Score = vPersonalHighScores[j].fScore; + + // XXX: temporary hack + if( pSong->HasBackground() ) + feat.Banner = pSong->GetBackgroundPath(); + // if( pSong->HasBanner() ) + // feat.Banner = pSong->GetBannerPath(); + + asFeatsOut.push_back( feat ); + } } StageStats stats; @@ -816,7 +870,7 @@ void GameState::GetRankingFeats( PlayerNumber pn, vector &asFeatsO RankingFeats feat; feat.Type = RankingFeats::RANKING; - feat.Feat = ssprintf("No. %d in Type %c (%d)", j+1, 'A'+i, stats.iMeter[pn] ); + feat.Feat = ssprintf("#%d in Type %c (%d)", j+1, 'A'+i, stats.iMeter[pn] ); feat.pStringToFill = &vHighScores[j].sName; feat.g = GRADE_NO_DATA; feat.Score = (float) vHighScores[j].iScore; diff --git a/stepmania/src/ScreenAttract.cpp b/stepmania/src/ScreenAttract.cpp index 80c0f70743..f5f648296a 100644 --- a/stepmania/src/ScreenAttract.cpp +++ b/stepmania/src/ScreenAttract.cpp @@ -53,6 +53,8 @@ ScreenAttract::ScreenAttract( CString sClassName ) : Screen( sClassName ) if( PREFSMAN->m_bAttractSound ) SOUND->PlayMusic( THEME->GetPathToS(m_sName + " music") ); + else + SOUND->PlayMusic( "" ); // stop music GAMESTATE->m_bPlayersCanJoin = true; diff --git a/stepmania/src/ScreenEvaluation.cpp b/stepmania/src/ScreenEvaluation.cpp index 450afb5149..e9dd736a1c 100644 --- a/stepmania/src/ScreenEvaluation.cpp +++ b/stepmania/src/ScreenEvaluation.cpp @@ -654,19 +654,30 @@ ScreenEvaluation::ScreenEvaluation( CString sClassName ) : Screen(sClassName) // for( p=0; pGetPathToG("ScreenEvaluation new record") ); - m_sprNewRecord[p].SetName( ssprintf("NewRecordP%d",p+1) ); - UtilSetXYAndOnCommand( m_sprNewRecord[p], "ScreenEvaluation" ); - this->AddChild( &m_sprNewRecord[p] ); + m_sprMachineRecord[p].Load( THEME->GetPathToG("ScreenEvaluation machine record") ); + m_sprMachineRecord[p].SetState( iMachineHighScoreIndex[p] ); + m_sprMachineRecord[p].StopAnimating(); + m_sprMachineRecord[p].SetName( ssprintf("MachineRecordP%d",p+1) ); + UtilSetXYAndOnCommand( m_sprMachineRecord[p], "ScreenEvaluation" ); + this->AddChild( &m_sprMachineRecord[p] ); + } + if( iPersonalHighScoreIndex[p] != -1 ) + { + m_sprPersonalRecord[p].Load( THEME->GetPathToG("ScreenEvaluation personal record") ); + m_sprPersonalRecord[p].SetState( iPersonalHighScoreIndex[p] ); + m_sprPersonalRecord[p].StopAnimating(); + m_sprPersonalRecord[p].SetName( ssprintf("PersonalRecordP%d",p+1) ); + UtilSetXYAndOnCommand( m_sprPersonalRecord[p], "ScreenEvaluation" ); + this->AddChild( &m_sprPersonalRecord[p] ); } } - bool bOneHasNewRecord = false; + bool bOneHasNewTopRecord = false; for( p=0; pIsPlayerEnabled(p) && iPersonalHighScoreIndex[p] == 0 ) - bOneHasNewRecord = true; + if( GAMESTATE->IsPlayerEnabled(p) && iMachineHighScoreIndex[p] != 0 || iPersonalHighScoreIndex[p] != 0 ) + bOneHasNewTopRecord = true; if( PREFSMAN->m_bAllowExtraStage && m_bTryExtraStage ) { @@ -680,7 +691,7 @@ ScreenEvaluation::ScreenEvaluation( CString sClassName ) : Screen(sClassName) else SOUND->PlayOnce( THEME->GetPathToS("ScreenEvaluation try extra1") ); } - else if( bOneHasNewRecord && ANNOUNCER->HasSoundsFor("evaluation new record") ) + else if( bOneHasNewTopRecord && ANNOUNCER->HasSoundsFor("evaluation new record") ) { SOUND->PlayOnceFromDir( ANNOUNCER->GetPathTo("evaluation new record") ); } @@ -861,7 +872,8 @@ void ScreenEvaluation::TweenOffScreen() { if( !GAMESTATE->IsPlayerEnabled(p) ) continue; - UtilOffCommand( m_sprNewRecord[p], "ScreenEvaluation" ); + UtilOffCommand( m_sprMachineRecord[p], "ScreenEvaluation" ); + UtilOffCommand( m_sprPersonalRecord[p], "ScreenEvaluation" ); } UtilOffCommand( m_sprTryExtraStage, "ScreenEvaluation" ); } diff --git a/stepmania/src/ScreenEvaluation.h b/stepmania/src/ScreenEvaluation.h index 94229db814..31eafe75d0 100644 --- a/stepmania/src/ScreenEvaluation.h +++ b/stepmania/src/ScreenEvaluation.h @@ -100,7 +100,8 @@ protected: BitmapText m_textTime[NUM_PLAYERS]; // extra area - Sprite m_sprNewRecord[NUM_PLAYERS]; + Sprite m_sprMachineRecord[NUM_PLAYERS]; + Sprite m_sprPersonalRecord[NUM_PLAYERS]; bool m_bTryExtraStage; Sprite m_sprTryExtraStage; }; diff --git a/stepmania/src/ScreenNameEntry.cpp b/stepmania/src/ScreenNameEntry.cpp index 8ddaf81610..32be114981 100644 --- a/stepmania/src/ScreenNameEntry.cpp +++ b/stepmania/src/ScreenNameEntry.cpp @@ -32,6 +32,7 @@ #define TIMER_X THEME->GetMetricF("ScreenNameEntry","TimerX") #define TIMER_Y THEME->GetMetricF("ScreenNameEntry","TimerY") #define CATEGORY_Y THEME->GetMetricF("ScreenNameEntry","CategoryY") +#define CATEGORY_ZOOM THEME->GetMetricF("ScreenNameEntry","CategoryZoom") #define CHARS_ZOOM_SMALL THEME->GetMetricF("ScreenNameEntry","CharsZoomSmall") #define CHARS_ZOOM_LARGE THEME->GetMetricF("ScreenNameEntry","CharsZoomLarge") #define CHARS_SPACING_Y THEME->GetMetricF("ScreenNameEntry","CharsSpacingY") @@ -208,6 +209,7 @@ ScreenNameEntry::ScreenNameEntry( CString sClassName ) : Screen( sClassName ) m_textCategory[p].LoadFromFont( THEME->GetPathToF("ScreenNameEntry category") ); m_textCategory[p].SetX( (float)GAMESTATE->GetCurrentStyleDef()->m_iCenterX[p] ); m_textCategory[p].SetY( CATEGORY_Y ); + m_textCategory[p].SetZoom( CATEGORY_ZOOM ); CString joined; for( unsigned j = 0; j < aFeats[p].size(); ++j ) { diff --git a/stepmania/src/Steps.cpp b/stepmania/src/Steps.cpp index b9f63298e5..439a748eb8 100644 --- a/stepmania/src/Steps.cpp +++ b/stepmania/src/Steps.cpp @@ -323,9 +323,9 @@ void SortNotesArrayByDifficulty( vector &arraySteps ) -bool Steps::MemCardData::HighScore::operator>( const Steps::MemCardData::HighScore& other ) const +bool Steps::MemCardData::HighScore::operator>=( const Steps::MemCardData::HighScore& other ) const { - return fScore > other.fScore; + return fScore >= other.fScore; /* Make sure we treat AAAA as higher than AAA, even though the score * is the same. * @@ -344,7 +344,7 @@ void Steps::MemCardData::AddHighScore( Steps::MemCardData::HighScore hs, int &iI int i; for( i=0; i<(int)vHighScores.size(); i++ ) { - if( hs > vHighScores[i] ) + if( hs >= vHighScores[i] ) // tie goes to new score break; } diff --git a/stepmania/src/Steps.h b/stepmania/src/Steps.h index 870bec26b5..b7d7dde1ee 100644 --- a/stepmania/src/Steps.h +++ b/stepmania/src/Steps.h @@ -74,7 +74,7 @@ public: fScore = 0; } - bool operator>( const HighScore& other ) const; + bool operator>=( const HighScore& other ) const; }; vector vHighScores;