diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/client.cpp | 11 | ||||
-rw-r--r-- | src/client.h | 16 | ||||
-rw-r--r-- | src/defaultsettings.cpp | 4 | ||||
-rw-r--r-- | src/network/clientopcodes.cpp | 2 | ||||
-rw-r--r-- | src/network/clientpackethandler.cpp | 6 | ||||
-rw-r--r-- | src/network/networkprotocol.h | 22 | ||||
-rw-r--r-- | src/network/serveropcodes.cpp | 2 | ||||
-rw-r--r-- | src/network/serverpackethandler.cpp | 2 | ||||
-rw-r--r-- | src/script/lua_api/l_client.cpp | 16 | ||||
-rw-r--r-- | src/script/lua_api/l_env.cpp | 3 | ||||
-rw-r--r-- | src/server.cpp | 12 | ||||
-rw-r--r-- | src/server.h | 8 |
12 files changed, 58 insertions, 46 deletions
diff --git a/src/client.cpp b/src/client.cpp index 09c67c268..049d35379 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -130,13 +130,14 @@ void Client::loadMods() return; } - // If modding is not enabled or flavour disable it, don't load mods, just builtin + // If modding is not enabled or CSM restrictions disable it + // don't load CSM mods, only builtin if (!m_modding_enabled) { warningstream << "Client side mods are disabled by configuration." << std::endl; return; } - if (checkCSMFlavourLimit(CSMFlavourLimit::CSM_FL_LOAD_CLIENT_MODS)) { + if (checkCSMRestrictionFlag(CSMRestrictionFlags::CSM_RF_LOAD_CLIENT_MODS)) { warningstream << "Client side mods are disabled by server." << std::endl; // If mods loading is disabled and builtin integrity is wrong, disconnect user. if (!checkBuiltinIntegrity()) { @@ -1282,16 +1283,16 @@ void Client::removeNode(v3s16 p) /** * Helper function for Client Side Modding - * Flavour is applied there, this should not be used for core engine + * CSM restrictions are 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)) { + if (checkCSMRestrictionFlag(CSMRestrictionFlags::CSM_RF_LOOKUP_NODES)) { v3s16 ppos = floatToInt(m_env.getLocalPlayer()->getPosition(), BS); - if ((u32) ppos.getDistanceFrom(p) > m_csm_noderange_limit) { + if ((u32) ppos.getDistanceFrom(p) > m_csm_restriction_noderange) { *is_valid_position = false; return {}; } diff --git a/src/client.h b/src/client.h index 5c07d043e..423db870a 100644 --- a/src/client.h +++ b/src/client.h @@ -226,7 +226,7 @@ public: void handleCommand_ModChannelSignal(NetworkPacket *pkt); void handleCommand_SrpBytesSandB(NetworkPacket *pkt); void handleCommand_FormspecPrepend(NetworkPacket *pkt); - void handleCommand_CSMFlavourLimits(NetworkPacket *pkt); + void handleCommand_CSMRestrictionFlags(NetworkPacket *pkt); void ProcessData(NetworkPacket *pkt); @@ -261,7 +261,7 @@ public: /** * Helper function for Client Side Modding - * Flavour is applied there, this should not be used for core engine + * CSM restrictions are applied there, this should not be used for core engine * @param p * @param is_valid_position * @return @@ -412,14 +412,14 @@ public: return m_address_name; } - inline bool checkCSMFlavourLimit(CSMFlavourLimit flag) const + inline bool checkCSMRestrictionFlag(CSMRestrictionFlags flag) const { - return m_csm_flavour_limits & flag; + return m_csm_restriction_flags & flag; } u32 getCSMNodeRangeLimit() const { - return m_csm_noderange_limit; + return m_csm_restriction_noderange; } inline std::unordered_map<u32, u32> &getHUDTranslationMap() @@ -600,9 +600,9 @@ private: bool m_shutdown = false; - // CSM flavour limits byteflag - u64 m_csm_flavour_limits = CSMFlavourLimit::CSM_FL_NONE; - u32 m_csm_noderange_limit = 8; + // CSM restrictions byteflag + u64 m_csm_restriction_flags = CSMRestrictionFlags::CSM_RF_NONE; + u32 m_csm_restriction_noderange = 8; std::unique_ptr<ModChannelMgr> m_modchannel_mgr; }; diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index e3a4f94b0..1d1da5128 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -332,8 +332,8 @@ void set_default_settings(Settings *settings) settings->setDefault("max_block_send_distance", "9"); settings->setDefault("block_send_optimize_distance", "4"); settings->setDefault("server_side_occlusion_culling", "true"); - settings->setDefault("csm_flavour_limits", "18"); - settings->setDefault("csm_flavour_noderange_limit", "8"); + settings->setDefault("csm_restriction_flags", "18"); + settings->setDefault("csm_restriction_noderange", "8"); settings->setDefault("max_clearobjects_extra_loaded_blocks", "4096"); settings->setDefault("time_speed", "72"); settings->setDefault("world_start_time", "5250"); diff --git a/src/network/clientopcodes.cpp b/src/network/clientopcodes.cpp index 9962de46a..923a92d32 100644 --- a/src/network/clientopcodes.cpp +++ b/src/network/clientopcodes.cpp @@ -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 - { "TOCLIENT_CSM_FLAVOUR_LIMITS", TOCLIENT_STATE_CONNECTED, &Client::handleCommand_CSMFlavourLimits }, // 0x2A + { "TOCLIENT_CSM_RESTRICTION_FLAGS", TOCLIENT_STATE_CONNECTED, &Client::handleCommand_CSMRestrictionFlags }, // 0x2A null_command_handler, null_command_handler, null_command_handler, diff --git a/src/network/clientpackethandler.cpp b/src/network/clientpackethandler.cpp index bc1f18ae8..f8be61317 100644 --- a/src/network/clientpackethandler.cpp +++ b/src/network/clientpackethandler.cpp @@ -1333,11 +1333,11 @@ void Client::handleCommand_FormspecPrepend(NetworkPacket *pkt) *pkt >> player->formspec_prepend; } -void Client::handleCommand_CSMFlavourLimits(NetworkPacket *pkt) +void Client::handleCommand_CSMRestrictionFlags(NetworkPacket *pkt) { - *pkt >> m_csm_flavour_limits >> m_csm_noderange_limit; + *pkt >> m_csm_restriction_flags >> m_csm_restriction_noderange; - // Now we have flavours, load mods if it's enabled + // Restrictions were received -> load mods if it's enabled // Note: this should be moved after mods receptions from server instead loadMods(); } diff --git a/src/network/networkprotocol.h b/src/network/networkprotocol.h index 0a5701e59..3d682a0ad 100644 --- a/src/network/networkprotocol.h +++ b/src/network/networkprotocol.h @@ -169,7 +169,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 + Add TOCLIENT_CSM_RESTRICTION_FLAGS to define which CSM features should be limited Add settable player collisionbox. Breaks compatibility with older clients as a 1-node vertical offset has been removed from player's @@ -283,9 +283,9 @@ enum ToClientCommand f1000 time_speed */ - TOCLIENT_CSM_FLAVOUR_LIMITS = 0x2A, + TOCLIENT_CSM_RESTRICTION_FLAGS = 0x2A, /* - u32 CSMFlavourLimits byteflag + u32 CSMRestrictionFlags byteflag */ // (oops, there is some gap here) @@ -928,12 +928,12 @@ enum PlayerListModifer: u8 PLAYER_LIST_REMOVE, }; -enum CSMFlavourLimit : u64 { - CSM_FL_NONE = 0x00000000, - CSM_FL_LOAD_CLIENT_MODS = 0x00000001, // Disable mods provided by clients - 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_LOOKUP_NODES = 0x00000010, // Limit node lookups - CSM_FL_ALL = 0xFFFFFFFF, +enum CSMRestrictionFlags : u64 { + CSM_RF_NONE = 0x00000000, + CSM_RF_LOAD_CLIENT_MODS = 0x00000001, // Disable mods provided by clients + CSM_RF_CHAT_MESSAGES = 0x00000002, // Disable chat message sending from CSM + CSM_RF_READ_ITEMDEFS = 0x00000004, // Disable itemdef lookups + CSM_RF_READ_NODEDEFS = 0x00000008, // Disable nodedef lookups + CSM_RF_LOOKUP_NODES = 0x00000010, // Limit node lookups + CSM_RF_ALL = 0xFFFFFFFF, }; diff --git a/src/network/serveropcodes.cpp b/src/network/serveropcodes.cpp index 883ff9d10..e4e313611 100644 --- a/src/network/serveropcodes.cpp +++ b/src/network/serveropcodes.cpp @@ -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 - { "TOCLIENT_CSM_FLAVOUR_LIMITS", 0, true }, // 0x2A + { "TOCLIENT_CSM_RESTRICTION_FLAGS", 0, true }, // 0x2A null_command_factory, null_command_factory, null_command_factory, diff --git a/src/network/serverpackethandler.cpp b/src/network/serverpackethandler.cpp index bb5eed92b..4647bcc04 100644 --- a/src/network/serverpackethandler.cpp +++ b/src/network/serverpackethandler.cpp @@ -320,7 +320,7 @@ void Server::handleCommand_Init2(NetworkPacket* pkt) float time_speed = g_settings->getFloat("time_speed"); SendTimeOfDay(pkt->getPeerId(), time, time_speed); - SendCSMFlavourLimits(pkt->getPeerId()); + SendCSMRestrictionFlags(pkt->getPeerId()); // Warnings about protocol version can be issued here if (getClient(pkt->getPeerId())->net_proto_version < LATEST_PROTOCOL_VERSION) { diff --git a/src/script/lua_api/l_client.cpp b/src/script/lua_api/l_client.cpp index 8e802d2a2..f70e65f0f 100644 --- a/src/script/lua_api/l_client.cpp +++ b/src/script/lua_api/l_client.cpp @@ -94,8 +94,12 @@ int ModApiClient::l_send_chat_message(lua_State *L) return 0; // If server disabled this API, discard - if (getClient(L)->checkCSMFlavourLimit(CSMFlavourLimit::CSM_FL_CHAT_MESSAGES)) + + // clang-format off + if (getClient(L)->checkCSMRestrictionFlag( + CSMRestrictionFlags::CSM_RF_CHAT_MESSAGES)) return 0; + // clang-format on std::string message = luaL_checkstring(L, 1); getClient(L)->sendChatMessage(utf8_to_wide(message)); @@ -290,8 +294,11 @@ int ModApiClient::l_get_item_def(lua_State *L) IItemDefManager *idef = gdef->idef(); assert(idef); - if (getClient(L)->checkCSMFlavourLimit(CSMFlavourLimit::CSM_FL_READ_ITEMDEFS)) + // clang-format off + if (getClient(L)->checkCSMRestrictionFlag( + CSMRestrictionFlags::CSM_RF_READ_ITEMDEFS)) return 0; + // clang-format on if (!lua_isstring(L, 1)) return 0; @@ -318,8 +325,11 @@ 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)) + // clang-format off + if (getClient(L)->checkCSMRestrictionFlag( + CSMRestrictionFlags::CSM_RF_READ_NODEDEFS)) return 0; + // clang-format on const std::string &name = lua_tostring(L, 1); const ContentFeatures &cf = ndef->get(ndef->getId(name)); diff --git a/src/script/lua_api/l_env.cpp b/src/script/lua_api/l_env.cpp index 2eb7f3395..246732a17 100644 --- a/src/script/lua_api/l_env.cpp +++ b/src/script/lua_api/l_env.cpp @@ -770,7 +770,8 @@ int ModApiEnvMod::l_find_node_near(lua_State *L) #ifndef SERVER // Client API limitations if (getClient(L) && - getClient(L)->checkCSMFlavourLimit(CSMFlavourLimit::CSM_FL_LOOKUP_NODES)) { + getClient(L)->checkCSMRestrictionFlag( + CSMRestrictionFlags::CSM_RF_LOOKUP_NODES)) { radius = std::max<int>(radius, getClient(L)->getCSMNodeRangeLimit()); } #endif diff --git a/src/server.cpp b/src/server.cpp index 09b3f2c40..753c71701 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -401,8 +401,8 @@ void Server::init() m_liquid_transform_every = g_settings->getFloat("liquid_update"); m_max_chatmessage_length = g_settings->getU16("chat_message_max_size"); - m_csm_flavour_limits = g_settings->getU64("csm_flavour_limits"); - m_csm_noderange_limit = g_settings->getU32("csm_flavour_noderange_limit"); + m_csm_restriction_flags = g_settings->getU64("csm_restriction_flags"); + m_csm_restriction_noderange = g_settings->getU32("csm_restriction_noderange"); } void Server::start() @@ -1934,11 +1934,11 @@ void Server::SendActiveObjectMessages(session_t peer_id, const std::string &data &pkt, reliable); } -void Server::SendCSMFlavourLimits(session_t peer_id) +void Server::SendCSMRestrictionFlags(session_t peer_id) { - NetworkPacket pkt(TOCLIENT_CSM_FLAVOUR_LIMITS, - sizeof(m_csm_flavour_limits) + sizeof(m_csm_noderange_limit), peer_id); - pkt << m_csm_flavour_limits << m_csm_noderange_limit; + NetworkPacket pkt(TOCLIENT_CSM_RESTRICTION_FLAGS, + sizeof(m_csm_restriction_flags) + sizeof(m_csm_restriction_noderange), peer_id); + pkt << m_csm_restriction_flags << m_csm_restriction_noderange; Send(&pkt); } diff --git a/src/server.h b/src/server.h index c51686650..8ac61aaad 100644 --- a/src/server.h +++ b/src/server.h @@ -462,7 +462,7 @@ private: u32 SendActiveObjectRemoveAdd(session_t peer_id, const std::string &datas); void SendActiveObjectMessages(session_t peer_id, const std::string &datas, bool reliable = true); - void SendCSMFlavourLimits(session_t peer_id); + void SendCSMRestrictionFlags(session_t peer_id); /* Something random @@ -650,9 +650,9 @@ private: std::unordered_map<std::string, ModMetadata *> m_mod_storages; float m_mod_storage_save_timer = 10.0f; - // CSM flavour limits byteflag - u64 m_csm_flavour_limits = CSMFlavourLimit::CSM_FL_NONE; - u32 m_csm_noderange_limit = 8; + // CSM restrictions byteflag + u64 m_csm_restriction_flags = CSMRestrictionFlags::CSM_RF_NONE; + u32 m_csm_restriction_noderange = 8; // ModChannel manager std::unique_ptr<ModChannelMgr> m_modchannel_mgr; |