Skip to content

Commit

Permalink
Even local clients needs the player list synced
Browse files Browse the repository at this point in the history
Could also have just done `client.setPlayer()` when starting the server, but that's more special-cased logic we don't
need.
  • Loading branch information
kwvanderlinde committed May 28, 2024
1 parent 52c493c commit 978f1f0
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/main/java/net/rptools/maptool/server/MapToolServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,15 @@ private void installConnection(Connection conn, Player player) {
router.addConnection(conn);

assetManagerMap.put(conn.getId(), new AssetTransferManager());

synchronized (playerMap) {
for (Player remotePlayer : playerMap.values()) {
var msg = PlayerConnectedMsg.newBuilder().setPlayer(remotePlayer.toDto());
sendMessage(conn.getId(), Message.newBuilder().setPlayerConnectedMsg(msg).build());
}
}
var msg = PlayerConnectedMsg.newBuilder().setPlayer(player.getTransferablePlayer().toDto());
broadcastMessage(Message.newBuilder().setPlayerConnectedMsg(msg).build());
}

public void addLocalConnection(Connection conn, Player localPlayer) {
Expand All @@ -247,15 +256,6 @@ public void addLocalConnection(Connection conn, Player localPlayer) {
private void addRemoteConnection(Connection conn, Player connPlayer) {
installConnection(conn, connPlayer);

synchronized (playerMap) {
for (Player player : playerMap.values()) {
var msg = PlayerConnectedMsg.newBuilder().setPlayer(player.toDto());
sendMessage(conn.getId(), Message.newBuilder().setPlayerConnectedMsg(msg).build());
}
}
var msg = PlayerConnectedMsg.newBuilder().setPlayer(connPlayer.getTransferablePlayer().toDto());
broadcastMessage(Message.newBuilder().setPlayerConnectedMsg(msg).build());

var msg2 = SetCampaignMsg.newBuilder().setCampaign(campaign.toDto());
sendMessage(conn.getId(), Message.newBuilder().setSetCampaignMsg(msg2).build());
}
Expand Down

0 comments on commit 978f1f0

Please sign in to comment.