From 9f13254d01decbbc6d067de659d450c9d232ed57 Mon Sep 17 00:00:00 2001 From: Max-Wilhelm Bruker Date: Sun, 3 Feb 2013 18:23:54 +0100 Subject: [PATCH] don't allow players to move cards that are attached to something --- common/server_player.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/common/server_player.cpp b/common/server_player.cpp index 698d5c24f..489c3dcb2 100644 --- a/common/server_player.cpp +++ b/common/server_player.cpp @@ -353,15 +353,21 @@ Response::ResponseCode Server_Player::moveCard(GameEventStorage &ges, Server_Car continue; cardIdsToMove.insert(_cards[i]->card_id()); + // Consistency checks. In case the command contains illegal moves, try to resolve the legal ones still. int position; Server_Card *card = startzone->getCard(_cards[i]->card_id(), &position); if (!card) return Response::RespNameNotFound; + if (card->getParentCard()) + continue; if (!card->getAttachedCards().isEmpty() && !targetzone->isColumnEmpty(x, y)) - return Response::RespContextError; + continue; cardsToMove.append(QPair(card, position)); cardProperties.insert(card, _cards[i]); } + // In case all moves were filtered out, abort. + if (cardsToMove.isEmpty()) + return Response::RespContextError; MoveCardCompareFunctor cmp(startzone == targetzone ? -1 : x); qSort(cardsToMove.begin(), cardsToMove.end(), cmp);