Skip to content
Permalink
Browse files

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.
  • Loading branch information...
paramat committed Mar 23, 2017
1 parent 09f2cd0 commit ec0c4d33db9e0b7b3e541757e34c04c08c3b48c9
Showing with 45 additions and 47 deletions.
  1. +1 −1 builtin/game/chatcommands.lua
  2. +4 −7 builtin/settingtypes.txt
  3. +4 −7 minetest.conf.example
  4. +1 −1 src/defaultsettings.cpp
  5. +13 −0 src/map.cpp
  6. +1 −0 src/map.h
  7. +1 −13 src/mapblock.h
  8. +14 −10 src/mapgen.cpp
  9. +3 −0 src/mapgen.h
  10. +3 −6 src/mapgen_valleys.cpp
  11. +0 −2 src/mapgen_valleys.h
@@ -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
@@ -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
@@ -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
@@ -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");

@@ -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 @@ class ServerMap : public Map
/*
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);
@@ -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
*/
@@ -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);

@@ -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;
@@ -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;

@@ -101,8 +101,6 @@ class MapgenValleys : public MapgenBasic {
private:
BiomeGenOriginal *m_bgen;

float map_gen_limit;

bool humid_rivers;
bool use_altitude_chill;
float humidity_adjust;

0 comments on commit ec0c4d3

Please sign in to comment.
You can’t perform that action at this time.