Split score reading into separate functions.
Type fixes.
This commit is contained in:
+105
-95
@@ -237,97 +237,20 @@ void SongManager::ReloadSongArray()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SongManager::ReadNoteScoresFromFile( CString fn, int c )
|
||||||
void SongManager::InitMachineScoresFromDisk()
|
|
||||||
{
|
{
|
||||||
|
ifstream f(fn);
|
||||||
// Init category ranking
|
if( !f.good() )
|
||||||
{
|
return;
|
||||||
for( int i=0; i<NUM_NOTES_TYPES; i++ )
|
|
||||||
for( int j=0; j<NUM_RANKING_CATEGORIES; j++ )
|
|
||||||
for( int k=0; k<NUM_RANKING_LINES; k++ )
|
|
||||||
{
|
|
||||||
m_MachineScores[i][j][k].iScore = 573000;
|
|
||||||
m_MachineScores[i][j][k].sName = DEFAULT_RANKING_NAME;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// category ranking
|
|
||||||
{
|
|
||||||
FILE* fp = fopen( CATEGORY_RANKING_FILE, "r" );
|
|
||||||
if( fp )
|
|
||||||
{
|
|
||||||
int version;
|
|
||||||
fscanf(fp, "%d\n", &version );
|
|
||||||
if( version == CATEGORY_RANKING_VERSION )
|
|
||||||
{
|
|
||||||
for( int i=0; i<NUM_NOTES_TYPES; i++ )
|
|
||||||
for( int j=0; j<NUM_RANKING_CATEGORIES; j++ )
|
|
||||||
for( int k=0; k<NUM_RANKING_LINES; k++ )
|
|
||||||
if( fp && !feof(fp) )
|
|
||||||
{
|
|
||||||
char szName[256];
|
|
||||||
fscanf(fp, "%f %[^\n]\n", &m_MachineScores[i][j][k].iScore, szName);
|
|
||||||
m_MachineScores[i][j][k].sName = szName;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fclose(fp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// course ranking
|
|
||||||
{
|
|
||||||
FILE* fp = fopen( COURSE_RANKING_FILE, "r" );
|
|
||||||
|
|
||||||
if( fp )
|
|
||||||
{
|
|
||||||
int version;
|
|
||||||
fscanf(fp, "%i\n", &version );
|
|
||||||
if( version == COURSE_RANKING_VERSION )
|
|
||||||
{
|
|
||||||
while( fp && !feof(fp) )
|
|
||||||
{
|
|
||||||
char szPath[256];
|
|
||||||
fscanf(fp, "%s\n", szPath);
|
|
||||||
Course* pCourse = GetCourseFromPath( szPath );
|
|
||||||
if( pCourse == NULL )
|
|
||||||
pCourse = GetCourseFromName( szPath );
|
|
||||||
|
|
||||||
for( int i=0; i<NUM_NOTES_TYPES; i++ )
|
|
||||||
for( int j=0; j<NUM_RANKING_LINES; j++ )
|
|
||||||
if( fp && !feof(fp) )
|
|
||||||
{
|
|
||||||
int iDancePoints;
|
|
||||||
float fSurviveTime;
|
|
||||||
char szName[256];
|
|
||||||
fscanf(fp, "%d %f %[^\n]\n", &iDancePoints, &fSurviveTime, szName);
|
|
||||||
if( pCourse )
|
|
||||||
{
|
|
||||||
pCourse->m_RankingScores[i][j].iDancePoints = iDancePoints;
|
|
||||||
pCourse->m_RankingScores[i][j].fSurviveTime = fSurviveTime;
|
|
||||||
pCourse->m_RankingScores[i][j].sName = szName;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fclose(fp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// notes scores
|
|
||||||
for( int c=0; c<NUM_MEMORY_CARDS; c++ )
|
|
||||||
{
|
|
||||||
ifstream f(NOTES_SCORES_FILE[c]);
|
|
||||||
if( f.good() )
|
|
||||||
{
|
|
||||||
CString line;
|
CString line;
|
||||||
|
|
||||||
getline(f, line);
|
getline(f, line);
|
||||||
int version;
|
int version;
|
||||||
sscanf(line.c_str(), "%i", &version);
|
sscanf(line.c_str(), "%i", &version);
|
||||||
|
|
||||||
if( version == NOTES_SCORES_VERSION )
|
if( version != NOTES_SCORES_VERSION )
|
||||||
{
|
return;
|
||||||
|
|
||||||
while( f && !f.eof() )
|
while( f && !f.eof() )
|
||||||
{
|
{
|
||||||
CString sSongDir;
|
CString sSongDir;
|
||||||
@@ -375,20 +298,18 @@ void SongManager::InitMachineScoresFromDisk()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// course scores
|
void SongManager::ReadCourseScoresFromFile( CString fn, int c )
|
||||||
{
|
{
|
||||||
for( int c=0; c<NUM_MEMORY_CARDS; c++ )
|
FILE* fp = fopen( fn, "r" );
|
||||||
{
|
|
||||||
FILE* fp = fopen( COURSE_SCORES_FILE[c], "r" );
|
if( !fp )
|
||||||
|
return;
|
||||||
|
|
||||||
if( fp )
|
|
||||||
{
|
|
||||||
int version;
|
int version;
|
||||||
fscanf(fp, "%d\n", &version );
|
fscanf(fp, "%d\n", &version );
|
||||||
|
|
||||||
if( version == COURSE_SCORES_VERSION )
|
if( version == COURSE_SCORES_VERSION )
|
||||||
{
|
{
|
||||||
while( fp && !feof(fp) )
|
while( fp && !feof(fp) )
|
||||||
@@ -400,7 +321,7 @@ void SongManager::InitMachineScoresFromDisk()
|
|||||||
pCourse = GetCourseFromName( szPath );
|
pCourse = GetCourseFromName( szPath );
|
||||||
|
|
||||||
for( int i=0; i<NUM_NOTES_TYPES; i++ )
|
for( int i=0; i<NUM_NOTES_TYPES; i++ )
|
||||||
if( fp && !feof(fp) )
|
if( !feof(fp) )
|
||||||
{
|
{
|
||||||
int iNumTimesPlayed;
|
int iNumTimesPlayed;
|
||||||
int iDancePoints;
|
int iDancePoints;
|
||||||
@@ -415,10 +336,99 @@ void SongManager::InitMachineScoresFromDisk()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SongManager::ReadCategoryRankingsFromFile( CString fn )
|
||||||
|
{
|
||||||
|
FILE* fp = fopen( fn, "r" );
|
||||||
|
if( !fp )
|
||||||
|
return;
|
||||||
|
|
||||||
|
int version;
|
||||||
|
fscanf(fp, "%d\n", &version );
|
||||||
|
if( version == CATEGORY_RANKING_VERSION )
|
||||||
|
{
|
||||||
|
for( int i=0; i<NUM_NOTES_TYPES; i++ )
|
||||||
|
for( int j=0; j<NUM_RANKING_CATEGORIES; j++ )
|
||||||
|
for( int k=0; k<NUM_RANKING_LINES; k++ )
|
||||||
|
if( !feof(fp) )
|
||||||
|
{
|
||||||
|
char szName[256];
|
||||||
|
fscanf(fp, "%i %[^\n]\n", &m_MachineScores[i][j][k].iScore, szName);
|
||||||
|
m_MachineScores[i][j][k].sName = szName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fclose(fp);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SongManager::ReadCourseRankingsFromFile( CString fn )
|
||||||
|
{
|
||||||
|
FILE* fp = fopen( fn, "r" );
|
||||||
|
|
||||||
|
if( !fp )
|
||||||
|
return;
|
||||||
|
int version;
|
||||||
|
fscanf(fp, "%i\n", &version );
|
||||||
|
if( version == COURSE_RANKING_VERSION )
|
||||||
|
{
|
||||||
|
while( fp && !feof(fp) )
|
||||||
|
{
|
||||||
|
char szPath[256];
|
||||||
|
fscanf(fp, "%[^\n]\n", szPath);
|
||||||
|
Course* pCourse = GetCourseFromPath( szPath );
|
||||||
|
if( pCourse == NULL )
|
||||||
|
pCourse = GetCourseFromName( szPath );
|
||||||
|
|
||||||
|
for( int i=0; i<NUM_NOTES_TYPES; i++ )
|
||||||
|
for( int j=0; j<NUM_RANKING_LINES; j++ )
|
||||||
|
if( !feof(fp) )
|
||||||
|
{
|
||||||
|
int iDancePoints;
|
||||||
|
float fSurviveTime;
|
||||||
|
char szName[256];
|
||||||
|
fscanf(fp, "%d %f %[^\n]\n", &iDancePoints, &fSurviveTime, szName);
|
||||||
|
if( pCourse )
|
||||||
|
{
|
||||||
|
pCourse->m_RankingScores[i][j].iDancePoints = iDancePoints;
|
||||||
|
pCourse->m_RankingScores[i][j].fSurviveTime = fSurviveTime;
|
||||||
|
pCourse->m_RankingScores[i][j].sName = szName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose(fp);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SongManager::InitMachineScoresFromDisk()
|
||||||
|
{
|
||||||
|
|
||||||
|
// Init category ranking
|
||||||
|
{
|
||||||
|
for( int i=0; i<NUM_NOTES_TYPES; i++ )
|
||||||
|
for( int j=0; j<NUM_RANKING_CATEGORIES; j++ )
|
||||||
|
for( int k=0; k<NUM_RANKING_LINES; k++ )
|
||||||
|
{
|
||||||
|
m_MachineScores[i][j][k].iScore = 573000;
|
||||||
|
m_MachineScores[i][j][k].sName = DEFAULT_RANKING_NAME;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// category ranking
|
||||||
|
ReadCategoryRankingsFromFile( CATEGORY_RANKING_FILE );
|
||||||
|
|
||||||
|
// course ranking
|
||||||
|
ReadCourseRankingsFromFile( COURSE_RANKING_FILE );
|
||||||
|
|
||||||
|
// notes scores
|
||||||
|
for( int c=0; c<NUM_MEMORY_CARDS; c++ )
|
||||||
|
ReadNoteScoresFromFile( NOTES_SCORES_FILE[c], c );
|
||||||
|
|
||||||
|
// course scores
|
||||||
|
for( int c=0; c<NUM_MEMORY_CARDS; c++ )
|
||||||
|
ReadCourseScoresFromFile( COURSE_SCORES_FILE[c], c );
|
||||||
}
|
}
|
||||||
|
|
||||||
void SongManager::SaveMachineScoresToDisk()
|
void SongManager::SaveMachineScoresToDisk()
|
||||||
|
|||||||
@@ -105,6 +105,11 @@ protected:
|
|||||||
void SanityCheckGroupDir( CString sDir ) const;
|
void SanityCheckGroupDir( CString sDir ) const;
|
||||||
void AddGroup( CString sDir, CString sGroupDirName );
|
void AddGroup( CString sDir, CString sGroupDirName );
|
||||||
|
|
||||||
|
void ReadNoteScoresFromFile( CString fn, int c );
|
||||||
|
void ReadCourseScoresFromFile( CString fn, int c );
|
||||||
|
void ReadCategoryRankingsFromFile( CString fn );
|
||||||
|
void ReadCourseRankingsFromFile( CString fn );
|
||||||
|
|
||||||
vector<Song*> m_pSongs; // all songs that can be played
|
vector<Song*> m_pSongs; // all songs that can be played
|
||||||
CStringArray m_arrayGroupNames;
|
CStringArray m_arrayGroupNames;
|
||||||
CStringArray m_GroupBannerPaths; // each song group has a banner associated with it
|
CStringArray m_GroupBannerPaths; // each song group has a banner associated with it
|
||||||
|
|||||||
Reference in New Issue
Block a user