From: Perttu Ahola Date: Mon, 14 Feb 2011 23:02:31 +0000 (+0200) Subject: server now won't crash when it is tries to generate blocks that are not inside MAP_GE... X-Git-Tag: 0.2.20110731_3~371 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=2684e620b5fe5d8c3e22c01b3d2f55b260f65501;p=oweals%2Fminetest.git server now won't crash when it is tries to generate blocks that are not inside MAP_GENERATION_LIMIT --- diff --git a/src/map.cpp b/src/map.cpp index 184d89b9c..f4f1668c7 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -4412,6 +4412,17 @@ MapBlock * ServerMap::createBlock(v3s16 p) DSTACK("%s: p=(%d,%d,%d)", __FUNCTION_NAME, p.X, p.Y, p.Z); + /* + 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) + throw InvalidPositionException("createBlock(): pos. over limit"); + v2s16 p2d(p.X, p.Z); s16 block_y = p.Y; /* @@ -4426,17 +4437,22 @@ MapBlock * ServerMap::createBlock(v3s16 p) sector = (ServerMapSector*)createSector(p2d); assert(sector->getId() == MAPSECTOR_SERVER); } - /*catch(InvalidPositionException &e) + catch(InvalidPositionException &e) { dstream<<"createBlock: createSector() failed"< 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) + throw InvalidPositionException("generateBlock(): pos. over limit"); + v2s16 p2d(p.X, p.Z); s16 block_y = p.Y; /* @@ -4472,7 +4499,7 @@ MapBlock * ServerMap::emergeBlock( sector = (ServerMapSector*)emergeSector(p2d, changed_blocks); assert(sector->getId() == MAPSECTOR_SERVER); } - catch(std::exception &e) + catch(InvalidPositionException &e) { dstream<<"emergeBlock: emergeSector() failed: " <