vector<Account*> Account::accounts = vector<Account*>();
-Account::Account(string n) {
+Account::Account(string n) : campaignProgress() {
name = string(n);
difficulty = 0;
progress = 0;
memset(fasttime, 0, sizeof(fasttime));
memset(unlocked, 0, sizeof(unlocked));
- currentCampaign = "main";
+ setCurrentCampaign("main");
+}
+
+void Account::setCurrentCampaign(string name) {
+ currentCampaign = name;
+ campaignProgress[name].highscore = 0;
+ campaignProgress[name].fasttime = 0;
+ campaignProgress[name].score = 0;
+ campaignProgress[name].time = 0;
}
Account* Account::add(string name) {
FILE *tfile;
int numaccounts;
int accountactive;
- int j;
tfile=fopen(ConvertFileName(filename.c_str()), "rb" );
int t;
char c;
funpackf(tfile, "Bi", &t);
- for(j=0;j<t;j++)
+ for(int j=0;j<t;j++)
{
funpackf(tfile, "Bb", &c);
campaignName.append(1,c);
funpackf(tfile, "Bf", &(acc->campaignProgress[campaignName].highscore));
int campaignchoicesmade,campaignchoice;
funpackf(tfile, "Bi", &campaignchoicesmade);
- for(j=0;j<campaignchoicesmade;j++)
+ for(int j=0;j<campaignchoicesmade;j++)
{
funpackf(tfile, "Bi", &campaignchoice);
if (campaignchoice >= 10) // what is that for?
}
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;j<temp;j++)
+ for(int i=0;i<temp;i++)
{
funpackf(tfile, "Bb", &ctemp);
acc->name.append(1,ctemp);
if(mainmenu==1||mainmenu==2)
for(i=1;i<4;i++){
- if((mousecoordh/screenwidth*640)>startx[i]&&(mousecoordh/screenwidth*640)<endx[i]&&480-(mousecoordv/screenheight*480)>starty[i]&&480-(mousecoordv/screenheight*480)<endy[i]){
+ if((mousecoordh/screenwidth*640)>startx[i]&&(mousecoordh/screenwidth*640)<endx[i]&&480-(mousecoordv/screenheight*480)>starty[i]&&480-(mousecoordv/screenheight*480)<endy[i]) {
selected=i;
}
}
if(mainmenu==3||mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==8||mainmenu==9||mainmenu==10||mainmenu==18)
- for(i=0;i<nummenuitems;i++){
- if((mousecoordh/screenwidth*640)>startx[i]&&(mousecoordh/screenwidth*640)<endx[i]&&480-(mousecoordv/screenheight*480)>starty[i]&&480-(mousecoordv/screenheight*480)<endy[i]){
- if(mainmenu!=5)selected=i;
- if(mainmenu==5&&(i!=0&&i!=6))selected=i;
- if(mainmenu==9&&(i!=numchallengelevels+1))selected=i; // seem useless, if mainmenu==9 then mainmenu!=5, so selected==i.
+ for(i=0;i<nummenuitems;i++) {
+ if((mousecoordh/screenwidth*640)>startx[i]&&(mousecoordh/screenwidth*640)<endx[i]&&480-(mousecoordv/screenheight*480)>starty[i]&&480-(mousecoordv/screenheight*480)<endy[i]) {
+ if(mainmenu!=5) selected=i;
+ else if( (i!=0) && (i!=6) ) selected=i;
}
}
inline Vector MakeEulerAnglesFromQ(Quaternion q)
{
- double r11, r21, r31, r32, r33, r12, r13;
+ double r11, r21, r31, r32, r33;
double q00, q11, q22, q33;
double tmp;
Vector u;
tmp = fabs(r31);
if(tmp > 0.999999)
{
- r12 = 2 * (q.v.x*q.v.y - q.n*q.v.z);
- r13 = 2 * (q.v.x*q.v.z + q.n*q.v.y);
+ double r12 = 2 * (q.v.x*q.v.y - q.n*q.v.z);
+ double r13 = 2 * (q.v.x*q.v.z + q.n*q.v.y);
u.x = RadiansToDegrees(0.0f); //roll
u.y = RadiansToDegrees((float) (-(pi/2) * r31/tmp)); // pitch