From: Côme Chilliet Date: Mon, 2 Jan 2017 23:56:55 +0000 (+0100) Subject: Attempt at fixing LoadStuff calling logic X-Git-Url: https://git.jsancho.org/?p=lugaru.git;a=commitdiff_plain;h=22dedb8ee79dd55169b8fdb07f1a12a0d6acd22d Attempt at fixing LoadStuff calling logic I failed to have the inside rock bug after these changes but it might be luck --- diff --git a/Source/Game.cpp b/Source/Game.cpp index 5da0518..c385674 100644 --- a/Source/Game.cpp +++ b/Source/Game.cpp @@ -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; diff --git a/Source/Game.hpp b/Source/Game.hpp index f276ef0..0dcee30 100644 --- a/Source/Game.hpp +++ b/Source/Game.hpp @@ -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; diff --git a/Source/GameInitDispose.cpp b/Source/GameInitDispose.cpp index 37593a1..525b522 100644 --- a/Source/GameInitDispose.cpp +++ b/Source/GameInitDispose.cpp @@ -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; } diff --git a/Source/GameTick.cpp b/Source/GameTick.cpp index 1f971e7..2a4f4bd 100644 --- a/Source/GameTick.cpp +++ b/Source/GameTick.cpp @@ -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; diff --git a/Source/Menu/Menu.cpp b/Source/Menu/Menu.cpp index 201d7df..27582aa 100644 --- a/Source/Menu/Menu.cpp +++ b/Source/Menu/Menu.cpp @@ -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;