diff options
author | tycho <work.tycho@gmail.com> | 2015-05-23 12:31:03 +0200 |
---|---|---|
committer | tycho <work.tycho@gmail.com> | 2015-05-23 12:31:03 +0200 |
commit | 1577a080ee4e2fb5baaee8c8c98149eb8418b6c6 (patch) | |
tree | f8d9453f07a7475562b68ccfbfa92ad817a206be /src/Mobs/Path.h | |
parent | Fix tests (diff) | |
parent | Merge pull request #2108 from mc-server/tgh-boolean (diff) | |
download | cuberite-1577a080ee4e2fb5baaee8c8c98149eb8418b6c6.tar cuberite-1577a080ee4e2fb5baaee8c8c98149eb8418b6c6.tar.gz cuberite-1577a080ee4e2fb5baaee8c8c98149eb8418b6c6.tar.bz2 cuberite-1577a080ee4e2fb5baaee8c8c98149eb8418b6c6.tar.lz cuberite-1577a080ee4e2fb5baaee8c8c98149eb8418b6c6.tar.xz cuberite-1577a080ee4e2fb5baaee8c8c98149eb8418b6c6.tar.zst cuberite-1577a080ee4e2fb5baaee8c8c98149eb8418b6c6.zip |
Diffstat (limited to 'src/Mobs/Path.h')
-rw-r--r-- | src/Mobs/Path.h | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/src/Mobs/Path.h b/src/Mobs/Path.h index 31002fe7f..71b42edc0 100644 --- a/src/Mobs/Path.h +++ b/src/Mobs/Path.h @@ -1,16 +1,13 @@ #pragma once -/* Wanna use the pathfinder? Put this in your header file: - -// Fwd: cPath +/* +// Needed Fwds: cPath enum class ePathFinderStatus; class cPath; - -Put this in your .cpp: -#include "...Path.h" */ +#include "../FastRandom.h" #ifdef COMPILING_PATHFIND_DEBUGGER /* Note: the COMPILING_PATHFIND_DEBUGGER flag is used by Native / WiseOldMan95 to debug this class outside of MCServer. This preprocessor flag is never set when compiling MCServer. */ @@ -24,13 +21,30 @@ class cChunk; /* Various little structs and classes */ enum class ePathFinderStatus {CALCULATING, PATH_FOUND, PATH_NOT_FOUND, NEARBY_FOUND}; -struct cPathCell; // Defined inside Path.cpp +enum class eCellStatus {OPENLIST, CLOSEDLIST, NOLIST}; +struct cPathCell +{ + Vector3i m_Location; // Location of the cell in the world. + int m_F, m_G, m_H; // F, G, H as defined in regular A*. + eCellStatus m_Status; // Which list is the cell in? Either non, open, or closed. + cPathCell * m_Parent; // Cell's parent, as defined in regular A*. + bool m_IsSolid; // Is the cell an air or a solid? Partial solids are currently considered solids. +}; + + + + + class compareHeuristics { public: bool operator()(cPathCell * & a_V1, cPathCell * & a_V2); }; + + + + class cPath { public: @@ -144,11 +158,12 @@ private: /* Pathfinding fields */ std::priority_queue<cPathCell *, std::vector<cPathCell *>, compareHeuristics> m_OpenList; - std::unordered_map<Vector3i, UniquePtr<cPathCell>, VectorHasher> m_Map; + std::unordered_map<Vector3i, cPathCell, VectorHasher> m_Map; Vector3i m_Destination; Vector3i m_Source; int m_StepsLeft; cPathCell * m_NearestPointToTarget; + cFastRandom m_Rand; /* Control fields */ ePathFinderStatus m_Status; |