From f61f817b9c170942a5b3ce3591125c2191645cd0 Mon Sep 17 00:00:00 2001 From: est31 Date: Tue, 15 Sep 2015 18:37:58 +0200 Subject: Disallow placing entities outside safe boundaries Entity positions are serialized as F1000. Disallow placing entities outside safe borders with the minetest.add_entity call. Note that this patch only enforces those boundaries for placing entities, moving entities that move outside boundaries aren't affected. Thanks to @nanepiwo for pointing this out. --- src/mapblock.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/mapblock.h') 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 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, -- cgit v1.2.3