From: paramat Date: Thu, 23 Mar 2017 00:18:59 +0000 (+0000) Subject: Map generation limit: Make per-world X-Git-Tag: 0.4.16~349 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=ec0c4d33db9e0b7b3e541757e34c04c08c3b48c9;p=oweals%2Fminetest.git Map generation limit: Make per-world The setting limits map generation but affects nothing else. Add 'mapgen_limit' to global mapgen parameters. Move 'blockpos_over_mapgen_limit()' to the only place it is called from: map.cpp. Allow teleportation to any part of the world even if over the set mapgen limit. Simplify the reading of this limit in mgvalleys. Remove the 'map_generation_limit' setting. --- diff --git a/builtin/game/chatcommands.lua b/builtin/game/chatcommands.lua index b4fa4f828..16f5f3be9 100644 --- a/builtin/game/chatcommands.lua +++ b/builtin/game/chatcommands.lua @@ -303,7 +303,7 @@ core.register_chatcommand("teleport", { p.y = tonumber(p.y) p.z = tonumber(p.z) if p.x and p.y and p.z then - local lm = tonumber(minetest.setting_get("map_generation_limit") or 31000) + local lm = 31000 if p.x < -lm or p.x > lm or p.y < -lm or p.y > lm or p.z < -lm or p.z > lm then return false, "Cannot teleport out of map bounds!" end diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index e63697f61..c9e0f7b87 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -893,13 +893,10 @@ water_level (Water level) int 1 # From how far blocks are generated for clients, stated in mapblocks (16 nodes). max_block_generate_distance (Max block generate distance) int 6 -# Where the map generator stops. -# Please note: -# - Limited to 31000 (setting above has no effect) -# - The map generator works in groups of 80x80x80 nodes (5x5x5 MapBlocks). -# - Those groups have an offset of -32, -32 nodes from the origin. -# - Only groups which are within the map_generation_limit are generated -map_generation_limit (Map generation limit) int 31000 0 31000 +# Limit of map generation, in nodes, in all 6 directions from (0, 0, 0). +# Only mapchunks completely within the mapgen limit are generated. +# Value is stored per-world. +mapgen_limit (Map generation limit) int 31000 0 31000 # Global map generation attributes. # In Mapgen v6 the 'decorations' flag controls all decorations except trees diff --git a/minetest.conf.example b/minetest.conf.example index 78488432f..a45a9948a 100644 --- a/minetest.conf.example +++ b/minetest.conf.example @@ -1092,14 +1092,11 @@ server_side_occlusion_culling = true # type: int # max_block_generate_distance = 6 -# Where the map generator stops. -# Please note: -# - Limited to 31000 (setting above has no effect) -# - The map generator works in groups of 80x80x80 nodes (5x5x5 MapBlocks). -# - Those groups have an offset of -32, -32 nodes from the origin. -# - Only groups which are within the map_generation_limit are generated +# Limit of map generation, in nodes, in all 6 directions from (0, 0, 0). +# Only mapchunks completely within the mapgen limit are generated. +# Value is stored per-world. # type: int min: 0 max: 31000 -# map_generation_limit = 31000 +# mapgen_limit = 31000 # Global map generation attributes. # In Mapgen v6 the 'decorations' flag controls all decorations except trees diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index 5b66c583a..4b50b991b 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -333,10 +333,10 @@ void set_default_settings(Settings *settings) // Mapgen settings->setDefault("mg_name", "v7"); settings->setDefault("water_level", "1"); + settings->setDefault("mapgen_limit", "31000"); settings->setDefault("chunksize", "5"); settings->setDefault("mg_flags", "dungeons"); settings->setDefault("fixed_map_seed", ""); - settings->setDefault("map_generation_limit", "31000"); settings->setDefault("max_block_generate_distance", "7"); settings->setDefault("enable_mapgen_debug_info", "false"); diff --git a/src/map.cpp b/src/map.cpp index 504760d09..b690ea3b3 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -1367,6 +1367,19 @@ s16 ServerMap::getWaterLevel() return getMapgenParams()->water_level; } +bool ServerMap::blockpos_over_mapgen_limit(v3s16 p) +{ + const s16 mapgen_limit_bp = rangelim( + getMapgenParams()->mapgen_limit, 0, MAX_MAP_GENERATION_LIMIT) / + MAP_BLOCKSIZE; + return p.X < -mapgen_limit_bp || + p.X > mapgen_limit_bp || + p.Y < -mapgen_limit_bp || + p.Y > mapgen_limit_bp || + p.Z < -mapgen_limit_bp || + p.Z > mapgen_limit_bp; +} + bool ServerMap::initBlockMake(v3s16 blockpos, BlockMakeData *data) { s16 csize = getMapgenParams()->chunksize; diff --git a/src/map.h b/src/map.h index aeb05c704..ea8dc76d1 100644 --- a/src/map.h +++ b/src/map.h @@ -379,6 +379,7 @@ public: /* Blocks are generated by using these and makeBlock(). */ + bool blockpos_over_mapgen_limit(v3s16 p); bool initBlockMake(v3s16 blockpos, BlockMakeData *data); void finishBlockMake(BlockMakeData *data, std::map *changed_blocks); diff --git a/src/mapblock.h b/src/mapblock.h index be2edc791..c48f337e0 100644 --- a/src/mapblock.h +++ b/src/mapblock.h @@ -32,6 +32,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "modifiedstate.h" #include "util/numeric.h" // getContainerPos #include "settings.h" +#include "mapgen.h" class Map; class NodeMetadataList; @@ -689,19 +690,6 @@ inline bool blockpos_over_max_limit(v3s16 p) p.Z > max_limit_bp; } -inline bool blockpos_over_mapgen_limit(v3s16 p) -{ - const s16 mapgen_limit_bp = rangelim( - g_settings->getS16("map_generation_limit"), 0, MAX_MAP_GENERATION_LIMIT) / - MAP_BLOCKSIZE; - return p.X < -mapgen_limit_bp || - p.X > mapgen_limit_bp || - p.Y < -mapgen_limit_bp || - p.Y > mapgen_limit_bp || - p.Z < -mapgen_limit_bp || - p.Z > mapgen_limit_bp; -} - /* Returns the position of the block where the node is located */ diff --git a/src/mapgen.cpp b/src/mapgen.cpp index a0b9990b7..6f3ea7cb0 100644 --- a/src/mapgen.cpp +++ b/src/mapgen.cpp @@ -97,11 +97,12 @@ STATIC_ASSERT( Mapgen::Mapgen() { - generating = false; - id = -1; - seed = 0; - water_level = 0; - flags = 0; + generating = false; + id = -1; + seed = 0; + water_level = 0; + mapgen_limit = 0; + flags = 0; vm = NULL; ndef = NULL; @@ -114,11 +115,12 @@ Mapgen::Mapgen() Mapgen::Mapgen(int mapgenid, MapgenParams *params, EmergeManager *emerge) : gennotify(emerge->gen_notify_on, &emerge->gen_notify_on_deco_ids) { - generating = false; - id = mapgenid; - water_level = params->water_level; - flags = params->flags; - csize = v3s16(1, 1, 1) * (params->chunksize * MAP_BLOCKSIZE); + generating = false; + id = mapgenid; + water_level = params->water_level; + mapgen_limit = params->mapgen_limit; + flags = params->flags; + csize = v3s16(1, 1, 1) * (params->chunksize * MAP_BLOCKSIZE); /* We are losing half our entropy by doing this, but it is necessary to @@ -1005,6 +1007,7 @@ void MapgenParams::readParams(const Settings *settings) this->mgtype = Mapgen::getMapgenType(mg_name); settings->getS16NoEx("water_level", water_level); + settings->getS16NoEx("mapgen_limit", mapgen_limit); settings->getS16NoEx("chunksize", chunksize); settings->getFlagStrNoEx("mg_flags", flags, flagdesc_mapgen); @@ -1022,6 +1025,7 @@ void MapgenParams::writeParams(Settings *settings) const settings->set("mg_name", Mapgen::getMapgenName(mgtype)); settings->setU64("seed", seed); settings->setS16("water_level", water_level); + settings->setS16("mapgen_limit", mapgen_limit); settings->setS16("chunksize", chunksize); settings->setFlagStr("mg_flags", flags, flagdesc_mapgen, U32_MAX); diff --git a/src/mapgen.h b/src/mapgen.h index 7aac1e6a0..c4e1652e8 100644 --- a/src/mapgen.h +++ b/src/mapgen.h @@ -124,6 +124,7 @@ struct MapgenParams { s16 chunksize; u64 seed; s16 water_level; + s16 mapgen_limit; u32 flags; BiomeParams *bparams; @@ -133,6 +134,7 @@ struct MapgenParams { chunksize(5), seed(0), water_level(1), + mapgen_limit(MAX_MAP_GENERATION_LIMIT), flags(MG_CAVES | MG_LIGHT | MG_DECORATIONS), bparams(NULL) { @@ -158,6 +160,7 @@ class Mapgen { public: s32 seed; int water_level; + int mapgen_limit; u32 flags; bool generating; int id; diff --git a/src/mapgen_valleys.cpp b/src/mapgen_valleys.cpp index ccf797eff..76a7a0582 100644 --- a/src/mapgen_valleys.cpp +++ b/src/mapgen_valleys.cpp @@ -70,9 +70,6 @@ MapgenValleys::MapgenValleys(int mapgenid, MapgenValleysParams *params, EmergeMa // NOTE: MapgenValleys has a hard dependency on BiomeGenOriginal this->m_bgen = (BiomeGenOriginal *)biomegen; - this->map_gen_limit = MYMIN(MAX_MAP_GENERATION_LIMIT, - g_settings->getU16("map_generation_limit")); - BiomeParamsOriginal *bp = (BiomeParamsOriginal *)params->bparams; this->spflags = params->spflags; @@ -621,7 +618,7 @@ void MapgenValleys::generateCaves(s16 max_stone_y, s16 large_cave_depth) const float massive_cave_threshold = 0.6f; // mct: 1 = small rare caves, 0.5 1/3rd ground volume, 0 = 1/2 ground volume. - float yblmin = -map_gen_limit + massive_cave_blend * 1.5f; + float yblmin = -mapgen_limit + massive_cave_blend * 1.5f; float yblmax = massive_cave_depth - massive_cave_blend * 1.5f; bool made_a_big_one = false; @@ -646,11 +643,11 @@ void MapgenValleys::generateCaves(s16 max_stone_y, s16 large_cave_depth) // lava_depth varies between one and ten as you approach // the bottom of the world. - s16 lava_depth = ceil((lava_max_height - node_min.Y + 1) * 10.f / map_gen_limit); + s16 lava_depth = ceil((lava_max_height - node_min.Y + 1) * 10.f / mapgen_limit); // This allows random lava spawns to be less common at the surface. s16 lava_chance = MYCUBE(lava_features_lim) * lava_depth; // water_depth varies between ten and one on the way down. - s16 water_depth = ceil((map_gen_limit - abs(node_min.Y) + 1) * 10.f / map_gen_limit); + s16 water_depth = ceil((mapgen_limit - abs(node_min.Y) + 1) * 10.f / mapgen_limit); // This allows random water spawns to be more common at the surface. s16 water_chance = MYCUBE(water_features_lim) * water_depth; diff --git a/src/mapgen_valleys.h b/src/mapgen_valleys.h index 6dd7ebc47..4a7a11bcc 100644 --- a/src/mapgen_valleys.h +++ b/src/mapgen_valleys.h @@ -101,8 +101,6 @@ public: private: BiomeGenOriginal *m_bgen; - float map_gen_limit; - bool humid_rivers; bool use_altitude_chill; float humidity_adjust;