From 865a665bf0fe6f414947a853b45c6b3515e93194 Mon Sep 17 00:00:00 2001 From: SoftCoder Date: Mon, 9 Oct 2017 20:21:14 -0700 Subject: [PATCH] - round 2 of cppcheck code cleanup --- source/glest_game/ai/ai.cpp | 28 +- source/glest_game/ai/ai.h | 2 +- source/glest_game/ai/ai_interface.cpp | 84 +-- source/glest_game/ai/ai_interface.h | 4 +- source/glest_game/ai/path_finder.cpp | 82 +-- source/glest_game/ai/path_finder.h | 2 +- source/glest_game/facilities/components.cpp | 12 +- source/glest_game/facilities/components.h | 4 +- source/glest_game/game/game.cpp | 42 +- source/glest_game/game/game.h | 4 +- source/glest_game/game/game_camera.cpp | 12 +- source/glest_game/game/game_camera.h | 2 +- source/glest_game/graphics/renderer.cpp | 646 +++++++++--------- source/glest_game/graphics/renderer.h | 20 +- source/glest_game/gui/selection.cpp | 12 +- source/glest_game/gui/selection.h | 2 +- source/glest_game/main/program.cpp | 26 +- source/glest_game/main/program.h | 2 +- .../menu/menu_state_masterserver.cpp | 10 +- .../glest_game/menu/menu_state_masterserver.h | 2 +- source/glest_game/network/connection_slot.cpp | 20 +- source/glest_game/network/connection_slot.h | 4 +- source/glest_game/steam/steam.cpp | 6 +- source/glest_game/type_instances/command.cpp | 6 +- source/glest_game/type_instances/command.h | 2 +- source/glest_game/type_instances/faction.cpp | 168 ++--- source/glest_game/type_instances/faction.h | 10 +- source/glest_game/type_instances/unit.cpp | 70 +- source/glest_game/type_instances/unit.h | 8 +- source/glest_game/types/faction_type.cpp | 38 +- source/glest_game/types/faction_type.h | 2 +- source/glest_game/types/unit_type.cpp | 18 +- source/glest_game/types/unit_type.h | 2 +- source/glest_game/world/map.cpp | 116 ++-- source/glest_game/world/map.h | 6 +- .../shared_lib/include/graphics/gl/opengl.h | 2 +- source/shared_lib/include/util/util.h | 2 +- .../shared_lib/sources/graphics/gl/opengl.cpp | 10 +- source/shared_lib/sources/util/conversion.cpp | 4 +- source/shared_lib/sources/util/util.cpp | 8 +- 40 files changed, 750 insertions(+), 750 deletions(-) diff --git a/source/glest_game/ai/ai.cpp b/source/glest_game/ai/ai.cpp index 4a1ba887..d2980869 100644 --- a/source/glest_game/ai/ai.cpp +++ b/source/glest_game/ai/ai.cpp @@ -620,20 +620,20 @@ vector Ai::findUnitsHarvestingResourceType(const ResourceType *rt) { return units; } -vector Ai::findUnitsDoingCommand(CommandClass currentCommand) { - vector units; - - for(int i = 0; i < aiInterface->getMyUnitCount(); ++i) { - const Unit *unit= aiInterface->getMyUnit(i); - if(unit->getType()->isCommandable() && unit->getType()->hasCommandClass(currentCommand)) { - if(unit->anyCommand() && unit->getCurrCommand()->getCommandType()->getClass() == currentCommand) { - units.push_back(i); - } - } - } - - return units; -} +//vector Ai::findUnitsDoingCommand(CommandClass currentCommand) { +// vector units; +// +// for(int i = 0; i < aiInterface->getMyUnitCount(); ++i) { +// const Unit *unit= aiInterface->getMyUnit(i); +// if(unit->getType()->isCommandable() && unit->getType()->hasCommandClass(currentCommand)) { +// if(unit->anyCommand() && unit->getCurrCommand()->getCommandType()->getClass() == currentCommand) { +// units.push_back(i); +// } +// } +// } +// +// return units; +//} bool Ai::findAbleUnit(int *unitIndex, CommandClass ability, CommandClass currentCommand){ vector units; diff --git a/source/glest_game/ai/ai.h b/source/glest_game/ai/ai.h index 8e8db410..518be0b7 100644 --- a/source/glest_game/ai/ai.h +++ b/source/glest_game/ai/ai.h @@ -211,7 +211,7 @@ public: bool findPosForBuilding(const UnitType* building, const Vec2i &searchPos, Vec2i &pos); bool findAbleUnit(int *unitIndex, CommandClass ability, bool idleOnly); bool findAbleUnit(int *unitIndex, CommandClass ability, CommandClass currentCommand); - vector findUnitsDoingCommand(CommandClass currentCommand); + //vector findUnitsDoingCommand(CommandClass currentCommand); vector findUnitsHarvestingResourceType(const ResourceType *rt); bool beingAttacked(Vec2i &pos, Field &field, int radius); diff --git a/source/glest_game/ai/ai_interface.cpp b/source/glest_game/ai/ai_interface.cpp index 0789a9f0..6bb7a7f2 100644 --- a/source/glest_game/ai/ai_interface.cpp +++ b/source/glest_game/ai/ai_interface.cpp @@ -599,23 +599,23 @@ int AiInterface::getMyUpgradeCount() const{ return world->getFaction(factionIndex)->getUpgradeManager()->getUpgradeCount(); } -int AiInterface::onSightUnitCount() { - int count=0; - Map *map= world->getMap(); - for(int i=0; igetFactionCount(); ++i) { - for(int j=0; jgetFaction(i)->getUnitCount(); ++j) { - Unit *unit = world->getFaction(i)->getUnit(j); - SurfaceCell *sc= map->getSurfaceCell(Map::toSurfCoords(unit->getPos())); - bool cannotSeeUnit = (unit->getType()->hasCellMap() == true && - unit->getType()->getAllowEmptyCellMap() == true && - unit->getType()->hasEmptyCellMap() == true); - if(sc->isVisible(teamIndex) && cannotSeeUnit == false) { - count++; - } - } - } - return count; -} +//int AiInterface::onSightUnitCount() { +// int count=0; +// Map *map= world->getMap(); +// for(int i=0; igetFactionCount(); ++i) { +// for(int j=0; jgetFaction(i)->getUnitCount(); ++j) { +// Unit *unit = world->getFaction(i)->getUnit(j); +// SurfaceCell *sc= map->getSurfaceCell(Map::toSurfCoords(unit->getPos())); +// bool cannotSeeUnit = (unit->getType()->hasCellMap() == true && +// unit->getType()->getAllowEmptyCellMap() == true && +// unit->getType()->hasEmptyCellMap() == true); +// if(sc->isVisible(teamIndex) && cannotSeeUnit == false) { +// count++; +// } +// } +// } +// return count; +//} const Resource *AiInterface::getResource(const ResourceType *rt){ return world->getFaction(factionIndex)->getResource(rt); @@ -635,31 +635,31 @@ const Unit *AiInterface::getMyUnit(int unitIndex) { return getMyUnitPtr(unitIndex); } -const Unit *AiInterface::getOnSightUnit(int unitIndex) { - - int count=0; - Map *map= world->getMap(); - - for(int i=0; igetFactionCount(); ++i) { - for(int j=0; jgetFaction(i)->getUnitCount(); ++j) { - Unit * unit= world->getFaction(i)->getUnit(j); - SurfaceCell *sc= map->getSurfaceCell(Map::toSurfCoords(unit->getPos())); - bool cannotSeeUnit = (unit->getType()->hasCellMap() == true && - unit->getType()->getAllowEmptyCellMap() == true && - unit->getType()->hasEmptyCellMap() == true); - - if(sc->isVisible(teamIndex) && cannotSeeUnit == false) { - if(count==unitIndex) { - return unit; - } - else { - count ++; - } - } - } - } - return NULL; -} +//const Unit *AiInterface::getOnSightUnit(int unitIndex) { +// +// int count=0; +// Map *map= world->getMap(); +// +// for(int i=0; igetFactionCount(); ++i) { +// for(int j=0; jgetFaction(i)->getUnitCount(); ++j) { +// Unit * unit= world->getFaction(i)->getUnit(j); +// SurfaceCell *sc= map->getSurfaceCell(Map::toSurfCoords(unit->getPos())); +// bool cannotSeeUnit = (unit->getType()->hasCellMap() == true && +// unit->getType()->getAllowEmptyCellMap() == true && +// unit->getType()->hasEmptyCellMap() == true); +// +// if(sc->isVisible(teamIndex) && cannotSeeUnit == false) { +// if(count==unitIndex) { +// return unit; +// } +// else { +// count ++; +// } +// } +// } +// } +// return NULL; +//} const FactionType * AiInterface::getMyFactionType(){ return world->getFaction(factionIndex)->getType(); diff --git a/source/glest_game/ai/ai_interface.h b/source/glest_game/ai/ai_interface.h index 83f54d22..f8324773 100644 --- a/source/glest_game/ai/ai_interface.h +++ b/source/glest_game/ai/ai_interface.h @@ -134,11 +134,11 @@ public: int getFactionCount(); int getMyUnitCount() const; int getMyUpgradeCount() const; - int onSightUnitCount(); + //int onSightUnitCount(); const Resource *getResource(const ResourceType *rt); const Unit *getMyUnit(int unitIndex); Unit *getMyUnitPtr(int unitIndex); - const Unit *getOnSightUnit(int unitIndex); + //const Unit *getOnSightUnit(int unitIndex); const FactionType *getMyFactionType(); Faction *getMyFaction(); const TechTree *getTechTree(); diff --git a/source/glest_game/ai/path_finder.cpp b/source/glest_game/ai/path_finder.cpp index 7056d418..936eb3f2 100644 --- a/source/glest_game/ai/path_finder.cpp +++ b/source/glest_game/ai/path_finder.cpp @@ -1132,47 +1132,47 @@ int PathFinder::findNodeIndex(Node *node, std::vector &nodeList) { return index; } -bool PathFinder::unitCannotMove(Unit *unit) { - bool unitImmediatelyBlocked = false; - - try { - // First check if unit currently blocked all around them, if so don't try to pathfind - const Vec2i unitPos = unit->getPos(); - int failureCount = 0; - int cellCount = 0; - - for(int i = -1; i <= 1; ++i) { - for(int j = -1; j <= 1; ++j) { - Vec2i pos = unitPos + Vec2i(i, j); - if(pos != unitPos) { - bool canUnitMoveToCell = map->aproxCanMove(unit, unitPos, pos); - if(canUnitMoveToCell == false) { - failureCount++; - } - cellCount++; - } - } - } - unitImmediatelyBlocked = (failureCount == cellCount); - - } - catch(const exception &ex) { - //setRunningStatus(false); - - SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); - - throw megaglest_runtime_error(ex.what()); - } - catch(...) { - char szBuf[8096]=""; - snprintf(szBuf,8096,"In [%s::%s %d] UNKNOWN error\n",__FILE__,__FUNCTION__,__LINE__); - SystemFlags::OutputDebug(SystemFlags::debugError,szBuf); - throw megaglest_runtime_error(szBuf); - } - - return unitImmediatelyBlocked; -} +//bool PathFinder::unitCannotMove(Unit *unit) { +// bool unitImmediatelyBlocked = false; +// +// try { +// // First check if unit currently blocked all around them, if so don't try to pathfind +// const Vec2i unitPos = unit->getPos(); +// int failureCount = 0; +// int cellCount = 0; +// +// for(int i = -1; i <= 1; ++i) { +// for(int j = -1; j <= 1; ++j) { +// Vec2i pos = unitPos + Vec2i(i, j); +// if(pos != unitPos) { +// bool canUnitMoveToCell = map->aproxCanMove(unit, unitPos, pos); +// if(canUnitMoveToCell == false) { +// failureCount++; +// } +// cellCount++; +// } +// } +// } +// unitImmediatelyBlocked = (failureCount == cellCount); +// +// } +// catch(const exception &ex) { +// //setRunningStatus(false); +// +// SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); +// if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); +// +// throw megaglest_runtime_error(ex.what()); +// } +// catch(...) { +// char szBuf[8096]=""; +// snprintf(szBuf,8096,"In [%s::%s %d] UNKNOWN error\n",__FILE__,__FUNCTION__,__LINE__); +// SystemFlags::OutputDebug(SystemFlags::debugError,szBuf); +// throw megaglest_runtime_error(szBuf); +// } +// +// return unitImmediatelyBlocked; +//} void PathFinder::saveGame(XmlNode *rootNode) { std::map mapTagReplacements; diff --git a/source/glest_game/ai/path_finder.h b/source/glest_game/ai/path_finder.h index 5906b487..c914a154 100644 --- a/source/glest_game/ai/path_finder.h +++ b/source/glest_game/ai/path_finder.h @@ -202,7 +202,7 @@ public: void removeUnitPrecache(Unit *unit); void clearCaches(); - bool unitCannotMove(Unit *unit); + //bool unitCannotMove(Unit *unit); int findNodeIndex(Node *node, Nodes &nodeList); int findNodeIndex(Node *node, std::vector &nodeList); diff --git a/source/glest_game/facilities/components.cpp b/source/glest_game/facilities/components.cpp index b6a5050b..77ca6521 100644 --- a/source/glest_game/facilities/components.cpp +++ b/source/glest_game/facilities/components.cpp @@ -419,17 +419,17 @@ bool GraphicLabel::getCenteredW() const { bool result = (centered || centeredW == 1); return result; } -void GraphicLabel::setCenteredW(bool centered) { - centeredW = (centered ? 1 : 0); -} +//void GraphicLabel::setCenteredW(bool centered) { +// centeredW = (centered ? 1 : 0); +//} bool GraphicLabel::getCenteredH() const { bool result = (centered || centeredH == 1); return result; } -void GraphicLabel::setCenteredH(bool centered) { - centeredH = (centered ? 1 : 0); -} +//void GraphicLabel::setCenteredH(bool centered) { +// centeredH = (centered ? 1 : 0); +//} // ===================================================== // class GraphicButton diff --git a/source/glest_game/facilities/components.h b/source/glest_game/facilities/components.h index 554311cf..f883512f 100644 --- a/source/glest_game/facilities/components.h +++ b/source/glest_game/facilities/components.h @@ -182,10 +182,10 @@ public: void setCentered(bool centered) {this->centered= centered;} bool getCenteredW() const; - void setCenteredW(bool centered); + //void setCenteredW(bool centered); bool getCenteredH() const; - void setCenteredH(bool centered); + //void setCenteredH(bool centered); Vec3f getTextColor() const {return textColor;} void setTextColor(Vec3f color) {this->textColor= color;} diff --git a/source/glest_game/game/game.cpp b/source/glest_game/game/game.cpp index 01497950..8bb6faa1 100644 --- a/source/glest_game/game/game.cpp +++ b/source/glest_game/game/game.cpp @@ -513,17 +513,17 @@ int Game::ErrorDisplayMessage(const char *msg, bool exitApp) { return 0; } -Texture2D * Game::findFactionLogoTexture(const GameSettings *settings, Logger *logger,string factionLogoFilter, bool useTechDefaultIfFilterNotFound) { - Texture2D *result = NULL; - string logoFilename = Game::findFactionLogoFile(settings, logger,factionLogoFilter); - if(logoFilename == "" && factionLogoFilter != "" && useTechDefaultIfFilterNotFound == true) { - logoFilename = Game::findFactionLogoFile(settings, logger); - } - - result = Renderer::findTexture(logoFilename); - - return result; -} +//Texture2D * Game::findFactionLogoTexture(const GameSettings *settings, Logger *logger,string factionLogoFilter, bool useTechDefaultIfFilterNotFound) { +// Texture2D *result = NULL; +// string logoFilename = Game::findFactionLogoFile(settings, logger,factionLogoFilter); +// if(logoFilename == "" && factionLogoFilter != "" && useTechDefaultIfFilterNotFound == true) { +// logoFilename = Game::findFactionLogoFile(settings, logger); +// } +// +// result = Renderer::findTexture(logoFilename); +// +// return result; +//} string Game::extractScenarioLogoFile(const GameSettings *settings, string &result, bool &loadingImageUsed, Logger *logger, string factionLogoFilter) { @@ -6132,16 +6132,16 @@ bool Game::factionLostGame(const Faction *faction) { return true; } -bool Game::hasBuilding(const Faction *faction) { - if(faction != NULL) { - for(int i=0; igetUnitCount(); ++i) { - if(faction->getUnit(i)->getType()->hasSkillClass(scBeBuilt)) { - return true; - } - } - } - return false; -} +//bool Game::hasBuilding(const Faction *faction) { +// if(faction != NULL) { +// for(int i=0; igetUnitCount(); ++i) { +// if(faction->getUnit(i)->getType()->hasSkillClass(scBeBuilt)) { +// return true; +// } +// } +// } +// return false; +//} void Game::incSpeed() { if(disableSpeedChange == true) { diff --git a/source/glest_game/game/game.h b/source/glest_game/game/game.h index 099bfa9d..fbcb6455 100644 --- a/source/glest_game/game/game.h +++ b/source/glest_game/game/game.h @@ -312,7 +312,7 @@ public: void endPerformanceTimer(); Vec2i getPerformanceTimerResults(); - static Texture2D * findFactionLogoTexture(const GameSettings *settings, Logger *logger=NULL,string factionLogoFilter=GameConstants::LOADING_SCREEN_FILE_FILTER, bool useTechDefaultIfFilterNotFound=true); + //static Texture2D * findFactionLogoTexture(const GameSettings *settings, Logger *logger=NULL,string factionLogoFilter=GameConstants::LOADING_SCREEN_FILE_FILTER, bool useTechDefaultIfFilterNotFound=true); static string findFactionLogoFile(const GameSettings *settings, Logger *logger=NULL, const string &factionLogoFilter=GameConstants::LOADING_SCREEN_FILE_FILTER); static string extractScenarioLogoFile(const GameSettings *settings, string &result, bool &loadingImageUsed, Logger *logger=NULL, string factionLogoFilter=GameConstants::LOADING_SCREEN_FILE_FILTER); static string extractFactionLogoFile(bool &loadingImageUsed, const string &factionName, string scenarioDir, const string &techName, Logger *logger=NULL, string factionLogoFilter=GameConstants::LOADING_SCREEN_FILE_FILTER); @@ -368,7 +368,7 @@ private: void checkWinnerScripted(); void setEndGameTeamWinnersAndLosers(); - bool hasBuilding(const Faction *faction); + //bool hasBuilding(const Faction *faction); bool factionLostGame(const Faction *faction); void incSpeed(); void decSpeed(); diff --git a/source/glest_game/game/game_camera.cpp b/source/glest_game/game/game_camera.cpp index 45b697ad..1f9a643f 100644 --- a/source/glest_game/game/game_camera.cpp +++ b/source/glest_game/game/game_camera.cpp @@ -352,12 +352,12 @@ void GameCamera::centerXZ(float x, float z){ destPos.z = pos.z= z+centerOffsetZ; } -void GameCamera::transitionXYZ(float x, float y, float z) { - destPos.x += x; - destPos.y += y; - destPos.z += z; - clampPosXYZ(0.0f, (float)limitX, minHeight, maxHeight, 0.0f, (float)limitY); -} +//void GameCamera::transitionXYZ(float x, float y, float z) { +// destPos.x += x; +// destPos.y += y; +// destPos.z += z; +// clampPosXYZ(0.0f, (float)limitX, minHeight, maxHeight, 0.0f, (float)limitY); +//} void GameCamera::transitionVH(float v, float h) { destAng.x -= v; diff --git a/source/glest_game/game/game_camera.h b/source/glest_game/game/game_camera.h index d30f2fb7..68a3cd88 100644 --- a/source/glest_game/game/game_camera.h +++ b/source/glest_game/game/game_camera.h @@ -149,7 +149,7 @@ public: void centerXZ(float x, float z); - void transitionXYZ(float x, float y, float z); + //void transitionXYZ(float x, float y, float z); void transitionVH(float v, float h); void rotateToVH(float v, float h); diff --git a/source/glest_game/graphics/renderer.cpp b/source/glest_game/graphics/renderer.cpp index 974d22be..8b878853 100644 --- a/source/glest_game/graphics/renderer.cpp +++ b/source/glest_game/graphics/renderer.cpp @@ -842,23 +842,23 @@ void Renderer::endMenu() { //} } -void Renderer::reloadResources() { - if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true) { - return; - } - - for(int i=0; iend(); - textureManager[i]->end(); - fontManager[i]->end(); - } - - for(int i=0; iinit(); - textureManager[i]->init(); - fontManager[i]->init(); - } -} +//void Renderer::reloadResources() { +// if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true) { +// return; +// } +// +// for(int i=0; iend(); +// textureManager[i]->end(); +// fontManager[i]->end(); +// } +// +// for(int i=0; iinit(); +// textureManager[i]->init(); +// fontManager[i]->init(); +// } +//} // ==================== engine interface ==================== @@ -962,13 +962,13 @@ void Renderer::endFont(::Shared::Graphics::Font *font, ResourceScope rs, bool mu fontManager[rs]->endFont(font,mustExistInList); } -void Renderer::resetFontManager(ResourceScope rs) { - if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true) { - return; - } - fontManager[rs]->end(); - fontManager[rsGlobal]->init(); -} +//void Renderer::resetFontManager(ResourceScope rs) { +// if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true) { +// return; +// } +// fontManager[rs]->end(); +// fontManager[rsGlobal]->init(); +//} void Renderer::addToDeferredParticleSystemList(std::pair deferredParticleSystem) { deferredParticleSystems.push_back(deferredParticleSystem); @@ -1098,33 +1098,33 @@ void Renderer::setupLighting() { assertGl(); } -void Renderer::setupLightingForRotatedModel() { - if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true) { - return; - } - - const World *world= game->getWorld(); - //const GameCamera *gameCamera= game->getGameCamera(); - const TimeFlow *timeFlow= world->getTimeFlow(); - float time= timeFlow->getTime(); - - assertGl(); - - //sun/moon light - Vec3f lightColor= timeFlow->computeLightColor(); - Vec3f fogColor= world->getTileset()->getFogColor(); - Vec4f lightPos= timeFlow->isDay()? computeSunPos(time): computeMoonPos(time); - //nearestLightPos= lightPos; - - glLightfv(GL_LIGHT0, GL_POSITION, lightPos.ptr()); - glLightfv(GL_LIGHT0, GL_AMBIENT, Vec4f(lightColor*lightAmbFactor, 1.f).ptr()); - glLightfv(GL_LIGHT0, GL_DIFFUSE, Vec4f(lightColor, 1.f).ptr()); - glLightfv(GL_LIGHT0, GL_SPECULAR, Vec4f(0.0f, 0.0f, 0.f, 1.f).ptr()); - - glFogfv(GL_FOG_COLOR, Vec4f(fogColor*lightColor, 1.f).ptr()); - - assertGl(); -} +//void Renderer::setupLightingForRotatedModel() { +// if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true) { +// return; +// } +// +// const World *world= game->getWorld(); +// //const GameCamera *gameCamera= game->getGameCamera(); +// const TimeFlow *timeFlow= world->getTimeFlow(); +// float time= timeFlow->getTime(); +// +// assertGl(); +// +// //sun/moon light +// Vec3f lightColor= timeFlow->computeLightColor(); +// Vec3f fogColor= world->getTileset()->getFogColor(); +// Vec4f lightPos= timeFlow->isDay()? computeSunPos(time): computeMoonPos(time); +// //nearestLightPos= lightPos; +// +// glLightfv(GL_LIGHT0, GL_POSITION, lightPos.ptr()); +// glLightfv(GL_LIGHT0, GL_AMBIENT, Vec4f(lightColor*lightAmbFactor, 1.f).ptr()); +// glLightfv(GL_LIGHT0, GL_DIFFUSE, Vec4f(lightColor, 1.f).ptr()); +// glLightfv(GL_LIGHT0, GL_SPECULAR, Vec4f(0.0f, 0.0f, 0.f, 1.f).ptr()); +// +// glFogfv(GL_FOG_COLOR, Vec4f(fogColor*lightColor, 1.f).ptr()); +// +// assertGl(); +//} void Renderer::loadGameCameraMatrix() { const GameCamera *gameCamera= game->getGameCamera(); @@ -1407,30 +1407,30 @@ bool Renderer::ExtractFrustum(VisibleQuadContainerCache &quadCacheItem) { return frustumChanged; } -bool Renderer::PointInFrustum(vector > &frustum, float x, float y, float z ) { - unsigned int p=0; - - for( p = 0; p < frustum.size(); p++ ) { - if( frustum[p][0] * x + frustum[p][1] * y + frustum[p][2] * z + frustum[p][3] <= 0 ) { - return false; - } - } - return true; -} - -bool Renderer::SphereInFrustum(vector > &frustum, float x, float y, float z, float radius) { - // Go through all the sides of the frustum - for(int i = 0; i < (int)frustum.size(); i++ ) { - // If the center of the sphere is farther away from the plane than the radius - if(frustum[i][0] * x + frustum[i][1] * y + frustum[i][2] * z + frustum[i][3] <= -radius ) { - // The distance was greater than the radius so the sphere is outside of the frustum - return false; - } - } - - // The sphere was inside of the frustum! - return true; -} +//bool Renderer::PointInFrustum(vector > &frustum, float x, float y, float z ) { +// unsigned int p=0; +// +// for( p = 0; p < frustum.size(); p++ ) { +// if( frustum[p][0] * x + frustum[p][1] * y + frustum[p][2] * z + frustum[p][3] <= 0 ) { +// return false; +// } +// } +// return true; +//} +// +//bool Renderer::SphereInFrustum(vector > &frustum, float x, float y, float z, float radius) { +// // Go through all the sides of the frustum +// for(int i = 0; i < (int)frustum.size(); i++ ) { +// // If the center of the sphere is farther away from the plane than the radius +// if(frustum[i][0] * x + frustum[i][1] * y + frustum[i][2] * z + frustum[i][3] <= -radius ) { +// // The distance was greater than the radius so the sphere is outside of the frustum +// return false; +// } +// } +// +// // The sphere was inside of the frustum! +// return true; +//} bool Renderer::CubeInFrustum(vector > &frustum, float x, float y, float z, float size ) { unsigned int p=0; @@ -3994,60 +3994,60 @@ void Renderer::renderMessageBox(GraphicMessageBox *messageBox) { // ==================== complex rendering ==================== -VisibleQuadContainerVBOCache * Renderer::GetSurfaceVBOs(SurfaceData *cellData) { - std::map::iterator iterFind = mapSurfaceVBOCache.find(cellData->uniqueId); - if(iterFind == mapSurfaceVBOCache.end()) { - Vec2f *texCoords = &cellData->texCoords[0]; - Vec2f *texCoordsSurface = &cellData->texCoordsSurface[0]; - Vec3f *vertices = &cellData->vertices[0]; - Vec3f *normals = &cellData->normals[0]; - - VisibleQuadContainerVBOCache vboCache; - - // Generate And Bind The Vertex Buffer - glGenBuffersARB( 1, (GLuint*)&vboCache.m_nVBOVertices ); // Get A Valid Name - glBindBufferARB( GL_ARRAY_BUFFER_ARB, vboCache.m_nVBOVertices ); // Bind The Buffer - // Load The Data - glBufferDataARB( GL_ARRAY_BUFFER_ARB, sizeof(Vec3f) * cellData->bufferCount, vertices, GL_STATIC_DRAW_ARB ); - glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); - - assertGl(); - // Generate And Bind The Texture Coordinate Buffer - glGenBuffersARB( 1, (GLuint*)&vboCache.m_nVBOFowTexCoords ); // Get A Valid Name - glBindBufferARB( GL_ARRAY_BUFFER_ARB, vboCache.m_nVBOFowTexCoords ); // Bind The Buffer - // Load The Data - glBufferDataARB( GL_ARRAY_BUFFER_ARB, sizeof(Vec2f) * cellData->bufferCount, texCoords, GL_STATIC_DRAW_ARB ); - glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); - - assertGl(); - // Generate And Bind The Texture Coordinate Buffer - glGenBuffersARB( 1, (GLuint*)&vboCache.m_nVBOSurfaceTexCoords ); // Get A Valid Name - glBindBufferARB( GL_ARRAY_BUFFER_ARB, vboCache.m_nVBOSurfaceTexCoords ); // Bind The Buffer - // Load The Data - glBufferDataARB( GL_ARRAY_BUFFER_ARB, sizeof(Vec2f) * cellData->bufferCount, texCoordsSurface, GL_STATIC_DRAW_ARB ); - glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); - - assertGl(); - // Generate And Bind The Normal Buffer - glGenBuffersARB( 1, (GLuint*)&vboCache.m_nVBONormals ); // Get A Valid Name - glBindBufferARB( GL_ARRAY_BUFFER_ARB, vboCache.m_nVBONormals ); // Bind The Buffer - // Load The Data - glBufferDataARB( GL_ARRAY_BUFFER_ARB, sizeof(Vec3f) * cellData->bufferCount, normals, GL_STATIC_DRAW_ARB ); - glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); - - vboCache.hasBuiltVBOs = true; - - mapSurfaceVBOCache[cellData->uniqueId] = vboCache; - - // don't need the data in computer RAM anymore its in the GPU now - cellData->texCoords.clear(); - cellData->texCoordsSurface.clear(); - cellData->vertices.clear(); - cellData->normals.clear(); - } - - return &mapSurfaceVBOCache[cellData->uniqueId]; -} +//VisibleQuadContainerVBOCache * Renderer::GetSurfaceVBOs(SurfaceData *cellData) { +// std::map::iterator iterFind = mapSurfaceVBOCache.find(cellData->uniqueId); +// if(iterFind == mapSurfaceVBOCache.end()) { +// Vec2f *texCoords = &cellData->texCoords[0]; +// Vec2f *texCoordsSurface = &cellData->texCoordsSurface[0]; +// Vec3f *vertices = &cellData->vertices[0]; +// Vec3f *normals = &cellData->normals[0]; +// +// VisibleQuadContainerVBOCache vboCache; +// +// // Generate And Bind The Vertex Buffer +// glGenBuffersARB( 1, (GLuint*)&vboCache.m_nVBOVertices ); // Get A Valid Name +// glBindBufferARB( GL_ARRAY_BUFFER_ARB, vboCache.m_nVBOVertices ); // Bind The Buffer +// // Load The Data +// glBufferDataARB( GL_ARRAY_BUFFER_ARB, sizeof(Vec3f) * cellData->bufferCount, vertices, GL_STATIC_DRAW_ARB ); +// glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); +// +// assertGl(); +// // Generate And Bind The Texture Coordinate Buffer +// glGenBuffersARB( 1, (GLuint*)&vboCache.m_nVBOFowTexCoords ); // Get A Valid Name +// glBindBufferARB( GL_ARRAY_BUFFER_ARB, vboCache.m_nVBOFowTexCoords ); // Bind The Buffer +// // Load The Data +// glBufferDataARB( GL_ARRAY_BUFFER_ARB, sizeof(Vec2f) * cellData->bufferCount, texCoords, GL_STATIC_DRAW_ARB ); +// glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); +// +// assertGl(); +// // Generate And Bind The Texture Coordinate Buffer +// glGenBuffersARB( 1, (GLuint*)&vboCache.m_nVBOSurfaceTexCoords ); // Get A Valid Name +// glBindBufferARB( GL_ARRAY_BUFFER_ARB, vboCache.m_nVBOSurfaceTexCoords ); // Bind The Buffer +// // Load The Data +// glBufferDataARB( GL_ARRAY_BUFFER_ARB, sizeof(Vec2f) * cellData->bufferCount, texCoordsSurface, GL_STATIC_DRAW_ARB ); +// glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); +// +// assertGl(); +// // Generate And Bind The Normal Buffer +// glGenBuffersARB( 1, (GLuint*)&vboCache.m_nVBONormals ); // Get A Valid Name +// glBindBufferARB( GL_ARRAY_BUFFER_ARB, vboCache.m_nVBONormals ); // Bind The Buffer +// // Load The Data +// glBufferDataARB( GL_ARRAY_BUFFER_ARB, sizeof(Vec3f) * cellData->bufferCount, normals, GL_STATIC_DRAW_ARB ); +// glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); +// +// vboCache.hasBuiltVBOs = true; +// +// mapSurfaceVBOCache[cellData->uniqueId] = vboCache; +// +// // don't need the data in computer RAM anymore its in the GPU now +// cellData->texCoords.clear(); +// cellData->texCoordsSurface.clear(); +// cellData->vertices.clear(); +// cellData->normals.clear(); +// } +// +// return &mapSurfaceVBOCache[cellData->uniqueId]; +//} void Renderer::ReleaseSurfaceVBOs() { for(std::map::iterator iterFind = mapSurfaceVBOCache.begin(); @@ -7685,31 +7685,31 @@ void Renderer::loadConfig() { } } -Texture2D *Renderer::saveScreenToTexture(int x, int y, int width, int height) { - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); - - Config &config= Config::getInstance(); - Texture2D::Filter textureFilter = strToTextureFilter(config.getString("Filter")); - int maxAnisotropy = config.getInt("FilterMaxAnisotropy"); - - Texture2D *texture = GraphicsInterface::getInstance().getFactory()->newTexture2D(); - texture->setForceCompressionDisabled(true); - texture->setMipmap(false); - Pixmap2D *pixmapScreenShot = texture->getPixmap(); - pixmapScreenShot->init(width, height, 3); - texture->init(textureFilter,maxAnisotropy); - - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); - //glFinish(); - - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); - glReadPixels(x, y, pixmapScreenShot->getW(), pixmapScreenShot->getH(), - GL_RGB, GL_UNSIGNED_BYTE, pixmapScreenShot->getPixels()); - - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); - - return texture; -} +//Texture2D *Renderer::saveScreenToTexture(int x, int y, int width, int height) { +// if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); +// +// Config &config= Config::getInstance(); +// Texture2D::Filter textureFilter = strToTextureFilter(config.getString("Filter")); +// int maxAnisotropy = config.getInt("FilterMaxAnisotropy"); +// +// Texture2D *texture = GraphicsInterface::getInstance().getFactory()->newTexture2D(); +// texture->setForceCompressionDisabled(true); +// texture->setMipmap(false); +// Pixmap2D *pixmapScreenShot = texture->getPixmap(); +// pixmapScreenShot->init(width, height, 3); +// texture->init(textureFilter,maxAnisotropy); +// +// if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); +// //glFinish(); +// +// if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); +// glReadPixels(x, y, pixmapScreenShot->getW(), pixmapScreenShot->getH(), +// GL_RGB, GL_UNSIGNED_BYTE, pixmapScreenShot->getPixels()); +// +// if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); +// +// return texture; +//} void Renderer::saveScreen(const string &path,int w, int h) { const Metrics &sm= Metrics::getInstance(); @@ -8303,111 +8303,111 @@ void Renderer::render2dMenuSetup() { //if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); } -void Renderer::init3dListMenu(const MainMenu *mm) { - if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true) { - return; - } - - //this->mm3d = mm; - //printf("In [%s::%s Line: %d] this->custom_mm3d [%p] this->mm3d [%p]\n",__FILE__,__FUNCTION__,__LINE__,this->custom_mm3d,this->mm3d); - -/* - assertGl(); - - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); - - const Metrics &metrics= Metrics::getInstance(); - //const MenuBackground *mb= mm->getConstMenuBackground(); - const MenuBackground *mb = NULL; - if(mm != NULL) { - mb = mm->getConstMenuBackground(); - } - - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); - - if(this->customlist3dMenu != NULL) { - *this->customlist3dMenu = glGenLists(1); - assertGl(); - } - else { - list3dMenu= glGenLists(1); - assertGl(); - list3dMenuValid=true; - } - - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); - - if(this->customlist3dMenu != NULL) { - glNewList(*this->customlist3dMenu, GL_COMPILE); - } - else { - glNewList(list3dMenu, GL_COMPILE); - } - - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); - //misc - glViewport(0, 0, metrics.getScreenW(), metrics.getScreenH()); - glClearColor(0.4f, 0.4f, 0.4f, 1.f); - glFrontFace(GL_CW); - glEnable(GL_CULL_FACE); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - gluPerspective(perspFov, metrics.getAspectRatio(), perspNearPlane, 1000000); - - //texture state - glEnable(GL_TEXTURE_2D); - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - - //material state - glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, defSpecularColor.ptr()); - glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, defAmbientColor.ptr()); - glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, defDiffuseColor.ptr()); - glColor4fv(defColor.ptr()); - glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE); - - //blend state - glDisable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - - //alpha test state - glEnable(GL_ALPHA_TEST); - glAlphaFunc(GL_GREATER, 0.f); - - //depth test state - glEnable(GL_DEPTH_TEST); - glDepthMask(GL_TRUE); - glDepthFunc(GL_LESS); - - //lighting state - glEnable(GL_LIGHTING); - - //matrix mode - glMatrixMode(GL_MODELVIEW); - - //stencil test - glDisable(GL_STENCIL_TEST); - - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); - - //fog - if(mb != NULL && mb->getFog()){ - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); - - glEnable(GL_FOG); - glFogi(GL_FOG_MODE, GL_EXP2); - glFogf(GL_FOG_DENSITY, mb->getFogDensity()); - } - - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); - - glEndList(); - - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); - - //assert - assertGl(); -*/ -} +//void Renderer::init3dListMenu(const MainMenu *mm) { +// if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true) { +// return; +// } +// +// //this->mm3d = mm; +// //printf("In [%s::%s Line: %d] this->custom_mm3d [%p] this->mm3d [%p]\n",__FILE__,__FUNCTION__,__LINE__,this->custom_mm3d,this->mm3d); +// +///* +// assertGl(); +// +// if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); +// +// const Metrics &metrics= Metrics::getInstance(); +// //const MenuBackground *mb= mm->getConstMenuBackground(); +// const MenuBackground *mb = NULL; +// if(mm != NULL) { +// mb = mm->getConstMenuBackground(); +// } +// +// if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); +// +// if(this->customlist3dMenu != NULL) { +// *this->customlist3dMenu = glGenLists(1); +// assertGl(); +// } +// else { +// list3dMenu= glGenLists(1); +// assertGl(); +// list3dMenuValid=true; +// } +// +// if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); +// +// if(this->customlist3dMenu != NULL) { +// glNewList(*this->customlist3dMenu, GL_COMPILE); +// } +// else { +// glNewList(list3dMenu, GL_COMPILE); +// } +// +// if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); +// //misc +// glViewport(0, 0, metrics.getScreenW(), metrics.getScreenH()); +// glClearColor(0.4f, 0.4f, 0.4f, 1.f); +// glFrontFace(GL_CW); +// glEnable(GL_CULL_FACE); +// glMatrixMode(GL_PROJECTION); +// glLoadIdentity(); +// gluPerspective(perspFov, metrics.getAspectRatio(), perspNearPlane, 1000000); +// +// //texture state +// glEnable(GL_TEXTURE_2D); +// glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); +// +// //material state +// glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, defSpecularColor.ptr()); +// glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, defAmbientColor.ptr()); +// glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, defDiffuseColor.ptr()); +// glColor4fv(defColor.ptr()); +// glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE); +// +// //blend state +// glDisable(GL_BLEND); +// glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); +// +// //alpha test state +// glEnable(GL_ALPHA_TEST); +// glAlphaFunc(GL_GREATER, 0.f); +// +// //depth test state +// glEnable(GL_DEPTH_TEST); +// glDepthMask(GL_TRUE); +// glDepthFunc(GL_LESS); +// +// //lighting state +// glEnable(GL_LIGHTING); +// +// //matrix mode +// glMatrixMode(GL_MODELVIEW); +// +// //stencil test +// glDisable(GL_STENCIL_TEST); +// +// if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); +// +// //fog +// if(mb != NULL && mb->getFog()){ +// if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); +// +// glEnable(GL_FOG); +// glFogi(GL_FOG_MODE, GL_EXP2); +// glFogf(GL_FOG_DENSITY, mb->getFogDensity()); +// } +// +// if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); +// +// glEndList(); +// +// if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); +// +// //assert +// assertGl(); +//*/ +//} void Renderer::render3dMenuSetup(const MainMenu *mm) { //if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); @@ -8880,60 +8880,60 @@ void Renderer::renderProgressBar(int size, int x, int y, Font2D *font, int custo } -void Renderer::renderTile(const Vec2i &pos) { - if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true) { - return; - } - - const Map *map= game->getWorld()->getMap(); - Vec2i scaledPos= pos * Map::cellScale; - - glMatrixMode(GL_MODELVIEW); - glPushMatrix(); - glTranslatef(-0.5f, 0.f, -0.5f); - - glInitNames(); - for(int i=0; i < Map::cellScale; ++i) { - for(int j=0; j < Map::cellScale; ++j) { - - Vec2i renderPos= scaledPos + Vec2i(i, j); - - glPushName(renderPos.y); - glPushName(renderPos.x); - - glDisable(GL_CULL_FACE); - - float h1 = map->getCell(renderPos.x, renderPos.y)->getHeight(); - float h2 = map->getCell(renderPos.x, renderPos.y+1)->getHeight(); - float h3 = map->getCell(renderPos.x+1, renderPos.y)->getHeight(); - float h4 = map->getCell(renderPos.x+1, renderPos.y+1)->getHeight(); - - glBegin(GL_TRIANGLE_STRIP); - glVertex3f( - static_cast(renderPos.x), - h1, - static_cast(renderPos.y)); - glVertex3f( - static_cast(renderPos.x), - h2, - static_cast(renderPos.y+1)); - glVertex3f( - static_cast(renderPos.x+1), - h3, - static_cast(renderPos.y)); - glVertex3f( - static_cast(renderPos.x+1), - h4, - static_cast(renderPos.y+1)); - glEnd(); - - glPopName(); - glPopName(); - } - } - - glPopMatrix(); -} +//void Renderer::renderTile(const Vec2i &pos) { +// if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true) { +// return; +// } +// +// const Map *map= game->getWorld()->getMap(); +// Vec2i scaledPos= pos * Map::cellScale; +// +// glMatrixMode(GL_MODELVIEW); +// glPushMatrix(); +// glTranslatef(-0.5f, 0.f, -0.5f); +// +// glInitNames(); +// for(int i=0; i < Map::cellScale; ++i) { +// for(int j=0; j < Map::cellScale; ++j) { +// +// Vec2i renderPos= scaledPos + Vec2i(i, j); +// +// glPushName(renderPos.y); +// glPushName(renderPos.x); +// +// glDisable(GL_CULL_FACE); +// +// float h1 = map->getCell(renderPos.x, renderPos.y)->getHeight(); +// float h2 = map->getCell(renderPos.x, renderPos.y+1)->getHeight(); +// float h3 = map->getCell(renderPos.x+1, renderPos.y)->getHeight(); +// float h4 = map->getCell(renderPos.x+1, renderPos.y+1)->getHeight(); +// +// glBegin(GL_TRIANGLE_STRIP); +// glVertex3f( +// static_cast(renderPos.x), +// h1, +// static_cast(renderPos.y)); +// glVertex3f( +// static_cast(renderPos.x), +// h2, +// static_cast(renderPos.y+1)); +// glVertex3f( +// static_cast(renderPos.x+1), +// h3, +// static_cast(renderPos.y)); +// glVertex3f( +// static_cast(renderPos.x+1), +// h4, +// static_cast(renderPos.y+1)); +// glEnd(); +// +// glPopName(); +// glPopName(); +// } +// } +// +// glPopMatrix(); +//} void Renderer::renderQuad(int x, int y, int w, int h, const Texture2D *texture) { if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true) { @@ -9404,16 +9404,16 @@ std::pair Renderer::posInCellQuadCache(Vec2i pos) { return result; } -Vec3f Renderer::getMarkedCellScreenPosQuadCache(Vec2i pos) { - Vec3f result(-1,-1,-1); - if(std::find( - quadCache.visibleScaledCellList.begin(), - quadCache.visibleScaledCellList.end(), - pos) != quadCache.visibleScaledCellList.end()) { - result = quadCache.visibleScaledCellToScreenPosList[pos]; - } - return result; -} +//Vec3f Renderer::getMarkedCellScreenPosQuadCache(Vec2i pos) { +// Vec3f result(-1,-1,-1); +// if(std::find( +// quadCache.visibleScaledCellList.begin(), +// quadCache.visibleScaledCellList.end(), +// pos) != quadCache.visibleScaledCellList.end()) { +// result = quadCache.visibleScaledCellToScreenPosList[pos]; +// } +// return result; +//} void Renderer::beginRenderToTexture(Texture2D **renderToTexture) { if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true) { diff --git a/source/glest_game/graphics/renderer.h b/source/glest_game/graphics/renderer.h index abeaa6ee..3eea90fa 100644 --- a/source/glest_game/graphics/renderer.h +++ b/source/glest_game/graphics/renderer.h @@ -353,7 +353,7 @@ private: vector normals; }; - VisibleQuadContainerVBOCache * GetSurfaceVBOs(SurfaceData *cellData); + //VisibleQuadContainerVBOCache * GetSurfaceVBOs(SurfaceData *cellData); void ReleaseSurfaceVBOs(); std::map > > mapSurfaceData; static bool rendererEnded; @@ -427,8 +427,8 @@ private: } mapRenderer; bool ExtractFrustum(VisibleQuadContainerCache &quadCacheItem); - bool PointInFrustum(vector > &frustum, float x, float y, float z ); - bool SphereInFrustum(vector > &frustum, float x, float y, float z, float radius); + //bool PointInFrustum(vector > &frustum, float x, float y, float z ); + //bool SphereInFrustum(vector > &frustum, float x, float y, float z, float radius); bool CubeInFrustum(vector > &frustum, float x, float y, float z, float size ); private: @@ -464,7 +464,7 @@ public: inline int getPointCount() const {return pointCount;} //misc - void reloadResources(); + //void reloadResources(); //engine interface void initTexture(ResourceScope rs, Texture *texture); @@ -480,7 +480,7 @@ public: Font2D *newFont(ResourceScope rs); Font3D *newFont3D(ResourceScope rs); void endFont(::Shared::Graphics::Font *font, ResourceScope rs, bool mustExistInList=false); - void resetFontManager(ResourceScope rs); + //void resetFontManager(ResourceScope rs); inline TextRenderer2D *getTextRenderer() const {return textRenderer;} inline TextRenderer3D *getTextRenderer3D() const {return textRenderer3D;} @@ -496,7 +496,7 @@ public: //lights and camera void setupLighting(); - void setupLightingForRotatedModel(); + //void setupLightingForRotatedModel(); void loadGameCameraMatrix(); void loadCameraMatrix(const Camera *camera); void computeVisibleQuad(); @@ -630,7 +630,7 @@ public: VisibleQuadContainerCache & getQuadCache(bool updateOnDirtyFrame=true,bool forceNew=false); std::pair posInCellQuadCache(Vec2i pos); - Vec3f getMarkedCellScreenPosQuadCache(Vec2i pos); + //Vec3f getMarkedCellScreenPosQuadCache(Vec2i pos); void updateMarkedCellScreenPosQuadCache(Vec2i pos); void forceQuadCacheUpdate(); void renderVisibleMarkedCells(bool renderTextHint=false,int x=-1, int y=-1); @@ -644,7 +644,7 @@ public: std::size_t getCurrentPixelByteCount(ResourceScope rs=rsGame) const; unsigned int getSaveScreenQueueSize(); - Texture2D *saveScreenToTexture(int x, int y, int width, int height); + //Texture2D *saveScreenToTexture(int x, int y, int width, int height); void renderProgressBar(int size, int x, int y, Font2D *font,int customWidth=-1, string prefixLabel="", bool centeredText=true); @@ -657,7 +657,7 @@ public: void setCustom3dMenu(const MainMenu *mm) { this->custom_mm3d = mm; } const MainMenu * getCustom3dMenu() { return this->custom_mm3d; } - void init3dListMenu(const MainMenu *mm); + //void init3dListMenu(const MainMenu *mm); void setProgram(Program *program) { this->program = program; } @@ -699,7 +699,7 @@ private: void internalRenderHp(int numberOfBars, int barNumber, float hp, Vec3f posVector, float width, float singleHPheight, Vec3f rightVector, Vec3f upVector); void renderTeamColorEffect(Vec3f &v, int heigth, int size, Vec3f color, const Texture2D *texture); void renderArrow(const Vec3f &pos1, const Vec3f &pos2, const Vec3f &color, float width); - void renderTile(const Vec2i &pos); + //void renderTile(const Vec2i &pos); void renderQuad(int x, int y, int w, int h, const Texture2D *texture); void simpleTask(BaseThread *callingThread,void *userdata); diff --git a/source/glest_game/gui/selection.cpp b/source/glest_game/gui/selection.cpp index f23dd007..87809950 100644 --- a/source/glest_game/gui/selection.cpp +++ b/source/glest_game/gui/selection.cpp @@ -324,12 +324,12 @@ void Selection::removeUnitFromGroup(int groupIndex,int unitId) { } } -vector Selection::getUnitsForGroup(int groupIndex) { - if(groupIndex < 0 || groupIndex >= maxGroups) { - throw megaglest_runtime_error("Invalid value for groupIndex = " + intToStr(groupIndex)); - } - return groups[groupIndex]; -} +//vector Selection::getUnitsForGroup(int groupIndex) { +// if(groupIndex < 0 || groupIndex >= maxGroups) { +// throw megaglest_runtime_error("Invalid value for groupIndex = " + intToStr(groupIndex)); +// } +// return groups[groupIndex]; +//} void Selection::recallGroup(int groupIndex,bool clearSelection){ if(groupIndex < 0 || groupIndex >= maxGroups) { diff --git a/source/glest_game/gui/selection.h b/source/glest_game/gui/selection.h index 794d501c..b305df8f 100644 --- a/source/glest_game/gui/selection.h +++ b/source/glest_game/gui/selection.h @@ -94,7 +94,7 @@ public: void removeUnitFromGroup(int groupIndex,int UnitId); void recallGroup(int groupIndex, bool clearSelection=true); - vector getUnitsForGroup(int groupIndex); + //vector getUnitsForGroup(int groupIndex); virtual void unitEvent(UnitObserver::Event event, const Unit *unit); bool canSelectUnitFactionCheck(const Unit *unit) const; diff --git a/source/glest_game/main/program.cpp b/source/glest_game/main/program.cpp index 45bd6b87..a2618863 100644 --- a/source/glest_game/main/program.cpp +++ b/source/glest_game/main/program.cpp @@ -967,19 +967,19 @@ void Program::resetSoundSystem() { startSoundSystem(); } -void Program::reInitGl() { - if(window != NULL) { - Config &config= Config::getInstance(); - window->initGl(config.getInt("ColorBits"), - config.getInt("DepthBits"), - config.getInt("StencilBits"), - config.getBool("HardwareAcceleration","false"), - config.getBool("FullScreenAntiAliasing","false"), - config.getFloat("GammaValue","0.0")); - window->setText(config.getString("WindowTitle","MegaGlest")); - initResolution(); - } -} +//void Program::reInitGl() { +// if(window != NULL) { +// Config &config= Config::getInstance(); +// window->initGl(config.getInt("ColorBits"), +// config.getInt("DepthBits"), +// config.getInt("StencilBits"), +// config.getBool("HardwareAcceleration","false"), +// config.getBool("FullScreenAntiAliasing","false"), +// config.getFloat("GammaValue","0.0")); +// window->setText(config.getString("WindowTitle","MegaGlest")); +// initResolution(); +// } +//} void Program::consoleAddLine(string line) { if(programState != NULL) { diff --git a/source/glest_game/main/program.h b/source/glest_game/main/program.h index 8fcb7db9..954d5716 100644 --- a/source/glest_game/main/program.h +++ b/source/glest_game/main/program.h @@ -222,7 +222,7 @@ public: void renderProgramMsgBox(); bool isInSpecialKeyCaptureEvent() { return programState->isInSpecialKeyCaptureEvent(); } - void reInitGl(); + //void reInitGl(); void resetSoundSystem(); void stopSoundSystem(); void startSoundSystem(); diff --git a/source/glest_game/menu/menu_state_masterserver.cpp b/source/glest_game/menu/menu_state_masterserver.cpp index b1876ec9..b5d98463 100644 --- a/source/glest_game/menu/menu_state_masterserver.cpp +++ b/source/glest_game/menu/menu_state_masterserver.cpp @@ -405,11 +405,11 @@ void MenuStateMasterserver::reloadUI() { GraphicComponent::reloadFontsForRegisterGraphicComponents(containerName); } -void MenuStateMasterserver::setConsolePos(int yPos){ - consoleIRC.setYPos(yPos); - lines[2].setY(consoleIRC.getYPos()-10); - chatManager.setYPos(consoleIRC.getYPos()-20); -} +//void MenuStateMasterserver::setConsolePos(int yPos){ +// consoleIRC.setYPos(yPos); +// lines[2].setY(consoleIRC.getYPos()-10); +// chatManager.setYPos(consoleIRC.getYPos()-20); +//} void MenuStateMasterserver::setButtonLinePosition(int pos){ buttonReturn.setY(pos); diff --git a/source/glest_game/menu/menu_state_masterserver.h b/source/glest_game/menu/menu_state_masterserver.h index f803a51b..55f2ac00 100644 --- a/source/glest_game/menu/menu_state_masterserver.h +++ b/source/glest_game/menu/menu_state_masterserver.h @@ -135,7 +135,7 @@ public: private: void showMessageBox(const string &text, const string &header, bool toggle); bool connectToServer(string ipString, int port); - void setConsolePos(int yPos); + //void setConsolePos(int yPos); void setButtonLinePosition(int pos); void clearServerLines(); void clearUserButtons(); diff --git a/source/glest_game/network/connection_slot.cpp b/source/glest_game/network/connection_slot.cpp index b2e95d9d..6242a4c8 100644 --- a/source/glest_game/network/connection_slot.cpp +++ b/source/glest_game/network/connection_slot.cpp @@ -98,10 +98,10 @@ void ConnectionSlotThread::setTaskCompleted(int eventId) { } } -void ConnectionSlotThread::purgeAllEvents() { - MutexSafeWrapper safeMutex(triggerIdMutex,CODE_AT_LINE); - eventList.clear(); -} +//void ConnectionSlotThread::purgeAllEvents() { +// MutexSafeWrapper safeMutex(triggerIdMutex,CODE_AT_LINE); +// eventList.clear(); +//} void ConnectionSlotThread::setAllEventsCompleted() { MutexSafeWrapper safeMutex(triggerIdMutex,CODE_AT_LINE); @@ -1574,12 +1574,12 @@ vector ConnectionSlot::getPendingNetworkCommandList(bool clearLi return ret; } -void ConnectionSlot::clearPendingNetworkCommandList() { - MutexSafeWrapper safeMutexSlot(mutexPendingNetworkCommandList,CODE_AT_LINE); - if(vctPendingNetworkCommandList.empty() == false) { - vctPendingNetworkCommandList.clear(); - } -} +//void ConnectionSlot::clearPendingNetworkCommandList() { +// MutexSafeWrapper safeMutexSlot(mutexPendingNetworkCommandList,CODE_AT_LINE); +// if(vctPendingNetworkCommandList.empty() == false) { +// vctPendingNetworkCommandList.clear(); +// } +//} bool ConnectionSlot::hasValidSocketId() { bool result = false; diff --git a/source/glest_game/network/connection_slot.h b/source/glest_game/network/connection_slot.h index 79224dbb..2f6cd6a0 100644 --- a/source/glest_game/network/connection_slot.h +++ b/source/glest_game/network/connection_slot.h @@ -114,7 +114,7 @@ public: void setSlotIndex(int index) { this->slotIndex = index; } void purgeCompletedEvents(); - void purgeAllEvents(); + //void purgeAllEvents(); void setAllEventsCompleted(); virtual bool canShutdown(bool deleteSelfIfShutdownDelayed=false); @@ -222,7 +222,7 @@ public: void clearThreadErrorList() { threadErrorList.clear(); } vector getPendingNetworkCommandList(bool clearList=false); - void clearPendingNetworkCommandList(); + //void clearPendingNetworkCommandList(); void signalUpdate(ConnectionSlotEvent *event); bool updateCompleted(ConnectionSlotEvent *event); diff --git a/source/glest_game/steam/steam.cpp b/source/glest_game/steam/steam.cpp index 6eed708d..4b874fd4 100644 --- a/source/glest_game/steam/steam.cpp +++ b/source/glest_game/steam/steam.cpp @@ -151,9 +151,9 @@ struct SteamPrivate { STEAMSHIM_setStatF(name, value); update(); } - void clearLocalStats() { - stats.clear(); - } +// void clearLocalStats() { +// stats.clear(); +// } const STEAMSHIM_Event * update(STEAMSHIM_EventType *waitForEvent=NULL) { const STEAMSHIM_Event *e; diff --git a/source/glest_game/type_instances/command.cpp b/source/glest_game/type_instances/command.cpp index f55819d2..56f45b50 100644 --- a/source/glest_game/type_instances/command.cpp +++ b/source/glest_game/type_instances/command.cpp @@ -92,9 +92,9 @@ void Command::setPos(const Vec2i &pos){ this->pos= pos; } -void Command::setOriginalPos(const Vec2i &pos) { - this->originalPos= pos; -} +//void Command::setOriginalPos(const Vec2i &pos) { +// this->originalPos= pos; +//} void Command::setPosToOriginalPos() { this->pos= this->originalPos; diff --git a/source/glest_game/type_instances/command.h b/source/glest_game/type_instances/command.h index 302e2519..8c04fea4 100644 --- a/source/glest_game/type_instances/command.h +++ b/source/glest_game/type_instances/command.h @@ -77,7 +77,7 @@ public: //set void setCommandType(const CommandType *commandType); void setPos(const Vec2i &pos); - void setOriginalPos(const Vec2i &pos); + //void setOriginalPos(const Vec2i &pos); void setPosToOriginalPos(); void setUnit(Unit *unit); diff --git a/source/glest_game/type_instances/faction.cpp b/source/glest_game/type_instances/faction.cpp index 4c057eec..56ffd19e 100644 --- a/source/glest_game/type_instances/faction.cpp +++ b/source/glest_game/type_instances/faction.cpp @@ -633,18 +633,18 @@ void Faction::removeUnitFromMovingList(int unitId) { unitsMovingList.erase(unitId); } -int Faction::getUnitMovingListCount() { - return (int)unitsMovingList.size(); -} +//int Faction::getUnitMovingListCount() { +// return (int)unitsMovingList.size(); +//} void Faction::addUnitToPathfindingList(int unitId) { //printf("ADD (1) Faction [%d - %s] threaded updates for [%d] units\n",this->getStartLocationIndex(),this->getType()->getName().c_str(),unitsPathfindingList.size()); unitsPathfindingList[unitId] = getWorld()->getFrameCount(); //printf("ADD (2) Faction [%d - %s] threaded updates for [%d] units\n",this->getStartLocationIndex(),this->getType()->getName().c_str(),unitsPathfindingList.size()); } -void Faction::removeUnitFromPathfindingList(int unitId) { - unitsPathfindingList.erase(unitId); -} +//void Faction::removeUnitFromPathfindingList(int unitId) { +// unitsPathfindingList.erase(unitId); +//} int Faction::getUnitPathfindingListCount() { //printf("GET Faction [%d - %s] threaded updates for [%d] units\n",this->getStartLocationIndex(),this->getType()->getName().c_str(),unitsPathfindingList.size()); @@ -1939,84 +1939,84 @@ void Faction::deletePixels() { } } -Unit * Faction::findClosestUnitWithSkillClass( const Vec2i &pos,const CommandClass &cmdClass, - const std::vector &skillClassList, - const UnitType *unitType) { - Unit *result = NULL; - -/* - std::map >::iterator iterFind = cacheUnitCommandClassList.find(cmdClass); - if(iterFind != cacheUnitCommandClassList.end()) { - for(std::map::iterator iter = iterFind->second.begin(); - iter != iterFind->second.end(); ++iter) { - Unit *curUnit = findUnit(iter->second); - if(curUnit != NULL) { - - const CommandType *cmdType = curUnit->getType()->getFirstCtOfClass(cmdClass); - bool isUnitPossibleCandidate = (cmdType != NULL); - if(skillClassList.empty() == false) { - isUnitPossibleCandidate = false; - - for(int j = 0; j < skillClassList.size(); ++j) { - SkillClass skValue = skillClassList[j]; - if(curUnit->getCurrSkill()->getClass() == skValue) { - isUnitPossibleCandidate = true; - break; - } - } - } - - if(isUnitPossibleCandidate == true) { - if(result == NULL || curUnit->getPos().dist(pos) < result->getPos().dist(pos)) { - result = curUnit; - } - } - } - } - } -*/ - - //if(result == NULL) { - for(int i = 0; i < getUnitCount(); ++i) { - Unit *curUnit = getUnit(i); - - bool isUnitPossibleCandidate = false; - - const CommandType *cmdType = curUnit->getType()->getFirstCtOfClass(cmdClass); - if(cmdType != NULL) { - const RepairCommandType *rct = dynamic_cast(cmdType); - if(rct != NULL && rct->isRepairableUnitType(unitType)) { - isUnitPossibleCandidate = true; - } - } - else { - isUnitPossibleCandidate = false; - } - - if(isUnitPossibleCandidate == true && skillClassList.empty() == false) { - isUnitPossibleCandidate = false; - - for(int j = 0; j < (int)skillClassList.size(); ++j) { - SkillClass skValue = skillClassList[j]; - if(curUnit->getCurrSkill()->getClass() == skValue) { - isUnitPossibleCandidate = true; - break; - } - } - } - - - if(isUnitPossibleCandidate == true) { - //cacheUnitCommandClassList[cmdClass][curUnit->getId()] = curUnit->getId(); - - if(result == NULL || curUnit->getPos().dist(pos) < result->getPos().dist(pos)) { - result = curUnit; - } - } - } - //} - return result; -} +//Unit * Faction::findClosestUnitWithSkillClass( const Vec2i &pos,const CommandClass &cmdClass, +// const std::vector &skillClassList, +// const UnitType *unitType) { +// Unit *result = NULL; +// +///* +// std::map >::iterator iterFind = cacheUnitCommandClassList.find(cmdClass); +// if(iterFind != cacheUnitCommandClassList.end()) { +// for(std::map::iterator iter = iterFind->second.begin(); +// iter != iterFind->second.end(); ++iter) { +// Unit *curUnit = findUnit(iter->second); +// if(curUnit != NULL) { +// +// const CommandType *cmdType = curUnit->getType()->getFirstCtOfClass(cmdClass); +// bool isUnitPossibleCandidate = (cmdType != NULL); +// if(skillClassList.empty() == false) { +// isUnitPossibleCandidate = false; +// +// for(int j = 0; j < skillClassList.size(); ++j) { +// SkillClass skValue = skillClassList[j]; +// if(curUnit->getCurrSkill()->getClass() == skValue) { +// isUnitPossibleCandidate = true; +// break; +// } +// } +// } +// +// if(isUnitPossibleCandidate == true) { +// if(result == NULL || curUnit->getPos().dist(pos) < result->getPos().dist(pos)) { +// result = curUnit; +// } +// } +// } +// } +// } +//*/ +// +// //if(result == NULL) { +// for(int i = 0; i < getUnitCount(); ++i) { +// Unit *curUnit = getUnit(i); +// +// bool isUnitPossibleCandidate = false; +// +// const CommandType *cmdType = curUnit->getType()->getFirstCtOfClass(cmdClass); +// if(cmdType != NULL) { +// const RepairCommandType *rct = dynamic_cast(cmdType); +// if(rct != NULL && rct->isRepairableUnitType(unitType)) { +// isUnitPossibleCandidate = true; +// } +// } +// else { +// isUnitPossibleCandidate = false; +// } +// +// if(isUnitPossibleCandidate == true && skillClassList.empty() == false) { +// isUnitPossibleCandidate = false; +// +// for(int j = 0; j < (int)skillClassList.size(); ++j) { +// SkillClass skValue = skillClassList[j]; +// if(curUnit->getCurrSkill()->getClass() == skValue) { +// isUnitPossibleCandidate = true; +// break; +// } +// } +// } +// +// +// if(isUnitPossibleCandidate == true) { +// //cacheUnitCommandClassList[cmdClass][curUnit->getId()] = curUnit->getId(); +// +// if(result == NULL || curUnit->getPos().dist(pos) < result->getPos().dist(pos)) { +// result = curUnit; +// } +// } +// } +// //} +// return result; +//} int Faction::getFrameCount() { int frameCount = 0; diff --git a/source/glest_game/type_instances/faction.h b/source/glest_game/type_instances/faction.h index 92f94e8e..5cc97471 100644 --- a/source/glest_game/type_instances/faction.h +++ b/source/glest_game/type_instances/faction.h @@ -238,10 +238,10 @@ public: //std::map unitsMovingList; void addUnitToMovingList(int unitId); void removeUnitFromMovingList(int unitId); - int getUnitMovingListCount(); + //int getUnitMovingListCount(); void addUnitToPathfindingList(int unitId); - void removeUnitFromPathfindingList(int unitId); + //void removeUnitFromPathfindingList(int unitId); int getUnitPathfindingListCount(); void clearUnitsPathfinding(); bool canUnitsPathfind(); @@ -347,9 +347,9 @@ public: void cleanupResourceTypeTargetCache(std::vector *deleteListPtr,int frameIndex); inline int getCacheResourceTargetListSize() const { return (int)cacheResourceTargetList.size(); } - Unit * findClosestUnitWithSkillClass(const Vec2i &pos,const CommandClass &cmdClass, - const std::vector &skillClassList, - const UnitType *unitType); +// Unit * findClosestUnitWithSkillClass(const Vec2i &pos,const CommandClass &cmdClass, +// const std::vector &skillClassList, +// const UnitType *unitType); void deletePixels(); diff --git a/source/glest_game/type_instances/unit.cpp b/source/glest_game/type_instances/unit.cpp index 1923ce0f..9ac35861 100644 --- a/source/glest_game/type_instances/unit.cpp +++ b/source/glest_game/type_instances/unit.cpp @@ -195,20 +195,20 @@ Checksum UnitPathBasic::getCRC() { // class UnitPath // ===================================================== -void WaypointPath::condense() { - if (size() < 2) { - return; - } - iterator prev, curr; - prev = curr = begin(); - while (++curr != end()) { - if (prev->dist(*curr) < 3.f) { - prev = erase(prev); - } else { - ++prev; - } - } -} +//void WaypointPath::condense() { +// if (size() < 2) { +// return; +// } +// iterator prev, curr; +// prev = curr = begin(); +// while (++curr != end()) { +// if (prev->dist(*curr) < 3.f) { +// prev = erase(prev); +// } else { +// ++prev; +// } +// } +//} std::string UnitPath::toString() const { std::string result = "unit path blockCount = " + intToStr(blockCount) + " pathQueue size = " + intToStr(size()); @@ -866,17 +866,17 @@ void Unit::setModelFacing(CardinalDir value) { lastRotation = targetRotation = rotation = value * 90.f; } -void Unit::setCurrField(Field currField) { - Field original_field = this->currField; - - this->currField = currField; - - if(original_field != this->currField) { - //printf("File: %s line: %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__LINE__); - game->getScriptManager()->onUnitTriggerEvent(this,utet_FieldChanged); - //printf("File: %s line: %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__LINE__); - } -} +//void Unit::setCurrField(Field currField) { +// Field original_field = this->currField; +// +// this->currField = currField; +// +// if(original_field != this->currField) { +// //printf("File: %s line: %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__LINE__); +// game->getScriptManager()->onUnitTriggerEvent(this,utet_FieldChanged); +// //printf("File: %s line: %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__LINE__); +// } +//} // ====================================== get ====================================== Vec2i Unit::getCenteredPos() const { @@ -2163,9 +2163,9 @@ void Unit::addObserver(UnitObserver *unitObserver){ observers.push_back(unitObserver); } -void Unit::removeObserver(UnitObserver *unitObserver){ - observers.remove(unitObserver); -} +//void Unit::removeObserver(UnitObserver *unitObserver){ +// observers.remove(unitObserver); +//} void Unit::notifyObservers(UnitObserver::Event event){ for(Observers::iterator it= observers.begin(); it!=observers.end(); ++it){ @@ -4568,13 +4568,13 @@ void Unit::addBadHarvestPos(const Vec2i &value) { cleanupOldBadHarvestPos(); } -void Unit::removeBadHarvestPos(const Vec2i &value) { - std::map::iterator iter = badHarvestPosList.find(value); - if(iter != badHarvestPosList.end()) { - badHarvestPosList.erase(value); - } - cleanupOldBadHarvestPos(); -} +//void Unit::removeBadHarvestPos(const Vec2i &value) { +// std::map::iterator iter = badHarvestPosList.find(value); +// if(iter != badHarvestPosList.end()) { +// badHarvestPosList.erase(value); +// } +// cleanupOldBadHarvestPos(); +//} void Unit::cleanupOldBadHarvestPos() { const unsigned int cleanupInterval = (GameConstants::updateFps * 5); diff --git a/source/glest_game/type_instances/unit.h b/source/glest_game/type_instances/unit.h index 7534a62c..458a69df 100644 --- a/source/glest_game/type_instances/unit.h +++ b/source/glest_game/type_instances/unit.h @@ -284,7 +284,7 @@ public: void push(const Vec2i &pos) { push_front(pos); } Vec2i peek() const {return front();} void pop() {erase(begin());} - void condense(); + //void condense(); }; @@ -613,7 +613,7 @@ public: bool isInteresting(InterestingUnitType iut) const; //set - void setCurrField(Field currField); + //void setCurrField(Field currField); void setCurrSkill(const SkillType *currSkill); void setCurrSkill(SkillClass sc); @@ -668,7 +668,7 @@ public: //observers void addObserver(UnitObserver *unitObserver) ; - void removeObserver(UnitObserver *unitObserver); + //void removeObserver(UnitObserver *unitObserver); void notifyObservers(UnitObserver::Event event); //other @@ -720,7 +720,7 @@ public: //std::vector > getBadHarvestPosList() const { return badHarvestPosList; } //void setBadHarvestPosList(std::vector > value) { badHarvestPosList = value; } void addBadHarvestPos(const Vec2i &value); - void removeBadHarvestPos(const Vec2i &value); + //void removeBadHarvestPos(const Vec2i &value); inline bool isBadHarvestPos(const Vec2i &value,bool checkPeerUnits=true) const { bool result = false; if(badHarvestPosList.empty() == true) { diff --git a/source/glest_game/types/faction_type.cpp b/source/glest_game/types/faction_type.cpp index f614ed2f..329a9f43 100644 --- a/source/glest_game/types/faction_type.cpp +++ b/source/glest_game/types/faction_type.cpp @@ -915,25 +915,25 @@ const UnitType *FactionType::getUnitType(const string &name) const{ throw megaglest_runtime_error("Unit type not found: [" + name + "] in faction type [" + this->name + "]",true); } -const UnitType *FactionType::getUnitTypeById(int id) const{ - for(int i=0; i < (int)unitTypes.size();i++){ - if(unitTypes[i].getId() == id) { - return &unitTypes[i]; - } - } - - printf("In [%s::%s Line: %d] scanning [%d] size = " MG_SIZE_T_SPECIFIER "\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,id,unitTypes.size()); - for(int i=0; i < (int)unitTypes.size();i++){ - printf("In [%s::%s Line: %d] scanning [%s] idx = %d [%s][%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,name.c_str(),i,unitTypes[i].getName(false).c_str(),unitTypes[i].getId()); - } - - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] scanning [%s] size = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,name.c_str(),unitTypes.size()); - for(int i=0; i < (int)unitTypes.size();i++){ - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] scanning [%s] idx = %d [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,name.c_str(),i,unitTypes[i].getName(false).c_str()); - } - - throw megaglest_runtime_error("Unit type not found: [" + intToStr(id) + "] in faction type [" + this->name + "]",true); -} +//const UnitType *FactionType::getUnitTypeById(int id) const{ +// for(int i=0; i < (int)unitTypes.size();i++){ +// if(unitTypes[i].getId() == id) { +// return &unitTypes[i]; +// } +// } +// +// printf("In [%s::%s Line: %d] scanning [%d] size = " MG_SIZE_T_SPECIFIER "\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,id,unitTypes.size()); +// for(int i=0; i < (int)unitTypes.size();i++){ +// printf("In [%s::%s Line: %d] scanning [%s] idx = %d [%s][%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,name.c_str(),i,unitTypes[i].getName(false).c_str(),unitTypes[i].getId()); +// } +// +// if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] scanning [%s] size = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,name.c_str(),unitTypes.size()); +// for(int i=0; i < (int)unitTypes.size();i++){ +// if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] scanning [%s] idx = %d [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,name.c_str(),i,unitTypes[i].getName(false).c_str()); +// } +// +// throw megaglest_runtime_error("Unit type not found: [" + intToStr(id) + "] in faction type [" + this->name + "]",true); +//} const UpgradeType *FactionType::getUpgradeType(const string &name) const{ for(int i=0; i < (int)upgradeTypes.size();i++){ diff --git a/source/glest_game/types/faction_type.h b/source/glest_game/types/faction_type.h index c965f0ce..8cf3863c 100644 --- a/source/glest_game/types/faction_type.h +++ b/source/glest_game/types/faction_type.h @@ -142,7 +142,7 @@ public: const UnitType *getUnitType(const string &name) const; - const UnitType *getUnitTypeById(int id) const; + //const UnitType *getUnitTypeById(int id) const; const UpgradeType *getUpgradeType(const string &name) const; int getStartingResourceAmount(const ResourceType *resourceType) const; diff --git a/source/glest_game/types/unit_type.cpp b/source/glest_game/types/unit_type.cpp index be0deae6..d2daf6b1 100644 --- a/source/glest_game/types/unit_type.cpp +++ b/source/glest_game/types/unit_type.cpp @@ -1184,15 +1184,15 @@ bool UnitType::hasCommandType(const CommandType *commandType) const { return false; } -bool UnitType::hasSkillType(const SkillType *skillType) const { - assert(skillType!=NULL); - for(int i=0; i < (int)skillTypes.size(); ++i) { - if(skillTypes[i]==skillType) { - return true; - } - } - return false; -} +//bool UnitType::hasSkillType(const SkillType *skillType) const { +// assert(skillType!=NULL); +// for(int i=0; i < (int)skillTypes.size(); ++i) { +// if(skillTypes[i]==skillType) { +// return true; +// } +// } +// return false; +//} bool UnitType::isOfClass(UnitClass uc) const{ switch(uc){ diff --git a/source/glest_game/types/unit_type.h b/source/glest_game/types/unit_type.h index fced61b1..0b3a75c3 100644 --- a/source/glest_game/types/unit_type.h +++ b/source/glest_game/types/unit_type.h @@ -336,7 +336,7 @@ public: inline bool hasCommandClass(CommandClass commandClass) const { return firstCommandTypeOfClass[commandClass]!=NULL; } - bool hasSkillType(const SkillType *skillType) const; + //bool hasSkillType(const SkillType *skillType) const; bool hasSkillClass(SkillClass skillClass) const; inline bool hasCellMap() const {return cellMap!=NULL;} inline bool getAllowEmptyCellMap() const {return allowEmptyCellMap;} diff --git a/source/glest_game/world/map.cpp b/source/glest_game/world/map.cpp index 2702e773..5f8fe06e 100644 --- a/source/glest_game/world/map.cpp +++ b/source/glest_game/world/map.cpp @@ -906,29 +906,29 @@ bool Map::canMorph(const Vec2i &pos,const Unit *currentUnit,const UnitType *targ } } -bool Map::canOccupy(const Vec2i &pos, Field field, const UnitType *ut, CardinalDir facing) { - if (ut->hasCellMap() && isInside(pos) && isInsideSurface(toSurfCoords(pos))) { - for (int y=0; y < ut->getSize(); ++y) { - for (int x=0; x < ut->getSize(); ++x) { - Vec2i cellPos = pos + Vec2i(x, y); - if(isInside(cellPos) && isInsideSurface(toSurfCoords(cellPos))) { - if (ut->getCellMapCell(x, y, facing)) { - if (isFreeCell(cellPos, field) == false) { - return false; - } - } - } - else { - return false; - } - } - } - return true; - } - else { - return isFreeCells(pos, ut->getSize(), field); - } -} +//bool Map::canOccupy(const Vec2i &pos, Field field, const UnitType *ut, CardinalDir facing) { +// if (ut->hasCellMap() && isInside(pos) && isInsideSurface(toSurfCoords(pos))) { +// for (int y=0; y < ut->getSize(); ++y) { +// for (int x=0; x < ut->getSize(); ++x) { +// Vec2i cellPos = pos + Vec2i(x, y); +// if(isInside(cellPos) && isInsideSurface(toSurfCoords(cellPos))) { +// if (ut->getCellMapCell(x, y, facing)) { +// if (isFreeCell(cellPos, field) == false) { +// return false; +// } +// } +// } +// else { +// return false; +// } +// } +// } +// return true; +// } +// else { +// return isFreeCells(pos, ut->getSize(), field); +// } +//} // ==================== unit placement ==================== @@ -1193,38 +1193,38 @@ Vec2i Map::computeDestPos( const Vec2i &refUnitPos, const Vec2i &unitPos, return pos; } -std::pair Map::getUnitDistanceToPos(const Unit *unit,Vec2i pos,const UnitType *ut) { - if(unit == NULL) { - throw megaglest_runtime_error("unit == NULL"); - } - - std::pair result(-1,Vec2i(0)); - //int unitId= unit->getId(); - Vec2i unitPos= computeDestPos(unit->getPosNotThreadSafe(), unit->getPosNotThreadSafe(), pos); - - Vec2i start = pos - Vec2i(1); - int unitTypeSize = 0; - if(ut != NULL) { - unitTypeSize = ut->getSize(); - } - Vec2i end = pos + Vec2i(unitTypeSize); - - for(int i = start.x; i <= end.x; ++i) { - for(int j = start.y; j <= end.y; ++j){ - Vec2i testPos(i,j); - - if(ut == NULL || isInUnitTypeCells(ut, pos,testPos) == false) { - float distance = unitPos.dist(testPos); - if(result.first < 0 || result.first > distance) { - result.first = distance; - result.second = testPos; - } - } - } - } - - return result; -} +//std::pair Map::getUnitDistanceToPos(const Unit *unit,Vec2i pos,const UnitType *ut) { +// if(unit == NULL) { +// throw megaglest_runtime_error("unit == NULL"); +// } +// +// std::pair result(-1,Vec2i(0)); +// //int unitId= unit->getId(); +// Vec2i unitPos= computeDestPos(unit->getPosNotThreadSafe(), unit->getPosNotThreadSafe(), pos); +// +// Vec2i start = pos - Vec2i(1); +// int unitTypeSize = 0; +// if(ut != NULL) { +// unitTypeSize = ut->getSize(); +// } +// Vec2i end = pos + Vec2i(unitTypeSize); +// +// for(int i = start.x; i <= end.x; ++i) { +// for(int j = start.y; j <= end.y; ++j){ +// Vec2i testPos(i,j); +// +// if(ut == NULL || isInUnitTypeCells(ut, pos,testPos) == false) { +// float distance = unitPos.dist(testPos); +// if(result.first < 0 || result.first > distance) { +// result.first = distance; +// result.second = testPos; +// } +// } +// } +// } +// +// return result; +//} const Unit * Map::findClosestUnitToPos(const Selection *selection, Vec2i originalBuildPos, const UnitType *ut) const { @@ -2049,9 +2049,9 @@ bool PosQuadIterator::next() { return true; } -void PosQuadIterator::skipX() { - pos.x+= step; -} +//void PosQuadIterator::skipX() { +// pos.x+= step; +//} const Vec2i &PosQuadIterator::getPos(){ return pos; diff --git a/source/glest_game/world/map.h b/source/glest_game/world/map.h index 665d0504..ea7103ab 100644 --- a/source/glest_game/world/map.h +++ b/source/glest_game/world/map.h @@ -332,7 +332,7 @@ public: bool isFreeCellsOrHasUnit(const Vec2i &pos, int size, Field field, const Unit *unit) const; bool isAproxFreeCells(const Vec2i &pos, int size, Field field, int teamIndex) const; bool canMorph(const Vec2i &pos,const Unit *currentUnit,const UnitType *targetUnitType ) const; - bool canOccupy(const Vec2i &pos, Field field, const UnitType *ut, CardinalDir facing); + //bool canOccupy(const Vec2i &pos, Field field, const UnitType *ut, CardinalDir facing); //unit placement bool aproxCanMove(const Unit *unit, const Vec2i &pos1, const Vec2i &pos2, std::map > > > > *lookupCache=NULL) const; @@ -348,7 +348,7 @@ public: bool isInUnitTypeCells(const UnitType *ut, const Vec2i &pos,const Vec2i &testPos) const; bool isNextToUnitTypeCells(const UnitType *ut, const Vec2i &pos,const Vec2i &testPos) const; Vec2i findBestBuildApproach(const Unit *unit, Vec2i originalBuildPos,const UnitType *ut) const; - std::pair getUnitDistanceToPos(const Unit *unit,Vec2i pos,const UnitType *ut); + //std::pair getUnitDistanceToPos(const Unit *unit,Vec2i pos,const UnitType *ut); //misc bool isNextTo(const Vec2i &pos, const Unit *unit) const; @@ -660,7 +660,7 @@ private: public: PosQuadIterator(const Map *map,const Quad2i &quad, int step=1); bool next(); - void skipX(); + //void skipX(); const Vec2i &getPos(); }; diff --git a/source/shared_lib/include/graphics/gl/opengl.h b/source/shared_lib/include/graphics/gl/opengl.h index 1897bc0d..7ca2f896 100644 --- a/source/shared_lib/include/graphics/gl/opengl.h +++ b/source/shared_lib/include/graphics/gl/opengl.h @@ -48,7 +48,7 @@ int getGlMaxTextureSize(); int getGlMaxTextureUnits(); int getGlModelviewMatrixStackDepth(); int getGlProjectionMatrixStackDepth(); -void checkGlExtension(const char *extensionName); +//void checkGlExtension(const char *extensionName); void inline _assertGl(const char *file, int line, GLenum *forceErrorNumber = NULL) { GLenum error = (forceErrorNumber != NULL ? *forceErrorNumber : glGetError()); diff --git a/source/shared_lib/include/util/util.h b/source/shared_lib/include/util/util.h index 5d23c536..c1127890 100644 --- a/source/shared_lib/include/util/util.h +++ b/source/shared_lib/include/util/util.h @@ -231,7 +231,7 @@ string replaceBy(const string &s, char c1, char c2); vector split(string s,string d); string toLower(const string &s); bool compareNonCaseSensitive(const string a, const string b); -void copyStringToBuffer(char *buffer, int bufferSize, const string& s); +//void copyStringToBuffer(char *buffer, int bufferSize, const string& s); //numeric fcs int clamp(int value, int min, int max); diff --git a/source/shared_lib/sources/graphics/gl/opengl.cpp b/source/shared_lib/sources/graphics/gl/opengl.cpp index c2a21ff2..10d1e685 100644 --- a/source/shared_lib/sources/graphics/gl/opengl.cpp +++ b/source/shared_lib/sources/graphics/gl/opengl.cpp @@ -167,10 +167,10 @@ int getGlProjectionMatrixStackDepth() { return i; } -void checkGlExtension(const char *extensionName) { - if(!isGlExtensionSupported(extensionName)){ - throw megaglest_runtime_error("OpenGL extension not supported: " + string(extensionName)); - } -} +//void checkGlExtension(const char *extensionName) { +// if(!isGlExtensionSupported(extensionName)){ +// throw megaglest_runtime_error("OpenGL extension not supported: " + string(extensionName)); +// } +//} }}}// end namespace diff --git a/source/shared_lib/sources/util/conversion.cpp b/source/shared_lib/sources/util/conversion.cpp index f4eff1d8..ba8568fd 100644 --- a/source/shared_lib/sources/util/conversion.cpp +++ b/source/shared_lib/sources/util/conversion.cpp @@ -201,8 +201,8 @@ bool IsNumeric(const char *p, bool allowNegative) { class Comma: public numpunct// own facet class { protected: - char do_thousands_sep() const { return ','; }// use the comma - string do_grouping() const { return "\3"; }//group 3 digits + //char do_thousands_sep() const { return ','; }// use the comma + //string do_grouping() const { return "\3"; }//group 3 digits }; string formatNumber(uint64 f) { diff --git a/source/shared_lib/sources/util/util.cpp b/source/shared_lib/sources/util/util.cpp index 4d898622..62bf2790 100644 --- a/source/shared_lib/sources/util/util.cpp +++ b/source/shared_lib/sources/util/util.cpp @@ -745,10 +745,10 @@ bool compareNonCaseSensitive(const string a, const string b) { return (toLower(a) < toLower(b)); } -void copyStringToBuffer(char *buffer, int bufferSize, const string& s){ - strncpy(buffer, s.c_str(), bufferSize-1); - buffer[bufferSize-1]= '\0'; -} +//void copyStringToBuffer(char *buffer, int bufferSize, const string& s){ +// strncpy(buffer, s.c_str(), bufferSize-1); +// buffer[bufferSize-1]= '\0'; +//} // ==================== numeric fcs ====================