]> git.jsancho.org Git - lugaru.git/blobdiff - Source/GameInitDispose.cpp
Removed useless code in GameInitDispose
[lugaru.git] / Source / GameInitDispose.cpp
index b20c1966c963bb34ee91e6effefd169b7af55d72..73673ee9678e0c7cb11ebb194ed19b0d8784343c 100644 (file)
@@ -18,11 +18,13 @@ You should have received a copy of the GNU General Public License
 along with Lugaru.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-#include "Game.h"
-#include "openal_wrapper.h"
-#include "Animation/Animation.h"
-#include "Texture.h"
-#include "Utils/Folders.h"
+#include "Game.hpp"
+
+#include "Animation/Animation.hpp"
+#include "Audio/openal_wrapper.hpp"
+#include "Graphic/Texture.hpp"
+#include "Menu/Menu.hpp"
+#include "Utils/Folders.hpp"
 
 extern float screenwidth, screenheight;
 extern float viewdistance;
@@ -36,7 +38,6 @@ extern int kTextureSize;
 extern float texdetail;
 extern float realtexdetail;
 extern float volume;
-extern Objects objects;
 extern int detail;
 extern bool cellophane;
 extern GLubyte bloodText[512 * 512 * 3];
@@ -56,7 +57,6 @@ extern float flashamount, flashr, flashg, flashb;
 extern int flashdelay;
 extern int whichjointstartarray[26];
 extern int whichjointendarray[26];
-extern int difficulty;
 extern float slomospeed;
 extern bool gamestarted;
 
@@ -78,11 +78,11 @@ void Dispose()
     LOGFUNC;
 
     if (Game::endgame == 2) {
-        Game::accountactive->endGame();
+        Account::active().endGame();
         Game::endgame = 0;
     }
 
-    Account::saveFile(Folders::getUserDataPath()+"/users", Game::accountactive);
+    Account::saveFile(Folders::getUserSavePath());
 
     //textures.clear();
 
@@ -114,17 +114,6 @@ void Game::deleteGame()
         delete skybox;
     if (text)
         delete text;
-    terraintexture.destroy();
-    terraintexture2.destroy();
-    cursortexture.destroy();
-    Maparrowtexture.destroy();
-    Mapboxtexture.destroy();
-    Mapcircletexture.destroy();
-    hawktexture.destroy();
-    loadscreentexture.destroy();
-
-    for (int i = 0; i < 10; i++)
-        Mainmenuitems[i].destroy();
 
     glDeleteTextures(1, &screentexture);
     glDeleteTextures(1, &screentexture2);
@@ -185,6 +174,10 @@ GLvoid Game::ReSizeGLScene(float fov, float pnear)
 
 void Game::LoadingScreen()
 {
+    if (!visibleloading) {
+        return;
+    }
+
     static float loadprogress;
     static AbsoluteTime frametime = {0, 0};
     AbsoluteTime currTime = UpTime ();
@@ -457,7 +450,7 @@ void Game::InitGame()
 
     numchallengelevels = 14;
 
-    accountactive = Account::loadFile(Folders::getUserDataPath()+"/users");
+    Account::loadFile(Folders::getUserSavePath());
 
     whichjointstartarray[0] = righthip;
     whichjointendarray[0] = rightfoot;
@@ -627,7 +620,7 @@ void Game::InitGame()
     newscreenwidth = screenwidth;
     newscreenheight = screenheight;
 
-    LoadMenu();
+    Menu::Load();
 
     Animation::loadAll();
 }
@@ -650,12 +643,11 @@ void Game::LoadScreenTexture()
     glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, kTextureSize, kTextureSize, 0);
 }
 
