diff --git a/cockatrice/src/localserver.h b/cockatrice/src/localserver.h index a93b51ef..90d304b0 100644 --- a/cockatrice/src/localserver.h +++ b/cockatrice/src/localserver.h @@ -13,6 +13,7 @@ public: ~LocalServer(); AuthenticationResult checkUserPassword(const QString & /*user*/, const QString & /*password*/) { return UnknownUser; } QString getLoginMessage() const { return QString(); } + bool getGameShouldPing() const { return false; } int getMaxGameInactivityTime() const { return 9999999; } int getMaxPlayerInactivityTime() const { return 9999999; } diff --git a/common/server.h b/common/server.h index 298eda4c..ff29b82f 100644 --- a/common/server.h +++ b/common/server.h @@ -34,6 +34,7 @@ public: 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); + virtual bool getGameShouldPing() const = 0; virtual int getMaxGameInactivityTime() const = 0; virtual int getMaxPlayerInactivityTime() const = 0; private: diff --git a/common/server_game.cpp b/common/server_game.cpp index d8afb5cc..396a09af 100644 --- a/common/server_game.cpp +++ b/common/server_game.cpp @@ -27,14 +27,16 @@ #include #include -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) { creator = addPlayer(_creator, false, false); - pingClock = new QTimer(this); - connect(pingClock, SIGNAL(timeout()), this, SLOT(pingClockTimeout())); - pingClock->start(1000); + if (parent->getGameShouldPing()) { + pingClock = new QTimer(this); + connect(pingClock, SIGNAL(timeout()), this, SLOT(pingClockTimeout())); + pingClock->start(1000); + } } Server_Game::~Server_Game() diff --git a/common/server_game.h b/common/server_game.h index cd70ebf6..6badea77 100644 --- a/common/server_game.h +++ b/common/server_game.h @@ -27,6 +27,7 @@ #include "protocol.h" class QTimer; +class Server; class Server_Game : public QObject { Q_OBJECT @@ -50,7 +51,7 @@ signals: private slots: void pingClockTimeout(); 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_Player *getCreator() const { return creator; } QString getCreatorName() const { return creator ? creator->getPlayerName() : QString(); } diff --git a/servatrice/src/servatrice.h b/servatrice/src/servatrice.h index be44cde8..a7c72a6e 100644 --- a/servatrice/src/servatrice.h +++ b/servatrice/src/servatrice.h @@ -42,6 +42,7 @@ public: bool execSqlQuery(QSqlQuery &query); AuthenticationResult checkUserPassword(const QString &user, const QString &password); QString getLoginMessage() const { return loginMessage; } + bool getGameShouldPing() const { return true; } int getMaxGameInactivityTime() const { return maxGameInactivityTime; } int getMaxPlayerInactivityTime() const { return maxPlayerInactivityTime; } private: