CPathfinder.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #ifndef CPATHFINDER_H
  2. #define CPATHFINDER_H
  3. #include "global.h"
  4. #include <queue>
  5. #include <vector>
  6. class CHeroInstance;
  7. class CGHeroInstance;
  8. struct CPathNode
  9. {
  10. bool accesible; //true if a hero can be on this node
  11. int dist; //distance from the first node of searching; -1 is infinity
  12. CPathNode * theNodeBefore;
  13. int3 coord; //coordiantes
  14. bool visited;
  15. };
  16. struct CPath
  17. {
  18. std::vector<CPathNode> nodes; //just get node by node
  19. int3 startPos(); // start point
  20. int3 endPos(); //destination point
  21. };
  22. /**
  23. * main pathfinder class
  24. */
  25. class CPathfinder
  26. {
  27. private:
  28. std::vector< std::vector<CPathNode *> > graph;
  29. public:
  30. CPath * getPath(int3 src, int3 dest, const CGHeroInstance * hero, unsigned char type=0); //calculates path between src and dest; returns pointer to CPath or NULL if path does not exists; type - type of calculation: 0 - positions are normal positions of hero; 1 - given places are tiles blocked by hero
  31. CPath * getPath(const int3 & src, const int3 & dest, const CGHeroInstance * hero, int (*getDist)(int3 & a, int3 & b), unsigned char type=0); //calculates path between src and dest; returns pointer to CPath or NULL if path does not exists; uses getDist to calculate distance; type - type of calculation: 0 - positions are normal positions of hero; 1 - given places are tiles blocked by hero
  32. static void convertPath(CPath * path, unsigned int mode); //mode=0 -> from 'manifest' to 'object'
  33. };
  34. #endif //CPATHFINDER_H