CSM: Revert "[CSM] Add send_chat_message and run_server_chatcommand"
authorrubenwardy <rw@rubenwardy.com>
Sun, 2 Jul 2017 19:25:22 +0000 (20:25 +0100)
committerparamat <mat.gregory@virginmedia.com>
Sat, 15 Jul 2017 00:35:18 +0000 (01:35 +0100)
Original PR: #5747.
This reverts commit 39f4a2f607d44738d60db84eba4b30e3d7450204.

builtin/client/chatcommands.lua
builtin/settingtypes.txt
doc/client_lua_api.md
minetest.conf.example
src/client.cpp
src/client.h
src/defaultsettings.cpp
src/script/lua_api/l_client.cpp
src/script/lua_api/l_client.h

index ed43a6140355956e44ff826e9cf0bd3a892250d8..20f98a293f9ed9b24a3a15070389717691d81612 100644 (file)
@@ -51,15 +51,3 @@ core.register_chatcommand("disconnect", {
                core.disconnect()
        end,
 })
-
-core.register_chatcommand("clear_chat_queue", {
-       description = core.gettext("Clear the out chat queue"),
-       func = function(param)
-               core.clear_out_chat_queue()
-               return true, core.gettext("The out chat queue is now empty")
-       end,
-})
-
-function core.run_server_chatcommand(cmd, param)
-       core.send_chat_message("/" .. cmd .. " " .. param)
-end
index 3f9163be9dae2052eb971269003e0101717d5e1b..8243ea79409824b33f7dfd1d3955f19437220897 100644 (file)
@@ -315,9 +315,6 @@ serverlist_url (Serverlist URL) string servers.minetest.net
 #    File in client/serverlist/ that contains your favorite servers displayed in the Multiplayer Tab.
 serverlist_file (Serverlist file) string favoriteservers.txt
 
-#    Maximum size of the out chat queue. 0 to disable queueing and -1 to make the queue size unlimited
-max_out_chat_queue_size (Maximum size of the out chat queue) int 20
-
 [*Graphics]
 
 [**In-Game]
index 3bd1e35671008f08a61fd3139464a78e1f0065fc..e2841dac118b9650555f897d71bcd6d670070fc0 100644 (file)
@@ -721,12 +721,6 @@ Call these functions only at load time!
 ### Player
 * `minetest.get_wielded_item()`
     * Returns the itemstack the local player is holding
-* `minetest.send_chat_message(message)`
-    * Act as if `message` was typed by the player into the terminal.
-* `minetest.run_server_chatcommand(cmd, param)`
-    * Alias for `minetest.send_chat_message("/" .. cmd .. " " .. param)`
-* `minetest.clear_out_chat_queue()`
-    * Clears the out chat queue
 * `minetest.localplayer`
     * Reference to the LocalPlayer object. See [`LocalPlayer`](#localplayer) class reference for methods.
 
index d0dce0ed83b1939f8c7c2b15ab11f5840aafae75..e09532be53cea58ea3627873aa245747aa3cf064 100644 (file)
 #    type: string
 # serverlist_file = favoriteservers.txt
 
-#    Maximum size of the out chat queue. 0 to disable queueing and -1 to make the queue size unlimited
-#    type: int
-# max_out_chat_queue_size = 20
-
 ## Graphics
 
 ### In-Game
index 0f689a7145971eb08797caf45a5a26cd391bce5b..d0c90b108d9062708f7a0f3126d935c842da0546 100644 (file)
@@ -83,7 +83,6 @@ Client::Client(
        m_con(PROTOCOL_ID, 512, CONNECTION_TIMEOUT, ipv6, this),
        m_address_name(address_name),
        m_server_ser_ver(SER_FMT_VER_INVALID),
-       m_last_chat_message_sent(time(NULL)),
        m_password(password),
        m_chosen_auth_mech(AUTH_MECHANISM_NONE),
        m_media_downloader(new ClientMediaDownloader()),
@@ -388,14 +387,6 @@ void Client::step(float dtime)
                }
        }
 
-       /*
-               Send pending messages on out chat queue
-       */
-       if (!m_out_chat_queue.empty() && canSendChatMessage()) {
-               sendChatMessage(m_out_chat_queue.front());
-               m_out_chat_queue.pop();
-       }
-
        /*
                Handle environment
        */
@@ -1152,50 +1143,13 @@ void Client::sendInventoryAction(InventoryAction *a)
        Send(&pkt);
 }
 
