1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00
vcmi/CPathfinder.h
Michał W. Urbańczyk 7d704c7f02 * working pathfinder
* drawing paths
* new command "P X1 Y1 Z1 X2 Y2 Z2" - draws path between given points
* borders handling rewritten
* minor stuff
2007-08-17 17:42:21 +00:00

33 lines
980 B
C++

#ifndef CPATHFINDER_H
#define CPATHFINDER_H
#include "int3.h"
#include <queue>
#include <vector>
class CHeroInstance;
struct CPathNode
{
bool accesible; //true if a hero can be on this node
int dist; //distance from the first node of searching; -1 is infinity
CPathNode * theNodeBefore;
int x, y; //coordiantes
bool visited;
};
struct CPath
{
std::vector<CPathNode> nodes; //just get node by node
};
/**
* main pathfinder class
*/
class CPathfinder
{
private:
std::vector< std::vector<CPathNode *> > graph;
public:
CPath * getPath(int3 & src, int3 & dest, CHeroInstance * hero); //calculates path between src and dest; returns pointer to CPath or NULL if path does not exists
CPath * getPath(int3 & src, int3 & dest, CHeroInstance * hero, int (*getDist)(int3 & a, int3 & b)); //calculates path between src and dest; returns pointer to CPath or NULL if path does not exists; uses getDist to calculate distance
};
#endif //CPATHFINDER_H