From 7be9aa4868b228bcbc8b3af04b212bc9828356da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Mon, 29 Oct 2018 16:56:14 +0100 Subject: [PATCH] Prevent shadowing of function arguments by local vars --- AI/VCAI/VCAI.cpp | 4 ++-- client/CreatureCostBox.cpp | 6 +++--- client/widgets/AdventureMapClasses.cpp | 6 +++--- launcher/modManager/cmodlistview_moc.cpp | 4 ++-- launcher/modManager/cmodlistview_moc.h | 2 +- lib/CGameInfoCallback.cpp | 4 ++-- lib/filesystem/CZipLoader.cpp | 8 ++++---- lib/filesystem/Filesystem.cpp | 4 ++-- lib/rmg/CRmgTemplateZone.cpp | 10 +++++----- lib/spells/BattleSpellMechanics.cpp | 6 +++--- lib/spells/effects/Catapult.cpp | 2 +- 11 files changed, 28 insertions(+), 28 deletions(-) diff --git a/AI/VCAI/VCAI.cpp b/AI/VCAI/VCAI.cpp index 7a3b30c38..7d54f64fb 100644 --- a/AI/VCAI/VCAI.cpp +++ b/AI/VCAI/VCAI.cpp @@ -2381,8 +2381,8 @@ void VCAI::striveToGoal(Goals::TSubgoal basicGoal) logAi->debug("The error message was: %s", e.what()); //erase base goal if we failed to execute decomposed goal - for (auto basicGoal : ultimateGoalsFromBasic[elementarGoal]) - goalsToRemove.push_back(basicGoal); + for (auto basicGoalToRemove : ultimateGoalsFromBasic[elementarGoal]) + goalsToRemove.push_back(basicGoalToRemove); } } } diff --git a/client/CreatureCostBox.cpp b/client/CreatureCostBox.cpp index 5cc61a9c4..ca1e070f9 100644 --- a/client/CreatureCostBox.cpp +++ b/client/CreatureCostBox.cpp @@ -49,10 +49,10 @@ void CreatureCostBox::createItems(TResources res) { int curx = pos.w / 2 - (16 * resources.size()) - (8 * (resources.size() - 1)); //reverse to display gold as first resource - for(auto & res : boost::adaptors::reverse(resources)) + for(auto & currentRes : boost::adaptors::reverse(resources)) { - res.second.first->moveBy(Point(curx, 22)); - res.second.second->moveBy(Point(curx, 22)); + currentRes.second.first->moveBy(Point(curx, 22)); + currentRes.second.second->moveBy(Point(curx, 22)); curx += 48; } } diff --git a/client/widgets/AdventureMapClasses.cpp b/client/widgets/AdventureMapClasses.cpp index 00a4c558f..cdc763c3e 100644 --- a/client/widgets/AdventureMapClasses.cpp +++ b/client/widgets/AdventureMapClasses.cpp @@ -277,9 +277,9 @@ void CHeroList::update(const CGHeroInstance * hero) listBox->resize(LOCPLINT->wanderingHeroes.size()); if (adventureInt->selection) { - auto hero = dynamic_cast(adventureInt->selection); - if (hero) - select(hero); + auto selectedHero = dynamic_cast(adventureInt->selection); + if (selectedHero) + select(selectedHero); } CList::update(); } diff --git a/launcher/modManager/cmodlistview_moc.cpp b/launcher/modManager/cmodlistview_moc.cpp index c90c94297..c31054cf2 100644 --- a/launcher/modManager/cmodlistview_moc.cpp +++ b/launcher/modManager/cmodlistview_moc.cpp @@ -377,10 +377,10 @@ QStringList CModListView::findInvalidDependencies(QString mod) return ret; } -QStringList CModListView::findBlockingMods(QString mod) +QStringList CModListView::findBlockingMods(QString modUnderTest) { QStringList ret; - auto required = modModel->getRequirements(mod); + auto required = modModel->getRequirements(modUnderTest); for(QString name : modModel->getModList()) { diff --git a/launcher/modManager/cmodlistview_moc.h b/launcher/modManager/cmodlistview_moc.h index f1dbbd30f..dd80ef860 100644 --- a/launcher/modManager/cmodlistview_moc.h +++ b/launcher/modManager/cmodlistview_moc.h @@ -51,7 +51,7 @@ class CModListView : public QWidget // find mods unknown to mod list (not present in repo and not installed) QStringList findInvalidDependencies(QString mod); // find mods that block enabling of this mod: conflicting with this mod or one of required mods - QStringList findBlockingMods(QString mod); + QStringList findBlockingMods(QString modUnderTest); // find mods that depend on this one QStringList findDependentMods(QString mod, bool excludeDisabled); diff --git a/lib/CGameInfoCallback.cpp b/lib/CGameInfoCallback.cpp index d2a46f161..ce763f1b5 100644 --- a/lib/CGameInfoCallback.cpp +++ b/lib/CGameInfoCallback.cpp @@ -556,9 +556,9 @@ EBuildingState::EBuildingState CGameInfoCallback::canBuildStructure( const CGTow const PlayerState *ps = getPlayer(t->tempOwner, false); if(ps) { - for(const CGTownInstance *t : ps->towns) + for(const CGTownInstance *town : ps->towns) { - if(t->hasBuilt(BuildingID::CAPITOL)) + if(town->hasBuilt(BuildingID::CAPITOL)) { return EBuildingState::HAVE_CAPITAL; //no more than one capitol } diff --git a/lib/filesystem/CZipLoader.cpp b/lib/filesystem/CZipLoader.cpp index 02d214850..673eee275 100644 --- a/lib/filesystem/CZipLoader.cpp +++ b/lib/filesystem/CZipLoader.cpp @@ -160,15 +160,15 @@ std::vector ZipArchive::listFiles(boost::filesystem::path filename) do { unz_file_info64 info; - std::vector filename; + std::vector zipFilename; unzGetCurrentFileInfo64 (file, &info, nullptr, 0, nullptr, 0, nullptr, 0); - filename.resize(info.size_filename); + zipFilename.resize(info.size_filename); // Get name of current file. Contrary to docs "info" parameter can't be null - unzGetCurrentFileInfo64 (file, &info, filename.data(), filename.size(), nullptr, 0, nullptr, 0); + unzGetCurrentFileInfo64 (file, &info, zipFilename.data(), zipFilename.size(), nullptr, 0, nullptr, 0); - ret.push_back(std::string(filename.data(), filename.size())); + ret.push_back(std::string(zipFilename.data(), zipFilename.size())); } while (unzGoToNextFile(file) == UNZ_OK); } diff --git a/lib/filesystem/Filesystem.cpp b/lib/filesystem/Filesystem.cpp index 5f4912dab..ac777b42a 100644 --- a/lib/filesystem/Filesystem.cpp +++ b/lib/filesystem/Filesystem.cpp @@ -113,8 +113,8 @@ void CFilesystemGenerator::loadJsonMap(const std::string &mountPoint, const Json if (filename) { auto configData = CResourceHandler::get("initial")->load(ResourceID(URI, EResType::TEXT))->readAll(); - const JsonNode config((char*)configData.first.get(), configData.second); - filesystem->addLoader(new CMappedFileLoader(mountPoint, config), false); + const JsonNode configInitial((char*)configData.first.get(), configData.second); + filesystem->addLoader(new CMappedFileLoader(mountPoint, configInitial), false); } } diff --git a/lib/rmg/CRmgTemplateZone.cpp b/lib/rmg/CRmgTemplateZone.cpp index d86c821ff..1396b9f97 100644 --- a/lib/rmg/CRmgTemplateZone.cpp +++ b/lib/rmg/CRmgTemplateZone.cpp @@ -985,24 +985,24 @@ bool CRmgTemplateZone::createTreasurePile(int3 &pos, float minDistance, const CT //find object closest to free path, then connect it to the middle of the zone int3 closestTile = int3(-1,-1,-1); - float minDistance = 1e10; + float minTreasureDistance = 1e10; for (auto visitablePos : info.visitableFromBottomPositions) //objects that are not visitable from top must be accessible from bottom or side { int3 closestFreeTile = findClosestTile(freePaths, visitablePos); - if (closestFreeTile.dist2d(visitablePos) < minDistance) + if (closestFreeTile.dist2d(visitablePos) < minTreasureDistance) { closestTile = visitablePos + int3 (0, 1, 0); //start below object (y+1), possibly even outside the map, to not make path up through it - minDistance = closestFreeTile.dist2d(visitablePos); + minTreasureDistance = closestFreeTile.dist2d(visitablePos); } } for (auto visitablePos : info.visitableFromTopPositions) //all objects are accessible from any direction { int3 closestFreeTile = findClosestTile(freePaths, visitablePos); - if (closestFreeTile.dist2d(visitablePos) < minDistance) + if (closestFreeTile.dist2d(visitablePos) < minTreasureDistance) { closestTile = visitablePos; - minDistance = closestFreeTile.dist2d(visitablePos); + minTreasureDistance = closestFreeTile.dist2d(visitablePos); } } assert (closestTile.valid()); diff --git a/lib/spells/BattleSpellMechanics.cpp b/lib/spells/BattleSpellMechanics.cpp index 14b8f7b68..7e1678ba0 100644 --- a/lib/spells/BattleSpellMechanics.cpp +++ b/lib/spells/BattleSpellMechanics.cpp @@ -528,13 +528,13 @@ Target BattleSpellMechanics::transformSpellTarget(const Target & aimPoint) const else { const Destination & primary = aimPoint.at(0); - BattleHex aimPoint = primary.hexValue; + BattleHex aimPointHex = primary.hexValue; //transform primary spell target with spell range (if it`s valid), leave anything else to effects - if(aimPoint.isValid()) + if(aimPointHex.isValid()) { - auto spellRange = spellRangeInHexes(aimPoint); + auto spellRange = spellRangeInHexes(aimPointHex); for(auto & hex : spellRange) spellTarget.push_back(Destination(hex)); } diff --git a/lib/spells/effects/Catapult.cpp b/lib/spells/effects/Catapult.cpp index 65b1078da..5db9efe3d 100644 --- a/lib/spells/effects/Catapult.cpp +++ b/lib/spells/effects/Catapult.cpp @@ -66,7 +66,7 @@ bool Catapult::applicable(Problem & problem, const Mechanics * m) const return true; } -void Catapult::apply(BattleStateProxy * battleState, RNG & rng, const Mechanics * m, const EffectTarget & target) const +void Catapult::apply(BattleStateProxy * battleState, RNG & rng, const Mechanics * m, const EffectTarget & /* eTarget */) const { //start with all destructible parts static const std::set possibleTargets =