aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2011-05-24 20:03:19 +0300
committerPerttu Ahola <celeron55@gmail.com>2011-05-24 20:03:19 +0300
commitab02f0aa1b852391db89a1384f5c7271271196a5 (patch)
tree95c4df9cabee8d5c9304cf556858e8f5a75e09d2
parente1a2b8f600ff9845ecff0f06c85d4d2c29970414 (diff)
downloadminetest-ab02f0aa1b852391db89a1384f5c7271271196a5.tar.gz
minetest-ab02f0aa1b852391db89a1384f5c7271271196a5.tar.bz2
minetest-ab02f0aa1b852391db89a1384f5c7271271196a5.zip
Added a check that avoids server crash (unhandled exception) when map generation is attempted near limit
-rw-r--r--src/map.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/map.cpp b/src/map.cpp
index c681a24b7..a49de3c46 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -3586,7 +3586,18 @@ void ServerMap::initChunkMake(ChunkMakeData &data, v2s16 chunkpos)
sectorpos_base - v2s16(1,1) * max_spread_amount_sectors;
s16 sectorpos_bigbase_size =
sectorpos_base_size + 2 * max_spread_amount_sectors;
-
+
+ // Check limits
+ const s16 limit = MAP_GENERATION_LIMIT / MAP_BLOCKSIZE;
+ if(sectorpos_bigbase.X < -limit
+ || sectorpos_bigbase.X + sectorpos_bigbase_size >= limit
+ || sectorpos_bigbase.Y < -limit
+ || sectorpos_bigbase.Y + sectorpos_bigbase_size >= limit)
+ {
+ data.no_op = true;
+ return;
+ }
+
data.seed = m_seed;
data.chunkpos = chunkpos;
data.y_blocks_min = y_blocks_min;