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_mesh_update_manager(std::make_unique<MeshUpdateManager>(this)),
m_env(
new ClientMap(this, rendering_engine, control, 666),
make_irr<ClientMap>(this, rendering_engine, control, 666),
tsrc, this
),
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(ClientMap *map,
ClientEnvironment::ClientEnvironment(irr_ptr<ClientMap> map,
ITextureSource *texturesource, Client *client):
Environment(client),
m_map(map),
m_map(std::move(map)),
m_texturesource(texturesource),
m_client(client)
{
@ -60,18 +60,17 @@ ClientEnvironment::~ClientEnvironment()
delete simple_object;
}
// Drop/delete map
m_map->drop();
m_map.reset();
delete m_local_player;
}
Map & ClientEnvironment::getMap()
Map &ClientEnvironment::getMap()
{
return *m_map;
}
ClientMap & ClientEnvironment::getClientMap()
ClientMap &ClientEnvironment::getClientMap()
{
return *m_map;
}

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