mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2025-12-22 23:26:14 -08:00
Cleanup max user check at login
This change accomplishes two goals. The first is it moves the checking for if the servers set user limit is reached out of the socket interface and into the protocol handler portion of the code (were it should live). It also eleminates the need for a DB query at login to check the user count. The user account is actually already maintained by the server and a function already existed to get the user count total.
This commit is contained in:
@@ -383,6 +383,14 @@ Response::ResponseCode Server_ProtocolHandler::cmdPing(const Command_Ping & /*cm
|
||||
|
||||
Response::ResponseCode Server_ProtocolHandler::cmdLogin(const Command_Login &cmd, ResponseContainer &rc)
|
||||
{
|
||||
// limit the number of users that can connect to the server based on configuration settings
|
||||
if (server->getmaxUserLimitEnabled()) {
|
||||
if (server->getUsersCount() >= server->getMaxUserLimit()) {
|
||||
qDebug() << "Max Users Total Limit Reached, please increase the max_users_total setting.";
|
||||
return Response::RespServerFull;
|
||||
}
|
||||
}
|
||||
|
||||
QString userName = QString::fromStdString(cmd.user_name()).simplified();
|
||||
QString clientId = QString::fromStdString(cmd.clientid()).simplified();
|
||||
QString clientVersion = QString::fromStdString(cmd.clientver()).simplified();
|
||||
|
||||
Reference in New Issue
Block a user