Rename CSM flavours to restrictions
authorSmallJoker <mk939@ymail.com>
Wed, 20 Jun 2018 20:36:08 +0000 (22:36 +0200)
committerSmallJoker <mk939@ymail.com>
Tue, 26 Jun 2018 13:38:42 +0000 (15:38 +0200)
& Satisfy LINT

13 files changed:
builtin/settingtypes.txt
src/client.cpp
src/client.h
src/defaultsettings.cpp
src/network/clientopcodes.cpp
src/network/clientpackethandler.cpp
src/network/networkprotocol.h
src/network/serveropcodes.cpp
src/network/serverpackethandler.cpp
src/script/lua_api/l_client.cpp
src/script/lua_api/l_env.cpp
src/server.cpp
src/server.h

index ce03725d239dc8f93689968e9fe07d709eeea4b7..0719dbf32ee680d96e32070fb6a1d2e31101591c 100644 (file)
@@ -115,7 +115,7 @@ safe_dig_and_place (Safe digging and placing) bool false
 #    Enable random user input (only used for testing).
 random_input (Random input) bool false
 
-#    Continuous forward movement, toggled by autoforward key. 
+#    Continuous forward movement, toggled by autoforward key.
 #    Press the autoforward key again or the backwards movement to disable.
 continuous_forward (Continuous forward) bool false
 
@@ -1134,13 +1134,12 @@ server_side_occlusion_culling (Server side occlusion culling) bool true
 #    CHAT_MESSAGES: 2 (disable send_chat_message call client-side)
 #    READ_ITEMDEFS: 4 (disable get_item_def call client-side)
 #    READ_NODEDEFS: 8 (disable get_node_def call client-side)
-#    LOOKUP_NODES_LIMIT: 16 (limits get_node call client-side to csm_flavour_noderange_limit)
-#    type: int
-csm_flavour_limits (Client side modding flavour limits) int 18
+#    LOOKUP_NODES_LIMIT: 16 (limits get_node call client-side to csm_restriction_noderange)
+csm_restriction_flags (Client side modding restrictions) int 18
 
-#   If the CSM flavour for node range is enabled, get_node is limited to
-#   this many nodes from the player.
-csm_flavour_noderange_limit (Client side noderange flavour limit) int 8
+#   If the CSM restriction for node range is enabled, get_node calls are limited
+#   to this distance from the player to the node.
+csm_restriction_noderange (Client side node lookup range restriction) int 8
 
 [*Security]
 
@@ -1246,7 +1245,7 @@ high_precision_fpu (High-precision FPU) bool true
 #    Changes the main menu UI:
 #    -   Full:  Multple singleplayer worlds, game choice, texture pack chooser, etc.
 #    -   Simple: One singleplayer world, no game or texture pack choosers. May be necessary for smaller screens.
-#    -   Auto: Simple on Android, full on everything else. 
+#    -   Auto: Simple on Android, full on everything else.
 main_menu_style (Main menu style) enum auto auto,full,simple
 
 #    Replaces the default main menu with a custom one.
index 09c67c2684a068d209f9a2c4e59263572c47bef4..049d35379aaeb6fd239de184418fdd846db8b7a6 100644 (file)
@@ -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 {};
                }
index 5c07d043e1dcc3bfb34baf8a817e37af6f403f79..423db870a65bc560f4f8f4facfa640f461a99c05 100644 (file)
@@ -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;
 };
index e3a4f94b032bfb02cbe4b505e21c4a302abd73de..1d1da5128e0d3a7294e1ad21a176b597c5559388 100644 (file)
@@ -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");
index 9962de46a2935d79a6f5c089d5186704f51a0507..923a92d32aebbd1739045ced0159c480cc2e1b8a 100644 (file)
@@ -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,
index bc1f18ae85c382251b3813e2bdd8a34a3d789884..f8be613177fb398c1ba954b68fdfee926eec7db8 100644 (file)
@@ -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();
 }
index 0a5701e59dcfcb417f5749f83038a3600189fae8..3d682a0ad11600751c2b31b5daa7441370b8bf60 100644 (file)
@@ -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,
 };
index 883ff9d106cb7f22908fb8f6c4e114b2019883f0..e4e313611225bf8bc74be0fc8f035dccc050a9dc 100644 (file)
@@ -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,
index bb5eed92b6cb96ba5d5f5c6f98861dd993266171..4647bcc042b615c6130afd5868d8b320f41bc973 100644 (file)
@@ -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) {
index 8e802d2a2fc9bfefe76d00ec44d7e6f37dc92d29..f70e65f0fb97d57d0ae3afb18b4a7f816d89b73e 100644 (file)
@@ -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));
index 2eb7f3395712afdcfc4ce67f86ff015da962cb72..246732a177163044b9d018a35f224cdbb8ad3b51 100644 (file)
@@ -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
index 09b3f2c4093c7dc24adedec756e05d3be9a83a7e..753c71701139d02a01543a8f990064a39dbfb9f7 100644 (file)
@@ -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);
 }
 
index c51686650c731aa8ba6a2aac076cce85865dcacb..8ac61aaad56ac407abf6a49373681cad6786cea9 100644 (file)
@@ -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;