]> git.jsancho.org Git - lugaru.git/blobdiff - Source/User/Account.cpp
Added braces to all statements with clang-tidy and ran clang-format again
[lugaru.git] / Source / User / Account.cpp
index ff4b04f52c0020341385109e300d66c77893a3cb..82072fc1aa764580a1ad1000e579022a34542dd3 100644 (file)
@@ -18,12 +18,14 @@ You should have received a copy of the GNU General Public License
 along with Lugaru.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-#include "User/Account.h"
+#include "User/Account.hpp"
+
+#include "MacCompatibility.hpp"
 #include "Utils/binio.h"
-#include "MacCompatibility.h"
+
 #include <fstream>
-#include "string.h"
 #include <iostream>
+#include <string.h>
 
 using namespace std;
 
@@ -32,7 +34,9 @@ extern bool devtools;
 vector<Account> Account::accounts;
 int Account::i_active = -1;
 
-Account::Account(const string& name) : name(name), campaignProgress()
+Account::Account(const string& name)
+    : name(name)
+    , campaignProgress()
 {
     difficulty = 0;
     progress = 0;
@@ -44,7 +48,8 @@ Account::Account(const string& name) : name(name), campaignProgress()
     setCurrentCampaign("main");
 }
 
-Account::Account(FILE* tfile) : Account("")
+Account::Account(FILE* tfile)
+    : Account("")
 {
     funpackf(tfile, "Bi", &difficulty);
     funpackf(tfile, "Bi", &progress);
@@ -55,9 +60,9 @@ Account::Account(FILE* tfile) : Account("")
         string campaignName = "";
         int t;
         char c;
-        funpackf(tfile, "Bi",  &t);
+        funpackf(tfile, "Bi", &t);
         for (int j = 0; j < t; j++) {
-            funpackf(tfile, "Bb",  &c);
+            funpackf(tfile, "Bb", &c);
             campaignName.append(1, c);
         }
         funpackf(tfile, "Bf", &(campaignProgress[campaignName].time));
@@ -78,9 +83,9 @@ Account::Account(FILE* tfile) : Account("")
     currentCampaign = "";
     int t;
     char c;
-    funpackf(tfile, "Bi",  &t);
+    funpackf(tfile, "Bi", &t);
     for (int i = 0; i < t; i++) {
-        funpackf(tfile, "Bb",  &c);
+        funpackf(tfile, "Bb", &c);
         currentCampaign.append(1, c);
     }
 
@@ -90,13 +95,13 @@ Account::Account(FILE* tfile) : Account("")
         funpackf(tfile, "Bf", &(fasttime[i]));
     }
     for (int i = 0; i < 60; i++) {
-        funpackf(tfile, "Bb",  &(unlocked[i]));
+        funpackf(tfile, "Bb", &(unlocked[i]));
     }
     int temp;
     char ctemp;
-    funpackf(tfile, "Bi",  &temp);
+    funpackf(tfile, "Bi", &temp);
     for (int i = 0; i < temp; i++) {
-        funpackf(tfile, "Bb",  &ctemp);
+        funpackf(tfile, "Bb", &ctemp);
         name.append(1, ctemp);
     }
     if (name.empty()) {
@@ -112,9 +117,9 @@ void Account::save(FILE* tfile)
 
     map<string, CampaignProgress>::const_iterator it;
     for (it = campaignProgress.begin(); it != campaignProgress.end(); ++it) {
-        fpackf(tfile, "Bi",  it->first.size());
+        fpackf(tfile, "Bi", it->first.size());
         for (unsigned j = 0; j < it->first.size(); j++) {
-            fpackf(tfile, "Bb",  it->first[j]);
+            fpackf(tfile, "Bb", it->first[j]);
         }
         fpackf(tfile, "Bf", it->second.time);
         fpackf(tfile, "Bf", it->second.score);
@@ -137,11 +142,11 @@ void Account::save(FILE* tfile)
         fpackf(tfile, "Bf", fasttime[j]);
     }
     for (unsigned j = 0; j < 60; j++) {
-        fpackf(tfile, "Bb",  unlocked[j]);
+        fpackf(tfile, "Bb", unlocked[j]);
     }
-    fpackf(tfile, "Bi",  name.size());
+    fpackf(tfile, "Bi", name.size());
     for (unsigned j = 0; j < name.size(); j++) {
-        fpackf(tfile, "Bb",  name[j]);
+        fpackf(tfile, "Bb", name[j]);
     }
 }
 
@@ -219,23 +224,26 @@ void Account::winCampaignLevel(int choice, float score, float time)
 void Account::winLevel(int level, float 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)
 {
-    FILE *tfile;
+    FILEtfile;
     int numaccounts;
     int iactive;
     errno = 0;
 
-    tfile = fopen(filename.c_str(), "rb" );
+    tfile = fopen(filename.c_str(), "rb");
 
     if (tfile) {
         funpackf(tfile, "Bi", &numaccounts);
@@ -256,10 +264,10 @@ void Account::loadFile(string filename)
 
 void Account::saveFile(string filename)
 {
-    FILE *tfile;
+    FILEtfile;
     errno = 0;
 
-    tfile = fopen(filename.c_str(), "wb" );
+    tfile = fopen(filename.c_str(), "wb");
     if (tfile) {
         fpackf(tfile, "Bi", getNbAccounts());
         fpackf(tfile, "Bi", i_active);