diff --git a/cockatrice/src/tab_game.cpp b/cockatrice/src/tab_game.cpp index 770561a0..697173f9 100644 --- a/cockatrice/src/tab_game.cpp +++ b/cockatrice/src/tab_game.cpp @@ -343,7 +343,7 @@ Player *TabGame::addPlayer(int playerId, const QString &playerName) return newPlayer; } -void TabGame::processGameEventContainer(GameEventContainer *cont) +void TabGame::processGameEventContainer(GameEventContainer *cont, AbstractClient *client) { const QList &eventList = cont->getEventList(); GameEventContext *context = cont->getContext(); @@ -359,24 +359,30 @@ void TabGame::processGameEventContainer(GameEventContainer *cont) break; } } - } else switch (event->getItemId()) { - case ItemId_Event_GameStateChanged: eventGameStateChanged(qobject_cast(event), context); break; - case ItemId_Event_PlayerPropertiesChanged: eventPlayerPropertiesChanged(qobject_cast(event), context); break; - case ItemId_Event_Join: eventJoin(qobject_cast(event), context); break; - case ItemId_Event_Leave: eventLeave(qobject_cast(event), context); break; - case ItemId_Event_GameClosed: eventGameClosed(qobject_cast(event), context); break; - case ItemId_Event_SetActivePlayer: eventSetActivePlayer(qobject_cast(event), context); break; - case ItemId_Event_SetActivePhase: eventSetActivePhase(qobject_cast(event), context); break; - case ItemId_Event_Ping: eventPing(qobject_cast(event), context); break; - - default: { - Player *player = players.value(event->getPlayerId(), 0); - if (!player) { - qDebug() << "unhandled game event: invalid player id"; - break; + } else { + if ((clients.size() > 1) && (event->getPlayerId() != -1)) + if (clients.at(event->getPlayerId()) != client) + continue; + + switch (event->getItemId()) { + case ItemId_Event_GameStateChanged: eventGameStateChanged(qobject_cast(event), context); break; + case ItemId_Event_PlayerPropertiesChanged: eventPlayerPropertiesChanged(qobject_cast(event), context); break; + case ItemId_Event_Join: eventJoin(qobject_cast(event), context); break; + case ItemId_Event_Leave: eventLeave(qobject_cast(event), context); break; + case ItemId_Event_GameClosed: eventGameClosed(qobject_cast(event), context); break; + case ItemId_Event_SetActivePlayer: eventSetActivePlayer(qobject_cast(event), context); break; + case ItemId_Event_SetActivePhase: eventSetActivePhase(qobject_cast(event), context); break; + case ItemId_Event_Ping: eventPing(qobject_cast(event), context); break; + + default: { + Player *player = players.value(event->getPlayerId(), 0); + if (!player) { + qDebug() << "unhandled game event: invalid player id"; + break; + } + player->processGameEvent(event, context); + emit userEvent(); } - player->processGameEvent(event, context); - emit userEvent(); } } } diff --git a/cockatrice/src/tab_game.h b/cockatrice/src/tab_game.h index 33cf86fd..8f2f831d 100644 --- a/cockatrice/src/tab_game.h +++ b/cockatrice/src/tab_game.h @@ -153,7 +153,7 @@ public: bool getSpectatorsSeeEverything() const { return spectatorsSeeEverything; } Player *getActiveLocalPlayer() const; - void processGameEventContainer(GameEventContainer *cont); + void processGameEventContainer(GameEventContainer *cont, AbstractClient *client); public slots: void sendGameCommand(GameCommand *command, int playerId); void sendCommandContainer(CommandContainer *cont, int playerId); diff --git a/cockatrice/src/tab_supervisor.cpp b/cockatrice/src/tab_supervisor.cpp index c1f55891..1d151bb4 100644 --- a/cockatrice/src/tab_supervisor.cpp +++ b/cockatrice/src/tab_supervisor.cpp @@ -181,7 +181,7 @@ void TabSupervisor::processGameEventContainer(GameEventContainer *cont) TabGame *tab = gameTabs.value(cont->getGameId()); if (tab) { qDebug() << "gameEvent gameId =" << cont->getGameId(); - tab->processGameEventContainer(cont); + tab->processGameEventContainer(cont, qobject_cast(sender())); } else qDebug() << "gameEvent: invalid gameId"; } diff --git a/cockatrice/src/tablezone.cpp b/cockatrice/src/tablezone.cpp index 33e88203..76ae6415 100644 --- a/cockatrice/src/tablezone.cpp +++ b/cockatrice/src/tablezone.cpp @@ -111,9 +111,7 @@ void TableZone::reorganizeCards() QPointF mapPoint = mapFromGrid(gridPoint); qreal x = mapPoint.x(); qreal y = mapPoint.y(); - - if (player->getMirrored()) - y = height - CARD_HEIGHT - y; + qDebug() << "gridPos=" << gridPoint << "mapPoint=" << mapPoint; int numberAttachedCards = cards[i]->getAttachedCards().size(); qreal actualX = x + numberAttachedCards * CARD_WIDTH / 3.0; @@ -207,7 +205,6 @@ CardItem *TableZone::getCardFromCoords(const QPointF &point) const return getCardFromGrid(gridPoint); } - QPointF TableZone::mapFromGrid(const QPoint &gridPoint) const { if ((gridPoint.y() == 3) && (settingsCache->getEconomicGrid())) @@ -219,18 +216,24 @@ QPointF TableZone::mapFromGrid(const QPoint &gridPoint) const qreal x = marginX + 0.5 * CARD_WIDTH * gridPoint.x(); for (int i = 0; i < gridPoint.x(); ++i) x += gridPointWidth.value(gridPoint.y() * 1000 + i, CARD_WIDTH); - - return QPointF( - x, - boxLineWidth + (CARD_HEIGHT + paddingY) * gridPoint.y() - ); + + qreal y = boxLineWidth + (CARD_HEIGHT + paddingY) * gridPoint.y(); + + if (player->getMirrored()) + y = height - CARD_HEIGHT - y; + + return QPointF(x, y); } } QPoint TableZone::mapToGrid(const QPointF &mapPoint) const { qreal x = mapPoint.x() - marginX; - qreal y = mapPoint.y() + paddingY / 2 - boxLineWidth; + qreal y = mapPoint.y(); + if (player->getMirrored()) + y = height - y; + y += paddingY / 2 - boxLineWidth; + if (x < 0) x = 0; else if (x > width - CARD_WIDTH - marginX)