From faa7cbff187118579f2856d5c42325d7ed1c4e9b Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Fri, 4 Dec 2015 01:06:02 +0200 Subject: [PATCH] Fixed gcc/clang warnings --- AI/VCAI/AIUtility.cpp | 4 ++-- AI/VCAI/Goals.cpp | 4 ++++ AI/VCAI/VCAI.cpp | 16 +++++++++++++++- AI/VCAI/VCAI.h | 14 -------------- launcher/modManager/cmodlistmodel_moc.h | 2 +- lib/CModHandler.cpp | 2 +- lib/int3.h | 11 +++++++---- lib/mapping/CCampaignHandler.cpp | 4 ++-- lib/mapping/CMapService.cpp | 8 ++++---- lib/rmg/CMapGenerator.cpp | 2 +- lib/rmg/CRmgTemplateZone.cpp | 3 ++- lib/spells/CSpellHandler.cpp | 2 +- server/CGameHandler.cpp | 2 +- 13 files changed, 41 insertions(+), 33 deletions(-) diff --git a/AI/VCAI/AIUtility.cpp b/AI/VCAI/AIUtility.cpp index 049d1d9c5..7cc22fe38 100644 --- a/AI/VCAI/AIUtility.cpp +++ b/AI/VCAI/AIUtility.cpp @@ -154,7 +154,7 @@ void foreach_neighbour(const int3 &pos, std::function foo { CCallback * cbp = cb.get(); // avoid costly retrieval of thread-specific pointer - for(const int3 &dir : dirs) + for(const int3 &dir : int3::getDirs()) { const int3 n = pos + dir; if(cbp->isInTheMap(n)) @@ -164,7 +164,7 @@ void foreach_neighbour(const int3 &pos, std::function foo void foreach_neighbour(CCallback * cbp, const int3 &pos, std::function foo) { - for(const int3 &dir : dirs) + for(const int3 &dir : int3::getDirs()) { const int3 n = pos + dir; if(cbp->isInTheMap(n)) diff --git a/AI/VCAI/Goals.cpp b/AI/VCAI/Goals.cpp index 9d4597940..40406f214 100644 --- a/AI/VCAI/Goals.cpp +++ b/AI/VCAI/Goals.cpp @@ -1028,6 +1028,10 @@ TSubgoal GatherArmy::whatToDoToAchieve() return fh->chooseSolution (getAllPossibleSubgoals()); //find dwelling. use current hero to prevent him from doing nothing. } + +static const BuildingID unitsSource[] = { BuildingID::DWELL_LVL_1, BuildingID::DWELL_LVL_2, BuildingID::DWELL_LVL_3, + BuildingID::DWELL_LVL_4, BuildingID::DWELL_LVL_5, BuildingID::DWELL_LVL_6, BuildingID::DWELL_LVL_7}; + TGoalVec GatherArmy::getAllPossibleSubgoals() { //get all possible towns, heroes and dwellings we may use diff --git a/AI/VCAI/VCAI.cpp b/AI/VCAI/VCAI.cpp index d1ae4c3ec..d45a3e3c2 100644 --- a/AI/VCAI/VCAI.cpp +++ b/AI/VCAI/VCAI.cpp @@ -1303,6 +1303,20 @@ bool VCAI::tryBuildNextStructure(const CGTownInstance * t, std::vectorconvertPosition(h->pos, false); std::map dstToRevealedTiles; - for(crint3 dir : dirs) + for(crint3 dir : int3::getDirs()) if(cb->isInTheMap(hpos+dir)) if (ourPos != dir) //don't stand in place if (isSafeToVisit(h, hpos + dir) && isAccessibleForHero (hpos + dir, h)) diff --git a/AI/VCAI/VCAI.h b/AI/VCAI/VCAI.h index 4da33bc71..bb3e5b7d5 100644 --- a/AI/VCAI/VCAI.h +++ b/AI/VCAI/VCAI.h @@ -113,20 +113,6 @@ struct SectorMap int3 findFirstVisitableTile(HeroPtr h, crint3 dst); }; -//Set of buildings for different goals. Does not include any prerequisites. -const BuildingID essential[] = {BuildingID::TAVERN, BuildingID::TOWN_HALL}; -const BuildingID goldSource[] = {BuildingID::TOWN_HALL, BuildingID::CITY_HALL, BuildingID::CAPITOL}; -const BuildingID unitsSource[] = { BuildingID::DWELL_LVL_1, BuildingID::DWELL_LVL_2, BuildingID::DWELL_LVL_3, - BuildingID::DWELL_LVL_4, BuildingID::DWELL_LVL_5, BuildingID::DWELL_LVL_6, BuildingID::DWELL_LVL_7}; -const BuildingID unitsUpgrade[] = { BuildingID::DWELL_LVL_1_UP, BuildingID::DWELL_LVL_2_UP, BuildingID::DWELL_LVL_3_UP, - BuildingID::DWELL_LVL_4_UP, BuildingID::DWELL_LVL_5_UP, BuildingID::DWELL_LVL_6_UP, BuildingID::DWELL_LVL_7_UP}; -const BuildingID unitGrowth[] = { BuildingID::FORT, BuildingID::CITADEL, BuildingID::CASTLE, BuildingID::HORDE_1, - BuildingID::HORDE_1_UPGR, BuildingID::HORDE_2, BuildingID::HORDE_2_UPGR}; -const BuildingID spells[] = {BuildingID::MAGES_GUILD_1, BuildingID::MAGES_GUILD_2, BuildingID::MAGES_GUILD_3, - BuildingID::MAGES_GUILD_4, BuildingID::MAGES_GUILD_5}; -const BuildingID extra[] = {BuildingID::RESOURCE_SILO, BuildingID::SPECIAL_1, BuildingID::SPECIAL_2, BuildingID::SPECIAL_3, - BuildingID::SPECIAL_4, BuildingID::SHIPYARD}; // all remaining buildings - class VCAI : public CAdventureAI { public: diff --git a/launcher/modManager/cmodlistmodel_moc.h b/launcher/modManager/cmodlistmodel_moc.h index 72430db69..dce474ded 100644 --- a/launcher/modManager/cmodlistmodel_moc.h +++ b/launcher/modManager/cmodlistmodel_moc.h @@ -52,7 +52,7 @@ public: /// CModListContainer overrides void resetRepositories() override; void addRepository(QVariantMap data) override; - void modChanged(QString modID); + void modChanged(QString modID) override; QVariant data(const QModelIndex &index, int role) const override; QVariant headerData(int section, Qt::Orientation orientation, int role) const override; diff --git a/lib/CModHandler.cpp b/lib/CModHandler.cpp index 31a953292..571d5c10b 100644 --- a/lib/CModHandler.cpp +++ b/lib/CModHandler.cpp @@ -467,7 +467,7 @@ static JsonNode loadModSettings(std::string path) JsonNode addMeta(JsonNode config, std::string meta) { config.setMeta(meta); - return std::move(config); + return config; } CModInfo::CModInfo(std::string identifier,const JsonNode & local, const JsonNode & config): diff --git a/lib/int3.h b/lib/int3.h index 7ac595183..2631b4929 100644 --- a/lib/int3.h +++ b/lib/int3.h @@ -131,6 +131,12 @@ public: { h & x & y & z; } + + static std::array getDirs() + { + return { { int3(0,1,0),int3(0,-1,0),int3(-1,0,0),int3(+1,0,0), + int3(1,1,0),int3(-1,1,0),int3(1,-1,0),int3(-1,-1,0) } }; + } }; inline std::ostream & operator<<(std::ostream & str, const int3 & sth) @@ -154,9 +160,6 @@ struct ShashInt3 } }; -static const int3 dirs[] = { int3(0,1,0),int3(0,-1,0),int3(-1,0,0),int3(+1,0,0), - int3(1,1,0),int3(-1,1,0),int3(1,-1,0),int3(-1,-1,0) }; - template int3 findClosestTile (Container & container, int3 dest) { @@ -175,4 +178,4 @@ int3 findClosestTile (Container & container, int3 dest) } } return result; -} \ No newline at end of file +} diff --git a/lib/mapping/CCampaignHandler.cpp b/lib/mapping/CCampaignHandler.cpp index 9935ed153..93f40e524 100644 --- a/lib/mapping/CCampaignHandler.cpp +++ b/lib/mapping/CCampaignHandler.cpp @@ -292,7 +292,7 @@ CScenarioTravel CCampaignHandler::readScenarioTravelFromMemory(CBinaryReader & r std::vector< std::vector > CCampaignHandler::getFile(const std::string & name, bool headerOnly) { - CCompressedStream stream(std::move(CResourceHandler::get()->load(ResourceID(name, EResType::CAMPAIGN))), true); + CCompressedStream stream(CResourceHandler::get()->load(ResourceID(name, EResType::CAMPAIGN)), true); std::vector< std::vector > ret; do @@ -363,7 +363,7 @@ std::vector CCampaignScenario::getLostCrossoverHeroes() const } } } - return std::move(lostCrossoverHeroes); + return lostCrossoverHeroes; } bool CScenarioTravel::STravelBonus::isBonusForHero() const diff --git a/lib/mapping/CMapService.cpp b/lib/mapping/CMapService.cpp index 4810ac492..fc4efb2e3 100644 --- a/lib/mapping/CMapService.cpp +++ b/lib/mapping/CMapService.cpp @@ -20,7 +20,7 @@ std::unique_ptr CMapService::loadMap(const std::string & name) getMapPatcher(name)->patchMapHeader(header); header.release(); - return std::move(map); + return map; } std::unique_ptr CMapService::loadMapHeader(const std::string & name) @@ -28,7 +28,7 @@ std::unique_ptr CMapService::loadMapHeader(const std::string & name) auto stream = getStreamFromFS(name); std::unique_ptr header = getMapLoader(stream)->loadMapHeader(); getMapPatcher(name)->patchMapHeader(header); - return std::move(header); + return header; } std::unique_ptr CMapService::loadMap(const ui8 * buffer, int size, const std::string & name) @@ -40,7 +40,7 @@ std::unique_ptr CMapService::loadMap(const ui8 * buffer, int size, const s getMapPatcher(name)->patchMapHeader(header); header.release(); - return std::move(map); + return map; } std::unique_ptr CMapService::loadMapHeader(const ui8 * buffer, int size, const std::string & name) @@ -48,7 +48,7 @@ std::unique_ptr CMapService::loadMapHeader(const ui8 * buffer, int s auto stream = getStreamFromMem(buffer, size); std::unique_ptr header = getMapLoader(stream)->loadMapHeader(); getMapPatcher(name)->patchMapHeader(header); - return std::move(header); + return header; } std::unique_ptr CMapService::getStreamFromFS(const std::string & name) diff --git a/lib/rmg/CMapGenerator.cpp b/lib/rmg/CMapGenerator.cpp index 48621d32f..0c7f6c963 100644 --- a/lib/rmg/CMapGenerator.cpp +++ b/lib/rmg/CMapGenerator.cpp @@ -17,7 +17,7 @@ static const int3 dirs4[] = {int3(0,1,0),int3(0,-1,0),int3(-1,0,0),int3(+1,0,0)} void CMapGenerator::foreach_neighbour(const int3 &pos, std::function foo) { - for(const int3 &dir : dirs) + for(const int3 &dir : int3::getDirs()) { int3 n = pos + dir; if(map->isInTheMap(n)) diff --git a/lib/rmg/CRmgTemplateZone.cpp b/lib/rmg/CRmgTemplateZone.cpp index 3db773d8b..9da6366be 100644 --- a/lib/rmg/CRmgTemplateZone.cpp +++ b/lib/rmg/CRmgTemplateZone.cpp @@ -2336,7 +2336,8 @@ ObjectInfo CRmgTemplateZone::getRandomObject(CMapGenerator* gen, CTreasurePileIn } assert (0); //we should never be here } - //FIXME: control reaches end of non-void function. Missing return? + + return ObjectInfo(); // unreachable } void CRmgTemplateZone::addAllPossibleObjects(CMapGenerator* gen) diff --git a/lib/spells/CSpellHandler.cpp b/lib/spells/CSpellHandler.cpp index 4b4a220ed..1beaac6e3 100644 --- a/lib/spells/CSpellHandler.cpp +++ b/lib/spells/CSpellHandler.cpp @@ -640,7 +640,7 @@ std::string CSpell::AnimationInfo::selectProjectile(const double angle) const } } - return std::move(res); + return res; } ///CSpell::TargetInfo diff --git a/server/CGameHandler.cpp b/server/CGameHandler.cpp index 9c3b8ba5d..ffedf5af3 100644 --- a/server/CGameHandler.cpp +++ b/server/CGameHandler.cpp @@ -1665,7 +1665,7 @@ std::list CGameHandler::generatePlayerTurnOrder() const if(!player.second.human) playerTurnOrder.push_back(player.first); } - return std::move(playerTurnOrder); + return playerTurnOrder; } void CGameHandler::setupBattle( int3 tile, const CArmedInstance *armies[2], const CGHeroInstance *heroes[2], bool creatureBank, const CGTownInstance *town )