diff options
author | paramat <mat.gregory@virginmedia.com> | 2017-03-23 00:18:59 +0000 |
---|---|---|
committer | paramat <mat.gregory@virginmedia.com> | 2017-03-27 03:18:09 +0100 |
commit | ec0c4d33db9e0b7b3e541757e34c04c08c3b48c9 (patch) | |
tree | a1d31e46b60906c71c9aa29a0588d6016b63f6d3 /src | |
parent | 09f2cd0264993e7b81d84d77bfc670b40ef82444 (diff) | |
download | minetest-ec0c4d33db9e0b7b3e541757e34c04c08c3b48c9.tar.gz minetest-ec0c4d33db9e0b7b3e541757e34c04c08c3b48c9.tar.bz2 minetest-ec0c4d33db9e0b7b3e541757e34c04c08c3b48c9.zip |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/defaultsettings.cpp | 2 | ||||
-rw-r--r-- | src/map.cpp | 13 | ||||
-rw-r--r-- | src/map.h | 1 | ||||
-rw-r--r-- | src/mapblock.h | 14 | ||||
-rw-r--r-- | src/mapgen.cpp | 24 | ||||
-rw-r--r-- | src/mapgen.h | 3 | ||||
-rw-r--r-- | src/mapgen_valleys.cpp | 9 | ||||
-rw-r--r-- | src/mapgen_valleys.h | 2 |
8 files changed, 36 insertions, 32 deletions
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; @@ -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<v3s16, MapBlock*> *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; |