don't throw away Course scores for Courses that aren't currently loaded on the machine
This commit is contained in:
@@ -185,10 +185,18 @@ void CourseID::FromCourse( const Course *p )
|
|||||||
{
|
{
|
||||||
if( p )
|
if( p )
|
||||||
{
|
{
|
||||||
sPath = p->m_sPath;
|
if( p->m_bIsAutogen )
|
||||||
|
{
|
||||||
|
sPath = "";
|
||||||
sName = p->m_sName;
|
sName = p->m_sName;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
sPath = p->m_sPath;
|
||||||
|
sName = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
sPath = "";
|
sPath = "";
|
||||||
sName = "";
|
sName = "";
|
||||||
@@ -205,3 +213,27 @@ Course *CourseID::ToCourse() const
|
|||||||
return pCourse;
|
return pCourse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
XNode* CourseID::CreateNode() const
|
||||||
|
{
|
||||||
|
XNode* pNode = new XNode;
|
||||||
|
pNode->name = "Course";
|
||||||
|
|
||||||
|
if( !sPath.empty() )
|
||||||
|
pNode->AppendAttr( "Path", sPath );
|
||||||
|
if( !sName.empty() )
|
||||||
|
pNode->AppendAttr( "Name", sName );
|
||||||
|
|
||||||
|
return pNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CourseID::LoadFromNode( const XNode* pNode )
|
||||||
|
{
|
||||||
|
ASSERT( pNode->name == "Course" );
|
||||||
|
pNode->GetAttrValue("Path", sPath);
|
||||||
|
pNode->GetAttrValue("Name", sName);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CourseID::IsValid() const
|
||||||
|
{
|
||||||
|
return !sPath.empty() || !sName.empty();
|
||||||
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
class Course;
|
class Course;
|
||||||
class Profile;
|
class Profile;
|
||||||
|
struct XNode;
|
||||||
|
|
||||||
namespace CourseUtil
|
namespace CourseUtil
|
||||||
{
|
{
|
||||||
@@ -38,6 +39,14 @@ public:
|
|||||||
CourseID() { FromCourse(NULL); }
|
CourseID() { FromCourse(NULL); }
|
||||||
void FromCourse( const Course *p );
|
void FromCourse( const Course *p );
|
||||||
Course *ToCourse() const;
|
Course *ToCourse() const;
|
||||||
|
bool operator<( const CourseID &other ) const
|
||||||
|
{
|
||||||
|
return sPath < other.sPath || sName < other.sName;
|
||||||
|
}
|
||||||
|
|
||||||
|
XNode* CreateNode() const;
|
||||||
|
void LoadFromNode( const XNode* pNode );
|
||||||
|
bool IsValid() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+45
-34
@@ -235,18 +235,23 @@ int Profile::GetTotalHighScoreDancePointsForStepsType( StepsType st ) const
|
|||||||
|
|
||||||
// add course high scores
|
// add course high scores
|
||||||
{
|
{
|
||||||
for( std::map<const Course*,HighScoresForACourse>::const_iterator iter = m_CourseHighScores.begin();
|
for( std::map<CourseID,HighScoresForACourse>::const_iterator i = m_CourseHighScores.begin();
|
||||||
iter != m_CourseHighScores.end();
|
i != m_CourseHighScores.end();
|
||||||
iter++ )
|
i++ )
|
||||||
{
|
{
|
||||||
const Course* pCourse = iter->first;
|
CourseID id = i->first;
|
||||||
ASSERT( pCourse );
|
const Course* pCourse = id.ToCourse();
|
||||||
|
|
||||||
|
// If the Course isn't loaded on the current machine, then we can't
|
||||||
|
// get radar values to compute dance points.
|
||||||
|
if( pCourse == NULL )
|
||||||
|
continue;
|
||||||
|
|
||||||
// Don't count any course that has any entries that change over time.
|
// Don't count any course that has any entries that change over time.
|
||||||
if( !pCourse->AllSongsAreFixed() )
|
if( !pCourse->AllSongsAreFixed() )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const HighScoresForACourse& h = iter->second;
|
const HighScoresForACourse& h = i->second;
|
||||||
FOREACH_CourseDifficulty( cd )
|
FOREACH_CourseDifficulty( cd )
|
||||||
{
|
{
|
||||||
const HighScoreList& hs = h.hs[st][cd];
|
const HighScoreList& hs = h.hs[st][cd];
|
||||||
@@ -336,30 +341,44 @@ void Profile::IncrementStepsPlayCount( const Song* pSong, const Steps* pSteps )
|
|||||||
//
|
//
|
||||||
void Profile::AddCourseHighScore( const Course* pCourse, StepsType st, CourseDifficulty cd, HighScore hs, int &iIndexOut )
|
void Profile::AddCourseHighScore( const Course* pCourse, StepsType st, CourseDifficulty cd, HighScore hs, int &iIndexOut )
|
||||||
{
|
{
|
||||||
std::map<const Course*,HighScoresForACourse>::iterator iter = m_CourseHighScores.find( pCourse );
|
CourseID courseID;
|
||||||
|
courseID.FromCourse( pCourse );
|
||||||
|
|
||||||
|
std::map<CourseID,HighScoresForACourse>::iterator iter = m_CourseHighScores.find( courseID );
|
||||||
if( iter == m_CourseHighScores.end() )
|
if( iter == m_CourseHighScores.end() )
|
||||||
m_CourseHighScores[pCourse].hs[st][cd].AddHighScore( hs, iIndexOut ); // operator[] inserts into map
|
m_CourseHighScores[courseID].hs[st][cd].AddHighScore( hs, iIndexOut ); // operator[] inserts into map
|
||||||
else
|
else
|
||||||
iter->second.hs[st][cd].AddHighScore( hs, iIndexOut );
|
iter->second.hs[st][cd].AddHighScore( hs, iIndexOut );
|
||||||
}
|
}
|
||||||
|
|
||||||
const HighScoreList& Profile::GetCourseHighScoreList( const Course* pCourse, StepsType st, CourseDifficulty cd ) const
|
const HighScoreList& Profile::GetCourseHighScoreList( const Course* pCourse, StepsType st, CourseDifficulty cd ) const
|
||||||
{
|
{
|
||||||
return ((Profile *)this)->m_CourseHighScores[pCourse].hs[st][cd];
|
return ((Profile *)this)->GetCourseHighScoreList( pCourse, st, cd );
|
||||||
}
|
}
|
||||||
|
|
||||||
HighScoreList& Profile::GetCourseHighScoreList( const Course* pCourse, StepsType st, CourseDifficulty cd )
|
HighScoreList& Profile::GetCourseHighScoreList( const Course* pCourse, StepsType st, CourseDifficulty cd )
|
||||||
{
|
{
|
||||||
std::map<const Course*,HighScoresForACourse>::iterator iter = m_CourseHighScores.find( pCourse );
|
CourseID courseID;
|
||||||
|
courseID.FromCourse( pCourse );
|
||||||
|
|
||||||
|
std::map<CourseID,HighScoresForACourse>::iterator iter = m_CourseHighScores.find( courseID );
|
||||||
if( iter == m_CourseHighScores.end() )
|
if( iter == m_CourseHighScores.end() )
|
||||||
return m_CourseHighScores[pCourse].hs[st][cd]; // operator[] inserts into map
|
return m_CourseHighScores[courseID].hs[st][cd]; // operator[] inserts into map
|
||||||
else
|
else
|
||||||
return iter->second.hs[st][cd];
|
return iter->second.hs[st][cd];
|
||||||
}
|
}
|
||||||
|
|
||||||
int Profile::GetCourseNumTimesPlayed( const Course* pCourse ) const
|
int Profile::GetCourseNumTimesPlayed( const Course* pCourse ) const
|
||||||
{
|
{
|
||||||
std::map<const Course*,HighScoresForACourse>::const_iterator iter = m_CourseHighScores.find( pCourse );
|
CourseID courseID;
|
||||||
|
courseID.FromCourse( pCourse );
|
||||||
|
|
||||||
|
return GetCourseNumTimesPlayed( courseID );
|
||||||
|
}
|
||||||
|
|
||||||
|
int Profile::GetCourseNumTimesPlayed( const CourseID &courseID ) const
|
||||||
|
{
|
||||||
|
std::map<CourseID,HighScoresForACourse>::const_iterator iter = m_CourseHighScores.find( courseID );
|
||||||
if( iter == m_CourseHighScores.end() )
|
if( iter == m_CourseHighScores.end() )
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
@@ -1275,19 +1294,19 @@ XNode* Profile::SaveCourseScoresCreateNode() const
|
|||||||
XNode* pNode = new XNode;
|
XNode* pNode = new XNode;
|
||||||
pNode->name = "CourseScores";
|
pNode->name = "CourseScores";
|
||||||
|
|
||||||
vector<Course*> vpCourses;
|
|
||||||
SONGMAN->GetAllCourses( vpCourses, true );
|
|
||||||
|
|
||||||
for( unsigned c=0; c<vpCourses.size(); c++ ) // foreach course
|
for( std::map<CourseID,HighScoresForACourse>::const_iterator i = m_CourseHighScores.begin();
|
||||||
|
i != m_CourseHighScores.end();
|
||||||
|
i++ )
|
||||||
{
|
{
|
||||||
Course *pCourse = vpCourses[c];
|
const CourseID &id = i->first;
|
||||||
|
const HighScoresForACourse &hsCourse = i->second;
|
||||||
|
|
||||||
// skip courses that have never been played
|
// skip courses that have never been played
|
||||||
if( pProfile->GetCourseNumTimesPlayed(pCourse) == 0 )
|
if( pProfile->GetCourseNumTimesPlayed(id) == 0 )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
XNode* pCourseNode = pNode->AppendChild( "Course" );
|
XNode* pCourseNode = pNode->AppendChild( id.CreateNode() );
|
||||||
pCourseNode->AppendAttr( "Name", pCourse->m_bIsAutogen ? pCourse->m_sName : pCourse->m_sPath );
|
|
||||||
|
|
||||||
for( StepsType st=(StepsType)0; st<NUM_STEPS_TYPES; ((int&)st)++ )
|
for( StepsType st=(StepsType)0; st<NUM_STEPS_TYPES; ((int&)st)++ )
|
||||||
{
|
{
|
||||||
@@ -1299,15 +1318,15 @@ XNode* Profile::SaveCourseScoresCreateNode() const
|
|||||||
|
|
||||||
FOREACH_CourseDifficulty( cd )
|
FOREACH_CourseDifficulty( cd )
|
||||||
{
|
{
|
||||||
|
const HighScoreList &hsl = hsCourse.hs[st][cd];
|
||||||
|
|
||||||
// skip course/steps types that have never been played
|
// skip course/steps types that have never been played
|
||||||
if( pProfile->GetCourseHighScoreList(pCourse, st, cd).iNumTimesPlayed == 0 )
|
if( hsl.iNumTimesPlayed == 0 )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
LPXNode pCourseDifficultyNode = pStepsTypeNode->AppendChild( "CourseDifficulty" );
|
LPXNode pCourseDifficultyNode = pStepsTypeNode->AppendChild( "CourseDifficulty" );
|
||||||
pCourseDifficultyNode->AppendAttr( "Type", CourseDifficultyToString(cd) );
|
pCourseDifficultyNode->AppendAttr( "Type", CourseDifficultyToString(cd) );
|
||||||
|
|
||||||
const HighScoreList &hsl = pProfile->GetCourseHighScoreList( pCourse, st, cd );
|
|
||||||
|
|
||||||
pCourseDifficultyNode->AppendChild( hsl.CreateNode() );
|
pCourseDifficultyNode->AppendChild( hsl.CreateNode() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1332,19 +1351,11 @@ void Profile::LoadCourseScoresFromNode( const XNode* pNode )
|
|||||||
if( (*course)->name != "Course" )
|
if( (*course)->name != "Course" )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
CString sCourse;
|
CourseID id;
|
||||||
if( !(*course)->GetAttrValue( "Name", sCourse ) )
|
id.LoadFromNode( *course );
|
||||||
|
if( !id.IsValid() )
|
||||||
WARN_AND_CONTINUE;
|
WARN_AND_CONTINUE;
|
||||||
|
|
||||||
Course* pCourse = SONGMAN->GetCourseFromPath( sCourse );
|
|
||||||
if( pCourse == NULL )
|
|
||||||
pCourse = SONGMAN->GetCourseFromName( sCourse );
|
|
||||||
if( pCourse == NULL )
|
|
||||||
{
|
|
||||||
LOG->Trace("Couldn't find course \"%s\"; scoring data will be lost", sCourse.c_str() );
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
for( XNodes::iterator stepsType = (*course)->childs.begin();
|
for( XNodes::iterator stepsType = (*course)->childs.begin();
|
||||||
stepsType != (*course)->childs.end();
|
stepsType != (*course)->childs.end();
|
||||||
stepsType++ )
|
stepsType++ )
|
||||||
@@ -1375,7 +1386,7 @@ void Profile::LoadCourseScoresFromNode( const XNode* pNode )
|
|||||||
if( pHighScoreListNode == NULL )
|
if( pHighScoreListNode == NULL )
|
||||||
WARN_AND_CONTINUE;
|
WARN_AND_CONTINUE;
|
||||||
|
|
||||||
HighScoreList &hsl = this->GetCourseHighScoreList( pCourse, st, cd );
|
HighScoreList &hsl = m_CourseHighScores[id].hs[st][cd];
|
||||||
hsl.LoadFromNode( pHighScoreListNode );
|
hsl.LoadFromNode( pHighScoreListNode );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
#include "TimeConstants.h"
|
#include "TimeConstants.h"
|
||||||
#include "SongUtil.h" // for SongID
|
#include "SongUtil.h" // for SongID
|
||||||
#include "StepsUtil.h" // for StepsID
|
#include "StepsUtil.h" // for StepsID
|
||||||
|
#include "CourseUtil.h" // for CourseID
|
||||||
|
|
||||||
//
|
//
|
||||||
// Current file versions
|
// Current file versions
|
||||||
@@ -148,12 +148,13 @@ public:
|
|||||||
{
|
{
|
||||||
HighScoreList hs[NUM_STEPS_TYPES][NUM_COURSE_DIFFICULTIES];
|
HighScoreList hs[NUM_STEPS_TYPES][NUM_COURSE_DIFFICULTIES];
|
||||||
};
|
};
|
||||||
std::map<const Course*,HighScoresForACourse> m_CourseHighScores;
|
std::map<CourseID,HighScoresForACourse> m_CourseHighScores;
|
||||||
|
|
||||||
void AddCourseHighScore( const Course* pCourse, StepsType st, CourseDifficulty cd, HighScore hs, int &iIndexOut );
|
void AddCourseHighScore( const Course* pCourse, StepsType st, CourseDifficulty cd, HighScore hs, int &iIndexOut );
|
||||||
HighScoreList& GetCourseHighScoreList( const Course* pCourse, StepsType st, CourseDifficulty cd );
|
HighScoreList& GetCourseHighScoreList( const Course* pCourse, StepsType st, CourseDifficulty cd );
|
||||||
const HighScoreList& GetCourseHighScoreList( const Course* pCourse, StepsType st, CourseDifficulty cd ) const;
|
const HighScoreList& GetCourseHighScoreList( const Course* pCourse, StepsType st, CourseDifficulty cd ) const;
|
||||||
int GetCourseNumTimesPlayed( const Course* pCourse ) const;
|
int GetCourseNumTimesPlayed( const Course* pCourse ) const;
|
||||||
|
int GetCourseNumTimesPlayed( const CourseID& courseID ) const;
|
||||||
void IncrementCoursePlayCount( const Course* pCourse, StepsType st, CourseDifficulty cd );
|
void IncrementCoursePlayCount( const Course* pCourse, StepsType st, CourseDifficulty cd );
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -80,6 +80,8 @@ void ReceptorArrow::DrawPrimitives()
|
|||||||
|
|
||||||
void ReceptorArrow::Step()
|
void ReceptorArrow::Step()
|
||||||
{
|
{
|
||||||
|
m_pReceptorGo->FinishTweening();
|
||||||
|
m_pReceptorWaiting->FinishTweening();
|
||||||
m_pReceptorGo->Command( m_sStepCommand );
|
m_pReceptorGo->Command( m_sStepCommand );
|
||||||
m_pReceptorWaiting->Command( m_sStepCommand );
|
m_pReceptorWaiting->Command( m_sStepCommand );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -369,7 +369,6 @@ Song *SongID::ToSong() const
|
|||||||
return SONGMAN->GetSongFromDir( sDir );
|
return SONGMAN->GetSongFromDir( sDir );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
XNode* SongID::CreateNode() const
|
XNode* SongID::CreateNode() const
|
||||||
{
|
{
|
||||||
XNode* pNode = new XNode;
|
XNode* pNode = new XNode;
|
||||||
|
|||||||
@@ -49,7 +49,6 @@ public:
|
|||||||
|
|
||||||
XNode* CreateNode() const;
|
XNode* CreateNode() const;
|
||||||
void LoadFromNode( const XNode* pNode );
|
void LoadFromNode( const XNode* pNode );
|
||||||
|
|
||||||
bool IsValid() const;
|
bool IsValid() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,6 @@ public:
|
|||||||
|
|
||||||
XNode* CreateNode() const;
|
XNode* CreateNode() const;
|
||||||
void LoadFromNode( const XNode* pNode );
|
void LoadFromNode( const XNode* pNode );
|
||||||
|
|
||||||
bool IsValid() const;
|
bool IsValid() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user