의 미러
https://github.com/minetest/minetest.git
synced 2025-07-06 01:40:21 +02:00
Rework user limit and checks around join process
This commit is contained in:
@ -659,7 +659,7 @@ std::vector<session_t> ClientInterface::getClientIDs(ClientState min_state)
|
||||
{
|
||||
std::vector<session_t> reply;
|
||||
RecursiveMutexAutoLock clientslock(m_clients_mutex);
|
||||
|
||||
reply.reserve(m_clients.size());
|
||||
for (const auto &m_client : m_clients) {
|
||||
if (m_client.second->getState() >= min_state)
|
||||
reply.push_back(m_client.second->peer_id);
|
||||
@ -677,14 +677,10 @@ void ClientInterface::markBlocksNotSent(const std::vector<v3s16> &positions, boo
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify if user limit was reached.
|
||||
* User limit count all clients from HelloSent state (MT protocol user) to Active state
|
||||
* @return true if user limit was reached
|
||||
*/
|
||||
bool ClientInterface::isUserLimitReached()
|
||||
{
|
||||
return getClientIDs(CS_HelloSent).size() >= g_settings->getU16("max_users");
|
||||
// Note that this only counts clients that have fully joined
|
||||
return getClientIDs().size() >= g_settings->getU16("max_users");
|
||||
}
|
||||
|
||||
void ClientInterface::step(float dtime)
|
||||
@ -812,16 +808,6 @@ ClientState ClientInterface::getClientState(session_t peer_id)
|
||||
return n->second->getState();
|
||||
}
|
||||
|
||||
void ClientInterface::setPlayerName(session_t peer_id, const std::string &name)
|
||||
{
|
||||
RecursiveMutexAutoLock clientslock(m_clients_mutex);
|
||||
RemoteClientMap::iterator n = m_clients.find(peer_id);
|
||||
// The client may not exist; clients are immediately removed if their
|
||||
// access is denied, and this event occurs later then.
|
||||
if (n != m_clients.end())
|
||||
n->second->setName(name);
|
||||
}
|
||||
|
||||
void ClientInterface::DeleteClient(session_t peer_id)
|
||||
{
|
||||
RecursiveMutexAutoLock conlock(m_clients_mutex);
|
||||
@ -902,18 +888,3 @@ u16 ClientInterface::getProtocolVersion(session_t peer_id)
|
||||
|
||||
return n->second->net_proto_version;
|
||||
}
|
||||
|
||||
void ClientInterface::setClientVersion(session_t peer_id, u8 major, u8 minor, u8 patch,
|
||||
const std::string &full)
|
||||
{
|
||||
RecursiveMutexAutoLock conlock(m_clients_mutex);
|
||||
|
||||
// Error check
|
||||
RemoteClientMap::iterator n = m_clients.find(peer_id);
|
||||
|
||||
// No client to set versions
|
||||
if (n == m_clients.end())
|
||||
return;
|
||||
|
||||
n->second->setVersionInfo(major, minor, patch, full);
|
||||
}
|
||||
|
@ -445,7 +445,7 @@ public:
|
||||
/* mark blocks as not sent on all active clients */
|
||||
void markBlocksNotSent(const std::vector<v3s16> &positions, bool low_priority = false);
|
||||
|
||||
/* verify is server user limit was reached */
|
||||
/* verify if server user limit was reached */
|
||||
bool isUserLimitReached();
|
||||
|
||||
/* get list of client player names */
|
||||
@ -475,16 +475,9 @@ public:
|
||||
/* get state of client by id*/
|
||||
ClientState getClientState(session_t peer_id);
|
||||
|
||||
/* set client playername */
|
||||
void setPlayerName(session_t peer_id, const std::string &name);
|
||||
|
||||
/* get protocol version of client */
|
||||
u16 getProtocolVersion(session_t peer_id);
|
||||
|
||||
/* set client version */
|
||||
void setClientVersion(session_t peer_id, u8 major, u8 minor, u8 patch,
|
||||
const std::string &full);
|
||||
|
||||
/* event to update client state */
|
||||
void event(session_t peer_id, ClientStateEvent event);
|
||||
|
||||
@ -515,9 +508,9 @@ private:
|
||||
// Connection
|
||||
std::shared_ptr<con::IConnection> m_con;
|
||||
std::recursive_mutex m_clients_mutex;
|
||||
// Connected clients (behind the con mutex)
|
||||
// Connected clients (behind the mutex)
|
||||
RemoteClientMap m_clients;
|
||||
std::vector<std::string> m_clients_names; //for announcing masterserver
|
||||
std::vector<std::string> m_clients_names; // for announcing to server list
|
||||
|
||||
// Environment
|
||||
ServerEnvironment *m_env;
|
||||
|
Reference in New Issue
Block a user