From 8a5df43e6c72efd899fc59b04168ecd5526300e4 Mon Sep 17 00:00:00 2001 From: Safwat Halaby Date: Fri, 20 Nov 2015 10:03:20 +0200 Subject: Decoupled cMonster and path recalc logic, re-implemented recalc --- src/Mobs/Path.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/Mobs/Path.cpp') 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); + } + } -- cgit v1.2.3