From 79f19b8369a0120fbf0bd0ee3739989fbbbca50e Mon Sep 17 00:00:00 2001 From: Loïc Blot Date: Tue, 18 Jul 2017 21:39:55 +0200 Subject: [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 --- src/client.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/client.cpp') diff --git a/src/client.cpp b/src/client.cpp index 443059c36..39bb1e2ff 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -1361,8 +1361,22 @@ void Client::removeNode(v3s16 p) } } +/** + * Helper function for Client Side Modding + * Flavour is applied there, this should not be used for core engine + * @param p + * @param is_valid_position + * @return + */ MapNode Client::getNode(v3s16 p, bool *is_valid_position) { + if (checkCSMFlavourLimit(CSMFlavourLimit::CSM_FL_LOOKUP_NODES)) { + v3s16 ppos = floatToInt(m_env.getLocalPlayer()->getPosition(), BS); + if ((u32) ppos.getDistanceFrom(p) > m_csm_noderange_limit) { + *is_valid_position = false; + return MapNode(); + } + } return m_env.getMap().getNodeNoEx(p, is_valid_position); } -- cgit v1.2.3