summaryrefslogtreecommitdiffstats
path: root/src/Mobs/Path.cpp
diff options
context:
space:
mode:
authorSafwat Halaby <SafwatHalaby@users.noreply.github.com>2015-12-13 06:33:59 +0100
committerSafwat Halaby <SafwatHalaby@users.noreply.github.com>2015-12-13 06:33:59 +0100
commit86b51083a174713eeaa4a9e602bb71acb51d55f5 (patch)
treec73d4b10ce1e4159a29b386e2d933ccaaa3c5d23 /src/Mobs/Path.cpp
parentMerge pull request #2739 from Gargaj/patch-6 (diff)
parentDecoupled cMonster and path recalc logic, re-implemented recalc (diff)
downloadcuberite-86b51083a174713eeaa4a9e602bb71acb51d55f5.tar
cuberite-86b51083a174713eeaa4a9e602bb71acb51d55f5.tar.gz
cuberite-86b51083a174713eeaa4a9e602bb71acb51d55f5.tar.bz2
cuberite-86b51083a174713eeaa4a9e602bb71acb51d55f5.tar.lz
cuberite-86b51083a174713eeaa4a9e602bb71acb51d55f5.tar.xz
cuberite-86b51083a174713eeaa4a9e602bb71acb51d55f5.tar.zst
cuberite-86b51083a174713eeaa4a9e602bb71acb51d55f5.zip
Diffstat (limited to 'src/Mobs/Path.cpp')
-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);
+ }
+
}