1
0
Fork 0

Merge pull request #2024 from mc-server/revert-2023-smartPointers

Revert "PathFinder - smart pointers"
This commit is contained in:
worktycho 2015-05-15 18:55:01 +01:00
commit 4605f4f174
2 changed files with 8 additions and 3 deletions

View File

@ -215,6 +215,11 @@ bool cPath::Step_Internal()
void cPath::FinishCalculation() void cPath::FinishCalculation()
{ {
for (auto && pair : m_Map)
{
delete pair.second;
}
m_Map.clear(); m_Map.clear();
m_OpenList = std::priority_queue<cPathCell *, std::vector<cPathCell *>, compareHeuristics>{}; m_OpenList = std::priority_queue<cPathCell *, std::vector<cPathCell *>, compareHeuristics>{};
} }
@ -343,7 +348,7 @@ cPathCell * cPath::GetCell(const Vector3i & a_Location)
{ {
Cell = new cPathCell(); Cell = new cPathCell();
Cell->m_Location = a_Location; Cell->m_Location = a_Location;
m_Map[a_Location] = UniquePtr<cPathCell>(Cell); m_Map[a_Location] = Cell;
Cell->m_IsSolid = IsSolid(a_Location); Cell->m_IsSolid = IsSolid(a_Location);
Cell->m_Status = eCellStatus::NOLIST; Cell->m_Status = eCellStatus::NOLIST;
#ifdef COMPILING_PATHFIND_DEBUGGER #ifdef COMPILING_PATHFIND_DEBUGGER
@ -355,6 +360,6 @@ cPathCell * cPath::GetCell(const Vector3i & a_Location)
} }
else else
{ {
return m_Map[a_Location].get(); return m_Map[a_Location];
} }
} }

View File

@ -131,7 +131,7 @@ private:
/* Pathfinding fields */ /* Pathfinding fields */
std::priority_queue<cPathCell *, std::vector<cPathCell *>, compareHeuristics> m_OpenList; std::priority_queue<cPathCell *, std::vector<cPathCell *>, compareHeuristics> m_OpenList;
std::unordered_map<Vector3i, UniquePtr<cPathCell>, VectorHasher> m_Map; std::unordered_map<Vector3i, cPathCell *, VectorHasher> m_Map;
Vector3i m_Destination; Vector3i m_Destination;
Vector3i m_Source; Vector3i m_Source;
int m_StepsLeft; int m_StepsLeft;