From 4ffc6621a9ca976f95eeda80e7c073ee932af85f Mon Sep 17 00:00:00 2001 From: SafwatHalaby Date: Fri, 15 May 2015 20:25:44 +0300 Subject: PathFinder uses UniquePtr for cell map. --- src/Mobs/Path.cpp | 9 ++------- src/Mobs/Path.h | 2 +- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/Mobs/Path.cpp b/src/Mobs/Path.cpp index ba7d615ae..dd306af13 100644 --- a/src/Mobs/Path.cpp +++ b/src/Mobs/Path.cpp @@ -215,11 +215,6 @@ bool cPath::Step_Internal() void cPath::FinishCalculation() { - for (auto && pair : m_Map) - { - delete pair.second; - } - m_Map.clear(); m_OpenList = std::priority_queue, compareHeuristics>{}; } @@ -348,7 +343,7 @@ cPathCell * cPath::GetCell(const Vector3i & a_Location) { Cell = new cPathCell(); Cell->m_Location = a_Location; - m_Map[a_Location] = Cell; + m_Map[a_Location] = UniquePtr(Cell); Cell->m_IsSolid = IsSolid(a_Location); Cell->m_Status = eCellStatus::NOLIST; #ifdef COMPILING_PATHFIND_DEBUGGER @@ -360,6 +355,6 @@ cPathCell * cPath::GetCell(const Vector3i & a_Location) } else { - return m_Map[a_Location]; + return m_Map[a_Location].get(); } } diff --git a/src/Mobs/Path.h b/src/Mobs/Path.h index adae77984..008722d29 100644 --- a/src/Mobs/Path.h +++ b/src/Mobs/Path.h @@ -131,7 +131,7 @@ private: /* Pathfinding fields */ std::priority_queue, compareHeuristics> m_OpenList; - std::unordered_map m_Map; + std::unordered_map, VectorHasher> m_Map; Vector3i m_Destination; Vector3i m_Source; int m_StepsLeft; -- cgit v1.2.3