mirror of
https://github.com/luanti-org/luanti.git
synced 2025-07-02 16:38:41 +00:00
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.
This commit is contained in:
parent
8e9c9e305a
commit
f61f817b9c
2 changed files with 21 additions and 0 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue