From c39da4cd69f7c70c0258138fe7ca17bc3aff4ad9 Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Sat, 6 Oct 2012 02:10:23 +0000 Subject: [PATCH] - code cleanup from cppcheck --- source/glest_game/ai/ai.cpp | 3 +++ source/glest_game/facilities/logger.cpp | 1 + source/glest_game/graphics/renderer.cpp | 23 ++++++++++++++----- source/glest_game/main/program.cpp | 1 + .../glest_game/menu/menu_state_join_game.cpp | 1 - source/glest_game/type_instances/faction.cpp | 2 ++ .../include/graphics/model_renderer.h | 8 ++++++- source/shared_lib/sources/graphics/model.cpp | 2 ++ 8 files changed, 33 insertions(+), 8 deletions(-) diff --git a/source/glest_game/ai/ai.cpp b/source/glest_game/ai/ai.cpp index e016c718..f42f29f6 100644 --- a/source/glest_game/ai/ai.cpp +++ b/source/glest_game/ai/ai.cpp @@ -39,6 +39,7 @@ ProduceTask::ProduceTask() : Task() { taskClass= tcProduce; unitType= NULL; resourceType= NULL; + unitClass = ucWarrior; } ProduceTask::ProduceTask(UnitClass unitClass) : Task() { @@ -52,11 +53,13 @@ ProduceTask::ProduceTask(const UnitType *unitType) : Task() { taskClass= tcProduce; this->unitType= unitType; resourceType= NULL; + unitClass = ucWarrior; } ProduceTask::ProduceTask(const ResourceType *resourceType) : Task() { taskClass= tcProduce; unitType= NULL; + unitClass = ucWarrior; this->resourceType= resourceType; } diff --git a/source/glest_game/facilities/logger.cpp b/source/glest_game/facilities/logger.cpp index efbb1c4b..972b944a 100644 --- a/source/glest_game/facilities/logger.cpp +++ b/source/glest_game/facilities/logger.cpp @@ -39,6 +39,7 @@ const int Logger::logLineCount= 15; Logger::Logger() { //masterserverMode = false; + progress = 0; string logs_path = getGameReadWritePath(GameConstants::path_logs_CacheLookupKey); if(logs_path != "") { fileName= logs_path + "log.txt"; diff --git a/source/glest_game/graphics/renderer.cpp b/source/glest_game/graphics/renderer.cpp index 18bcac8b..eac78999 100644 --- a/source/glest_game/graphics/renderer.cpp +++ b/source/glest_game/graphics/renderer.cpp @@ -38,15 +38,16 @@ using namespace Shared::Graphics; namespace Glest { namespace Game{ uint32 Renderer::SurfaceData::nextUniqueId = 1; - bool Renderer::renderText3DEnabled = true; +const float SKIP_INTERPOLATION_DISTANCE = 20.0f; +const string DEFAULT_CHAR_FOR_WIDTH_CALC = "V"; + // ===================================================== // class MeshCallbackTeamColor // ===================================================== bool MeshCallbackTeamColor::noTeamColors = false; -const string DEFAULT_CHAR_FOR_WIDTH_CALC = "V"; void MeshCallbackTeamColor::execute(const Mesh *mesh) { //team color @@ -4618,7 +4619,9 @@ void Renderer::renderObjects(const int renderFps) { } //objModel->updateInterpolationData(0.f, true); - objModel->updateInterpolationData(o->getAnimProgress(), true); + //if(this->gameCamera->getPos().dist(o->getPos()) <= SKIP_INTERPOLATION_DISTANCE) { + objModel->updateInterpolationData(o->getAnimProgress(), true); + //} modelRenderer->render(objModel); triangleCount+= objModel->getTriangleCount(); @@ -4975,7 +4978,11 @@ void Renderer::renderUnits(const int renderFps) { //render Model *model= unit->getCurrentModelPtr(); - model->updateInterpolationData(unit->getAnimProgress(), unit->isAlive() && !unit->isAnimProgressBound()); + //printf("Rendering model [%d - %s]\n[%s]\nCamera [%s]\nDistance: %f\n",unit->getId(),unit->getType()->getName().c_str(),unit->getCurrVector().getString().c_str(),this->gameCamera->getPos().getString().c_str(),this->gameCamera->getPos().dist(unit->getCurrVector())); + + //if(this->gameCamera->getPos().dist(unit->getCurrVector()) <= SKIP_INTERPOLATION_DISTANCE) { + model->updateInterpolationData(unit->getAnimProgress(), unit->isAlive() && !unit->isAnimProgressBound()); + //} modelRenderer->render(model); triangleCount+= model->getTriangleCount(); @@ -7401,7 +7408,9 @@ vector Renderer::renderUnitsFast(bool renderingShadows, bool colorPickin //render Model *model= unit->getCurrentModelPtr(); - model->updateInterpolationVertices(unit->getAnimProgress(), unit->isAlive() && !unit->isAnimProgressBound()); + //if(this->gameCamera->getPos().dist(unit->getCurrVector()) <= SKIP_INTERPOLATION_DISTANCE) { + model->updateInterpolationVertices(unit->getAnimProgress(), unit->isAlive() && !unit->isAnimProgressBound()); + //} if(colorPickingSelection == true) { unit->setUniquePickingColor(); @@ -7507,7 +7516,9 @@ vector Renderer::renderObjectsFast(bool renderingShadows, bool resour if(resourceOnly == false || o->getResource()!= NULL) { Model *objModel= o->getModelPtr(); - objModel->updateInterpolationData(o->getAnimProgress(), true); + //if(this->gameCamera->getPos().dist(o->getPos()) <= SKIP_INTERPOLATION_DISTANCE) { + objModel->updateInterpolationData(o->getAnimProgress(), true); + //} const Vec3f &v= o->getConstPos(); if(colorPickingSelection == false) { diff --git a/source/glest_game/main/program.cpp b/source/glest_game/main/program.cpp index 6f9381f3..60517f36 100644 --- a/source/glest_game/main/program.cpp +++ b/source/glest_game/main/program.cpp @@ -173,6 +173,7 @@ void Program::ShowMessageProgramState::update() { Program::Program() { //this->masterserverMode = false; + this->window = NULL; this->shutdownApplicationEnabled = false; this->skipRenderFrameCount = 0; this->messageBoxIsSystemError = false; diff --git a/source/glest_game/menu/menu_state_join_game.cpp b/source/glest_game/menu/menu_state_join_game.cpp index cf277682..339d167e 100644 --- a/source/glest_game/menu/menu_state_join_game.cpp +++ b/source/glest_game/menu/menu_state_join_game.cpp @@ -593,7 +593,6 @@ void MenuStateJoinGame::update() if(clientInterface->getIntroDone()) { labelInfo.setText(lang.get("WaitingHost")); - Config& config= Config::getInstance(); string host = labelServerIp.getText(); std::vector hostPartsList; Tokenize(host,hostPartsList,":"); diff --git a/source/glest_game/type_instances/faction.cpp b/source/glest_game/type_instances/faction.cpp index f1c07459..fec71847 100644 --- a/source/glest_game/type_instances/faction.cpp +++ b/source/glest_game/type_instances/faction.cpp @@ -408,6 +408,8 @@ Faction::Faction() { loadWorldNode = NULL; techTree = NULL; + control = ctClosed; + overridePersonalityType = fpt_EndCount; } diff --git a/source/shared_lib/include/graphics/model_renderer.h b/source/shared_lib/include/graphics/model_renderer.h index 23b65915..68a72cfb 100644 --- a/source/shared_lib/include/graphics/model_renderer.h +++ b/source/shared_lib/include/graphics/model_renderer.h @@ -52,7 +52,13 @@ protected: MeshCallback *meshCallback; public: - ModelRenderer() {meshCallback= NULL;} + ModelRenderer() { + renderNormals = false; + renderTextures = false; + renderColors = false; + + meshCallback= NULL; + } virtual ~ModelRenderer(){}; diff --git a/source/shared_lib/sources/graphics/model.cpp b/source/shared_lib/sources/graphics/model.cpp index 7d86fd59..266aee69 100644 --- a/source/shared_lib/sources/graphics/model.cpp +++ b/source/shared_lib/sources/graphics/model.cpp @@ -47,6 +47,8 @@ Mesh::Mesh() { vertexCount= 0; indexCount= 0; texCoordFrameCount = 0; + opacity = 0.0f; + specularPower = 0.0f; vertices= NULL; normals= NULL;