]> git.lizzy.rs Git - minetest.git/commitdiff
Safety check the map's blocksize (#12895)
authorlhofhansl <larsh@apache.org>
Fri, 28 Oct 2022 02:31:42 +0000 (19:31 -0700)
committerGitHub <noreply@github.com>
Fri, 28 Oct 2022 02:31:42 +0000 (19:31 -0700)
src/content/subgames.cpp
src/serverenvironment.cpp

index d0de926ef367e1fdc059bf4a3af82d4901dbbd6a..3658fa83efd23b892b8233dc1523ae6de14c0d6d 100644 (file)
@@ -390,6 +390,8 @@ void loadGameConfAndInitWorld(const std::string &path, const std::string &name,
                conf.set("mod_storage_backend", "sqlite3");
                conf.setBool("creative_mode", g_settings->getBool("creative_mode"));
                conf.setBool("enable_damage", g_settings->getBool("enable_damage"));
+               if (MAP_BLOCKSIZE != 16)
+                       conf.set("blocksize", std::to_string(MAP_BLOCKSIZE));
 
                if (!conf.updateConfigFile(worldmt_path.c_str())) {
                        throw BaseException("Failed to update the config file");
index dfa3e09613fc1d31f5e41bca133ca0edde7e1615..4cdb21a4b1676dc738aa81707f7328e4774d1b6e 100644 (file)
@@ -420,6 +420,13 @@ void ServerEnvironment::init()
 
        // If we open world.mt read the backend configurations.
        if (succeeded) {
+               // Check that the world's blocksize matches the compiled MAP_BLOCKSIZE
+               u16 blocksize = 16;
+               conf.getU16NoEx("blocksize", blocksize);
+               if (blocksize != MAP_BLOCKSIZE) {
+                       throw BaseException(std::string("The map's blocksize is not supported."));
+               }
+
                // Read those values before setting defaults
                bool player_backend_exists = conf.exists("player_backend");
                bool auth_backend_exists = conf.exists("auth_backend");