X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=Source%2FAccount.cpp;h=7eba58815332e28c4edda56ca0be8fd99c7a7c87;hb=e4c69ab5c1d15cdb4a909de8ba8f2057fe6f095d;hp=45e1300e68c827c6dccf45fbe5f5900cb5827b1c;hpb=2cd28eb24fc1b4011511b6c3ed8c025bfc74de4d;p=lugaru.git diff --git a/Source/Account.cpp b/Source/Account.cpp index 45e1300..7eba588 100644 --- a/Source/Account.cpp +++ b/Source/Account.cpp @@ -32,7 +32,7 @@ extern bool debugmode; vector Account::accounts = vector(); -Account::Account(string n) { +Account::Account(string n) : campaignProgress() { name = string(n); difficulty = 0; progress = 0; @@ -41,7 +41,11 @@ Account::Account(string n) { memset(fasttime, 0, sizeof(fasttime)); memset(unlocked, 0, sizeof(unlocked)); - currentCampaign = "main"; + setCurrentCampaign("main"); +} + +void Account::setCurrentCampaign(string name) { + currentCampaign = name; } Account* Account::add(string name) { @@ -67,7 +71,7 @@ Account* Account::destroy(Account* a) { return NULL; } } - printf("Unexpected error : User %s not found %d\n",a->getName(),a); + printf("Unexpected error : User %s not found\n",a->getName()); return accounts.front(); } @@ -102,7 +106,6 @@ Account* Account::loadFile(string filename) { FILE *tfile; int numaccounts; int accountactive; - int j; tfile=fopen(ConvertFileName(filename.c_str()), "rb" ); @@ -126,7 +129,7 @@ Account* Account::loadFile(string filename) { int t; char c; funpackf(tfile, "Bi", &t); - for(j=0;jcampaignProgress[campaignName].highscore)); int campaignchoicesmade,campaignchoice; funpackf(tfile, "Bi", &campaignchoicesmade); - for(j=0;j= 10) // what is that for? @@ -149,20 +152,30 @@ Account* Account::loadFile(string filename) { } } + acc->currentCampaign = ""; + int t; + char c; + funpackf(tfile, "Bi", &t); + for(int i=0;icurrentCampaign.append(1,c); + } + funpackf(tfile, "Bf", &(acc->points)); - for(j=0;j<50;j++) + for(int i=0;i<50;i++) { - funpackf(tfile, "Bf", &(acc->highscore[j])); - funpackf(tfile, "Bf", &(acc->fasttime[j])); + funpackf(tfile, "Bf", &(acc->highscore[i])); + funpackf(tfile, "Bf", &(acc->fasttime[i])); } - for(j=0;j<60;j++) + for(int i=0;i<60;i++) { - funpackf(tfile, "Bb", &(acc->unlocked[j])); + funpackf(tfile, "Bb", &(acc->unlocked[i])); } int temp; char ctemp; funpackf(tfile, "Bi", &temp); - for(j=0;jname.append(1,ctemp); @@ -199,7 +212,7 @@ void Account::saveFile(string filename, Account* accountactive) { fpackf(tfile, "Bi", a->progress); fpackf(tfile, "Bi", a->campaignProgress.size()); - map::const_iterator it; + map::const_iterator it; for( it=a->campaignProgress.begin(); it!= a->campaignProgress.end(); ++it) { fpackf(tfile, "Bi", it->first.size()); for(j=0;jfirst.size();j++) @@ -217,6 +230,12 @@ void Account::saveFile(string filename, Account* accountactive) { } } + fpackf(tfile, "Bi", a->getCurrentCampaign().size()); + for(j=0;jgetCurrentCampaign().size();j++) + { + fpackf(tfile, "Bb", a->getCurrentCampaign()[j]); + } + fpackf(tfile, "Bf", a->points); for(j=0;j<50;j++) {