Registered Only Server

Allow for registration only server.
This commit is contained in:
woogerboy21 2014-06-30 16:26:57 -04:00
parent 69a8fa0bb1
commit 3c216ac9cd
5 changed files with 14 additions and 2 deletions

View file

@ -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))