From 43d516672a6687ae872095e57ca053284b093ccc Mon Sep 17 00:00:00 2001 From: Max-Wilhelm Bruker Date: Mon, 19 Oct 2009 21:30:58 +0200 Subject: [PATCH] fix typo; don't point from an item to itself --- cockatrice/src/arrowitem.cpp | 22 +++++++++++++--------- cockatrice/src/player.h | 2 +- servatrice/src/serversocket.cpp | 2 +- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/cockatrice/src/arrowitem.cpp b/cockatrice/src/arrowitem.cpp index 7ab664b6..054cc5f3 100644 --- a/cockatrice/src/arrowitem.cpp +++ b/cockatrice/src/arrowitem.cpp @@ -32,14 +32,18 @@ void ArrowItem::updatePath(const QPointF &endPoint) QLineF line(startPoint, endPoint); qreal lineLength = line.length(); - path = QPainterPath(QPointF(0, -arrowWidth / 2)); - path.lineTo(0, arrowWidth / 2); - path.lineTo(lineLength - headLength, arrowWidth / 2); - path.lineTo(lineLength - headLength, headWidth / 2); - path.lineTo(lineLength, 0); - path.lineTo(lineLength - headLength, -headWidth / 2); - path.lineTo(lineLength - headLength, -arrowWidth / 2); - path.lineTo(0, -arrowWidth / 2); + if (lineLength < headLength) + path = QPainterPath(); + else { + path = QPainterPath(QPointF(0, -arrowWidth / 2)); + path.lineTo(0, arrowWidth / 2); + path.lineTo(lineLength - headLength, arrowWidth / 2); + path.lineTo(lineLength - headLength, headWidth / 2); + path.lineTo(lineLength, 0); + path.lineTo(lineLength - headLength, -headWidth / 2); + path.lineTo(lineLength - headLength, -arrowWidth / 2); + path.lineTo(0, -arrowWidth / 2); + } setPos(startPoint); setTransform(QTransform().rotate(-line.angle())); @@ -79,7 +83,7 @@ void ArrowDragItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) void ArrowDragItem::mouseReleaseEvent(QGraphicsSceneMouseEvent * /*event*/) { - if (targetItem) { + if (targetItem && (targetItem != startItem)) { CardZone *startZone = static_cast(startItem->parentItem()); CardZone *targetZone = static_cast(targetItem->parentItem()); startZone->getPlayer()->client->createArrow( diff --git a/cockatrice/src/player.h b/cockatrice/src/player.h index e3c1fb6b..0ff8cf39 100644 --- a/cockatrice/src/player.h +++ b/cockatrice/src/player.h @@ -42,7 +42,7 @@ public slots: void actShuffle(); void actDrawCard(); void actDrawCards(); - void actMuligan(); + void actMulligan(); void actViewLibrary(); void actViewTopCards(); diff --git a/servatrice/src/serversocket.cpp b/servatrice/src/serversocket.cpp index 5fd01153..4b877cd4 100644 --- a/servatrice/src/serversocket.cpp +++ b/servatrice/src/serversocket.cpp @@ -581,7 +581,7 @@ ReturnMessage::ReturnCode ServerSocket::cmdCreateArrow(const QList &pa return ReturnMessage::ReturnContextError; Card *startCard = startZone->getCard(params[2].toInt(), false); Card *targetCard = targetZone->getCard(params[5].toInt(), false); - if (!startCard || !targetCard) + if (!startCard || !targetCard || (startCard == targetCard)) return ReturnMessage::ReturnContextError; emit broadcastEvent(QString("create_arrow|%1|%2|%3|%4|%5|%6")