1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-03-21 21:17:49 +02:00

Fixed warnings.

This commit is contained in:
AlexVinS 2019-01-08 00:40:09 +03:00
parent 9ec3d2ef64
commit f1cd4656ff
5 changed files with 24 additions and 26 deletions

View File

@ -122,7 +122,6 @@ TGoalVec Explore::getAllPossibleSubgoals()
} }
} }
auto primaryHero = ai->primaryHero().h;
for(auto h : heroes) for(auto h : heroes)
{ {
for(auto obj : objs) //double loop, performance risk? 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( int Explore::howManyTilesWillBeDiscovered(
const int3 & pos, const int3 & pos,
int radious, int radious,
CCallback * cbp, CCallback * cbp,
const TeamState * ts, const TeamState * ts,
VCAI * aip, VCAI * aip,
HeroPtr h) const HeroPtr h) const
@ -212,8 +211,8 @@ int Explore::howManyTilesWillBeDiscovered(
for(int y = pos.y - radious; y <= pos.y + radious; y++) for(int y = pos.y - radious; y <= pos.y + radious; y++)
{ {
int3 npos = int3(x, y, pos.z); int3 npos = int3(x, y, pos.z);
if(cbp->isInTheMap(npos) if(cbp->isInTheMap(npos)
&& pos.dist2d(npos) - 0.5 < radious && pos.dist2d(npos) - 0.5 < radious
&& !ts->fogOfWarMap[npos.x][npos.y][npos.z] && !ts->fogOfWarMap[npos.x][npos.y][npos.z]
&& hasReachableNeighbor(npos, h, cbp, aip)) && hasReachableNeighbor(npos, h, cbp, aip))
{ {
@ -277,7 +276,7 @@ TSubgoal Explore::explorationNewPoint(HeroPtr h) const
int3 mapSize = cbp->getMapSize(); int3 mapSize = cbp->getMapSize();
int perimiter = 2 * radius * (mapSize.x + mapSize.y); int perimiter = 2 * radius * (mapSize.x + mapSize.y);
std::vector<int3> from; std::vector<int3> from;
std::vector<int3> to; std::vector<int3> to;
@ -420,4 +419,4 @@ void Explore::getVisibleNeighbours(const std::vector<int3> & tiles, std::vector<
} }
}); });
} }
} }

View File

