diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/environment.cpp | 9 | ||||
-rw-r--r-- | src/mapblock.h | 12 |
2 files changed, 21 insertions, 0 deletions
diff --git a/src/environment.cpp b/src/environment.cpp index eb599668b..0b3c0347d 100644 --- a/src/environment.cpp +++ b/src/environment.cpp @@ -1493,6 +1493,15 @@ u16 ServerEnvironment::addActiveObjectRaw(ServerActiveObject *object, delete object; return 0; } + + if (objectpos_over_limit(object->getBasePosition())) { + errorstream << "ServerEnvironment::addActiveObjectRaw(): " + << "object position outside maximum range" << std::endl; + if (object->environmentDeletes()) + delete object; + return 0; + } + /*infostream<<"ServerEnvironment::addActiveObjectRaw(): " <<"added (id="<<object->getId()<<")"<<std::endl;*/ diff --git a/src/mapblock.h b/src/mapblock.h index 197d58ec7..b2d5f98fa 100644 --- a/src/mapblock.h +++ b/src/mapblock.h @@ -637,6 +637,18 @@ private: typedef std::vector<MapBlock*> MapBlockVect; +inline bool objectpos_over_limit(v3f p) +{ + const static u16 map_gen_limit = MYMIN(MAX_MAP_GENERATION_LIMIT, + g_settings->getU16("map_generation_limit")); + return (p.X < -map_gen_limit + || p.X > map_gen_limit + || p.Y < -map_gen_limit + || p.Y > map_gen_limit + || p.Z < -map_gen_limit + || p.Z > map_gen_limit); +} + inline bool blockpos_over_limit(v3s16 p) { const static u16 map_gen_limit = MYMIN(MAX_MAP_GENERATION_LIMIT, |