-//TODO: move LoadStuff() closer to GameTick.cpp to get rid of various vars shared in Game.h
+//TODO: move LoadStuff() closer to GameTick.cpp to get rid of various vars shared in Game.hpp
 void Game::LoadStuff()
 {
     static float temptexdetail;
     static float viewdistdetail;
-    static int i, j;
     float megascale = 1;
 
     LOGFUNC;
@@ -664,14 +656,9 @@ void Game::LoadStuff()
 
     stillloading = 1;
 
-    for (auto p:Person::players) {
-        p->skeleton.drawmodel.textureptr.destroy();
-    }
-
-    i = abs(Random() % 4);
-    visibleloading = 0; //don't use loadscreentexture yet
+    visibleloading = false; //don't use loadscreentexture yet
     loadscreentexture.load("Textures/Fire.jpg", 1);
-    visibleloading = 1;
+    visibleloading = true;
 
     temptexdetail = texdetail;
     texdetail = 1;
@@ -684,12 +671,13 @@ void Game::LoadStuff()
 
     if (detail == 2) {
         texdetail = 1;
-    }
-    if (detail == 1) {
+        kTextureSize = 1024;
+    } else if (detail == 1) {
         texdetail = 2;
-    }
-    if (detail == 0) {
+        kTextureSize = 512;
+    } else {
         texdetail = 4;
+        kTextureSize = 256;
     }
 
     realtexdetail = texdetail;
@@ -756,14 +744,6 @@ void Game::LoadStuff()
 
     viewer = 0;
 
-
-    if (detail)
-        kTextureSize = 1024;
-    if (detail == 1)
-        kTextureSize = 512;
-    if (detail == 0)
-        kTextureSize = 256;
-
     //Set up distant light
     light.color[0] = .95;
     light.color[1] = .95;
@@ -827,23 +807,23 @@ void Game::LoadStuff()
     moveamount.z = 2;
     // FIXME - Why this uses skeleton.joints.size() and not Animation::numjoints? (are they equal?)
     // It seems skeleton.joints.size() is 0 at this point, so this is useless.
-    for (i = 0; i < Person::players[0]->skeleton.joints.size(); i++) {
-        for (j = 0; j < Animation::animations[knifesneakattackanim].frames.size(); j++) {
+    for (unsigned i = 0; i < Person::players[0]->skeleton.joints.size(); i++) {
+        for (unsigned j = 0; j < Animation::animations[knifesneakattackanim].frames.size(); j++) {
             Animation::animations[knifesneakattackanim].frames[j].joints[i].position += moveamount;
         }
     }
 
     LoadingScreen();
 
-    for (i = 0; i < Person::players[0]->skeleton.joints.size(); i++) {
-        for (j = 0; j < Animation::animations[knifesneakattackedanim].frames.size(); j++) {
+    for (unsigned i = 0; i < Person::players[0]->skeleton.joints.size(); i++) {
+        for (unsigned j = 0; j < Animation::animations[knifesneakattackedanim].frames.size(); j++) {
             Animation::animations[knifesneakattackedanim].frames[j].joints[i].position += moveamount;
         }
     }
 
     LoadingScreen();
 
-    for (i = 0; i < Person::players[0]->skeleton.joints.size(); i++) {
+    for (unsigned i = 0; i < Person::players[0]->skeleton.joints.size(); i++) {
         Animation::animations[dead1anim].frames[1].joints[i].position = Animation::animations[dead1anim].frames[0].joints[i].position;
         Animation::animations[dead2anim].frames[1].joints[i].position = Animation::animations[dead2anim].frames[0].joints[i].position;
         Animation::animations[dead3anim].frames[1].joints[i].position = Animation::animations[dead3anim].frames[0].joints[i].position;
@@ -859,29 +839,24 @@ void Game::LoadStuff()
     Animation::animations[dead3anim].frames[1].speed = 0.001;
     Animation::animations[dead4anim].frames[1].speed = 0.001;
 
-    for (i = 0; i < Person::players[0]->skeleton.joints.size(); i++) {
-        for (j = 0; j < Animation::animations[swordsneakattackanim].frames.size(); j++) {
+    for (unsigned i = 0; i < Person::players[0]->skeleton.joints.size(); i++) {
+        for (unsigned j = 0; j < Animation::animations[swordsneakattackanim].frames.size(); j++) {
             Animation::animations[swordsneakattackanim].frames[j].joints[i].position += moveamount;
         }
     }
     LoadingScreen();
-    for (j = 0; j < Animation::animations[swordsneakattackanim].frames.size(); j++) {
+    for (unsigned j = 0; j < Animation::animations[swordsneakattackanim].frames.size(); j++) {
         Animation::animations[swordsneakattackanim].frames[j].weapontarget += moveamount;
     }
 
     LoadingScreen();
 
-    for (i = 0; i < Person::players[0]->skeleton.joints.size(); i++) {
-        for (j = 0; j < Animation::animations[swordsneakattackedanim].frames.size(); j++) {
+    for (unsigned i = 0; i < Person::players[0]->skeleton.joints.size(); i++) {
+        for (unsigned j = 0; j < Animation::animations[swordsneakattackedanim].frames.size(); j++) {
             Animation::animations[swordsneakattackedanim].frames[j].joints[i].position += moveamount;
         }
     }
 
-    LoadingScreen();
-    temptexdetail = texdetail;
-    texdetail = 1;
-    texdetail = temptexdetail;
-
     LoadingScreen();
 
     if (!screentexture) {
@@ -896,6 +871,6 @@ void Game::LoadStuff()
     loading = 0;
     changedelay = 1;
 
-    visibleloading = 0;
+    visibleloading = false;
 }