server shouldn't update client ping in local games
This commit is contained in:
parent
62bf2572a9
commit
daf1fa18aa
5 changed files with 11 additions and 5 deletions
|
@ -13,6 +13,7 @@ public:
|
||||||
~LocalServer();
|
~LocalServer();
|
||||||
AuthenticationResult checkUserPassword(const QString & /*user*/, const QString & /*password*/) { return UnknownUser; }
|
AuthenticationResult checkUserPassword(const QString & /*user*/, const QString & /*password*/) { return UnknownUser; }
|
||||||
QString getLoginMessage() const { return QString(); }
|
QString getLoginMessage() const { return QString(); }
|
||||||
|
bool getGameShouldPing() const { return false; }
|
||||||
int getMaxGameInactivityTime() const { return 9999999; }
|
int getMaxGameInactivityTime() const { return 9999999; }
|
||||||
int getMaxPlayerInactivityTime() const { return 9999999; }
|
int getMaxPlayerInactivityTime() const { return 9999999; }
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,7 @@ public:
|
||||||
virtual QString getLoginMessage() const = 0;
|
virtual QString getLoginMessage() const = 0;
|
||||||
Server_Game *createGame(const QString &description, const QString &password, int maxPlayers, bool spectatorsAllowed, bool spectatorsNeedPassword, bool spectatorsCanTalk, bool spectatorsSeeEverything, Server_ProtocolHandler *creator);
|
Server_Game *createGame(const QString &description, const QString &password, int maxPlayers, bool spectatorsAllowed, bool spectatorsNeedPassword, bool spectatorsCanTalk, bool spectatorsSeeEverything, Server_ProtocolHandler *creator);
|
||||||
|
|
||||||
|
virtual bool getGameShouldPing() const = 0;
|
||||||
virtual int getMaxGameInactivityTime() const = 0;
|
virtual int getMaxGameInactivityTime() const = 0;
|
||||||
virtual int getMaxPlayerInactivityTime() const = 0;
|
virtual int getMaxPlayerInactivityTime() const = 0;
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -27,14 +27,16 @@
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
Server_Game::Server_Game(Server_ProtocolHandler *_creator, int _gameId, const QString &_description, const QString &_password, int _maxPlayers, bool _spectatorsAllowed, bool _spectatorsNeedPassword, bool _spectatorsCanTalk, bool _spectatorsSeeEverything, QObject *parent)
|
Server_Game::Server_Game(Server_ProtocolHandler *_creator, int _gameId, const QString &_description, const QString &_password, int _maxPlayers, bool _spectatorsAllowed, bool _spectatorsNeedPassword, bool _spectatorsCanTalk, bool _spectatorsSeeEverything, Server *parent)
|
||||||
: QObject(parent), gameStarted(false), gameId(_gameId), description(_description), password(_password), maxPlayers(_maxPlayers), activePlayer(-1), activePhase(-1), spectatorsAllowed(_spectatorsAllowed), spectatorsNeedPassword(_spectatorsNeedPassword), spectatorsCanTalk(_spectatorsCanTalk), spectatorsSeeEverything(_spectatorsSeeEverything), inactivityCounter(0)
|
: QObject(parent), gameStarted(false), gameId(_gameId), description(_description), password(_password), maxPlayers(_maxPlayers), activePlayer(-1), activePhase(-1), spectatorsAllowed(_spectatorsAllowed), spectatorsNeedPassword(_spectatorsNeedPassword), spectatorsCanTalk(_spectatorsCanTalk), spectatorsSeeEverything(_spectatorsSeeEverything), inactivityCounter(0)
|
||||||
{
|
{
|
||||||
creator = addPlayer(_creator, false, false);
|
creator = addPlayer(_creator, false, false);
|
||||||
|
|
||||||
pingClock = new QTimer(this);
|
if (parent->getGameShouldPing()) {
|
||||||
connect(pingClock, SIGNAL(timeout()), this, SLOT(pingClockTimeout()));
|
pingClock = new QTimer(this);
|
||||||
pingClock->start(1000);
|
connect(pingClock, SIGNAL(timeout()), this, SLOT(pingClockTimeout()));
|
||||||
|
pingClock->start(1000);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Server_Game::~Server_Game()
|
Server_Game::~Server_Game()
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include "protocol.h"
|
#include "protocol.h"
|
||||||
|
|
||||||
class QTimer;
|
class QTimer;
|
||||||
|
class Server;
|
||||||
|
|
||||||
class Server_Game : public QObject {
|
class Server_Game : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -50,7 +51,7 @@ signals:
|
||||||
private slots:
|
private slots:
|
||||||
void pingClockTimeout();
|
void pingClockTimeout();
|
||||||
public:
|
public:
|
||||||
Server_Game(Server_ProtocolHandler *_creator, int _gameId, const QString &_description, const QString &_password, int _maxPlayers, bool _spectatorsAllowed, bool _spectatorsNeedPassword, bool _spectatorsCanTalk, bool _spectatorsSeeEverything, QObject *parent = 0);
|
Server_Game(Server_ProtocolHandler *_creator, int _gameId, const QString &_description, const QString &_password, int _maxPlayers, bool _spectatorsAllowed, bool _spectatorsNeedPassword, bool _spectatorsCanTalk, bool _spectatorsSeeEverything, Server *parent);
|
||||||
~Server_Game();
|
~Server_Game();
|
||||||
Server_Player *getCreator() const { return creator; }
|
Server_Player *getCreator() const { return creator; }
|
||||||
QString getCreatorName() const { return creator ? creator->getPlayerName() : QString(); }
|
QString getCreatorName() const { return creator ? creator->getPlayerName() : QString(); }
|
||||||
|
|
|
@ -42,6 +42,7 @@ public:
|
||||||
bool execSqlQuery(QSqlQuery &query);
|
bool execSqlQuery(QSqlQuery &query);
|
||||||
AuthenticationResult checkUserPassword(const QString &user, const QString &password);
|
AuthenticationResult checkUserPassword(const QString &user, const QString &password);
|
||||||
QString getLoginMessage() const { return loginMessage; }
|
QString getLoginMessage() const { return loginMessage; }
|
||||||
|
bool getGameShouldPing() const { return true; }
|
||||||
int getMaxGameInactivityTime() const { return maxGameInactivityTime; }
|
int getMaxGameInactivityTime() const { return maxGameInactivityTime; }
|
||||||
int getMaxPlayerInactivityTime() const { return maxPlayerInactivityTime; }
|
int getMaxPlayerInactivityTime() const { return maxPlayerInactivityTime; }
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Reference in a new issue