-bool Client::canSendChatMessage() const
-{
-       u32 now = time(NULL);
-       float time_passed = now - m_last_chat_message_sent;
-
-       float virt_chat_message_allowance = m_chat_message_allowance + time_passed *
-                       (CLIENT_CHAT_MESSAGE_LIMIT_PER_10S / 8.0f);
-
-       if (virt_chat_message_allowance < 1.0f)
-               return false;
-
-       return true;
-}
-
 void Client::sendChatMessage(const std::wstring &message)
 {
-       const s16 max_queue_size = g_settings->getS16("max_out_chat_queue_size");
-       if (canSendChatMessage()) {
-               u32 now = time(NULL);
-               float time_passed = now - m_last_chat_message_sent;
-               m_last_chat_message_sent = time(NULL);
-
-               m_chat_message_allowance += time_passed * (CLIENT_CHAT_MESSAGE_LIMIT_PER_10S / 8.0f);
-               if (m_chat_message_allowance > CLIENT_CHAT_MESSAGE_LIMIT_PER_10S)
-                       m_chat_message_allowance = CLIENT_CHAT_MESSAGE_LIMIT_PER_10S;
-
-               m_chat_message_allowance -= 1.0f;
+       NetworkPacket pkt(TOSERVER_CHAT_MESSAGE, 2 + message.size() * sizeof(u16));
 
-               NetworkPacket pkt(TOSERVER_CHAT_MESSAGE, 2 + message.size() * sizeof(u16));
+       pkt << message;
 
-               pkt << message;
-
-               Send(&pkt);
-       } else if (m_out_chat_queue.size() < (u16) max_queue_size || max_queue_size == -1) {
-               m_out_chat_queue.push(message);
-       } else {
-               infostream << "Could not queue chat message because maximum out chat queue size ("
-                               << max_queue_size << ") is reached." << std::endl;
-       }
-}
-
-void Client::clearOutChatQueue()
-{
-       m_out_chat_queue = std::queue<std::wstring>();
+       Send(&pkt);
 }
 
 void Client::sendChangePassword(const std::string &oldpassword,
index 0255b2803337f2c361edd41e7b03db2febe6eb94..29cbe9c100d887518556af5338ba3d130cca169a 100644 (file)
@@ -40,8 +40,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include <fstream>
 #include "filesys.h"
 
-#define CLIENT_CHAT_MESSAGE_LIMIT_PER_10S 10.0f
-
 struct MeshMakeData;
 class MapBlockMesh;
 class IWritableTextureSource;
@@ -375,7 +373,6 @@ public:
                const StringMap &fields);
        void sendInventoryAction(InventoryAction *a);
        void sendChatMessage(const std::wstring &message);
-       void clearOutChatQueue();
        void sendChangePassword(const std::string &oldpassword,
                const std::string &newpassword);
        void sendDamage(u8 damage);
@@ -582,8 +579,6 @@ private:
        inline std::string getPlayerName()
        { return m_env.getLocalPlayer()->getName(); }
 
-       bool canSendChatMessage() const;
-
        float m_packetcounter_timer = 0.0f;
        float m_connection_reinit_timer = 0.1f;
        float m_avg_rtt_timer = 0.0f;
@@ -630,9 +625,6 @@ private:
        //s32 m_daynight_i;
        //u32 m_daynight_ratio;
        std::queue<std::wstring> m_chat_queue;
-       std::queue<std::wstring> m_out_chat_queue;
-       u32 m_last_chat_message_sent;
-       float m_chat_message_allowance = 5.0f;
 
        // The authentication methods we can use to enter sudo mode (=change password)
        u32 m_sudo_auth_methods;
index 707f2c3aa1a0d362ddcc653ab48c60be97a9fffe..45920330f2a29d644885a239740386f7f2f6ec36 100644 (file)
@@ -57,7 +57,6 @@ void set_default_settings(Settings *settings)
        settings->setDefault("curl_verify_cert", "true");
        settings->setDefault("enable_remote_media_server", "true");
        settings->setDefault("enable_client_modding", "false");
-       settings->setDefault("max_out_chat_queue_size", "20");
 
        // Keymap
        settings->setDefault("remote_port", "30000");
index 1077d5f2d86568ccc782b58865abd038bfd1e4a7..0b957a6e23a31172bff4cbcfa14eaaedabbf84a9 100644 (file)
@@ -85,23 +85,6 @@ int ModApiClient::l_display_chat_message(lua_State *L)
        return 1;
 }
 
-// send_chat_message(message)
-int ModApiClient::l_send_chat_message(lua_State *L)
-{
-       if (!lua_isstring(L, 1))
-               return 0;
-       std::string message = luaL_checkstring(L, 1);
-       getClient(L)->sendChatMessage(utf8_to_wide(message));
-       return 0;
-}
-
-// clear_out_chat_queue()
-int ModApiClient::l_clear_out_chat_queue(lua_State *L)
-{
-       getClient(L)->clearOutChatQueue();
-       return 0;
-}
-
 // get_player_names()
 int ModApiClient::l_get_player_names(lua_State *L)
 {
@@ -354,8 +337,6 @@ void ModApiClient::Initialize(lua_State *L, int top)
        API_FCT(get_current_modname);
        API_FCT(print);
        API_FCT(display_chat_message);
-       API_FCT(send_chat_message);
-       API_FCT(clear_out_chat_queue);
        API_FCT(get_player_names);
        API_FCT(set_last_run_mod);
        API_FCT(get_last_run_mod);
index 7472915f5c1b6442f5dadae918b2bf023e283570..6bb12187fd3ab4fcdc2663f52ebbbd8d1223dc36 100644 (file)
@@ -37,12 +37,6 @@ private:
        // display_chat_message(message)
        static int l_display_chat_message(lua_State *L);
 
-       // send_chat_message(message)
-       static int l_send_chat_message(lua_State *L);
-
-       // clear_out_chat_queue()
-       static int l_clear_out_chat_queue(lua_State *L);
-
        // get_player_names()
        static int l_get_player_names(lua_State *L);