diff --git a/source/g3d_viewer/main.cpp b/source/g3d_viewer/main.cpp index 9024c1e1..dd43ba72 100644 --- a/source/g3d_viewer/main.cpp +++ b/source/g3d_viewer/main.cpp @@ -552,7 +552,7 @@ void MainWindow::onPaint(wxPaintEvent &event) { renderer->renderParticleManager(); glCanvas->SwapBuffers(); - bool haveLoadedParticles = (particleProjectilePathList.size() > 0 || particleSplashPathList.size() > 0); + bool haveLoadedParticles = (particleProjectilePathList.empty() == false || particleSplashPathList.empty() == false); if(autoScreenShotAndExit == true) { printf("Auto exiting app...\n"); @@ -563,7 +563,7 @@ void MainWindow::onPaint(wxPaintEvent &event) { Close(); return; } - else if((modelPathList.size() > 0) && resetAnimation && haveLoadedParticles) { + else if((modelPathList.empty() == false) && resetAnimation && haveLoadedParticles) { if(anim >= resetAnim && resetAnim > 0) { printf("RESETTING EVERYTHING [%f][%f]...\n",anim,resetAnim); fflush(stdout); @@ -647,7 +647,7 @@ void MainWindow::onMouseWheelDown(wxMouseEvent &event) { onPaint(paintEvent); } - catch(std::runtime_error e) { + catch(std::runtime_error &e) { std::cout << e.what() << std::endl; wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal(); } @@ -664,7 +664,7 @@ void MainWindow::onMouseWheelUp(wxMouseEvent &event) { onPaint(paintEvent); } - catch(std::runtime_error e) { + catch(std::runtime_error &e) { std::cout << e.what() << std::endl; wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal(); } @@ -699,7 +699,7 @@ void MainWindow::onMouseMove(wxMouseEvent &event){ lastX= x; lastY= y; } - catch(std::runtime_error e) { + catch(std::runtime_error &e) { std::cout << e.what() << std::endl; wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal(); } @@ -729,7 +729,7 @@ void MainWindow::onMenuFileLoad(wxCommandEvent &event){ } isControlKeyPressed = false; } - catch(std::runtime_error e) { + catch(std::runtime_error &e) { std::cout << e.what() << std::endl; wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal(); } @@ -763,7 +763,7 @@ void MainWindow::onMenuFileLoadParticleXML(wxCommandEvent &event){ } isControlKeyPressed = false; } - catch(std::runtime_error e) { + catch(std::runtime_error &e) { std::cout << e.what() << std::endl; wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal(); } @@ -797,7 +797,7 @@ void MainWindow::onMenuFileLoadProjectileParticleXML(wxCommandEvent &event){ } isControlKeyPressed = false; } - catch(std::runtime_error e) { + catch(std::runtime_error &e) { std::cout << e.what() << std::endl; wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal(); } @@ -832,7 +832,7 @@ void MainWindow::onMenuFileLoadSplashParticleXML(wxCommandEvent &event){ } isControlKeyPressed = false; } - catch(std::runtime_error e) { + catch(std::runtime_error &e) { std::cout << e.what() << std::endl; wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal(); } @@ -858,7 +858,7 @@ void MainWindow::OnChangeColor(wxCommandEvent &event) { renderer->setBackgroundColor(col.Red()/255.0f, col.Green()/255.0f, col.Blue()/255.0f); } } - catch(std::runtime_error e) { + catch(std::runtime_error &e) { std::cout << e.what() << std::endl; wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal(); } @@ -870,7 +870,7 @@ void MainWindow::onMenumFileToggleScreenshotTransparent(wxCommandEvent &event) { renderer->setAlphaColor(alpha); //printf("alpha = %f\n",alpha); } - catch(std::runtime_error e) { + catch(std::runtime_error &e) { std::cout << e.what() << std::endl; wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal(); } @@ -942,7 +942,7 @@ void MainWindow::saveScreenshot() { } } } - catch(std::runtime_error e) { + catch(std::runtime_error &e) { std::cout << e.what() << std::endl; wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal(); } @@ -990,7 +990,7 @@ void MainWindow::onMenuFileClearAll(wxCommandEvent &event) { if(timer) timer->Start(100); } - catch(std::runtime_error e) { + catch(std::runtime_error &e) { std::cout << e.what() << std::endl; wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal(); } @@ -1123,7 +1123,7 @@ void MainWindow::loadUnit(string path, string skillName) { SetTitle(ToUnicode(titlestring)); } } - catch(std::runtime_error e) { + catch(std::runtime_error &e) { std::cout << e.what() << std::endl; wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Not a Mega-Glest particle XML file, or broken"), wxOK | wxICON_ERROR).ShowModal(); } @@ -1157,7 +1157,7 @@ void MainWindow::loadModel(string path) { } SetTitle(ToUnicode(titlestring)); } - catch(std::runtime_error e) { + catch(std::runtime_error &e) { std::cout << e.what() << std::endl; wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal(); } @@ -1182,7 +1182,7 @@ void MainWindow::loadParticle(string path) { } try{ - if(this->particlePathList.size() > 0) { + if(this->particlePathList.empty() == false) { string titlestring=winHeader; for(unsigned int idx = 0; idx < this->particlePathList.size(); idx++) { string particlePath = this->particlePathList[idx]; @@ -1198,8 +1198,8 @@ void MainWindow::loadParticle(string path) { std::string unitXML = dir + folderDelimiter + extractFileFromDirectoryPath(dir) + ".xml"; - int size = -1; - int height = -1; + //int size = -1; + //int height = -1; if(fileExists(unitXML) == true) { XmlTree xmlTree; @@ -1207,9 +1207,9 @@ void MainWindow::loadParticle(string path) { const XmlNode *unitNode= xmlTree.getRootNode(); const XmlNode *parametersNode= unitNode->getChild("parameters"); //size - size= parametersNode->getChild("size")->getAttribute("value")->getIntValue(); + int size= parametersNode->getChild("size")->getAttribute("value")->getIntValue(); //height - height= parametersNode->getChild("height")->getAttribute("value")->getIntValue(); + int height= parametersNode->getChild("height")->getAttribute("value")->getIntValue(); // std::cout << "About to load [" << particlePath << "] from [" << dir << "] unit [" << unitXML << "]" << std::endl; @@ -1247,7 +1247,7 @@ void MainWindow::loadParticle(string path) { SetTitle(ToUnicode(titlestring)); } } - catch(std::runtime_error e) { + catch(std::runtime_error &e) { std::cout << e.what() << std::endl; wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Not a Mega-Glest particle XML file, or broken"), wxOK | wxICON_ERROR).ShowModal(); } @@ -1273,7 +1273,7 @@ void MainWindow::loadProjectileParticle(string path) { } try { - if(this->particleProjectilePathList.size() > 0) { + if(this->particleProjectilePathList.empty() == false) { string titlestring=winHeader; for(unsigned int idx = 0; idx < this->particleProjectilePathList.size(); idx++) { string particlePath = this->particleProjectilePathList[idx]; @@ -1307,7 +1307,7 @@ void MainWindow::loadProjectileParticle(string path) { XmlTree xmlTree; xmlTree.load(dir + folderDelimiter + particlePath,Properties::getTagReplacementValues()); - const XmlNode *particleSystemNode= xmlTree.getRootNode(); + //const XmlNode *particleSystemNode= xmlTree.getRootNode(); // std::cout << "Loaded successfully, loading values..." << std::endl; @@ -1350,7 +1350,7 @@ void MainWindow::loadProjectileParticle(string path) { } } } - catch(std::runtime_error e) { + catch(std::runtime_error &e) { std::cout << e.what() << std::endl; wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Not a Mega-Glest projectile particle XML file, or broken"), wxOK | wxICON_ERROR).ShowModal(); } @@ -1376,7 +1376,7 @@ void MainWindow::loadSplashParticle(string path) { // uses ParticleSystemTypeSp } try { - if(this->particleSplashPathList.size() > 0) { + if(this->particleSplashPathList.empty() == false) { string titlestring=winHeader; for(unsigned int idx = 0; idx < this->particleSplashPathList.size(); idx++) { string particlePath = this->particleSplashPathList[idx]; @@ -1410,7 +1410,7 @@ void MainWindow::loadSplashParticle(string path) { // uses ParticleSystemTypeSp XmlTree xmlTree; xmlTree.load(dir + folderDelimiter + particlePath,Properties::getTagReplacementValues()); - const XmlNode *particleSystemNode= xmlTree.getRootNode(); + //const XmlNode *particleSystemNode= xmlTree.getRootNode(); // std::cout << "Loaded successfully, loading values..." << std::endl; @@ -1453,7 +1453,7 @@ void MainWindow::loadSplashParticle(string path) { // uses ParticleSystemTypeSp } } } - catch(std::runtime_error e) { + catch(std::runtime_error &e) { std::cout << e.what() << std::endl; wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Not a Mega-Glest projectile particle XML file, or broken"), wxOK | wxICON_ERROR).ShowModal(); } @@ -1465,7 +1465,7 @@ void MainWindow::onMenuModeNormals(wxCommandEvent &event){ renderer->toggleNormals(); menuMode->Check(miModeNormals, renderer->getNormals()); } - catch(std::runtime_error e) { + catch(std::runtime_error &e) { std::cout << e.what() << std::endl; wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal(); } @@ -1476,7 +1476,7 @@ void MainWindow::onMenuModeWireframe(wxCommandEvent &event){ renderer->toggleWireframe(); menuMode->Check(miModeWireframe, renderer->getWireframe()); } - catch(std::runtime_error e) { + catch(std::runtime_error &e) { std::cout << e.what() << std::endl; wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal(); } @@ -1487,7 +1487,7 @@ void MainWindow::onMenuModeGrid(wxCommandEvent &event){ renderer->toggleGrid(); menuMode->Check(miModeGrid, renderer->getGrid()); } - catch(std::runtime_error e) { + catch(std::runtime_error &e) { std::cout << e.what() << std::endl; wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal(); } @@ -1503,7 +1503,7 @@ void MainWindow::onMenuSpeedSlower(wxCommandEvent &event){ string statusTextValue = statusbarText + " animation speed: " + floatToStr(speed * 1000.0) + " anim value: " + floatToStr(anim) + " zoom: " + floatToStr(zoom) + " rotX: " + floatToStr(rotX) + " rotY: " + floatToStr(rotY); GetStatusBar()->SetStatusText(ToUnicode(statusTextValue.c_str())); } - catch(std::runtime_error e) { + catch(std::runtime_error &e) { std::cout << e.what() << std::endl; wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal(); } @@ -1519,7 +1519,7 @@ void MainWindow::onMenuSpeedFaster(wxCommandEvent &event){ string statusTextValue = statusbarText + " animation speed: " + floatToStr(speed * 1000.0 ) + " anim value: " + floatToStr(anim) + " zoom: " + floatToStr(zoom) + " rotX: " + floatToStr(rotX) + " rotY: " + floatToStr(rotY); GetStatusBar()->SetStatusText(ToUnicode(statusTextValue.c_str())); } - catch(std::runtime_error e) { + catch(std::runtime_error &e) { std::cout << e.what() << std::endl; wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal(); } @@ -1538,7 +1538,7 @@ void MainWindow::onMenuColorRed(wxCommandEvent &event) { menuCustomColor->Check(miColorOrange, false); menuCustomColor->Check(miColorMagenta, false); } - catch(std::runtime_error e) { + catch(std::runtime_error &e) { std::cout << e.what() << std::endl; wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal(); } @@ -1556,7 +1556,7 @@ void MainWindow::onMenuColorBlue(wxCommandEvent &event) { menuCustomColor->Check(miColorOrange, false); menuCustomColor->Check(miColorMagenta, false); } - catch(std::runtime_error e) { + catch(std::runtime_error &e) { std::cout << e.what() << std::endl; wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal(); } @@ -1574,7 +1574,7 @@ void MainWindow::onMenuColorGreen(wxCommandEvent &event) { menuCustomColor->Check(miColorOrange, false); menuCustomColor->Check(miColorMagenta, false); } - catch(std::runtime_error e) { + catch(std::runtime_error &e) { std::cout << e.what() << std::endl; wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal(); } @@ -1592,7 +1592,7 @@ void MainWindow::onMenuColorYellow(wxCommandEvent &event) { menuCustomColor->Check(miColorOrange, false); menuCustomColor->Check(miColorMagenta, false); } - catch(std::runtime_error e) { + catch(std::runtime_error &e) { std::cout << e.what() << std::endl; wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal(); } @@ -1610,7 +1610,7 @@ void MainWindow::onMenuColorWhite(wxCommandEvent &event) { menuCustomColor->Check(miColorOrange, false); menuCustomColor->Check(miColorMagenta, false); } - catch(std::runtime_error e) { + catch(std::runtime_error &e) { std::cout << e.what() << std::endl; wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal(); } @@ -1628,7 +1628,7 @@ void MainWindow::onMenuColorCyan(wxCommandEvent &event) { menuCustomColor->Check(miColorOrange, false); menuCustomColor->Check(miColorMagenta, false); } - catch(std::runtime_error e) { + catch(std::runtime_error &e) { std::cout << e.what() << std::endl; wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal(); } @@ -1646,7 +1646,7 @@ void MainWindow::onMenuColorOrange(wxCommandEvent &event) { menuCustomColor->Check(miColorOrange, true); menuCustomColor->Check(miColorMagenta, false); } - catch(std::runtime_error e) { + catch(std::runtime_error &e) { std::cout << e.what() << std::endl; wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal(); } @@ -1664,7 +1664,7 @@ void MainWindow::onMenuColorMagenta(wxCommandEvent &event) { menuCustomColor->Check(miColorOrange, false); menuCustomColor->Check(miColorMagenta, true); } - catch(std::runtime_error e) { + catch(std::runtime_error &e) { std::cout << e.what() << std::endl; wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal(); } @@ -1764,7 +1764,7 @@ void MainWindow::onKeyDown(wxKeyEvent &e) { std::cout << "pressed " << e.GetKeyCode() << std::endl; } - catch(std::runtime_error e) { + catch(std::runtime_error &e) { std::cout << e.what() << std::endl; wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal(); } @@ -1795,7 +1795,7 @@ void MainWindow::onMenuRestart(wxCommandEvent &event) { } if(timer) timer->Start(100); } - catch(std::runtime_error e) { + catch(std::runtime_error &e) { std::cout << e.what() << std::endl; wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal(); } diff --git a/source/glest_game/ai/ai.cpp b/source/glest_game/ai/ai.cpp index f91aa5f6..7c5b8572 100644 --- a/source/glest_game/ai/ai.cpp +++ b/source/glest_game/ai/ai.cpp @@ -441,7 +441,7 @@ void Ai::sendScoutPatrol(){ for(int i= 0; i < tt->getResourceTypeCount(); ++i){ const ResourceType *rt_= tt->getResourceType(i); - const Resource *r= aiInterface->getResource(rt); + //const Resource *r= aiInterface->getResource(rt); if(rt_->getClass() == rcTech){ rt=rt_; @@ -640,9 +640,7 @@ void Ai::massiveAttack(const Vec2i &pos, Field field, bool ultraAttack){ void Ai::returnBase(int unitIndex) { Vec2i pos; CommandResult r; - int fi; - - fi= aiInterface->getFactionIndex(); + int fi= aiInterface->getFactionIndex(); pos= Vec2i( random.randRange(-villageRadius, villageRadius), random.randRange(-villageRadius, villageRadius)) + getRandomHomePosition(); @@ -804,17 +802,17 @@ void Ai::unblockUnits() { if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld [START]\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); - if(signalAdjacentUnits.size() > 0) { + if(signalAdjacentUnits.empty() == false) { //printf("#2 AI units ARE BLOCKED about to unblock\n"); int unitGroupCommandId = -1; for(std::map >::reverse_iterator iterMap = signalAdjacentUnits.rbegin(); - iterMap != signalAdjacentUnits.rend(); iterMap++) { + iterMap != signalAdjacentUnits.rend(); ++iterMap) { for(std::map::iterator iterMap2 = iterMap->second.begin(); - iterMap2 != iterMap->second.end(); iterMap2++) { - int idx = iterMap2->first; + iterMap2 != iterMap->second.end(); ++iterMap2) { + //int idx = iterMap2->first; const Unit *adjacentUnit = iterMap2->second; if(adjacentUnit != NULL && adjacentUnit->getType()->getFirstCtOfClass(ccMove) != NULL) { const CommandType *ct = adjacentUnit->getType()->getFirstCtOfClass(ccMove); @@ -844,7 +842,7 @@ void Ai::unblockUnits() { if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld [START]\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); } -bool Ai::outputAIBehaviourToConsole() { +bool Ai::outputAIBehaviourToConsole() const { return false; } diff --git a/source/glest_game/ai/ai.h b/source/glest_game/ai/ai.h index b709deab..bcee03c3 100644 --- a/source/glest_game/ai/ai.h +++ b/source/glest_game/ai/ai.h @@ -188,7 +188,7 @@ public: bool haveBlockedUnits(); void unblockUnits(); - bool outputAIBehaviourToConsole(); + bool outputAIBehaviourToConsole() const; }; }}//end namespace diff --git a/source/glest_game/ai/ai_interface.cpp b/source/glest_game/ai/ai_interface.cpp index 8d5e2024..137b330b 100644 --- a/source/glest_game/ai/ai_interface.cpp +++ b/source/glest_game/ai/ai_interface.cpp @@ -533,7 +533,7 @@ bool AiInterface::isResourceNear(const Vec2i &pos, const ResourceType *rt, Vec2i bool AiInterface::getNearestSightedResource(const ResourceType *rt, const Vec2i &pos, Vec2i &resultPos, bool usableResourceTypeOnly) { Faction *faction = world->getFaction(factionIndex); - float tmpDist=0; + //float tmpDist=0; float nearestDist= infinity; bool anyResource= false; resultPos.x = -1; @@ -572,7 +572,7 @@ bool AiInterface::getNearestSightedResource(const ResourceType *rt, const Vec2i } else { const Map *map = world->getMap(); - Faction *faction = world->getFaction(factionIndex); + //Faction *faction = world->getFaction(factionIndex); for(int i = 0; i < map->getW(); ++i) { for(int j = 0; j < map->getH(); ++j) { @@ -587,7 +587,7 @@ bool AiInterface::getNearestSightedResource(const ResourceType *rt, const Vec2i //if resource cell if(r != NULL) { if(r->getType() == rt) { - tmpDist= pos.dist(resPos); + float tmpDist= pos.dist(resPos); if(tmpDist < nearestDist) { anyResource= true; nearestDist= tmpDist; diff --git a/source/glest_game/ai/ai_rule.cpp b/source/glest_game/ai/ai_rule.cpp index ccf0a76d..10d983c8 100644 --- a/source/glest_game/ai/ai_rule.cpp +++ b/source/glest_game/ai/ai_rule.cpp @@ -89,9 +89,11 @@ void AiRuleScoutPatrol::execute(){ AiRuleRepair::AiRuleRepair(Ai *ai): AiRule(ai) { + damagedUnitIndex = 0; + damagedUnitIsCastle = false; } -double AiRuleRepair::getMinCastleHpRatio() { +double AiRuleRepair::getMinCastleHpRatio() const { return 0.6; } @@ -145,8 +147,8 @@ bool AiRuleRepair::test(){ } } - int candidatedamagedUnitIndex=-1; if(unitCanProduceWorker == true) { + int candidatedamagedUnitIndex=-1; int unitCountAlreadyRepairingDamagedUnit = 0; // Now check if any other unit is able to repair this unit for(int i1 = 0; i1 < aiInterface->getMyUnitCount(); ++i1) { @@ -354,6 +356,7 @@ void AiRuleReturnBase::execute(){ AiRuleMassiveAttack::AiRuleMassiveAttack(Ai *ai): AiRule(ai) { + ultraAttack=false; } bool AiRuleMassiveAttack::test(){ @@ -512,6 +515,7 @@ void AiRuleAddTasks::execute(){ AiRuleBuildOneFarm::AiRuleBuildOneFarm(Ai *ai): AiRule(ai) { + farm=NULL; } bool AiRuleBuildOneFarm::test(){ @@ -557,6 +561,7 @@ AiRuleProduceResourceProducer::AiRuleProduceResourceProducer(Ai *ai): AiRule(ai) { interval= shortInterval; + rt=NULL; } bool AiRuleProduceResourceProducer::test(){ @@ -785,7 +790,7 @@ void AiRuleProduce::produceSpecific(const ProduceTask *pt){ int lowestCommandCount=1000000; int currentProducerIndex=producers[randomstart]; int bestIndex=-1; - int besti=0; + //int besti=0; int currentCommandCount=0; for(unsigned int i=randomstart; igetMyUnit(currentProducerIndex)->getCommandSize(); bestIndex=currentProducerIndex; - besti=i%(producers.size()); + //besti=i%(producers.size()); } } if( aiInterface->getMyUnit(bestIndex)->getCommandSize() > 2) { @@ -1173,9 +1178,9 @@ void AiRuleBuild::buildSpecific(const BuildTask *bt) { const int enemySightDistanceToAvoid = 18; vector enemies; ai->getAiInterface()->getWorld()->getUnitUpdater()->findEnemiesForCell(searchPos,bt->getUnitType()->getSize(),enemySightDistanceToAvoid,ai->getAiInterface()->getMyFaction(),enemies,true); - if(enemies.size() > 0) { - for(int i1 = 0; i1 < 25 && enemies.size() > 0; ++i1) { - for(int j1 = 0; j1 < 25 && enemies.size() > 0; ++j1) { + if(enemies.empty() == false) { + for(int i1 = 0; i1 < 25 && enemies.empty() == false; ++i1) { + for(int j1 = 0; j1 < 25 && enemies.empty() == false; ++j1) { Vec2i tryPos = searchPos + Vec2i(i1,j1); const int spacing = 1; @@ -1189,9 +1194,9 @@ void AiRuleBuild::buildSpecific(const BuildTask *bt) { } } } - if(enemies.size() > 0) { - for(int i1 = -1; i1 >= -25 && enemies.size() > 0; --i1) { - for(int j1 = -1; j1 >= -25 && enemies.size() > 0; --j1) { + if(enemies.empty() == false) { + for(int i1 = -1; i1 >= -25 && enemies.empty() == false; --i1) { + for(int j1 = -1; j1 >= -25 && enemies.empty() == false; --j1) { Vec2i tryPos = searchPos + Vec2i(i1,j1); const int spacing = 1; diff --git a/source/glest_game/ai/ai_rule.h b/source/glest_game/ai/ai_rule.h index 228e6f6f..b249132a 100644 --- a/source/glest_game/ai/ai_rule.h +++ b/source/glest_game/ai/ai_rule.h @@ -115,7 +115,7 @@ private: bool damagedUnitIsCastle; int getMinUnitsToRepairCastle(); - double getMinCastleHpRatio(); + double getMinCastleHpRatio() const; public: AiRuleRepair(Ai *ai); diff --git a/source/glest_game/facilities/components.cpp b/source/glest_game/facilities/components.cpp index 28576998..3e358167 100644 --- a/source/glest_game/facilities/components.cpp +++ b/source/glest_game/facilities/components.cpp @@ -101,7 +101,7 @@ void GraphicComponent::applyAllCustomProperties(std::string containerName) { std::map >::iterator iterFind1 = GraphicComponent::registeredGraphicComponentList.find(containerName); if(iterFind1 != GraphicComponent::registeredGraphicComponentList.end()) { for(std::map::iterator iterFind2 = iterFind1->second.begin(); - iterFind2 != iterFind1->second.end(); iterFind2++) { + iterFind2 != iterFind1->second.end(); ++iterFind2) { iterFind2->second->applyCustomProperties(containerName); } } @@ -146,7 +146,7 @@ bool GraphicComponent::saveAllCustomProperties(std::string containerName) { std::map >::iterator iterFind1 = GraphicComponent::registeredGraphicComponentList.find(containerName); if(iterFind1 != GraphicComponent::registeredGraphicComponentList.end()) { for(std::map::iterator iterFind2 = iterFind1->second.begin(); - iterFind2 != iterFind1->second.end(); iterFind2++) { + iterFind2 != iterFind1->second.end(); ++iterFind2) { bool saved = iterFind2->second->saveCustomProperties(containerName); foundPropertiesToSave = (saved || foundPropertiesToSave); } @@ -545,8 +545,8 @@ void GraphicScrollBar::init(int x, int y, bool horizontal,int length, int thickn this->elementCount=1; this->visibleSize=1; this->visibleStart=0; - int visibleCompPosStart=0; - int visibleCompPosEnd=length; + this->visibleCompPosStart=0; + this->visibleCompPosEnd=length; lighted= false; } @@ -628,11 +628,11 @@ bool GraphicScrollBar::mouseMove(int x, int y){ return b; } -int GraphicScrollBar::getLength() { +int GraphicScrollBar::getLength() const { return horizontal?getW():getH(); } -int GraphicScrollBar::getThickness() { +int GraphicScrollBar::getThickness() const { return horizontal?getH():getW(); } diff --git a/source/glest_game/facilities/components.h b/source/glest_game/facilities/components.h index e0b22b62..4ac1311b 100644 --- a/source/glest_game/facilities/components.h +++ b/source/glest_game/facilities/components.h @@ -314,9 +314,9 @@ public: bool getHorizontal() const {return horizontal;} - int getLength(); + int getLength() const; void setLength(int length) {horizontal?setW(length):setH(length);} - int getThickness(); + int getThickness() const; bool getLighted() const {return lighted;} diff --git a/source/glest_game/game/chat_manager.cpp b/source/glest_game/game/chat_manager.cpp index 4bc5e052..e1d0dfeb 100644 --- a/source/glest_game/game/chat_manager.cpp +++ b/source/glest_game/game/chat_manager.cpp @@ -43,6 +43,7 @@ ChatManager::ChatManager() { maxTextLenght=64; font=CoreData::getInstance().getConsoleFont(); font3D=CoreData::getInstance().getConsoleFont3D(); + inMenu=false; } void ChatManager::init(Console* console, int thisTeamIndex, const bool inMenu, string manualPlayerNameOverride) { @@ -207,7 +208,7 @@ void ChatManager::updateNetwork() { GameNetworkInterface *gameNetworkInterface= NetworkManager::getInstance().getGameNetworkInterface(); //string text; //string sender; - Config &config= Config::getInstance(); + //Config &config= Config::getInstance(); //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] gameNetworkInterface->getChatText() [%s]\n",__FILE__,__FUNCTION__,__LINE__,gameNetworkInterface->getChatText().c_str()); diff --git a/source/glest_game/game/commander.cpp b/source/glest_game/game/commander.cpp index a38178b4..59fd3695 100644 --- a/source/glest_game/game/commander.cpp +++ b/source/glest_game/game/commander.cpp @@ -85,7 +85,7 @@ void CommanderNetworkThread::execute() { try { if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); - unsigned int idx = 0; + //unsigned int idx = 0; for(;this->commanderInterface != NULL;) { if(getQuitStatus() == true) { if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); @@ -135,6 +135,7 @@ Commander::Commander() { //this->networkThread = new CommanderNetworkThread(this); //this->networkThread->setUniqueID(__FILE__); //this->networkThread->start(); + world=NULL; } Commander::~Commander() { @@ -709,7 +710,8 @@ Command* Commander::buildCommand(const NetworkCommand* networkCommand) const { SystemFlags::OutputDebug(SystemFlags::debugError,"%s\n",szBuf); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s\n",szBuf); - std::string worldLog = world->DumpWorldToLog(); + //std::string worldLog = world->DumpWorldToLog(); + world->DumpWorldToLog(); GameNetworkInterface *gameNetworkInterface= NetworkManager::getInstance().getGameNetworkInterface(); if(gameNetworkInterface != NULL && gameNetworkInterface->isConnected() == true) { @@ -769,7 +771,8 @@ Command* Commander::buildCommand(const NetworkCommand* networkCommand) const { __FILE__,__FUNCTION__,__LINE__,networkCommand->toString().c_str(),unit->getType()->getCommandTypeListDesc().c_str(),unit->getId(), unit->getFullName().c_str(),unit->getDesc().c_str(),unit->getFaction()->getIndex()); SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s\n",szBuf); - std::string worldLog = world->DumpWorldToLog(); + //std::string worldLog = world->DumpWorldToLog(); + world->DumpWorldToLog(); GameNetworkInterface *gameNetworkInterface= NetworkManager::getInstance().getGameNetworkInterface(); if(gameNetworkInterface != NULL) { diff --git a/source/glest_game/game/game.cpp b/source/glest_game/game/game.cpp index be92700f..979c4bec 100644 --- a/source/glest_game/game/game.cpp +++ b/source/glest_game/game/game.cpp @@ -46,6 +46,43 @@ Game::Game() : ProgramState(NULL) { if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); originalDisplayMsgCallback = NULL; aiInterfaces.clear(); + + mouse2d=0; + mouseX=0; + mouseY=0; + updateFps=0; + lastUpdateFps=0; + avgUpdateFps=0; + totalRenderFps=0; + renderFps=0; + lastRenderFps=0; + avgRenderFps=0; + currentAvgRenderFpsTotal=0; + paused=false; + gameOver=false; + renderNetworkStatus=false; + showFullConsole=false; + mouseMoved=false; + scrollSpeed=0; + camLeftButtonDown=false; + camRightButtonDown=false; + camUpButtonDown=false; + camDownButtonDown=false; + speed=sNormal; + weatherParticleSystem=NULL; + isFirstRender=false; + quitTriggeredIndicator=false; + original_updateFps=0; + original_cameraFps=0; + captureAvgTestStatus=false; + updateFpsAvgTest=0; + renderFpsAvgTest=0; + renderExtraTeamColor=0; + photoModeEnabled=false; + visibleHUD=false; + withRainEffect=false; + program=NULL; + gameStarted=false; } Game::Game(Program *program, const GameSettings *gameSettings): @@ -222,7 +259,7 @@ string Game::extractScenarioLogoFile(const GameSettings *settings, string &resul vector loadScreenList; findAll(scenarioDir + factionLogoFilter, loadScreenList, false, false); - if(loadScreenList.size() > 0) { + if(loadScreenList.empty() == false) { string senarioLogo = scenarioDir + loadScreenList[0]; if(fileExists(senarioLogo) == true) { if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] found scenario loading screen '%s'\n",__FILE__,__FUNCTION__,senarioLogo.c_str()); @@ -288,7 +325,7 @@ string Game::extractFactionLogoFile(bool &loadingImageUsed, string factionName, vector loadScreenList; findAll(path + factionLogoFilter, loadScreenList, false, false); - if(loadScreenList.size() > 0) { + if(loadScreenList.empty() == false) { string factionLogo = path + loadScreenList[0]; if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] looking for loading screen '%s'\n",__FILE__,__FUNCTION__,__LINE__,factionLogo.c_str()); @@ -332,7 +369,7 @@ string Game::extractTechLogoFile(string scenarioDir, string techName, vector loadScreenList; findAll(path + factionLogoFilter, loadScreenList, false, false); - if(loadScreenList.size() > 0) { + if(loadScreenList.empty() == false) { string factionLogo = path + loadScreenList[0]; if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] looking for loading screen '%s'\n",__FILE__,__FUNCTION__,__LINE__,factionLogo.c_str()); @@ -379,7 +416,7 @@ void Game::loadHudTexture(const GameSettings *settings) string path= currentPath + techName + "/" + "factions" + "/" + factionName; endPathWithSlash(path); findAll(path + "hud.*", hudList, false, false); - if(hudList.size() > 0){ + if(hudList.empty() == false){ string hudImageFileName= path + hudList[0]; if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] looking for a HUD '%s'\n",__FILE__,__FUNCTION__,__LINE__,hudImageFileName.c_str()); @@ -464,7 +501,7 @@ vector Game::processTech(string techName) { endPathWithSlash(techPath); findAll(techPath + techName + "/factions/*.", factions, false, false); - if(factions.size() > 0) { + if(factions.empty() == false) { for(unsigned int factionIdx = 0; factionIdx < factions.size(); ++factionIdx) { bool loadingImageUsed = false; string factionLogo = ""; @@ -1950,7 +1987,7 @@ void Game::render3d(){ void Game::render2d(){ Renderer &renderer= Renderer::getInstance(); - Config &config= Config::getInstance(); + //Config &config= Config::getInstance(); CoreData &coreData= CoreData::getInstance(); //init @@ -2126,9 +2163,9 @@ void Game::render2d(){ if(renderer.getShowDebugUI() == true) { const Metrics &metrics= Metrics::getInstance(); - int mx= metrics.getMinimapX(); - int my= metrics.getMinimapY(); - int mw= metrics.getMinimapW(); + //int mx= metrics.getMinimapX(); + //int my= metrics.getMinimapY(); + //int mw= metrics.getMinimapW(); int mh= metrics.getMinimapH(); const Vec4f fontColor=getGui()->getDisplay()->getColor(); @@ -2176,9 +2213,9 @@ void Game::render2d(){ if(NetworkManager::getInstance().getGameNetworkInterface() != NULL) { const Metrics &metrics= Metrics::getInstance(); int mx= metrics.getMinimapX(); - int my= metrics.getMinimapY(); + //int my= metrics.getMinimapY(); int mw= metrics.getMinimapW(); - int mh= metrics.getMinimapH(); + //int mh= metrics.getMinimapH(); const Vec4f fontColor=getGui()->getDisplay()->getColor(); if(Renderer::renderText3DEnabled == true) { diff --git a/source/glest_game/game/game_camera.cpp b/source/glest_game/game/game_camera.cpp index 9d97679e..d7c42c53 100644 --- a/source/glest_game/game/game_camera.cpp +++ b/source/glest_game/game/game_camera.cpp @@ -74,6 +74,11 @@ GameCamera::GameCamera() : pos(0.f, defaultHeight, 0.f), minVAng = -Config::getInstance().getFloat("CameraMaxYaw","77.5"); maxVAng = -Config::getInstance().getFloat("CameraMinYaw","20"); fov = Config::getInstance().getFloat("CameraFov","45"); + + lastHAng=0; + lastVAng=0; + limitX=0; + limitY=0; } GameCamera::~GameCamera() { diff --git a/source/glest_game/game/game_settings.h b/source/glest_game/game/game_settings.h index 91bc757a..4ed8f78e 100644 --- a/source/glest_game/game/game_settings.h +++ b/source/glest_game/game/game_settings.h @@ -80,6 +80,11 @@ private: public: GameSettings() { + defaultUnits=false; + defaultResources=false; + defaultVictoryConditions=false; + mapFilterIndex = 0; + factionCount = 0; thisFactionIndex = 0; fogOfWar = true; allowObservers = false; @@ -131,7 +136,7 @@ public: } } } - if(languageList.size() == 0) { + if(languageList.empty() == true) { languageList.push_back(""); } return languageList; diff --git a/source/glest_game/game/script_manager.cpp b/source/glest_game/game/script_manager.cpp index e9b8a856..c457fb62 100644 --- a/source/glest_game/game/script_manager.cpp +++ b/source/glest_game/game/script_manager.cpp @@ -220,7 +220,7 @@ void ScriptManager::onTimerTriggerEvent() { if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d] TimerTriggerEventList.size() = %d\n",__FILE__,__FUNCTION__,__LINE__,TimerTriggerEventList.size()); for(std::map::iterator iterMap = TimerTriggerEventList.begin(); - iterMap != TimerTriggerEventList.end(); iterMap++) { + iterMap != TimerTriggerEventList.end(); ++iterMap) { TimerTriggerEvent &event = iterMap->second; @@ -251,7 +251,7 @@ void ScriptManager::onCellTriggerEvent(Unit *movingUnit) { inCellTriggerEvent = true; if(movingUnit != NULL) { for(std::map::iterator iterMap = CellTriggerEventList.begin(); - iterMap != CellTriggerEventList.end(); iterMap++) { + iterMap != CellTriggerEventList.end(); ++iterMap) { CellTriggerEvent &event = iterMap->second; if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d] movingUnit = %d, event.type = %d, movingUnit->getPos() = %s, event.sourceId = %d, event.destId = %d, event.destPos = %s\n", @@ -642,7 +642,7 @@ void ScriptManager::unregisterCellTriggerEvent(int eventId) { } if(inCellTriggerEvent == false) { - if(unRegisterCellTriggerEventList.size() > 0) { + if(unRegisterCellTriggerEventList.empty() == false) { for(int i = 0; i < unRegisterCellTriggerEventList.size(); ++i) { int delayedEventId = unRegisterCellTriggerEventList[i]; if(CellTriggerEventList.find(delayedEventId) != CellTriggerEventList.end()) { diff --git a/source/glest_game/graphics/particle_type.cpp b/source/glest_game/graphics/particle_type.cpp index e1e56d6b..c6128c57 100644 --- a/source/glest_game/graphics/particle_type.cpp +++ b/source/glest_game/graphics/particle_type.cpp @@ -77,7 +77,7 @@ ParticleSystemType::~ParticleSystemType() { memoryObjectList[this]--; assert(memoryObjectList[this] == 0); } - for(Children::iterator it = children.begin(); it != children.end(); it++) + for(Children::iterator it = children.begin(); it != children.end(); ++it) delete *it; } @@ -101,7 +101,7 @@ void ParticleSystemType::copyAll(const ParticleSystemType &src) { this->teamcolorNoEnergy = src.teamcolorNoEnergy; this->teamcolorEnergy = src.teamcolorEnergy; this->alternations = src.alternations; - for(Children::iterator it = children.begin(); it != children.end(); it++) { + for(Children::iterator it = children.begin(); it != children.end(); ++it) { UnitParticleSystemType *child = *it; // Deep copy the child particles @@ -265,7 +265,7 @@ void ParticleSystemType::load(const XmlNode *particleSystemNode, const string &d void ParticleSystemType::setValues(AttackParticleSystem *ats){ // add instances of all children; some settings will cascade to all children - for(Children::iterator i=children.begin(); i!=children.end(); i++){ + for(Children::iterator i=children.begin(); i!=children.end(); ++i){ UnitParticleSystem *child = new UnitParticleSystem(); (*i)->setValues(child); ats->addChild(child); diff --git a/source/glest_game/graphics/renderer.cpp b/source/glest_game/graphics/renderer.cpp index 2dff278f..c0de87c7 100644 --- a/source/glest_game/graphics/renderer.cpp +++ b/source/glest_game/graphics/renderer.cpp @@ -273,7 +273,7 @@ void Renderer::simpleTask(BaseThread *callingThread) { string path=""; static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__); MutexSafeWrapper safeMutex(&saveScreenShotThreadAccessor,mutexOwnerId); - if(saveScreenQueue.size() > 0) { + if(saveScreenQueue.empty() == false) { if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d] saveScreenQueue.size() = %d\n",__FILE__,__FUNCTION__,__LINE__,saveScreenQueue.size()); savePixMapBuffer = saveScreenQueue.front().second; @@ -797,7 +797,7 @@ void Renderer::computeVisibleQuad() { br = _unprojectMap(Vec2i(viewport[2],viewport[3]),model,projection,viewport,"br"), bl = _unprojectMap(Vec2i(0,viewport[3]),model,projection,viewport,"bl"); // orientate it for map iterator - bool swapRequiredX = false; + //bool swapRequiredX = false; bool swapRequiredY = false; int const cellBuffer = 4; if((tl.x > tr.x) || (bl.x > br.x)) { @@ -812,7 +812,7 @@ void Renderer::computeVisibleQuad() { tl.x -= cellBuffer; std::swap(tl.x,tr.x); - swapRequiredX = true; + //swapRequiredX = true; } else { tl.x += cellBuffer; @@ -825,7 +825,7 @@ void Renderer::computeVisibleQuad() { br.x -= cellBuffer; std::swap(bl.x,br.x); - swapRequiredX = true; + //swapRequiredX = true; } else { br.x += cellBuffer; @@ -1135,7 +1135,7 @@ void Renderer::renderTextureQuad(int x, int y, int w, int h, const Texture2D *te void Renderer::renderConsoleLine3D(int lineIndex, int xPosition, int yPosition, int lineHeight, Font3D* font, string stringToHightlight, const ConsoleLineInfo *lineInfo) { Vec4f fontColor; - const Metrics &metrics= Metrics::getInstance(); + //const Metrics &metrics= Metrics::getInstance(); FontMetrics *fontMetrics= font->getMetrics(); if(game != NULL) { @@ -2769,15 +2769,15 @@ void Renderer::MapRenderer::Layer::render(VisibleQuadContainerCache &qCache) { const bool renderOnlyVisibleQuad = true; if(renderOnlyVisibleQuad == true) { - int startIndex = -1; - int lastValidIndex = -1; - vector > rowsToRender; if(rowsToRenderCache.find(qCache.lastVisibleQuad) != rowsToRenderCache.end()) { rowsToRender = rowsToRenderCache[qCache.lastVisibleQuad]; } else { + int startIndex = -1; + int lastValidIndex = -1; + for(int visibleIndex = 0; visibleIndex < qCache.visibleScaledCellList.size(); ++visibleIndex) { Vec2i &pos = qCache.visibleScaledCellList[visibleIndex]; @@ -2806,7 +2806,7 @@ void Renderer::MapRenderer::Layer::render(VisibleQuadContainerCache &qCache) { rowsToRenderCache[qCache.lastVisibleQuad] = rowsToRender; } - if(rowsToRender.size() > 0) { + if(rowsToRender.empty() == false) { //printf("Layer has %d rows in visible quad, visible quad has %d cells\n",rowsToRender.size(),qCache.visibleScaledCellList.size()); glVertexPointer(3,GL_FLOAT,0,_bindVBO(vbo_vertices,vertices)); @@ -2960,11 +2960,8 @@ void Renderer::renderSurface(const int renderFps) { } } - int lastTex=-1; - int currTex=-1; const Rect2i mapBounds(0, 0, map->getSurfaceW()-1, map->getSurfaceH()-1); - glActiveTexture(baseTexUnit); VisibleQuadContainerCache &qCache = getQuadCache(); @@ -2975,7 +2972,10 @@ void Renderer::renderSurface(const int renderFps) { //mapRenderer.render(map,coordStep,qCache); mapRenderer.renderVisibleLayers(map,coordStep,qCache); } - else if(qCache.visibleScaledCellList.size() > 0) { + else if(qCache.visibleScaledCellList.empty() == false) { + + int lastTex=-1; + int currTex=-1; Quad2i snapshotOfvisibleQuad = visibleQuad; @@ -3561,7 +3561,7 @@ void Renderer::renderWater() { void Renderer::renderTeamColorCircle(){ VisibleQuadContainerCache &qCache = getQuadCache(); - if(qCache.visibleQuadUnitList.size() > 0) { + if(qCache.visibleQuadUnitList.empty() == false) { glPushAttrib(GL_ENABLE_BIT | GL_CURRENT_BIT | GL_DEPTH_BUFFER_BIT); glDisable(GL_LIGHTING); @@ -3586,7 +3586,7 @@ void Renderer::renderTeamColorCircle(){ void Renderer::renderTeamColorPlane(){ VisibleQuadContainerCache &qCache = getQuadCache(); - if(qCache.visibleQuadUnitList.size() > 0){ + if(qCache.visibleQuadUnitList.empty() == false){ glPushAttrib(GL_ENABLE_BIT); glDisable(GL_LIGHTING); glEnable(GL_TEXTURE_2D); @@ -3608,8 +3608,8 @@ void Renderer::renderTeamColorPlane(){ void Renderer::renderUnits(const int renderFps) { - Unit *unit=NULL; - const World *world= game->getWorld(); + //Unit *unit=NULL; + //const World *world= game->getWorld(); MeshCallbackTeamColor meshCallbackTeamColor; //assert @@ -3626,7 +3626,7 @@ void Renderer::renderUnits(const int renderFps) { bool modelRenderStarted = false; VisibleQuadContainerCache &qCache = getQuadCache(); - if(qCache.visibleQuadUnitList.size() > 0) { + if(qCache.visibleQuadUnitList.empty() == false) { for(int visibleUnitIndex = 0; visibleUnitIndex < qCache.visibleQuadUnitList.size(); ++visibleUnitIndex) { Unit *unit = qCache.visibleQuadUnitList[visibleUnitIndex]; @@ -3674,10 +3674,9 @@ void Renderer::renderUnits(const int renderFps) { glRotatef(unit->getRotation(), 0.f, 1.f, 0.f); //dead alpha - float alpha= 1.0f; const SkillType *st= unit->getCurrSkill(); if(st->getClass() == scDie && static_cast(st)->getFade()) { - alpha= 1.0f-unit->getAnimProgress(); + float alpha= 1.0f-unit->getAnimProgress(); glDisable(GL_COLOR_MATERIAL); glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, Vec4f(1.0f, 1.0f, 1.0f, alpha).ptr()); } @@ -3727,9 +3726,9 @@ void Renderer::renderUnits(const int renderFps) { } void Renderer::renderTeamColorEffect(Vec3f &v, int heigth, int size, Vec3f color, const Texture2D *texture) { - GLUquadricObj *disc; + //GLUquadricObj *disc; float halfSize=size; - halfSize=halfSize; + //halfSize=halfSize; float heigthoffset=0.5+heigth%25*0.004; glPushMatrix(); glBindTexture(GL_TEXTURE_2D, static_cast(texture)->getHandle()); @@ -4336,7 +4335,7 @@ void Renderer::renderMinimap(){ //draw units VisibleQuadContainerCache &qCache = getQuadCache(); - if(qCache.visibleUnitList.size() > 0) { + if(qCache.visibleUnitList.empty() == false) { uint32 unitIdx=0; vector unit_vertices; unit_vertices.resize(qCache.visibleUnitList.size()*4); @@ -4827,7 +4826,7 @@ void Renderer::computeSelected( Selection::UnitContainer &units, const Object *& if(index>=OBJECT_SELECT_OFFSET) { Object *object = qCache.visibleObjectList[index-OBJECT_SELECT_OFFSET]; - if(object != NULL && object) { + if(object != NULL) { obj=object; if(withObjectSelection) { break; @@ -5303,7 +5302,7 @@ void Renderer::renderUnitsFast(bool renderingShadows) { bool modelRenderStarted = false; VisibleQuadContainerCache &qCache = getQuadCache(); - if(qCache.visibleQuadUnitList.size() > 0) { + if(qCache.visibleQuadUnitList.empty() == false) { for(int visibleUnitIndex = 0; visibleUnitIndex < qCache.visibleQuadUnitList.size(); ++visibleUnitIndex) { Unit *unit = qCache.visibleQuadUnitList[visibleUnitIndex]; @@ -5372,14 +5371,14 @@ void Renderer::renderUnitsFast(bool renderingShadows) { //render objects for selection purposes void Renderer::renderObjectsFast(bool renderingShadows, bool resourceOnly) { const World *world= game->getWorld(); - const Map *map= world->getMap(); + //const Map *map= world->getMap(); assertGl(); bool modelRenderStarted = false; VisibleQuadContainerCache &qCache = getQuadCache(); - if(qCache.visibleObjectList.size() > 0) { + if(qCache.visibleObjectList.empty() == false) { for(int visibleIndex = 0; visibleIndex < qCache.visibleObjectList.size(); ++visibleIndex) { Object *o = qCache.visibleObjectList[visibleIndex]; @@ -6071,7 +6070,7 @@ void Renderer::setAllowRenderUnitTitles(bool value) { void Renderer::renderUnitTitles3D(Font3D *font, Vec3f color) { std::map unitRenderedList; - if(visibleFrameUnitList.size() > 0) { + if(visibleFrameUnitList.empty() == false) { //printf("Render Unit titles ON\n"); for(int idx = 0; idx < visibleFrameUnitList.size(); idx++) { @@ -6105,7 +6104,7 @@ void Renderer::renderUnitTitles3D(Font3D *font, Vec3f color) { } /* - if(renderUnitTitleList.size() > 0) { + if(renderUnitTitleList.empty() == false) { for(int idx = 0; idx < renderUnitTitleList.size(); idx++) { std::pair &unitInfo = renderUnitTitleList[idx]; Unit *unit = unitInfo.first; @@ -6130,7 +6129,7 @@ void Renderer::renderUnitTitles3D(Font3D *font, Vec3f color) { void Renderer::renderUnitTitles(Font2D *font, Vec3f color) { std::map unitRenderedList; - if(visibleFrameUnitList.size() > 0) { + if(visibleFrameUnitList.empty() == false) { //printf("Render Unit titles ON\n"); for(int idx = 0; idx < visibleFrameUnitList.size(); idx++) { @@ -6162,7 +6161,7 @@ void Renderer::renderUnitTitles(Font2D *font, Vec3f color) { } /* - if(renderUnitTitleList.size() > 0) { + if(renderUnitTitleList.empty() == false) { for(int idx = 0; idx < renderUnitTitleList.size(); idx++) { std::pair &unitInfo = renderUnitTitleList[idx]; Unit *unit = unitInfo.first; diff --git a/source/glest_game/graphics/renderer.h b/source/glest_game/graphics/renderer.h index 76806d8f..8c6be2f7 100644 --- a/source/glest_game/graphics/renderer.h +++ b/source/glest_game/graphics/renderer.h @@ -270,7 +270,11 @@ private: class SurfaceData { public: - SurfaceData(){}; + SurfaceData() { + uniqueId=0; + bufferCount=0; + textureHandle=0; + } static uint32 nextUniqueId; uint32 uniqueId; int bufferCount; diff --git a/source/glest_game/graphics/unit_particle_type.cpp b/source/glest_game/graphics/unit_particle_type.cpp index 9ff4b40e..f532a556 100644 --- a/source/glest_game/graphics/unit_particle_type.cpp +++ b/source/glest_game/graphics/unit_particle_type.cpp @@ -185,7 +185,7 @@ void UnitParticleSystemType::load(const XmlNode *particleSystemNode, const strin const void UnitParticleSystemType::setValues(UnitParticleSystem *ups){ // whilst we extend ParticleSystemType we don't use ParticleSystemType::setValues() // add instances of all children; some settings will cascade to all children - for(Children::iterator i=children.begin(); i!=children.end(); i++){ + for(Children::iterator i=children.begin(); i!=children.end(); ++i){ UnitParticleSystem *child = new UnitParticleSystem(); (*i)->setValues(child); ups->addChild(child); diff --git a/source/glest_game/gui/display.cpp b/source/glest_game/gui/display.cpp index a384ae1f..14e0628a 100644 --- a/source/glest_game/gui/display.cpp +++ b/source/glest_game/gui/display.cpp @@ -94,7 +94,7 @@ void Display::switchColor(){ currentColor= (currentColor+1) % colorCount; } -int Display::computeDownIndex(int x, int y){ +int Display::computeDownIndex(int x, int y) const { y= y-(downY-cellSideCount*imageSize); if(y>imageSize*cellSideCount || y < 0){ diff --git a/source/glest_game/gui/display.h b/source/glest_game/gui/display.h index 0cfcdb1e..8bb1aae7 100644 --- a/source/glest_game/gui/display.h +++ b/source/glest_game/gui/display.h @@ -74,8 +74,8 @@ public: const Texture2D *getUpImage(int index) const {return upImages[index];} const Texture2D *getDownImage(int index) const {return downImages[index];} bool getDownLighted(int index) const {return downLighted[index];} - const CommandType *getCommandType(int i) {return commandTypes[i];} - CommandClass getCommandClass(int i) {return commandClasses[i];} + const CommandType *getCommandType(int i) const {return commandTypes[i];} + CommandClass getCommandClass(int i) const {return commandClasses[i];} Vec4f getColor() const; int getProgressBar() const {return progressBar;} int getDownSelectedPos() const {return downSelectedPos;} @@ -97,7 +97,7 @@ public: //misc void clear(); void switchColor(); - int computeDownIndex(int x, int y); + int computeDownIndex(int x, int y) const; int computeDownX(int index) const; int computeDownY(int index) const; int computeUpX(int index) const; diff --git a/source/glest_game/gui/gui.cpp b/source/glest_game/gui/gui.cpp index b3f61299..16793850 100644 --- a/source/glest_game/gui/gui.cpp +++ b/source/glest_game/gui/gui.cpp @@ -112,6 +112,12 @@ Gui::Gui(){ minQuadSize=20; selectedResourceObject=NULL; hudTexture=NULL; + commander=NULL; + world=NULL; + game=NULL; + gameCamera=NULL; + console=NULL; + choosenBuildingType=NULL; if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] END\n",__FILE__,__FUNCTION__); } @@ -640,7 +646,7 @@ void Gui::mouseDownDisplayUnitBuild(int posDisplay){ string Gui::computeDefaultInfoString() { - Lang &lang= Lang::getInstance(); + //Lang &lang= Lang::getInstance(); string result=""; //printf("\n\n\n\n********* selection.isCommandable() [%d] selection.isUniform() [%d]\n\n",selection.isCommandable(),selection.isUniform()); @@ -972,7 +978,7 @@ void Gui::computeSelected(bool doubleClick, bool force){ activeCommandType= NULL; //select all units of the same type if double click - if(doubleClick && units.size()>0){ + if(doubleClick && units.empty() == false){ const Unit *refUnit= getRelevantObjectFromSelection(&units); int factionIndex= refUnit->getFactionIndex(); for(int i=0; igetFaction(factionIndex)->getUnitCount(); ++i){ diff --git a/source/glest_game/main/battle_end.cpp b/source/glest_game/main/battle_end.cpp index 7a0b524b..2170e60b 100644 --- a/source/glest_game/main/battle_end.cpp +++ b/source/glest_game/main/battle_end.cpp @@ -80,7 +80,7 @@ void BattleEnd::update() { void BattleEnd::render() { Renderer &renderer= Renderer::getInstance(); - CoreData &coreData= CoreData::getInstance(); + //CoreData &coreData= CoreData::getInstance(); canRender(); incrementFps(); @@ -146,7 +146,7 @@ void BattleEnd::render() { continue; } - int team= stats.getTeam(i) + 1; + //int team= stats.getTeam(i) + 1; int kills= stats.getKills(i); if(kills > bestKills) { bestKills = kills; diff --git a/source/glest_game/main/intro.cpp b/source/glest_game/main/intro.cpp index d10c696a..9c5e4973 100644 --- a/source/glest_game/main/intro.cpp +++ b/source/glest_game/main/intro.cpp @@ -47,6 +47,7 @@ Text::Text(const Texture2D *texture, const Vec2i &pos, const Vec2i &size, int ti this->time= time; this->texture= texture; this->font= NULL; + this->font3D=NULL; } // ===================================================== diff --git a/source/glest_game/main/main.cpp b/source/glest_game/main/main.cpp index 8974117b..afd90a58 100644 --- a/source/glest_game/main/main.cpp +++ b/source/glest_game/main/main.cpp @@ -1365,14 +1365,14 @@ void setupLogging(Config &config, bool haveSpecialOutputCommandLineOption) { } void runTechValidationForPath(string techPath, string techName, - const std::vector filteredFactionList, World &world, + const std::vector &filteredFactionList, World &world, bool purgeUnusedFiles,bool purgeDuplicateFiles, bool showDuplicateFiles, bool svnPurgeFiles,double &purgedMegaBytes) { - Config &config = Config::getInstance(); + //Config &config = Config::getInstance(); vector factionsList; findDirs(techPath + techName + "/factions/", factionsList, false, false); - if(factionsList.size() > 0) { + if(factionsList.empty() == false) { Checksum checksum; set factions; for(int j = 0; j < factionsList.size(); ++j) { @@ -1391,7 +1391,7 @@ void runTechValidationForPath(string techPath, string techName, } } - if(factions.size() > 0) { + if(factions.empty() == false) { bool techtree_errors = false; std::map > > loadedFileList; @@ -1425,7 +1425,7 @@ void runTechValidationForPath(string techPath, string techName, // Validate the faction setup to ensure we don't have any bad associations std::vector resultErrors = world.validateFactionTypes(); - if(resultErrors.size() > 0) { + if(resultErrors.empty() == false) { techtree_errors = true; // Display the validation errors string errorText = "\nErrors were detected:\n=====================\n"; @@ -1448,7 +1448,7 @@ void runTechValidationForPath(string techPath, string techName, } resultErrors = world.validateResourceTypes(); - if(resultErrors.size() > 0) { + if(resultErrors.empty() == false) { techtree_errors = true; // Display the validation errors string errorText = "\nErrors were detected:\n=====================\n"; @@ -1559,7 +1559,7 @@ void runTechValidationForPath(string techPath, string techName, std::map > mapDuplicateFiles; // Now check for duplicate data content for(std::map > >::iterator iterMap = loadedFileList.begin(); - iterMap != loadedFileList.end(); iterMap++) { + iterMap != loadedFileList.end(); ++iterMap) { string fileName = iterMap->first; Checksum checksum; checksum.addFile(fileName); @@ -1583,7 +1583,7 @@ void runTechValidationForPath(string techPath, string techName, bool foundDuplicates = false; for(std::map >::iterator iterMap = mapDuplicateFiles.begin(); - iterMap != mapDuplicateFiles.end(); iterMap++) { + iterMap != mapDuplicateFiles.end(); ++iterMap) { vector &fileList = iterMap->second; if(fileList.size() > 1) { if(foundDuplicates == false) { @@ -1614,7 +1614,7 @@ void runTechValidationForPath(string techPath, string techName, } for(map::iterator iterMap1 = parentList.begin(); - iterMap1 != parentList.end(); iterMap1++) { + iterMap1 != parentList.end(); ++iterMap1) { if(iterMap1 == parentList.begin()) { printf("\tParents:\n"); @@ -1878,7 +1878,7 @@ void runTechValidationReport(int argc, char** argv) { string factionList = paramPartTokens[1]; Tokenize(factionList,filteredFactionList,","); - if(filteredFactionList.size() > 0) { + if(filteredFactionList.empty() == false) { printf("Filtering factions and only looking for the following:\n"); for(int idx = 0; idx < filteredFactionList.size(); ++idx) { filteredFactionList[idx] = trim(filteredFactionList[idx]); @@ -1909,7 +1909,7 @@ void runTechValidationReport(int argc, char** argv) { string techtreeList = paramPartTokens[1]; Tokenize(techtreeList,filteredTechTreeList,","); - if(filteredTechTreeList.size() > 0) { + if(filteredTechTreeList.empty() == false) { printf("Filtering techtrees and only looking for the following:\n"); for(int idx = 0; idx < filteredTechTreeList.size(); ++idx) { filteredTechTreeList[idx] = trim(filteredTechTreeList[idx]); @@ -2017,7 +2017,7 @@ void ShowINISettings(int argc, char **argv,Config &config,Config &configKeys) { string tokenList = paramPartTokens[1]; Tokenize(tokenList,filteredPropertyList,","); - if(filteredPropertyList.size() > 0) { + if(filteredPropertyList.empty() == false) { printf("Filtering properties and only looking for the following:\n"); for(int idx = 0; idx < filteredPropertyList.size(); ++idx) { filteredPropertyList[idx] = trim(filteredPropertyList[idx]); @@ -2038,7 +2038,7 @@ void ShowINISettings(int argc, char **argv,Config &config,Config &configKeys) { const pair &nameValue = mergedMainSettings[i]; bool displayProperty = false; - if(filteredPropertyList.size() > 0) { + if(filteredPropertyList.empty() == false) { if(find(filteredPropertyList.begin(),filteredPropertyList.end(),nameValue.first) != filteredPropertyList.end()) { displayProperty = true; } @@ -2061,7 +2061,7 @@ void ShowINISettings(int argc, char **argv,Config &config,Config &configKeys) { const pair &nameValue = mergedKeySettings[i]; bool displayProperty = false; - if(filteredPropertyList.size() > 0) { + if(filteredPropertyList.empty() == false) { if(find(filteredPropertyList.begin(),filteredPropertyList.end(),nameValue.first) != filteredPropertyList.end()) { displayProperty = true; } @@ -2086,7 +2086,7 @@ void ShowINISettings(int argc, char **argv,Config &config,Config &configKeys) { const pair &nameValue = mergedMainSettings[i]; bool displayProperty = false; - if(filteredPropertyList.size() > 0) { + if(filteredPropertyList.empty() == false) { if(find(filteredPropertyList.begin(),filteredPropertyList.end(),nameValue.first) != filteredPropertyList.end()) { displayProperty = true; } @@ -2114,7 +2114,7 @@ void ShowINISettings(int argc, char **argv,Config &config,Config &configKeys) { const pair &nameValue = mergedKeySettings[i]; bool displayProperty = false; - if(filteredPropertyList.size() > 0) { + if(filteredPropertyList.empty() == false) { if(find(filteredPropertyList.begin(),filteredPropertyList.end(),nameValue.first) != filteredPropertyList.end()) { displayProperty = true; } @@ -2178,7 +2178,7 @@ void CheckForDuplicateData() { } } } - if(duplicateMapsToRename.size() > 0) { + if(duplicateMapsToRename.empty() == false) { string errorMsg = "Warning duplicate maps were detected and renamed:\n"; for(int i = 0; i < duplicateMapsToRename.size(); ++i) { string currentPath = mapPaths[1]; @@ -2236,7 +2236,7 @@ void CheckForDuplicateData() { } } } - if(duplicateTilesetsToRename.size() > 0) { + if(duplicateTilesetsToRename.empty() == false) { string errorMsg = "Warning duplicate tilesets were detected and renamed:\n"; for(int i = 0; i < duplicateTilesetsToRename.size(); ++i) { @@ -2262,7 +2262,7 @@ void CheckForDuplicateData() { newFile = newFile + "/" + tilesetName + "_custom.xml"; //printf("\n\n\n###### RENAME [%s] to [%s]\n\n",oldFile.c_str(),newFile.c_str()); - int result2 = rename(oldFile.c_str(),newFile.c_str()); + rename(oldFile.c_str(),newFile.c_str()); } errorMsg += szBuf; } @@ -2298,7 +2298,7 @@ void CheckForDuplicateData() { } } } - if(duplicateTechtreesToRename.size() > 0) { + if(duplicateTechtreesToRename.empty() == false) { string errorMsg = "Warning duplicate techtrees were detected and renamed:\n"; for(int i = 0; i < duplicateTechtreesToRename.size(); ++i) { @@ -2324,7 +2324,7 @@ void CheckForDuplicateData() { newFile = newFile + "/" + tilesetName + "_custom.xml"; //printf("\n\n\n###### RENAME [%s] to [%s]\n\n",oldFile.c_str(),newFile.c_str()); - int result2 = rename(oldFile.c_str(),newFile.c_str()); + rename(oldFile.c_str(),newFile.c_str()); } errorMsg += szBuf; } diff --git a/source/glest_game/main/program.cpp b/source/glest_game/main/program.cpp index e96bb8d8..7079c336 100644 --- a/source/glest_game/main/program.cpp +++ b/source/glest_game/main/program.cpp @@ -55,6 +55,8 @@ ProgramState::ProgramState(Program *program) { this->mouse2dAnim = 0; this->fps= 0; this->lastFps= 0; + this->startX=0; + this->startY=0; } void ProgramState::incrementFps() { @@ -546,7 +548,8 @@ void Program::init(WindowGl *window, bool initSound, bool toggleFullScreen){ if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); //lang - Lang &lang= Lang::getInstance(); + //Lang &lang= Lang::getInstance(); + Lang::getInstance(); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); diff --git a/source/glest_game/menu/main_menu.cpp b/source/glest_game/menu/main_menu.cpp index 98eb156b..d585edb4 100644 --- a/source/glest_game/menu/main_menu.cpp +++ b/source/glest_game/menu/main_menu.cpp @@ -86,9 +86,9 @@ void MainMenu::init() { //asynchronus render update void MainMenu::render() { - Config &config= Config::getInstance(); + //Config &config= Config::getInstance(); Renderer &renderer= Renderer::getInstance(); - CoreData &coreData= CoreData::getInstance(); + //CoreData &coreData= CoreData::getInstance(); //fps++; canRender(); diff --git a/source/glest_game/menu/menu_state_about.cpp b/source/glest_game/menu/menu_state_about.cpp index d01951f1..a39058a3 100644 --- a/source/glest_game/menu/menu_state_about.cpp +++ b/source/glest_game/menu/menu_state_about.cpp @@ -165,7 +165,7 @@ void MenuStateAbout::keyDown(SDL_KeyboardEvent key){ Config &configKeys= Config::getInstance(std::pair(cfgMainKeys, cfgUserKeys)); //if(key == configKeys.getCharKey("SaveGUILayout")){ if(isKeyPressed(configKeys.getSDLKey("SaveGUILayout"),key) == true) { - bool saved= GraphicComponent::saveAllCustomProperties(containerName); + GraphicComponent::saveAllCustomProperties(containerName); //Lang &lang= Lang::getInstance(); //console.addLine(lang.get("GUILayoutSaved") + " [" + (saved ? lang.get("Yes") : lang.get("No"))+ "]"); } diff --git a/source/glest_game/menu/menu_state_connected_game.cpp b/source/glest_game/menu/menu_state_connected_game.cpp index 4844e5d5..1a9cc42d 100644 --- a/source/glest_game/menu/menu_state_connected_game.cpp +++ b/source/glest_game/menu/menu_state_connected_game.cpp @@ -429,7 +429,7 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM vector mapPathList = config.getPathListForType(ptMaps); std::pair mapsPath; - if(mapPathList.size() > 0) { + if(mapPathList.empty() == false) { mapsPath.first = mapPathList[0]; } if(mapPathList.size() > 1) { @@ -437,7 +437,7 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM } std::pair tilesetsPath; vector tilesetsList = Config::getInstance().getPathListForType(ptTilesets); - if(tilesetsList.size() > 0) { + if(tilesetsList.empty() == false) { tilesetsPath.first = tilesetsList[0]; if(tilesetsList.size() > 1) { tilesetsPath.second = tilesetsList[1]; @@ -446,7 +446,7 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM std::pair techtreesPath; vector techtreesList = Config::getInstance().getPathListForType(ptTechs); - if(techtreesList.size() > 0) { + if(techtreesList.empty() == false) { techtreesPath.first = techtreesList[0]; if(techtreesList.size() > 1) { techtreesPath.second = techtreesList[1]; @@ -455,7 +455,7 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM std::pair scenariosPath; vector scenariosList = Config::getInstance().getPathListForType(ptScenarios); - if(scenariosList.size() > 0) { + if(scenariosList.empty() == false) { scenariosPath.first = scenariosList[0]; if(scenariosList.size() > 1) { scenariosPath.second = scenariosList[1]; @@ -588,7 +588,7 @@ void MenuStateConnectedGame::mouseClick(int x, int y, MouseButton mouseButton){ } } else if(buttonCancelDownloads.mouseClick(x,y)) { - if(ftpClientThread != NULL && fileFTPProgressList.size() > 0) { + if(ftpClientThread != NULL && fileFTPProgressList.empty() == false) { ftpClientThread->setCallBackObject(NULL); if(ftpClientThread->shutdownAndWait() == true) { delete ftpClientThread; @@ -612,7 +612,7 @@ void MenuStateConnectedGame::mouseClick(int x, int y, MouseButton mouseButton){ Config &config = Config::getInstance(); vector mapPathList = config.getPathListForType(ptMaps); std::pair mapsPath; - if(mapPathList.size() > 0) { + if(mapPathList.empty() == false) { mapsPath.first = mapPathList[0]; } if(mapPathList.size() > 1) { @@ -620,7 +620,7 @@ void MenuStateConnectedGame::mouseClick(int x, int y, MouseButton mouseButton){ } std::pair tilesetsPath; vector tilesetsList = Config::getInstance().getPathListForType(ptTilesets); - if(tilesetsList.size() > 0) { + if(tilesetsList.empty() == false) { tilesetsPath.first = tilesetsList[0]; if(tilesetsList.size() > 1) { tilesetsPath.second = tilesetsList[1]; @@ -629,7 +629,7 @@ void MenuStateConnectedGame::mouseClick(int x, int y, MouseButton mouseButton){ std::pair techtreesPath; vector techtreesList = Config::getInstance().getPathListForType(ptTechs); - if(techtreesList.size() > 0) { + if(techtreesList.empty() == false) { techtreesPath.first = techtreesList[0]; if(techtreesList.size() > 1) { techtreesPath.second = techtreesList[1]; @@ -638,7 +638,7 @@ void MenuStateConnectedGame::mouseClick(int x, int y, MouseButton mouseButton){ std::pair scenariosPath; vector scenariosList = Config::getInstance().getPathListForType(ptScenarios); - if(scenariosList.size() > 0) { + if(scenariosList.empty() == false) { scenariosPath.first = scenariosList[0]; if(scenariosList.size() > 1) { scenariosPath.second = scenariosList[1]; @@ -1014,7 +1014,7 @@ void MenuStateConnectedGame::render() { renderer.renderListBox(&listBoxNetworkPauseGameForLaggedClients); MutexSafeWrapper safeMutexFTPProgress((ftpClientThread != NULL ? ftpClientThread->getProgressMutex() : NULL),string(__FILE__) + "_" + intToStr(__LINE__)); - if(fileFTPProgressList.size() > 0) { + if(fileFTPProgressList.empty() == false) { Lang &lang= Lang::getInstance(); renderer.renderButton(&buttonCancelDownloads); int yLocation = buttonCancelDownloads.getY() - 20; @@ -1192,11 +1192,11 @@ void MenuStateConnectedGame::update() { factionCRCList.clear(); for(unsigned int factionIdx = 0; factionIdx < factionFiles.size(); ++factionIdx) { string factionName = factionFiles[factionIdx]; - int32 factionCRC = 0; if(factionName != GameConstants::RANDOMFACTION_SLOTNAME && factionName != GameConstants::OBSERVER_SLOTNAME && factionName != ITEM_MISSING) { + int32 factionCRC = 0; time_t now = time(NULL); time_t lastUpdateDate = getFolderTreeContentsCheckSumRecursivelyLastGenerated(config.getPathListForType(ptTechs,""), "/" + gameSettings->getTech() + "/factions/" + factionName + "/*", ".xml"); @@ -1417,7 +1417,7 @@ void MenuStateConnectedGame::update() { } if(mismatchedFactionText != "") { - if(mismatchedFactionTextList.size() > 0) { + if(mismatchedFactionTextList.empty() == false) { if(mismatchedFactionText != "") { mismatchedFactionText += "."; mismatchedFactionTextList.push_back(mismatchedFactionText); @@ -1583,7 +1583,7 @@ void MenuStateConnectedGame::update() { if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) chrono.start(); try { - bool mustSwitchPlayerName = false; + //bool mustSwitchPlayerName = false; if(clientInterface->getGameSettingsReceived()) { updateDataSynchDetailText = true; bool errorOnMissingData = (clientInterface->getAllowGameDataSynchCheck() == false); @@ -1868,7 +1868,7 @@ void MenuStateConnectedGame::update() { needToSetChangedGameSettings = true; lastSetChangedGameSettings = time(NULL); - mustSwitchPlayerName = true; + //mustSwitchPlayerName = true; } } @@ -1992,7 +1992,7 @@ bool MenuStateConnectedGame::loadFactions(const GameSettings *gameSettings, bool if(gameSettings->getTech() != "") { Config &config = Config::getInstance(); - Lang &lang= Lang::getInstance(); + //Lang &lang= Lang::getInstance(); vector techPaths = config.getPathListForType(ptTechs); for(int idx = 0; idx < techPaths.size(); idx++) { @@ -2000,7 +2000,7 @@ bool MenuStateConnectedGame::loadFactions(const GameSettings *gameSettings, bool endPathWithSlash(techPath); //findAll(techPath + gameSettings->getTech() + "/factions/*.", results, false, false); findDirs(techPath + gameSettings->getTech() + "/factions/", results, false, false); - if(results.size() > 0) { + if(results.empty() == false) { break; } } @@ -2064,7 +2064,7 @@ bool MenuStateConnectedGame::loadFactions(const GameSettings *gameSettings, bool listBoxFactions[i].setItems(results); } - foundFactions = (results.size() > 0); + foundFactions = (results.empty() == false); } } if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); @@ -2427,7 +2427,7 @@ void MenuStateConnectedGame::FTPClient_CallbackEvent(string itemName, FTP_Client_CallbackType type, pair result, void *userdata) { if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__); - Lang &lang= Lang::getInstance(); + //Lang &lang= Lang::getInstance(); if(type == ftp_cct_DownloadProgress) { FTPClientCallbackInterface::FtpProgressStats *stats = (FTPClientCallbackInterface::FtpProgressStats *)userdata; if(stats != NULL) { diff --git a/source/glest_game/menu/menu_state_custom_game.cpp b/source/glest_game/menu/menu_state_custom_game.cpp index 5e1348fc..15ae5cbc 100644 --- a/source/glest_game/menu/menu_state_custom_game.cpp +++ b/source/glest_game/menu/menu_state_custom_game.cpp @@ -186,7 +186,7 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b string ipText = "none"; std::vector ipList = Socket::getLocalIPAddressList(); - if(ipList.size() > 0) { + if(ipList.empty() == false) { ipText = ""; for(int idx = 0; idx < ipList.size(); idx++) { string ip = ipList[idx]; @@ -481,12 +481,12 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b //findAll(techPath + techTreeFiles[listBoxTechTree.getSelectedItemIndex()] + "/factions/*.", results, false, false); findDirs(techPath + techTreeFiles[listBoxTechTree.getSelectedItemIndex()] + "/factions/", results, false, false); - if(results.size() > 0) { + if(results.empty() == false) { break; } } - if(results.size() == 0) { + if(results.empty() == true) { //throw runtime_error("(1)There are no factions for the tech tree [" + techTreeFiles[listBoxTechTree.getSelectedItemIndex()] + "]"); showGeneralError=true; generalErrorToShow = "[#1] There are no factions for the tech tree [" + techTreeFiles[listBoxTechTree.getSelectedItemIndex()] + "]"; @@ -2052,7 +2052,7 @@ void MenuStateCustomGame::simpleTask(BaseThread *callingThread) { CURL *handle = SystemFlags::initHTTP(); for(std::map::const_iterator iterMap = newPublishToServerInfo.begin(); - iterMap != newPublishToServerInfo.end(); iterMap++) { + iterMap != newPublishToServerInfo.end(); ++iterMap) { request += iterMap->first; request += "="; @@ -2713,12 +2713,12 @@ void MenuStateCustomGame::reloadFactions(bool keepExistingSelectedItem) { //findAll(techPath + techTreeFiles[listBoxTechTree.getSelectedItemIndex()] + "/factions/*.", results, false, false); findDirs(techPath + techTreeFiles[listBoxTechTree.getSelectedItemIndex()] + "/factions/", results, false, false); - if(results.size() > 0) { + if(results.empty() == false) { break; } } - if(results.size() == 0) { + if(results.empty() == true) { //throw runtime_error("(2)There are no factions for the tech tree [" + techTreeFiles[listBoxTechTree.getSelectedItemIndex()] + "]"); showGeneralError=true; generalErrorToShow = "[#2] There are no factions for the tech tree [" + techTreeFiles[listBoxTechTree.getSelectedItemIndex()] + "]";