]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/clientiface.h
Server: Calculate maximal total block sends dynamically (#6393)
[dragonfireclient.git] / src / clientiface.h
index 09855a3725327ff9fc9b00bc1e051e89b4752e88..4850b0c2aec5a3c74b5a8901aa21b03e7585e6cc 100644 (file)
@@ -16,14 +16,15 @@ You should have received a copy of the GNU Lesser General Public License along
 with this program; if not, write to the Free Software Foundation, Inc.,
 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */
-#ifndef _CLIENTIFACE_H_
-#define _CLIENTIFACE_H_
+
+#pragma once
 
 #include "irr_v3d.h"                   // for irrlicht datatypes
 
 #include "constants.h"
 #include "serialization.h"             // for SER_FMT_VER_INVALID
 #include "network/networkpacket.h"
+#include "network/networkprotocol.h"
 #include "porting.h"
 
 #include <list>
@@ -204,7 +205,7 @@ enum ClientStateEvent
 */
 struct PrioritySortedBlockTransfer
 {
-       PrioritySortedBlockTransfer(float a_priority, v3s16 a_pos, u16 a_peer_id)
+       PrioritySortedBlockTransfer(float a_priority, const v3s16 &a_pos, u16 a_peer_id)
        {
                priority = a_priority;
                pos = a_pos;
@@ -245,8 +246,8 @@ class RemoteClient
        bool isMechAllowed(AuthMechanism mech)
        { return allowed_auth_mechs & mech; }
 
-       RemoteClient() {}
-       ~RemoteClient() {}
+       RemoteClient() = default;
+       ~RemoteClient() = default;
 
        /*
                Finds block that should be sent next to the client.
@@ -271,10 +272,7 @@ class RemoteClient
         */
        void ResendBlockIfOnWire(v3s16 p);
 
-       s32 SendingCount()
-       {
-               return m_blocks_sending.size();
-       }
+       u32 getSendingCount() const { return m_blocks_sending.size(); }
 
        // Increments timeouts and removes timed-out blocks from list
        // NOTE: This doesn't fix the server-not-sending-block bug
@@ -417,7 +415,7 @@ class ClientInterface {
 
        friend class Server;
 
-       ClientInterface(con::Connection* con);
+       ClientInterface(const std::shared_ptr<con::Connection> &con);
        ~ClientInterface();
 
        /* run sync step */
@@ -426,6 +424,9 @@ class ClientInterface {
        /* get list of active client id's */
        std::vector<u16> getClientIDs(ClientState min_state=CS_Active);
 
+       /* verify is server user limit was reached */
+       bool isUserLimitReached();
+
        /* get list of client player names */
        const std::vector<std::string> &getPlayerNames() const { return m_clients_names; }
 
@@ -434,6 +435,7 @@ class ClientInterface {
 
        /* send to all clients */
        void sendToAll(NetworkPacket *pkt);
+       void sendToAllCompat(NetworkPacket *pkt, NetworkPacket *legacypkt, u16 min_proto_ver);
 
        /* delete a client */
        void DeleteClient(u16 peer_id);
@@ -470,7 +472,6 @@ class ClientInterface {
        }
 
        static std::string state2Name(ClientState state);
-
 protected:
        //TODO find way to avoid this functions
        void lock() { m_clients_mutex.lock(); }
@@ -483,7 +484,7 @@ class ClientInterface {
        void UpdatePlayerList();
 
        // Connection
-       con::Connection* m_con;
+       std::shared_ptr<con::Connection> m_con;
        std::mutex m_clients_mutex;
        // Connected clients (behind the con mutex)
        RemoteClientMap m_clients;
@@ -491,11 +492,8 @@ class ClientInterface {
 
        // Environment
        ServerEnvironment *m_env;
-       std::mutex m_env_mutex;
 
        float m_print_info_timer;
 
        static const char *statenames[];
 };
-
-#endif