Fix the previous number of points being 0 after relaunching STK (#3320)

* On launch, also update the number of previous points so it is not 0

* Do the first call after the loading of the challenges status

* Remove prints
This commit is contained in:
Alayan-stk-2 2018-06-20 02:20:21 +02:00 committed by auriamg
parent 5d34488adc
commit 750320fbeb
3 changed files with 8 additions and 7 deletions

View File

@ -45,7 +45,6 @@ StoryModeStatus::StoryModeStatus(const XMLNode *node)
{
node->get("first-time", &m_first_time);
} // if node
} // StoryModeStatus
//-----------------------------------------------------------------------------
@ -78,7 +77,7 @@ bool StoryModeStatus::isLocked(const std::string& feature)
} // featureIsLocked
//-----------------------------------------------------------------------------
void StoryModeStatus::computeActive()
void StoryModeStatus::computeActive(bool first_call)
{
int old_points = m_points;
m_points = 0;
@ -98,8 +97,8 @@ void StoryModeStatus::computeActive()
// -----------------
if((i->second)->isSolvedAtAnyDifficulty())
{
// The constructor calls computeActive, which actually locks
// all features, so unlock the solved ones (and don't try to
// computeActive is called in createStoryModeStatus, which actually
// locks all features, so unlock the solved ones (and don't try to
// save the state, since we are currently reading it)
if (i->second->isSolved(RaceManager::DIFFICULTY_EASY))
@ -184,8 +183,10 @@ void StoryModeStatus::computeActive()
// now we have the number of points.
// Update the previous number of points
// On game launch, set it to the number of points the player has
if (old_points != m_points)
m_points_before = old_points;
m_points_before = (first_call) ? m_points : old_points;
unlockFeatureByList();

View File

@ -78,7 +78,7 @@ public:
StoryModeStatus(const XMLNode *node=NULL);
~StoryModeStatus();
void computeActive();
void computeActive (bool first_call=false);
bool isLocked (const std::string& feature);
void unlockFeatureByList();
void lockFeature (ChallengeStatus *challenge);

View File

@ -222,7 +222,7 @@ StoryModeStatus* UnlockManager::createStoryModeStatus(const XMLNode *node)
status->addStatus(challenge_status);
}
status->computeActive();
status->computeActive(/* first call*/ true);
return status;
} // createStoryModeStatus