fixing high score bugs

This commit is contained in:
Chris Danford
2003-10-19 21:38:11 +00:00
parent 900b2c1685
commit 420988148d
7 changed files with 99 additions and 28 deletions
+67 -13
View File
@@ -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<RankingFeats> &asFeatsOut )
{
if( !IsHumanPlayer(pn) )
@@ -769,27 +777,50 @@ void GameState::GetRankingFeats( PlayerNumber pn, vector<RankingFeats> &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<SongAndSteps> 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<Steps::MemCardData::HighScore> &vHighScores = pSteps->m_MemCardDatas[MEMORY_CARD_MACHINE].vHighScores;
for( unsigned j=0; j<vHighScores.size(); j++ )
SongAndSteps sas;
sas.pSong = m_vPlayedStageStats[i].pSong;
ASSERT( sas.pSong );
sas.pSteps = m_vPlayedStageStats[i].pSteps[pn];
ASSERT( sas.pSteps );
vSongAndSteps.push_back( sas );
}
sort( vSongAndSteps.begin(), vSongAndSteps.end() );
vector<SongAndSteps>::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<Steps::MemCardData::HighScore> &vMachineHighScores = pSteps->m_MemCardDatas[MEMORY_CARD_MACHINE].vHighScores;
for( j=0; j<vMachineHighScores.size(); j++ )
{
if( vHighScores[j].sName != RANKING_TO_FILL_IN_MARKER[pn] )
if( vMachineHighScores[j].sName != RANKING_TO_FILL_IN_MARKER[pn] )
continue;
RankingFeats feat;
feat.Type = RankingFeats::SONG;
feat.Feat = ssprintf("No. %d in %s", j+1, pSong->GetFullTranslitTitle().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<RankingFeats> &asFeatsO
asFeatsOut.push_back( feat );
}
// Find Personal Records
vector<Steps::MemCardData::HighScore> &vPersonalHighScores = pSteps->m_MemCardDatas[pn].vHighScores;
for( j=0; j<vPersonalHighScores.size(); j++ )
{
if( vPersonalHighScores[j].sName != RANKING_TO_FILL_IN_MARKER[pn] )
continue;
RankingFeats feat;
feat.Type = RankingFeats::SONG;
feat.Feat = ssprintf("PR #%d in %s %s", j+1, pSong->GetTranslitMainTitle().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<RankingFeats> &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;
+2
View File
@@ -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;
+22 -10
View File
@@ -654,19 +654,30 @@ ScreenEvaluation::ScreenEvaluation( CString sClassName ) : Screen(sClassName)
//
for( p=0; p<NUM_PLAYERS; p++ )
{
if( iPersonalHighScoreIndex[p] == 0 )
if( iMachineHighScoreIndex[p] != -1 )
{
m_sprNewRecord[p].Load( THEME->GetPathToG("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; p<NUM_PLAYERS; p++ )
if( GAMESTATE->IsPlayerEnabled(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" );
}
+2 -1
View File
@@ -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;
};
+2
View File
@@ -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 )
{
+3 -3
View File
@@ -323,9 +323,9 @@ void SortNotesArrayByDifficulty( vector<Steps*> &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;
}
+1 -1
View File
@@ -74,7 +74,7 @@ public:
fScore = 0;
}
bool operator>( const HighScore& other ) const;
bool operator>=( const HighScore& other ) const;
};
vector<HighScore> vHighScores;