From d88d6f2c55f880d354d69d0324d780a7536ef5d2 Mon Sep 17 00:00:00 2001 From: Craig Wisniewski Date: Thu, 18 May 2023 21:34:47 +0930 Subject: [PATCH 1/3] Fix for gaps in initative list --- .../java/net/rptools/maptool/model/Zone.java | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/main/java/net/rptools/maptool/model/Zone.java b/src/main/java/net/rptools/maptool/model/Zone.java index 7736e44760..06edd954ba 100644 --- a/src/main/java/net/rptools/maptool/model/Zone.java +++ b/src/main/java/net/rptools/maptool/model/Zone.java @@ -601,18 +601,27 @@ public Zone(Zone zone, boolean keepIds) { } } // Set the initiative list using the newly create tokens. + int newCurrent = -1; + int oldCurrent = zone.initiativeList.getCurrent(); if (saveInitiative.length > 0) { + int newInd = 0; for (int i = 0; i < saveInitiative.length; i++) { Token token = (Token) saveInitiative[i][0]; - initiativeList.insertToken(i, token); - TokenInitiative ti = initiativeList.getTokenInitiative(i); - TokenInitiative oldti = (TokenInitiative) saveInitiative[i][1]; - ti.setHolding(oldti.isHolding()); - ti.setState(oldti.getState()); + if (token != null) { + initiativeList.insertToken(newInd, token); + TokenInitiative ti = initiativeList.getTokenInitiative(newInd); + TokenInitiative oldti = (TokenInitiative) saveInitiative[i][1]; + ti.setHolding(oldti.isHolding()); + ti.setState(oldti.getState()); + if (oldCurrent == i) { + newCurrent = newInd; + } + newInd++; + } } } initiativeList.setZone(this); - initiativeList.setCurrent(zone.initiativeList.getCurrent()); + initiativeList.setCurrent(newCurrent); initiativeList.setRound(zone.initiativeList.getRound()); initiativeList.setHideNPC(zone.initiativeList.isHideNPC()); From 6875a4888e34232a87e400384dcd10101387b1aa Mon Sep 17 00:00:00 2001 From: Craig Wisniewski Date: Thu, 18 May 2023 21:42:28 +0930 Subject: [PATCH 2/3] Add comment --- src/main/java/net/rptools/maptool/model/Zone.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/net/rptools/maptool/model/Zone.java b/src/main/java/net/rptools/maptool/model/Zone.java index 06edd954ba..0b33c2c80f 100644 --- a/src/main/java/net/rptools/maptool/model/Zone.java +++ b/src/main/java/net/rptools/maptool/model/Zone.java @@ -601,6 +601,7 @@ public Zone(Zone zone, boolean keepIds) { } } // Set the initiative list using the newly create tokens. + // We also have to work around old campaign issues where there may be empty positions in the initiative list int newCurrent = -1; int oldCurrent = zone.initiativeList.getCurrent(); if (saveInitiative.length > 0) { From 77c1f4e304f7e711c9ec616cfa32be7fd68909c3 Mon Sep 17 00:00:00 2001 From: Craig Wisniewski Date: Thu, 18 May 2023 21:46:26 +0930 Subject: [PATCH 3/3] spotless --- src/main/java/net/rptools/maptool/model/Zone.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/rptools/maptool/model/Zone.java b/src/main/java/net/rptools/maptool/model/Zone.java index 0b33c2c80f..2459ab8f44 100644 --- a/src/main/java/net/rptools/maptool/model/Zone.java +++ b/src/main/java/net/rptools/maptool/model/Zone.java @@ -601,7 +601,8 @@ public Zone(Zone zone, boolean keepIds) { } } // Set the initiative list using the newly create tokens. - // We also have to work around old campaign issues where there may be empty positions in the initiative list + // We also have to work around old campaign issues where there may be empty positions in the + // initiative list int newCurrent = -1; int oldCurrent = zone.initiativeList.getCurrent(); if (saveInitiative.length > 0) {