From: Côme Chilliet Date: Fri, 16 Dec 2016 22:56:00 +0000 (+0100) Subject: Moved visibleloading check inside LoadingScreen X-Git-Url: https://git.jsancho.org/?a=commitdiff_plain;h=e66f03512f2e3471462c3927f47e464711eb7ae8;p=lugaru.git Moved visibleloading check inside LoadingScreen --- diff --git a/Source/Animation/Animation.cpp b/Source/Animation/Animation.cpp index 89aa9f4..8ee1fd6 100644 --- a/Source/Animation/Animation.cpp +++ b/Source/Animation/Animation.cpp @@ -23,8 +23,6 @@ along with Lugaru. If not, see . #include "Game.hpp" #include "Utils/Folders.hpp" -extern bool visibleloading; - std::vector Animation::animations; void Animation::loadAll() @@ -99,8 +97,7 @@ Animation::Animation(const std::string& filename, anim_height_type aheight, anim height = aheight; attack = aattack; - if (visibleloading) - Game::LoadingScreen(); + Game::LoadingScreen(); // read file in binary mode tfile = Folders::openMandatoryFile( filepath, "rb" ); diff --git a/Source/Animation/Skeleton.cpp b/Source/Animation/Skeleton.cpp index a098b1a..014117c 100644 --- a/Source/Animation/Skeleton.cpp +++ b/Source/Animation/Skeleton.cpp @@ -37,8 +37,6 @@ extern int detail; extern int whichjointstartarray[26]; extern int whichjointendarray[26]; -extern bool visibleloading; - Skeleton::Skeleton() : selected(0), id(0), diff --git a/Source/Environment/Terrain.cpp b/Source/Environment/Terrain.cpp index 98828fd..ba4e240 100644 --- a/Source/Environment/Terrain.cpp +++ b/Source/Environment/Terrain.cpp @@ -38,7 +38,6 @@ extern int detail; extern bool decals; extern float blurness; extern float targetblurness; -extern bool visibleloading; extern bool skyboxtexture; //Functions @@ -426,8 +425,7 @@ bool Terrain::load(const std::string& fileName) } } texture.bpp = 24; - if (visibleloading) - Game::LoadingScreen(); + Game::LoadingScreen(); texdetail = temptexdetail; @@ -439,8 +437,7 @@ bool Terrain::load(const std::string& fileName) } } - if (visibleloading) - Game::LoadingScreen(); + Game::LoadingScreen(); float slopeness; @@ -449,8 +446,7 @@ bool Terrain::load(const std::string& fileName) textureness[i][j] = -1; } } - if (visibleloading) - Game::LoadingScreen(); + Game::LoadingScreen(); for (i = 0; i < size; i++) { @@ -499,8 +495,7 @@ bool Terrain::load(const std::string& fileName) } } } - if (visibleloading) - Game::LoadingScreen(); + Game::LoadingScreen(); for (i = 0; i < size; i++) { for (j = 0; j < size; j++) { @@ -512,8 +507,7 @@ bool Terrain::load(const std::string& fileName) } } } - if (visibleloading) - Game::LoadingScreen(); + Game::LoadingScreen(); for (i = 0; i < size; i++) { for (j = 0; j < size; j++) { @@ -638,8 +632,7 @@ bool Terrain::load(const std::string& fileName) } } } - if (visibleloading) - Game::LoadingScreen(); + Game::LoadingScreen(); patch_size = size / subdivision; patch_elements = (patch_size) * (patch_size) * 54; @@ -732,7 +725,9 @@ void Terrain::drawpatch(int whichx, int whichy, float opacity) glEnable(GL_BLEND); UpdateTransparency(whichx, whichy); } + glColor4f(1, 1, 1, 1); + //Set up vertex array glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_COLOR_ARRAY); @@ -756,7 +751,9 @@ void Terrain::drawpatchother(int whichx, int whichy, float opacity) UpdateTransparency(whichx, whichy); } UpdateTransparencyother(whichx, whichy); + glColor4f(1, 1, 1, 1); + //Set up vertex array glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_COLOR_ARRAY); @@ -1394,8 +1391,7 @@ void Terrain::DoShadows() } } } - if (visibleloading) - Game::LoadingScreen(); + Game::LoadingScreen(); } brightness = dotproduct(&lightloc, &normals[i][j]); if (shadowed) @@ -1419,8 +1415,7 @@ void Terrain::DoShadows() } } - if (visibleloading) - Game::LoadingScreen(); + Game::LoadingScreen(); //Smooth shadows for (i = 0; i < size; i++) { diff --git a/Source/Environment/Terrain.hpp b/Source/Environment/Terrain.hpp index 097cdbd..444a47b 100644 --- a/Source/Environment/Terrain.hpp +++ b/Source/Environment/Terrain.hpp @@ -113,19 +113,21 @@ public: XYZ getLighting(float pointx, float pointz); XYZ getNormal(float pointx, float pointz); void UpdateVertexArray(int whichx, int whichy); - void UpdateTransparency(int whichx, int whichy); - void UpdateTransparencyother(int whichx, int whichy); - void UpdateTransparencyotherother(int whichx, int whichy); bool load(const std::string& fileName); void CalculateNormals(); void drawdecals(); void draw(int layer); - void drawpatch(int whichx, int whichy, float opacity); - void drawpatchother(int whichx, int whichy, float opacity); - void drawpatchotherother(int whichx, int whichy, float opacity); void DoShadows(); Terrain(); + +private: + void drawpatch(int whichx, int whichy, float opacity); + void drawpatchother(int whichx, int whichy, float opacity); + void drawpatchotherother(int whichx, int whichy, float opacity); + void UpdateTransparency(int whichx, int whichy); + void UpdateTransparencyother(int whichx, int whichy); + void UpdateTransparencyotherother(int whichx, int whichy); }; #endif diff --git a/Source/GameInitDispose.cpp b/Source/GameInitDispose.cpp index 5e6ce04..d6173f5 100644 --- a/Source/GameInitDispose.cpp +++ b/Source/GameInitDispose.cpp @@ -174,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 (); @@ -652,9 +656,9 @@ void Game::LoadStuff() stillloading = 1; - 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; @@ -872,6 +876,6 @@ void Game::LoadStuff() loading = 0; changedelay = 1; - visibleloading = 0; + visibleloading = false; } diff --git a/Source/GameTick.cpp b/Source/GameTick.cpp index c8b61ca..a400c22 100644 --- a/Source/GameTick.cpp +++ b/Source/GameTick.cpp @@ -566,9 +566,9 @@ void Game::Loadlevel(const std::string& name, bool tutorial) LOG(std::string("Loading level...") + name); if (!gameon) - visibleloading = 1; + visibleloading = true; if (stealthloading) - visibleloading = 0; + visibleloading = false; if (!stillloading) loadtime = 0; gamestarted = 1; @@ -663,8 +663,7 @@ void Game::Loadlevel(const std::string& name, bool tutorial) terrain.patchobjectnum[i][j] = 0; } } - if (visibleloading) - LoadingScreen(); + Game::LoadingScreen(); } weapons.clear(); @@ -721,8 +720,7 @@ void Game::Loadlevel(const std::string& name, bool tutorial) weapons.push_back(Weapon(type, 0)); } - if (visibleloading) - LoadingScreen(); + Game::LoadingScreen(); funpackf(tfile, "Bf Bf Bf", &Person::players[0]->armorhead, &Person::players[0]->armorhigh, &Person::players[0]->armorlow); funpackf(tfile, "Bf Bf Bf", &Person::players[0]->protectionhead, &Person::players[0]->protectionhigh, &Person::players[0]->protectionlow); @@ -781,20 +779,14 @@ void Game::Loadlevel(const std::string& name, bool tutorial) Hotspot::hotspots.clear(); } - if (visibleloading) - LoadingScreen(); + Game::LoadingScreen(); if (!stealthloading) { Object::ComputeCenter(); - - if (visibleloading) - LoadingScreen(); - Object::ComputeRadius(); } - if (visibleloading) - LoadingScreen(); + Game::LoadingScreen(); int numplayers; funpackf(tfile, "Bi", &numplayers); @@ -810,8 +802,7 @@ void Game::Loadlevel(const std::string& name, bool tutorial) cerr << "Invalid Person found in " << name << endl; } } - if (visibleloading) - LoadingScreen(); + Game::LoadingScreen(); funpackf(tfile, "Bi", &numpathpoints); if (numpathpoints > 30 || numpathpoints < 0) @@ -822,8 +813,7 @@ void Game::Loadlevel(const std::string& name, bool tutorial) funpackf(tfile, "Bi", &pathpointconnect[j][k]); } } - if (visibleloading) - LoadingScreen(); + Game::LoadingScreen(); funpackf(tfile, "Bf Bf Bf Bf", &mapcenter.x, &mapcenter.y, &mapcenter.z, &mapradius); @@ -835,18 +825,15 @@ void Game::Loadlevel(const std::string& name, bool tutorial) if (!stealthloading) { Object::AddObjectsToTerrain(); terrain.DoShadows(); - if (visibleloading) - LoadingScreen(); + Game::LoadingScreen(); Object::DoShadows(); - if (visibleloading) - LoadingScreen(); + Game::LoadingScreen(); } fclose(tfile); for (unsigned i = 0; i < Person::players.size(); i++) { - if (visibleloading) - LoadingScreen(); + Game::LoadingScreen(); if (i == 0) { Person::players[i]->burnt = 0; Person::players[i]->bled = 0; @@ -901,8 +888,7 @@ void Game::Loadlevel(const std::string& name, bool tutorial) } - if (visibleloading) - LoadingScreen(); + Game::LoadingScreen(); if (cellophane) { Person::players[i]->proportionhead.z = 0; @@ -968,8 +954,7 @@ void Game::Loadlevel(const std::string& name, bool tutorial) hawkcoords = Person::players[0]->coords; hawkcoords.y += 30; - if (visibleloading) - LoadingScreen(); + Game::LoadingScreen(); LOG("Starting background music..."); @@ -993,7 +978,7 @@ void Game::Loadlevel(const std::string& name, bool tutorial) leveltime = 0; wonleveltime = 0; - visibleloading = 0; + visibleloading = false; } void doDevKeys() @@ -5618,7 +5603,7 @@ void Game::TickOnceAfter() LoadStuff(); whichchoice = 0; actuallevel = campaignlevels[actuallevel].nextlevel.front(); - visibleloading = 1; + visibleloading = true; stillloading = 1; Loadlevel(campaignlevels[actuallevel].mapname.c_str()); campaign = 1; diff --git a/Source/Globals.cpp b/Source/Globals.cpp index df62ea9..7184ce2 100644 --- a/Source/Globals.cpp +++ b/Source/Globals.cpp @@ -25,7 +25,7 @@ along with Lugaru. If not, see . #include #include -bool visibleloading = 0; +bool visibleloading = false; float volume = 0; bool ismotionblur = false; diff --git a/Source/Graphic/Models.cpp b/Source/Graphic/Models.cpp index 1e59472..4120864 100644 --- a/Source/Graphic/Models.cpp +++ b/Source/Graphic/Models.cpp @@ -30,8 +30,6 @@ extern float fadestart; extern float texdetail; extern bool decals; -extern bool visibleloading; - int Model::LineCheck(XYZ *p1, XYZ *p2, XYZ *p, XYZ *move, float *rotate) { static int j; @@ -474,8 +472,7 @@ bool Model::load(const std::string& filename, bool texture ) LOG(std::string("Loading model...") + filename); - if (visibleloading) - Game::LoadingScreen(); + Game::LoadingScreen(); type = normaltype; color = 0; @@ -819,8 +816,7 @@ void Model::Rotate(float xang, float yang, float zang) void Model::CalculateNormals(bool facenormalise) { - if (visibleloading) - Game::LoadingScreen(); + Game::LoadingScreen(); static int i; if (type != normaltype && type != decalstype) return; diff --git a/Source/Menu/Menu.cpp b/Source/Menu/Menu.cpp index bac46a6..54f6fc5 100644 --- a/Source/Menu/Menu.cpp +++ b/Source/Menu/Menu.cpp @@ -712,7 +712,7 @@ void Menu::Tick() LoadStuff(); whichchoice = selected - NB_CAMPAIGN_MENU_ITEM - Account::active().getCampaignChoicesMade(); actuallevel = (Account::active().getCampaignChoicesMade() > 0 ? campaignlevels[Account::active().getCampaignChoicesMade() - 1].nextlevel[whichchoice] : 0); - visibleloading = 1; + visibleloading = true; stillloading = 1; Loadlevel(campaignlevels[actuallevel].mapname.c_str()); campaign = 1; diff --git a/Source/Utils/ImageIO.cpp b/Source/Utils/ImageIO.cpp index 508c10f..95f8954 100644 --- a/Source/Utils/ImageIO.cpp +++ b/Source/Utils/ImageIO.cpp @@ -28,8 +28,6 @@ along with Lugaru. If not, see . #include #include -extern bool visibleloading; - /* These two are needed for screenshot */ extern int kContextWidth; extern int kContextHeight; @@ -51,9 +49,7 @@ ImageRec::~ImageRec() bool load_image(const char *file_name, ImageRec &tex) { - if (visibleloading) { - Game::LoadingScreen(); - } + Game::LoadingScreen(); if ( tex.data == NULL ) { return false; diff --git a/Source/main.cpp b/Source/main.cpp index 8463907..1ee05a5 100644 --- a/Source/main.cpp +++ b/Source/main.cpp @@ -53,7 +53,6 @@ extern int mainmenu; extern float slomospeed; extern float slomofreq; -extern bool visibleloading; extern int difficulty;