summaryrefslogtreecommitdiffstats
path: root/src/Mobs/Path.cpp
diff options
context:
space:
mode:
authorSafwat Halaby <SafwatHalaby@users.noreply.github.com>2015-11-20 09:03:20 +0100
committerSafwat Halaby <SafwatHalaby@users.noreply.github.com>2015-12-13 06:13:34 +0100
commit8a5df43e6c72efd899fc59b04168ecd5526300e4 (patch)
treec73d4b10ce1e4159a29b386e2d933ccaaa3c5d23 /src/Mobs/Path.cpp
parentMerge pull request #2739 from Gargaj/patch-6 (diff)
downloadcuberite-8a5df43e6c72efd899fc59b04168ecd5526300e4.tar
cuberite-8a5df43e6c72efd899fc59b04168ecd5526300e4.tar.gz
cuberite-8a5df43e6c72efd899fc59b04168ecd5526300e4.tar.bz2
cuberite-8a5df43e6c72efd899fc59b04168ecd5526300e4.tar.lz
cuberite-8a5df43e6c72efd899fc59b04168ecd5526300e4.tar.xz
cuberite-8a5df43e6c72efd899fc59b04168ecd5526300e4.tar.zst
cuberite-8a5df43e6c72efd899fc59b04168ecd5526300e4.zip
Diffstat (limited to '')
-rw-r--r--src/Mobs/Path.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/Mobs/Path.cpp b/src/Mobs/Path.cpp
index b98dd0d10..c0cffbeb4 100644
--- a/src/Mobs/Path.cpp
+++ b/src/Mobs/Path.cpp
@@ -34,6 +34,7 @@ cPath::cPath(
int a_MaxUp, int a_MaxDown
) :
m_StepsLeft(a_MaxSteps),
+ m_IsValid(true),
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)
@@ -68,11 +69,14 @@ cPath::cPath(
ProcessCell(GetCell(m_Source), nullptr, 0);
}
+cPath::cPath() : m_IsValid(false)
+{
+}
-ePathFinderStatus cPath::Step(cChunk & a_Chunk)
+ePathFinderStatus cPath::CalculationStep(cChunk & a_Chunk)
{
m_Chunk = &a_Chunk;
if (m_Status != ePathFinderStatus::CALCULATING)
@@ -287,11 +291,12 @@ void cPath::AttemptToFindAlternative()
void cPath::BuildPath()
{
cPathCell * CurrentCell = GetCell(m_Destination);
- do
+ while (CurrentCell->m_Parent != nullptr)
{
- m_PathPoints.push_back(CurrentCell->m_Location); // Populate the cPath with points.
+ m_PathPoints.push_back(CurrentCell->m_Location); // Populate the cPath with points. All midpoints are added. Destination is added. Source is excluded.
CurrentCell = CurrentCell->m_Parent;
- } while (CurrentCell != nullptr);
+ }
+
}