Add map limit config option
authorrubenwardy <rubenwardy@gmail.com>
Mon, 13 Jul 2015 15:01:31 +0000 (16:01 +0100)
committerest31 <MTest31@outlook.com>
Sun, 2 Aug 2015 12:27:04 +0000 (14:27 +0200)
minetest.conf.example
src/clientiface.cpp
src/constants.h
src/defaultsettings.cpp
src/map.cpp
src/mapblock.h
src/mapgen.cpp
src/mapgen_v5.cpp
src/mapgen_v6.cpp
src/mapgen_v7.cpp
src/mg_biome.cpp

index b9e7d59e4a2359df5b072aa823905eccc41cc078..f4b9057005e51f22e9df2cbc0b8841d0484754d8 100644 (file)
 #max_block_send_distance = 10
 #    From how far blocks are generated for clients, stated in mapblocks (16 nodes)
 #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
+#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
 #    memory consumption (4096=100MB, as a rule of thumb).
 #    Comma-separated list of trusted mods that are allowed to access insecure
 #    functions even when mod security is on (via request_insecure_environment()).
 #secure.trusted_mods =
-
index 6944e56db756c63e754795d2cf391cdc5d9dbb9d..3330e0af916e1690e90c14304cc5ef70b8b08c9d 100644 (file)
@@ -209,25 +209,19 @@ void RemoteClient::GetNextBlocks (
                                max_simul_dynamic = max_simul_sends_setting;
 
                        // Don't select too many blocks for sending
-                       if(num_blocks_selected >= max_simul_dynamic)
-                       {
+                       if (num_blocks_selected >= max_simul_dynamic) {
                                //queue_is_full = true;
                                goto queue_full_break;
                        }
 
                        // Don't send blocks that are currently being transferred
-                       if(m_blocks_sending.find(p) != m_blocks_sending.end())
+                       if (m_blocks_sending.find(p) != m_blocks_sending.end())
                                continue;
 
                        /*
                                Do not go over-limit
                        */
-                       if(p.X < -MAP_GENERATION_LIMIT / MAP_BLOCKSIZE
-                       || p.X > MAP_GENERATION_LIMIT / MAP_BLOCKSIZE
-                       || p.Y < -MAP_GENERATION_LIMIT / MAP_BLOCKSIZE
-                       || p.Y > MAP_GENERATION_LIMIT / MAP_BLOCKSIZE
-                       || p.Z < -MAP_GENERATION_LIMIT / MAP_BLOCKSIZE
-                       || p.Z > MAP_GENERATION_LIMIT / MAP_BLOCKSIZE)
+                       if (blockpos_over_limit(p))
                                continue;
 
                        // If this is true, inexistent block will be made from scratch
@@ -239,7 +233,7 @@ void RemoteClient::GetNextBlocks (
                                        generate = false;*/
 
                                // Limit the send area vertically to 1/2
-                               if(abs(p.Y - center.Y) > full_d_max / 2)
+                               if (abs(p.Y - center.Y) > full_d_max / 2)
                                        continue;
                        }
 
index 22cadc5a81642823fce0e2f6ef2b67eee253079c..b606fc4fa114282da0894f17f01a075d6bc774db 100644 (file)
@@ -64,7 +64,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 // The absolute working limit is (2^15 - viewing_range).
 // I really don't want to make every algorithm to check if it's going near
 // the limit or not, so this is lower.
-#define MAP_GENERATION_LIMIT (31000)
+// This is the maximum value the setting map_generation_limit can be
+#define MAX_MAP_GENERATION_LIMIT (31000)
 
 // Size of node in floating-point units
 // The original idea behind this is to disallow plain casts between
@@ -116,4 +117,3 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #define DEFAULT_FONT_SIZE       (10)
 
 #endif
-
index 42c6175139f6db0c9beb93e3f34ff9036447bfd2..4674b2b77fb7c23a0f613d66c17e1869abeec175 100644 (file)
@@ -94,6 +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("screenW", "800");
        settings->setDefault("screenH", "600");
        settings->setDefault("fullscreen", "false");
index 9974ff363a7aa5f520e9df961a45ffecd58a0e0e..50b50220db23fdaaeaa42c9d91e54c86f72c4b57 100644 (file)
@@ -2502,10 +2502,12 @@ ServerMapSector * ServerMap::createSector(v2s16 p2d)
        /*
                Do not create over-limit
        */
-       if(p2d.X < -MAP_GENERATION_LIMIT / MAP_BLOCKSIZE
-       || p2d.X > MAP_GENERATION_LIMIT / MAP_BLOCKSIZE
-       || p2d.Y < -MAP_GENERATION_LIMIT / MAP_BLOCKSIZE
-       || p2d.Y > MAP_GENERATION_LIMIT / MAP_BLOCKSIZE)
+       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)
                throw InvalidPositionException("createSector(): pos. over limit");
 
        /*
@@ -2649,12 +2651,7 @@ MapBlock * ServerMap::createBlock(v3s16 p)
        /*
                Do not create over-limit
        */
-       if(p.X < -MAP_GENERATION_LIMIT / MAP_BLOCKSIZE
-       || p.X > MAP_GENERATION_LIMIT / MAP_BLOCKSIZE
-       || p.Y < -MAP_GENERATION_LIMIT / MAP_BLOCKSIZE
-       || p.Y > MAP_GENERATION_LIMIT / MAP_BLOCKSIZE
-       || p.Z < -MAP_GENERATION_LIMIT / MAP_BLOCKSIZE
-       || p.Z > MAP_GENERATION_LIMIT / MAP_BLOCKSIZE)
+       if (blockpos_over_limit(p))
                throw InvalidPositionException("createBlock(): pos. over limit");
 
        v2s16 p2d(p.X, p.Z);
index ba33c01a2eef145f24803241c795de1f31d3ea56..334136b92f0f442d404a144d23c4ce18781ee34f 100644 (file)
@@ -31,6 +31,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "nodetimer.h"
 #include "modifiedstate.h"
 #include "util/numeric.h" // getContainerPos
+#include "settings.h"
 
 class Map;
 class NodeMetadataList;
@@ -638,13 +639,14 @@ typedef std::vector<MapBlock*> MapBlockVect;
 
 inline bool blockpos_over_limit(v3s16 p)
 {
-       return
-         (p.X < -MAP_GENERATION_LIMIT / MAP_BLOCKSIZE
-       || p.X >  MAP_GENERATION_LIMIT / MAP_BLOCKSIZE
-       || p.Y < -MAP_GENERATION_LIMIT / MAP_BLOCKSIZE
-       || p.Y >  MAP_GENERATION_LIMIT / MAP_BLOCKSIZE
-       || p.Z < -MAP_GENERATION_LIMIT / MAP_BLOCKSIZE
-       || p.Z >  MAP_GENERATION_LIMIT / MAP_BLOCKSIZE);
+       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);
 }
 
 /*
@@ -681,4 +683,3 @@ inline void getNodeSectorPosWithOffset(const v2s16 &p, v2s16 &block, v2s16 &offs
 std::string analyze_block(MapBlock *block);
 
 #endif
-
index 7f7c4e2409f46cd24fd07fca44e85db2a9b9a4e1..1843e953da70f1e3e878f4360fec5995f19d986a 100644 (file)
@@ -143,7 +143,7 @@ s16 Mapgen::findGroundLevelFull(v2s16 p2d)
 }
 
 
-// Returns -MAP_GENERATION_LIMIT if not found
+// Returns -MAX_MAP_GENERATION_LIMIT if not found
 s16 Mapgen::findGroundLevel(v2s16 p2d, s16 ymin, s16 ymax)
 {
        v3s16 em = vm->m_area.getExtent();
@@ -157,7 +157,7 @@ s16 Mapgen::findGroundLevel(v2s16 p2d, s16 ymin, s16 ymax)
 
                vm->m_area.add_y(em, i, -1);
        }
-       return (y >= ymin) ? y : -MAP_GENERATION_LIMIT;
+       return (y >= ymin) ? y : -MAX_MAP_GENERATION_LIMIT;
 }
 
 
@@ -475,4 +475,3 @@ void MapgenParams::save(Settings &settings) const
        if (sparams)
                sparams->writeParams(&settings);
 }
-
index f23dad4ecb635e2d58dca0c118f657998f3ae404..5b842a99edd72cc4104e0c93cb4cffac26d91891 100644 (file)
@@ -370,7 +370,7 @@ int MapgenV5::generateBaseTerrain()
 {
        u32 index = 0;
        u32 index2d = 0;
-       int stone_surface_max_y = -MAP_GENERATION_LIMIT;
+       int stone_surface_max_y = -MAX_MAP_GENERATION_LIMIT;
 
        for (s16 z=node_min.Z; z<=node_max.Z; z++) {
                for (s16 y=node_min.Y - 1; y<=node_max.Y + 1; y++) {
@@ -585,4 +585,3 @@ void MapgenV5::dustTopNodes()
                }
        }
 }
-
index 09acec7837215954be54dcbf16f0ca6e26801230..9e34aac2d741faa54ea54a15c8e3c116a818985b 100644 (file)
@@ -626,7 +626,7 @@ int MapgenV6::generateGround()
        MapNode n_air(CONTENT_AIR), n_water_source(c_water_source);
        MapNode n_stone(c_stone), n_desert_stone(c_desert_stone);
        MapNode n_ice(c_ice);
-       int stone_surface_max_y = -MAP_GENERATION_LIMIT;
+       int stone_surface_max_y = -MAX_MAP_GENERATION_LIMIT;
 
        u32 index = 0;
        for (s16 z = node_min.Z; z <= node_max.Z; z++)
index e499ebb81c1fdee78a59241c60a012208b0d938c..9f612de81c004e97beb48738d1dbd8b3c21abef3 100644 (file)
@@ -505,8 +505,8 @@ void MapgenV7::generateBaseTerrain(s16 *stone_surface_min_y, s16 *stone_surface_
        MapNode n_water(c_water_source);
 
        v3s16 em = vm->m_area.getExtent();
-       s16 surface_min_y = MAP_GENERATION_LIMIT;
-       s16 surface_max_y = -MAP_GENERATION_LIMIT;
+       s16 surface_min_y = MAX_MAP_GENERATION_LIMIT;
+       s16 surface_max_y = -MAX_MAP_GENERATION_LIMIT;
        u32 index = 0;
 
        for (s16 z = node_min.Z; z <= node_max.Z; z++)
@@ -885,4 +885,3 @@ void MapgenV7::generateCaves(s16 max_stone_y)
                cave.makeCave(node_min, node_max, max_stone_y);
        }
 }
-
index 1944aa12f0c062030a63400d1f23ff7eed881566..a21d99b171033bed4baee603708d3761e468e8e3 100644 (file)
@@ -45,8 +45,8 @@ BiomeManager::BiomeManager(IGameDef *gamedef) :
        b->depth_top       = 0;
        b->depth_filler    = 0;
        b->depth_water_top = 0;
-       b->y_min           = -MAP_GENERATION_LIMIT;
-       b->y_max           = MAP_GENERATION_LIMIT;
+       b->y_min           = -MAX_MAP_GENERATION_LIMIT;
+       b->y_max           = MAX_MAP_GENERATION_LIMIT;
        b->heat_point      = 0.0;
        b->humidity_point  = 0.0;
 
@@ -140,4 +140,3 @@ void Biome::resolveNodeNames()
        getIdFromNrBacklog(&c_river_water, "mapgen_river_water_source", CONTENT_AIR);
        getIdFromNrBacklog(&c_dust,        "air",                       CONTENT_IGNORE);
 }
-