X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;ds=inline;f=Source%2FUser%2FAccount.cpp;h=bfc621e080c6692160ae1727566a0eac58a541a7;hb=6c2be7b3030442d0ffda2d712ef2159283de2f22;hp=52f863e34c7a6ba491f3530b5adce1a0042011d2;hpb=8b6e8f3ad7390309795eb35c0959264cb7924402;p=lugaru.git
diff --git a/Source/User/Account.cpp b/Source/User/Account.cpp
index 52f863e..bfc621e 100644
--- a/Source/User/Account.cpp
+++ b/Source/User/Account.cpp
@@ -1,6 +1,6 @@
/*
Copyright (C) 2003, 2010 - Wolfire Games
-Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
+Copyright (C) 2010-2017 - Lugaru contributors (see AUTHORS file)
This file is part of Lugaru.
@@ -20,7 +20,7 @@ along with Lugaru. If not, see .
#include "User/Account.hpp"
-#include "MacCompatibility.hpp"
+#include "Platform/Platform.hpp"
#include "Utils/binio.h"
#include
@@ -65,10 +65,13 @@ Account::Account(FILE* tfile)
funpackf(tfile, "Bb", &c);
campaignName.append(1, c);
}
+ float fscore, fhighscore;
funpackf(tfile, "Bf", &(campaignProgress[campaignName].time));
- funpackf(tfile, "Bf", &(campaignProgress[campaignName].score));
+ funpackf(tfile, "Bf", &(fscore));
funpackf(tfile, "Bf", &(campaignProgress[campaignName].fasttime));
- funpackf(tfile, "Bf", &(campaignProgress[campaignName].highscore));
+ funpackf(tfile, "Bf", &(fhighscore));
+ campaignProgress[campaignName].score = fscore;
+ campaignProgress[campaignName].highscore = fhighscore;
int campaignchoicesmade, campaignchoice;
funpackf(tfile, "Bi", &campaignchoicesmade);
for (int j = 0; j < campaignchoicesmade; j++) {
@@ -91,8 +94,10 @@ Account::Account(FILE* tfile)
funpackf(tfile, "Bf", &points);
for (int i = 0; i < 50; i++) {
- funpackf(tfile, "Bf", &(highscore[i]));
+ float fscore;
+ funpackf(tfile, "Bf", &(fscore));
funpackf(tfile, "Bf", &(fasttime[i]));
+ highscore[i] = fscore;
}
for (int i = 0; i < 60; i++) {
funpackf(tfile, "Bb", &(unlocked[i]));
@@ -122,9 +127,9 @@ void Account::save(FILE* tfile)
fpackf(tfile, "Bb", it->first[j]);
}
fpackf(tfile, "Bf", it->second.time);
- fpackf(tfile, "Bf", it->second.score);
+ fpackf(tfile, "Bf", float(it->second.score));
fpackf(tfile, "Bf", it->second.fasttime);
- fpackf(tfile, "Bf", it->second.highscore);
+ fpackf(tfile, "Bf", float(it->second.highscore));
fpackf(tfile, "Bi", it->second.choices.size());
for (unsigned j = 0; j < it->second.choices.size(); j++) {
fpackf(tfile, "Bi", it->second.choices[j]);
@@ -138,7 +143,7 @@ void Account::save(FILE* tfile)
fpackf(tfile, "Bf", points);
for (unsigned j = 0; j < 50; j++) {
- fpackf(tfile, "Bf", highscore[j]);
+ fpackf(tfile, "Bf", float(highscore[j]));
fpackf(tfile, "Bf", fasttime[j]);
}
for (unsigned j = 0; j < 60; j++) {
@@ -214,23 +219,26 @@ void Account::endGame()
campaignProgress[currentCampaign].time = 0;
}
-void Account::winCampaignLevel(int choice, float score, float time)
+void Account::winCampaignLevel(int choice, int score, float time)
{
campaignProgress[currentCampaign].choices.push_back(choice);
setCampaignScore(campaignProgress[currentCampaign].score + score);
campaignProgress[currentCampaign].time = time;
}
-void Account::winLevel(int level, float score, float time)
+void Account::winLevel(int level, int score, float time)
{
if (!devtools) {
- if (score > highscore[level])
+ if (score > highscore[level]) {
highscore[level] = score;
- if (time < fasttime[level] || fasttime[level] == 0)
+ }
+ if (time < fasttime[level] || fasttime[level] == 0) {
fasttime[level] = time;
+ }
}
- if (progress < level + 1)
+ if (progress < level + 1) {
progress = level + 1;
+ }
}
void Account::loadFile(string filename)