diff --git a/vassal-app/src/main/java/VASSAL/counters/PlaceMarker.java b/vassal-app/src/main/java/VASSAL/counters/PlaceMarker.java index ced3d24bb2..477f41ff43 100644 --- a/vassal-app/src/main/java/VASSAL/counters/PlaceMarker.java +++ b/vassal-app/src/main/java/VASSAL/counters/PlaceMarker.java @@ -241,61 +241,61 @@ protected Command placeMarker(boolean clearParentId) { !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; - } + 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); - } + } + 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); + 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, index); - c = c.append(ct.getChangeCommand()); + 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(); } - - m.repaint(); + final ChangeTracker ct = new ChangeTracker(parent); + parent.insert(marker, index); + c = c.append(ct.getChangeCommand()); } - 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()); - } + + 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) {