]> git.jsancho.org Git - lugaru.git/commitdiff
Attempt at fixing LoadStuff calling logic
authorCôme Chilliet <come@chilliet.eu>
Mon, 2 Jan 2017 23:56:55 +0000 (00:56 +0100)
committerCôme Chilliet <come@chilliet.eu>
Mon, 2 Jan 2017 23:56:55 +0000 (00:56 +0100)
I failed to have the inside rock bug after these changes but it might be luck

Source/Game.cpp
Source/Game.hpp
Source/GameInitDispose.cpp
Source/GameTick.cpp
Source/Menu/Menu.cpp

index 5da0518b1583e617cffca29ad293b8e75bbe9645..c38567497e5a1d9226186b939dc4c622e656d70a 100644 (file)
@@ -64,7 +64,7 @@ float yaw = 0;
 float pitch = 0;
 SkyBox *skybox = NULL;
 bool cameramode = 0;
-bool firstload = 0;
+bool firstLoadDone = false;
 
 Texture hawktexture;
 float hawkyaw = 0;
index f276ef0ddfb80bb3ce44beab369791ac1ab58574..0dcee30ea483ab7778362cb009228c09d8bdf1ac 100644 (file)
@@ -72,7 +72,7 @@ extern int oldmousecoordh, oldmousecoordv;
 extern float yaw, pitch;
 extern SkyBox *skybox;
 extern bool cameramode;
-extern bool firstload;
+extern bool firstLoadDone;
 
 extern float leveltime;
 extern float wonleveltime;
index 37593a1ab524adfe2eae7ac6ec6ef4bafdf4df37..525b5227663e51bada5bc6bbdb1e6f4a20f97b6b 100644 (file)
@@ -588,7 +588,7 @@ void Game::InitGame()
     mainmenu = 1;
 
     stillloading = 0;
-    firstload = 0;
+    firstLoadDone = false;
 
     newdetail = detail;
     newscreenwidth = screenwidth;
@@ -618,10 +618,11 @@ void Game::LoadScreenTexture()
 }
 
 //TODO: move LoadStuff() closer to GameTick.cpp to get rid of various vars shared in Game.hpp
+/* Loads models and textures which only needs to be loaded once */
 void Game::LoadStuff()
 {
-    static float temptexdetail;
-    static float viewdistdetail;
+    float temptexdetail;
+    float viewdistdetail;
     float megascale = 1;
 
     LOGFUNC;
@@ -773,8 +774,6 @@ void Game::LoadStuff()
     gameon = 1;
     mainmenu = 0;
 
-    firstload = 0;
-
     //Fix knife stab, too lazy to do it manually
     XYZ moveamount;
     moveamount = 0;
@@ -846,5 +845,6 @@ void Game::LoadStuff()
     changedelay = 1;
 
     visibleloading = false;
+    firstLoadDone = true;
 }
 
index 1f971e70f8f7869b67d0232493d7e1e6b9b74094..2a4f4bd8a644cbc0fcd174390a4ee1aad7c3ab1c 100644 (file)
@@ -502,8 +502,9 @@ void Game::Loadlevel(int which)
         char buf[32];
         snprintf(buf, 32, "map%d", which + 1); // challenges
         Loadlevel(buf);
-    } else
+    } else {
         Loadlevel("mapsave");
+    }
 }
 
 void Game::Loadlevel(const std::string& name, bool tutorial)
@@ -924,9 +925,6 @@ void Game::Loadlevel(const std::string& name, bool tutorial)
     oldmusicvolume[2] = 0;
     oldmusicvolume[3] = 0;
 
-    if (!firstload)
-        firstload = 1;
-
     leveltime = 0;
     wonleveltime = 0;
     visibleloading = false;
@@ -4553,8 +4551,9 @@ void Game::TickOnceAfter()
                     loading = 2;
                     loadtime = 0;
                     targetlevel = 7;
-                    if (!firstload)
+                    if (!firstLoadDone) {
                         LoadStuff();
+                    }
                     whichchoice = 0;
                     actuallevel = campaignlevels[actuallevel].nextlevel.front();
                     visibleloading = true;
index 201d7dfdfc9ace84e7ab7d449280875db4969029..27582aad5d9c4fa7bee5e194f15c262528fb9094 100644 (file)
@@ -706,10 +706,11 @@ void Menu::Tick()
                 loading = 2;
                 loadtime = 0;
                 targetlevel = 7;
-                if (firstload)
+                if (firstLoadDone) {
                     TickOnceAfter();
-                else
+                } else {
                     LoadStuff();
+                }
                 whichchoice = selected - NB_CAMPAIGN_MENU_ITEM - Account::active().getCampaignChoicesMade();
                 actuallevel = (Account::active().getCampaignChoicesMade() > 0 ? campaignlevels[Account::active().getCampaignChoicesMade() - 1].nextlevel[whichchoice] : 0);
                 visibleloading = true;
@@ -727,10 +728,11 @@ void Menu::Tick()
                 loading = 2;
                 loadtime = 0;
                 targetlevel = -1;
-                if (firstload) {
+                if (firstLoadDone) {
                     TickOnceAfter();
-                } else
+                } else {
                     LoadStuff();
+                }
                 Loadlevel(-1);
 
                 mainmenu = 0;
@@ -813,10 +815,11 @@ void Menu::Tick()
                 loading = 2;
                 loadtime = 0;
                 targetlevel = selected;
-                if (firstload)
+                if (firstLoadDone) {
                     TickOnceAfter();
-                else
+                } else {
                     LoadStuff();
+                }
                 Loadlevel(selected);
                 campaign = 0;