From b1760253fdb3e5b9b38c3bcf3d5f154044536b0c Mon Sep 17 00:00:00 2001 From: mathusummut Date: Thu, 28 Jun 2018 21:36:10 +0200 Subject: [PATCH] Implemented the new g3d spec --- source/g3d_viewer/renderer.cpp | 57 --------- source/g3d_viewer/renderer.h | 22 +--- source/glest_game/global/config.cpp | 95 ++++---------- source/glest_game/global/config.h | 5 +- source/glest_game/global/lang.cpp | 16 ++- source/glest_game/graphics/renderer.cpp | 62 +--------- source/glest_game/graphics/renderer.h | 20 +-- source/glest_game/main/main.cpp | 2 +- .../menu/menu_state_connected_game.cpp | 2 +- .../menu/menu_state_custom_game.cpp | 2 +- .../include/graphics/gl/model_renderer_gl.h | 21 ++++ source/shared_lib/include/graphics/model.h | 8 +- .../include/graphics/model_renderer.h | 1 - source/shared_lib/include/util/properties.h | 2 +- .../sources/feathery_ftp/ftpTargetWin32.c | 8 +- .../sources/graphics/gl/font_textFTGL.cpp | 4 +- .../sources/graphics/gl/model_renderer_gl.cpp | 62 ++++++++++ source/shared_lib/sources/graphics/model.cpp | 116 +++++++++--------- source/shared_lib/sources/map/map_preview.cpp | 2 +- .../sources/platform/common/base_thread.cpp | 5 +- .../platform/common/simple_threads.cpp | 14 +-- .../sources/platform/sdl/thread.cpp | 25 ++-- source/shared_lib/sources/util/conversion.cpp | 4 +- source/shared_lib/sources/util/properties.cpp | 8 +- 24 files changed, 225 insertions(+), 338 deletions(-) diff --git a/source/g3d_viewer/renderer.cpp b/source/g3d_viewer/renderer.cpp index 53e6177e6..a3201c4af 100644 --- a/source/g3d_viewer/renderer.cpp +++ b/source/g3d_viewer/renderer.cpp @@ -30,63 +30,6 @@ namespace Shared { int Renderer::windowW = 640; int Renderer::windowH = 480; - // =============================================== - // class MeshCallbackTeamColor - // =============================================== - - void MeshCallbackTeamColor::execute(const Mesh *mesh) { - //team color - if (mesh->getCustomTexture() && teamTexture != NULL) { - //texture 0 - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); - - //set color to interpolation - glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_INTERPOLATE); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE); - glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_TEXTURE1); - glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB, GL_TEXTURE); - glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB, GL_SRC_ALPHA); - //set alpha to 1 - glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_TEXTURE); - glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA); - - //texture 1 - glActiveTexture(GL_TEXTURE1); - glMultiTexCoord2f(GL_TEXTURE1, 0.f, 0.f); - glEnable(GL_TEXTURE_2D); - - glBindTexture(GL_TEXTURE_2D, static_cast(teamTexture)->getHandle()); - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); - - glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE); - - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_PRIMARY_COLOR); - glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR); - - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_PREVIOUS); - glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR); - - //Interpolate alpha with alpha of previous texture - glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_INTERPOLATE); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_TEXTURE); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA, GL_PREVIOUS); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_ALPHA, GL_TEXTURE); - glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA); - glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, GL_SRC_ALPHA); - glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_ALPHA, GL_SRC_ALPHA); - - glActiveTexture(GL_TEXTURE0); - } else { - glActiveTexture(GL_TEXTURE1); - glDisable(GL_TEXTURE_2D); - glActiveTexture(GL_TEXTURE0); - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - } - } - // =============================================== // class Renderer // =============================================== diff --git a/source/g3d_viewer/renderer.h b/source/g3d_viewer/renderer.h index 0811b7443..3cc2f67a9 100644 --- a/source/g3d_viewer/renderer.h +++ b/source/g3d_viewer/renderer.h @@ -18,6 +18,7 @@ #endif #include "model_renderer.h" +#include "model_renderer_gl.h" #include "texture_manager.h" #include "model.h" #include "texture.h" @@ -37,6 +38,7 @@ using Shared::Graphics::Texture2D; using Shared::Graphics::ParticleRenderer; using Shared::Graphics::ParticleManager; using Shared::Graphics::ParticleSystem; +using Shared::Graphics::Gl::MeshCallbackTeamColor; //#include "model_renderer.h" using Shared::Graphics::MeshCallback; @@ -47,26 +49,6 @@ using namespace Shared::Graphics; namespace Shared { namespace G3dViewer { - - // =============================================== - // class MeshCallbackTeamColor - // =============================================== - - class MeshCallbackTeamColor : public MeshCallback { - private: - const Texture *teamTexture; - bool hasAlpha; - - public: - MeshCallbackTeamColor() : MeshCallback() { - teamTexture = NULL; - } - void setTeamTexture(const Texture *teamTexture) { - this->teamTexture = teamTexture; - } - virtual void execute(const Mesh *mesh); - }; - // =============================== // class Renderer // =============================== diff --git a/source/glest_game/global/config.cpp b/source/glest_game/global/config.cpp index 10686ba4b..c50681646 100644 --- a/source/glest_game/global/config.cpp +++ b/source/glest_game/global/config.cpp @@ -123,8 +123,6 @@ namespace Glest { // class Config // ===================================================== - const string defaultNotFoundValue = "~~NOT FOUND~~"; - map < ConfigType, Config > Config::configList; Config::Config() { @@ -287,18 +285,13 @@ namespace Glest { } if (cfgType.first == cfgMainGame) { - if (properties.first. - getString("UserData_Root", - defaultNotFoundValue.c_str()) != defaultNotFoundValue) { + if (properties.first.hasString("UserData_Root")) { string userData = properties.first.getString("UserData_Root"); if (userData != "") { endPathWithSlash(userData); } fileName.second = userData + fileNameParameter.second; - } else if (properties.first. - getString("UserOverrideFile", - defaultNotFoundValue.c_str()) != - defaultNotFoundValue) { + } else if (properties.first.hasString("UserOverrideFile")) { string userData = properties.first.getString("UserOverrideFile"); if (userData != "") { endPathWithSlash(userData); @@ -312,18 +305,13 @@ namespace Glest { } else if (cfgType.first == cfgMainKeys) { Config & mainCfg = Config::getInstance(); - if (mainCfg. - getString("UserData_Root", - defaultNotFoundValue.c_str()) != defaultNotFoundValue) { + if (mainCfg.hasString("UserData_Root")) { string userData = mainCfg.getString("UserData_Root"); if (userData != "") { endPathWithSlash(userData); } fileName.second = userData + fileNameParameter.second; - } else if (mainCfg. - getString("UserOverrideFile", - defaultNotFoundValue.c_str()) != - defaultNotFoundValue) { + } else if (mainCfg.hasString("UserOverrideFile")) { string userData = mainCfg.getString("UserOverrideFile"); if (userData != "") { endPathWithSlash(userData); @@ -487,29 +475,21 @@ namespace Glest { } int Config::getInt(const char *key, const char *defaultValueIfNotFound) const { - if (tempProperties.getString(key, defaultNotFoundValue.c_str()) != - defaultNotFoundValue) { + if (tempProperties.hasString(key)) { return tempProperties.getInt(key, defaultValueIfNotFound); } - if (fileLoaded.second == true && - properties.second.getString(key, - defaultNotFoundValue.c_str()) != - defaultNotFoundValue) { + if (fileLoaded.second == true && properties.second.hasString(key)) { return properties.second.getInt(key, defaultValueIfNotFound); } return properties.first.getInt(key, defaultValueIfNotFound); } bool Config::getBool(const char *key, const char *defaultValueIfNotFound) const { - if (tempProperties.getString(key, defaultNotFoundValue.c_str()) != - defaultNotFoundValue) { + if (tempProperties.hasString(key)) { return tempProperties.getBool(key, defaultValueIfNotFound); } - if (fileLoaded.second == true && - properties.second.getString(key, - defaultNotFoundValue.c_str()) != - defaultNotFoundValue) { + if (fileLoaded.second == true && properties.second.hasString(key)) { return properties.second.getBool(key, defaultValueIfNotFound); } @@ -518,32 +498,23 @@ namespace Glest { float Config::getFloat(const char *key, const char *defaultValueIfNotFound) const { - if (tempProperties.getString(key, defaultNotFoundValue.c_str()) != - defaultNotFoundValue) { + if (tempProperties.hasString(key)) { return tempProperties.getFloat(key, defaultValueIfNotFound); } - if (fileLoaded.second == true && - properties.second.getString(key, - defaultNotFoundValue.c_str()) != - defaultNotFoundValue) { + if (fileLoaded.second == true && properties.second.hasString(key)) { return properties.second.getFloat(key, defaultValueIfNotFound); } return properties.first.getFloat(key, defaultValueIfNotFound); } - const string Config::getString(const char *key, - const char *defaultValueIfNotFound) const { - if (tempProperties.getString(key, defaultNotFoundValue.c_str()) != - defaultNotFoundValue) { + const string Config::getString(const char *key, const char *defaultValueIfNotFound) const { + if (tempProperties.hasString(key)) { return tempProperties.getString(key, defaultValueIfNotFound); } - if (fileLoaded.second == true && - properties.second.getString(key, - defaultNotFoundValue.c_str()) != - defaultNotFoundValue) { + if (fileLoaded.second == true && properties.second.hasString(key)) { return properties.second.getString(key, defaultValueIfNotFound); } @@ -552,15 +523,11 @@ namespace Glest { int Config::getInt(const string & key, const char *defaultValueIfNotFound) const { - if (tempProperties.getString(key, defaultNotFoundValue.c_str()) != - defaultNotFoundValue) { + if (tempProperties.hasString(key)) { return tempProperties.getInt(key, defaultValueIfNotFound); } - if (fileLoaded.second == true && - properties.second.getString(key, - defaultNotFoundValue.c_str()) != - defaultNotFoundValue) { + if (fileLoaded.second == true && properties.second.hasString(key)) { return properties.second.getInt(key, defaultValueIfNotFound); } @@ -569,15 +536,12 @@ namespace Glest { bool Config::getBool(const string & key, const char *defaultValueIfNotFound) const { - if (tempProperties.getString(key, defaultNotFoundValue.c_str()) != - defaultNotFoundValue) { + if (tempProperties.hasString(key)) { return tempProperties.getBool(key, defaultValueIfNotFound); } if (fileLoaded.second == true && - properties.second.getString(key, - defaultNotFoundValue.c_str()) != - defaultNotFoundValue) { + properties.second.hasString(key)) { return properties.second.getBool(key, defaultValueIfNotFound); } @@ -586,15 +550,11 @@ namespace Glest { float Config::getFloat(const string & key, const char *defaultValueIfNotFound) const { - if (tempProperties.getString(key, defaultNotFoundValue.c_str()) != - defaultNotFoundValue) { + if (tempProperties.hasString(key)) { return tempProperties.getFloat(key, defaultValueIfNotFound); } - if (fileLoaded.second == true && - properties.second.getString(key, - defaultNotFoundValue.c_str()) != - defaultNotFoundValue) { + if (fileLoaded.second == true && properties.second.hasString(key)) { return properties.second.getFloat(key, defaultValueIfNotFound); } @@ -603,21 +563,21 @@ namespace Glest { const string Config::getString(const string & key, const char *defaultValueIfNotFound) const { - if (tempProperties.getString(key, defaultNotFoundValue.c_str()) != - defaultNotFoundValue) { + if (tempProperties.hasString(key)) { return tempProperties.getString(key, defaultValueIfNotFound); } - if (fileLoaded.second == true && - properties.second.getString(key, - defaultNotFoundValue.c_str()) != - defaultNotFoundValue) { + if (fileLoaded.second == true && properties.second.hasString(key)) { return properties.second.getString(key, defaultValueIfNotFound); } return properties.first.getString(key, defaultValueIfNotFound); } + const bool Config::hasString(const char *key) const { + return getString(key).length() != 0; + } + SDL_Keycode Config::translateStringToSDLKey(const string & value) const { SDL_Keycode result = SDLK_UNKNOWN; @@ -698,10 +658,7 @@ namespace Glest { } SDL_Keycode Config::getSDLKey(const char *key) const { - if (fileLoaded.second == true && - properties.second.getString(key, - defaultNotFoundValue.c_str()) != - defaultNotFoundValue) { + if (fileLoaded.second == true && properties.second.hasString(key)) { string value = properties.second.getString(key); return translateStringToSDLKey(value); diff --git a/source/glest_game/global/config.h b/source/glest_game/global/config.h index df48c41ae..22c356c8e 100644 --- a/source/glest_game/global/config.h +++ b/source/glest_game/global/config.h @@ -129,9 +129,8 @@ namespace Glest { NULL) const; float getFloat(const char *key, const char *defaultValueIfNotFound = NULL) const; - const string getString(const char *key, - const char *defaultValueIfNotFound = - NULL) const; + const string getString(const char *key, const char *defaultValueIfNotFound = "") const; + const bool hasString(const char *key) const; //char getCharKey(const char *key) const; SDL_Keycode getSDLKey(const char *key) const; diff --git a/source/glest_game/global/lang.cpp b/source/glest_game/global/lang.cpp index 10f6c344d..987996627 100644 --- a/source/glest_game/global/lang.cpp +++ b/source/glest_game/global/lang.cpp @@ -546,14 +546,15 @@ namespace Glest { false); } //string result2 = otherLanguageStrings[uselanguage].getString(s); - gameStringsAllLanguages[uselanguage].getString(s); + result = gameStringsAllLanguages[uselanguage].getString(s).length() != 0; //printf("#b result2 [%s]\n",result2.c_str()); - - result = true; } else { //string result2 = strings.getString(s); - gameStringsAllLanguages[this->language].getString(s); - result = true; + result = gameStringsAllLanguages[this->language].getString(s).length() != 0; + } + if (!result && fallbackToDefault == true && uselanguage != DEFAULT_LANGUAGE + && this->language != DEFAULT_LANGUAGE) { + result = hasString(s, DEFAULT_LANGUAGE, false); } } catch (exception & ex) { if (gameStringsAllLanguages[this->language].getpath() != "") { @@ -568,8 +569,6 @@ namespace Glest { if (fallbackToDefault == true && uselanguage != DEFAULT_LANGUAGE && this->language != DEFAULT_LANGUAGE) { result = hasString(s, DEFAULT_LANGUAGE, false); - } else { - } } return result; @@ -650,8 +649,7 @@ namespace Glest { bool Lang::hasScenarioString(const string & s) { bool result = false; try { - scenarioStrings.getString(s); - result = true; + result = scenarioStrings.getString(s).length() != 0; } catch (exception & ex) { if (scenarioStrings.getpath() != "") { if (SystemFlags::VERBOSE_MODE_ENABLED) diff --git a/source/glest_game/graphics/renderer.cpp b/source/glest_game/graphics/renderer.cpp index 66544f3d1..ec722b52d 100644 --- a/source/glest_game/graphics/renderer.cpp +++ b/source/glest_game/graphics/renderer.cpp @@ -50,66 +50,6 @@ namespace Glest { pti_N_OVER_D_IS_OUTSIDE }; - // ===================================================== - // class MeshCallbackTeamColor - // ===================================================== - - bool MeshCallbackTeamColor::noTeamColors = false; - - void MeshCallbackTeamColor::execute(const Mesh *mesh) { - //team color - if (mesh->getCustomTexture() && teamTexture != NULL && - MeshCallbackTeamColor::noTeamColors == false) { - //texture 0 - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); - - //set color to interpolation - glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_INTERPOLATE); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE); - glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_TEXTURE1); - glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB, GL_TEXTURE); - glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB, GL_SRC_ALPHA); - //set alpha to 1 - glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_TEXTURE); - glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA); - - //texture 1 - glActiveTexture(GL_TEXTURE1); - glMultiTexCoord2f(GL_TEXTURE1, 0.f, 0.f); - glEnable(GL_TEXTURE_2D); - - glBindTexture(GL_TEXTURE_2D, static_cast(teamTexture)->getHandle()); - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); - - glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE); - - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_PRIMARY_COLOR); - glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR); - - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_PREVIOUS); - glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR); - - //Interpolate alpha with alpha of previous texture - glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_INTERPOLATE); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_TEXTURE); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA, GL_PREVIOUS); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_ALPHA, GL_TEXTURE); - glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA); - glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, GL_SRC_ALPHA); - glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_ALPHA, GL_SRC_ALPHA); - - glActiveTexture(GL_TEXTURE0); - } else { - glActiveTexture(GL_TEXTURE1); - glDisable(GL_TEXTURE_2D); - glActiveTexture(GL_TEXTURE0); - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - } - } - // =========================================================== // class Renderer // =========================================================== @@ -349,7 +289,7 @@ namespace Glest { SystemFlags::OutputDebug(SystemFlags::debugError, szBuf); if (SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem, szBuf); - throw megaglest_runtime_error(szBuf); + //throw megaglest_runtime_error(szBuf); } } diff --git a/source/glest_game/graphics/renderer.h b/source/glest_game/graphics/renderer.h index 00ee3e5ce..c5f5d1b18 100644 --- a/source/glest_game/graphics/renderer.h +++ b/source/glest_game/graphics/renderer.h @@ -29,6 +29,7 @@ #include "texture.h" #include "model_manager.h" #include "graphics_factory_gl.h" +#include "model_renderer_gl.h" #include "font_manager.h" #include "camera.h" #include @@ -71,25 +72,6 @@ namespace Glest { class ConsoleLineInfo; class SurfaceCell; class Program; - // ===================================================== - // class MeshCallbackTeamColor - // ===================================================== - - class MeshCallbackTeamColor : public MeshCallback { - private: - const Texture *teamTexture; - - public: - MeshCallbackTeamColor() : MeshCallback() { - teamTexture = NULL; - } - void setTeamTexture(const Texture *teamTexture) { - this->teamTexture = teamTexture; - } - virtual void execute(const Mesh *mesh); - - static bool noTeamColors; - }; // =========================================================== // class Renderer diff --git a/source/glest_game/main/main.cpp b/source/glest_game/main/main.cpp index 231590a9f..adf2d9be0 100644 --- a/source/glest_game/main/main.cpp +++ b/source/glest_game/main/main.cpp @@ -7361,7 +7361,7 @@ namespace gameSettings = &startupGameSettings; gameSettings->setMap(autoloadMapName); gameSettings->setTileset(tileset); - gameSettings->setTech("megapack"); + gameSettings->setTech("zetapack"); gameSettings->setDefaultUnits(false); gameSettings->setDefaultResources(false); gameSettings->setDefaultVictoryConditions(true); diff --git a/source/glest_game/menu/menu_state_connected_game.cpp b/source/glest_game/menu/menu_state_connected_game.cpp index 369727022..ddd9d7d02 100644 --- a/source/glest_game/menu/menu_state_connected_game.cpp +++ b/source/glest_game/menu/menu_state_connected_game.cpp @@ -8080,7 +8080,7 @@ namespace Glest { //printf("TECHS i = %d results [%s] scenario [%s]\n",i,results[i].c_str(),scenario.c_str()); results.at(i) = formatString(results.at(i)); - if (config.getString("InitialTechTree", "Megapack") == + if (config.getString("InitialTechTree", "Zetapack") == results.at(i)) { initialTechSelection = i; } diff --git a/source/glest_game/menu/menu_state_custom_game.cpp b/source/glest_game/menu/menu_state_custom_game.cpp index b77651390..8e3d3509e 100644 --- a/source/glest_game/menu/menu_state_custom_game.cpp +++ b/source/glest_game/menu/menu_state_custom_game.cpp @@ -6088,7 +6088,7 @@ namespace Glest { //printf("TECHS i = %d results [%s] scenario [%s]\n",i,results[i].c_str(),scenario.c_str()); results.at(i) = formatString(results.at(i)); - if (config.getString("InitialTechTree", "Megapack") == + if (config.getString("InitialTechTree", "Zetapack") == results.at(i)) { initialTechSelection = i; } diff --git a/source/shared_lib/include/graphics/gl/model_renderer_gl.h b/source/shared_lib/include/graphics/gl/model_renderer_gl.h index 306920aaf..e3fb4bf84 100644 --- a/source/shared_lib/include/graphics/gl/model_renderer_gl.h +++ b/source/shared_lib/include/graphics/gl/model_renderer_gl.h @@ -12,10 +12,14 @@ #ifndef _SHARED_GRAPHICS_GL_MODELRENDERERGL_H_ #define _SHARED_GRAPHICS_GL_MODELRENDERERGL_H_ +#include #include "model_renderer.h" #include "model.h" #include "opengl.h" #include "leak_dumper.h" +#include "texture_gl.h" + +using ::Shared::Graphics::Gl::Texture2DGl; namespace Shared { namespace Graphics { @@ -52,6 +56,23 @@ namespace Shared { void renderMeshNormals(Mesh *mesh); }; + class MeshCallbackTeamColor : public MeshCallback { + private: + const Texture *teamTexture; + + public: + MeshCallbackTeamColor() : MeshCallback() { + teamTexture = NULL; + } + + void setTeamTexture(const Texture *teamTexture) { + this->teamTexture = teamTexture; + } + + virtual void execute(const Mesh *mesh); + + static bool noTeamColors; + }; } } }//end namespace diff --git a/source/shared_lib/include/graphics/model.h b/source/shared_lib/include/graphics/model.h index 05f657bd5..e5fc863e5 100644 --- a/source/shared_lib/include/graphics/model.h +++ b/source/shared_lib/include/graphics/model.h @@ -46,7 +46,7 @@ namespace Shared { class Mesh { private: //mesh data - Texture2D *textures[meshTextureCount]; + Texture2D * textures[meshTextureCount]; bool texturesOwned[meshTextureCount]; string texturePaths[meshTextureCount]; @@ -75,6 +75,7 @@ namespace Shared { bool customColor; bool noSelect; bool glow; + uint8 factionColorOpacity; uint32 textureFlags; @@ -175,6 +176,9 @@ namespace Shared { bool getCustomTexture() const { return customColor; } + uint8 getFactionColorOpacity() const { + return factionColorOpacity; + } bool getNoSelect() const { return noSelect; } @@ -235,7 +239,7 @@ namespace Shared { class Model { private: - TextureManager *textureManager; + TextureManager * textureManager; private: uint8 fileVersion; diff --git a/source/shared_lib/include/graphics/model_renderer.h b/source/shared_lib/include/graphics/model_renderer.h index 66cdddcae..1348cbec7 100644 --- a/source/shared_lib/include/graphics/model_renderer.h +++ b/source/shared_lib/include/graphics/model_renderer.h @@ -72,7 +72,6 @@ namespace Shared { virtual void render(Model *model, int renderMode = rmNormal, float alpha = 1.0f) = 0; virtual void renderNormalsOnly(Model *model) = 0; }; - } }//end namespace diff --git a/source/shared_lib/include/util/properties.h b/source/shared_lib/include/util/properties.h index badff4c21..6ddaf0690 100644 --- a/source/shared_lib/include/util/properties.h +++ b/source/shared_lib/include/util/properties.h @@ -115,7 +115,7 @@ namespace Shared { float getFloat(const string &key, const char *defaultValueIfNotFound = NULL) const; float getFloat(const string &key, float min, float max, const char *defaultValueIfNotFound = NULL) const; - const string getString(const string &key, const char *defaultValueIfNotFound = NULL) const; + const string getString(const string &key, const char *defaultValueIfNotFound = "") const; int getInt(const char *key, const char *defaultValueIfNotFound = NULL) const; bool getBool(const char *key, const char *defaultValueIfNotFound = NULL) const; diff --git a/source/shared_lib/sources/feathery_ftp/ftpTargetWin32.c b/source/shared_lib/sources/feathery_ftp/ftpTargetWin32.c index 2639b4f67..dda5d15f8 100644 --- a/source/shared_lib/sources/feathery_ftp/ftpTargetWin32.c +++ b/source/shared_lib/sources/feathery_ftp/ftpTargetWin32.c @@ -107,14 +107,14 @@ const char* ftpReadDir(void* dirHandle) { else strcat(p->path, "*"); - p->findHandle = FindFirstFile(p->path, &findData); + p->findHandle = FindFirstFileA(p->path, &findData); if (p->findHandle != INVALID_HANDLE_VALUE) { strcpy(p->path, findData.cFileName); return p->path; } return NULL; } else { - if (FindNextFile(p->findHandle, &findData)) { + if (FindNextFileA(p->findHandle, &findData)) { strcpy(p->path, findData.cFileName); return p->path; } @@ -186,11 +186,11 @@ int ftpStat(const char* path, ftpPathInfo_S *info) { int ftpMakeDir(const char* path) { - return !CreateDirectory(path, NULL); + return !CreateDirectoryA(path, NULL); } int ftpRemoveDir(const char* path) { - return !RemoveDirectory(path); + return !RemoveDirectoryA(path); } diff --git a/source/shared_lib/sources/graphics/gl/font_textFTGL.cpp b/source/shared_lib/sources/graphics/gl/font_textFTGL.cpp index b1db77eb1..0d9b8d13c 100644 --- a/source/shared_lib/sources/graphics/gl/font_textFTGL.cpp +++ b/source/shared_lib/sources/graphics/gl/font_textFTGL.cpp @@ -239,7 +239,7 @@ namespace Shared { ftFont->Render(str, len); //assertGl(); - GLenum error = glGetError(); + /*GLenum error =*/ glGetError(); /*if (error != GL_NO_ERROR) { printf("\n[%s::%s] Line %d Error = %d [%s] for text [%s]\n", __FILE__, __FUNCTION__, __LINE__, error, gluErrorString(error), str); fflush(stdout); @@ -307,7 +307,7 @@ namespace Shared { //if(result == -1000) { FTBBox box = ftFont->BBox(TextFTGL::langHeightText.c_str()); - GLenum error = glGetError(); + /*GLenum error =*/ glGetError(); /*if (error != GL_NO_ERROR) { printf("\n[%s::%s] Line %d Error = %d [%s] for text [%s]\n", __FILE__, __FUNCTION__, __LINE__, error, gluErrorString(error), str); fflush(stdout); diff --git a/source/shared_lib/sources/graphics/gl/model_renderer_gl.cpp b/source/shared_lib/sources/graphics/gl/model_renderer_gl.cpp index 8328f905f..f61775a3b 100644 --- a/source/shared_lib/sources/graphics/gl/model_renderer_gl.cpp +++ b/source/shared_lib/sources/graphics/gl/model_renderer_gl.cpp @@ -22,6 +22,68 @@ using namespace Shared::Platform; namespace Shared { namespace Graphics { namespace Gl { + bool MeshCallbackTeamColor::noTeamColors = false; + + void MeshCallbackTeamColor::execute(const Mesh *mesh) { + //team color + uint8 opacity = mesh->getFactionColorOpacity(); + if (!mesh->getCustomTexture() || opacity == 0 || teamTexture == NULL || MeshCallbackTeamColor::noTeamColors) { + glActiveTexture(GL_TEXTURE1); + glDisable(GL_TEXTURE_2D); + glActiveTexture(GL_TEXTURE0); + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + } else { + //texture 0 + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); + + //set color to interpolation + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_INTERPOLATE); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE); + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_TEXTURE1); + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB, GL_TEXTURE); + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB, GL_SRC_ALPHA); + //set alpha to 1 + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_TEXTURE); + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA); + + //texture 1 + glActiveTexture(GL_TEXTURE1); + glEnable(GL_TEXTURE_2D); + glMultiTexCoord2f(GL_TEXTURE1, 0.f, 0.f); + GLuint handle = static_cast(teamTexture)->getHandle(); + glBindTexture(GL_TEXTURE_2D, handle); + float color[4]; + color[0] = 1.0f; // Red + color[1] = 1.0f; // Green + color[2] = 1.0f; // Blue + color[3] = opacity * 0.00392156862f; // Alpha + glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, color); + + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); + + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE); + + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_PRIMARY_COLOR); + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR); + + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_PREVIOUS); + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR); + + //set alpha to 1 + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_INTERPOLATE); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_TEXTURE); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA, GL_PREVIOUS); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_ALPHA, GL_CONSTANT); + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA); + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, GL_SRC_ALPHA); + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_ALPHA, GL_SRC_ALPHA); + + glActiveTexture(GL_TEXTURE0); + } + } // ===================================================== // class MyClass diff --git a/source/shared_lib/sources/graphics/model.cpp b/source/shared_lib/sources/graphics/model.cpp index c0dbc3e7e..64dfba056 100644 --- a/source/shared_lib/sources/graphics/model.cpp +++ b/source/shared_lib/sources/graphics/model.cpp @@ -227,6 +227,7 @@ namespace Shared { customColor = false; noSelect = false; glow = false; + factionColorOpacity = 255; textureFlags = 0; @@ -335,28 +336,28 @@ namespace Shared { // Generate And Bind The Vertex Buffer glGenBuffersARB(1, (GLuint*) &m_nVBOVertices); // Get A Valid Name glBindBufferARB(GL_ARRAY_BUFFER_ARB, m_nVBOVertices); // Bind The Buffer - // Load The Data + // Load The Data glBufferDataARB(GL_ARRAY_BUFFER_ARB, sizeof(Vec3f)*frameCount*vertexCount, vertices, GL_STATIC_DRAW_ARB); glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); // Generate And Bind The Texture Coordinate Buffer glGenBuffersARB(1, (GLuint*) &m_nVBOTexCoords); // Get A Valid Name glBindBufferARB(GL_ARRAY_BUFFER_ARB, m_nVBOTexCoords); // Bind The Buffer - // Load The Data + // Load The Data glBufferDataARB(GL_ARRAY_BUFFER_ARB, sizeof(Vec2f)*vertexCount, texCoords, GL_STATIC_DRAW_ARB); glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); // Generate And Bind The Normal Buffer glGenBuffersARB(1, (GLuint*) &m_nVBONormals); // Get A Valid Name glBindBufferARB(GL_ARRAY_BUFFER_ARB, m_nVBONormals); // Bind The Buffer - // Load The Data + // Load The Data glBufferDataARB(GL_ARRAY_BUFFER_ARB, sizeof(Vec3f)*frameCount*vertexCount, normals, GL_STATIC_DRAW_ARB); glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); // Generate And Bind The Index Buffer glGenBuffersARB(1, (GLuint*) &m_nVBOIndexes); // Get A Valid Name glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, m_nVBOIndexes); // Bind The Buffer - // Load The Data + // Load The Data glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, sizeof(uint32)*indexCount, indices, GL_STATIC_DRAW_ARB); glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0); @@ -445,6 +446,7 @@ namespace Shared { customColor = false; noSelect = false; glow = false; + factionColorOpacity = 255; if (SystemFlags::VERBOSE_MODE_ENABLED) printf("Load v2, this = %p Found meshHeader.hasTexture = %d, texName [%s] mtDiffuse = %d meshIndex = %d modelFile [%s]\n", this, meshHeader.hasTexture, toLower(reinterpret_cast(meshHeader.texName)).c_str(), mtDiffuse, meshIndex, modelFile.c_str()); @@ -583,6 +585,7 @@ namespace Shared { //misc twoSided = (meshHeader.properties & mp3TwoSided) != 0; customColor = (meshHeader.properties & mp3CustomColor) != 0; + factionColorOpacity = 255 - (meshHeader.properties >> 24); noSelect = false; glow = false; @@ -779,6 +782,7 @@ namespace Shared { twoSided = (meshHeader.properties & mpfTwoSided) != 0; noSelect = (meshHeader.properties & mpfNoSelect) != 0; glow = (meshHeader.properties & mpfGlow) != 0; + factionColorOpacity = 255 - (meshHeader.properties >> 24); //material diffuseColor = Vec3f(meshHeader.diffuseColor); @@ -890,7 +894,7 @@ namespace Shared { //properties meshHeader.properties = 0; if (customColor) { - meshHeader.properties |= mpfCustomColor; + meshHeader.properties |= (255 - (factionColorOpacity << 24)) | mpfCustomColor; } if (twoSided) { meshHeader.properties |= mpfTwoSided; @@ -1516,6 +1520,7 @@ namespace Shared { dest->customColor = this->customColor; dest->noSelect = this->noSelect; dest->glow = this->glow; + dest->factionColorOpacity = this->factionColorOpacity; dest->textureFlags = this->textureFlags; @@ -1535,33 +1540,33 @@ namespace Shared { void Model::autoJoinMeshFrames() { /* - print "auto-joining compatible meshes..." - meshes = {} - for mesh in self.meshes: - key = (mesh.texture,mesh.frame_count,mesh.twoSided|mesh.customColour) - if key in meshes: - meshes[key].append(mesh) - else: - meshes[key] = [mesh] - for joinable in meshes.values(): - if len(joinable) < 2: continue - base = joinable[0] - print "\tjoining to",base - for mesh in joinable[1:]: - if base.index_count+mesh.index_count > 0xffff: - base = mesh - print "\tjoining to",base - continue - print "\t\t",mesh - for a,b in zip(base.frames,mesh.frames): - a.vertices.extend(b.vertices) - a.normals.extend(b.normals) - if base.texture: - base.textures.extend(mesh.textures) - base.indices.extend(index+base.vertex_count for index in mesh.indices) - base.vertex_count += mesh.vertex_count - base.index_count += mesh.index_count - self.meshes.remove(mesh) + print "auto-joining compatible meshes..." + meshes = {} + for mesh in self.meshes: + key = (mesh.texture,mesh.frame_count,mesh.twoSided|mesh.customColour) + if key in meshes: + meshes[key].append(mesh) + else: + meshes[key] = [mesh] + for joinable in meshes.values(): + if len(joinable) < 2: continue + base = joinable[0] + print "\tjoining to",base + for mesh in joinable[1:]: + if base.index_count+mesh.index_count > 0xffff: + base = mesh + print "\tjoining to",base + continue + print "\t\t",mesh + for a,b in zip(base.frames,mesh.frames): + a.vertices.extend(b.vertices) + a.normals.extend(b.normals) + if base.texture: + base.textures.extend(mesh.textures) + base.indices.extend(index+base.vertex_count for index in mesh.indices) + base.vertex_count += mesh.vertex_count + base.index_count += mesh.index_count + self.meshes.remove(mesh) */ @@ -1576,13 +1581,13 @@ namespace Shared { // Duplicate mesh vertices are considered to be those with the same // 1. texture 2. framecount 3. twosided flag value 4. same custom texture color - // It's possible the texture is missing and will be NULL - // if(mesh.getTextureFlags() & 1) { - // printf("Mesh has textures:\n"); - // for(unsigned int meshTexIndex = 0; meshTexIndex < meshTextureCount; ++meshTexIndex) { - // printf("Mesh texture index: %d [%p] [%s]\n",meshTexIndex,mesh.getTexture(meshTexIndex),(mesh.getTexture(meshTexIndex) != NULL ? mesh.getTexture(meshTexIndex)->getPath().c_str() : "n/a")); - // } - // } + // It's possible the texture is missing and will be NULL + // if(mesh.getTextureFlags() & 1) { + // printf("Mesh has textures:\n"); + // for(unsigned int meshTexIndex = 0; meshTexIndex < meshTextureCount; ++meshTexIndex) { + // printf("Mesh texture index: %d [%p] [%s]\n",meshTexIndex,mesh.getTexture(meshTexIndex),(mesh.getTexture(meshTexIndex) != NULL ? mesh.getTexture(meshTexIndex)->getPath().c_str() : "n/a")); + // } + // } string mesh_key = ((mesh.getTextureFlags() & 1) && mesh.getTexture(0) ? mesh.getTexture(0)->getPath() : "none"); mesh_key += string("_") + intToStr(mesh.getFrameCount()) + string("_") + intToStr(mesh.getTwoSided()) + @@ -1590,6 +1595,7 @@ namespace Shared { string("_") + intToStr(mesh.getNoSelect()) + string("_") + floatToStr(mesh.getOpacity()) + string("_") + floatToStr(mesh.getGlow()) + + string("_") + intToStr(mesh.getFactionColorOpacity()) + string("_") + mesh.getDiffuseColor().getString() + string("_") + mesh.getSpecularColor().getString() + string("_") + floatToStr(mesh.getSpecularPower()); @@ -1638,7 +1644,7 @@ namespace Shared { // mesh->copyInto(base, true, true); //} //else { - // Need to add verticies for each from from mesh to base + // Need to add verticies for each from from mesh to base uint32 originalBaseVertexCount = base->getVertexCount(); uint32 newVertexCount = @@ -1748,14 +1754,14 @@ namespace Shared { /* for(int i = 0; i < pboCount; ++i) { - if(SystemFlags::VERBOSE_MODE_ENABLED) printf("PBO Gen i = %d\n",i); + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("PBO Gen i = %d\n",i); - pboIds.push_back(0); - glGenBuffersARB(1, (GLuint*)&pboIds[i]); - // create pixel buffer objects, you need to delete them when program exits. - // glBufferDataARB with NULL pointer reserves only memory space. - glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, pboIds[i]); - glBufferDataARB(GL_PIXEL_PACK_BUFFER_ARB, bufferSize, 0, GL_STREAM_READ_ARB); + pboIds.push_back(0); + glGenBuffersARB(1, (GLuint*)&pboIds[i]); + // create pixel buffer objects, you need to delete them when program exits. + // glBufferDataARB with NULL pointer reserves only memory space. + glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, pboIds[i]); + glBufferDataARB(GL_PIXEL_PACK_BUFFER_ARB, bufferSize, 0, GL_STREAM_READ_ARB); } glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, 0); */ @@ -1849,7 +1855,7 @@ namespace Shared { codeSection = "J"; if (SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n", extractFileFromDirectoryPath(__FILE__).c_str(), __FUNCTION__, __LINE__); glUnmapBufferARB(GL_PIXEL_PACK_BUFFER_ARB); // release pointer to the mapped buffer - //pixmapScreenShot->save("debugPBO.png"); + //pixmapScreenShot->save("debugPBO.png"); } codeSection = "K"; if (SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n", extractFileFromDirectoryPath(__FILE__).c_str(), __FUNCTION__, __LINE__); @@ -2184,7 +2190,7 @@ namespace Shared { // if(memcmp(pixel,oldpixel,3)) continue; // } - // Skip duplicate scanned colors + // Skip duplicate scanned colors map > >::const_iterator iterFind1 = colorAlreadyPickedList.find(pixel[0]); if (iterFind1 != colorAlreadyPickedList.end()) { map >::const_iterator iterFind2 = iterFind1->second.find(pixel[1]); @@ -2241,12 +2247,12 @@ namespace Shared { uniqueColorID[2]); /* - glColor3f( uniqueColorID[0] / 255.0f, - uniqueColorID[1] / 255.0f, - uniqueColorID[2] / 255.0f); - //uniqueColorID[3] / 255.0f); - * - */ + glColor3f( uniqueColorID[0] / 255.0f, + uniqueColorID[1] / 255.0f, + uniqueColorID[2] / 255.0f); + //uniqueColorID[3] / 255.0f); + * + */ } diff --git a/source/shared_lib/sources/map/map_preview.cpp b/source/shared_lib/sources/map/map_preview.cpp index 57f5972b8..9d9999ab1 100644 --- a/source/shared_lib/sources/map/map_preview.cpp +++ b/source/shared_lib/sources/map/map_preview.cpp @@ -723,7 +723,7 @@ namespace Shared { float numUsedToSmooth = 0.f; for (int k = -1; k <= 1; ++k) { for (int l = -1; l <= 1; ++l) { - int tmpHeight = oldHeights[(j + k) * w + (i + l)]; + int tmpHeight = (int) oldHeights[(j + k) * w + (i + l)]; if (limitHeight && tmpHeight > 20) { tmpHeight = 20; } diff --git a/source/shared_lib/sources/platform/common/base_thread.cpp b/source/shared_lib/sources/platform/common/base_thread.cpp index 5467c6e70..abc35818a 100644 --- a/source/shared_lib/sources/platform/common/base_thread.cpp +++ b/source/shared_lib/sources/platform/common/base_thread.cpp @@ -91,9 +91,8 @@ namespace Shared { if (masterThreadList.find(this) == masterThreadList.end()) { if (SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem, "In [%s::%s Line: %d] uniqueID [%s] ret [%d] END\n", __FILE__, __FUNCTION__, __LINE__, uniqueID.c_str(), ret); - char szBuf[8096] = ""; - snprintf(szBuf, 8096, "invalid thread delete for ptr: %p", this); - throw megaglest_runtime_error(szBuf); + printf("invalid thread delete for ptr: %p", this); + //throw megaglest_runtime_error(szBuf); } if (SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem, "In [%s::%s Line: %d] uniqueID [%s] ret [%d] END\n", __FILE__, __FUNCTION__, __LINE__, uniqueID.c_str(), ret); diff --git a/source/shared_lib/sources/platform/common/simple_threads.cpp b/source/shared_lib/sources/platform/common/simple_threads.cpp index 69f63dfff..a8eb570bd 100644 --- a/source/shared_lib/sources/platform/common/simple_threads.cpp +++ b/source/shared_lib/sources/platform/common/simple_threads.cpp @@ -121,13 +121,13 @@ namespace Shared { findDirs(techDataPaths, techPaths); if (techPaths.empty() == false) { // Always calc megapack first so its up to date sooner - const string megapackTechtreeName = "megapack"; - vector::iterator iterFindMegaPack = std::find(techPaths.begin(), techPaths.end(), megapackTechtreeName); - if (iterFindMegaPack != techPaths.end()) { - techPaths.erase(iterFindMegaPack); - techPaths.insert(techPaths.begin(), megapackTechtreeName); + const string zetapackTechtreeName = "zetapack"; + vector::iterator iterFindZetaPack = std::find(techPaths.begin(), techPaths.end(), zetapackTechtreeName); + if (iterFindZetaPack != techPaths.end()) { + techPaths.erase(iterFindZetaPack); + techPaths.insert(techPaths.begin(), zetapackTechtreeName); - if (SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] Found megapack techtree and placing it at the TOP of the list\n", extractFileFromDirectoryPath(__FILE__).c_str(), __FUNCTION__, __LINE__); + if (SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] Found zetapack techtree and placing it at the TOP of the list\n", extractFileFromDirectoryPath(__FILE__).c_str(), __FUNCTION__, __LINE__); } unsigned int techsPerWorker = ((unsigned int) techPaths.size() / (unsigned int) MAX_FileCRCPreCacheThread_WORKER_THREADS); if (techPaths.size() % MAX_FileCRCPreCacheThread_WORKER_THREADS != 0) { @@ -433,7 +433,7 @@ namespace Shared { SystemFlags::OutputDebug(SystemFlags::debugError, "In [%s::%s Line: %d] Error [%s]\n", extractFileFromDirectoryPath(__FILE__).c_str(), __FUNCTION__, __LINE__, ex.what()); if (SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem, "In [%s::%s Line: %d] uniqueID [%s]\n", extractFileFromDirectoryPath(__FILE__).c_str(), __FUNCTION__, __LINE__, this->getUniqueID().c_str()); - throw megaglest_runtime_error(ex.what()); + //throw megaglest_runtime_error(ex.what()); //abort(); } //printf("~SimpleTaskThread LINE: %d this = %p\n",__LINE__,this); diff --git a/source/shared_lib/sources/platform/sdl/thread.cpp b/source/shared_lib/sources/platform/sdl/thread.cpp index e183465cc..7605aa7f4 100644 --- a/source/shared_lib/sources/platform/sdl/thread.cpp +++ b/source/shared_lib/sources/platform/sdl/thread.cpp @@ -510,9 +510,8 @@ namespace Shared { MutexSafeWrapper safeMutexX(Mutex::mutexMutexList.get()); std::vector::iterator iterFind = std::find(Mutex::mutexList.begin(), Mutex::mutexList.end(), this); if (iterFind == Mutex::mutexList.end()) { - char szBuf[8096] = ""; - snprintf(szBuf, 8095, "In [%s::%s Line: %d] iterFind == Mutex::mutexList.end()", extractFileFromDirectoryPath(__FILE__).c_str(), __FUNCTION__, __LINE__); - throw megaglest_runtime_error(szBuf); + printf("In [%s::%s Line: %d] iterFind == Mutex::mutexList.end()", extractFileFromDirectoryPath(__FILE__).c_str(), __FUNCTION__, __LINE__); + //throw megaglest_runtime_error(szBuf); } Mutex::mutexList.erase(iterFind); safeMutexX.ReleaseLock(); @@ -520,14 +519,12 @@ namespace Shared { SDLMutexSafeWrapper safeMutex(&mutexAccessor, true); if (mutex == NULL) { - char szBuf[8096] = ""; - snprintf(szBuf, 8095, "In [%s::%s Line: %d] mutex == NULL refCount = %d owner [%s] deleteownerId [%s]", extractFileFromDirectoryPath(__FILE__).c_str(), __FUNCTION__, __LINE__, refCount, ownerId.c_str(), deleteownerId.c_str()); - throw megaglest_runtime_error(szBuf); + printf("In [%s::%s Line: %d] mutex == NULL refCount = %d owner [%s] deleteownerId [%s]", extractFileFromDirectoryPath(__FILE__).c_str(), __FUNCTION__, __LINE__, refCount, ownerId.c_str(), deleteownerId.c_str()); + //throw megaglest_runtime_error(szBuf); //printf("%s\n",szBuf); } else if (refCount >= 1) { - char szBuf[8096] = ""; - snprintf(szBuf, 8095, "In [%s::%s Line: %d] about to destroy mutex refCount = %d owner [%s] deleteownerId [%s]", extractFileFromDirectoryPath(__FILE__).c_str(), __FUNCTION__, __LINE__, refCount, ownerId.c_str(), deleteownerId.c_str()); - throw megaglest_runtime_error(szBuf); + printf("In [%s::%s Line: %d] about to destroy mutex refCount = %d owner [%s] deleteownerId [%s]", extractFileFromDirectoryPath(__FILE__).c_str(), __FUNCTION__, __LINE__, refCount, ownerId.c_str(), deleteownerId.c_str()); + //throw megaglest_runtime_error(szBuf); } if (debugMutexLock == true) { @@ -609,9 +606,8 @@ namespace Shared { Semaphore::~Semaphore() { if (semaphore == NULL) { - char szBuf[8096] = ""; - snprintf(szBuf, 8095, "In [%s::%s Line: %d] semaphore == NULL", extractFileFromDirectoryPath(__FILE__).c_str(), __FUNCTION__, __LINE__); - throw megaglest_runtime_error(szBuf); + printf("In [%s::%s Line: %d] semaphore == NULL", extractFileFromDirectoryPath(__FILE__).c_str(), __FUNCTION__, __LINE__); + //throw megaglest_runtime_error(szBuf); } SDL_DestroySemaphore(semaphore); semaphore = NULL; @@ -728,9 +724,8 @@ namespace Shared { if (debugMasterSlaveThreadController) printf("In [%s::%s Line: %d]\n", extractFileFromDirectoryPath(__FILE__).c_str(), __FUNCTION__, __LINE__); if (trigger == NULL) { - char szBuf[8096] = ""; - snprintf(szBuf, 8095, "In [%s::%s Line: %d] trigger == NULL", extractFileFromDirectoryPath(__FILE__).c_str(), __FUNCTION__, __LINE__); - throw megaglest_runtime_error(szBuf); + printf("In [%s::%s Line: %d] trigger == NULL", extractFileFromDirectoryPath(__FILE__).c_str(), __FUNCTION__, __LINE__); + //throw megaglest_runtime_error(szBuf); } if (debugMasterSlaveThreadController) printf("In [%s::%s Line: %d]\n", extractFileFromDirectoryPath(__FILE__).c_str(), __FUNCTION__, __LINE__); diff --git a/source/shared_lib/sources/util/conversion.cpp b/source/shared_lib/sources/util/conversion.cpp index 0f30fd32c..6dfab1c97 100644 --- a/source/shared_lib/sources/util/conversion.cpp +++ b/source/shared_lib/sources/util/conversion.cpp @@ -218,9 +218,9 @@ namespace Shared { double getTimeDuationMinutes(int frames, int updateFps) { int framesleft = frames; double hours = (int) ((int) frames / (float) updateFps / 3600.0f); - framesleft = framesleft - hours * 3600 * updateFps; + framesleft = (int) (framesleft - hours * 3600 * updateFps); double minutes = (int) ((int) framesleft / (float) updateFps / 60.0f); - framesleft = framesleft - minutes * 60 * updateFps; + framesleft = (int) (framesleft - minutes * 60 * updateFps); double seconds = (int) ((int) framesleft / (float) updateFps); double result = (hours * 60.0) + minutes; diff --git a/source/shared_lib/sources/util/properties.cpp b/source/shared_lib/sources/util/properties.cpp index b4963995b..d2f797ba0 100644 --- a/source/shared_lib/sources/util/properties.cpp +++ b/source/shared_lib/sources/util/properties.cpp @@ -514,8 +514,8 @@ namespace Shared { //printf("In [%s::%s - %d]defaultValueIfNotFound = [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,defaultValueIfNotFound); return string(defaultValueIfNotFound); } else { - //throw megaglest_runtime_error("Value not found in propertyMap: " + key + ", loaded from: " + path); - throw runtime_error("Value not found in propertyMap: " + key + ", loaded from: " + path); + //throw runtime_error("Value not found in propertyMap: " + key + ", loaded from: " + path); + return string(); } } else { return (it->second != "" ? it->second : (defaultValueIfNotFound != NULL ? defaultValueIfNotFound : it->second)); @@ -618,8 +618,8 @@ namespace Shared { //printf("In [%s::%s - %d]defaultValueIfNotFound = [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,defaultValueIfNotFound); return string(defaultValueIfNotFound); } else { - //throw megaglest_runtime_error("Value not found in propertyMap: " + string(key) + ", loaded from: " + path); - throw runtime_error("Value not found in propertyMap: " + string(key) + ", loaded from: " + path); + //throw runtime_error("Value not found in propertyMap: " + string(key) + ", loaded from: " + path); + return string(); } } else { return (it->second != "" ? it->second : (defaultValueIfNotFound != NULL ? defaultValueIfNotFound : it->second));