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>
*/
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;
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.
*/
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
friend class Server;
- ClientInterface(con::Connection* con);
+ ClientInterface(const std::shared_ptr<con::Connection> &con);
~ClientInterface();
/* run sync step */
/* 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; }
/* 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);
}
static std::string state2Name(ClientState state);
-
protected:
//TODO find way to avoid this functions
void lock() { m_clients_mutex.lock(); }
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;
// Environment
ServerEnvironment *m_env;
- std::mutex m_env_mutex;
float m_print_info_timer;
static const char *statenames[];
};
-
-#endif