]> git.jsancho.org Git - lugaru.git/blobdiff - Source/Account.cpp
Switched all data access to the new methods
[lugaru.git] / Source / Account.cpp
index 1d7bbd1d4951c94692b4e5fe7771aabf47ad955e..f650330a0f87bcbb3d9c456eb03488bf3fca5d88 100644 (file)
@@ -23,6 +23,7 @@ along with Lugaru.  If not, see <http://www.gnu.org/licenses/>.
 #include <fstream>
 #include "MacCompatibility.h"
 #include "string.h"
+#include <iostream>
 
 using namespace std;
 
@@ -115,7 +116,7 @@ Account* Account::loadFile(string filename)
     int numaccounts;
     int accountactive;
 
-    tfile = fopen(ConvertFileName(filename.c_str()), "rb" );
+    tfile = fopen(filename.c_str(), "rb" );
 
     if (tfile) {
         funpackf(tfile, "Bi", &numaccounts);
@@ -128,7 +129,6 @@ Account* Account::loadFile(string filename)
             funpackf(tfile, "Bi", &(acc->progress));
             int nbCampaigns;
             funpackf(tfile, "Bi", &nbCampaigns);
-            //~ printf("loading %d campaign progress info\n",nbCampaigns);
 
             for (int k = 0; k < nbCampaigns; ++k) {
                 string campaignName = "";
@@ -139,7 +139,6 @@ Account* Account::loadFile(string filename)
                     funpackf(tfile, "Bb",  &c);
                     campaignName.append(1, c);
                 }
-                //~ printf("loading %s campaign progress info\n",campaignName.c_str());
                 funpackf(tfile, "Bf", &(acc->campaignProgress[campaignName].time));
                 funpackf(tfile, "Bf", &(acc->campaignProgress[campaignName].score));
                 funpackf(tfile, "Bf", &(acc->campaignProgress[campaignName].fasttime));
@@ -187,7 +186,7 @@ Account* Account::loadFile(string filename)
         fclose(tfile);
         return get(accountactive);
     } else {
-        printf("filenotfound\n");
+        perror(("Couldn't load users from " + filename).c_str());
         return NULL;
     }
 }
@@ -196,7 +195,7 @@ void Account::saveFile(string filename, Account* accountactive)
 {
     FILE *tfile;
 
-    tfile = fopen(ConvertFileName(filename.c_str(), "wb"), "wb" );
+    tfile = fopen(filename.c_str(), "wb" );
     if (tfile) {
         printf("writing %d accounts :\n", getNbAccounts());
         fpackf(tfile, "Bi", getNbAccounts());
@@ -245,6 +244,8 @@ void Account::saveFile(string filename, Account* accountactive)
         }
 
         fclose(tfile);
+    } else {
+        perror(("Couldn't save users in " + filename).c_str());
     }
 }