mirror of
https://github.com/minetest/minetest.git
synced 2024-11-27 01:53:45 +01:00
Server: properly delete ServerMap on interrupted startups
A static mod error (e.g. typo) would abort the initialization but never free ServerMap
This commit is contained in:
parent
9b64834c6a
commit
d287da184c
@ -116,7 +116,8 @@ bool MapSettingsManager::saveMapMeta()
|
||||
{
|
||||
// If mapgen params haven't been created yet; abort
|
||||
if (!mapgen_params) {
|
||||
errorstream << "saveMapMeta: mapgen_params not present!" << std::endl;
|
||||
infostream << "saveMapMeta: mapgen_params not present! "
|
||||
<< "Server startup was probably interrupted." << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -351,6 +351,7 @@ Server::~Server()
|
||||
// Deinitialize scripting
|
||||
infostream << "Server: Deinitializing scripting" << std::endl;
|
||||
delete m_script;
|
||||
delete m_startup_server_map; // if available
|
||||
delete m_game_settings;
|
||||
|
||||
while (!m_unsent_map_edit_queue.empty()) {
|
||||
@ -399,6 +400,7 @@ void Server::init()
|
||||
|
||||
// Create the Map (loads map_meta.txt, overriding configured mapgen params)
|
||||
ServerMap *servermap = new ServerMap(m_path_world, this, m_emerge, m_metrics_backend.get());
|
||||
m_startup_server_map = servermap;
|
||||
|
||||
// Initialize scripting
|
||||
infostream << "Server: Initializing Lua" << std::endl;
|
||||
@ -440,6 +442,7 @@ void Server::init()
|
||||
m_craftdef->initHashes(this);
|
||||
|
||||
// Initialize Environment
|
||||
m_startup_server_map = nullptr; // Ownership moved to ServerEnvironment
|
||||
m_env = new ServerEnvironment(servermap, m_script, this, m_path_world);
|
||||
|
||||
m_inventory_mgr->setEnv(m_env);
|
||||
|
@ -547,6 +547,10 @@ private:
|
||||
// Environment
|
||||
ServerEnvironment *m_env = nullptr;
|
||||
|
||||
// Reference to the server map until ServerEnvironment is initialized
|
||||
// after that this variable must be a nullptr
|
||||
ServerMap *m_startup_server_map = nullptr;
|
||||
|
||||
// server connection
|
||||
std::shared_ptr<con::Connection> m_con;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user