From 5bb6073422dfecc038240c24dd6df7bdcd44c55f Mon Sep 17 00:00:00 2001 From: DawnFire42 Date: Sun, 12 Jul 2026 02:33:26 -0400 Subject: [PATCH] Fix card position when added to the stack (#7041) --- .../src/game_graphics/zones/stack_zone.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/cockatrice/src/game_graphics/zones/stack_zone.cpp b/cockatrice/src/game_graphics/zones/stack_zone.cpp index 46ff099ab..184f96d62 100644 --- a/cockatrice/src/game_graphics/zones/stack_zone.cpp +++ b/cockatrice/src/game_graphics/zones/stack_zone.cpp @@ -43,12 +43,18 @@ void StackZone::handleDropEvent(const QList &dragItems, return; } - int index = calcDropIndexFromY(dropPoint.y(), MIN_CARD_VISIBLE); - - // Same-zone no-op: don't move a card onto itself const auto &cards = getLogic()->getCards(); - if (!cards.isEmpty() && startZone == getLogic() && cards.at(index)->getId() == dragItems.at(0)->getId()) { - return; + int index; + if (startZone == getLogic()) { + // Reordering within the zone: use drop position + index = calcDropIndexFromY(dropPoint.y(), MIN_CARD_VISIBLE); + // Same-zone no-op: don't move a card onto itself + if (!cards.isEmpty() && cards.at(index)->getId() == dragItems.at(0)->getId()) { + return; + } + } else { + // Coming from another zone: append at end (top of stack, rendered on top) + index = static_cast(cards.size()); } Command_MoveCard cmd;