X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Fclientiface.cpp;h=f07f02012fc38411d79087da8c3218e9821f793f;hb=9c8fec83af2c94791865cd82ee18abdc54f913a1;hp=361315c3bcb6411456e61afd202a61d1c17a84cc;hpb=7ddf67aa1478813e12a5fcdfb4986b9e5adfe62f;p=dragonfireclient.git diff --git a/src/clientiface.cpp b/src/clientiface.cpp index 361315c3b..f07f02012 100644 --- a/src/clientiface.cpp +++ b/src/clientiface.cpp @@ -18,18 +18,17 @@ with this program; if not, write to the Free Software Foundation, Inc., */ #include - #include "clientiface.h" +#include "network/connection.h" +#include "network/serveropcodes.h" #include "remoteplayer.h" #include "settings.h" #include "mapblock.h" -#include "network/connection.h" #include "serverenvironment.h" #include "map.h" #include "emerge.h" #include "content_sao.h" // TODO this is used for cleanup of only #include "log.h" -#include "network/serveropcodes.h" #include "util/srp.h" #include "face_position_cache.h" @@ -95,7 +94,7 @@ void RemoteClient::GetNextBlocks ( } v3f playerpos = sao->getBasePosition(); - v3f playerspeed = player->getSpeed(); + const v3f &playerspeed = player->getSpeed(); v3f playerspeeddir(0,0,0); if(playerspeed.getLength() > 1.0*BS) playerspeeddir = playerspeed / playerspeed.getLength(); @@ -623,15 +622,24 @@ std::vector ClientInterface::getClientIDs(ClientState min_state) std::vector reply; MutexAutoLock clientslock(m_clients_mutex); - for (RemoteClientMap::iterator i = m_clients.begin(); - i != m_clients.end(); ++i) { - if (i->second->getState() >= min_state) - reply.push_back(i->second->peer_id); + for (const auto &m_client : m_clients) { + if (m_client.second->getState() >= min_state) + reply.push_back(m_client.second->peer_id); } return reply; } +/** + * 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"); +} + void ClientInterface::step(float dtime) { m_print_info_timer += dtime;