1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-12 02:28:11 +02:00

EPathfindingLayer: copy other code from ETerrainType for debugging

This commit is contained in:
ArseniyShestakov 2015-11-02 13:25:01 +03:00
parent 2b6e1498d2
commit 4b64bec711
4 changed files with 35 additions and 3 deletions

View File

@ -372,7 +372,7 @@ int3 whereToExplore(HeroPtr h)
{
int3 op = obj->visitablePos();
CGPath p;
ai->myCb->getPathsInfo(h.get())->getPath(p, ops);
ai->myCb->getPathsInfo(h.get())->getPath(p, op);
if (p.nodes.size() && p.endPos() == op && p.nodes.size() <= DIST_LIMIT)
if (ai->isGoodForVisit(obj, h, sm))
nearbyVisitableObjs.push_back(obj);

View File

@ -459,6 +459,7 @@ CGPathNode::CGPathNode()
moveRemains = 0;
turns = 255;
theNodeBefore = nullptr;
layer = EPathfindingLayer::WRONG;
}
bool CGPathNode::reachable() const

View File

@ -63,6 +63,8 @@ ID_LIKE_OPERATORS(Obj, Obj::EObj)
ID_LIKE_OPERATORS(ETerrainType, ETerrainType::EETerrainType)
ID_LIKE_OPERATORS(EPathfindingLayer, EPathfindingLayer::EEPathfindingLayer)
ID_LIKE_OPERATORS(ArtifactID, ArtifactID::EArtifactID)
ID_LIKE_OPERATORS(ArtifactPosition, ArtifactPosition::EArtifactPosition)
@ -160,3 +162,30 @@ std::string ETerrainType::toString() const
ss << *this;
return ss.str();
}
std::ostream & operator<<(std::ostream & os, const EPathfindingLayer actionType)
{
static const std::map<EPathfindingLayer::EEPathfindingLayer, std::string> pathfinderLayerToString =
{
#define DEFINE_ELEMENT(element) {EPathfindingLayer::element, #element}
DEFINE_ELEMENT(WRONG),
DEFINE_ELEMENT(AUTO),
DEFINE_ELEMENT(LAND),
DEFINE_ELEMENT(SAIL),
DEFINE_ELEMENT(WATER),
DEFINE_ELEMENT(AIR),
DEFINE_ELEMENT(NUM_LAYERS)
};
auto it = pathfinderLayerToString.find(actionType.num);
if (it == pathfinderLayerToString.end()) return os << "<Unknown type>";
else return os << it->second;
}
std::string EPathfindingLayer::toString() const
{
std::stringstream ss;
ss << *this;
return ss.str();
}

View File

@ -750,15 +750,17 @@ class DLL_LINKAGE EPathfindingLayer
public:
enum EEPathfindingLayer
{
AUTO = -1, LAND = 0, SAIL = 1, WATER, AIR, NUM_LAYERS
WRONG = -2, AUTO = -1, LAND = 0, SAIL = 1, WATER, AIR, NUM_LAYERS
};
EPathfindingLayer(EEPathfindingLayer _num = AUTO) : num(_num)
EPathfindingLayer(EEPathfindingLayer _num = WRONG) : num(_num)
{}
ID_LIKE_CLASS_COMMON(EPathfindingLayer, EEPathfindingLayer)
EEPathfindingLayer num;
std::string toString() const;
};
DLL_LINKAGE std::ostream & operator<<(std::ostream & os, const EPathfindingLayer actionType);