- phase 3 of cppcheck verbose fixes

This commit is contained in:
Mark Vejvoda 2011-09-01 18:08:56 +00:00
parent 57afc2d715
commit bb68106912
18 changed files with 83 additions and 64 deletions

View File

@ -587,7 +587,7 @@ void MainWindow::onPaint(wxPaintEvent &event) {
}
}
}
else if(modelPathList.size() == 0 && haveLoadedParticles) {
else if(modelPathList.empty() == true && haveLoadedParticles) {
if(renderer->hasActiveParticleSystem(ParticleSystem::pst_ProjectileParticleSystem) == false &&
renderer->hasActiveParticleSystem(ParticleSystem::pst_SplashParticleSystem) == false) {

View File

@ -640,7 +640,7 @@ void Ai::massiveAttack(const Vec2i &pos, Field field, bool ultraAttack){
void Ai::returnBase(int unitIndex) {
Vec2i pos;
CommandResult r;
int fi= aiInterface->getFactionIndex();
aiInterface->getFactionIndex();
pos= Vec2i(
random.randRange(-villageRadius, villageRadius), random.randRange(-villageRadius, villageRadius)) +
getRandomHomePosition();

View File

@ -41,7 +41,7 @@ Cartographer::Cartographer(World *world)
Logger::getInstance().add("Cartographer", true);
cellMap = world->getMap();
int w = cellMap->getW(), h = cellMap->getH();
//int w = cellMap->getW(), h = cellMap->getH();
routePlanner = world->getRoutePlanner();
masterMap = new AnnotatedMap(world);

View File

@ -80,7 +80,7 @@ ClusterMap::~ClusterMap() {
#define LOG(x) {}
void ClusterMap::assertValid() {
bool valid[fieldCount];
//bool valid[fieldCount];
bool inUse[fieldCount];
int numNodes[fieldCount];
int numEdges[fieldCount];
@ -94,7 +94,7 @@ void ClusterMap::assertValid() {
TKMap tkMap;
valid[f] = true;
//valid[f] = true;
numNodes[f] = 0;
numEdges[f] = 0;
inUse[f] = aMap->maxClearance[f] != 0;
@ -111,13 +111,13 @@ void ClusterMap::assertValid() {
const Transition *t = b->transitions[f].transitions[j];
if (tSet.find(t) != tSet.end()) {
LOG("single transition on multiple borders.\n");
valid[f] = false;
//valid[f] = false;
} else {
tSet.insert(t);
TKey key(t->nwPos, t->vertical);
if (tkMap.find(key) != tkMap.end()) {
LOG("seperate transitions of same orientation on same cell.\n");
valid[f] = false;
//valid[f] = false;
} else {
tkMap[key] = t;
}
@ -131,13 +131,13 @@ void ClusterMap::assertValid() {
const Transition *t = b->transitions[f].transitions[j];
if (tSet.find(t) != tSet.end()) {
LOG("single transition on multiple borders.\n");
valid[f] = false;
//valid[f] = false;
} else {
tSet.insert(t);
TKey key(t->nwPos, t->vertical);
if (tkMap.find(key) != tkMap.end()) {
LOG("seperate transitions of same orientation on same cell.\n");
valid[f] = false;
//valid[f] = false;
} else {
tkMap[key] = t;
}
@ -153,11 +153,11 @@ void ClusterMap::assertValid() {
TSet::iterator it2 = tSet.find((*eit)->transition());
if (it2 == tSet.end()) {
LOG("Invalid edge.\n");
valid[f] = false;
//valid[f] = false;
} else {
if (*it == *it2) {
LOG("self referential transition.\n");
valid[f] = false;
//valid[f] = false;
}
}
++numEdges[f];
@ -507,7 +507,7 @@ void ClusterMap::update() {
/** compute intra-cluster path lengths */
void ClusterMap::evalCluster(const Vec2i &cluster) {
//_PROFILE_FUNCTION();
int linePathSuccess = 0, linePathFail = 0;
//int linePathSuccess = 0, linePathFail = 0;
SearchEngine<NodePool> *se = carto->getRoutePlanner()->getSearchEngine();
se->getNeighbourFunc().setSearchCluster(cluster);
Transitions transitions;

View File

@ -109,15 +109,17 @@ public:
}
//only for infuence_map_test.cpp:249
PatchMap<bits> &operator=(const PatchMap<bits> &op){
//FIXME: better when moved to InfluenceMap::operator=...
this->def = op.def;
this->x = op.x; this->y = op.y; this->w = op.w; this->h = op.h;
//
if(&op != this) {
//FIXME: better when moved to InfluenceMap::operator=...
this->def = op.def;
this->x = op.x; this->y = op.y; this->w = op.w; this->h = op.h;
//
sectionsPerRow = op.sectionsPerRow;
delete[] data;
data = new uint32[op.h * sectionsPerRow];
memcpy(data, op.data, op.h * sectionsPerRow);
sectionsPerRow = op.sectionsPerRow;
delete[] data;
data = new uint32[op.h * sectionsPerRow];
memcpy(data, op.data, op.h * sectionsPerRow);
}
return *this;
}
~PatchMap() { delete [] data; }

View File

@ -107,6 +107,9 @@ RoutePlanner::RoutePlanner(World *world)
, nodeStore(NULL)
, tSearchEngine(NULL)
, tNodeStore(NULL) {
#ifdef _GAE_DEBUG_EDITION_
debug_texture_action=SHOW_PATH_ONLY;
#endif
const int &w = world->getMap()->getW();
const int &h = world->getMap()->getH();
@ -420,7 +423,7 @@ HAAStarResult RoutePlanner::findWaypointPathUnExplored(Unit *unit, const Vec2i &
if (res == hsrFailed) {
return hsrFailed;
}
bool startTrap = res == hsrStartTrap;
//bool startTrap = res == hsrStartTrap;
UnexploredGoal goal(world->getMap(), unit->getTeam());
UnexploredCost cost(unit->getCurrField(), unit->getType()->getSize(), unit->getTeam(), world->getMap());
TransitionHeuristic heuristic(dest);
@ -848,7 +851,7 @@ TravelState RoutePlanner::customGoalSearch(PMap1Goal &goal, Unit *unit, const Ve
}
UnitPath &path = *advPath;
WaypointPath &wpPath = *unit->getWaypointPath();
//WaypointPath &wpPath = *unit->getWaypointPath();
const Vec2i &start = unit->getPos();
// setup search

View File

@ -377,7 +377,7 @@ void DebugRenderer::renderArrow(
const float arrowEndSize = 0.5f;
Vec3f dir = Vec3f(_pos2 - pos1);
float len = dir.length();
//float len = dir.length();
float alphaFactor = 0.3f;
dir.normalize();

View File

@ -2909,7 +2909,7 @@ void Renderer::MapRenderer::render(const Map* map,float coordStep,VisibleQuadCon
}
void Renderer::MapRenderer::destroy() {
while(layers.size()) {
while(layers.empty() == false) {
delete layers.back();
layers.pop_back();
}
@ -5370,7 +5370,7 @@ void Renderer::renderUnitsFast(bool renderingShadows) {
//render objects for selection purposes
void Renderer::renderObjectsFast(bool renderingShadows, bool resourceOnly) {
const World *world= game->getWorld();
//const World *world= game->getWorld();
//const Map *map= world->getMap();
assertGl();
@ -6077,7 +6077,7 @@ void Renderer::renderUnitTitles3D(Font3D *font, Vec3f color) {
const Unit *unit = visibleFrameUnitList[idx];
if(unit != NULL) {
if(unit->getVisible() == true) {
if(unit != NULL && unit->getCurrentUnitTitle() != "") {
if(unit->getCurrentUnitTitle() != "") {
//get the screen coordinates
Vec3f screenPos = unit->getScreenPos();
#ifdef USE_STREFLOP

View File

@ -128,17 +128,17 @@ void BattleEnd::render() {
renderer.reset2d();
renderer.renderBackground(CoreData::getInstance().getBackgroundTexture());
int winnerIndex = -1;
//int winnerIndex = -1;
int bestScore = -1;
int mostKillsIndex = -1;
//int mostKillsIndex = -1;
int bestKills = -1;
int mostEnemyKillsIndex = -1;
//int mostEnemyKillsIndex = -1;
int bestEnemyKills = -1;
int leastDeathsIndex = -1;
//int leastDeathsIndex = -1;
int leastDeaths = -1;
int mostUnitsProducedIndex = -1;
//int mostUnitsProducedIndex = -1;
int bestUnitsProduced = -1;
int mostResourcesHarvestedIndex = -1;
//int mostResourcesHarvestedIndex = -1;
int bestResourcesHarvested = -1;
for(int i=0; i<stats.getFactionCount(); ++i) {
@ -150,38 +150,38 @@ void BattleEnd::render() {
int kills= stats.getKills(i);
if(kills > bestKills) {
bestKills = kills;
mostKillsIndex = i;
//mostKillsIndex = i;
}
int enemykills= stats.getEnemyKills(i);
if(enemykills > bestEnemyKills) {
bestEnemyKills = enemykills;
mostEnemyKillsIndex = i;
//mostEnemyKillsIndex = i;
}
int deaths= stats.getDeaths(i);
if(deaths < leastDeaths || leastDeaths < 0) {
leastDeaths = deaths;
leastDeathsIndex = i;
//leastDeathsIndex = i;
}
int unitsProduced= stats.getUnitsProduced(i);
if(unitsProduced > bestUnitsProduced) {
bestUnitsProduced = unitsProduced;
mostUnitsProducedIndex = i;
//mostUnitsProducedIndex = i;
}
int resourcesHarvested = stats.getResourcesHarvested(i);
if(resourcesHarvested > bestResourcesHarvested) {
bestResourcesHarvested = resourcesHarvested;
mostResourcesHarvestedIndex = i;
//mostResourcesHarvestedIndex = i;
}
int score= enemykills*100 + unitsProduced*50 + resourcesHarvested/10;
if(score > bestScore) {
bestScore = score;
winnerIndex = i;
//winnerIndex = i;
}
}

View File

@ -1376,7 +1376,7 @@ void runTechValidationForPath(string techPath, string techName,
Checksum checksum;
set<string> factions;
for(int j = 0; j < factionsList.size(); ++j) {
if( filteredFactionList.size() == 0 ||
if( filteredFactionList.empty() == true ||
std::find(filteredFactionList.begin(),filteredFactionList.end(),factionsList[j]) != filteredFactionList.end()) {
factions.insert(factionsList[j]);
}
@ -1385,7 +1385,7 @@ void runTechValidationForPath(string techPath, string techName,
printf("\n----------------------------------------------------------------");
printf("\nChecking techPath [%s] techName [%s] total faction count = %d\n",techPath.c_str(), techName.c_str(),(int)factionsList.size());
for(int j = 0; j < factionsList.size(); ++j) {
if( filteredFactionList.size() == 0 ||
if( filteredFactionList.empty() == true ||
std::find(filteredFactionList.begin(),filteredFactionList.end(),factionsList[j]) != filteredFactionList.end()) {
printf("Using faction [%s]\n",factionsList[j].c_str());
}
@ -1989,7 +1989,7 @@ void runTechValidationReport(int argc, char** argv) {
for(int idx2 = 0; idx2 < techTreeFiles.size(); idx2++) {
string &techName = techTreeFiles[idx2];
if( filteredTechTreeList.size() == 0 ||
if( filteredTechTreeList.empty() == true ||
std::find(filteredTechTreeList.begin(),filteredTechTreeList.end(),techName) != filteredTechTreeList.end()) {
runTechValidationForPath(techPath, techName, filteredFactionList,

View File

@ -2005,7 +2005,7 @@ bool MenuStateConnectedGame::loadFactions(const GameSettings *gameSettings, bool
}
}
if(results.size() == 0) {
if(results.empty() == true) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
NetworkManager &networkManager= NetworkManager::getInstance();

View File

@ -1523,7 +1523,7 @@ void MenuStateCustomGame::update() {
ServerInterface* serverInterface= NetworkManager::getInstance().getServerInterface();
Lang& lang= Lang::getInstance();
bool haveAtLeastOneNetworkClientConnected = false;
//bool haveAtLeastOneNetworkClientConnected = false;
bool hasOneNetworkSlotOpen = false;
int currentConnectionCount=0;
Config &config = Config::getInstance();
@ -1696,7 +1696,7 @@ void MenuStateCustomGame::update() {
//printf("FYI we have at least 1 client connected, slot = %d'\n",i);
haveAtLeastOneNetworkClientConnected = true;
//haveAtLeastOneNetworkClientConnected = true;
if(serverInterface->getSlot(i) != NULL &&
serverInterface->getSlot(i)->getConnectHasHandshaked()) {
currentConnectionCount++;
@ -2023,7 +2023,7 @@ void MenuStateCustomGame::simpleTask(BaseThread *callingThread) {
//printf("-=-=-=-=- IN MenuStateCustomGame simpleTask - B\n");
MutexSafeWrapper safeMutex(callingThread->getMutexThreadObjectAccessor(),string(__FILE__) + "_" + intToStr(__LINE__));
bool republish = (needToRepublishToMasterserver == true && publishToServerInfo.size() != 0);
bool republish = (needToRepublishToMasterserver == true && publishToServerInfo.empty() == false);
needToRepublishToMasterserver = false;
std::map<string,string> newPublishToServerInfo = publishToServerInfo;
publishToServerInfo.clear();
@ -2336,11 +2336,10 @@ void MenuStateCustomGame::loadGameSettings(GameSettings *gameSettings) {
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) {
//factionCRC = getFolderTreeContentsCheckSumRecursively(config.getPathListForType(ptTechs,""), "/" + gameSettings->getTech() + "/factions/" + factionName + "/*", ".xml", NULL, true);
factionCRC = getFolderTreeContentsCheckSumRecursively(config.getPathListForType(ptTechs,""), "/" + gameSettings->getTech() + "/factions/" + factionName + "/*", ".xml", NULL);
int32 factionCRC = getFolderTreeContentsCheckSumRecursively(config.getPathListForType(ptTechs,""), "/" + gameSettings->getTech() + "/factions/" + factionName + "/*", ".xml", NULL);
if(factionCRC == 0) {
factionCRC = getFolderTreeContentsCheckSumRecursively(config.getPathListForType(ptTechs,""), "/" + gameSettings->getTech() + "/factions/" + factionName + "/*", ".xml", NULL, true);
}

View File

@ -1780,7 +1780,7 @@ void ServerInterface::simpleTask(BaseThread *callingThread) {
CURL *handle = SystemFlags::initHTTP();
for(std::map<string,string>::const_iterator iterMap = newPublishToServerInfo.begin();
iterMap != newPublishToServerInfo.end(); iterMap++) {
iterMap != newPublishToServerInfo.end(); ++iterMap) {
request += iterMap->first;
request += "=";

View File

@ -2147,7 +2147,7 @@ string Unit::getDescExtension() const{
str+= "\n" + lang.get("OrdersOnQueue") + ": ";
}
str+= "\n#" + intToStr(i + 1) + " " + ct->getName();
it++;
++it;
}
}

View File

@ -52,7 +52,7 @@ bool AttackBoost::isAffected(const Unit *source, const Unit *dest) const {
bool destUnitMightApply = false;
// All units are affected (including enemies)
if(targetType == abtAll) {
destUnitMightApply = (boostUnitList.size() == 0);
destUnitMightApply = (boostUnitList.empty() == true);
// Specify which units are affected
for(unsigned int i = 0; i < boostUnitList.size(); ++i) {
@ -66,10 +66,10 @@ bool AttackBoost::isAffected(const Unit *source, const Unit *dest) const {
}
// Only same faction units are affected
else if(targetType == abtFaction) {
//if(boostUnitList.size() == 0) {
//if(boostUnitList.empty() == true) {
if(source->getFactionIndex() == dest->getFactionIndex()) {
//destUnitMightApply = true;
destUnitMightApply = (boostUnitList.size() == 0);
destUnitMightApply = (boostUnitList.empty() == true);
// Specify which units are affected
for(unsigned int i = 0; i < boostUnitList.size(); ++i) {
@ -85,10 +85,10 @@ bool AttackBoost::isAffected(const Unit *source, const Unit *dest) const {
}
// Only ally units are affected
else if(targetType == abtAlly) {
//if(boostUnitList.size() == 0) {
//if(boostUnitList.empty() == true) {
if(source->isAlly(dest) == true) {
//destUnitMightApply = true;
destUnitMightApply = (boostUnitList.size() == 0);
destUnitMightApply = (boostUnitList.empty() == true);
// Specify which units are affected
for(unsigned int i = 0; i < boostUnitList.size(); ++i) {
@ -103,10 +103,10 @@ bool AttackBoost::isAffected(const Unit *source, const Unit *dest) const {
}
// Only foe units are affected
else if(targetType == abtFoe) {
//if(boostUnitList.size() == 0) {
//if(boostUnitList.empty() == true) {
if(source->isAlly(dest) == false) {
//destUnitMightApply = true;
destUnitMightApply = (boostUnitList.size() == 0);
destUnitMightApply = (boostUnitList.empty() == true);
// Specify which units are affected
for(unsigned int i = 0; i < boostUnitList.size(); ++i) {
@ -209,7 +209,7 @@ void SkillType::load(const XmlNode *sn, const string &dir, const TechTree *tt,
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line %d] WARNING CANNOT LOAD MODEL [%s] for parentLoader [%s]\n",__FILE__,__FUNCTION__,__LINE__,path.c_str(),parentLoader.c_str());
}
}
if(animations.size() <= 0) {
if(animations.empty() == true) {
char szBuf[4096]="";
sprintf(szBuf,"Error no animations found for skill [%s] for parentLoader [%s]",name.c_str(),parentLoader.c_str());
throw runtime_error(szBuf);

View File

@ -208,12 +208,12 @@ std::vector<std::string> TechTree::validateFactionTypes() {
std::vector<std::string> results;
for (int i = 0; i < factionTypes.size(); ++i) {
std::vector<std::string> factionResults = factionTypes[i].validateFactionType();
if(factionResults.size() > 0) {
if(factionResults.empty() == false) {
results.insert(results.end(), factionResults.begin(), factionResults.end());
}
factionResults = factionTypes[i].validateFactionTypeUpgradeTypes();
if(factionResults.size() > 0) {
if(factionResults.empty() == false) {
results.insert(results.end(), factionResults.begin(), factionResults.end());
}
}
@ -228,7 +228,7 @@ std::vector<std::string> TechTree::validateResourceTypes() {
//printf("Validating [%d / %d] faction [%s]\n",i,(int)factionTypes.size(),factionTypes[i].getName().c_str());
std::vector<std::string> factionResults = factionTypes[i].validateFactionTypeResourceTypes(resourceTypes);
if(factionResults.size() > 0) {
if(factionResults.empty() == false) {
results.insert(results.end(), factionResults.begin(), factionResults.end());
}
@ -245,7 +245,7 @@ std::vector<std::string> TechTree::validateResourceTypes() {
}
}
if(resourceTypesNotUsed.size() > 0) {
if(resourceTypesNotUsed.empty() == false) {
//printf("FOUND unused resource Types [%d]\n",(int)resourceTypesNotUsed.size());
for (unsigned int i = 0; i < resourceTypesNotUsed.size(); ++i) {

View File

@ -1280,7 +1280,7 @@ void World::initFactionTypes(GameSettings *gs) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
if(factions.size() > 0) {
if(factions.empty() == false) {
thisTeamIndex= getFaction(thisFactionIndex)->getTeam();
}
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);

View File

@ -81,6 +81,22 @@ MainWindow::MainWindow(string appPath)
, glCanvas(NULL)
, program(NULL), boxsizer(NULL), startupSettingsInited(false) {
menuFile=NULL;
menuEdit=NULL;
menuEditMirror=NULL;
menuView=NULL;
menuBrush=NULL;
menuBrushHeight=NULL;
menuBrushGradient=NULL;
menuBrushSurface=NULL;
menuBrushObject=NULL;
menuBrushResource=NULL;
menuBrushStartLocation=NULL;
menuRadius=NULL;
fileDialog=NULL;
resourceUnderMouse=0;
objectUnderMouse=0;
this->appPath = appPath;
Properties::setApplicationPath(executable_path(appPath));
@ -523,12 +539,11 @@ void MainWindow::onMouseMove(wxMouseEvent &event, int x, int y) {
return;
}
bool repaint = false;
int dif;
if (event.LeftIsDown()) {
change(x, y);
repaint = true;
} else if (event.MiddleIsDown()) {
dif = (y - lastY);
int dif = (y - lastY);
if (dif != 0) {
program->incCellSize(dif / abs(dif));
repaint = true;