Fix object position border checking
authorest31 <MTest31@outlook.com>
Wed, 16 Sep 2015 14:12:59 +0000 (16:12 +0200)
committerest31 <MTest31@outlook.com>
Wed, 16 Sep 2015 15:39:49 +0000 (17:39 +0200)
Borders have to be converted into BS format in order to be accurately comparable to
object positions.

src/environment.cpp
src/mapblock.h

index 0b3c0347d56ed5d89be54efd8d4c0f8a41a1b7f5..6877c2460e010643551a37bd3870ea28842dddb2 100644 (file)
@@ -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;
index b2d5f98faa633742b20d39727605cca95da62cdd..73c17ee601f6c7b9bf16a3a4983e0160001c8205 100644 (file)
@@ -639,14 +639,14 @@ 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);
+       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)