summaryrefslogtreecommitdiffstats
path: root/src/Mobs/Path.cpp
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@hotmail.co.uk>2015-08-27 00:13:13 +0200
committerTiger Wang <ziwei.tiger@hotmail.co.uk>2015-08-27 00:13:13 +0200
commit3b8dc45dc3418359b05ec54b90c94aa2b94405c8 (patch)
treee2e4cb1200d8da5ada4f4d60a7703971ae81c7d3 /src/Mobs/Path.cpp
parentSmall fix for cEvent (diff)
parentFixed a position bug in the pathfinder (diff)
downloadcuberite-3b8dc45dc3418359b05ec54b90c94aa2b94405c8.tar
cuberite-3b8dc45dc3418359b05ec54b90c94aa2b94405c8.tar.gz
cuberite-3b8dc45dc3418359b05ec54b90c94aa2b94405c8.tar.bz2
cuberite-3b8dc45dc3418359b05ec54b90c94aa2b94405c8.tar.lz
cuberite-3b8dc45dc3418359b05ec54b90c94aa2b94405c8.tar.xz
cuberite-3b8dc45dc3418359b05ec54b90c94aa2b94405c8.tar.zst
cuberite-3b8dc45dc3418359b05ec54b90c94aa2b94405c8.zip
Diffstat (limited to 'src/Mobs/Path.cpp')
-rw-r--r--src/Mobs/Path.cpp25
1 files changed, 4 insertions, 21 deletions
diff --git a/src/Mobs/Path.cpp b/src/Mobs/Path.cpp
index dd908c86b..43b29f1d0 100644
--- a/src/Mobs/Path.cpp
+++ b/src/Mobs/Path.cpp
@@ -17,9 +17,6 @@
-
-
-
bool compareHeuristics::operator()(cPathCell * & a_Cell1, cPathCell * & a_Cell2)
{
return a_Cell1->m_F > a_Cell2->m_F;
@@ -36,7 +33,7 @@ cPath::cPath(
double a_BoundingBoxWidth, double a_BoundingBoxHeight,
int a_MaxUp, int a_MaxDown
) :
-
+ m_StepsLeft(a_MaxSteps),
m_CurrentPoint(0), // GetNextPoint increments this to 1, but that's fine, since the first cell is always a_StartingPoint
m_Chunk(&a_Chunk),
m_BadChunkFound(false)
@@ -67,22 +64,8 @@ cPath::cPath(
m_NearestPointToTarget = GetCell(m_Source);
m_Status = ePathFinderStatus::CALCULATING;
- m_StepsLeft = a_MaxSteps;
-
- ProcessCell(GetCell(a_StartingPoint), nullptr, 0);
- m_Chunk = nullptr;
-}
-
-
-
-
-cPath::~cPath()
-{
- if (m_Status == ePathFinderStatus::CALCULATING)
- {
- FinishCalculation();
- }
+ ProcessCell(GetCell(m_Source), nullptr, 0);
}
@@ -113,7 +96,7 @@ ePathFinderStatus cPath::Step(cChunk & a_Chunk)
int i;
for (i = 0; i < CALCULATIONS_PER_STEP; ++i)
{
- if (Step_Internal()) // Step_Internal returns true when no more calculation is needed.
+ if (StepOnce()) // StepOnce returns true when no more calculation is needed.
{
break; // if we're here, m_Status must have changed either to PATH_FOUND or PATH_NOT_FOUND.
}
@@ -179,7 +162,7 @@ bool cPath::IsSolid(const Vector3i & a_Location)
-bool cPath::Step_Internal()
+bool cPath::StepOnce()
{
cPathCell * CurrentCell = OpenListPop();