servatrice: create correct game ids when not using a database
This commit is contained in:
parent
c8852b450d
commit
a1e35ccda5
5 changed files with 11 additions and 8 deletions
|
@ -22,9 +22,7 @@ LocalServerInterface *LocalServer::newConnection()
|
||||||
}
|
}
|
||||||
|
|
||||||
LocalServer_DatabaseInterface::LocalServer_DatabaseInterface(LocalServer *_localServer)
|
LocalServer_DatabaseInterface::LocalServer_DatabaseInterface(LocalServer *_localServer)
|
||||||
: Server_DatabaseInterface(_localServer),
|
: Server_DatabaseInterface(_localServer), localServer(_localServer)
|
||||||
nextGameId(0),
|
|
||||||
nextReplayId(0)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,14 +20,13 @@ class LocalServer_DatabaseInterface : public Server_DatabaseInterface {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
private:
|
private:
|
||||||
LocalServer *localServer;
|
LocalServer *localServer;
|
||||||
int nextGameId, nextReplayId;
|
|
||||||
protected:
|
protected:
|
||||||
ServerInfo_User getUserData(const QString &name, bool withId = false);
|
ServerInfo_User getUserData(const QString &name, bool withId = false);
|
||||||
public:
|
public:
|
||||||
LocalServer_DatabaseInterface(LocalServer *_localServer);
|
LocalServer_DatabaseInterface(LocalServer *_localServer);
|
||||||
AuthenticationResult checkUserPassword(Server_ProtocolHandler *handler, const QString &user, const QString &password, QString &reasonStr, int &secondsLeft);
|
AuthenticationResult checkUserPassword(Server_ProtocolHandler *handler, const QString &user, const QString &password, QString &reasonStr, int &secondsLeft);
|
||||||
int getNextGameId() { return ++nextGameId; }
|
int getNextGameId() { return localServer->getNextLocalGameId(); }
|
||||||
int getNextReplayId() { return ++nextReplayId; }
|
int getNextReplayId() { return -1; }
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
Server::Server(bool _threaded, QObject *parent)
|
Server::Server(bool _threaded, QObject *parent)
|
||||||
: QObject(parent), threaded(_threaded), clientsLock(QReadWriteLock::Recursive)
|
: QObject(parent), threaded(_threaded), clientsLock(QReadWriteLock::Recursive), nextLocalGameId(0)
|
||||||
{
|
{
|
||||||
qRegisterMetaType<ServerInfo_Game>("ServerInfo_Game");
|
qRegisterMetaType<ServerInfo_Game>("ServerInfo_Game");
|
||||||
qRegisterMetaType<ServerInfo_Room>("ServerInfo_Room");
|
qRegisterMetaType<ServerInfo_Room>("ServerInfo_Room");
|
||||||
|
|
|
@ -61,6 +61,7 @@ public:
|
||||||
virtual bool getThreaded() const { return false; }
|
virtual bool getThreaded() const { return false; }
|
||||||
|
|
||||||
Server_DatabaseInterface *getDatabaseInterface() const;
|
Server_DatabaseInterface *getDatabaseInterface() const;
|
||||||
|
int getNextLocalGameId() { QMutexLocker locker(&nextLocalGameIdMutex); return ++nextLocalGameId; }
|
||||||
virtual void storeGameInformation(int secondsElapsed, const QSet<QString> &allPlayersEver, const QSet<QString> &allSpectatorsEver, const QList<GameReplay *> &replays) { }
|
virtual void storeGameInformation(int secondsElapsed, const QSet<QString> &allPlayersEver, const QSet<QString> &allSpectatorsEver, const QList<GameReplay *> &replays) { }
|
||||||
|
|
||||||
void sendIsl_Response(const Response &item, int serverId = -1, qint64 sessionId = -1);
|
void sendIsl_Response(const Response &item, int serverId = -1, qint64 sessionId = -1);
|
||||||
|
@ -81,6 +82,8 @@ private:
|
||||||
bool threaded;
|
bool threaded;
|
||||||
QMultiMap<QString, PlayerReference> persistentPlayers;
|
QMultiMap<QString, PlayerReference> persistentPlayers;
|
||||||
mutable QReadWriteLock persistentPlayersLock;
|
mutable QReadWriteLock persistentPlayersLock;
|
||||||
|
int nextLocalGameId;
|
||||||
|
QMutex nextLocalGameIdMutex;
|
||||||
protected slots:
|
protected slots:
|
||||||
void externalUserJoined(const ServerInfo_User &userInfo);
|
void externalUserJoined(const ServerInfo_User &userInfo);
|
||||||
void externalUserLeft(const QString &userName);
|
void externalUserLeft(const QString &userName);
|
||||||
|
|
|
@ -389,6 +389,9 @@ QMap<QString, ServerInfo_User> Servatrice_DatabaseInterface::getIgnoreList(const
|
||||||
|
|
||||||
int Servatrice_DatabaseInterface::getNextGameId()
|
int Servatrice_DatabaseInterface::getNextGameId()
|
||||||
{
|
{
|
||||||
|
if (!sqlDatabase.isValid())
|
||||||
|
return server->getNextLocalGameId();
|
||||||
|
|
||||||
if (!checkSql())
|
if (!checkSql())
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue