server shouldn't update client ping in local games

This commit is contained in:
Max-Wilhelm Bruker 2010-09-09 03:41:01 +02:00
parent 62bf2572a9
commit daf1fa18aa
5 changed files with 11 additions and 5 deletions

View file

@ -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; }

View file

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

View file

@ -27,15 +27,17 @@
#include <QTimer>
#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)
{
creator = addPlayer(_creator, false, false);
if (parent->getGameShouldPing()) {
pingClock = new QTimer(this);
connect(pingClock, SIGNAL(timeout()), this, SLOT(pingClockTimeout()));
pingClock->start(1000);
}
}
Server_Game::~Server_Game()
{

View file

@ -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(); }

View file

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