mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-09 17:44:01 -07:00
Registered Only Server
Allow for registration only server.
This commit is contained in:
parent
69a8fa0bb1
commit
3c216ac9cd
5 changed files with 14 additions and 2 deletions
|
|
@ -1,4 +1,4 @@
|
|||
/***************************************************************************
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Max-Wilhelm Bruker *
|
||||
* brukie@gmx.net *
|
||||
* *
|
||||
|
|
@ -225,7 +225,7 @@ void MainWindow::actAbout()
|
|||
+ tr("French:") + " Yannick Hammer, Arnaud Faes<br>"
|
||||
+ tr("Japanese:") + " Nagase Task<br>"
|
||||
+ tr("Russian:") + " Alexander Davidov<br>"
|
||||
// + tr("Czech:") + " Ondřej Trhoň<br>"
|
||||
// + tr("Czech:") + " Ondrej Trhon<br>"
|
||||
// + tr("Slovak:") + " Ganjalf Rendy<br>"
|
||||
+ tr("Italian:") + " Luigi Sciolla<br>"
|
||||
+ tr("Swedish:") + " Jessica Dahl<br>"
|
||||
|
|
@ -261,6 +261,9 @@ void MainWindow::loginError(Response::ResponseCode r, QString reasonStr, quint32
|
|||
case Response::RespUsernameInvalid:
|
||||
QMessageBox::critical(this, tr("Error"), tr("Invalid username."));
|
||||
break;
|
||||
case Response::RespRegRequired:
|
||||
QMessageBox::critical(this, tr("Error"), tr("This server requires user registration."));
|
||||
break;
|
||||
default:
|
||||
QMessageBox::critical(this, tr("Error"), tr("Unknown login error: %1").arg(static_cast<int>(r)));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ message Response {
|
|||
RespUserIsBanned = 19;
|
||||
RespAccessDenied = 20;
|
||||
RespUsernameInvalid = 21;
|
||||
RespRegRequired = 22;
|
||||
}
|
||||
enum ResponseType {
|
||||
JOIN_ROOM = 1000;
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@
|
|||
#include <QCoreApplication>
|
||||
#include <QThread>
|
||||
#include <QDebug>
|
||||
#include <QSettings>
|
||||
|
||||
Server::Server(bool _threaded, QObject *parent)
|
||||
: QObject(parent), threaded(_threaded), nextLocalGameId(0)
|
||||
|
|
@ -131,6 +132,11 @@ AuthenticationResult Server::loginUser(Server_ProtocolHandler *session, QString
|
|||
} else if (authState == UnknownUser) {
|
||||
// Change user name so that no two users have the same names,
|
||||
// don't interfere with registered user names though.
|
||||
QSettings *settings = new QSettings("servatrice.ini", QSettings::IniFormat);
|
||||
bool requireReg = settings->value("server/regonly").toBool();
|
||||
if (requireReg)
|
||||
return RegistrationRequired;
|
||||
|
||||
QString tempName = name;
|
||||
int i = 0;
|
||||
while (users.contains(tempName) || databaseInterface->userExists(tempName) || databaseInterface->userSessionExists(tempName))
|
||||
|
|
|
|||
|
|
@ -345,6 +345,7 @@ Response::ResponseCode Server_ProtocolHandler::cmdLogin(const Command_Login &cmd
|
|||
case NotLoggedIn: return Response::RespWrongPassword;
|
||||
case WouldOverwriteOldSession: return Response::RespWouldOverwriteOldSession;
|
||||
case UsernameInvalid: return Response::RespUsernameInvalid;
|
||||
case RegistrationRequired: return Response::RespRegRequired;
|
||||
default: authState = res;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ id=1
|
|||
number_pools=1
|
||||
writelog=1
|
||||
logfilters=""
|
||||
regonly=0
|
||||
|
||||
[servernetwork]
|
||||
active=0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue