diff --git a/src/server.cpp b/src/server.cpp index ddafa6312..e57d81dbb 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -393,6 +393,10 @@ Server::~Server() infostream << "Server: Saving environment metadata" << std::endl; m_env->saveMeta(); + // Delete classes that depend on the environment + m_inventory_mgr.reset(); + m_script.reset(); + // Note that this also deletes and saves the map. delete m_env; m_env = nullptr; @@ -409,6 +413,9 @@ Server::~Server() } } + // emerge may depend on definition managers, so destroy first + m_emerge.reset(); + // Delete the rest in the reverse order of creation delete m_game_settings; delete m_banmanager;