mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-11 17:51:04 +00:00
[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
This commit is contained in:
parent
7e3cdf7088
commit
79f19b8369
18 changed files with 136 additions and 29 deletions
|
@ -66,7 +66,7 @@ const ToClientCommandHandler toClientCommandTable[TOCLIENT_NUM_MSG_TYPES] =
|
|||
{ "TOCLIENT_INVENTORY", TOCLIENT_STATE_CONNECTED, &Client::handleCommand_Inventory }, // 0x27
|
||||
null_command_handler,
|
||||
{ "TOCLIENT_TIME_OF_DAY", TOCLIENT_STATE_CONNECTED, &Client::handleCommand_TimeOfDay }, // 0x29
|
||||
null_command_handler,
|
||||
{ "TOCLIENT_CSM_FLAVOUR_LIMITS", TOCLIENT_STATE_CONNECTED, &Client::handleCommand_CSMFlavourLimits }, // 0x2A
|
||||
null_command_handler,
|
||||
null_command_handler,
|
||||
null_command_handler,
|
||||
|
|
|
@ -1376,3 +1376,8 @@ void Client::handleCommand_SrpBytesSandB(NetworkPacket* pkt)
|
|||
resp_pkt << std::string(bytes_M, len_M);
|
||||
Send(&resp_pkt);
|
||||
}
|
||||
|
||||
void Client::handleCommand_CSMFlavourLimits(NetworkPacket *pkt)
|
||||
{
|
||||
*pkt >> m_csm_flavour_limits >> m_csm_noderange_limit;
|
||||
}
|
||||
|
|
|
@ -17,8 +17,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#ifndef NETWORKPROTOCOL_HEADER
|
||||
#define NETWORKPROTOCOL_HEADER
|
||||
#pragma once
|
||||
|
||||
#include "util/string.h"
|
||||
|
||||
/*
|
||||
|
@ -168,6 +168,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
* sender
|
||||
* type (RAW, NORMAL, ANNOUNCE, SYSTEM)
|
||||
* content
|
||||
Add TOCLIENT_CSM_FLAVOUR_LIMITS to define which CSM flavour should be limited
|
||||
*/
|
||||
|
||||
#define LATEST_PROTOCOL_VERSION 35
|
||||
|
@ -313,6 +314,11 @@ enum ToClientCommand
|
|||
f1000 time_speed
|
||||
*/
|
||||
|
||||
TOCLIENT_CSM_FLAVOUR_LIMITS = 0x2A,
|
||||
/*
|
||||
u32 CSMFlavourLimits byteflag
|
||||
*/
|
||||
|
||||
// (oops, there is some gap here)
|
||||
|
||||
TOCLIENT_CHAT_MESSAGE = 0x2F,
|
||||
|
@ -1003,5 +1009,12 @@ enum PlayerListModifer: u8
|
|||
PLAYER_LIST_REMOVE,
|
||||
};
|
||||
|
||||
enum CSMFlavourLimit : u64 {
|
||||
CSM_FL_NONE = 0x00000000,
|
||||
CSM_FL_LOOKUP_NODES = 0x00000001, // Limit node lookups
|
||||
CSM_FL_CHAT_MESSAGES = 0x00000002, // Disable chat message sending from CSM
|
||||
CSM_FL_READ_ITEMDEFS = 0x00000004, // Disable itemdef lookups
|
||||
CSM_FL_READ_NODEDEFS = 0x00000008, // Disable nodedef lookups
|
||||
CSM_FL_ALL = 0xFFFFFFFF,
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -155,7 +155,7 @@ const ClientCommandFactory clientCommandFactoryTable[TOCLIENT_NUM_MSG_TYPES] =
|
|||
{ "TOCLIENT_INVENTORY", 0, true }, // 0x27
|
||||
null_command_factory,
|
||||
{ "TOCLIENT_TIME_OF_DAY", 0, true }, // 0x29
|
||||
null_command_factory,
|
||||
{ "TOCLIENT_CSM_FLAVOUR_LIMITS", 0, true }, // 0x2A
|
||||
null_command_factory,
|
||||
null_command_factory,
|
||||
null_command_factory,
|
||||
|
|
|
@ -643,6 +643,8 @@ void Server::handleCommand_Init2(NetworkPacket* pkt)
|
|||
float time_speed = g_settings->getFloat("time_speed");
|
||||
SendTimeOfDay(pkt->getPeerId(), time, time_speed);
|
||||
|
||||
SendCSMFlavourLimits(pkt->getPeerId());
|
||||
|
||||
// Warnings about protocol version can be issued here
|
||||
if (getClient(pkt->getPeerId())->net_proto_version < LATEST_PROTOCOL_VERSION) {
|
||||
SendChatMessage(pkt->getPeerId(), ChatMessage(CHATMESSAGE_TYPE_SYSTEM,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue