summaryrefslogtreecommitdiff
path: root/src/content
diff options
context:
space:
mode:
authorSmallJoker <mk939@ymail.com>2020-11-22 17:49:30 +0100
committersfan5 <sfan5@live.de>2021-01-29 17:32:35 +0100
commit37a05ec8d6cbf9ff4432225cffe78c16fdd0647d (patch)
tree727e4272f1f16fe1a6a51484d1bba728c8632615 /src/content
parent5e9dd1667b244df4e7767be404d4a12966d6a90a (diff)
downloadminetest-37a05ec8d6cbf9ff4432225cffe78c16fdd0647d.tar.gz
minetest-37a05ec8d6cbf9ff4432225cffe78c16fdd0647d.tar.bz2
minetest-37a05ec8d6cbf9ff4432225cffe78c16fdd0647d.zip
Settings: Proper priority hierarchy
Remove old defaults system Introduce priority-based fallback list Use new functions for map_meta special functions Change groups to use end tags Unittest changes: * Adapt unittest to the new code * Compare Settings objects
Diffstat (limited to 'src/content')
-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;
}