summaryrefslogtreecommitdiff
path: root/src/script/lua_api/l_env.cpp
diff options
context:
space:
mode:
authorLoïc Blot <nerzhul@users.noreply.github.com>2017-07-18 21:39:55 +0200
committerGitHub <noreply@github.com>2017-07-18 21:39:55 +0200
commit79f19b8369a0120fbf0bd0ee3739989fbbbca50e (patch)
tree0051cde3efe56d35d03aa50a5095d9b8ba04d15b /src/script/lua_api/l_env.cpp
parent7e3cdf7088b1fb6744d0bd9cc903823b6e3bbfe3 (diff)
downloadminetest-79f19b8369a0120fbf0bd0ee3739989fbbbca50e.tar.gz
minetest-79f19b8369a0120fbf0bd0ee3739989fbbbca50e.tar.bz2
minetest-79f19b8369a0120fbf0bd0ee3739989fbbbca50e.zip
[CSM] Add flavour limits controlled by server (#5930)
* [CSM] Add flavour limits controlled by server Server send flavour limits to client permitting to disable or limit some Lua calls * Add limits for reading nodedefs and itemdefs * flavour: Add lookup node limits * Merge get_node_or_nil into get_node. Sending fake node doesn't make sense in CSM, just return nil if node is not available for any reason * Add node range customization when noderange flavour is enabled (default 8 nodes) * Limit nodes range & disable chat message sending by default * Bump protocol version
Diffstat (limited to 'src/script/lua_api/l_env.cpp')
-rw-r--r--src/script/lua_api/l_env.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/script/lua_api/l_env.cpp b/src/script/lua_api/l_env.cpp
index 3a4ba89f3..2a57ca59b 100644
--- a/src/script/lua_api/l_env.cpp
+++ b/src/script/lua_api/l_env.cpp
@@ -25,6 +25,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "lua_api/l_vmanip.h"
#include "common/c_converter.h"
#include "common/c_content.h"
+#include <algorithm>
#include "scripting_server.h"
#include "environment.h"
#include "server.h"
@@ -726,6 +727,15 @@ int ModApiEnvMod::l_find_node_near(lua_State *L)
}
int start_radius = (lua_toboolean(L, 4)) ? 0 : 1;
+
+#ifndef SERVER
+ // Client API limitations
+ if (getClient(L) &&
+ getClient(L)->checkCSMFlavourLimit(CSMFlavourLimit::CSM_FL_LOOKUP_NODES)) {
+ radius = std::max<int>(radius, getClient(L)->getCSMNodeRangeLimit());
+ }
+#endif
+
for (int d = start_radius; d <= radius; d++) {
std::vector<v3s16> list = FacePositionCache::getFacePositions(d);
for (std::vector<v3s16>::iterator i = list.begin();