diff --git a/vassal-app/src/main/java/VASSAL/counters/PlaceMarker.java b/vassal-app/src/main/java/VASSAL/counters/PlaceMarker.java index d688a59471..a4e2b58b9b 100644 --- a/vassal-app/src/main/java/VASSAL/counters/PlaceMarker.java +++ b/vassal-app/src/main/java/VASSAL/counters/PlaceMarker.java @@ -237,65 +237,65 @@ protected Command placeMarker(boolean clearParentId) { p = getMap().snapTo(p); } - if (m.getStackMetrics().isStackingEnabled() && - !Boolean.TRUE.equals(marker.getProperty(Properties.NO_STACK)) && - !Boolean.TRUE.equals(outer.getProperty(Properties.NO_STACK)) && - m.getPieceCollection().canMerge(outer, marker)) { - GamePiece target = outer; - int index = -1; - Stack parent = getParent(); - - if (parent == null) { - // we're not in a stack now, but we will be _after_ the merge - if (placement == STACK_BOTTOM || placement == BELOW) { - index = 0; - } - } - else { - // we're in a stack already - switch (placement) { - case STACK_TOP: - target = parent; - break; - case STACK_BOTTOM: - index = 0; - break; - case ABOVE: - break; - case BELOW: - index = parent.indexOf(outer); - } - } - - c = m.getStackMetrics().merge(target, marker); + if ( xOffset == 0 && yOffset == 0 && m.getStackMetrics().isStackingEnabled() && + !Boolean.TRUE.equals(marker.getProperty(Properties.NO_STACK)) && + !Boolean.TRUE.equals(outer.getProperty(Properties.NO_STACK)) && + m.getPieceCollection().canMerge(outer, marker)) { + GamePiece target = outer; + int index = -1; + Stack parent = getParent(); - if (index >= 0) { - // we need to adjust the marker's position in the Stack if (parent == null) { - // get the newly formed Stack if there hadn't been one before - parent = target.getParent(); + // we're not in a stack now, but we will be _after_ the merge + if (placement == STACK_BOTTOM || placement == BELOW) { + index = 0; + } + } + else { + // we're in a stack already + switch (placement) { + case STACK_TOP: + target = parent; + break; + case STACK_BOTTOM: + index = 0; + break; + case ABOVE: + break; + case BELOW: + index = parent.indexOf(outer); + } } - final ChangeTracker ct = new ChangeTracker(parent); - parent.insert(marker, index); - c = c.append(ct.getChangeCommand()); - } - m.repaint(); - } - else if (m.getStackMetrics().isStackingEnabled() && !Boolean.TRUE.equals(marker.getProperty(Properties.NO_STACK))) { - c = m.placeOrMerge(marker, p); - final Stack parent = marker.getParent(); - if ((parent != null) && (parent.pieceCount > 1)) { - if ((placement == STACK_BOTTOM) || (placement == BELOW)) { + c = m.getStackMetrics().merge(target, marker); + + if (index >= 0) { + // we need to adjust the marker's position in the Stack + if (parent == null) { + // get the newly formed Stack if there hadn't been one before + parent = target.getParent(); + } final ChangeTracker ct = new ChangeTracker(parent); - parent.insert(marker, 0); + parent.insert(marker, index); c = c.append(ct.getChangeCommand()); } + + m.repaint(); + } + else if (xOffset == 0 && yOffset == 0 && m.getStackMetrics().isStackingEnabled() && !Boolean.TRUE.equals(marker.getProperty(Properties.NO_STACK))) { + c = m.placeOrMerge(marker, p); + final Stack parent = marker.getParent(); + if ((parent != null) && (parent.pieceCount > 1)) { + if ((placement == STACK_BOTTOM) || (placement == BELOW)) { + final ChangeTracker ct = new ChangeTracker(parent); + parent.insert(marker, 0); + c = c.append(ct.getChangeCommand()); + } + } + } + else { + c = m.placeAt(marker, p); } - } - else { - c = m.placeAt(marker, p); - } // Set Our ParentID into the markers parent UniqueID. May have been called by Replace, in which case we do not set a parent Id as the parent will be deleted if (!clearParentId) {