diff options
Diffstat (limited to 'src/script/lua_api')
-rw-r--r-- | src/script/lua_api/l_client.cpp | 27 | ||||
-rw-r--r-- | src/script/lua_api/l_client.h | 3 | ||||
-rw-r--r-- | src/script/lua_api/l_env.cpp | 10 |
3 files changed, 22 insertions, 18 deletions
diff --git a/src/script/lua_api/l_client.cpp b/src/script/lua_api/l_client.cpp index e7d75cce7..6f9240466 100644 --- a/src/script/lua_api/l_client.cpp +++ b/src/script/lua_api/l_client.cpp @@ -91,6 +91,11 @@ int ModApiClient::l_send_chat_message(lua_State *L) { if (!lua_isstring(L, 1)) return 0; + + // If server disabled this API, discard + if (getClient(L)->checkCSMFlavourLimit(CSMFlavourLimit::CSM_FL_CHAT_MESSAGES)) + return 0; + std::string message = luaL_checkstring(L, 1); getClient(L)->sendChatMessage(utf8_to_wide(message)); return 0; @@ -166,24 +171,11 @@ int ModApiClient::l_gettext(lua_State *L) // get_node(pos) // pos = {x=num, y=num, z=num} -int ModApiClient::l_get_node(lua_State *L) -{ - // pos - v3s16 pos = read_v3s16(L, 1); - // Do it - bool pos_ok; - MapNode n = getClient(L)->getNode(pos, &pos_ok); - // Return node - pushnode(L, n, getClient(L)->ndef()); - return 1; -} - -// get_node_or_nil(pos) -// pos = {x=num, y=num, z=num} int ModApiClient::l_get_node_or_nil(lua_State *L) { // pos v3s16 pos = read_v3s16(L, 1); + // Do it bool pos_ok; MapNode n = getClient(L)->getNode(pos, &pos_ok); @@ -290,6 +282,9 @@ int ModApiClient::l_get_item_def(lua_State *L) IItemDefManager *idef = gdef->idef(); assert(idef); + if (getClient(L)->checkCSMFlavourLimit(CSMFlavourLimit::CSM_FL_READ_ITEMDEFS)) + return 0; + if (!lua_isstring(L, 1)) return 0; @@ -315,6 +310,9 @@ int ModApiClient::l_get_node_def(lua_State *L) if (!lua_isstring(L, 1)) return 0; + if (getClient(L)->checkCSMFlavourLimit(CSMFlavourLimit::CSM_FL_READ_NODEDEFS)) + return 0; + const std::string &name = lua_tostring(L, 1); const ContentFeatures &cf = ndef->get(ndef->getId(name)); if (cf.name != name) // Unknown node. | name = <whatever>, cf.name = ignore @@ -363,7 +361,6 @@ void ModApiClient::Initialize(lua_State *L, int top) API_FCT(show_formspec); API_FCT(send_respawn); API_FCT(gettext); - API_FCT(get_node); API_FCT(get_node_or_nil); API_FCT(get_wielded_item); API_FCT(disconnect); diff --git a/src/script/lua_api/l_client.h b/src/script/lua_api/l_client.h index 7472915f5..8a3c7f0e8 100644 --- a/src/script/lua_api/l_client.h +++ b/src/script/lua_api/l_client.h @@ -65,9 +65,6 @@ private: static int l_set_last_run_mod(lua_State *L); // get_node(pos) - static int l_get_node(lua_State *L); - - // get_node_or_nil(pos) static int l_get_node_or_nil(lua_State *L); // get_wielded_item() 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(); |