Skip to content

Commit

Permalink
Merge pull request #4074 from cwisniew/fix-3310
Browse files Browse the repository at this point in the history
Fix for gaps in initative list
  • Loading branch information
cwisniew authored May 21, 2023
2 parents 738eb86 + 77c1f4e commit ef04166
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions src/main/java/net/rptools/maptool/model/Zone.java
Original file line number Diff line number Diff line change
Expand Up @@ -601,18 +601,29 @@ 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) {
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());

Expand Down

0 comments on commit ef04166

Please sign in to comment.