Merge pull request #1347 from woogerboy21/fix_clientid_localgame

Fix local game not starting properly.
This commit is contained in:
woogerboy21 2015-08-08 17:33:34 -04:00
commit 644ea0482f
3 changed files with 29 additions and 28 deletions

View file

@ -3,13 +3,14 @@
#include "pb/session_commands.pb.h"
LocalClient::LocalClient(LocalServerInterface *_lsi, const QString &_playerName, QObject *parent)
LocalClient::LocalClient(LocalServerInterface *_lsi, const QString &_playerName, const QString &_clientId, QObject *parent)
: AbstractClient(parent), lsi(_lsi)
{
connect(lsi, SIGNAL(itemToClient(const ServerMessage &)), this, SLOT(itemFromServer(const ServerMessage &)));
Command_Login loginCmd;
loginCmd.set_user_name(_playerName.toStdString());
loginCmd.set_clientid(_clientId.toStdString());
sendCommand(prepareSessionCommand(loginCmd));
Command_JoinRoom joinCmd;

View file

@ -10,7 +10,7 @@ class LocalClient : public AbstractClient {
private:
LocalServerInterface *lsi;
public:
LocalClient(LocalServerInterface *_lsi, const QString &_playerName, QObject *parent = 0);
LocalClient(LocalServerInterface *_lsi, const QString &_playerName, const QString &_clientId, QObject *parent = 0);
~LocalClient();
void sendCommandContainer(const CommandContainer &cont);

View file

@ -189,13 +189,13 @@ void MainWindow::actSinglePlayer()
localServer = new LocalServer(this);
LocalServerInterface *mainLsi = localServer->newConnection();
LocalClient *mainClient = new LocalClient(mainLsi, tr("Player %1").arg(1), this);
LocalClient *mainClient = new LocalClient(mainLsi, tr("Player %1").arg(1), settingsCache->getClientID(), this);
QList<AbstractClient *> localClients;
localClients.append(mainClient);
for (int i = 0; i < numberPlayers - 1; ++i) {
LocalServerInterface *slaveLsi = localServer->newConnection();
LocalClient *slaveClient = new LocalClient(slaveLsi, tr("Player %1").arg(i + 2), this);
LocalClient *slaveClient = new LocalClient(slaveLsi, tr("Player %1").arg(i + 2), settingsCache->getClientID(), this);
localClients.append(slaveClient);
}
tabSupervisor->startLocal(localClients);