X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Fclientiface.h;h=4850b0c2aec5a3c74b5a8901aa21b03e7585e6cc;hb=745a90dc84339774a37fddff480dd60c69f4cc2a;hp=09855a3725327ff9fc9b00bc1e051e89b4752e88;hpb=76be103a91d6987527af19e87d93007be8ba8a67;p=dragonfireclient.git diff --git a/src/clientiface.h b/src/clientiface.h index 09855a372..4850b0c2a 100644 --- a/src/clientiface.h +++ b/src/clientiface.h @@ -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 @@ -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); ~ClientInterface(); /* run sync step */ @@ -426,6 +424,9 @@ class ClientInterface { /* get list of active client id's */ std::vector getClientIDs(ClientState min_state=CS_Active); + /* verify is server user limit was reached */ + bool isUserLimitReached(); + /* get list of client player names */ const std::vector &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 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