From 9973afbac6e763e97f575d8a875073dfb0977b7a Mon Sep 17 00:00:00 2001 From: fgenesis Date: Mon, 9 Mar 2015 04:55:03 +0100 Subject: [PATCH] Allow custom capes in mods --- Aquaria/Avatar.cpp | 28 ++++++---------------------- BBGE/Core.cpp | 2 +- BBGE/RenderObject.cpp | 5 ++++- BBGE/Texture.cpp | 6 ++++++ BBGE/Texture.h | 2 +- 5 files changed, 18 insertions(+), 25 deletions(-) diff --git a/Aquaria/Avatar.cpp b/Aquaria/Avatar.cpp index 6642d42..2455e20 100644 --- a/Aquaria/Avatar.cpp +++ b/Aquaria/Avatar.cpp @@ -4110,33 +4110,17 @@ void Avatar::refreshNormalForm() if (c.empty()) c = "Naija"; refreshModel("Naija", c); - if (true) + if(hair) { - if (hair) - hair->alphaMod = 1.0; + hair->alphaMod = 1.0; if (!c.empty() && c!="Naija") { - if (exists(core->getBaseTextureDirectory() + "naija/cape-"+c+".png")) - { - if (hair) - hair->setTexture("naija/cape-"+c); - } - else - { - if (hair) - hair->alphaMod = 0; - } + hair->setTexture("naija/cape-"+c); + if (Texture::textureError != TEXERR_OK) + hair->alphaMod = 0; } else - { - if (hair) - hair->setTexture("naija/cape"); - } - } - else - { - if (hair) - hair->alphaMod = 0.0; + hair->setTexture("naija/cape"); } } diff --git a/BBGE/Core.cpp b/BBGE/Core.cpp index 7a0d1a6..a12c63e 100644 --- a/BBGE/Core.cpp +++ b/BBGE/Core.cpp @@ -4484,7 +4484,7 @@ Texture *Core::doTextureAdd(const std::string &texture, const std::string &loadN { t->addRef(); - Texture::textureError = TEXERR_OK; + Texture::textureError = t->failed ? TEXERR_FILENOTFOUND : TEXERR_OK; /* std::ostringstream os; diff --git a/BBGE/RenderObject.cpp b/BBGE/RenderObject.cpp index 322c2aa..b66d817 100644 --- a/BBGE/RenderObject.cpp +++ b/BBGE/RenderObject.cpp @@ -1328,8 +1328,11 @@ void RenderObject::setTexture(const std::string &n) if (name.empty()) return; - if(texture && texture->name == core->getInternalTextureName(name)) + if(texture && !texture->failed && texture->name == core->getInternalTextureName(name)) + { + Texture::textureError = TEXERR_OK; return; // no texture change + } Texture *oldtex = texture; Texture *t = core->addTexture(name); diff --git a/BBGE/Texture.cpp b/BBGE/Texture.cpp index 9f04a4c..29336b9 100644 --- a/BBGE/Texture.cpp +++ b/BBGE/Texture.cpp @@ -68,6 +68,7 @@ Texture::Texture() : Resource() repeat = false; repeating = false; + failed = false; pngSetStandardOrientation(0); ow = oh = -1; @@ -273,11 +274,13 @@ void Texture::reload() void Texture::load(std::string file) { Texture::textureError = TEXERR_OK; + failed = false; if (file.size()<4) { errorLog("Texture Name is Empty or Too Short"); Texture::textureError = TEXERR_FILENOTFOUND; + failed = true; return; } @@ -365,6 +368,7 @@ void Texture::load(std::string file) Texture::textureError = TEXERR_FILENOTFOUND; width = 64; height = 64; + failed = true; } } else @@ -375,6 +379,7 @@ void Texture::load(std::string file) Texture::textureError = TEXERR_FILENOTFOUND; width = 64; height = 64; + failed = true; } } @@ -464,6 +469,7 @@ void Texture::loadPNG(const std::string &file) width = 64; height = 64; Texture::textureError = TEXERR_FILENOTFOUND; + failed = true; } if(memptr) diff --git a/BBGE/Texture.h b/BBGE/Texture.h index 68b43fc..e27c242 100644 --- a/BBGE/Texture.h +++ b/BBGE/Texture.h @@ -62,7 +62,7 @@ public: static ImageTGA *TGAloadMem(void *mem, int size); static bool useMipMaps; - bool repeat, repeating; + bool repeat, repeating, failed; #ifdef BBGE_BUILD_OPENGL static GLint filter;