summaryrefslogtreecommitdiff
path: root/src/environment.cpp
diff options
context:
space:
mode:
authorest31 <MTest31@outlook.com>2015-09-15 18:37:58 +0200
committerest31 <MTest31@outlook.com>2015-09-15 19:45:17 +0200
commitf61f817b9c170942a5b3ce3591125c2191645cd0 (patch)
treecb8ff32f6bcfbbc6e26b1142e144216c752aedf1 /src/environment.cpp
parent8e9c9e305aecdb5b432c0990fef85fa6ff3c042b (diff)
downloadminetest-f61f817b9c170942a5b3ce3591125c2191645cd0.tar.gz
minetest-f61f817b9c170942a5b3ce3591125c2191645cd0.tar.bz2
minetest-f61f817b9c170942a5b3ce3591125c2191645cd0.zip
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.
Diffstat (limited to 'src/environment.cpp')
-rw-r--r--src/environment.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/environment.cpp b/src/environment.cpp
index eb599668b..0b3c0347d 100644
--- a/src/environment.cpp
+++ b/src/environment.cpp
@@ -1493,6 +1493,15 @@ u16 ServerEnvironment::addActiveObjectRaw(ServerActiveObject *object,
delete object;
return 0;
}
+
+ if (objectpos_over_limit(object->getBasePosition())) {
+ errorstream << "ServerEnvironment::addActiveObjectRaw(): "
+ << "object position outside maximum range" << std::endl;
+ if (object->environmentDeletes())
+ delete object;
+ return 0;
+ }
+
/*infostream<<"ServerEnvironment::addActiveObjectRaw(): "
<<"added (id="<<object->getId()<<")"<<std::endl;*/