Skip to content

Commit

Permalink
load ett save format if possible otherwise fallback onto stats.xml
Browse files Browse the repository at this point in the history
  • Loading branch information
MinaciousGrace committed Apr 26, 2017
1 parent b5ae71c commit 4f3ed7d
Showing 1 changed file with 44 additions and 42 deletions.
86 changes: 44 additions & 42 deletions src/Profile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1153,6 +1153,8 @@ ProfileLoadResult Profile::LoadAllFromDir( const RString &sDir, bool bRequireSig
LoadEditableDataFromDir( sDir );

ProfileLoadResult ret= LoadEttFromDir(sDir, bRequireSignature);
if (ret != ProfileLoadResult_Success)
ret = LoadStatsFromDir(sDir, bRequireSignature);
if (ret != ProfileLoadResult_Success)
return ret;

Expand Down Expand Up @@ -2095,48 +2097,48 @@ float Profile::CalculateCaloriesFromHeartRate(float HeartRate, float Duration)
/ 4.184f) * Duration;
}

XNode* Profile::SaveSongScoresCreateNode() const
{
CHECKPOINT_M("Getting the node to save song scores.");

const Profile* pProfile = this;
ASSERT(pProfile != NULL);

XNode* pNode = new XNode("SongScores");

FOREACHM_CONST(SongID, HighScoresForASong, m_SongHighScores, i)
{
const SongID &songID = i->first;
const HighScoresForASong &hsSong = i->second;

// skip songs that have never been played
if (pProfile->GetSongNumTimesPlayed(songID) == 0)
continue;

XNode* pSongNode = pNode->AppendChild(songID.CreateNode());

int jCheck2 = hsSong.m_StepsHighScores.size();
int jCheck1 = 0;
FOREACHM_CONST(StepsID, HighScoresForASteps, hsSong.m_StepsHighScores, j)
{
jCheck1++;
ASSERT(jCheck1 <= jCheck2);
const StepsID &stepsID = j->first;
const HighScoresForASteps &hsSteps = j->second;

const HighScoreList &hsl = hsSteps.hsl;

// skip steps that have never been played
if (hsl.GetNumTimesPlayed() == 0)
continue;

XNode* pStepsNode = pSongNode->AppendChild(stepsID.CreateNode());

pStepsNode->AppendChild(hsl.CreateNode());
}
}

return pNode;
XNode* Profile::SaveSongScoresCreateNode() const
{
CHECKPOINT_M("Getting the node to save song scores.");

const Profile* pProfile = this;
ASSERT(pProfile != NULL);

XNode* pNode = new XNode("SongScores");

FOREACHM_CONST(SongID, HighScoresForASong, m_SongHighScores, i)
{
const SongID &songID = i->first;
const HighScoresForASong &hsSong = i->second;

// skip songs that have never been played
if (pProfile->GetSongNumTimesPlayed(songID) == 0)
continue;

XNode* pSongNode = pNode->AppendChild(songID.CreateNode());

int jCheck2 = hsSong.m_StepsHighScores.size();
int jCheck1 = 0;
FOREACHM_CONST(StepsID, HighScoresForASteps, hsSong.m_StepsHighScores, j)
{
jCheck1++;
ASSERT(jCheck1 <= jCheck2);
const StepsID &stepsID = j->first;
const HighScoresForASteps &hsSteps = j->second;

const HighScoreList &hsl = hsSteps.hsl;

// skip steps that have never been played
if (hsl.GetNumTimesPlayed() == 0)
continue;

XNode* pStepsNode = pSongNode->AppendChild(stepsID.CreateNode());

pStepsNode->AppendChild(hsl.CreateNode());
}
}

return pNode;
}

XNode* Profile::SaveEttScoresCreateNode() const
Expand Down

0 comments on commit 4f3ed7d

Please sign in to comment.