Skip to content

Commit

Permalink
Integrate finish() and promptForSide().
Browse files Browse the repository at this point in the history
  • Loading branch information
riverwanderer committed Sep 9, 2023
1 parent 90f4c27 commit e4ab000
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions vassal-app/src/main/java/VASSAL/build/module/PlayerRoster.java
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ protected void launch() {
}

String newSide;
newSide = promptForSide();
newSide = promptForSide("");
if ((newSide == null) || newSide.equals(mySide)) {
return;
}
Expand Down Expand Up @@ -767,15 +767,14 @@ protected String promptForSide(String newSide) {
boolean fromWizard;
boolean found = false; // Set when we find a usable side

if (newSide == null) {
newSide = "";
if (newSide != null && newSide.isEmpty()) {
fromWizard = false;
}
else {
fromWizard = true;
}

while (newSide != null) { // Loops until a valid side is found or op is canceled (repeats side check to minimuse race condition window)
while (newSide != null && !newSide.isEmpty()) { // Loops until a valid side is found or op is canceled (repeats side check to minimuse race condition window)

for (final PlayerInfo p : players) {
alreadyTaken.add(p.side);
Expand All @@ -798,6 +797,7 @@ protected String promptForSide(String newSide) {
}

availableSides.removeAll(alreadyTaken);
String nextChoice = translatedObserver; // This will be our defaulted choice for the dropdown.

// If a "real" player side is available, we want to offer "the next one" as the default, rather than observer.
// Thus hotseat players can easily cycle through the player positions as they will appear successively as the default.
Expand All @@ -810,14 +810,12 @@ protected String promptForSide(String newSide) {
for (int tries = 0; i != myidx && tries < sides.size(); i = (i + 1) % sides.size(), tries++) { // Wrap-around search of sides
final String s = sides.get(i);
if (!alreadyTaken.contains(s) && !isSoloSide(s)) {
found = true; // Found an available slot that's not our current one and not a "solo" slot.
nextChoice = sides.get(i); // Found an available slot that's not our current one and not a "solo" slot.
break;
}
}
}

final String nextChoice = found ? sides.get(i) : translatedObserver; // This will be our defaulted choice for the dropdown.

availableSides.add(0, translatedObserver);

final GameModule g = GameModule.getGameModule();
Expand Down

0 comments on commit e4ab000

Please sign in to comment.