CPathfinder.h 981 B

12345678910111213141516171819202122232425262728293031323334
  1. #ifndef CPATHFINDER_H
  2. #define CPATHFINDER_H
  3. #include "CGameInfo.h"
  4. #include "int3.h"
  5. #include <queue>
  6. #include <vector>
  7. struct CPathNode
  8. {
  9. bool accesible; //true if a hero can be on this node
  10. int dist; //distance from the first node of searching; -1 is infinity
  11. CPathNode * theNodeBefore;
  12. int x, y; //coordiantes
  13. bool visited;
  14. };
  15. struct CPath
  16. {
  17. std::queue<CPathNode> nodes; //just get node by node
  18. };
  19. /**
  20. * main pathfinder class
  21. */
  22. class CPathfinder
  23. {
  24. private:
  25. std::vector< std::vector<CPathNode *> > graph;
  26. public:
  27. 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
  28. 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
  29. };
  30. #endif //CPATHFINDER_H