]> git.jsancho.org Git - lugaru.git/commitdiff
Some bug fixes. Now the game remember which campaign you were playing last time.
authorCôme BERNIGAUD <come.bernigaud@gmail.com>
Thu, 12 May 2011 16:22:06 +0000 (18:22 +0200)
committerCôme BERNIGAUD <come.bernigaud@gmail.com>
Thu, 12 May 2011 16:22:06 +0000 (18:22 +0200)
Source/Account.cpp
Source/GameDraw.cpp
Source/GameInitDispose.cpp
Source/GameTick.cpp

index 1388b7e0e281e4d1fa4e57ef3b0295f2a311c72e..662c0d35ea2c48832d86945ef65e48c6e3ee0b3d 100644 (file)
@@ -77,7 +77,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();
 }
 
@@ -158,6 +158,16 @@ Account* Account::loadFile(string filename) {
                                }
                        }
                        
+                       acc->currentCampaign = "";
+                       int t;
+                       char c;
+                       funpackf(tfile, "Bi",  &t);
+                       for(int i=0;i<t;i++)
+                       {
+                               funpackf(tfile, "Bb",  &c);
+                               acc->currentCampaign.append(1,c);
+                       }
+                       
                        funpackf(tfile, "Bf", &(acc->points));
                        for(int i=0;i<50;i++)
                        {
@@ -226,6 +236,12 @@ void Account::saveFile(string filename, Account* accountactive) {
                                }
                        }
                        
+                       fpackf(tfile, "Bi", a->getCurrentCampaign().size());
+                       for(j=0;j<a->getCurrentCampaign().size();j++)
+                       {
+                               fpackf(tfile, "Bb", a->getCurrentCampaign()[j]);
+                       }
+                       
                        fpackf(tfile, "Bf", a->points);
                        for(j=0;j<50;j++)
                        {
index e8a999857b7a1982040876052fe660e2d81dc16d..dd74893d7a9e80aa6b0b1f43e3247113f7eb3f02 100644 (file)
@@ -2021,6 +2021,14 @@ vector<string> Game::ListCampaigns() {
 void Game::LoadCampaign() {
        if(!accountactive)
                return;
+       if(!Mainmenuitems[7]) {
+               ifstream test(ConvertFileName((":Data:Textures:"+accountactive->getCurrentCampaign()+":World.png").c_str()));
+               if(test.good()) {
+                       LoadTexture((":Data:Textures:"+accountactive->getCurrentCampaign()+":World.png").c_str(),&Mainmenuitems[7],0,0);
+               } else {
+                       LoadTexture(":Data:Textures:World.png",&Mainmenuitems[7],0,0);
+               }
+       }
        ifstream ipstream(ConvertFileName((":Data:Campaigns:"+accountactive->getCurrentCampaign()+".txt").c_str()));
        ipstream.ignore(256,':');
        ipstream >> campaignnumlevels;
index d6e663366797c48e4a9a0e460a222fd6ea9de39e..2a9a405aba8c73f66a0af072d99fb39653c2658b 100644 (file)
@@ -831,7 +831,7 @@ void Game::InitGame()
        LoadTexture(":Data:Textures:Quit.png",&Mainmenuitems[3],0,0);
        LoadTexture(":Data:Textures:Eyelid.png",&Mainmenuitems[4],0,1);
        //LoadTexture(":Data:Textures:Eye.jpg",&Mainmenuitems[5],0,1);
-       LoadTexture(":Data:Textures:World.png",&Mainmenuitems[7],0,0);
+       //~ LoadTexture(":Data:Textures:World.png",&Mainmenuitems[7],0,0); // LoadCampaign will take care of that
        texdetail=temptexdetail;
 
        FadeLoadingScreen(95);
index 36452aa4f5e09f5c6de70fdc6ef92e8ee51199d1..86f840f4c574ae10dbb809363e6fee2e0cdd8661 100644 (file)
@@ -5740,15 +5740,10 @@ void Game::MenuTick(){
                                                                c=campaigns.begin();
                                                        accountactive->setCurrentCampaign(*c);
                                                }
-                                               LoadCampaign();
                                                if(Mainmenuitems[7])
-                                                       glDeleteTextures(1,&Mainmenuitems[7]);
-                                               ifstream test(ConvertFileName((":Data:Textures:"+accountactive->getCurrentCampaign()+":World.png").c_str()));
-                                               if(test.good()) {
-                                                       LoadTexture((":Data:Textures:"+accountactive->getCurrentCampaign()+":World.png").c_str(),&Mainmenuitems[7],0,0);
-                                               } else {
-                                                       LoadTexture(":Data:Textures:World.png",&Mainmenuitems[7],0,0);
-                                               }
+                                                       glDeleteTextures(1,&Mainmenuitems[7]); // we delete the world texture so load campaign will reload it
+                                               Mainmenuitems[7] = 0;
+                                               LoadCampaign();
                                                break;
                                }
                                break;