campaignfasttime = 0;
campaignscore = 0;
campaigntime = 0;
- campaignchoicesmade = 0;
- memset(campaignchoices, 0, sizeof(campaignchoices));
}
Account* Account::add(string name) {
}
void Account::endGame() {
- campaignchoicesmade=0;
+ campaignchoices.clear();
campaignscore=0;
campaigntime=0;
}
void Account::winCampaignLevel(int choice, float score, float time) {
- campaignchoices[campaignchoicesmade++] = choice;
+ campaignchoices.push_back(choice);
setCampaignScore(campaignscore+score);
campaigntime = time;
}
funpackf(tfile, "Bf", &(acc->campaignhighscore));
funpackf(tfile, "Bi", &(acc->difficulty));
funpackf(tfile, "Bi", &(acc->progress));
- funpackf(tfile, "Bi", &(acc->campaignchoicesmade));
- for(j=0;j<acc->campaignchoicesmade;j++)
+ int campaignchoicesmade,campaignchoice;
+ funpackf(tfile, "Bi", &campaignchoicesmade);
+ for(j=0;j<campaignchoicesmade;j++)
{
- funpackf(tfile, "Bi", &(acc->campaignchoices[j]));
- if (acc->campaignchoices[j] >= 10)
+ funpackf(tfile, "Bi", &campaignchoice);
+ if (campaignchoice >= 10) // what is that for?
{
- acc->campaignchoices[j] = 0;
+ campaignchoice = 0;
}
+ acc->campaignchoices.push_back(campaignchoice);
}
funpackf(tfile, "Bf", &(acc->points));
for(j=0;j<50;j++)
fpackf(tfile, "Bf", a->campaignhighscore);
fpackf(tfile, "Bi", a->difficulty);
fpackf(tfile, "Bi", a->progress);
- fpackf(tfile, "Bi", a->campaignchoicesmade);
- for(j=0;j<a->campaignchoicesmade;j++)
+ fpackf(tfile, "Bi", a->getCampaignChoicesMade());
+ for(j=0;j<a->getCampaignChoicesMade();j++)
{
fpackf(tfile, "Bi", a->campaignchoices[j]);
}
void setDifficulty(int i) { difficulty = i; };
const char* getName() { return name.c_str(); };
float getCampaignScore() { return campaignscore; };
- int getCampaignChoicesMade() { return campaignchoicesmade; };
+ int getCampaignChoicesMade() { return campaignchoices.size(); };
int getCampaignChoice(int i) { return campaignchoices[i]; };
void setCampaignScore(int s) {
campaignscore=s;
float campaignfasttime;
float campaignscore;
float campaigntime;
- int campaignchoicesmade;
- int campaignchoices[5000]; // should really disappear. I'd use a vector or something like that.
+ std::vector<int> campaignchoices;
//statics
static std::vector<Account*> accounts;