mirror of https://github.com/minetest/minetest.git
Enable generation of non-cubic maps
Changes map_generation_limit configuration setting and associated functions to use V3S16 type. Updates minetest.conf.example: changes commentary on "map_generation_limit" to explain new functionality Updates defaultsettings.cpp: changes default setting format Updates map.cpp: changes operation of over-limit check to support new setting format Updates mapblock.h: changes operation of in-line functions "objectpos_over_limit()" and "blockpos_over_limit()" to support new setting format Updates settings.cpp and settings.h: adds new functions for getting/setting V3U16 (and V3S16), to facilitate the new setting. Adds new function "getMapGenerationLimit()" which supports different types.
This commit is contained in:
parent
f062bbd7a1
commit
8da804d03e
|
@ -559,13 +559,15 @@
|
|||
# From how far blocks are generated for clients, stated in mapblocks (16 nodes)
|
||||
#max_block_generate_distance = 6
|
||||
|
||||
# Where the map generator stops.
|
||||
# Where the map generator stops, in node distance from zero (per axis, in each direction)
|
||||
# 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 = 31000
|
||||
# * The map generator works in groups of chunksize mapblocks, default 5 (80x80x80 nodes)
|
||||
# * Only chunks which are entirely within the map_generation_limit are generated
|
||||
#map_generation_limit = (31000,31000,31000)
|
||||
# Can also be set with a single value, which will be generalized to all six axis directions
|
||||
# * The example setting below is the same as the one above;
|
||||
#map_generation_limit = 31000
|
||||
|
||||
# Number of extra blocks that can be loaded by /clearobjects at once.
|
||||
# This is a trade-off between sqlite transaction overhead and
|
||||
|
|
|
@ -94,7 +94,7 @@ void set_default_settings(Settings *settings)
|
|||
// A bit more than the server will send around the player, to make fog blend well
|
||||
settings->setDefault("viewing_range_nodes_max", "240");
|
||||
settings->setDefault("viewing_range_nodes_min", "35");
|
||||
settings->setDefault("map_generation_limit", "31000");
|
||||
settings->setDefault("map_generation_limit", "(31000,31000,31000)");
|
||||
settings->setDefault("screenW", "800");
|
||||
settings->setDefault("screenH", "600");
|
||||
settings->setDefault("fullscreen", "false");
|
||||
|
|
14
src/map.cpp
14
src/map.cpp
|
@ -2573,12 +2573,14 @@ ServerMapSector * ServerMap::createSector(v2s16 p2d)
|
|||
/*
|
||||
Do not create over-limit
|
||||
*/
|
||||
const static u16 map_gen_limit = MYMIN(MAX_MAP_GENERATION_LIMIT,
|
||||
g_settings->getU16("map_generation_limit"));
|
||||
if(p2d.X < -map_gen_limit / MAP_BLOCKSIZE
|
||||
|| p2d.X > map_gen_limit / MAP_BLOCKSIZE
|
||||
|| p2d.Y < -map_gen_limit / MAP_BLOCKSIZE
|
||||
|| p2d.Y > map_gen_limit / MAP_BLOCKSIZE)
|
||||
const static v3s16 map_gen_limit = g_settings->getMapGenerationLimit();
|
||||
|
||||
const static s16 map_gen_limit_x = MYMIN(MAX_MAP_GENERATION_LIMIT, map_gen_limit.X);
|
||||
const static s16 map_gen_limit_z = MYMIN(MAX_MAP_GENERATION_LIMIT, map_gen_limit.Z);
|
||||
if (p2d.X < -map_gen_limit_x / MAP_BLOCKSIZE
|
||||
|| p2d.X > map_gen_limit_x / MAP_BLOCKSIZE
|
||||
|| p2d.Y < -map_gen_limit_z / MAP_BLOCKSIZE
|
||||
|| p2d.Y > map_gen_limit_z / MAP_BLOCKSIZE)
|
||||
throw InvalidPositionException("createSector(): pos. over limit");
|
||||
|
||||
/*
|
||||
|
|
|
@ -639,26 +639,32 @@ typedef std::vector<MapBlock*> MapBlockVect;
|
|||
|
||||
inline bool objectpos_over_limit(v3f p)
|
||||
{
|
||||
const static float map_gen_limit_bs = MYMIN(MAX_MAP_GENERATION_LIMIT,
|
||||
g_settings->getU16("map_generation_limit")) * BS;
|
||||
return (p.X < -map_gen_limit_bs
|
||||
|| p.X > map_gen_limit_bs
|
||||
|| p.Y < -map_gen_limit_bs
|
||||
|| p.Y > map_gen_limit_bs
|
||||
|| p.Z < -map_gen_limit_bs
|
||||
|| p.Z > map_gen_limit_bs);
|
||||
const static v3s16 map_gen_limit = g_settings->getMapGenerationLimit();
|
||||
|
||||
const static float map_gen_limit_x_bs = MYMIN(MAX_MAP_GENERATION_LIMIT, map_gen_limit.X) * BS;
|
||||
const static float map_gen_limit_y_bs = MYMIN(MAX_MAP_GENERATION_LIMIT, map_gen_limit.Y) * BS;
|
||||
const static float map_gen_limit_z_bs = MYMIN(MAX_MAP_GENERATION_LIMIT, map_gen_limit.Z) * BS;
|
||||
return (p.X < -map_gen_limit_x_bs
|
||||
|| p.X > map_gen_limit_x_bs
|
||||
|| p.Y < -map_gen_limit_y_bs
|
||||
|| p.Y > map_gen_limit_y_bs
|
||||
|| p.Z < -map_gen_limit_z_bs
|
||||
|| p.Z > map_gen_limit_z_bs);
|
||||
}
|
||||
|
||||
inline bool blockpos_over_limit(v3s16 p)
|
||||
{
|
||||
const static u16 map_gen_limit = MYMIN(MAX_MAP_GENERATION_LIMIT,
|
||||
g_settings->getU16("map_generation_limit"));
|
||||
return (p.X < -map_gen_limit / MAP_BLOCKSIZE
|
||||
|| p.X > map_gen_limit / MAP_BLOCKSIZE
|
||||
|| p.Y < -map_gen_limit / MAP_BLOCKSIZE
|
||||
|| p.Y > map_gen_limit / MAP_BLOCKSIZE
|
||||
|| p.Z < -map_gen_limit / MAP_BLOCKSIZE
|
||||
|| p.Z > map_gen_limit / MAP_BLOCKSIZE);
|
||||
const static v3s16 map_gen_limit = g_settings->getMapGenerationLimit();
|
||||
|
||||
const static s16 map_gen_limit_x = MYMIN(MAX_MAP_GENERATION_LIMIT, map_gen_limit.X);
|
||||
const static s16 map_gen_limit_y = MYMIN(MAX_MAP_GENERATION_LIMIT, map_gen_limit.Y);
|
||||
const static s16 map_gen_limit_z = MYMIN(MAX_MAP_GENERATION_LIMIT, map_gen_limit.Z);
|
||||
return (p.X < -map_gen_limit_x / MAP_BLOCKSIZE
|
||||
|| p.X > map_gen_limit_x / MAP_BLOCKSIZE
|
||||
|| p.Y < -map_gen_limit_y / MAP_BLOCKSIZE
|
||||
|| p.Y > map_gen_limit_y / MAP_BLOCKSIZE
|
||||
|| p.Z < -map_gen_limit_z / MAP_BLOCKSIZE
|
||||
|| p.Z > map_gen_limit_z / MAP_BLOCKSIZE);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -426,6 +426,32 @@ s16 Settings::getS16(const std::string &name) const
|
|||
}
|
||||
|
||||
|
||||
v3s16 Settings::getV3S16(const std::string &name) const
|
||||
{
|
||||
v3s16 value;
|
||||
Strfnd f(get(name));
|
||||
f.next("(");
|
||||
value.X = stoi(f.next(","), -32768, 32767);
|
||||
value.Y = stoi(f.next(","), -32768, 32767);
|
||||
value.Z = stoi(f.next(")"), -32768, 32767);
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
v3s16 Settings::getMapGenerationLimit() const
|
||||
{
|
||||
v3s16 mgl;
|
||||
if (get("map_generation_limit").find("(")==std::string::npos){
|
||||
mgl.X = getS16("map_generation_limit");
|
||||
mgl.Y = mgl.X;
|
||||
mgl.Z = mgl.X;
|
||||
return mgl;
|
||||
}
|
||||
mgl = getV3S16("map_generation_limit");
|
||||
return mgl;
|
||||
}
|
||||
|
||||
|
||||
s32 Settings::getS32(const std::string &name) const
|
||||
{
|
||||
return stoi(get(name));
|
||||
|
@ -662,6 +688,17 @@ bool Settings::getS16NoEx(const std::string &name, s16 &val) const
|
|||
}
|
||||
|
||||
|
||||
bool Settings::getV3S16NoEx(const std::string &name, v3s16 &val) const
|
||||
{
|
||||
try {
|
||||
val = getV3S16(name);
|
||||
return true;
|
||||
} catch (SettingNotFoundException &e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool Settings::getS32NoEx(const std::string &name, s32 &val) const
|
||||
{
|
||||
try {
|
||||
|
@ -798,6 +835,14 @@ bool Settings::setS16(const std::string &name, s16 value)
|
|||
}
|
||||
|
||||
|
||||
bool Settings::setV3S16(const std::string &name, v3s16 value)
|
||||
{
|
||||
std::ostringstream os;
|
||||
os << "(" << value.X << "," << value.Y << "," << value.Z << ")";
|
||||
return set(name, os.str());
|
||||
}
|
||||
|
||||
|
||||
bool Settings::setU16(const std::string &name, u16 value)
|
||||
{
|
||||
return set(name, itos(value));
|
||||
|
|
|
@ -134,6 +134,8 @@ public:
|
|||
bool getBool(const std::string &name) const;
|
||||
u16 getU16(const std::string &name) const;
|
||||
s16 getS16(const std::string &name) const;
|
||||
v3s16 getV3S16(const std::string &name) const;
|
||||
v3s16 getMapGenerationLimit() const;
|
||||
s32 getS32(const std::string &name) const;
|
||||
u64 getU64(const std::string &name) const;
|
||||
float getFloat(const std::string &name) const;
|
||||
|
@ -164,6 +166,7 @@ public:
|
|||
bool getFlag(const std::string &name) const;
|
||||
bool getU16NoEx(const std::string &name, u16 &val) const;
|
||||
bool getS16NoEx(const std::string &name, s16 &val) const;
|
||||
bool getV3S16NoEx(const std::string &name, v3s16 &val) const;
|
||||
bool getS32NoEx(const std::string &name, s32 &val) const;
|
||||
bool getU64NoEx(const std::string &name, u64 &val) const;
|
||||
bool getFloatNoEx(const std::string &name, float &val) const;
|
||||
|
@ -189,6 +192,7 @@ public:
|
|||
bool setGroupDefault(const std::string &name, Settings *group);
|
||||
bool setBool(const std::string &name, bool value);
|
||||
bool setS16(const std::string &name, s16 value);
|
||||
bool setV3S16(const std::string &name, v3s16 value);
|
||||
bool setU16(const std::string &name, u16 value);
|
||||
bool setS32(const std::string &name, s32 value);
|
||||
bool setU64(const std::string &name, u64 value);
|
||||
|
|
Loading…
Reference in New Issue