add CourseLastScores for tournaments

This commit is contained in:
Chris Danford
2004-04-22 22:01:38 +00:00
parent d2e6537efe
commit 0cc49c66bb
7 changed files with 171 additions and 79 deletions
+2 -1
View File
@@ -36,7 +36,8 @@ class CourseID
CString sName;
public:
CourseID() { FromCourse(NULL); }
CourseID() { Unset(); }
void Unset() { FromCourse(NULL); }
void FromCourse( const Course *p );
Course *ToCourse() const;
bool operator<( const CourseID &other ) const
+93 -37
View File
@@ -157,9 +157,14 @@ void Profile::InitAwards()
}
}
void Profile::InitLastScores()
void Profile::InitSongLastScores()
{
m_vLastScores.clear();
m_vLastStepsScores.clear();
}
void Profile::InitCourseLastScores()
{
m_vLastCourseScores.clear();
}
CString Profile::GetDisplayName() const
@@ -528,7 +533,8 @@ bool Profile::LoadAllFromDir( CString sDir, bool bRequireSignature )
LOAD_NODE( ScreenshotData );
LOAD_NODE( CalorieData );
LOAD_NODE( Awards );
LOAD_NODE( LastScores );
LOAD_NODE( SongLastScores );
LOAD_NODE( CourseLastScores );
}
return true; // FIXME? Investigate what happens if we always return true.
@@ -554,7 +560,8 @@ bool Profile::SaveAllToDir( CString sDir, bool bSignData ) const
xml.AppendChild( SaveScreenshotDataCreateNode() );
xml.AppendChild( SaveCalorieDataCreateNode() );
xml.AppendChild( SaveAwardsCreateNode() );
xml.AppendChild( SaveLastScoresCreateNode() );
xml.AppendChild( SaveSongLastScoresCreateNode() );
xml.AppendChild( SaveCourseLastScoresCreateNode() );
bool bSaved = xml.SaveToFile(fn);
// Update file cache, or else IsAFile in CryptManager won't see this new file.
@@ -1805,30 +1812,6 @@ bool Profile::HasPeakComboAward( PeakComboAward pca )
}
XNode* Profile::HighScoreForASongAndSteps::CreateNode() const
{
XNode* pNode = new XNode;
@@ -1855,11 +1838,11 @@ void Profile::HighScoreForASongAndSteps::LoadFromNode( const XNode* pNode )
hs.LoadFromNode( p );
}
void Profile::LoadLastScoresFromNode( const XNode* pNode )
void Profile::LoadSongLastScoresFromNode( const XNode* pNode )
{
CHECKPOINT;
ASSERT( pNode->name == "LastScores" );
ASSERT( pNode->name == "LastSongScores" );
for( XNodes::const_iterator p = pNode->childs.begin();
p != pNode->childs.end();
p++ )
@@ -1869,14 +1852,14 @@ void Profile::LoadLastScoresFromNode( const XNode* pNode )
HighScoreForASongAndSteps h;
h.LoadFromNode( *p );
m_vLastScores.push_back( h );
m_vLastStepsScores.push_back( h );
}
else
WARN_AND_CONTINUE;
}
}
XNode* Profile::SaveLastScoresCreateNode() const
XNode* Profile::SaveSongLastScoresCreateNode() const
{
CHECKPOINT;
@@ -1884,24 +1867,97 @@ XNode* Profile::SaveLastScoresCreateNode() const
ASSERT( pProfile );
XNode* pNode = new XNode;
pNode->name = "LastScores";
pNode->name = "LastSongScores";
unsigned uNumToSave = min( m_vLastScores.size(), (unsigned)MAX_LAST_SCORES_TO_SAVE );
unsigned uNumToSave = min( m_vLastStepsScores.size(), (unsigned)MAX_LAST_SCORES_TO_SAVE );
for( unsigned i=0; i<uNumToSave; i++ )
{
pNode->AppendChild( m_vLastScores[i].CreateNode() );
pNode->AppendChild( m_vLastStepsScores[i].CreateNode() );
}
return pNode;
}
void Profile::AddLastScore( Song* pSong, Steps* pSteps, HighScore hs )
void Profile::AddStepsLastScore( const Song* pSong, const Steps* pSteps, HighScore hs )
{
HighScoreForASongAndSteps h;
h.songID.FromSong( pSong );
h.stepsID.FromSteps( pSteps );
h.hs = hs;
m_vLastScores.push_back( h );
m_vLastStepsScores.push_back( h );
}
XNode* Profile::HighScoreForACourse::CreateNode() const
{
XNode* pNode = new XNode;
pNode->name = "HighScoreForACourse";
pNode->AppendChild( courseID.CreateNode() );
pNode->AppendChild( hs.CreateNode() );
return pNode;
}
void Profile::HighScoreForACourse::LoadFromNode( const XNode* pNode )
{
Unset();
ASSERT( pNode->name == "HighScoreForACourse" );
XNode* p;
if( p = pNode->GetChild("Course") )
courseID.LoadFromNode( p );
if( p = pNode->GetChild("HighScore") )
hs.LoadFromNode( p );
}
void Profile::LoadCourseLastScoresFromNode( const XNode* pNode )
{
CHECKPOINT;
ASSERT( pNode->name == "LastCourseScores" );
for( XNodes::const_iterator p = pNode->childs.begin();
p != pNode->childs.end();
p++ )
{
if( (*p)->name == "HighScoreForACourse" )
{
HighScoreForACourse h;
h.LoadFromNode( *p );
m_vLastCourseScores.push_back( h );
}
else
WARN_AND_CONTINUE;
}
}
XNode* Profile::SaveCourseLastScoresCreateNode() const
{
CHECKPOINT;
const Profile* pProfile = this;
ASSERT( pProfile );
XNode* pNode = new XNode;
pNode->name = "LastCourseScores";
unsigned uNumToSave = min( m_vLastCourseScores.size(), (unsigned)MAX_LAST_SCORES_TO_SAVE );
for( unsigned i=0; i<uNumToSave; i++ )
{
pNode->AppendChild( m_vLastCourseScores[i].CreateNode() );
}
return pNode;
}
void Profile::AddCourseLastScore( const Course* pCourse, StepsType st, CourseDifficulty cd, HighScore hs )
{
HighScoreForACourse h;
h.courseID.FromCourse( pCourse );
h.hs = hs;
m_vLastCourseScores.push_back( h );
}
+28 -7
View File
@@ -238,7 +238,7 @@ public:
bool HasPeakComboAward( PeakComboAward pca );
//
// LastScores
// LastSongScores
//
struct HighScoreForASongAndSteps
{
@@ -252,8 +252,25 @@ public:
XNode* CreateNode() const;
void LoadFromNode( const XNode* pNode );
};
vector<HighScoreForASongAndSteps> m_vLastScores;
void AddLastScore( Song* pSong, Steps* pSteps, HighScore hs );
vector<HighScoreForASongAndSteps> m_vLastStepsScores;
void AddStepsLastScore( const Song* pSong, const Steps* pSteps, HighScore hs );
//
// LastCourseScores
//
struct HighScoreForACourse
{
CourseID courseID;
HighScore hs;
HighScoreForACourse() { Unset(); }
void Unset() { courseID.Unset(); hs.Unset(); }
XNode* CreateNode() const;
void LoadFromNode( const XNode* pNode );
};
vector<HighScoreForACourse> m_vLastCourseScores;
void AddCourseLastScore( const Course* pCourse, StepsType st, CourseDifficulty cd, HighScore hs );
//
// Init'ing
@@ -268,7 +285,8 @@ public:
InitScreenshotData();
InitCalorieData();
InitAwards();
InitLastScores();
InitSongLastScores();
InitCourseLastScores();
}
void InitEditableData();
void InitGeneralData();
@@ -278,7 +296,8 @@ public:
void InitScreenshotData();
void InitCalorieData();
void InitAwards();
void InitLastScores();
void InitSongLastScores();
void InitCourseLastScores();
//
// Loading and saving
@@ -299,7 +318,8 @@ public:
void LoadScreenshotDataFromNode( const XNode* pNode );
void LoadCalorieDataFromNode( const XNode* pNode );
void LoadAwardsFromNode( const XNode* pNode );
void LoadLastScoresFromNode( const XNode* pNode );
void LoadSongLastScoresFromNode( const XNode* pNode );
void LoadCourseLastScoresFromNode( const XNode* pNode );
void SaveEditableDataToDir( CString sDir ) const;
XNode* SaveGeneralDataCreateNode() const;
@@ -309,7 +329,8 @@ public:
XNode* SaveScreenshotDataCreateNode() const;
XNode* SaveCalorieDataCreateNode() const;
XNode* SaveAwardsCreateNode() const;
XNode* SaveLastScoresCreateNode() const;
XNode* SaveSongLastScoresCreateNode() const;
XNode* SaveCourseLastScoresCreateNode() const;
void DeleteProfileDataFromDirSM390a12( CString sDir ) const;
void DeleteSongScoresFromDirSM390a12( CString sDir ) const;
+36 -19
View File
@@ -432,14 +432,21 @@ int ProfileManager::GetSongNumTimesPlayed( const Song* pSong, ProfileSlot slot )
return GetProfile(slot)->GetSongNumTimesPlayed( pSong );
}
void ProfileManager::AddStepsHighScore( const Song* pSong, const Steps* pSteps, PlayerNumber pn, HighScore hs, int &iPersonalIndexOut, int &iMachineIndexOut )
void ProfileManager::AddStepsScore( const Song* pSong, const Steps* pSteps, PlayerNumber pn, HighScore hs, int &iPersonalIndexOut, int &iMachineIndexOut )
{
hs.sName = RANKING_TO_FILL_IN_MARKER[pn];
if( hs.fPercentDP >= PREFSMAN->m_fMinPercentageForHighScore )
{
hs.sName = RANKING_TO_FILL_IN_MARKER[pn];
if( PROFILEMAN->IsUsingProfile(pn) )
PROFILEMAN->GetProfile(pn)->AddStepsHighScore( pSong, pSteps, hs, iPersonalIndexOut );
else
iPersonalIndexOut = -1;
PROFILEMAN->GetMachineProfile()->AddStepsHighScore( pSong, pSteps, hs, iMachineIndexOut );
}
if( PROFILEMAN->IsUsingProfile(pn) )
PROFILEMAN->GetProfile(pn)->AddStepsHighScore( pSong, pSteps, hs, iPersonalIndexOut );
else
iPersonalIndexOut = -1;
PROFILEMAN->GetMachineProfile()->AddStepsHighScore( pSong, pSteps, hs, iMachineIndexOut );
PROFILEMAN->GetProfile(pn)->AddStepsLastScore( pSong, pSteps, hs );
PROFILEMAN->GetMachineProfile()->AddStepsLastScore( pSong, pSteps, hs );
}
void ProfileManager::IncrementStepsPlayCount( const Song* pSong, const Steps* pSteps, PlayerNumber pn )
@@ -468,14 +475,21 @@ HighScore ProfileManager::GetHighScoreForDifficulty( const Song *s, const StyleD
//
// Course stats
//
void ProfileManager::AddCourseHighScore( const Course* pCourse, StepsType st, CourseDifficulty cd, PlayerNumber pn, HighScore hs, int &iPersonalIndexOut, int &iMachineIndexOut )
void ProfileManager::AddCourseScore( const Course* pCourse, StepsType st, CourseDifficulty cd, PlayerNumber pn, HighScore hs, int &iPersonalIndexOut, int &iMachineIndexOut )
{
hs.sName = RANKING_TO_FILL_IN_MARKER[pn];
if( hs.fPercentDP >= PREFSMAN->m_fMinPercentageForHighScore )
{
hs.sName = RANKING_TO_FILL_IN_MARKER[pn];
if( PROFILEMAN->IsUsingProfile(pn) )
PROFILEMAN->GetProfile(pn)->AddCourseHighScore( pCourse, st, cd, hs, iPersonalIndexOut );
else
iPersonalIndexOut = -1;
PROFILEMAN->GetMachineProfile()->AddCourseHighScore( pCourse, st, cd, hs, iMachineIndexOut );
}
if( PROFILEMAN->IsUsingProfile(pn) )
PROFILEMAN->GetProfile(pn)->AddCourseHighScore( pCourse, st, cd, hs, iPersonalIndexOut );
else
iPersonalIndexOut = -1;
PROFILEMAN->GetMachineProfile()->AddCourseHighScore( pCourse, st, cd, hs, iMachineIndexOut );
PROFILEMAN->GetProfile(pn)->AddCourseLastScore( pCourse, st, cd, hs );
PROFILEMAN->GetMachineProfile()->AddCourseLastScore( pCourse, st, cd, hs );
}
void ProfileManager::IncrementCoursePlayCount( const Course* pCourse, StepsType st, CourseDifficulty cd, PlayerNumber pn )
@@ -489,14 +503,17 @@ void ProfileManager::IncrementCoursePlayCount( const Course* pCourse, StepsType
//
// Category stats
//
void ProfileManager::AddCategoryHighScore( StepsType st, RankingCategory rc, PlayerNumber pn, HighScore hs, int &iPersonalIndexOut, int &iMachineIndexOut )
void ProfileManager::AddCategoryScore( StepsType st, RankingCategory rc, PlayerNumber pn, HighScore hs, int &iPersonalIndexOut, int &iMachineIndexOut )
{
hs.sName = RANKING_TO_FILL_IN_MARKER[pn];
if( PROFILEMAN->IsUsingProfile(pn) )
PROFILEMAN->GetProfile(pn)->AddCategoryHighScore( st, rc, hs, iPersonalIndexOut );
else
iPersonalIndexOut = -1;
PROFILEMAN->GetMachineProfile()->AddCategoryHighScore( st, rc, hs, iMachineIndexOut );
if( hs.fPercentDP > PREFSMAN->m_fMinPercentageForHighScore )
{
hs.sName = RANKING_TO_FILL_IN_MARKER[pn];
if( PROFILEMAN->IsUsingProfile(pn) )
PROFILEMAN->GetProfile(pn)->AddCategoryHighScore( st, rc, hs, iPersonalIndexOut );
else
iPersonalIndexOut = -1;
PROFILEMAN->GetMachineProfile()->AddCategoryHighScore( st, rc, hs, iMachineIndexOut );
}
}
void ProfileManager::IncrementCategoryPlayCount( StepsType st, RankingCategory rc, PlayerNumber pn )
+3 -3
View File
@@ -83,20 +83,20 @@ public:
//
int GetSongNumTimesPlayed( const Song* pSong, ProfileSlot card ) const;
bool IsSongNew( const Song* pSong ) const { return GetSongNumTimesPlayed(pSong,PROFILE_SLOT_MACHINE)==0; }
void AddStepsHighScore( const Song* pSong, const Steps* pSteps, PlayerNumber pn, HighScore hs, int &iPersonalIndexOut, int &iMachineIndexOut );
void AddStepsScore( const Song* pSong, const Steps* pSteps, PlayerNumber pn, HighScore hs, int &iPersonalIndexOut, int &iMachineIndexOut );
void IncrementStepsPlayCount( const Song* pSong, const Steps* pSteps, PlayerNumber pn );
HighScore GetHighScoreForDifficulty( const Song *s, const StyleDef *st, ProfileSlot slot, Difficulty dc ) const;
//
// Course stats
//
void AddCourseHighScore( const Course* pCourse, StepsType st, CourseDifficulty cd, PlayerNumber pn, HighScore hs, int &iPersonalIndexOut, int &iMachineIndexOut );
void AddCourseScore( const Course* pCourse, StepsType st, CourseDifficulty cd, PlayerNumber pn, HighScore hs, int &iPersonalIndexOut, int &iMachineIndexOut );
void IncrementCoursePlayCount( const Course* pCourse, StepsType st, CourseDifficulty cd, PlayerNumber pn );
//
// Category stats
//
void AddCategoryHighScore( StepsType nt, RankingCategory rc, PlayerNumber pn, HighScore hs, int &iPersonalIndexOut, int &iMachineIndexOut );
void AddCategoryScore( StepsType nt, RankingCategory rc, PlayerNumber pn, HighScore hs, int &iPersonalIndexOut, int &iMachineIndexOut );
void IncrementCategoryPlayCount( StepsType nt, RankingCategory rc, PlayerNumber pn );
+3 -6
View File
@@ -959,8 +959,7 @@ void ScreenEvaluation::CommitScores(
ASSERT( pSteps );
if( hs.fPercentDP >= PREFSMAN->m_fMinPercentageForHighScore )
PROFILEMAN->AddStepsHighScore( pSong, pSteps, (PlayerNumber)p, hs, iPersonalHighScoreIndexOut[p], iMachineHighScoreIndexOut[p] );
PROFILEMAN->AddStepsScore( pSong, pSteps, (PlayerNumber)p, hs, iPersonalHighScoreIndexOut[p], iMachineHighScoreIndexOut[p] );
}
break;
@@ -973,8 +972,7 @@ void ScreenEvaluation::CommitScores(
float fAverageMeter = stageStats.iMeter[p] / (float)PREFSMAN->m_iNumArcadeStages;
rcOut[p] = AverageMeterToRankingCategory( fAverageMeter );
if( hs.fPercentDP > PREFSMAN->m_fMinPercentageForHighScore )
PROFILEMAN->AddCategoryHighScore( nt, rcOut[p], (PlayerNumber)p, hs, iPersonalHighScoreIndexOut[p], iMachineHighScoreIndexOut[p] );
PROFILEMAN->AddCategoryScore( nt, rcOut[p], (PlayerNumber)p, hs, iPersonalHighScoreIndexOut[p], iMachineHighScoreIndexOut[p] );
// TRICKY: Increment play count here, and not on ScreenGameplay like the others.
PROFILEMAN->IncrementCategoryPlayCount( nt, rcOut[p], (PlayerNumber)p );
@@ -992,8 +990,7 @@ void ScreenEvaluation::CommitScores(
if( stageStats.bFailed[p] && pCourse->IsNonstop() )
continue;
if( hs.fPercentDP > PREFSMAN->m_fMinPercentageForHighScore )
PROFILEMAN->AddCourseHighScore( pCourse, nt, cd, (PlayerNumber)p, hs, iPersonalHighScoreIndexOut[p], iMachineHighScoreIndexOut[p] );
PROFILEMAN->AddCourseScore( pCourse, nt, cd, (PlayerNumber)p, hs, iPersonalHighScoreIndexOut[p], iMachineHighScoreIndexOut[p] );
}
break;
default:
+6 -6
View File
@@ -168,12 +168,12 @@ ScreenNameEntryTraditional::ScreenNameEntryTraditional( CString sClassName ) : S
hs.iScore = st.iScore[p];
StepsType nt = GAMESTATE->GetCurrentStyleDef()->m_StepsType;
int a, b;
PROFILEMAN->AddStepsHighScore( st.pSong, GAMESTATE->m_pCurNotes[p], (PlayerNumber)p, hs, a, b );
PROFILEMAN->AddStepsHighScore( st.pSong, GAMESTATE->m_pCurNotes[p], (PlayerNumber)p, hs, a, b );
PROFILEMAN->AddStepsHighScore( st.pSong, GAMESTATE->m_pCurNotes[p], (PlayerNumber)p, hs, a, b );
PROFILEMAN->AddStepsHighScore( st.pSong, GAMESTATE->m_pCurNotes[p], (PlayerNumber)p, hs, a, b );
PROFILEMAN->AddStepsHighScore( st.pSong, GAMESTATE->m_pCurNotes[p], (PlayerNumber)p, hs, a, b );
PROFILEMAN->AddCategoryHighScore( nt, RANKING_A, (PlayerNumber)p, hs, a, b );
PROFILEMAN->AddStepsScore( st.pSong, GAMESTATE->m_pCurNotes[p], (PlayerNumber)p, hs, a, b );
PROFILEMAN->AddStepsScore( st.pSong, GAMESTATE->m_pCurNotes[p], (PlayerNumber)p, hs, a, b );
PROFILEMAN->AddStepsScore( st.pSong, GAMESTATE->m_pCurNotes[p], (PlayerNumber)p, hs, a, b );
PROFILEMAN->AddStepsScore( st.pSong, GAMESTATE->m_pCurNotes[p], (PlayerNumber)p, hs, a, b );
PROFILEMAN->AddStepsScore( st.pSong, GAMESTATE->m_pCurNotes[p], (PlayerNumber)p, hs, a, b );
PROFILEMAN->AddCategoryScore( nt, RANKING_A, (PlayerNumber)p, hs, a, b );
}
g_vPlayedStageStats.push_back( st );