]> git.jsancho.org Git - lugaru.git/commitdiff
clean ups, and now campaignProgess is well initialized in accounts
authorCôme BERNIGAUD <come.bernigaud@gmail.com>
Wed, 11 May 2011 11:55:41 +0000 (13:55 +0200)
committerCôme BERNIGAUD <come.bernigaud@gmail.com>
Wed, 11 May 2011 11:55:41 +0000 (13:55 +0200)
Source/Account.cpp
Source/Account.h
Source/Frustum.cpp
Source/GameDraw.cpp
Source/PhysicsMath.h

index 45e1300e68c827c6dccf45fbe5f5900cb5827b1c..beb5f46a041787aae4e675b1588de9449ab21584 100644 (file)
@@ -32,7 +32,7 @@ extern bool debugmode;
 
 vector<Account*> Account::accounts = vector<Account*>();
 
-Account::Account(string n) {
+Account::Account(string n) : campaignProgress() {
        name = string(n);
        difficulty = 0;
        progress = 0;
@@ -41,7 +41,15 @@ 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;
+       campaignProgress[name].highscore = 0;
+       campaignProgress[name].fasttime = 0;
+       campaignProgress[name].score = 0;
+       campaignProgress[name].time = 0;
 }
 
 Account* Account::add(string name) {
@@ -102,7 +110,6 @@ Account* Account::loadFile(string filename) {
        FILE *tfile;
        int numaccounts;
        int accountactive;
-       int j;
        
        tfile=fopen(ConvertFileName(filename.c_str()), "rb" );
        
@@ -126,7 +133,7 @@ Account* Account::loadFile(string filename) {
                                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);
@@ -138,7 +145,7 @@ Account* Account::loadFile(string filename) {
                                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?
@@ -150,19 +157,19 @@ Account* Account::loadFile(string filename) {
                        }
                        
                        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);
index acd285061266b722d939bd3146425f65a36b21d8..388c064fcc6c2b6063614aeb95b927737beee55f 100644 (file)
@@ -73,6 +73,7 @@ class Account {
                float getHighScore(int i) { return highscore[i]; };
                float getFastTime(int i) { return fasttime[i]; };
                int getProgress() { return progress; };
+               void setCurrentCampaign(std::string name);
                
                static int getNbAccounts() { return accounts.size(); };
        private:
index 9425ddeeea7ac9cbccf34c8837fab3afacf735b5..f8fb2f51758380d9e169cd464a27715d9c087c80 100644 (file)
@@ -30,7 +30,6 @@ void FRUSTUM::
        static float projmatrix[16];
        static float mvmatrix[16];
        static float clip[16];
-       static float t;
        
        glGetFloatv(GL_PROJECTION_MATRIX, projmatrix);
        glGetFloatv(GL_MODELVIEW_MATRIX, mvmatrix);
index 70b6716c177561b4c5e70ec1db3fd21acacf674f..ad542f11c819def708c2f29c9c22ad5fd59e7e33 100644 (file)
@@ -2674,17 +2674,16 @@ void Game::DrawMenu()
 
        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;
                        }
                }
 
index a26c88c60e275eadadbcebe2ee26511bce5cab04..75aa7a861e0893decb57f8d6bd5d484479519e55 100644 (file)
@@ -714,7 +714,7 @@ inline      Quaternion      MakeQFromEulerAngles(float x, float y, float z)
 
 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;
@@ -733,8 +733,8 @@ inline      Vector  MakeEulerAnglesFromQ(Quaternion q)
        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