From 6c81be51ffd26ec7dee1ecb887a8743a8b6a6ce4 Mon Sep 17 00:00:00 2001 From: est31 Date: Wed, 16 Sep 2015 16:12:59 +0200 Subject: [PATCH] Fix object position border checking Borders have to be converted into BS format in order to be accurately comparable to object positions. --- src/environment.cpp | 4 +++- src/mapblock.h | 16 ++++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/environment.cpp b/src/environment.cpp index 0b3c0347d..6877c2460 100644 --- a/src/environment.cpp +++ b/src/environment.cpp @@ -1495,8 +1495,10 @@ u16 ServerEnvironment::addActiveObjectRaw(ServerActiveObject *object, } if (objectpos_over_limit(object->getBasePosition())) { + v3f p = object->getBasePosition(); errorstream << "ServerEnvironment::addActiveObjectRaw(): " - << "object position outside maximum range" << std::endl; + << "object position (" << p.X << "," << p.Y << "," << p.Z + << ") outside maximum range" << std::endl; if (object->environmentDeletes()) delete object; return 0; diff --git a/src/mapblock.h b/src/mapblock.h index b2d5f98fa..73c17ee60 100644 --- a/src/mapblock.h +++ b/src/mapblock.h @@ -639,14 +639,14 @@ typedef std::vector 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); + 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); } inline bool blockpos_over_limit(v3s16 p) -- 2.25.1