Use irr_ptr for ClientEnvironment::m_map

This commit is contained in:
Desour 2023-07-10 00:00:00 +02:00 committed by sfan5
parent e3efaa1733
commit ecf8c7696a
3 changed files with 9 additions and 9 deletions

@ -120,7 +120,7 @@ Client::Client(
m_rendering_engine(rendering_engine), m_rendering_engine(rendering_engine),
m_mesh_update_manager(std::make_unique<MeshUpdateManager>(this)), m_mesh_update_manager(std::make_unique<MeshUpdateManager>(this)),
m_env( m_env(
new ClientMap(this, rendering_engine, control, 666), make_irr<ClientMap>(this, rendering_engine, control, 666),
tsrc, this tsrc, this
), ),
m_particle_manager(std::make_unique<ParticleManager>(&m_env)), m_particle_manager(std::make_unique<ParticleManager>(&m_env)),

@ -43,10 +43,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
ClientEnvironment ClientEnvironment
*/ */
ClientEnvironment::ClientEnvironment(ClientMap *map, ClientEnvironment::ClientEnvironment(irr_ptr<ClientMap> map,
ITextureSource *texturesource, Client *client): ITextureSource *texturesource, Client *client):
Environment(client), Environment(client),
m_map(map), m_map(std::move(map)),
m_texturesource(texturesource), m_texturesource(texturesource),
m_client(client) m_client(client)
{ {
@ -60,18 +60,17 @@ ClientEnvironment::~ClientEnvironment()
delete simple_object; delete simple_object;
} }
// Drop/delete map m_map.reset();
m_map->drop();
delete m_local_player; delete m_local_player;
} }
Map & ClientEnvironment::getMap() Map &ClientEnvironment::getMap()
{ {
return *m_map; return *m_map;
} }
ClientMap & ClientEnvironment::getClientMap() ClientMap &ClientEnvironment::getClientMap()
{ {
return *m_map; return *m_map;
} }

@ -22,6 +22,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "environment.h" #include "environment.h"
#include "util/numeric.h" // IntervalLimiter #include "util/numeric.h" // IntervalLimiter
#include "activeobjectmgr.h" // client::ActiveObjectMgr #include "activeobjectmgr.h" // client::ActiveObjectMgr
#include "irr_ptr.h"
#include <set> #include <set>
#ifdef SERVER #ifdef SERVER
@ -66,7 +67,7 @@ typedef std::unordered_map<u16, ClientActiveObject*> ClientActiveObjectMap;
class ClientEnvironment : public Environment class ClientEnvironment : public Environment
{ {
public: public:
ClientEnvironment(ClientMap *map, ITextureSource *texturesource, Client *client); ClientEnvironment(irr_ptr<ClientMap> map, ITextureSource *texturesource, Client *client);
~ClientEnvironment(); ~ClientEnvironment();
Map & getMap(); Map & getMap();
@ -151,7 +152,7 @@ public:
u64 getFrameTimeDelta() const { return m_frame_dtime; } u64 getFrameTimeDelta() const { return m_frame_dtime; }
private: private:
ClientMap *m_map; irr_ptr<ClientMap> m_map;
LocalPlayer *m_local_player = nullptr; LocalPlayer *m_local_player = nullptr;
ITextureSource *m_texturesource; ITextureSource *m_texturesource;
Client *m_client; Client *m_client;