mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-10 19:32:10 +00:00
Use unique_ptr for trivial ownership (#16300)
This commit is contained in:
parent
08bc036311
commit
5b37614d23
10 changed files with 44 additions and 59 deletions
|
@ -169,8 +169,6 @@ public:
|
|||
Pathfinder() = delete;
|
||||
Pathfinder(Map *map, const NodeDefManager *ndef) : m_map(map), m_ndef(ndef) {}
|
||||
|
||||
~Pathfinder();
|
||||
|
||||
/**
|
||||
* path evaluation function
|
||||
* @param env environment to look for path
|
||||
|
@ -307,7 +305,7 @@ private:
|
|||
/** contains all map data already collected and analyzed.
|
||||
Access it via the getIndexElement/getIdxElem methods. */
|
||||
friend class GridNodeContainer;
|
||||
GridNodeContainer *m_nodes_container = nullptr;
|
||||
std::unique_ptr<GridNodeContainer> m_nodes_container;
|
||||
|
||||
Map *m_map = nullptr;
|
||||
|
||||
|
@ -639,11 +637,10 @@ std::vector<v3s16> Pathfinder::getPath(v3s16 source,
|
|||
m_max_index_y = diff.Y;
|
||||
m_max_index_z = diff.Z;
|
||||
|
||||
delete m_nodes_container;
|
||||
if (diff.getLength() > 5) {
|
||||
m_nodes_container = new MapGridNodeContainer(this);
|
||||
m_nodes_container = std::make_unique<MapGridNodeContainer>(this);
|
||||
} else {
|
||||
m_nodes_container = new ArrayGridNodeContainer(this, diff);
|
||||
m_nodes_container = std::make_unique<ArrayGridNodeContainer>(this, diff);
|
||||
}
|
||||
#ifdef PATHFINDER_DEBUG
|
||||
printType();
|
||||
|
@ -799,10 +796,6 @@ std::vector<v3s16> Pathfinder::getPath(v3s16 source,
|
|||
return retval;
|
||||
}
|
||||
|
||||
Pathfinder::~Pathfinder()
|
||||
{
|
||||
delete m_nodes_container;
|
||||
}
|
||||
/******************************************************************************/
|
||||
v3s16 Pathfinder::getRealPos(v3s16 ipos)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue