diff --git a/source/glest_game/ai/ai.cpp b/source/glest_game/ai/ai.cpp index 467ffc20c..4a1ba8877 100644 --- a/source/glest_game/ai/ai.cpp +++ b/source/glest_game/ai/ai.cpp @@ -761,7 +761,7 @@ void Ai::sendScoutPatrol(){ bool megaResourceAttack=(aiInterface->getControlType() == ctCpuMega || aiInterface->getControlType() == ctNetworkCpuMega) && random.randRange(0, 1) == 1; - if(possibleTargetFound == false && (megaResourceAttack || ultraResourceAttack)) { + if(megaResourceAttack || ultraResourceAttack) { Map *map= aiInterface->getMap(); const TechTree *tt= aiInterface->getTechTree(); @@ -1131,8 +1131,8 @@ void Ai::unblockUnits() { //printf("#2 AI found blocked unit [%d - %s]\n",u->getId(),u->getFullName().c_str()); - int failureCount = 0; - int cellCount = 0; + //int failureCount = 0; + //int cellCount = 0; for(int i = -1; i <= 1; ++i) { for(int j = -1; j <= 1; ++j) { @@ -1141,10 +1141,10 @@ void Ai::unblockUnits() { if(pos != unitPos) { bool canUnitMoveToCell = map->aproxCanMove(u, unitPos, pos); if(canUnitMoveToCell == false) { - failureCount++; + //failureCount++; getAdjacentUnits(signalAdjacentUnits, u); } - cellCount++; + //cellCount++; } } } diff --git a/source/glest_game/ai/ai.h b/source/glest_game/ai/ai.h index 69dd3979d..8e8db410d 100644 --- a/source/glest_game/ai/ai.h +++ b/source/glest_game/ai/ai.h @@ -66,9 +66,9 @@ private: ProduceTask(); public: - ProduceTask(UnitClass unitClass); - ProduceTask(const UnitType *unitType); - ProduceTask(const ResourceType *resourceType); + explicit ProduceTask(UnitClass unitClass); + explicit ProduceTask(const UnitType *unitType); + explicit ProduceTask(const ResourceType *resourceType); UnitClass getUnitClass() const {return unitClass;} const UnitType *getUnitType() const {return unitType;} @@ -91,8 +91,8 @@ private: BuildTask(); public: - BuildTask(const UnitType *unitType); - BuildTask(const ResourceType *resourceType); + explicit BuildTask(const UnitType *unitType); + explicit BuildTask(const ResourceType *resourceType); BuildTask(const UnitType *unitType, const Vec2i &pos); const UnitType *getUnitType() const {return unitType;} @@ -113,7 +113,7 @@ private: UpgradeTask(); public: - UpgradeTask(const UpgradeType *upgradeType); + explicit UpgradeTask(const UpgradeType *upgradeType); const UpgradeType *getUpgradeType() const {return upgradeType;} virtual string toString() const; diff --git a/source/glest_game/ai/ai_interface.cpp b/source/glest_game/ai/ai_interface.cpp index 50bd16673..0789a9f02 100644 --- a/source/glest_game/ai/ai_interface.cpp +++ b/source/glest_game/ai/ai_interface.cpp @@ -359,7 +359,7 @@ std::pair AiInterface::giveCommand(int unitIndex, CommandC std::pair result(crFailUndefined,""); if(executeCommandOverNetwork() == true) { const Unit *unit = getMyUnit(unitIndex); - result = commander->tryGiveCommand(unit, unit->getType()->getFirstCtOfClass(commandClass), pos, unit->getType(),CardinalDir::NORTH); + result = commander->tryGiveCommand(unit, unit->getType()->getFirstCtOfClass(commandClass), pos, unit->getType(),CardinalDir(CardinalDir::NORTH)); return result; } else { @@ -410,7 +410,7 @@ std::pair AiInterface::giveCommand(const Unit *unit, const if(executeCommandOverNetwork() == true) { result = commander->tryGiveCommand(unit, commandType, pos, - unit->getType(),CardinalDir::NORTH, false, NULL,unitGroupCommandId); + unit->getType(),CardinalDir(CardinalDir::NORTH), false, NULL,unitGroupCommandId); return result; } else { @@ -460,7 +460,7 @@ std::pair AiInterface::giveCommand(int unitIndex, const Co if(executeCommandOverNetwork() == true) { const Unit *unit = getMyUnit(unitIndex); - result = commander->tryGiveCommand(unit, commandType, pos, unit->getType(),CardinalDir::NORTH); + result = commander->tryGiveCommand(unit, commandType, pos, unit->getType(),CardinalDir(CardinalDir::NORTH)); return result; } else { @@ -508,13 +508,13 @@ std::pair AiInterface::giveCommand(int unitIndex, const Co if(executeCommandOverNetwork() == true) { const Unit *unit = getMyUnit(unitIndex); - result = commander->tryGiveCommand(unit, commandType, pos, ut,CardinalDir::NORTH); + result = commander->tryGiveCommand(unit, commandType, pos, ut,CardinalDir(CardinalDir::NORTH)); return result; } else { if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); - result = world->getFaction(factionIndex)->getUnit(unitIndex)->giveCommand(new Command(commandType, pos, ut, CardinalDir::NORTH)); + result = world->getFaction(factionIndex)->getUnit(unitIndex)->giveCommand(new Command(commandType, pos, ut, CardinalDir(CardinalDir::NORTH))); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); @@ -558,7 +558,7 @@ std::pair AiInterface::giveCommand(int unitIndex, const Co Unit *targetUnit = u; const Unit *unit = getMyUnit(unitIndex); - result = commander->tryGiveCommand(unit, commandType, Vec2i(0), unit->getType(),CardinalDir::NORTH,false,targetUnit); + result = commander->tryGiveCommand(unit, commandType, Vec2i(0), unit->getType(),CardinalDir(CardinalDir::NORTH),false,targetUnit); return result; } diff --git a/source/glest_game/ai/ai_interface.h b/source/glest_game/ai/ai_interface.h index e0cedefdd..83f54d22d 100644 --- a/source/glest_game/ai/ai_interface.h +++ b/source/glest_game/ai/ai_interface.h @@ -44,7 +44,7 @@ protected: virtual void setTaskCompleted(int frameIndex); public: - AiInterfaceThread(AiInterface *aiIntf); + explicit AiInterfaceThread(AiInterface *aiIntf); virtual ~AiInterfaceThread(); virtual void execute(); void signal(int frameIndex); diff --git a/source/glest_game/ai/ai_rule.h b/source/glest_game/ai/ai_rule.h index cb1a32697..d212a51f5 100644 --- a/source/glest_game/ai/ai_rule.h +++ b/source/glest_game/ai/ai_rule.h @@ -49,7 +49,7 @@ protected: Ai *ai; public: - AiRule(Ai *ai); + explicit AiRule(Ai *ai); virtual ~AiRule() {} virtual int getTestInterval() const= 0; //in milliseconds @@ -68,7 +68,7 @@ private: int stoppedWorkerIndex; public: - AiRuleWorkerHarvest(Ai *ai); + explicit AiRuleWorkerHarvest(Ai *ai); virtual int getTestInterval() const {return 2000;} virtual string getName() const {return "Worker stopped => Order worker to harvest";} @@ -86,7 +86,7 @@ private: int workerIndex; public: - AiRuleRefreshHarvester(Ai *ai); + explicit AiRuleRefreshHarvester(Ai *ai); virtual int getTestInterval() const {return 20000;} virtual string getName() const {return "Worker reassigned to needed resource";} @@ -101,7 +101,7 @@ public: class AiRuleScoutPatrol: public AiRule{ public: - AiRuleScoutPatrol(Ai *ai); + explicit AiRuleScoutPatrol(Ai *ai); virtual int getTestInterval() const {return 10000;} virtual string getName() const {return "Base is stable => Send scout patrol";} @@ -123,7 +123,7 @@ private: double getMinCastleHpRatio() const; public: - AiRuleRepair(Ai *ai); + explicit AiRuleRepair(Ai *ai); virtual int getTestInterval() const {return 10000;} virtual string getName() const {return "Building Damaged => Repair";} @@ -140,7 +140,7 @@ class AiRuleReturnBase: public AiRule{ private: int stoppedUnitIndex; public: - AiRuleReturnBase(Ai *ai); + explicit AiRuleReturnBase(Ai *ai); virtual int getTestInterval() const {return 5000;} virtual string getName() const {return "Stopped unit => Order return base";} @@ -163,7 +163,7 @@ private: bool ultraAttack; public: - AiRuleMassiveAttack(Ai *ai); + explicit AiRuleMassiveAttack(Ai *ai); virtual int getTestInterval() const {return 1000;} virtual string getName() const {return "Unit under attack => Order massive attack";} @@ -178,7 +178,7 @@ public: class AiRuleAddTasks: public AiRule{ public: - AiRuleAddTasks(Ai *ai); + explicit AiRuleAddTasks(Ai *ai); virtual int getTestInterval() const {return 5000;} virtual string getName() const {return "Tasks empty => Add tasks";} @@ -196,7 +196,7 @@ private: const UnitType *farm; public: - AiRuleBuildOneFarm(Ai *ai); + explicit AiRuleBuildOneFarm(Ai *ai); virtual int getTestInterval() const {return 10000;} virtual string getName() const {return "No farms => Build one";} @@ -219,7 +219,7 @@ private: bool newResourceBehaviour; public: - AiRuleProduceResourceProducer(Ai *ai); + explicit AiRuleProduceResourceProducer(Ai *ai); virtual int getTestInterval() const {return interval;} virtual string getName() const {return "No resources => Build Resource Producer";} @@ -241,7 +241,7 @@ private: bool newResourceBehaviour; public: - AiRuleProduce(Ai *ai); + explicit AiRuleProduce(Ai *ai); virtual int getTestInterval() const {return 2000;} virtual string getName() const {return "Performing produce task";} @@ -269,7 +269,7 @@ private: const BuildTask *buildTask; public: - AiRuleBuild(Ai *ai); + explicit AiRuleBuild(Ai *ai); virtual int getTestInterval() const {return 2000;} virtual string getName() const {return "Performing build task";} @@ -296,7 +296,7 @@ private: const UpgradeTask *upgradeTask; public: - AiRuleUpgrade(Ai *ai); + explicit AiRuleUpgrade(Ai *ai); virtual int getTestInterval() const {return 2000;} virtual string getName() const {return "Performing upgrade task";} @@ -322,7 +322,7 @@ private: const UnitType *storeType; public: - AiRuleExpand(Ai *ai); + explicit AiRuleExpand(Ai *ai); virtual int getTestInterval() const {return 30000;} virtual string getName() const {return "Expanding";} @@ -337,7 +337,7 @@ public: class AiRuleUnBlock: public AiRule{ public: - AiRuleUnBlock(Ai *ai); + explicit AiRuleUnBlock(Ai *ai); virtual int getTestInterval() const {return 3000;} virtual string getName() const {return "Blocked Units => Move surrounding units";} diff --git a/source/glest_game/ai/path_finder.h b/source/glest_game/ai/path_finder.h index 23717a77b..5906b487e 100644 --- a/source/glest_game/ai/path_finder.h +++ b/source/glest_game/ai/path_finder.h @@ -90,7 +90,7 @@ public: protected: Mutex *factionMutexPrecache; public: - FactionState(int factionIndex) : + explicit FactionState(int factionIndex) : //factionMutexPrecache(new Mutex) { factionMutexPrecache(NULL) { //, random(factionIndex) { @@ -184,7 +184,7 @@ private: public: PathFinder(); - PathFinder(const Map *map); + explicit PathFinder(const Map *map); ~PathFinder(); PathFinder(const PathFinder& obj) { @@ -265,7 +265,7 @@ private: if(SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled == true && SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynchMax).enabled == true) { char szBuf[8096]=""; - snprintf(szBuf,8096,"In processNode() nodeLimitReached %d unitFactionIndex %d foundOpenPosForPos %d allowUnitMoveSoon %d maxNodeCount %d node->pos = %s finalPos = %s sucPos = %s faction.openPosList.size() %ld closedNodesList.size() %ld", + snprintf(szBuf,8096,"In processNode() nodeLimitReached %d unitFactionIndex %d foundOpenPosForPos %d allowUnitMoveSoon %d maxNodeCount %d node->pos = %s finalPos = %s sucPos = %s faction.openPosList.size() %lu closedNodesList.size() %lu", nodeLimitReached,unitFactionIndex,foundOpenPosForPos, allowUnitMoveSoon, maxNodeCount,node->pos.getString().c_str(),finalPos.getString().c_str(),sucPos.getString().c_str(),faction.openPosList.size(),faction.closedNodesList.size()); if(Thread::isCurrentThreadMainThread() == false) { @@ -327,9 +327,9 @@ private: inline void doAStarPathSearch(bool & nodeLimitReached, int & whileLoopCount, int & unitFactionIndex, bool & pathFound, Node *& node, const Vec2i & finalPos, - std::map closedNodes, - std::map cameFrom, std::map , - bool> canAddNode, Unit *& unit, int & maxNodeCount, int curFrameIndex) { + const std::map &closedNodes, + const std::map &cameFrom, const std::map ,bool> &canAddNode, + Unit *& unit, int & maxNodeCount, int curFrameIndex) { if(SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled == true && SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynchMax).enabled == true) { diff --git a/source/glest_game/facilities/auto_test.h b/source/glest_game/facilities/auto_test.h index 3e5039324..73b878fc4 100644 --- a/source/glest_game/facilities/auto_test.h +++ b/source/glest_game/facilities/auto_test.h @@ -59,7 +59,7 @@ public: static void setMaxGameTime(time_t value) { gameTime = value; } static void setWantExitGameWhenDone(bool value) { wantExitGame = value; } static string getLoadGameSettingsFile() { return loadGameSettingsFile; } - static void setLoadGameSettingsFile(string filename) { loadGameSettingsFile = filename; } + static void setLoadGameSettingsFile(const string &filename) { loadGameSettingsFile = filename; } bool mustExitGame() const { return exitGame; } diff --git a/source/glest_game/facilities/components.cpp b/source/glest_game/facilities/components.cpp index 43f1f11f2..b6a5050bd 100644 --- a/source/glest_game/facilities/components.cpp +++ b/source/glest_game/facilities/components.cpp @@ -41,7 +41,7 @@ Vec3f GraphicComponent::customTextColor = Vec3f(1.0,1.0,1.0); std::map > GraphicComponent::registeredGraphicComponentList; -GraphicComponent::GraphicComponent(std::string containerName, std::string objName, bool registerControl) { +GraphicComponent::GraphicComponent(const std::string &containerName, const std::string &objName, bool registerControl) { this->containerName = containerName; this->instanceName = ""; if(containerName == "" || objName == "") { @@ -370,7 +370,7 @@ void GraphicComponent::resetFade(){ const int GraphicLabel::defH= 20; const int GraphicLabel::defW= 70; -GraphicLabel::GraphicLabel(std::string containerName, std::string objName, bool registerControl) : +GraphicLabel::GraphicLabel(const std::string &containerName, const std::string &objName, bool registerControl) : GraphicComponent(containerName, objName, registerControl) { centered = false; wordWrap = false; @@ -438,7 +438,7 @@ void GraphicLabel::setCenteredH(bool centered) { const int GraphicButton::defH= 22; const int GraphicButton::defW= 90; -GraphicButton::GraphicButton(std::string containerName, std::string objName, bool registerControl) : +GraphicButton::GraphicButton(const std::string &containerName, const std::string &objName, bool registerControl) : GraphicComponent(containerName,objName,registerControl) { lighted = false; @@ -469,7 +469,7 @@ bool GraphicButton::mouseMove(int x, int y){ const int GraphicListBox::defH= 22; const int GraphicListBox::defW= 140; -GraphicListBox::GraphicListBox(std::string containerName, std::string objName) +GraphicListBox::GraphicListBox(const std::string &containerName, const std::string &objName) : GraphicComponent(containerName, objName), graphButton1(containerName, objName + "_button1"), graphButton2(containerName, objName + "_button2") { selectedItemIndex = 0; @@ -707,7 +707,7 @@ bool GraphicListBox::mouseClick(int x, int y,string advanceToItemStartingWith) { const int GraphicMessageBox::defH= 280; const int GraphicMessageBox::defW= 350; -GraphicMessageBox::GraphicMessageBox(std::string containerName, std::string objName) : +GraphicMessageBox::GraphicMessageBox(const std::string &containerName, const std::string &objName) : GraphicComponent(containerName, objName) { header= ""; autoWordWrap=true; @@ -836,7 +836,7 @@ bool GraphicMessageBox::mouseClick(int x, int y, int &clickedButton){ const int GraphicLine::defH= 5; const int GraphicLine::defW= 1000; -GraphicLine::GraphicLine(std::string containerName, std::string objName) +GraphicLine::GraphicLine(const std::string &containerName, const std::string &objName) : GraphicComponent(containerName, objName) { horizontal = false; } @@ -853,7 +853,7 @@ void GraphicLine::init(int x, int y, int w, int h){ const int GraphicCheckBox::defH= 22; const int GraphicCheckBox::defW= 22; -GraphicCheckBox::GraphicCheckBox(std::string containerName, std::string objName) +GraphicCheckBox::GraphicCheckBox(const std::string &containerName, const std::string &objName) : GraphicComponent(containerName, objName) { value = false; lighted = false; @@ -895,7 +895,7 @@ bool GraphicCheckBox::mouseClick(int x, int y){ const int GraphicScrollBar::defThickness=20; const int GraphicScrollBar::defLength= 200; -GraphicScrollBar::GraphicScrollBar(std::string containerName, std::string objName) +GraphicScrollBar::GraphicScrollBar(const std::string &containerName, const std::string &objName) : GraphicComponent(containerName, objName) { lighted = false; activated = false; @@ -1041,7 +1041,8 @@ void GraphicScrollBar::arrangeComponents(vector &gcs) { const int PopupMenu::defH= 240; const int PopupMenu::defW= 350; -PopupMenu::PopupMenu(std::string containerName, std::string objName) : GraphicComponent(containerName, objName, false) { +PopupMenu::PopupMenu(const std::string &containerName, const std::string &objName) : + GraphicComponent(containerName, objName, false) { registerGraphicComponentOnlyFontCallbacks(containerName,objName); h= defH; diff --git a/source/glest_game/facilities/components.h b/source/glest_game/facilities/components.h index b089b47a6..554311cf0 100644 --- a/source/glest_game/facilities/components.h +++ b/source/glest_game/facilities/components.h @@ -75,7 +75,7 @@ protected: virtual void FontChangedCallback(std::string fontUniqueId, Font *font); public: - GraphicComponent(std::string containerName="", std::string objName="", bool registerControl=true); + GraphicComponent(const std::string &containerName="", const std::string &objName="", bool registerControl=true); virtual ~GraphicComponent(); static void setCustomTextColor(Vec3f value) { customTextColor = value; } @@ -164,7 +164,7 @@ private: Texture2D *texture; public: - GraphicLabel(std::string containerName="", std::string objName="", bool registerControl=true); + GraphicLabel(const std::string &containerName="", const std::string &objName="", bool registerControl=true); void init(int x, int y, int w=defW, int h=defH, bool centered= false, Vec3f textColor=GraphicComponent::customTextColor, bool wordWrap=false); virtual bool mouseMove(int x, int y); @@ -228,7 +228,7 @@ private: Texture *customTexture; public: - GraphicButton(std::string containerName="", std::string objName="", bool registerControl=true); + GraphicButton(const std::string &containerName="", const std::string &objName="", bool registerControl=true); void init(int x, int y, int w=defW, int h=defH); bool getUseCustomTexture() const { return useCustomTexture; } @@ -263,7 +263,7 @@ private: bool leftControlled; public: - GraphicListBox(std::string containerName="", std::string objName=""); + GraphicListBox(const std::string &containerName="", const std::string &objName=""); void init(int x, int y, int w=defW, int h=defH, Vec3f textColor=GraphicComponent::customTextColor); int getItemCount() const {return (int)items.size();} @@ -313,7 +313,7 @@ private: private: void alignButtons(); public: - GraphicMessageBox(std::string containerName="", std::string objName=""); + GraphicMessageBox(const std::string &containerName="", const std::string &objName=""); virtual ~GraphicMessageBox(); void init(const string &button1Str, const string &button2Str, int newWidth=-1,int newHeight=-1); void init(const string &button1Str, int newWidth=-1,int newHeight=-1); @@ -351,7 +351,7 @@ private: bool horizontal; public: - GraphicLine(std::string containerName="", std::string objName=""); + GraphicLine(const std::string &containerName="", const std::string &objName=""); void init(int x, int y, int w=defW, int h=defH); bool getHorizontal() const {return horizontal;} void setHorizontal(bool horizontal) {this->horizontal= horizontal;} @@ -371,7 +371,7 @@ private: bool lighted; public: - GraphicCheckBox(std::string containerName="", std::string objName=""); + GraphicCheckBox(const std::string &containerName="", const std::string &objName=""); void init(int x, int y, int w=defW, int h=defH); bool getValue() const {return value;} void setValue(bool value) {this->value= value;} @@ -403,7 +403,7 @@ private: int visibleCompPosEnd; public: - GraphicScrollBar(std::string containerName="", std::string objName=""); + GraphicScrollBar(const std::string &containerName="", const std::string &objName=""); void init(int x, int y, bool horizontal,int length=defLength, int thickness=defThickness); virtual bool mouseDown(int x, int y); virtual bool mouseMove(int x, int y); @@ -447,7 +447,7 @@ private: string header; public: - PopupMenu(std::string containerName="", std::string objName=""); + PopupMenu(const std::string &containerName="", const std::string &objName=""); virtual ~PopupMenu(); void init(string menuHeader, std::vector menuItems); diff --git a/source/glest_game/game/chat_manager.cpp b/source/glest_game/game/chat_manager.cpp index 502c6f2e5..3228d7036 100644 --- a/source/glest_game/game/chat_manager.cpp +++ b/source/glest_game/game/chat_manager.cpp @@ -260,8 +260,7 @@ void ChatManager::keyDown(SDL_KeyboardEvent key) { int newMatchedIndex = -1; for(unsigned int index = 0; index < (unsigned int)matchedIndexes.size(); ++index) { int possibleMatchIndex = matchedIndexes[index]; - if(replaceCurrentAutoCompleteName < 0 || - (replaceCurrentAutoCompleteName >= 0 && possibleMatchIndex > replaceCurrentAutoCompleteName)) { + if(replaceCurrentAutoCompleteName < 0 || possibleMatchIndex>replaceCurrentAutoCompleteName) { newMatchedIndex = possibleMatchIndex; break; } @@ -269,8 +268,7 @@ void ChatManager::keyDown(SDL_KeyboardEvent key) { if(newMatchedIndex < 0) { for(unsigned int index = 0; index < (unsigned int)matchedIndexes.size(); ++index) { int possibleMatchIndex = matchedIndexes[index]; - if(replaceCurrentAutoCompleteName < 0 || - (replaceCurrentAutoCompleteName >= 0 && possibleMatchIndex < replaceCurrentAutoCompleteName)) { + if(replaceCurrentAutoCompleteName < 0 || possibleMatchIndex>replaceCurrentAutoCompleteName) { newMatchedIndex = possibleMatchIndex; break; } @@ -308,8 +306,7 @@ void ChatManager::keyDown(SDL_KeyboardEvent key) { int newMatchedIndex = -1; for(unsigned int index = 0; index < (unsigned int)matchedIndexes.size(); ++index) { int possibleMatchIndex = matchedIndexes[index]; - if(replaceCurrentAutoCompleteName < 0 || - (replaceCurrentAutoCompleteName >= 0 && possibleMatchIndex > replaceCurrentAutoCompleteName)) { + if(replaceCurrentAutoCompleteName < 0 || possibleMatchIndex>replaceCurrentAutoCompleteName) { newMatchedIndex = possibleMatchIndex; break; } @@ -317,8 +314,7 @@ void ChatManager::keyDown(SDL_KeyboardEvent key) { if(newMatchedIndex < 0) { for(unsigned int index = 0; index < (unsigned int)matchedIndexes.size(); ++index) { int possibleMatchIndex = matchedIndexes[index]; - if(replaceCurrentAutoCompleteName < 0 || - (replaceCurrentAutoCompleteName >= 0 && possibleMatchIndex < replaceCurrentAutoCompleteName)) { + if(replaceCurrentAutoCompleteName < 0 || possibleMatchIndex>replaceCurrentAutoCompleteName) { newMatchedIndex = possibleMatchIndex; break; } diff --git a/source/glest_game/game/chat_manager.h b/source/glest_game/game/chat_manager.h index ac47a54ac..f63f78a6e 100644 --- a/source/glest_game/game/chat_manager.h +++ b/source/glest_game/game/chat_manager.h @@ -104,7 +104,7 @@ public: bool getDisableTeamMode() const { return disableTeamMode; } void setDisableTeamMode(bool value); - void setAutoCompleteTextList(vector list) { autoCompleteTextList = list; } + void setAutoCompleteTextList(const vector &list) { autoCompleteTextList = list; } bool isInCustomInputMode() const { return customCB != NULL; }; }; diff --git a/source/glest_game/game/console.cpp b/source/glest_game/game/console.cpp index 85dd50a3e..878d220d6 100644 --- a/source/glest_game/game/console.cpp +++ b/source/glest_game/game/console.cpp @@ -79,7 +79,7 @@ void Console::setFont3D(Font3D *font) { } } -void Console::registerGraphicComponent(std::string containerName, std::string objName) { +void Console::registerGraphicComponent(const std::string &containerName, const std::string &objName) { this->instanceName = objName; } @@ -118,7 +118,7 @@ void Console::addStdMessage(const string &s,bool clearOtherLines) { } } -void Console::addStdMessage(const string &s,string failText, bool clearOtherLines) { +void Console::addStdMessage(const string &s,const string &failText, bool clearOtherLines) { if(clearOtherLines == true) { addLineOnly(Lang::getInstance().getString(s) + failText); } @@ -136,11 +136,11 @@ void Console::addStdScenarioMessage(const string &s,bool clearOtherLines) { } } -void Console::addLineOnly(string line) { +void Console::addLineOnly(const string &line) { addLine(line,false,-1,Vec3f(1.f, 1.f, 1.f),false,true); } -void Console::addLine(string line, bool playSound, int playerIndex, Vec3f textColor, bool teamMode,bool clearOtherLines) { +void Console::addLine(const string &line, bool playSound, int playerIndex, Vec3f textColor, bool teamMode,bool clearOtherLines) { try { if(playSound == true) { SoundRenderer::getInstance().playFx(CoreData::getInstance().getClickSoundA()); @@ -186,7 +186,7 @@ void Console::addLine(string line, bool playSound, int playerIndex, Vec3f textCo } } -void Console::addLine(string line, bool playSound, string playerName, Vec3f textColor, bool teamMode) { +void Console::addLine(const string &line, bool playSound, const string &playerName, Vec3f textColor, bool teamMode) { try { if(playSound == true) { SoundRenderer::getInstance().playFx(CoreData::getInstance().getClickSoundA()); diff --git a/source/glest_game/game/console.h b/source/glest_game/game/console.h index d7bb73b17..af8b7d3ff 100644 --- a/source/glest_game/game/console.h +++ b/source/glest_game/game/console.h @@ -92,9 +92,9 @@ public: Console(); virtual ~Console(); - void registerGraphicComponent(std::string containerName, std::string objName); + void registerGraphicComponent(const std::string &containerName, const std::string &objName); string getInstanceName() const { return instanceName; } - void setInstanceName(string value) { instanceName = value; } + void setInstanceName(const string &value) { instanceName = value; } string getFontCallbackName() const { return fontCallbackName; } int getStoredLineCount() const {return (int)storedLines.size();} @@ -113,7 +113,7 @@ public: void setFont(Font2D *font); void setFont3D(Font3D *font); string getStringToHighlight() const { return stringToHighlight;} - void setStringToHighlight(string stringToHighlight) { this->stringToHighlight = stringToHighlight;} + void setStringToHighlight(const string &stringToHighlight) { this->stringToHighlight = stringToHighlight;} void resetFonts(); @@ -124,13 +124,13 @@ public: void clearStoredLines(); void addStdMessage(const string &s, bool clearOtherLines=false); - void addStdMessage(const string &s, string failText, bool clearOtherLines=false); + void addStdMessage(const string &s, const string &failText, bool clearOtherLines=false); void addStdScenarioMessage(const string &s,bool clearOtherLines=false); - void addLineOnly(string line); - void addLine(string line, bool playSound= false,int playerIndex=-1,Vec3f textColor=Vec3f(1.f, 1.f, 1.f),bool teamMode=false,bool clearOtherLines=false); - void addLine(string line, bool playSound,string playerName, Vec3f textColor=Vec3f(1.f, 1.f, 1.f),bool teamMode=false); - void addLine(string line, bool playSound, Vec3f textColor) { addLine(line,playSound,"",textColor,false); } + void addLineOnly(const string &line); + void addLine(const string &line, bool playSound= false,int playerIndex=-1,Vec3f textColor=Vec3f(1.f, 1.f, 1.f),bool teamMode=false,bool clearOtherLines=false); + void addLine(const string &line, bool playSound, const string &playerName, Vec3f textColor=Vec3f(1.f, 1.f, 1.f),bool teamMode=false); + void addLine(const string &line, bool playSound, Vec3f textColor) { addLine(line,playSound,"",textColor,false); } void update(); bool isEmpty(); diff --git a/source/glest_game/game/game.cpp b/source/glest_game/game/game.cpp index c8d65ca1e..01497950b 100644 --- a/source/glest_game/game/game.cpp +++ b/source/glest_game/game/game.cpp @@ -601,8 +601,8 @@ string Game::extractScenarioLogoFile(const GameSettings *settings, string &resul return scenarioDir; } -string Game::extractFactionLogoFile(bool &loadingImageUsed, string factionName, - string scenarioDir, string techName, Logger *logger, string factionLogoFilter) { +string Game::extractFactionLogoFile(bool &loadingImageUsed, const string &factionName, + string scenarioDir, const string &techName, Logger *logger, string factionLogoFilter) { string result = ""; if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Searching for faction loading screen\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); @@ -800,8 +800,8 @@ string Game::extractFactionLogoFile(bool &loadingImageUsed, string factionName, return result; } -string Game::extractTechLogoFile(string scenarioDir, string techName, - bool &loadingImageUsed, Logger *logger,string factionLogoFilter) { +string Game::extractTechLogoFile(string scenarioDir, const string &techName, + bool &loadingImageUsed, Logger *logger,const string &factionLogoFilter) { string result = ""; if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Searching for tech loading screen\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); Config &config = Config::getInstance(); @@ -891,7 +891,7 @@ void Game::loadHudTexture(const GameSettings *settings) } string Game::findFactionLogoFile(const GameSettings *settings, Logger *logger, - string factionLogoFilter) { + const string &factionLogoFilter) { string result = ""; if(settings == NULL) { result = ""; @@ -918,14 +918,15 @@ string Game::findFactionLogoFile(const GameSettings *settings, Logger *logger, } } - string scenarioDir = ""; - bool skipCustomLoadScreen = false; - if(skipCustomLoadScreen == false) { - scenarioDir = extractScenarioLogoFile(settings, result, loadingImageUsed, + //string scenarioDir = ""; + //bool skipCustomLoadScreen = false; + //if(skipCustomLoadScreen == false) { + string scenarioDir = extractScenarioLogoFile(settings, result, loadingImageUsed, logger, factionLogoFilter); - } + //} // try to use a faction related loading screen - if(skipCustomLoadScreen == false && loadingImageUsed == false) { + //if(skipCustomLoadScreen == false && loadingImageUsed == false) { + if(loadingImageUsed == false) { for(int i=0; i < settings->getFactionCount(); ++i ) { if( settings->getFactionControl(i) == ctHuman || (settings->getFactionControl(i) == ctNetwork && settings->getThisFactionIndex() == i)) { @@ -938,7 +939,8 @@ string Game::findFactionLogoFile(const GameSettings *settings, Logger *logger, } // try to use a tech related loading screen - if(skipCustomLoadScreen == false && loadingImageUsed == false){ + //if(skipCustomLoadScreen == false && loadingImageUsed == false){ + if(loadingImageUsed == false) { result = extractTechLogoFile(scenarioDir, techName, loadingImageUsed, logger, factionLogoFilter); } @@ -5299,9 +5301,7 @@ void Game::highlightUnit(int unitId,float radius, float thickness, Vec4f color) } void Game::unhighlightUnit(int unitId) { - if(unitHighlightList.find(unitId) != unitHighlightList.end()) { - unitHighlightList.erase(unitId); - } + unitHighlightList.erase(unitId); } // ==================== render ==================== @@ -6538,7 +6538,7 @@ void Game::saveGame(){ config.save(); } -string Game::saveGame(string name, string path) { +string Game::saveGame(string name, const string &path) { Config &config= Config::getInstance(); // auto name file if using saved file pattern string if(name == GameConstants::saveGameFilePattern) { diff --git a/source/glest_game/game/game.h b/source/glest_game/game/game.h index f17756f95..099bfa9df 100644 --- a/source/glest_game/game/game.h +++ b/source/glest_game/game/game.h @@ -313,10 +313,10 @@ public: Vec2i getPerformanceTimerResults(); 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, string factionLogoFilter=GameConstants::LOADING_SCREEN_FILE_FILTER); + 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, string factionName, string scenarioDir, string techName, Logger *logger=NULL, string factionLogoFilter=GameConstants::LOADING_SCREEN_FILE_FILTER); - static string extractTechLogoFile(string scenarioDir, string techName, 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); + static string extractTechLogoFile(string scenarioDir, const string &techName, bool &loadingImageUsed, Logger *logger=NULL,const string &factionLogoFilter=GameConstants::LOADING_SCREEN_FILE_FILTER); void loadHudTexture(const GameSettings *settings); @@ -332,7 +332,7 @@ public: void stopStreamingVideo(const string &playVideo); void stopAllVideo(); - string saveGame(string name, string path="saved/"); + string saveGame(string name, const string &path="saved/"); static void loadGame(string name,Program *programPtr,bool isMasterserverMode, const GameSettings *joinGameSettings=NULL); void addNetworkCommandToReplayList(NetworkCommand* networkCommand,int worldFrameCount); diff --git a/source/glest_game/game/game_camera.h b/source/glest_game/game/game_camera.h index 1b8481da5..d30f2fb70 100644 --- a/source/glest_game/game/game_camera.h +++ b/source/glest_game/game/game_camera.h @@ -176,7 +176,7 @@ public: void loadGame(const XmlNode *rootNode); private: - void setClampBounds(bool value) { clampBounds = value; } + //void setClampBounds(bool value) { clampBounds = value; } void resetPosition(); void setClampDisabled(bool value) { clampDisable = value; }; void clampPosXYZ(float x1, float x2, float y1, float y2, float z1, float z2); diff --git a/source/glest_game/game/game_constants.h b/source/glest_game/game/game_constants.h index e5c65828f..6a228258d 100644 --- a/source/glest_game/game/game_constants.h +++ b/source/glest_game/game/game_constants.h @@ -205,7 +205,7 @@ public: enum Enum { NORTH, EAST, SOUTH, WEST, COUNT }; CardinalDir() : value(NORTH) {} - CardinalDir(Enum v) : value(v) {} + explicit CardinalDir(Enum v) : value(v) {} explicit CardinalDir(int v) { assertDirValid(v); value = static_cast(v); diff --git a/source/glest_game/game/game_settings.h b/source/glest_game/game/game_settings.h index 19d85f171..c0456cc9a 100644 --- a/source/glest_game/game/game_settings.h +++ b/source/glest_game/game/game_settings.h @@ -451,7 +451,7 @@ public: this->networkPlayerGameStatus[factionIndex]= status; } - void setNetworkPlayerLanguages(int factionIndex, string language) { + void setNetworkPlayerLanguages(int factionIndex, const string &language) { if(factionIndex < 0 || factionIndex >= GameConstants::maxPlayers) { char szBuf[8096]=""; snprintf(szBuf,8096,"In [%s] Invalid factionIndex = %d\n",__FUNCTION__,factionIndex); @@ -536,7 +536,7 @@ public: void setTilesetCRC(uint32 value) { tilesetCRC = value; } void setTechCRC(uint32 value) { techCRC = value; } - void setFactionCRCList(vector > value) { factionCRCList = value; } + void setFactionCRCList(const vector > &value) { factionCRCList = value; } int getAiAcceptSwitchTeamPercentChance() const { return aiAcceptSwitchTeamPercentChance;} void setAiAcceptSwitchTeamPercentChance(int value) { aiAcceptSwitchTeamPercentChance = value; } diff --git a/source/glest_game/game/script_manager.cpp b/source/glest_game/game/script_manager.cpp index c48bef392..ffa0a0e8c 100644 --- a/source/glest_game/game/script_manager.cpp +++ b/source/glest_game/game/script_manager.cpp @@ -31,7 +31,7 @@ ScriptManagerMessage::ScriptManagerMessage() : text(""), header("") { this->messageNotTranslated = true; } -ScriptManagerMessage::ScriptManagerMessage(string textIn, string headerIn, +ScriptManagerMessage::ScriptManagerMessage(const string &textIn, const string &headerIn, int factionIndex,int teamIndex, bool messageNotTranslated) : text(textIn), header(headerIn) { this->factionIndex = factionIndex; @@ -1357,9 +1357,7 @@ void ScriptManager::unregisterCellTriggerEvent(int eventId) { if(unRegisterCellTriggerEventList.empty() == false) { for(int i = 0; i < (int)unRegisterCellTriggerEventList.size(); ++i) { int delayedEventId = unRegisterCellTriggerEventList[i]; - if(CellTriggerEventList.find(delayedEventId) != CellTriggerEventList.end()) { - CellTriggerEventList.erase(delayedEventId); - } + CellTriggerEventList.erase(delayedEventId); } unRegisterCellTriggerEventList.clear(); } diff --git a/source/glest_game/game/script_manager.h b/source/glest_game/game/script_manager.h index 1b9330e18..859e49cc5 100644 --- a/source/glest_game/game/script_manager.h +++ b/source/glest_game/game/script_manager.h @@ -57,7 +57,7 @@ private: public: ScriptManagerMessage(); - ScriptManagerMessage(string text, string header, int factionIndex=-1,int teamIndex=-1,bool messageNotTranslated=false); + ScriptManagerMessage(const string &text, const string &header, int factionIndex=-1,int teamIndex=-1,bool messageNotTranslated=false); const string &getText() const {return text;} const string &getHeader() const {return header;} int getFactionIndex() const {return factionIndex;} diff --git a/source/glest_game/game/stats.h b/source/glest_game/game/stats.h index b36e88222..a460fd0a2 100644 --- a/source/glest_game/game/stats.h +++ b/source/glest_game/game/stats.h @@ -142,12 +142,12 @@ public: void die(int diedFactionIndex, bool isDeathCounted); void produce(int producerFactionIndex, bool isProductionCounted); void harvest(int harvesterFactionIndex, int amount); - void setPlayerName(int playerIndex, string value) {playerStats[playerIndex].playerName = value; } + void setPlayerName(int playerIndex, const string &value) {playerStats[playerIndex].playerName = value; } void setPlayerColor(int playerIndex, Vec3f value) {playerStats[playerIndex].playerColor = value; } void addFramesToCalculatePlaytime() {this->framesToCalculatePlaytime++; } - void setTechName(string name) { techName = name; } + void setTechName(const string &name) { techName = name; } string getTechName() const { return techName; } string getStats() const; diff --git a/source/glest_game/global/core_data.cpp b/source/glest_game/global/core_data.cpp index f0758433e..d32655f06 100644 --- a/source/glest_game/global/core_data.cpp +++ b/source/glest_game/global/core_data.cpp @@ -1175,7 +1175,7 @@ void CoreData::unRegisterFontChangedCallback(std::string entityName) { void CoreData::triggerFontChangedCallbacks(std::string fontUniqueId, Font *font) { for (std::map >::const_iterator iterMap = registeredFontChangedCallbacks.begin(); - iterMap != registeredFontChangedCallbacks.end(); iterMap++) { + iterMap != registeredFontChangedCallbacks.end(); ++iterMap) { for (unsigned int index = 0; index < iterMap->second.size(); ++index) { //printf("Font Callback detected calling: Control [%s] for Font: [%s] value [%p]\n",iterMap->first.c_str(),fontUniqueId.c_str(),font); FontChangedCallbackInterface *cb = iterMap->second[index]; diff --git a/source/glest_game/graphics/renderer.cpp b/source/glest_game/graphics/renderer.cpp index d486dd82b..974d22be1 100644 --- a/source/glest_game/graphics/renderer.cpp +++ b/source/glest_game/graphics/renderer.cpp @@ -2547,9 +2547,9 @@ void Renderer::renderResourceStatus() { twoRessourceLines, rt, rowsRendered, resourceCountRendered); } } - if(resourceCountRendered > 0) { - rowsRendered++; - } + //if(resourceCountRendered > 0) { + // rowsRendered++; + //} } glPopAttrib(); @@ -4305,9 +4305,9 @@ void Renderer::MapRenderer::Layer::render(VisibleQuadContainerCache &qCache) { return; } - const bool renderOnlyVisibleQuad = true; - - if(renderOnlyVisibleQuad == true) { +// const bool renderOnlyVisibleQuad = true; +// +// if(renderOnlyVisibleQuad == true) { vector > rowsToRender; if(rowsToRenderCache.find(qCache.lastVisibleQuad) != rowsToRenderCache.end()) { @@ -4363,20 +4363,20 @@ void Renderer::MapRenderer::Layer::render(VisibleQuadContainerCache &qCache) { glDrawRangeElements(GL_TRIANGLES,rowsToRender[i].first,rowsToRender[i].second,indexCount,GL_UNSIGNED_INT,_bindVBO(vbo_indices,indices,GL_ELEMENT_ARRAY_BUFFER_ARB)); } } - } - else { - glVertexPointer(3,GL_FLOAT,0,_bindVBO(vbo_vertices,vertices)); - glNormalPointer(GL_FLOAT,0,_bindVBO(vbo_normals,normals)); - - glClientActiveTexture(Renderer::fowTexUnit); - glTexCoordPointer(2,GL_FLOAT,0,_bindVBO(vbo_fowTexCoords,fowTexCoords)); - - glClientActiveTexture(Renderer::baseTexUnit); - glBindTexture(GL_TEXTURE_2D,textureHandle); - glTexCoordPointer(2,GL_FLOAT,0,_bindVBO(vbo_surfTexCoords,surfTexCoords)); - - glDrawElements(GL_TRIANGLES,indexCount,GL_UNSIGNED_INT,_bindVBO(vbo_indices,indices,GL_ELEMENT_ARRAY_BUFFER_ARB)); - } +// } +// else { +// glVertexPointer(3,GL_FLOAT,0,_bindVBO(vbo_vertices,vertices)); +// glNormalPointer(GL_FLOAT,0,_bindVBO(vbo_normals,normals)); +// +// glClientActiveTexture(Renderer::fowTexUnit); +// glTexCoordPointer(2,GL_FLOAT,0,_bindVBO(vbo_fowTexCoords,fowTexCoords)); +// +// glClientActiveTexture(Renderer::baseTexUnit); +// glBindTexture(GL_TEXTURE_2D,textureHandle); +// glTexCoordPointer(2,GL_FLOAT,0,_bindVBO(vbo_surfTexCoords,surfTexCoords)); +// +// glDrawElements(GL_TRIANGLES,indexCount,GL_UNSIGNED_INT,_bindVBO(vbo_indices,indices,GL_ELEMENT_ARRAY_BUFFER_ARB)); +// } } void Renderer::MapRenderer::renderVisibleLayers(const Map* map,float coordStep,VisibleQuadContainerCache &qCache) { @@ -7133,9 +7133,9 @@ void Renderer::selectUsingFrustumSelection(Selection::UnitContainer &units, object->getPos().x, object->getPos().y, object->getPos().z, 1); if(insideQuad == true) { obj = object; - if(withObjectSelection == true) { - break; - } + //if(withObjectSelection == true) { + break; + //} } } } @@ -9327,12 +9327,12 @@ VisibleQuadContainerCache & Renderer::getQuadCache( bool updateOnDirtyFrame, } } else { - bool insideQuad = false; + //bool insideQuad = false; - if( !insideQuad) { + //if( !insideQuad) { SurfaceCell *sc = map->getSurfaceCell(pos.x, pos.y); - insideQuad = CubeInFrustum(quadCache.frustumData, sc->getVertex().x, sc->getVertex().y, sc->getVertex().z, 0); - } + bool insideQuad = CubeInFrustum(quadCache.frustumData, sc->getVertex().x, sc->getVertex().y, sc->getVertex().z, 0); + //} if( !insideQuad) { SurfaceCell *sc = map->getSurfaceCell(pos.x+1, pos.y); insideQuad = CubeInFrustum(quadCache.frustumData, sc->getVertex().x, sc->getVertex().y, sc->getVertex().z, 0); diff --git a/source/glest_game/graphics/renderer.h b/source/glest_game/graphics/renderer.h index 9a5f98147..abeaa6eed 100644 --- a/source/glest_game/graphics/renderer.h +++ b/source/glest_game/graphics/renderer.h @@ -371,12 +371,16 @@ private: const Map* map; struct Layer { - inline Layer(int th): + inline explicit Layer(int th): vbo_vertices(0), vbo_normals(0), vbo_fowTexCoords(0), vbo_surfTexCoords(0), vbo_indices(0), indexCount(0), textureHandle(th),textureCRC(0) {} + inline explicit Layer(Layer &obj) { + *this = obj; + } + inline Layer & operator=(Layer &obj) { this->vertices = obj.vertices; this->normals = obj.normals; diff --git a/source/glest_game/gui/gui.cpp b/source/glest_game/gui/gui.cpp index 71a30eaa5..d8044575f 100644 --- a/source/glest_game/gui/gui.cpp +++ b/source/glest_game/gui/gui.cpp @@ -102,7 +102,7 @@ Gui::Gui(){ activeCommandType= NULL; activeCommandClass= ccStop; selectingBuilding= false; - selectedBuildingFacing = CardinalDir::NORTH; + selectedBuildingFacing = CardinalDir(CardinalDir::NORTH); selectingPos= false; selectingMeetingPoint= false; activePos= invalidPos; @@ -203,7 +203,7 @@ void Gui::invalidatePosObjWorld(){ void Gui::resetState(){ selectingBuilding= false; - selectedBuildingFacing = CardinalDir::NORTH; + selectedBuildingFacing = CardinalDir(CardinalDir::NORTH); selectingPos= false; selectingMeetingPoint= false; activePos= invalidPos; @@ -736,7 +736,7 @@ void Gui::mouseDownDisplayUnitBuild(int posDisplay) { choosenBuildingType = ut; selectingPos = true; - selectedBuildingFacing = CardinalDir::NORTH; + selectedBuildingFacing = CardinalDir(CardinalDir::NORTH); activePos = posDisplay; } } diff --git a/source/glest_game/main/intro.h b/source/glest_game/main/intro.h index 856a8726a..50b4abbea 100644 --- a/source/glest_game/main/intro.h +++ b/source/glest_game/main/intro.h @@ -113,7 +113,7 @@ private: void renderModelBackground(); public: - Intro(Program *program); + explicit Intro(Program *program); virtual ~Intro(); virtual void update(); diff --git a/source/glest_game/main/main.cpp b/source/glest_game/main/main.cpp index 7bf0146af..5f9e8ade5 100644 --- a/source/glest_game/main/main.cpp +++ b/source/glest_game/main/main.cpp @@ -458,7 +458,7 @@ void generate_stack_trace(string &out, CONTEXT ctx, int skip) { } struct UntypedException { - UntypedException(const EXCEPTION_RECORD & er) + explicit UntypedException(const EXCEPTION_RECORD & er) : exception_object(reinterpret_cast(er.ExceptionInformation[1])), type_array(reinterpret_cast<_ThrowInfo *>(er.ExceptionInformation[2])->pCatchableTypeArray) {} @@ -639,7 +639,7 @@ void stackdumper(unsigned int type, EXCEPTION_POINTERS *ep, bool fatalExit) { printf("\n** Already in error handler aborting, msg [%s]\n",msg); fflush(stdout); abort(); - return; + //return; } inErrorNow = true; @@ -1787,7 +1787,7 @@ void runTilesetValidationForPath(string tilesetPath, string tilesetName, bool showDuplicateFiles, bool gitPurgeFiles,double &purgedMegaBytes) { Checksum checksum; - bool techtree_errors = false; + //bool techtree_errors = false; std::map > > loadedFileList; vector pathList; @@ -2113,9 +2113,9 @@ void runTilesetValidationForPath(string tilesetPath, string tilesetName, } } - if(techtree_errors == false) { - printf("\nValidation found NO ERRORS for tilesetPath [%s] tilesetName [%s]:\n",tilesetPath.c_str(), tilesetName.c_str()); - } + //if(techtree_errors == false) { + printf("\nValidation found NO ERRORS for tilesetPath [%s] tilesetName [%s]:\n",tilesetPath.c_str(), tilesetName.c_str()); + //} printf("----------------------------------------------------------------"); } @@ -3307,7 +3307,6 @@ Steam & initSteamInstance() { } void setupSteamSettings(bool steamEnabled) { - bool needToSaveConfig=false; Config &config = Config::getInstance(); config.setBool("SteamEnabled",steamEnabled,true); if(steamEnabled) { @@ -3321,6 +3320,7 @@ void setupSteamSettings(bool steamEnabled) { string steamLang = steam.lang(); printf("Steam Integration Enabled!\nSteam User Name is [%s] Language is [%s]\n", steamPlayerName.c_str(), steamLang.c_str()); + bool needToSaveConfig=false; string currentPLayerName = config.getString("NetPlayerName",""); if( currentPLayerName == "newbie" || currentPLayerName == "" ) { config.setString("NetPlayerName",steamPlayerName); diff --git a/source/glest_game/main/main.h b/source/glest_game/main/main.h index 819f828eb..e8e1646c7 100644 --- a/source/glest_game/main/main.h +++ b/source/glest_game/main/main.h @@ -39,7 +39,7 @@ private: void showLanguages(); public: - MainWindow(Program *program); + explicit MainWindow(Program *program); ~MainWindow(); void setProgram(Program *program); diff --git a/source/glest_game/main/program.h b/source/glest_game/main/program.h index 270f80ce2..8fcb7db90 100644 --- a/source/glest_game/main/program.h +++ b/source/glest_game/main/program.h @@ -68,7 +68,7 @@ public: static const char *MAIN_PROGRAM_RENDER_KEY; - ProgramState(Program *program); + explicit ProgramState(Program *program); virtual ~ProgramState(){}; int getFps() const { return fps; } diff --git a/source/glest_game/menu/main_menu.h b/source/glest_game/menu/main_menu.h index f7230cd96..bf8a5cb59 100644 --- a/source/glest_game/menu/main_menu.h +++ b/source/glest_game/menu/main_menu.h @@ -62,8 +62,8 @@ private: void initBackgroundVideo(); public: - MainMenu(Program *program); - ~MainMenu(); + explicit MainMenu(Program *program); + virtual ~MainMenu(); MenuBackground *getMenuBackground() {return &menuBackground;} const MenuBackground *getConstMenuBackground() const {return &menuBackground;} diff --git a/source/glest_game/menu/menu_state_custom_game.cpp b/source/glest_game/menu/menu_state_custom_game.cpp index be91da7c4..3bf202545 100644 --- a/source/glest_game/menu/menu_state_custom_game.cpp +++ b/source/glest_game/menu/menu_state_custom_game.cpp @@ -1698,7 +1698,7 @@ void MenuStateCustomGame::updateResourceMultiplier(const int index) { //printf("Line: %d multiplier index: %d index: %d\n",__LINE__,listBoxRMultiplier[index].getSelectedItemIndex(),index); } -void MenuStateCustomGame::loadGameSettings(std::string fileName) { +void MenuStateCustomGame::loadGameSettings(const std::string &fileName) { // Ensure we have set the gamesettings at least once GameSettings gameSettings = loadGameSettingsFromFile(fileName); if(gameSettings.getMap() == "") { diff --git a/source/glest_game/menu/menu_state_custom_game.h b/source/glest_game/menu/menu_state_custom_game.h index cf9a0db97..2b23031fa 100644 --- a/source/glest_game/menu/menu_state_custom_game.h +++ b/source/glest_game/menu/menu_state_custom_game.h @@ -279,7 +279,7 @@ private: void loadFactionTexture(string filepath); GameSettings loadGameSettingsFromFile(std::string fileName); - void loadGameSettings(std::string fileName); + void loadGameSettings(const std::string &fileName); void RestoreLastGameSettings(); void PlayNow(bool saveGame); diff --git a/source/glest_game/network/client_interface.h b/source/glest_game/network/client_interface.h index 75e9ef496..6190ceb65 100644 --- a/source/glest_game/network/client_interface.h +++ b/source/glest_game/network/client_interface.h @@ -38,7 +38,7 @@ protected: virtual void setQuitStatus(bool value); public: - ClientInterfaceThread(ClientInterface *client); + explicit ClientInterfaceThread(ClientInterface *client); virtual ~ClientInterfaceThread(); virtual void execute(); diff --git a/source/glest_game/network/connection_slot.cpp b/source/glest_game/network/connection_slot.cpp index ed1717a8a..b2e95d9da 100644 --- a/source/glest_game/network/connection_slot.cpp +++ b/source/glest_game/network/connection_slot.cpp @@ -1393,7 +1393,7 @@ void ConnectionSlot::update(bool checkForNewClients,int lockedSlotIndex) { double maxClientLagTimeAllowed = 8; // New lag check - if((maxFrameCountLagAllowed > 0 && clientLagCount > maxFrameCountLagAllowed) || + if((clientLagCount > maxFrameCountLagAllowed) || (maxClientLagTimeAllowed > 0 && clientLagTime > maxClientLagTimeAllowed)) { waitForLaggingClient = true; diff --git a/source/glest_game/network/connection_slot.h b/source/glest_game/network/connection_slot.h index 48906fefc..79224dbb1 100644 --- a/source/glest_game/network/connection_slot.h +++ b/source/glest_game/network/connection_slot.h @@ -96,7 +96,7 @@ protected: void slotUpdateTask(ConnectionSlotEvent *event); public: - ConnectionSlotThread(int slotIndex); + explicit ConnectionSlotThread(int slotIndex); ConnectionSlotThread(ConnectionSlotCallbackInterface *slotInterface,int slotIndex); virtual ~ConnectionSlotThread(); diff --git a/source/glest_game/network/network_interface.h b/source/glest_game/network/network_interface.h index 38c5f245f..939097179 100644 --- a/source/glest_game/network/network_interface.h +++ b/source/glest_game/network/network_interface.h @@ -412,7 +412,7 @@ private: FileTransferInfo info; public: - FileTransferSocketThread(FileTransferInfo fileInfo); + explicit FileTransferSocketThread(FileTransferInfo fileInfo); virtual void execute(); }; diff --git a/source/glest_game/network/network_message.cpp b/source/glest_game/network/network_message.cpp index 6140cdc4b..8a73ad2da 100644 --- a/source/glest_game/network/network_message.cpp +++ b/source/glest_game/network/network_message.cpp @@ -1725,7 +1725,7 @@ const char * NetworkMessageCommandList::getPackedMessageFormatDetail() const { unsigned int NetworkMessageCommandList::getPackedSizeDetail(int count) { unsigned int result = 0; - if(result == 0) { + //if(result == 0) { for(unsigned int i = 0; i < (unsigned int)count; ++i) { NetworkCommand packedData; unsigned char *buf = new unsigned char[sizeof(NetworkCommand)*3]; @@ -1746,7 +1746,7 @@ unsigned int NetworkMessageCommandList::getPackedSizeDetail(int count) { packedData.unitCommandGroupId); delete [] buf; } - } + //} return result; } void NetworkMessageCommandList::unpackMessageDetail(unsigned char *buf,int count) { diff --git a/source/glest_game/network/network_message.h b/source/glest_game/network/network_message.h index 7345b495b..15c10438f 100644 --- a/source/glest_game/network/network_message.h +++ b/source/glest_game/network/network_message.h @@ -285,7 +285,7 @@ protected: public: NetworkMessageReady(); - NetworkMessageReady(uint32 checksum); + explicit NetworkMessageReady(uint32 checksum); virtual size_t getDataSize() const { return sizeof(Data); } @@ -464,7 +464,7 @@ protected: unsigned char * packMessageDetail(uint16 totalCommand); public: - NetworkMessageCommandList(int32 frameCount= -1); + explicit NetworkMessageCommandList(int32 frameCount= -1); virtual size_t getDataSize() const { return sizeof(Data); } virtual unsigned char * getData(); @@ -652,7 +652,7 @@ protected: public: NetworkMessageSynchNetworkGameData() {}; - NetworkMessageSynchNetworkGameData(const GameSettings *gameSettings); + explicit NetworkMessageSynchNetworkGameData(const GameSettings *gameSettings); virtual size_t getDataSize() const { return sizeof(Data); } @@ -847,7 +847,7 @@ protected: public: NetworkMessageSynchNetworkGameDataFileGet(); - NetworkMessageSynchNetworkGameDataFileGet(const string fileName); + explicit NetworkMessageSynchNetworkGameDataFileGet(const string fileName); virtual size_t getDataSize() const { return sizeof(Data); } @@ -972,7 +972,7 @@ protected: virtual unsigned char * packMessage(); public: - PlayerIndexMessage( int16 playerIndex); + explicit PlayerIndexMessage( int16 playerIndex); virtual size_t getDataSize() const { return sizeof(Data); } @@ -1038,7 +1038,7 @@ protected: public: NetworkMessageLoadingStatus(); - NetworkMessageLoadingStatus(uint32 status); + explicit NetworkMessageLoadingStatus(uint32 status); virtual size_t getDataSize() const { return sizeof(Data); } diff --git a/source/glest_game/network/network_protocol.cpp b/source/glest_game/network/network_protocol.cpp index 615067101..fdb3adfa6 100644 --- a/source/glest_game/network/network_protocol.cpp +++ b/source/glest_game/network/network_protocol.cpp @@ -88,7 +88,7 @@ long double unpack754(unsigned long long int i, unsigned bits, unsigned expbits) while(shift < 0) { result /= 2.0; shift++; } // sign it - result *= (i>>(bits-1))&1? -1.0: 1.0; + result *= ((i>>(bits-1))&1) ? -1.0: 1.0; return result; } diff --git a/source/glest_game/type_instances/faction.cpp b/source/glest_game/type_instances/faction.cpp index fda62e0e6..4c057eec4 100644 --- a/source/glest_game/type_instances/faction.cpp +++ b/source/glest_game/type_instances/faction.cpp @@ -345,10 +345,10 @@ void FactionThread::execute() { codeLocation = "7"; //Config &config= Config::getInstance(); //bool sortedUnitsAllowed = config.getBool("AllowGroupedUnitCommands","true"); - bool sortedUnitsAllowed = false; - if(sortedUnitsAllowed == true) { - this->faction->sortUnitsByCommandGroups(); - } + //bool sortedUnitsAllowed = false; + //if(sortedUnitsAllowed == true) { + this->faction->sortUnitsByCommandGroups(); + //} codeLocation = "8"; static string mutexOwnerId2 = string(__FILE__) + string("_") + intToStr(__LINE__); @@ -1976,7 +1976,7 @@ Unit * Faction::findClosestUnitWithSkillClass( const Vec2i &pos,const CommandCla } */ - if(result == NULL) { + //if(result == NULL) { for(int i = 0; i < getUnitCount(); ++i) { Unit *curUnit = getUnit(i); @@ -2014,7 +2014,7 @@ Unit * Faction::findClosestUnitWithSkillClass( const Vec2i &pos,const CommandCla } } } - } + //} return result; } diff --git a/source/glest_game/type_instances/faction.h b/source/glest_game/type_instances/faction.h index 946ac31b3..92f94e8ee 100644 --- a/source/glest_game/type_instances/faction.h +++ b/source/glest_game/type_instances/faction.h @@ -101,7 +101,7 @@ protected: virtual bool canShutdown(bool deleteSelfIfShutdownDelayed=false); public: - FactionThread(Faction *faction); + explicit FactionThread(Faction *faction); virtual ~FactionThread(); virtual void execute(); diff --git a/source/glest_game/type_instances/unit.cpp b/source/glest_game/type_instances/unit.cpp index e07af0b23..1923ce0f9 100644 --- a/source/glest_game/type_instances/unit.cpp +++ b/source/glest_game/type_instances/unit.cpp @@ -535,7 +535,7 @@ Unit::Unit(int id, UnitPathInterface *unitpath, const Vec2i &pos, changedActiveCommandFrame = 0; lastSynchDataString=""; - modelFacing = CardinalDir::NORTH; + modelFacing = CardinalDir(CardinalDir::NORTH); lastStuckFrame = 0; lastStuckPos = Vec2i(0,0); lastPathfindFailedFrame = 0; diff --git a/source/glest_game/types/tech_tree.h b/source/glest_game/types/tech_tree.h index c1e9fbfdf..d00d2a6c2 100644 --- a/source/glest_game/types/tech_tree.h +++ b/source/glest_game/types/tech_tree.h @@ -72,7 +72,7 @@ public: static string findPath(const string &techName, const vector &pathTechList); static bool exists(const string &techName, const vector &pathTechList); - TechTree(const vector pathList); + explicit TechTree(const vector pathList); ~TechTree(); Checksum * getChecksumValue() { return &checksumValue; } diff --git a/source/glest_game/world/map.cpp b/source/glest_game/world/map.cpp index b48153ea0..2702e773f 100644 --- a/source/glest_game/world/map.cpp +++ b/source/glest_game/world/map.cpp @@ -57,7 +57,7 @@ Cell::Cell() { void Cell::saveGame(XmlNode *rootNode, int index) const { bool saveCell = false; - if(saveCell == false) { + //if(saveCell == false) { for(unsigned int i = 0; i < fieldCount; ++i) { if(units[i] != NULL) { saveCell = true; @@ -68,7 +68,7 @@ void Cell::saveGame(XmlNode *rootNode, int index) const { break; } } - } + //} if(saveCell == true) { std::map mapTagReplacements; @@ -723,9 +723,9 @@ bool Map::isResourceNear(int frameIndex,const Vec2i &pos, const ResourceType *rt //printf("!!!! unit [%s - %d] resPos = [%s] resourceClickPos->dist(resPos) [%f] distanceFromClick [%f] unit->getCenteredPos().dist(resPos) [%f] distanceFromUnit [%f]\n",unit->getFullName().c_str(),unit->getId(),resPos.getString().c_str(),resourceClickPos->dist(resPos),distanceFromClick,unit->getCenteredPos().dist(resPos),distanceFromUnit); if(distanceFromClick < 0 || resourceClickPos->dist(resPos) <= distanceFromClick) { - if(resourceClickPos != NULL) { - distanceFromClick = resourceClickPos->dist(resPos); - } + //if(resourceClickPos != NULL) { + distanceFromClick = resourceClickPos->dist(resPos); + //} if(unit != NULL) { distanceFromUnit = unit->getCenteredPos().dist(resPos); } diff --git a/source/glest_game/world/map.h b/source/glest_game/world/map.h index ce334a7f8..665d05041 100644 --- a/source/glest_game/world/map.h +++ b/source/glest_game/world/map.h @@ -201,7 +201,7 @@ public: class FastAINodeCache { public: - FastAINodeCache(Unit *unit) { + explicit FastAINodeCache(Unit *unit) { this->unit = unit; } Unit *unit; diff --git a/source/glest_game/world/surface_atlas.h b/source/glest_game/world/surface_atlas.h index b836d121f..0250c1a91 100644 --- a/source/glest_game/world/surface_atlas.h +++ b/source/glest_game/world/surface_atlas.h @@ -47,7 +47,7 @@ private: const Texture2D *texture; public: - SurfaceInfo(const Pixmap2D *center); + explicit SurfaceInfo(const Pixmap2D *center); SurfaceInfo(const Pixmap2D *lu, const Pixmap2D *ru, const Pixmap2D *ld, const Pixmap2D *rd); bool operator==(const SurfaceInfo &si) const; diff --git a/source/glest_game/world/unit_updater.cpp b/source/glest_game/world/unit_updater.cpp index b0b2fa8cb..ee851d4af 100644 --- a/source/glest_game/world/unit_updater.cpp +++ b/source/glest_game/world/unit_updater.cpp @@ -40,6 +40,8 @@ namespace Glest{ namespace Game{ // class UnitUpdater // ===================================================== +time_t UnitRangeCellsLookupItem::lastDebug = 0; + // ===================== PUBLIC ======================== UnitUpdater::UnitUpdater() : mutexAttackWarnings(new Mutex(CODE_AT_LINE)), @@ -418,7 +420,7 @@ Unit* UnitUpdater::spawnUnit(Unit *unit,string spawnUnit,Vec2i spawnPos) { Unit *spawned= new Unit(world->getNextUnitId(unit->getFaction()), newpath, Vec2i(0), spawnUnitType, unit->getFaction(), - world->getMap(), CardinalDir::NORTH); + world->getMap(), CardinalDir(CardinalDir::NORTH)); bool placedSpawnUnit=world->placeUnit(_spawnPos, 10, spawned); @@ -2095,7 +2097,7 @@ void UnitUpdater::updateRepair(Unit *unit, int frameIndex) { const CommandType *ctbuild = unit->getType()->getFirstCtOfClass(ccBuild); NetworkCommand networkCommand(this->world,nctGiveCommand, unit->getId(), ctbuild->getId(), command->getPos(), - command->getUnitType()->getId(), -1, CardinalDir::NORTH, true, command->getStateType(), + command->getUnitType()->getId(), -1, CardinalDir(CardinalDir::NORTH), true, command->getStateType(), command->getStateValue()); if(SystemFlags::getSystemSettingType(SystemFlags::debugUnitCommands).enabled) SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); @@ -2369,7 +2371,7 @@ void UnitUpdater::updateProduce(Unit *unit, int frameIndex) { throw megaglest_runtime_error("detected unsupported pathfinder type!"); } - produced= new Unit(world->getNextUnitId(unit->getFaction()), newpath, Vec2i(0), pct->getProducedUnit(), unit->getFaction(), world->getMap(), CardinalDir::NORTH); + produced= new Unit(world->getNextUnitId(unit->getFaction()), newpath, Vec2i(0), pct->getProducedUnit(), unit->getFaction(), world->getMap(), CardinalDir(CardinalDir::NORTH)); if(SystemFlags::getSystemSettingType(SystemFlags::debugUnitCommands).enabled) SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d] about to place unit for unit [%s]\n",__FILE__,__FUNCTION__,__LINE__,produced->toString(false).c_str()); diff --git a/source/glest_game/world/world.cpp b/source/glest_game/world/world.cpp index 1bc995efe..e7c942fa3 100644 --- a/source/glest_game/world/world.cpp +++ b/source/glest_game/world/world.cpp @@ -1288,7 +1288,7 @@ void World::morphToUnit(int unitId,const string &morphName,bool ignoreRequiremen } const UnitType* unitType = mct->getMorphUnit(); - cr = this->game->getCommander()->tryGiveCommand(unit, mct,unit->getPos(), unitType,CardinalDir::NORTH); + cr = this->game->getCommander()->tryGiveCommand(unit, mct,unit->getPos(), unitType,CardinalDir(CardinalDir::NORTH)); } catch(const exception &ex) { if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); @@ -1337,7 +1337,7 @@ void World::createUnit(const string &unitName, int factionIndex, const Vec2i &po throw megaglest_runtime_error("detected unsupported pathfinder type!",true); } - Unit* unit= new Unit(getNextUnitId(faction), newpath, pos, ut, faction, &map, CardinalDir::NORTH); + Unit* unit= new Unit(getNextUnitId(faction), newpath, pos, ut, faction, &map, CardinalDir(CardinalDir::NORTH)); if(SystemFlags::getSystemSettingType(SystemFlags::debugUnitCommands).enabled) SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d] unit created for unit [%s]\n",__FILE__,__FUNCTION__,__LINE__,unit->toString().c_str()); @@ -2269,7 +2269,7 @@ void World::initUnits() { throw megaglest_runtime_error("detected unsupported pathfinder type!"); } - Unit *unit= new Unit(getNextUnitId(f), newpath, Vec2i(0), ut, f, &map, CardinalDir::NORTH); + Unit *unit= new Unit(getNextUnitId(f), newpath, Vec2i(0), ut, f, &map, CardinalDir(CardinalDir::NORTH)); int startLocationIndex= f->getStartLocationIndex(); placeUnitAtLocation(map.getStartLocation(startLocationIndex), generationArea, unit, true); } diff --git a/source/shared_lib/include/platform/common/platform_common.h b/source/shared_lib/include/platform/common/platform_common.h index 8313f968e..d715d1db6 100644 --- a/source/shared_lib/include/platform/common/platform_common.h +++ b/source/shared_lib/include/platform/common/platform_common.h @@ -187,7 +187,7 @@ bool isdir(const char *path); bool fileExists(const string &path); inline bool folderExists(const string &path) { return isdir(path.c_str()); } -void findDirs(string path, vector &results, bool errorOnNotFound,bool keepDuplicates); +void findDirs(const string &path, vector &results, bool errorOnNotFound,bool keepDuplicates); void findDirs(const vector &paths, vector &results, bool errorOnNotFound=false,bool keepDuplicates=false); void findAll(const vector &paths, const string &fileFilter, vector &results, bool cutExtension=false, bool errorOnNotFound=true,bool keepDuplicates=false); void findAll(const string &path, vector &results, bool cutExtension=false, bool errorOnNotFound=true); @@ -195,24 +195,24 @@ vector getFolderTreeContentsListRecursively(const string &path, const st string getGameVersion(); string getGameGITVersion(); -void setGameVersion(string version); -void setGameGITVersion(string git); +void setGameVersion(const string &version); +void setGameGITVersion(const string &git); string getCRCCacheFilePath(); -void setCRCCacheFilePath(string path); +void setCRCCacheFilePath(const string &path); -std::pair getFolderTreeContentsCheckSumCacheKey(vector paths, string pathSearchString, const string &filterFileExt); -void clearFolderTreeContentsCheckSum(vector paths, string pathSearchString, const string &filterFileExt); +std::pair getFolderTreeContentsCheckSumCacheKey(vector paths, const string &pathSearchString, const string &filterFileExt); +void clearFolderTreeContentsCheckSum(vector paths, const string &pathSearchString, const string &filterFileExt); uint32 getFolderTreeContentsCheckSumRecursively(vector paths, string pathSearchString, const string &filterFileExt, Checksum *recursiveChecksum,bool forceNoCache=false); -time_t getFolderTreeContentsCheckSumRecursivelyLastGenerated(vector paths, string pathSearchString, const string &filterFileExt); +time_t getFolderTreeContentsCheckSumRecursivelyLastGenerated(const vector &paths, string pathSearchString, const string &filterFileExt); std::pair getFolderTreeContentsCheckSumCacheKey(const string &path, const string &filterFileExt); void clearFolderTreeContentsCheckSum(const string &path, const string &filterFileExt); uint32 getFolderTreeContentsCheckSumRecursively(const string &path, const string &filterFileExt, Checksum *recursiveChecksum,bool forceNoCache=false); -std::pair getFolderTreeContentsCheckSumListCacheKey(vector paths, string pathSearchString, const string &filterFileExt); -void clearFolderTreeContentsCheckSumList(vector paths, string pathSearchString, const string &filterFileExt); -vector > getFolderTreeContentsCheckSumListRecursively(vector paths, string pathSearchString, const string &filterFileExt, vector > *recursiveMap); +std::pair getFolderTreeContentsCheckSumListCacheKey(vector paths, const string &pathSearchString, const string &filterFileExt); +void clearFolderTreeContentsCheckSumList(vector paths, const string &pathSearchString, const string &filterFileExt); +vector > getFolderTreeContentsCheckSumListRecursively(vector paths, const string &pathSearchString, const string &filterFileExt, vector > *recursiveMap); std::pair getFolderTreeContentsCheckSumListCacheKey(const string &path, const string &filterFileExt); void clearFolderTreeContentsCheckSumList(const string &path, const string &filterFileExt); @@ -303,7 +303,7 @@ string getFullFileArchiveCompressCommand(string fileArchiveCompressCommand, string fileArchiveCompressCommandParameters, string archivename, string archivefiles); bool executeShellCommand(string cmd,int expectedResult=IGNORE_CMD_RESULT_VALUE,ShellCommandOutputCallbackInterface *cb=NULL); -string executable_path(string exeName,bool includeExeNameInPath=false); +string executable_path(const string &exeName,bool includeExeNameInPath=false); void saveDataToFile(string filename, string data); diff --git a/source/shared_lib/sources/graphics/model.cpp b/source/shared_lib/sources/graphics/model.cpp index b5a35fb5b..61b5a582d 100644 --- a/source/shared_lib/sources/graphics/model.cpp +++ b/source/shared_lib/sources/graphics/model.cpp @@ -2090,14 +2090,9 @@ void BaseColorPickEntity::recycleUniqueColor() { if(usedColorIDList.empty() == false) { string color_key = getColorDescription(); - if(usedColorIDList.find(color_key) != usedColorIDList.end()) { - usedColorIDList.erase(color_key); - - //printf("REMOVING used Color [%s] usedColorIDList = %d nextColorIDReuseList = %d!\n",color_key.c_str(),(int)usedColorIDList.size(),(int)nextColorIDReuseList.size()); - } - else { - printf("Line ref: %d *WARNING* color [%s] used count: %d NOT FOUND in history list!\n",__LINE__,color_key.c_str(),(int)usedColorIDList.size()); - } + usedColorIDList.erase(color_key); + //printf("REMOVING used Color [%s] usedColorIDList = %d nextColorIDReuseList = %d!\n",color_key.c_str(),(int)usedColorIDList.size(),(int)nextColorIDReuseList.size()); + //printf("Line ref: %d *WARNING* color [%s] used count: %d NOT FOUND in history list!\n",__LINE__,color_key.c_str(),(int)usedColorIDList.size()); } } diff --git a/source/shared_lib/sources/platform/common/platform_common.cpp b/source/shared_lib/sources/platform/common/platform_common.cpp index 29e98208f..642d25fb4 100644 --- a/source/shared_lib/sources/platform/common/platform_common.cpp +++ b/source/shared_lib/sources/platform/common/platform_common.cpp @@ -286,7 +286,7 @@ void Tokenize(const string& str,vector& tokens,const string& delimiters) } -void findDirs(string path, vector &results, bool errorOnNotFound,bool keepDuplicates) { +void findDirs(const string &path, vector &results, bool errorOnNotFound,bool keepDuplicates) { results.clear(); string currentPath = path; endPathWithSlash(currentPath); @@ -687,7 +687,7 @@ string getCRCCacheFilePath() { return crcCachePath; } -void setCRCCacheFilePath(string path) { +void setCRCCacheFilePath(const string &path) { crcCachePath = path; } @@ -697,10 +697,10 @@ string getGameVersion() { string getGameGITVersion() { return gameGITVersion; } -void setGameVersion(string version) { +void setGameVersion(const string &version) { gameVersion = version; } -void setGameGITVersion(string git) { +void setGameGITVersion(const string &git) { gameGITVersion = git; } @@ -718,7 +718,7 @@ string getFormattedCRCCacheFileName(std::pair cacheKeys) { string result = getCRCCacheFilePath() + "CRC_CACHE_" + uIntToStr(checksum.getSum()); return result; } -std::pair getFolderTreeContentsCheckSumCacheKey(vector paths, string pathSearchString, const string &filterFileExt) { +std::pair getFolderTreeContentsCheckSumCacheKey(vector paths, const string &pathSearchString, const string &filterFileExt) { string cacheLookupId = CacheManager::getFolderTreeContentsCheckSumRecursivelyCacheLookupKey1; string cacheKey = ""; @@ -886,15 +886,14 @@ void writeCachedFileCRCValue(string crcCacheFile, uint32 &crcValue, string actua } } -void clearFolderTreeContentsCheckSum(vector paths, string pathSearchString, const string &filterFileExt) { +void clearFolderTreeContentsCheckSum(vector paths, const string &pathSearchString, const string &filterFileExt) { std::pair cacheKeys = getFolderTreeContentsCheckSumCacheKey(paths, pathSearchString, filterFileExt); string cacheLookupId = cacheKeys.first; std::map &crcTreeCache = CacheManager::getCachedItem< std::map >(cacheLookupId); string cacheKey = cacheKeys.second; - if(crcTreeCache.find(cacheKey) != crcTreeCache.end()) { - crcTreeCache.erase(cacheKey); - } + crcTreeCache.erase(cacheKey); + for(unsigned int idx = 0; idx < paths.size(); ++idx) { string path = paths[idx]; clearFolderTreeContentsCheckSum(path, filterFileExt); @@ -908,7 +907,7 @@ void clearFolderTreeContentsCheckSum(vector paths, string pathSearchStri } } -time_t getFolderTreeContentsCheckSumRecursivelyLastGenerated(vector paths, string pathSearchString, const string &filterFileExt) { +time_t getFolderTreeContentsCheckSumRecursivelyLastGenerated(const vector &paths, string pathSearchString, const string &filterFileExt) { if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"-------------- In [%s::%s Line: %d] Calculating CRC for [%s] -----------\n",__FILE__,__FUNCTION__,__LINE__,pathSearchString.c_str()); std::pair cacheKeys = getFolderTreeContentsCheckSumCacheKey(paths, pathSearchString, filterFileExt); @@ -1013,9 +1012,8 @@ void clearFolderTreeContentsCheckSum(const string &path, const string &filterFil std::map &crcTreeCache = CacheManager::getCachedItem< std::map >(cacheLookupId); string cacheKey = cacheKeys.second; - if(crcTreeCache.find(cacheKey) != crcTreeCache.end()) { - crcTreeCache.erase(cacheKey); - } + crcTreeCache.erase(cacheKey); + string crcCacheFile = getFormattedCRCCacheFileName(cacheKeys); if(fileExists(crcCacheFile) == true) { bool result = removeFile(crcCacheFile); @@ -1166,7 +1164,7 @@ uint32 getFolderTreeContentsCheckSumRecursively(const string &path, const string } -std::pair getFolderTreeContentsCheckSumListCacheKey(vector paths, string pathSearchString, const string &filterFileExt) { +std::pair getFolderTreeContentsCheckSumListCacheKey(vector paths, const string &pathSearchString, const string &filterFileExt) { string cacheLookupId = CacheManager::getFolderTreeContentsCheckSumListRecursivelyCacheLookupKey1; string cacheKey = ""; @@ -1177,15 +1175,14 @@ std::pair getFolderTreeContentsCheckSumListCacheKey(vector paths, string pathSearchString, const string &filterFileExt) { +void clearFolderTreeContentsCheckSumList(vector paths, const string &pathSearchString, const string &filterFileExt) { std::pair cacheKeys = getFolderTreeContentsCheckSumListCacheKey(paths, pathSearchString, filterFileExt); string cacheLookupId = cacheKeys.first; std::map > > &crcTreeCache = CacheManager::getCachedItem< std::map > > >(cacheLookupId); string cacheKey = cacheKeys.second; - if(crcTreeCache.find(cacheKey) != crcTreeCache.end()) { - crcTreeCache.erase(cacheKey); - } + crcTreeCache.erase(cacheKey); + for(unsigned int idx = 0; idx < paths.size(); ++idx) { string path = paths[idx]; clearFolderTreeContentsCheckSumList(path, filterFileExt); @@ -1197,7 +1194,7 @@ void clearFolderTreeContentsCheckSumList(vector paths, string pathSearch } } -vector > getFolderTreeContentsCheckSumListRecursively(vector paths, string pathSearchString, const string &filterFileExt, vector > *recursiveMap) { +vector > getFolderTreeContentsCheckSumListRecursively(vector paths, const string &pathSearchString, const string &filterFileExt, vector > *recursiveMap) { std::pair cacheKeys = getFolderTreeContentsCheckSumListCacheKey(paths, pathSearchString, filterFileExt); string cacheLookupId = cacheKeys.first; std::map > > &crcTreeCache = CacheManager::getCachedItem< std::map > > >(cacheLookupId); @@ -1360,9 +1357,8 @@ void clearFolderTreeContentsCheckSumList(const string &path, const string &filte std::map > > &crcTreeCache = CacheManager::getCachedItem< std::map > > >(cacheLookupId); string cacheKey = cacheKeys.second; - if(crcTreeCache.find(cacheKey) != crcTreeCache.end()) { - crcTreeCache.erase(cacheKey); - } + crcTreeCache.erase(cacheKey); + string crcCacheFile = getFormattedCRCCacheFileName(cacheKeys); if(fileExists(crcCacheFile) == true) { bool result = removeFile(crcCacheFile); @@ -2001,7 +1997,7 @@ off_t getFileSize(string filename) { return 0; } -string executable_path(string exeName, bool includeExeNameInPath) { +string executable_path(const string &exeName, bool includeExeNameInPath) { string value = ""; #ifdef _WIN32 char path[MAX_PATH]=""; diff --git a/source/shared_lib/sources/platform/posix/socket.cpp b/source/shared_lib/sources/platform/posix/socket.cpp index 7d30e5c32..8bc2922f3 100644 --- a/source/shared_lib/sources/platform/posix/socket.cpp +++ b/source/shared_lib/sources/platform/posix/socket.cpp @@ -807,7 +807,7 @@ void Socket::getLocalIPAddressListForPlatform(std::vector &ipList) PIP_ADAPTER_UNICAST_ADDRESS pUnicast = NULL; LPSOCKADDR addr = NULL; pCurrAddresses = pAddresses; - char buff[100]; + //char buff[100]; DWORD bufflen=100; while (pCurrAddresses) { if (pCurrAddresses->OperStatus != IfOperStatusUp) {