From fdee267b8dccf98a851e01c592bf80ce26e2d364 Mon Sep 17 00:00:00 2001 From: =?utf8?q?C=C3=B4me=20BERNIGAUD?= Date: Thu, 12 May 2011 18:22:06 +0200 Subject: [PATCH] Some bug fixes. Now the game remember which campaign you were playing last time. --- Source/Account.cpp | 18 +++++++++++++++++- Source/GameDraw.cpp | 8 ++++++++ Source/GameInitDispose.cpp | 2 +- Source/GameTick.cpp | 11 +++-------- 4 files changed, 29 insertions(+), 10 deletions(-) diff --git a/Source/Account.cpp b/Source/Account.cpp index 1388b7e..662c0d3 100644 --- a/Source/Account.cpp +++ b/Source/Account.cpp @@ -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;icurrentCampaign.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;jgetCurrentCampaign().size();j++) + { + fpackf(tfile, "Bb", a->getCurrentCampaign()[j]); + } + fpackf(tfile, "Bf", a->points); for(j=0;j<50;j++) { diff --git a/Source/GameDraw.cpp b/Source/GameDraw.cpp index e8a9998..dd74893 100644 --- a/Source/GameDraw.cpp +++ b/Source/GameDraw.cpp @@ -2021,6 +2021,14 @@ vector 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; diff --git a/Source/GameInitDispose.cpp b/Source/GameInitDispose.cpp index d6e6633..2a9a405 100644 --- a/Source/GameInitDispose.cpp +++ b/Source/GameInitDispose.cpp @@ -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); diff --git a/Source/GameTick.cpp b/Source/GameTick.cpp index 36452aa..86f840f 100644 --- a/Source/GameTick.cpp +++ b/Source/GameTick.cpp @@ -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; -- 2.39.2