aboutsummaryrefslogtreecommitdiff
path: root/src/content/subgames.cpp
diff options
context:
space:
mode:
authorMinetest-j45 <55553015+Minetest-j45@users.noreply.github.com>2021-08-30 15:22:40 +0100
committerGitHub <noreply@github.com>2021-08-30 15:22:40 +0100
commit7824a4956bf489b4e2cc35e0c97272eee06be6ba (patch)
tree70243765dc1743a83596f9c6eec122fb417ef92c /src/content/subgames.cpp
parent607add326feb44e078b843464ce4a8de09f28743 (diff)
parent35445d24f425c6291a0580b468919ca83de716fd (diff)
downloaddragonfireclient-7824a4956bf489b4e2cc35e0c97272eee06be6ba.tar.xz
Merge pull request #1 from EliasFleckenstein03/master
update
Diffstat (limited to 'src/content/subgames.cpp')
-rw-r--r--src/content/subgames.cpp24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/content/subgames.cpp b/src/content/subgames.cpp
index c6350f2dd..e9dc609b0 100644
--- a/src/content/subgames.cpp
+++ b/src/content/subgames.cpp
@@ -329,18 +329,16 @@ void loadGameConfAndInitWorld(const std::string &path, const std::string &name,
}
}
- // Override defaults with those provided by the game.
- // We clear and reload the defaults because the defaults
- // might have been overridden by other subgame config
- // files that were loaded before.
- g_settings->clearDefaults();
- set_default_settings(g_settings);
-
- Settings game_defaults;
- getGameMinetestConfig(gamespec.path, game_defaults);
- game_defaults.removeSecureSettings();
+ Settings *game_settings = Settings::getLayer(SL_GAME);
+ const bool new_game_settings = (game_settings == nullptr);
+ if (new_game_settings) {
+ // Called by main-menu without a Server instance running
+ // -> create and free manually
+ game_settings = Settings::createLayer(SL_GAME);
+ }
- g_settings->overrideDefaults(&game_defaults);
+ getGameMinetestConfig(gamespec.path, *game_settings);
+ game_settings->removeSecureSettings();
infostream << "Initializing world at " << final_path << std::endl;
@@ -381,4 +379,8 @@ void loadGameConfAndInitWorld(const std::string &path, const std::string &name,
fs::safeWriteToFile(map_meta_path, oss.str());
}
+
+ // The Settings object is no longer needed for created worlds
+ if (new_game_settings)
+ delete game_settings;
}