diff --git a/cockatrice/src/gameselector.cpp b/cockatrice/src/gameselector.cpp index 9ca8a7e3e..9c165d269 100644 --- a/cockatrice/src/gameselector.cpp +++ b/cockatrice/src/gameselector.cpp @@ -27,23 +27,34 @@ GameSelector::GameSelector(AbstractClient *_client, TabRoom *_room, const QMapheader()->setResizeMode(1, QHeaderView::ResizeToContents); showFullGamesCheckBox = new QCheckBox; + showRunningGamesCheckBox = new QCheckBox; + + QVBoxLayout *filterLayout = new QVBoxLayout; + filterLayout->addWidget(showFullGamesCheckBox); + filterLayout->addWidget(showRunningGamesCheckBox); + if (room) createButton = new QPushButton; else createButton = 0; joinButton = new QPushButton; spectateButton = new QPushButton; + QHBoxLayout *buttonLayout = new QHBoxLayout; - buttonLayout->addWidget(showFullGamesCheckBox); - buttonLayout->addStretch(); if (room) buttonLayout->addWidget(createButton); buttonLayout->addWidget(joinButton); buttonLayout->addWidget(spectateButton); + buttonLayout->setAlignment(Qt::AlignTop); + + QHBoxLayout *hbox = new QHBoxLayout; + hbox->addLayout(filterLayout); + hbox->addStretch(); + hbox->addLayout(buttonLayout); QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->addWidget(gameListView); - mainLayout->addLayout(buttonLayout); + mainLayout->addLayout(hbox); retranslateUi(); setLayout(mainLayout); @@ -52,6 +63,7 @@ GameSelector::GameSelector(AbstractClient *_client, TabRoom *_room, const QMapsetFullGamesVisible(state); } +void GameSelector::showRunningGamesChanged(int state) +{ + gameListProxyModel->setRunningGamesVisible(state); +} + void GameSelector::actCreate() { DlgCreateGame dlg(client, room->getRoomId(), room->getGameTypes(), this); @@ -118,6 +135,7 @@ void GameSelector::retranslateUi() { setTitle(tr("Games")); showFullGamesCheckBox->setText(tr("Show &full games")); + showRunningGamesCheckBox->setText(tr("Show &running games")); if (createButton) createButton->setText(tr("C&reate")); joinButton->setText(tr("&Join")); diff --git a/cockatrice/src/gameselector.h b/cockatrice/src/gameselector.h index 4a178bc3b..cf603b336 100644 --- a/cockatrice/src/gameselector.h +++ b/cockatrice/src/gameselector.h @@ -18,6 +18,7 @@ class GameSelector : public QGroupBox { Q_OBJECT private slots: void showFullGamesChanged(int state); + void showRunningGamesChanged(int state); void actCreate(); void actJoin(); void checkResponse(ResponseCode response); @@ -31,7 +32,7 @@ private: GamesModel *gameListModel; GamesProxyModel *gameListProxyModel; QPushButton *createButton, *joinButton, *spectateButton; - QCheckBox *showFullGamesCheckBox; + QCheckBox *showFullGamesCheckBox, *showRunningGamesCheckBox; public: GameSelector(AbstractClient *_client, TabRoom *_room, const QMap &_rooms, const QMap &_gameTypes, QWidget *parent = 0); void retranslateUi(); diff --git a/cockatrice/src/gamesmodel.cpp b/cockatrice/src/gamesmodel.cpp index 9aff702b5..fc8e7d555 100644 --- a/cockatrice/src/gamesmodel.cpp +++ b/cockatrice/src/gamesmodel.cpp @@ -85,7 +85,7 @@ void GamesModel::updateGameList(ServerInfo_Game *_game) for (int i = 0; i < oldGameTypeList.size(); ++i) gameTypeList.append(new GameTypeId(oldGameTypeList[i]->getData())); - ServerInfo_Game *game = new ServerInfo_Game(_game->getRoomId(), _game->getGameId(), _game->getDescription(), _game->getHasPassword(), _game->getPlayerCount(), _game->getMaxPlayers(), gameTypeList, new ServerInfo_User(_game->getCreatorInfo()), _game->getOnlyBuddies(), _game->getOnlyRegistered(), _game->getSpectatorsAllowed(), _game->getSpectatorsNeedPassword(), _game->getSpectatorCount()); + ServerInfo_Game *game = new ServerInfo_Game(_game->getRoomId(), _game->getGameId(), _game->getDescription(), _game->getHasPassword(), _game->getPlayerCount(), _game->getMaxPlayers(), _game->getStarted(), gameTypeList, new ServerInfo_User(_game->getCreatorInfo()), _game->getOnlyBuddies(), _game->getOnlyRegistered(), _game->getSpectatorsAllowed(), _game->getSpectatorsNeedPassword(), _game->getSpectatorCount()); for (int i = 0; i < gameList.size(); i++) if (gameList[i]->getGameId() == game->getGameId()) { if (game->getPlayerCount() == 0) { @@ -118,17 +118,22 @@ void GamesProxyModel::setFullGamesVisible(bool _fullGamesVisible) invalidateFilter(); } +void GamesProxyModel::setRunningGamesVisible(bool _runningGamesVisible) +{ + runningGamesVisible = _runningGamesVisible; + invalidateFilter(); +} + bool GamesProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &/*sourceParent*/) const { - if (fullGamesVisible) - return true; - GamesModel *model = qobject_cast(sourceModel()); if (!model) return false; ServerInfo_Game *game = model->getGame(sourceRow); - if (game->getPlayerCount() == game->getMaxPlayers()) + if ((game->getPlayerCount() == game->getMaxPlayers()) && !fullGamesVisible) + return false; + if (game->getStarted() && !runningGamesVisible) return false; return true; diff --git a/cockatrice/src/gamesmodel.h b/cockatrice/src/gamesmodel.h index 6be0d1406..8461faf66 100644 --- a/cockatrice/src/gamesmodel.h +++ b/cockatrice/src/gamesmodel.h @@ -30,9 +30,11 @@ class GamesProxyModel : public QSortFilterProxyModel { Q_OBJECT private: bool fullGamesVisible; + bool runningGamesVisible; public: GamesProxyModel(QObject *parent = 0); void setFullGamesVisible(bool _fullGamesVisible); + void setRunningGamesVisible(bool _runningGamesVisible); protected: bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const; }; diff --git a/cockatrice/translations/cockatrice_cs.ts b/cockatrice/translations/cockatrice_cs.ts index 0b328cc06..a5a99653b 100644 --- a/cockatrice/translations/cockatrice_cs.ts +++ b/cockatrice/translations/cockatrice_cs.ts @@ -1203,89 +1203,94 @@ This is only saved for moderators and cannot be seen by the banned person. GameSelector - - - - - - - - + + + + + + + + Error - + Please join the appropriate room first. - + Wrong password. - + Spectators are not allowed in this game. - + The game is already full. - + The game does not exist any more. - + This game is only open to registered users. - + This game is only open to its creator's buddies. - + You are being ignored by the creator of this game. - + Join game - + Password: - + Games - + Show &full games - + + Show &running games + + + + C&reate - + &Join - + J&oin as spectator diff --git a/cockatrice/translations/cockatrice_de.ts b/cockatrice/translations/cockatrice_de.ts index 735b3c3be..c423fa687 100644 --- a/cockatrice/translations/cockatrice_de.ts +++ b/cockatrice/translations/cockatrice_de.ts @@ -1947,24 +1947,24 @@ Dies wird nur für Moderatoren gespeichert und kann von der gebannten Person nic GameSelector - + C&reate Spiel e&rstellen - + &Join &Teilnehmen - - - - - - - - + + + + + + + + Error Fehler @@ -1973,71 +1973,76 @@ Dies wird nur für Moderatoren gespeichert und kann von der gebannten Person nic XXX - + Please join the appropriate room first. Bitte betreten Sie erst den entsprechenden Raum. - + Wrong password. Falsches Passwort. - + Spectators are not allowed in this game. In diesem Spiel sind keine Zuschauer zugelassen. - + The game is already full. Das Spiel ist bereits voll. - + The game does not exist any more. Dieses Spiel gibt es nicht mehr. - + This game is only open to registered users. Dieses Spiel kann nur von registrierten Benutzern betreten werden. - + This game is only open to its creator's buddies. Dieses Spiel kann nur von Freunden des Erstellers betreten werden. - + You are being ignored by the creator of this game. Der Ersteller dieses Spiels ignoriert Sie. - + Join game Spiel beitreten - + Password: Passwort: - + Games Spiele - + Show &full games &Volle Spiele anzeigen + + + Show &running games + &Laufende Spiele anzeigen + &Show full games &Volle Spiele anzeigen - + J&oin as spectator &Zuschauen diff --git a/cockatrice/translations/cockatrice_en.ts b/cockatrice/translations/cockatrice_en.ts index 87989e2c9..5693f33d1 100644 --- a/cockatrice/translations/cockatrice_en.ts +++ b/cockatrice/translations/cockatrice_en.ts @@ -1203,89 +1203,94 @@ This is only saved for moderators and cannot be seen by the banned person. GameSelector - + C&reate - + &Join - - - - - - - - + + + + + + + + Error - + Please join the appropriate room first. - + Wrong password. - + Spectators are not allowed in this game. - + The game is already full. - + The game does not exist any more. - + This game is only open to registered users. - + This game is only open to its creator's buddies. - + You are being ignored by the creator of this game. - + Join game - + Password: - + Games - + Show &full games - + + Show &running games + + + + J&oin as spectator diff --git a/cockatrice/translations/cockatrice_es.ts b/cockatrice/translations/cockatrice_es.ts index 877347b7e..1e091cca1 100644 --- a/cockatrice/translations/cockatrice_es.ts +++ b/cockatrice/translations/cockatrice_es.ts @@ -1565,93 +1565,98 @@ This is only saved for moderators and cannot be seen by the banned person. GameSelector - + C&reate C&rear - + &Join E&ntrar - - - - - - - - + + + + + + + + Error Error - + Please join the appropriate room first. - + Wrong password. Contraseña incorrecta. - + Spectators are not allowed in this game. No se permiten espectadores en esta partida. - + The game is already full. La partida no tiene plazas libres. - + The game does not exist any more. La partida ya no existe. - + This game is only open to registered users. Esta partida está abierta sólo a usuarios registrados. - + This game is only open to its creator's buddies. Esta partida está abierta sólo a los amigos del creador. - + You are being ignored by the creator of this game. Estas siendo ignorado por el creador de la partida. - + Join game Entrar en la partida - + Password: Contraseña: - + Games Partidas - + Show &full games Ver partidas &sin plazas libres + + + Show &running games + + &Show full games &Ver partidas sin plazas libres - + J&oin as spectator Entrar como e&spectador diff --git a/cockatrice/translations/cockatrice_fr.ts b/cockatrice/translations/cockatrice_fr.ts index 2df8edd40..a6c656f4c 100644 --- a/cockatrice/translations/cockatrice_fr.ts +++ b/cockatrice/translations/cockatrice_fr.ts @@ -1415,94 +1415,99 @@ This is only saved for moderators and cannot be seen by the banned person. GameSelector - - - - - - - - + + + + + + + + Error Erreur - + Please join the appropriate room first. - + Wrong password. Mot de passe erroné. - + Spectators are not allowed in this game. Les spectateurs ne sont pas autorisés dans cette partie. - + The game is already full. Cette partie est déjà pleine. - + The game does not exist any more. La partie n'existe plus. - + This game is only open to registered users. Cette partie n'est accessible qu'aux joueurs enregistrés. - + This game is only open to its creator's buddies. Cette partie n'est accessible qu'aux amis. - + You are being ignored by the creator of this game. Vous avez été ignoré par le créateur de la partie. - + Join game Rejoindre partie - + Password: Mot de passe: - + Games Parties - + Show &full games Montrer &toutes les parties + + + Show &running games + + &Show full games toutes ou complèetes? &Montrer toutes les parties - + C&reate C&réer - + &Join Re&joindre - + J&oin as spectator Rej&oindre en tant que spectateur diff --git a/cockatrice/translations/cockatrice_ja.ts b/cockatrice/translations/cockatrice_ja.ts index c9f0a6e9a..6d4c3aa93 100644 --- a/cockatrice/translations/cockatrice_ja.ts +++ b/cockatrice/translations/cockatrice_ja.ts @@ -1251,93 +1251,98 @@ This is only saved for moderators and cannot be seen by the banned person. GameSelector - + C&reate 部屋を作る - + &Join 参加する - - - - - - - - + + + + + + + + Error エラー - + Please join the appropriate room first. - + Wrong password. パスワードが間違っています. - + Spectators are not allowed in this game. この試合は観戦者は許可されていません. - + The game is already full. このゲームはすでに満員です. - + The game does not exist any more. このゲームはもう存在しません. - + This game is only open to registered users. このゲームは登録済みプレイヤーにのみ公開されています. - + This game is only open to its creator's buddies. このゲームは作成者のフレンドのみに公開されています. - + You are being ignored by the creator of this game. あなたはこのゲームの作成者によって拒否されています. - + Join game 参加 - + Password: パスワード: - + Games ゲーム - + Show &full games 全てのゲームを見る + + + Show &running games + + &Show full games 全てのゲームを見る - + J&oin as spectator 観戦者として参加 diff --git a/cockatrice/translations/cockatrice_pl.ts b/cockatrice/translations/cockatrice_pl.ts index 492dbed27..3ba27c1e7 100644 --- a/cockatrice/translations/cockatrice_pl.ts +++ b/cockatrice/translations/cockatrice_pl.ts @@ -1203,89 +1203,94 @@ This is only saved for moderators and cannot be seen by the banned person. GameSelector - - - - - - - - + + + + + + + + Error - + Please join the appropriate room first. - + Wrong password. - + Spectators are not allowed in this game. - + The game is already full. - + The game does not exist any more. - + This game is only open to registered users. - + This game is only open to its creator's buddies. - + You are being ignored by the creator of this game. - + Join game - + Password: - + Games - + Show &full games - + + Show &running games + + + + C&reate - + &Join - + J&oin as spectator diff --git a/cockatrice/translations/cockatrice_pt-br.ts b/cockatrice/translations/cockatrice_pt-br.ts index 0404d46d5..4f3707934 100644 --- a/cockatrice/translations/cockatrice_pt-br.ts +++ b/cockatrice/translations/cockatrice_pt-br.ts @@ -1419,93 +1419,98 @@ This is only saved for moderators and cannot be seen by the banned person. GameSelector - + C&reate &Criar - + &Join &Entrar - - - - - - - - + + + + + + + + Error Erro - + Please join the appropriate room first. - + Wrong password. Senha incorreta. - + Spectators are not allowed in this game. Não são permitidos visitantes neste jogo. - + The game is already full. O jogo está cheio. - + The game does not exist any more. O jogo não existe mais. - + This game is only open to registered users. Este jogo é aberto apenas para usuários registrados. - + This game is only open to its creator's buddies. Este jogo é aberto apenas para os amigos de quem criou o jogo. - + You are being ignored by the creator of this game. Você está sendo ignorado pelo criador deste jogo. - + Join game Entrar no jogo - + Password: Senha: - + Games Jogos - + Show &full games &Mostrar os jogos cheios + + + Show &running games + + &Show full games &Mostrar os jogos cheios - + J&oin as spectator E&ntrar como visitante diff --git a/cockatrice/translations/cockatrice_pt.ts b/cockatrice/translations/cockatrice_pt.ts index 351b8b981..a985f0b9d 100644 --- a/cockatrice/translations/cockatrice_pt.ts +++ b/cockatrice/translations/cockatrice_pt.ts @@ -1419,93 +1419,98 @@ This is only saved for moderators and cannot be seen by the banned person. GameSelector - - - - - - - - + + + + + + + + Error Erro - + Please join the appropriate room first. - + Wrong password. Password incorrecta. - + Spectators are not allowed in this game. Não são permitidos espectadores neste jogo. - + The game is already full. O jogo já se encontra cheio. - + The game does not exist any more. O jogo já não existe. - + This game is only open to registered users. Este jogo só está aberto a utilizadores registados. - + This game is only open to its creator's buddies. Este jogo só está aberto aos amigos do seu criador. - + You are being ignored by the creator of this game. Você está a ser ignorado pelo criador deste jogo. - + Join game Entrar no jogo - + Password: Password: - + Games Jogos - + Show &full games &Mostrar jogos cheios + + + Show &running games + + &Show full games &Mostrar jogos cheios - + C&reate &Criar - + &Join &Entrar - + J&oin as spectator Entrar como &espectador diff --git a/cockatrice/translations/cockatrice_ru.ts b/cockatrice/translations/cockatrice_ru.ts index 8f875c2a9..ff02c2a11 100644 --- a/cockatrice/translations/cockatrice_ru.ts +++ b/cockatrice/translations/cockatrice_ru.ts @@ -1358,89 +1358,94 @@ This is only saved for moderators and cannot be seen by the banned person. GameSelector - - - - - - - - + + + + + + + + Error Ошибка - + Please join the appropriate room first. - + Wrong password. Неверный пароль. - + Spectators are not allowed in this game. В эту игру не пускают зрителей. - + The game is already full. Все места заняты! =Ь - + The game does not exist any more. Эта игра была удалена. - + This game is only open to registered users. Доступно только для зарегистрированных. - + This game is only open to its creator's buddies. Доступно только для друзей. - + You are being ignored by the creator of this game. Вы добавлены в игнор-лист данного игрока. - + Join game Присоединиться - + Password: Пароль: - + Games Игры - + Show &full games Показывать &текущие - + + Show &running games + + + + C&reate С&оздать - + &Join &Присоединиться - + J&oin as spectator П&рисоединиться как зритель diff --git a/cockatrice/translations/cockatrice_sk.ts b/cockatrice/translations/cockatrice_sk.ts index dddb74650..1a1beeac1 100644 --- a/cockatrice/translations/cockatrice_sk.ts +++ b/cockatrice/translations/cockatrice_sk.ts @@ -1203,89 +1203,94 @@ This is only saved for moderators and cannot be seen by the banned person. GameSelector - - - - - - - - + + + + + + + + Error - + Please join the appropriate room first. - + Wrong password. - + Spectators are not allowed in this game. - + The game is already full. - + The game does not exist any more. - + This game is only open to registered users. - + This game is only open to its creator's buddies. - + You are being ignored by the creator of this game. - + Join game - + Password: - + Games - + Show &full games - + + Show &running games + + + + C&reate - + &Join - + J&oin as spectator diff --git a/common/protocol_datastructures.cpp b/common/protocol_datastructures.cpp index 3e4564c86..7d68434af 100644 --- a/common/protocol_datastructures.cpp +++ b/common/protocol_datastructures.cpp @@ -40,7 +40,7 @@ ServerInfo_UserList::ServerInfo_UserList(const QString &_itemType, const QList &_gameTypes, ServerInfo_User *_creatorInfo, bool _onlyBuddies, bool _onlyRegistered, bool _spectatorsAllowed, bool _spectatorsNeedPassword, int _spectatorCount) +ServerInfo_Game::ServerInfo_Game(int _roomId, int _gameId, const QString &_description, bool _hasPassword, int _playerCount, int _maxPlayers, bool _started, const QList &_gameTypes, ServerInfo_User *_creatorInfo, bool _onlyBuddies, bool _onlyRegistered, bool _spectatorsAllowed, bool _spectatorsNeedPassword, int _spectatorCount) : SerializableItem_Map("game") { insertItem(new SerializableItem_Int("room_id", _roomId)); @@ -49,6 +49,7 @@ ServerInfo_Game::ServerInfo_Game(int _roomId, int _gameId, const QString &_descr insertItem(new SerializableItem_Bool("has_password", _hasPassword)); insertItem(new SerializableItem_Int("player_count", _playerCount)); insertItem(new SerializableItem_Int("max_players", _maxPlayers)); + insertItem(new SerializableItem_Bool("started", _started)); if (!_creatorInfo) _creatorInfo = new ServerInfo_User; insertItem(_creatorInfo); diff --git a/common/protocol_datastructures.h b/common/protocol_datastructures.h index 6ad7cd095..a3843a3d7 100644 --- a/common/protocol_datastructures.h +++ b/common/protocol_datastructures.h @@ -69,7 +69,7 @@ public: class ServerInfo_Game : public SerializableItem_Map { public: - ServerInfo_Game(int _roomId = -1, int _gameId = -1, const QString &_description = QString(), bool _hasPassword = false, int _playerCount = -1, int _maxPlayers = -1, const QList &_gameTypes = QList(), ServerInfo_User *creatorInfo = 0, bool _onlyBuddies = false, bool _onlyRegistered = false, bool _spectatorsAllowed = false, bool _spectatorsNeedPassword = false, int _spectatorCount = -1); + ServerInfo_Game(int _roomId = -1, int _gameId = -1, const QString &_description = QString(), bool _hasPassword = false, int _playerCount = -1, int _maxPlayers = -1, bool _started = false, const QList &_gameTypes = QList(), ServerInfo_User *creatorInfo = 0, bool _onlyBuddies = false, bool _onlyRegistered = false, bool _spectatorsAllowed = false, bool _spectatorsNeedPassword = false, int _spectatorCount = -1); static SerializableItem *newItem() { return new ServerInfo_Game; } int getRoomId() const { return static_cast(itemMap.value("room_id"))->getData(); } int getGameId() const { return static_cast(itemMap.value("game_id"))->getData(); } @@ -77,6 +77,7 @@ public: bool getHasPassword() const { return static_cast(itemMap.value("has_password"))->getData(); } int getPlayerCount() const { return static_cast(itemMap.value("player_count"))->getData(); } int getMaxPlayers() const { return static_cast(itemMap.value("max_players"))->getData(); } + bool getStarted() const { return static_cast(itemMap.value("started"))->getData(); } QList getGameTypes() const { return typecastItemList(); } ServerInfo_User *getCreatorInfo() const { return static_cast(itemMap.value("user")); } bool getOnlyBuddies() const { return static_cast(itemMap.value("only_buddies"))->getData(); } diff --git a/common/server_card.cpp b/common/server_card.cpp index 3d34ac530..6cafdd903 100644 --- a/common/server_card.cpp +++ b/common/server_card.cpp @@ -19,8 +19,8 @@ ***************************************************************************/ #include "server_card.h" -Server_Card::Server_Card(QString _name, int _id, int _coord_x, int _coord_y) - : id(_id), coord_x(_coord_x), coord_y(_coord_y), name(_name), tapped(false), attacking(false), facedown(false), color(QString()), power(-1), toughness(-1), annotation(QString()), destroyOnZoneChange(false), doesntUntap(false), parentCard(0) +Server_Card::Server_Card(QString _name, int _id, int _coord_x, int _coord_y, Server_CardZone *_zone) + : zone(_zone), id(_id), coord_x(_coord_x), coord_y(_coord_y), name(_name), tapped(false), attacking(false), facedown(false), color(QString()), power(-1), toughness(-1), annotation(QString()), destroyOnZoneChange(false), doesntUntap(false), parentCard(0) { } diff --git a/common/server_card.h b/common/server_card.h index de84d21ce..a908befaf 100644 --- a/common/server_card.h +++ b/common/server_card.h @@ -46,7 +46,7 @@ private: Server_Card *parentCard; QList attachedCards; public: - Server_Card(QString _name, int _id, int _coord_x, int _coord_y); + Server_Card(QString _name, int _id, int _coord_x, int _coord_y, Server_CardZone *_zone = 0); ~Server_Card(); Server_CardZone *getZone() const { return zone; } diff --git a/common/server_cardzone.cpp b/common/server_cardzone.cpp index 8738afab9..dd1db3eee 100644 --- a/common/server_cardzone.cpp +++ b/common/server_cardzone.cpp @@ -52,10 +52,12 @@ int Server_CardZone::removeCard(Server_Card *card) int index = cards.indexOf(card); cards.removeAt(index); + card->setZone(0); + return index; } -Server_Card *Server_CardZone::getCard(int id, bool remove, int *position) +Server_Card *Server_CardZone::getCard(int id, int *position) { QMutexLocker locker(&player->getGame()->gameMutex); @@ -65,10 +67,6 @@ Server_Card *Server_CardZone::getCard(int id, bool remove, int *position) while (CardIterator.hasNext()) { Server_Card *tmp = CardIterator.next(); if (tmp->getId() == id) { - if (remove) { - cards.removeAt(i); - tmp->setZone(0); - } if (position) *position = i; return tmp; @@ -80,10 +78,6 @@ Server_Card *Server_CardZone::getCard(int id, bool remove, int *position) if ((id >= cards.size()) || (id < 0)) return NULL; Server_Card *tmp = cards[id]; - if (remove) { - cards.removeAt(id); - tmp->setZone(0); - } if (position) *position = id; return tmp; diff --git a/common/server_cardzone.h b/common/server_cardzone.h index 62a129a1d..898e89c78 100644 --- a/common/server_cardzone.h +++ b/common/server_cardzone.h @@ -41,7 +41,7 @@ public: ~Server_CardZone(); int removeCard(Server_Card *card); - Server_Card *getCard(int id, bool remove, int *position = NULL); + Server_Card *getCard(int id, int *position = NULL); int getCardsBeingLookedAt() const { return cardsBeingLookedAt; } void setCardsBeingLookedAt(int _cardsBeingLookedAt) { cardsBeingLookedAt = _cardsBeingLookedAt; } diff --git a/common/server_game.cpp b/common/server_game.cpp index bc14c7e96..5838e3f97 100644 --- a/common/server_game.cpp +++ b/common/server_game.cpp @@ -160,6 +160,8 @@ void Server_Game::doStartGameIfReady() */ activePlayer = -1; nextTurn(); + + room->broadcastGameListUpdate(this); } void Server_Game::startGameIfReady() @@ -490,7 +492,7 @@ ServerInfo_Game *Server_Game::getInfo() const if (players.isEmpty()) // Game is closing - return new ServerInfo_Game(room->getId(), getGameId(), QString(), false, 0, getMaxPlayers(), QList(), 0, false, 0); + return new ServerInfo_Game(room->getId(), getGameId(), QString(), false, 0, getMaxPlayers(), false, QList(), 0, false, 0); else { // Game is open @@ -505,6 +507,7 @@ ServerInfo_Game *Server_Game::getInfo() const !getPassword().isEmpty(), getPlayerCount(), getMaxPlayers(), + gameStarted, gameTypeList, new ServerInfo_User(getCreatorInfo(), false), onlyBuddies, diff --git a/common/server_player.cpp b/common/server_player.cpp index e56953803..3a9899a97 100644 --- a/common/server_player.cpp +++ b/common/server_player.cpp @@ -127,7 +127,7 @@ void Server_Player::setupZones() if (!currentCard) continue; for (int k = 0; k < currentCard->getNumber(); ++k) - z->cards.append(new Server_Card(currentCard->getName(), nextCardId++, 0, 0)); + z->cards.append(new Server_Card(currentCard->getName(), nextCardId++, 0, 0, z)); } } @@ -334,7 +334,7 @@ ResponseCode Server_Player::moveCard(CommandContainer *cont, Server_CardZone *st QMap cardProperties; for (int i = 0; i < _cards.size(); ++i) { int position; - Server_Card *card = startzone->getCard(_cards[i]->getCardId(), false, &position); + Server_Card *card = startzone->getCard(_cards[i]->getCardId(), &position); if (!card) return RespNameNotFound; if (!card->getAttachedCards().isEmpty() && !targetzone->isColumnEmpty(x, y)) @@ -510,7 +510,7 @@ ResponseCode Server_Player::setCardAttrHelper(CommandContainer *cont, const QStr return RespInvalidCommand; } } else { - Server_Card *card = zone->getCard(cardId, false); + Server_Card *card = zone->getCard(cardId); if (!card) return RespNameNotFound; result = card->setAttribute(attrName, attrValue, false); diff --git a/common/server_protocolhandler.cpp b/common/server_protocolhandler.cpp index 974869e75..2db831263 100644 --- a/common/server_protocolhandler.cpp +++ b/common/server_protocolhandler.cpp @@ -768,7 +768,7 @@ ResponseCode Server_ProtocolHandler::cmdFlipCard(Command_FlipCard *cmd, CommandC if (!zone->hasCoords()) return RespContextError; - Server_Card *card = zone->getCard(cmd->getCardId(), false); + Server_Card *card = zone->getCard(cmd->getCardId()); if (!card) return RespNameNotFound; @@ -797,7 +797,7 @@ ResponseCode Server_ProtocolHandler::cmdAttachCard(Command_AttachCard *cmd, Comm if (!startzone) return RespNameNotFound; - Server_Card *card = startzone->getCard(cmd->getCardId(), false); + Server_Card *card = startzone->getCard(cmd->getCardId()); if (!card) return RespNameNotFound; @@ -819,7 +819,7 @@ ResponseCode Server_ProtocolHandler::cmdAttachCard(Command_AttachCard *cmd, Comm // Possibly a flag will have to be introduced for this sometime. if (!targetzone->hasCoords()) return RespContextError; - targetCard = targetzone->getCard(cmd->getTargetCardId(), false); + targetCard = targetzone->getCard(cmd->getTargetCardId()); if (targetCard) if (targetCard->getParentCard()) return RespContextError; @@ -929,14 +929,14 @@ ResponseCode Server_ProtocolHandler::cmdCreateArrow(Command_CreateArrow *cmd, Co return RespNameNotFound; if (startZone->getType() != PublicZone) return RespContextError; - Server_Card *startCard = startZone->getCard(cmd->getStartCardId(), false); + Server_Card *startCard = startZone->getCard(cmd->getStartCardId()); if (!startCard) return RespNameNotFound; Server_Card *targetCard = 0; if (!playerTarget) { if (targetZone->getType() != PublicZone) return RespContextError; - targetCard = targetZone->getCard(cmd->getTargetCardId(), false); + targetCard = targetZone->getCard(cmd->getTargetCardId()); } Server_ArrowTarget *targetItem; @@ -1015,7 +1015,7 @@ ResponseCode Server_ProtocolHandler::cmdSetCardCounter(Command_SetCardCounter *c if (!zone->hasCoords()) return RespContextError; - Server_Card *card = zone->getCard(cmd->getCardId(), false); + Server_Card *card = zone->getCard(cmd->getCardId()); if (!card) return RespNameNotFound; @@ -1042,7 +1042,7 @@ ResponseCode Server_ProtocolHandler::cmdIncCardCounter(Command_IncCardCounter *c if (!zone->hasCoords()) return RespContextError; - Server_Card *card = zone->getCard(cmd->getCardId(), false); + Server_Card *card = zone->getCard(cmd->getCardId()); if (!card) return RespNameNotFound; @@ -1255,7 +1255,7 @@ ResponseCode Server_ProtocolHandler::cmdRevealCards(Command_RevealCards *cmd, Co return RespContextError; cardsToReveal.append(zone->cards.at(rng->getNumber(0, zone->cards.size() - 1))); } else { - Server_Card *card = zone->getCard(cmd->getCardId(), false); + Server_Card *card = zone->getCard(cmd->getCardId()); if (!card) return RespNameNotFound; cardsToReveal.append(card);