CPathfinder.h 1006 B

123456789101112131415161718192021222324252627282930313233343536
  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 v1, v2, v3,
  10. v4, v5,
  11. v6, v7, v8; //true if we can pass, false if not
  12. bool accesible; //true if a hero can be on this node
  13. int dist; //distance from the first node of searching; -1 is infinity
  14. CPathNode * theNodeBefore;
  15. int x, y; //coordiantes
  16. };
  17. struct CPath
  18. {
  19. std::queue<CPathNode> nodes; //just get node by node
  20. };
  21. /**
  22. * main pathfinder class
  23. */
  24. class CPathfinder
  25. {
  26. private:
  27. std::vector< std::vector<CPathNode> > graph;
  28. public:
  29. CPath * getPath(int3 & src, int3 & dest); //calculates path between src and dest; returns pointer to CPath or NULL if path does not exists
  30. CPath * getPath(int3 & src, int3 & dest, 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
  31. };
  32. #endif //CPATHFINDER_H