diff options
Diffstat (limited to 'src/mapblock.h')
-rw-r--r-- | src/mapblock.h | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/src/mapblock.h b/src/mapblock.h index c737b4c37..d46b7b880 100644 --- a/src/mapblock.h +++ b/src/mapblock.h @@ -656,23 +656,34 @@ inline bool objectpos_over_limit(v3f p) 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.X > map_gen_limit_bs || p.Y < -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); + || p.Z > map_gen_limit_bs); } +/* + We are checking for any node of the mapblock being beyond the limit. + + At the negative limit we are checking for + block minimum nodepos < -mapgenlimit. + At the positive limit we are checking for + block maximum nodepos > mapgenlimit. + + Block minimum nodepos = blockpos * mapblocksize. + Block maximum nodepos = (blockpos + 1) * mapblocksize - 1. +*/ inline bool blockpos_over_limit(v3s16 p) { const static u16 map_gen_limit = MYMIN(MAX_MAP_GENERATION_LIMIT, g_settings->getU16("map_generation_limit")); - return (p.X < -map_gen_limit / MAP_BLOCKSIZE - || p.X > map_gen_limit / MAP_BLOCKSIZE - || p.Y < -map_gen_limit / MAP_BLOCKSIZE - || p.Y > map_gen_limit / MAP_BLOCKSIZE - || p.Z < -map_gen_limit / MAP_BLOCKSIZE - || p.Z > map_gen_limit / MAP_BLOCKSIZE); + return (p.X * MAP_BLOCKSIZE < -map_gen_limit + || (p.X + 1) * MAP_BLOCKSIZE - 1 > map_gen_limit + || p.Y * MAP_BLOCKSIZE < -map_gen_limit + || (p.Y + 1) * MAP_BLOCKSIZE - 1 > map_gen_limit + || p.Z * MAP_BLOCKSIZE < -map_gen_limit + || (p.Z + 1) * MAP_BLOCKSIZE - 1 > map_gen_limit); } /* |