Skip to content

Commit

Permalink
Possible fix for #13719. This change explicitly bypasses Place Marker…
Browse files Browse the repository at this point in the history
…'s stack operations when an offset is specified.
  • Loading branch information
riverwanderer committed Nov 29, 2024
1 parent 97870c7 commit 6da977c
Showing 1 changed file with 51 additions and 51 deletions.
102 changes: 51 additions & 51 deletions vassal-app/src/main/java/VASSAL/counters/PlaceMarker.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 6da977c

Please sign in to comment.