Skip to content

Commit

Permalink
Deobfuscate lobby joining code
Browse files Browse the repository at this point in the history
This revealed artificial delays in joining lobbies, probably as a means
of flood protection. This can be verified by going into a single player
lobby and clicking "Multiplayer", then "Single player" again rapidly and
seeing a blank screen stuck on the sleep timer.
  • Loading branch information
StenAL committed May 27, 2024
1 parent 8bd754d commit b87ac4d
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 32 deletions.
8 changes: 4 additions & 4 deletions client/src/main/java/agolf/GameApplet.java
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,13 @@ protected void setGameState(int panelActive, int lobbyId, int lobbyExtra) {
boolean var5 = false;
if (this.gameContainer.defaultLobby != null) {
if (this.gameContainer.defaultLobby.equalsIgnoreCase("singlehidden")) {
var5 = this.gameContainer.lobbySelectionPanel.method443(1, true);
var5 = this.gameContainer.lobbySelectionPanel.selectLobby(1, true);
} else if (this.gameContainer.defaultLobby.equalsIgnoreCase("single")) {
var5 = this.gameContainer.lobbySelectionPanel.method443(1, false);
var5 = this.gameContainer.lobbySelectionPanel.selectLobby(1, false);
} else if (this.gameContainer.defaultLobby.equalsIgnoreCase("dual")) {
var5 = this.gameContainer.lobbySelectionPanel.method443(2, false);
var5 = this.gameContainer.lobbySelectionPanel.selectLobby(2, false);
} else if (this.gameContainer.defaultLobby.equalsIgnoreCase("multi")) {
var5 = this.gameContainer.lobbySelectionPanel.method443(3, false);
var5 = this.gameContainer.lobbySelectionPanel.selectLobby(3, false);
}

this.gameContainer.defaultLobby = null;
Expand Down
53 changes: 26 additions & 27 deletions client/src/main/java/agolf/LobbySelectPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@

public class LobbySelectPanel extends Panel implements ActionListener, MouseListener, ItemListener {

private static final int[] anIntArray526 = new int[]{3000, 7000, 15000};
private static final int anInt527 = anIntArray526.length;
private static long[] aLongArray528;
private static final int[] lobbyJoinDelays = new int[]{3000, 7000, 15000};
private static long[] lobbyJoinAvailableTimestamps;
private static boolean playHidden;
private GameContainer gameContainer;
private int width;
Expand Down Expand Up @@ -143,41 +142,41 @@ public void itemStateChanged(ItemEvent evt) {
this.gameContainer.graphicsQualityIndex = this.choicerGraphics.getSelectedIndex();
}

public static String method442(int var0) {
if (aLongArray528 == null) {
aLongArray528 = new long[anInt527];
public static String getLobbySelectMessage(int lobbyId) {
if (lobbyJoinAvailableTimestamps == null) {
lobbyJoinAvailableTimestamps = new long[lobbyJoinDelays.length];

for (int var1 = 0; var1 < anInt527; ++var1) {
aLongArray528[var1] = 0L;
for (int i = 0; i < lobbyJoinDelays.length; ++i) {
lobbyJoinAvailableTimestamps[i] = 0L;
}
}

long var2 = System.currentTimeMillis();
long var4 = 0L;
long now = System.currentTimeMillis();
long sleepTime = 0L;

for (int var6 = 0; var6 < anInt527; ++var6) {
long var7 = aLongArray528[var6] + (long) anIntArray526[var6] - var2;
if (var7 > var4) {
var4 = var7;
for (int i = 0; i < lobbyJoinDelays.length; ++i) {
long delayNeededForTimestamp = lobbyJoinAvailableTimestamps[i] + (long) lobbyJoinDelays[i] - now;
if (delayNeededForTimestamp > sleepTime) {
sleepTime = delayNeededForTimestamp;
}
}

for (int var9 = anInt527 - 1; var9 >= 1; --var9) {
aLongArray528[var9] = aLongArray528[var9 - 1];
for (int i = lobbyJoinDelays.length - 1; i >= 1; --i) {
lobbyJoinAvailableTimestamps[i] = lobbyJoinAvailableTimestamps[i - 1];
}

aLongArray528[0] = var2 + var4;
Tools.sleep(var4);
return "select\t" + (var0 <= 2 ? String.valueOf(var0) : "x") + (var0 == 1 && playHidden ? "h" : "");
lobbyJoinAvailableTimestamps[0] = now + sleepTime;
Tools.sleep(sleepTime);
return "select\t" + (lobbyId <= 2 ? String.valueOf(lobbyId) : "x") + (lobbyId == 1 && playHidden ? "h" : "");
}

protected boolean method443(int var1, boolean var2) {
if (this.gameContainer.disableSinglePlayer && var1 == 1) {
protected boolean selectLobby(int lobbyId, boolean playHidden) {
if (this.gameContainer.disableSinglePlayer && lobbyId == 1) {
return false;
} else {
this.checkboxPlayHidden.setState(var2);
playHidden = var2;
return this.selectLobby(var1);
this.checkboxPlayHidden.setState(playHidden);
LobbySelectPanel.playHidden = playHidden;
return this.selectLobby(lobbyId);
}
}

Expand Down Expand Up @@ -281,12 +280,12 @@ private void drawNumPlayers(Graphics g, int x, int numPlayers) {
}
}

private boolean selectLobby(int var1) {
if (this.lobbyNumPlayers[var1 - 1] >= this.lobbyMaxPlayers && this.gameContainer.gameApplet.getPlayerAccessLevel() == 0) {
private boolean selectLobby(int lobbyId) {
if (this.lobbyNumPlayers[lobbyId - 1] >= this.lobbyMaxPlayers && this.gameContainer.gameApplet.getPlayerAccessLevel() == 0) {
return false;
} else {
this.gameContainer.gameApplet.setGameState(0);
this.writeData(method442(var1));
this.writeData(getLobbySelectMessage(lobbyId));
return true;
}
}
Expand Down
2 changes: 1 addition & 1 deletion client/src/main/java/agolf/lobby/LobbyControlPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public void actionPerformed(ActionEvent evt) {

if (lobbyId > 0) {
this.gameContainer.gameApplet.setGameState(0);
this.gameContainer.lobbyPanel.writeData(LobbySelectPanel.method442(lobbyId));
this.gameContainer.lobbyPanel.writeData(LobbySelectPanel.getLobbySelectMessage(lobbyId));
}

}
Expand Down

0 comments on commit b87ac4d

Please sign in to comment.