From 55d493e7ef51a11ea79530124df1c5e6cd26f379 Mon Sep 17 00:00:00 2001 From: Max-Wilhelm Bruker Date: Mon, 3 Jan 2011 20:46:15 +0100 Subject: [PATCH] single player works again, version bump --- cockatrice/cockatrice.pro | 2 +- cockatrice/src/localclient.cpp | 1 + cockatrice/src/localserver.cpp | 2 ++ cockatrice/src/messagelogwidget.cpp | 22 +++++++++++++--------- cockatrice/src/tab_room.cpp | 4 ++++ cockatrice/src/tab_supervisor.cpp | 2 +- cockatrice/src/window_main.cpp | 4 ++-- common/protocol.h | 2 +- servatrice/src/servatrice.cpp | 2 +- 9 files changed, 26 insertions(+), 15 deletions(-) diff --git a/cockatrice/cockatrice.pro b/cockatrice/cockatrice.pro index 1faaa3de..330f612c 100644 --- a/cockatrice/cockatrice.pro +++ b/cockatrice/cockatrice.pro @@ -5,7 +5,7 @@ INCLUDEPATH += . src ../common MOC_DIR = build OBJECTS_DIR = build RESOURCES = cockatrice.qrc -QT += network svg webkit +QT += network svg HEADERS += src/counter.h \ src/dlg_creategame.h \ diff --git a/cockatrice/src/localclient.cpp b/cockatrice/src/localclient.cpp index b42b810c..87b215ba 100644 --- a/cockatrice/src/localclient.cpp +++ b/cockatrice/src/localclient.cpp @@ -7,6 +7,7 @@ LocalClient::LocalClient(LocalServerInterface *_lsi, const QString &_playerName, { connect(lsi, SIGNAL(itemToClient(ProtocolItem *)), this, SLOT(itemFromServer(ProtocolItem *))); sendCommand(new Command_Login(_playerName, QString())); + sendCommand(new Command_JoinRoom(0)); } LocalClient::~LocalClient() diff --git a/cockatrice/src/localserver.cpp b/cockatrice/src/localserver.cpp index 1af04676..da403f91 100644 --- a/cockatrice/src/localserver.cpp +++ b/cockatrice/src/localserver.cpp @@ -1,9 +1,11 @@ #include "localserver.h" #include "localserverinterface.h" +#include "server_room.h" LocalServer::LocalServer(QObject *parent) : Server(parent) { + addRoom(new Server_Room(0, QString(), QString(), false, QString(), this)); } LocalServer::~LocalServer() diff --git a/cockatrice/src/messagelogwidget.cpp b/cockatrice/src/messagelogwidget.cpp index 7e42c0b3..4ce4621d 100644 --- a/cockatrice/src/messagelogwidget.cpp +++ b/cockatrice/src/messagelogwidget.cpp @@ -181,7 +181,7 @@ void MessageLogWidget::logMoveCard(Player *player, QString cardName, CardZone *s { QString startName = startZone->getName(); QString targetName = targetZone->getName(); - if (((startName == "table") && (targetName == "table")) || ((startName == "hand") && (targetName == "hand"))) + if (((startName == "table") && (targetName == "table") && (startZone == targetZone)) || ((startName == "hand") && (targetName == "hand"))) return; QPair temp = getFromStr(startZone, cardName, oldX); bool cardNameContainsStartZone = false; @@ -190,6 +190,18 @@ void MessageLogWidget::logMoveCard(Player *player, QString cardName, CardZone *s cardName = temp.first; } QString fromStr = temp.second; + QString cardStr; + if (cardNameContainsStartZone) + cardStr = cardName; + else if (cardName.isEmpty()) + cardStr = tr("a card"); + else + cardStr = QString("%1").arg(sanitizeHtml(cardName)); + + if ((startName == "table") && (targetName == "table")) { + append(tr("%1 gives %2 control over %3.").arg(sanitizeHtml(player->getName())).arg(sanitizeHtml(targetZone->getPlayer()->getName())).arg(cardStr)); + return; + } QString finalStr; if (targetName == "table") @@ -214,14 +226,6 @@ void MessageLogWidget::logMoveCard(Player *player, QString cardName, CardZone *s else if (targetName == "stack") finalStr = tr("%1 plays %2%3."); - QString cardStr; - if (cardNameContainsStartZone) - cardStr = cardName; - else if (cardName.isEmpty()) - cardStr = tr("a card"); - else - cardStr = QString("%1").arg(sanitizeHtml(cardName)); - append(finalStr.arg(sanitizeHtml(player->getName())).arg(cardStr).arg(fromStr).arg(newX)); } diff --git a/cockatrice/src/tab_room.cpp b/cockatrice/src/tab_room.cpp index 381adb78..be61033f 100644 --- a/cockatrice/src/tab_room.cpp +++ b/cockatrice/src/tab_room.cpp @@ -202,6 +202,10 @@ TabRoom::TabRoom(AbstractClient *_client, const QString &_ownName, ServerInfo_Ro const QList users = info->getUserList(); for (int i = 0; i < users.size(); ++i) userList->processUserInfo(users[i]); + + const QList games = info->getGameList(); + for (int i = 0; i < games.size(); ++i) + gameSelector->processGameInfo(games[i]); } TabRoom::~TabRoom() diff --git a/cockatrice/src/tab_supervisor.cpp b/cockatrice/src/tab_supervisor.cpp index 36c7de53..50794a83 100644 --- a/cockatrice/src/tab_supervisor.cpp +++ b/cockatrice/src/tab_supervisor.cpp @@ -146,7 +146,7 @@ void TabSupervisor::localGameJoined(Event_GameJoined *event) setCurrentWidget(tab); for (int i = 1; i < localClients.size(); ++i) { - Command_JoinGame *cmd = new Command_JoinGame(event->getGameId()); + Command_JoinGame *cmd = new Command_JoinGame(0, event->getGameId()); localClients[i]->sendCommand(cmd); } } diff --git a/cockatrice/src/window_main.cpp b/cockatrice/src/window_main.cpp index 8074a63e..1badc0f0 100644 --- a/cockatrice/src/window_main.cpp +++ b/cockatrice/src/window_main.cpp @@ -113,9 +113,9 @@ void MainWindow::actSinglePlayer() } tabSupervisor->startLocal(localClients); -/* Command_CreateGame *createCommand = new Command_CreateGame(QString(), QString(), numberPlayers, false, false, false, false); + Command_CreateGame *createCommand = new Command_CreateGame(0, QString(), QString(), numberPlayers, false, false, false, false); mainClient->sendCommand(createCommand); -*/} +} void MainWindow::localGameEnded() { diff --git a/common/protocol.h b/common/protocol.h index 97fe77e4..e882823b 100644 --- a/common/protocol.h +++ b/common/protocol.h @@ -54,7 +54,7 @@ private: static void initializeHashAuto(); bool receiverMayDelete; public: - static const int protocolVersion = 10; + static const int protocolVersion = 11; static void initializeHash(); virtual int getItemId() const = 0; bool getReceiverMayDelete() const { return receiverMayDelete; } diff --git a/servatrice/src/servatrice.cpp b/servatrice/src/servatrice.cpp index e5ec8488..25317ce9 100644 --- a/servatrice/src/servatrice.cpp +++ b/servatrice/src/servatrice.cpp @@ -209,4 +209,4 @@ void Servatrice::statusUpdate() execSqlQuery(query); } -const QString Servatrice::versionString = "Servatrice 0.20101116"; +const QString Servatrice::versionString = "Servatrice 0.20110103";