Fix offline worlds showing population of 65535

The service has been updated to return -1 when worlds are offline, and then the UI updated to display OFF when the count is less than 0
This commit is contained in:
Adam
2020-11-09 12:41:50 -05:00
parent b031d4c60f
commit 4f3d57d739
2 changed files with 8 additions and 3 deletions

View File

@@ -74,7 +74,7 @@ public class WorldsService
.address(readString(buf))
.activity(readString(buf))
.location(buf.get() & 0xFF)
.players(buf.getShort() & 0xFFFF);
.players(buf.getShort());
worlds.add(worldBuilder.build());
}

View File

@@ -207,7 +207,12 @@ class WorldTableRow extends JPanel
void updatePlayerCount(int playerCount)
{
this.updatedPlayerCount = playerCount;
playerCountField.setText(String.valueOf(playerCount));
playerCountField.setText(playerCountString(playerCount));
}
private static String playerCountString(int playerCount)
{
return playerCount < 0 ? "OFF" : Integer.toString(playerCount);
}
void setPing(int ping)
@@ -272,7 +277,7 @@ class WorldTableRow extends JPanel
JPanel column = new JPanel(new BorderLayout());
column.setBorder(new EmptyBorder(0, 5, 0, 5));
playerCountField = new JLabel(world.getPlayers() + "");
playerCountField = new JLabel(playerCountString(world.getPlayers()));
playerCountField.setFont(FontManager.getRunescapeSmallFont());
column.add(playerCountField, BorderLayout.WEST);