From c5a25b4fcb307a02e5dd746d05c859abf0ffa4a7 Mon Sep 17 00:00:00 2001 From: Mark Benson Date: Sat, 30 Sep 2023 01:40:50 +0100 Subject: [PATCH 1/4] Player joins as side msg shared to all. --- .../src/main/java/VASSAL/build/module/PlayerRoster.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/vassal-app/src/main/java/VASSAL/build/module/PlayerRoster.java b/vassal-app/src/main/java/VASSAL/build/module/PlayerRoster.java index 7f7ff90dcf..f79c608ad6 100644 --- a/vassal-app/src/main/java/VASSAL/build/module/PlayerRoster.java +++ b/vassal-app/src/main/java/VASSAL/build/module/PlayerRoster.java @@ -496,6 +496,8 @@ public void finish() { if (GameModule.getGameModule().isMultiplayerConnected()) { final Command c = new Chatter.DisplayText(GameModule.getGameModule().getChatter(), Resources.getString(GlobalOptions.getInstance().chatterHTMLSupport() ? "PlayerRoster.joined_side_2" : "PlayerRoster.joined_side", GameModule.getGameModule().getPrefs().getValue(GameModule.REAL_NAME), translateSide(newSide))); c.execute(); + GameModule.getGameModule().getServer().sendToOthers(c); + } final Add a = new Add(this, GameModule.getActiveUserId(), GlobalOptions.getInstance().getPlayerId(), newSide); @@ -1149,4 +1151,4 @@ public void validate(Buildable target, ValidationReport report) { } } } -} +} \ No newline at end of file From 11ffd6c5eb800d68cff2f9fd944692b029403d25 Mon Sep 17 00:00:00 2001 From: riverwanderer <58135975+riverwanderer@users.noreply.github.com> Date: Thu, 2 Nov 2023 18:01:03 +0000 Subject: [PATCH 2/4] Change 3x sendToOthers() calls to sendAndLog(), covering both joining and changing sides. Retain previous calls as comments, until this change is proven --- .../VASSAL/build/module/PlayerRoster.java | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/vassal-app/src/main/java/VASSAL/build/module/PlayerRoster.java b/vassal-app/src/main/java/VASSAL/build/module/PlayerRoster.java index f79c608ad6..038fda466e 100644 --- a/vassal-app/src/main/java/VASSAL/build/module/PlayerRoster.java +++ b/vassal-app/src/main/java/VASSAL/build/module/PlayerRoster.java @@ -298,7 +298,8 @@ protected void launch() { a.execute(); c = c.append(a); - gm.getServer().sendToOthers(c); + // how is it if we log ? gm.getServer().sendToOthers(c); + gm.sendAndLog(c); newSide = getMySide(); fireSideChange(mySide, newSide); @@ -478,13 +479,14 @@ public void setup(boolean gameStarting) { */ @Override public void finish() { + final GameModule gm = GameModule.getGameModule(); // In case we set a new password at this step, update the prefs configurer, and write module preferences. - GameModule.getGameModule().getPasswordConfigurer().setValue(GameModule.getUserId()); + gm.getPasswordConfigurer().setValue(GameModule.getUserId()); try { - GameModule.getGameModule().getPrefs().save(); + gm.getPrefs().save(); } catch (IOException e) { - GameModule.getGameModule().warn(Resources.getString("PlayerRoster.failed_pref_write", e.getLocalizedMessage())); + gm.warn(Resources.getString("PlayerRoster.failed_pref_write", e.getLocalizedMessage())); } // Drop into standard routine, starting with checking that the side is still available (race condition mitigation) @@ -493,16 +495,18 @@ public void finish() { // null is a cancel op - player will not connect to the game if (newSide != null) { - if (GameModule.getGameModule().isMultiplayerConnected()) { - final Command c = new Chatter.DisplayText(GameModule.getGameModule().getChatter(), Resources.getString(GlobalOptions.getInstance().chatterHTMLSupport() ? "PlayerRoster.joined_side_2" : "PlayerRoster.joined_side", GameModule.getGameModule().getPrefs().getValue(GameModule.REAL_NAME), translateSide(newSide))); + if (gm.isMultiplayerConnected()) { + final Command c = new Chatter.DisplayText(gm.getChatter(), Resources.getString(GlobalOptions.getInstance().chatterHTMLSupport() ? "PlayerRoster.joined_side_2" : "PlayerRoster.joined_side", gm.getPrefs().getValue(GameModule.REAL_NAME), translateSide(newSide))); c.execute(); - GameModule.getGameModule().getServer().sendToOthers(c); + // trying with logging in place of gm.getServer().sendToOthers(c); + gm.sendAndLog(c); } final Add a = new Add(this, GameModule.getActiveUserId(), GlobalOptions.getInstance().getPlayerId(), newSide); a.execute(); - GameModule.getGameModule().getServer().sendToOthers(a); + // trying with logging in place of gm.getServer().sendToOthers(a); + gm.sendAndLog(a); pickedSide = true; } From 08db33cc00873c772c19f0f90a807cecaa638c6e Mon Sep 17 00:00:00 2001 From: Mark Benson Date: Thu, 7 Dec 2023 13:10:57 +0000 Subject: [PATCH 3/4] Typos. This version always implements gm.sendAndLog(a) in the 3 places that formerly used sendToOthers() --- .../src/main/java/VASSAL/build/module/PlayerRoster.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/vassal-app/src/main/java/VASSAL/build/module/PlayerRoster.java b/vassal-app/src/main/java/VASSAL/build/module/PlayerRoster.java index 038fda466e..9262e60f06 100644 --- a/vassal-app/src/main/java/VASSAL/build/module/PlayerRoster.java +++ b/vassal-app/src/main/java/VASSAL/build/module/PlayerRoster.java @@ -113,7 +113,7 @@ public PlayerRoster() { e -> launch() )); - getLaunchButton().setEnabled(false); // not usuable without a game + getLaunchButton().setEnabled(false); // not usable without a game retireButton = getLaunchButton(); // for compatibility setShowDisabledOptions(false); //AbstractToolbarItem @@ -325,7 +325,7 @@ protected static PlayerRoster getInstance() { return GameModule.getGameModule().getPlayerRoster(); } - /** Return my Untranslatted side */ + /** Return my Untranslated side */ public static String getMySide() { return getMySide(false); } @@ -814,7 +814,7 @@ protected String promptForSide(String newSide) { } } - 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) { // Loops until a valid side is found or op is canceled (repeats side check to minimise race condition window) // Refresh from current game state for (final PlayerInfo p : players) { alreadyTaken.add(p.getLocalizedSide()); @@ -841,7 +841,7 @@ protected String promptForSide(String newSide) { // When player is already connected, offer a hot-seat... // 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. + // Thus, hotseat players can easily cycle through the player positions as they will appear successively as the default. // Common names for Solitaire players (Solitaire, Solo, Referee) do not count as "real" player sides, and will be skipped. // If we have no "next" side available to offer, we stay with the observer side as our default offering. if (alreadyConnected) { From 331c74b563c4b119571af40c77c10e4e0e31e7b5 Mon Sep 17 00:00:00 2001 From: Mark Benson Date: Thu, 7 Dec 2023 13:10:57 +0000 Subject: [PATCH 4/4] Typos. This version always implements gm.sendAndLog(a) in the 3 places that formerly used sendToOthers() --- .../main/java/VASSAL/build/module/PlayerRoster.java | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/vassal-app/src/main/java/VASSAL/build/module/PlayerRoster.java b/vassal-app/src/main/java/VASSAL/build/module/PlayerRoster.java index 038fda466e..4ac0a22198 100644 --- a/vassal-app/src/main/java/VASSAL/build/module/PlayerRoster.java +++ b/vassal-app/src/main/java/VASSAL/build/module/PlayerRoster.java @@ -113,7 +113,7 @@ public PlayerRoster() { e -> launch() )); - getLaunchButton().setEnabled(false); // not usuable without a game + getLaunchButton().setEnabled(false); // not usable without a game retireButton = getLaunchButton(); // for compatibility setShowDisabledOptions(false); //AbstractToolbarItem @@ -298,7 +298,6 @@ protected void launch() { a.execute(); c = c.append(a); - // how is it if we log ? gm.getServer().sendToOthers(c); gm.sendAndLog(c); newSide = getMySide(); @@ -325,7 +324,7 @@ protected static PlayerRoster getInstance() { return GameModule.getGameModule().getPlayerRoster(); } - /** Return my Untranslatted side */ + /** Return my Untranslated side */ public static String getMySide() { return getMySide(false); } @@ -498,14 +497,12 @@ public void finish() { if (gm.isMultiplayerConnected()) { final Command c = new Chatter.DisplayText(gm.getChatter(), Resources.getString(GlobalOptions.getInstance().chatterHTMLSupport() ? "PlayerRoster.joined_side_2" : "PlayerRoster.joined_side", gm.getPrefs().getValue(GameModule.REAL_NAME), translateSide(newSide))); c.execute(); - // trying with logging in place of gm.getServer().sendToOthers(c); gm.sendAndLog(c); } final Add a = new Add(this, GameModule.getActiveUserId(), GlobalOptions.getInstance().getPlayerId(), newSide); a.execute(); - // trying with logging in place of gm.getServer().sendToOthers(a); gm.sendAndLog(a); pickedSide = true; @@ -814,7 +811,7 @@ protected String promptForSide(String newSide) { } } - 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) { // Loops until a valid side is found or op is canceled (repeats side check to minimise race condition window) // Refresh from current game state for (final PlayerInfo p : players) { alreadyTaken.add(p.getLocalizedSide()); @@ -841,7 +838,7 @@ protected String promptForSide(String newSide) { // When player is already connected, offer a hot-seat... // 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. + // Thus, hotseat players can easily cycle through the player positions as they will appear successively as the default. // Common names for Solitaire players (Solitaire, Solo, Referee) do not count as "real" player sides, and will be skipped. // If we have no "next" side available to offer, we stay with the observer side as our default offering. if (alreadyConnected) {