Use irr_ptr for Game::sky

This commit is contained in:
Desour 2023-07-11 00:00:00 +02:00 committed by sfan5
parent 17c041a65c
commit b93ae33f85

@ -595,7 +595,8 @@ public:
m_client(client) m_client(client)
{} {}
void setSky(Sky *sky) { void setSky(Sky *sky)
{
m_sky = sky; m_sky = sky;
for (GameGlobalShaderConstantSetter *ggscs : created_nosky) { for (GameGlobalShaderConstantSetter *ggscs : created_nosky) {
ggscs->setSky(m_sky); ggscs->setSky(m_sky);
@ -894,7 +895,7 @@ private:
MapDrawControl *draw_control = nullptr; MapDrawControl *draw_control = nullptr;
Camera *camera = nullptr; Camera *camera = nullptr;
irr_ptr<Clouds> clouds; irr_ptr<Clouds> clouds;
Sky *sky = nullptr; // Free using ->Drop() irr_ptr<Sky> sky;
Hud *hud = nullptr; Hud *hud = nullptr;
Minimap *mapper = nullptr; Minimap *mapper = nullptr;
@ -1267,8 +1268,7 @@ void Game::shutdown()
gui_chat_console.reset(); gui_chat_console.reset();
if (sky) sky.reset();
sky->drop();
/* cleanup menus */ /* cleanup menus */
while (g_menumgr.menuCount() > 0) { while (g_menumgr.menuCount() > 0) {
@ -1526,8 +1526,8 @@ bool Game::createClient(const GameStartData &start_data)
/* Skybox /* Skybox
*/ */
sky = new Sky(-1, m_rendering_engine, texture_src, shader_src); sky = make_irr<Sky>(-1, m_rendering_engine, texture_src, shader_src);
scsf->setSky(sky); scsf->setSky(sky.get());
/* Pre-calculated values /* Pre-calculated values
*/ */