From f1cd4656ff1c25e1aaa6e7ce7ea3e2ad33a917ff Mon Sep 17 00:00:00 2001 From: AlexVinS Date: Tue, 8 Jan 2019 00:40:09 +0300 Subject: [PATCH] Fixed warnings. --- AI/VCAI/Goals/Explore.cpp | 15 +++++++-------- AI/VCAI/Goals/GatherArmy.cpp | 3 --- AI/VCAI/Pathfinding/AINodeStorage.cpp | 5 ++--- AI/VCAI/Pathfinding/AIPathfinderConfig.cpp | 10 +++++----- AI/VCAI/ResourceManager.cpp | 17 ++++++++++------- 5 files changed, 24 insertions(+), 26 deletions(-) diff --git a/AI/VCAI/Goals/Explore.cpp b/AI/VCAI/Goals/Explore.cpp index 385cc797a..9921fa211 100644 --- a/AI/VCAI/Goals/Explore.cpp +++ b/AI/VCAI/Goals/Explore.cpp @@ -122,7 +122,6 @@ TGoalVec Explore::getAllPossibleSubgoals() } } - auto primaryHero = ai->primaryHero().h; for(auto h : heroes) { for(auto obj : objs) //double loop, performance risk? @@ -199,9 +198,9 @@ bool Explore::hasReachableNeighbor(const int3 &pos, HeroPtr hero, CCallback * cb } int Explore::howManyTilesWillBeDiscovered( - const int3 & pos, - int radious, - CCallback * cbp, + const int3 & pos, + int radious, + CCallback * cbp, const TeamState * ts, VCAI * aip, HeroPtr h) const @@ -212,8 +211,8 @@ int Explore::howManyTilesWillBeDiscovered( for(int y = pos.y - radious; y <= pos.y + radious; y++) { int3 npos = int3(x, y, pos.z); - if(cbp->isInTheMap(npos) - && pos.dist2d(npos) - 0.5 < radious + if(cbp->isInTheMap(npos) + && pos.dist2d(npos) - 0.5 < radious && !ts->fogOfWarMap[npos.x][npos.y][npos.z] && hasReachableNeighbor(npos, h, cbp, aip)) { @@ -277,7 +276,7 @@ TSubgoal Explore::explorationNewPoint(HeroPtr h) const int3 mapSize = cbp->getMapSize(); int perimiter = 2 * radius * (mapSize.x + mapSize.y); - + std::vector from; std::vector to; @@ -420,4 +419,4 @@ void Explore::getVisibleNeighbours(const std::vector & tiles, std::vector< } }); } -} \ No newline at end of file +} diff --git a/AI/VCAI/Goals/GatherArmy.cpp b/AI/VCAI/Goals/GatherArmy.cpp index cc18540a8..6764aea09 100644 --- a/AI/VCAI/Goals/GatherArmy.cpp +++ b/AI/VCAI/Goals/GatherArmy.cpp @@ -44,9 +44,6 @@ 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/Pathfinding/AINodeStorage.cpp b/AI/VCAI/Pathfinding/AINodeStorage.cpp index 9e50af94a..a8d4cf191 100644 --- a/AI/VCAI/Pathfinding/AINodeStorage.cpp +++ b/AI/VCAI/Pathfinding/AINodeStorage.cpp @@ -63,7 +63,7 @@ boost::optional AINodeStorage::getOrCreateNode(const int3 & pos, c CGPathNode * AINodeStorage::getInitialNode() { auto hpos = hero->getPosition(false); - auto initialNode = + auto initialNode = getOrCreateNode(hpos, hero->boat ? EPathfindingLayer::SAIL : EPathfindingLayer::LAND, NORMAL_CHAIN) .get(); @@ -99,7 +99,7 @@ void AINodeStorage::commit(CDestinationNodeInfo & destination, const PathNodeInf dstNode->action = destination.action; dstNode->theNodeBefore = srcNode->theNodeBefore; dstNode->manaCost = srcNode->manaCost; - + if(dstNode->specialAction) { dstNode->specialAction->applyOnDestination(getHero(), destination, source, dstNode, srcNode); @@ -193,7 +193,6 @@ bool AINodeStorage::isTileAccessible(int3 pos, const EPathfindingLayer layer) co { std::vector paths; auto chains = nodes[pos.x][pos.y][pos.z][layer]; - auto initialPos = hero->visitablePos(); for(const AIPathNode & node : chains) { diff --git a/AI/VCAI/Pathfinding/AIPathfinderConfig.cpp b/AI/VCAI/Pathfinding/AIPathfinderConfig.cpp index 74939519c..932613d87 100644 --- a/AI/VCAI/Pathfinding/AIPathfinderConfig.cpp +++ b/AI/VCAI/Pathfinding/AIPathfinderConfig.cpp @@ -77,9 +77,9 @@ namespace AIPathfinding bool isAffordableBy(HeroPtr hero, const AIPathNode * source) const { logAi->trace( - "Hero %s has %d mana and needed %d and already spent %d", - hero->name, - hero->mana, + "Hero %s has %d mana and needed %d and already spent %d", + hero->name, + hero->mana, getManaCost(hero), source->manaCost); @@ -215,7 +215,7 @@ namespace AIPathfinding } bool tryEmbarkVirtualBoat( - CDestinationNodeInfo &destination, + CDestinationNodeInfo &destination, const PathNodeInfo &source, std::shared_ptr virtualBoat) const { @@ -232,7 +232,7 @@ namespace AIPathfinding { AIPathNode * boatNode = boatNodeOptional.get(); - if(boatNode->action == CGPathNode::NOT_SET) + if(boatNode->action == CGPathNode::UNKNOWN) { boatNode->specialAction = virtualBoat; destination.blocked = false; diff --git a/AI/VCAI/ResourceManager.cpp b/AI/VCAI/ResourceManager.cpp index e466805da..027b9e9c2 100644 --- a/AI/VCAI/ResourceManager.cpp +++ b/AI/VCAI/ResourceManager.cpp @@ -131,7 +131,7 @@ Goals::TSubgoal ResourceManager::collectResourcesForOurGoal(ResourceObjective &o break; } } - if (resourceType == Res::INVALID) //no needed resources has 0 income, + if (resourceType == Res::INVALID) //no needed resources has 0 income, { //find the one which takes longest to collect typedef std::pair timePair; @@ -160,7 +160,7 @@ Goals::TSubgoal ResourceManager::whatToDo() const //suggest any goal if (queue.size()) { auto o = queue.top(); - + auto allResources = cb->getResourceAmount(); //we don't consider savings, it's out top-priority goal if (allResources.canAfford(o.resources)) return o.goal; @@ -186,9 +186,9 @@ Goals::TSubgoal ResourceManager::whatToDo(TResources &res, Goals::TSubgoal goal) accumulatedResources += it->resources; logAi->trace( - "ResourceManager: checking goal %s, accumulatedResources=%s, available=%s", - it->goal->name(), - accumulatedResources.toString(), + "ResourceManager: checking goal %s, accumulatedResources=%s, available=%s", + it->goal->name(), + accumulatedResources.toString(), allResources.toString()); if(!accumulatedResources.canBeAfforded(allResources)) @@ -312,16 +312,19 @@ bool ResourceManager::removeOutdatedObjectives(std::function bool { - predicate(ro.goal); + return predicate(ro.goal); }); + if(it != queue.end()) //removed at least one { logAi->debug("Removing goal %s from ResourceManager.", it->goal->name()); queue.erase(queue.s_handle_from_iterator(it)); removedAnything = true; } - else //found nothing more to remove + else + { //found nothing more to remove break; + } } return removedAnything; }