From 0741ad3526096ce0494a984c612b3dfca18fe6bb Mon Sep 17 00:00:00 2001 From: SafwatHalaby Date: Tue, 19 May 2015 21:07:05 +0300 Subject: Removed UniquePTR from PathFinder --- src/Mobs/Path.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/Mobs/Path.h') diff --git a/src/Mobs/Path.h b/src/Mobs/Path.h index 7a4182f17..b3ad5ffd5 100644 --- a/src/Mobs/Path.h +++ b/src/Mobs/Path.h @@ -24,7 +24,15 @@ 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: @@ -144,7 +152,7 @@ private: /* Pathfinding fields */ std::priority_queue, compareHeuristics> m_OpenList; - std::unordered_map, VectorHasher> m_Map; + std::unordered_map m_Map; Vector3i m_Destination; Vector3i m_Source; int m_StepsLeft; -- cgit v1.2.3 From 395f3d9c4c94428bc6ec0b90c907567a368f068f Mon Sep 17 00:00:00 2001 From: SafwatHalaby Date: Tue, 19 May 2015 22:47:48 +0300 Subject: newlines --- src/Mobs/Path.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/Mobs/Path.h') diff --git a/src/Mobs/Path.h b/src/Mobs/Path.h index b3ad5ffd5..acc56ef2d 100644 --- a/src/Mobs/Path.h +++ b/src/Mobs/Path.h @@ -33,12 +33,21 @@ struct cPathCell 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: -- cgit v1.2.3 From 8436e5d8bd0889830f8daa7a15f08b6772e106fe Mon Sep 17 00:00:00 2001 From: SafwatHalaby Date: Tue, 19 May 2015 06:54:20 +0300 Subject: Path recalculation improvements --- src/Mobs/Path.h | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src/Mobs/Path.h') diff --git a/src/Mobs/Path.h b/src/Mobs/Path.h index acc56ef2d..b296bbdf5 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. */ @@ -166,6 +163,7 @@ private: Vector3i m_Source; int m_StepsLeft; cPathCell * m_NearestPointToTarget; + cFastRandom m_Rand; /* Control fields */ ePathFinderStatus m_Status; -- cgit v1.2.3