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.
This commit is contained in:
paramat 2017-03-23 00:18:59 +00:00
parent 09f2cd0264
commit ec0c4d33db
11 changed files with 45 additions and 47 deletions

View File

@ -303,7 +303,7 @@ core.register_chatcommand("teleport", {
p.y = tonumber(p.y) p.y = tonumber(p.y)
p.z = tonumber(p.z) p.z = tonumber(p.z)
if p.x and p.y and p.z then 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 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!" return false, "Cannot teleport out of map bounds!"
end end

View File

@ -893,13 +893,10 @@ water_level (Water level) int 1
# From how far blocks are generated for clients, stated in mapblocks (16 nodes). # From how far blocks are generated for clients, stated in mapblocks (16 nodes).
max_block_generate_distance (Max block generate distance) int 6 max_block_generate_distance (Max block generate distance) int 6
# Where the map generator stops. # Limit of map generation, in nodes, in all 6 directions from (0, 0, 0).
# Please note: # Only mapchunks completely within the mapgen limit are generated.
# - Limited to 31000 (setting above has no effect) # Value is stored per-world.
# - The map generator works in groups of 80x80x80 nodes (5x5x5 MapBlocks). mapgen_limit (Map generation limit) int 31000 0 31000
# - 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
# Global map generation attributes. # Global map generation attributes.
# In Mapgen v6 the 'decorations' flag controls all decorations except trees # In Mapgen v6 the 'decorations' flag controls all decorations except trees

View File

@ -1092,14 +1092,11 @@ server_side_occlusion_culling = true
# type: int # type: int
# max_block_generate_distance = 6 # max_block_generate_distance = 6
# Where the map generator stops. # Limit of map generation, in nodes, in all 6 directions from (0, 0, 0).
# Please note: # Only mapchunks completely within the mapgen limit are generated.
# - Limited to 31000 (setting above has no effect) # Value is stored per-world.
# - 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
# type: int min: 0 max: 31000 # type: int min: 0 max: 31000
# map_generation_limit = 31000 # mapgen_limit = 31000
# Global map generation attributes. # Global map generation attributes.
# In Mapgen v6 the 'decorations' flag controls all decorations except trees # In Mapgen v6 the 'decorations' flag controls all decorations except trees

View File

@ -333,10 +333,10 @@ void set_default_settings(Settings *settings)
// Mapgen // Mapgen
settings->setDefault("mg_name", "v7"); settings->setDefault("mg_name", "v7");
settings->setDefault("water_level", "1"); settings->setDefault("water_level", "1");
settings->setDefault("mapgen_limit", "31000");
settings->setDefault("chunksize", "5"); settings->setDefault("chunksize", "5");
settings->setDefault("mg_flags", "dungeons"); settings->setDefault("mg_flags", "dungeons");
settings->setDefault("fixed_map_seed", ""); settings->setDefault("fixed_map_seed", "");
settings->setDefault("map_generation_limit", "31000");
settings->setDefault("max_block_generate_distance", "7"); settings->setDefault("max_block_generate_distance", "7");
settings->setDefault("enable_mapgen_debug_info", "false"); settings->setDefault("enable_mapgen_debug_info", "false");

View File

@ -1367,6 +1367,19 @@ s16 ServerMap::getWaterLevel()
return getMapgenParams()->water_level; 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) bool ServerMap::initBlockMake(v3s16 blockpos, BlockMakeData *data)
{ {
s16 csize = getMapgenParams()->chunksize; s16 csize = getMapgenParams()->chunksize;

View File

@ -379,6 +379,7 @@ public:
/* /*
Blocks are generated by using these and makeBlock(). Blocks are generated by using these and makeBlock().
*/ */
bool blockpos_over_mapgen_limit(v3s16 p);
bool initBlockMake(v3s16 blockpos, BlockMakeData *data); bool initBlockMake(v3s16 blockpos, BlockMakeData *data);
void finishBlockMake(BlockMakeData *data, void finishBlockMake(BlockMakeData *data,
std::map<v3s16, MapBlock*> *changed_blocks); std::map<v3s16, MapBlock*> *changed_blocks);

View File

@ -32,6 +32,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "modifiedstate.h" #include "modifiedstate.h"
#include "util/numeric.h" // getContainerPos #include "util/numeric.h" // getContainerPos
#include "settings.h" #include "settings.h"
#include "mapgen.h"
class Map; class Map;
class NodeMetadataList; class NodeMetadataList;
@ -689,19 +690,6 @@ inline bool blockpos_over_max_limit(v3s16 p)
p.Z > max_limit_bp; 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 Returns the position of the block where the node is located
*/ */

View File

@ -97,11 +97,12 @@ STATIC_ASSERT(
Mapgen::Mapgen() Mapgen::Mapgen()
{ {
generating = false; generating = false;
id = -1; id = -1;
seed = 0; seed = 0;
water_level = 0; water_level = 0;
flags = 0; mapgen_limit = 0;
flags = 0;
vm = NULL; vm = NULL;
ndef = NULL; ndef = NULL;
@ -114,11 +115,12 @@ Mapgen::Mapgen()
Mapgen::Mapgen(int mapgenid, MapgenParams *params, EmergeManager *emerge) : Mapgen::Mapgen(int mapgenid, MapgenParams *params, EmergeManager *emerge) :
gennotify(emerge->gen_notify_on, &emerge->gen_notify_on_deco_ids) gennotify(emerge->gen_notify_on, &emerge->gen_notify_on_deco_ids)
{ {
generating = false; generating = false;
id = mapgenid; id = mapgenid;
water_level = params->water_level; water_level = params->water_level;
flags = params->flags; mapgen_limit = params->mapgen_limit;
csize = v3s16(1, 1, 1) * (params->chunksize * MAP_BLOCKSIZE); 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 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); this->mgtype = Mapgen::getMapgenType(mg_name);
settings->getS16NoEx("water_level", water_level); settings->getS16NoEx("water_level", water_level);
settings->getS16NoEx("mapgen_limit", mapgen_limit);
settings->getS16NoEx("chunksize", chunksize); settings->getS16NoEx("chunksize", chunksize);
settings->getFlagStrNoEx("mg_flags", flags, flagdesc_mapgen); 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->set("mg_name", Mapgen::getMapgenName(mgtype));
settings->setU64("seed", seed); settings->setU64("seed", seed);
settings->setS16("water_level", water_level); settings->setS16("water_level", water_level);
settings->setS16("mapgen_limit", mapgen_limit);
settings->setS16("chunksize", chunksize); settings->setS16("chunksize", chunksize);
settings->setFlagStr("mg_flags", flags, flagdesc_mapgen, U32_MAX); settings->setFlagStr("mg_flags", flags, flagdesc_mapgen, U32_MAX);

View File

@ -124,6 +124,7 @@ struct MapgenParams {
s16 chunksize; s16 chunksize;
u64 seed; u64 seed;
s16 water_level; s16 water_level;
s16 mapgen_limit;
u32 flags; u32 flags;
BiomeParams *bparams; BiomeParams *bparams;
@ -133,6 +134,7 @@ struct MapgenParams {
chunksize(5), chunksize(5),
seed(0), seed(0),
water_level(1), water_level(1),
mapgen_limit(MAX_MAP_GENERATION_LIMIT),
flags(MG_CAVES | MG_LIGHT | MG_DECORATIONS), flags(MG_CAVES | MG_LIGHT | MG_DECORATIONS),
bparams(NULL) bparams(NULL)
{ {
@ -158,6 +160,7 @@ class Mapgen {
public: public:
s32 seed; s32 seed;
int water_level; int water_level;
int mapgen_limit;
u32 flags; u32 flags;
bool generating; bool generating;
int id; int id;

View File

@ -70,9 +70,6 @@ MapgenValleys::MapgenValleys(int mapgenid, MapgenValleysParams *params, EmergeMa
// NOTE: MapgenValleys has a hard dependency on BiomeGenOriginal // NOTE: MapgenValleys has a hard dependency on BiomeGenOriginal
this->m_bgen = (BiomeGenOriginal *)biomegen; 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; BiomeParamsOriginal *bp = (BiomeParamsOriginal *)params->bparams;
this->spflags = params->spflags; 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; const float massive_cave_threshold = 0.6f;
// mct: 1 = small rare caves, 0.5 1/3rd ground volume, 0 = 1/2 ground volume. // 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; float yblmax = massive_cave_depth - massive_cave_blend * 1.5f;
bool made_a_big_one = false; 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 // lava_depth varies between one and ten as you approach
// the bottom of the world. // 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. // This allows random lava spawns to be less common at the surface.
s16 lava_chance = MYCUBE(lava_features_lim) * lava_depth; s16 lava_chance = MYCUBE(lava_features_lim) * lava_depth;
// water_depth varies between ten and one on the way down. // 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. // This allows random water spawns to be more common at the surface.
s16 water_chance = MYCUBE(water_features_lim) * water_depth; s16 water_chance = MYCUBE(water_features_lim) * water_depth;

View File

@ -101,8 +101,6 @@ public:
private: private:
BiomeGenOriginal *m_bgen; BiomeGenOriginal *m_bgen;
float map_gen_limit;
bool humid_rivers; bool humid_rivers;
bool use_altitude_chill; bool use_altitude_chill;
float humidity_adjust; float humidity_adjust;