@ -44,9 +44,6 @@ TSubgoal GatherArmy::whatToDoToAchieve()
return fh->chooseSolution(getAllPossibleSubgoals()); //find dwelling. use current hero to prevent him from doing nothing. 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() TGoalVec GatherArmy::getAllPossibleSubgoals()
{ {
//get all possible towns, heroes and dwellings we may use //get all possible towns, heroes and dwellings we may use

View File

@ -63,7 +63,7 @@ boost::optional<AIPathNode *> AINodeStorage::getOrCreateNode(const int3 & pos, c
CGPathNode * AINodeStorage::getInitialNode() CGPathNode * AINodeStorage::getInitialNode()
{ {
auto hpos = hero->getPosition(false); auto hpos = hero->getPosition(false);
auto initialNode = auto initialNode =
getOrCreateNode(hpos, hero->boat ? EPathfindingLayer::SAIL : EPathfindingLayer::LAND, NORMAL_CHAIN) getOrCreateNode(hpos, hero->boat ? EPathfindingLayer::SAIL : EPathfindingLayer::LAND, NORMAL_CHAIN)
.get(); .get();
@ -99,7 +99,7 @@ void AINodeStorage::commit(CDestinationNodeInfo & destination, const PathNodeInf
dstNode->action = destination.action; dstNode->action = destination.action;
dstNode->theNodeBefore = srcNode->theNodeBefore; dstNode->theNodeBefore = srcNode->theNodeBefore;
dstNode->manaCost = srcNode->manaCost; dstNode->manaCost = srcNode->manaCost;
if(dstNode->specialAction) if(dstNode->specialAction)
{ {
dstNode->specialAction->applyOnDestination(getHero(), destination, source, dstNode, srcNode); dstNode->specialAction->applyOnDestination(getHero(), destination, source, dstNode, srcNode);
@ -193,7 +193,6 @@ bool AINodeStorage::isTileAccessible(int3 pos, const EPathfindingLayer layer) co
{ {
std::vector<AIPath> paths; std::vector<AIPath> paths;
auto chains = nodes[pos.x][pos.y][pos.z][layer]; auto chains = nodes[pos.x][pos.y][pos.z][layer];
auto initialPos = hero->visitablePos();
for(const AIPathNode & node : chains) for(const AIPathNode & node : chains)
{ {

View File

@ -77,9 +77,9 @@ namespace AIPathfinding
bool isAffordableBy(HeroPtr hero, const AIPathNode * source) const bool isAffordableBy(HeroPtr hero, const AIPathNode * source) const
{ {
logAi->trace( logAi->trace(
"Hero %s has %d mana and needed %d and already spent %d", "Hero %s has %d mana and needed %d and already spent %d",
hero->name, hero->name,
hero->mana, hero->mana,
getManaCost(hero), getManaCost(hero),
source->manaCost); source->manaCost);
@ -215,7 +215,7 @@ namespace AIPathfinding
} }
bool tryEmbarkVirtualBoat( bool tryEmbarkVirtualBoat(
CDestinationNodeInfo &destination, CDestinationNodeInfo &destination,
const PathNodeInfo &source, const PathNodeInfo &source,
std::shared_ptr<const VirtualBoatAction> virtualBoat) const std::shared_ptr<const VirtualBoatAction> virtualBoat) const
{ {
@ -232,7 +232,7 @@ namespace AIPathfinding
{ {
AIPathNode * boatNode = boatNodeOptional.get(); AIPathNode * boatNode = boatNodeOptional.get();
if(boatNode->action == CGPathNode::NOT_SET) if(boatNode->action == CGPathNode::UNKNOWN)
{ {
boatNode->specialAction = virtualBoat; boatNode->specialAction = virtualBoat;
destination.blocked = false; destination.blocked = false;

View File

@ -131,7 +131,7 @@ Goals::TSubgoal ResourceManager::collectResourcesForOurGoal(ResourceObjective &o
break; 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 //find the one which takes longest to collect
typedef std::pair<Res::ERes, float> timePair; typedef std::pair<Res::ERes, float> timePair;
@ -160,7 +160,7 @@ Goals::TSubgoal ResourceManager::whatToDo() const //suggest any goal
if (queue.size()) if (queue.size())
{ {
auto o = queue.top(); auto o = queue.top();
auto allResources = cb->getResourceAmount(); //we don't consider savings, it's out top-priority goal auto allResources = cb->getResourceAmount(); //we don't consider savings, it's out top-priority goal
if (allResources.canAfford(o.resources)) if (allResources.canAfford(o.resources))
return o.goal; return o.goal;
@ -186,9 +186,9 @@ Goals::TSubgoal ResourceManager::whatToDo(TResources &res, Goals::TSubgoal goal)
accumulatedResources += it->resources; accumulatedResources += it->resources;
logAi->trace( logAi->trace(
"ResourceManager: checking goal %s, accumulatedResources=%s, available=%s", "ResourceManager: checking goal %s, accumulatedResources=%s, available=%s",
it->goal->name(), it->goal->name(),
accumulatedResources.toString(), accumulatedResources.toString(),
allResources.toString()); allResources.toString());
if(!accumulatedResources.canBeAfforded(allResources)) if(!accumulatedResources.canBeAfforded(allResources))
@ -312,16 +312,19 @@ bool ResourceManager::removeOutdatedObjectives(std::function<bool(const Goals::T
{ //unfortunately we can't use remove_if on heap { //unfortunately we can't use remove_if on heap
auto it = boost::find_if(queue, [&](const ResourceObjective & ro) -> bool auto it = boost::find_if(queue, [&](const ResourceObjective & ro) -> bool
{ {
predicate(ro.goal); return predicate(ro.goal);
}); });
if(it != queue.end()) //removed at least one if(it != queue.end()) //removed at least one
{ {
logAi->debug("Removing goal %s from ResourceManager.", it->goal->name()); logAi->debug("Removing goal %s from ResourceManager.", it->goal->name());
queue.erase(queue.s_handle_from_iterator(it)); queue.erase(queue.s_handle_from_iterator(it));
removedAnything = true; removedAnything = true;
} }
else //found nothing more to remove else
{ //found nothing more to remove
break; break;
}
} }
return removedAnything; return removedAnything;
} }