fix typo; don't point from an item to itself
This commit is contained in:
parent
c86a1ed4f6
commit
43d516672a
3 changed files with 15 additions and 11 deletions
|
@ -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<CardZone *>(startItem->parentItem());
|
||||
CardZone *targetZone = static_cast<CardZone *>(targetItem->parentItem());
|
||||
startZone->getPlayer()->client->createArrow(
|
||||
|
|
|
@ -42,7 +42,7 @@ public slots:
|
|||
void actShuffle();
|
||||
void actDrawCard();
|
||||
void actDrawCards();
|
||||
void actMuligan();
|
||||
void actMulligan();
|
||||
|
||||
void actViewLibrary();
|
||||
void actViewTopCards();
|
||||
|
|
|
@ -581,7 +581,7 @@ ReturnMessage::ReturnCode ServerSocket::cmdCreateArrow(const QList<QVariant> &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")
|
||||
|
|
Loading…
Reference in a new issue