Skip to content

Commit

Permalink
Miscellaneous deobfuscation in client code
Browse files Browse the repository at this point in the history
These are some small changes that did not really fit in with other
commits.
  • Loading branch information
StenAL committed May 18, 2024
1 parent 8128b05 commit 87324a3
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 75 deletions.
6 changes: 2 additions & 4 deletions client/src/main/java/agolf/game/GameBackgroundCanvas.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,11 @@ public void update(Graphics g) {
}

protected String[] generateTrackInformation() {
String[] var1 = new String[]{this.trackAuthor, this.trackName, this.trackFirstBest, this.trackLastBest};
return var1;
return new String[]{this.trackAuthor, this.trackName, this.trackFirstBest, this.trackLastBest};
}

protected int[][] generateTrackStatistics() {
int[][] var1 = new int[][]{this.trackStats, this.trackRatings};
return var1;
return new int[][]{this.trackStats, this.trackRatings};
}

//this useless func is called when we get start packet
Expand Down
2 changes: 1 addition & 1 deletion client/src/main/java/agolf/game/GameCanvas.java
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ public synchronized void mousePressed(MouseEvent event) {
this.removeMouseListener(this);
this.removeKeyListener(this);
this.setCursor(cursorDefault);
if (super.gameContainer.gamePanel.canStroke(true)) {
if (super.gameContainer.gamePanel.tryStroke(true)) {
super.gameContainer.gamePanel.setBeginStroke(this.currentPlayerID, x, y, this.shootingMode);
//this.doHackedStroke(this.currentPlayerID, true, x, y, this.keyCountMod4);
this.doStroke(this.currentPlayerID, true, x, y, this.shootingMode);
Expand Down
8 changes: 4 additions & 4 deletions client/src/main/java/agolf/game/GameControlPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ protected void displaySkipButton() {
this.setVisible(true);
}

protected void method327(int state) {
protected void setState(int state) {
this.setVisible(false);
this.removeAll();
this.skipButtonVisible = false;
Expand Down Expand Up @@ -130,8 +130,8 @@ protected void method327(int state) {
if (this.playerCount > 1) {
this.playerNamesDisplayModeChoicer = new Choicer();

for (int var2 = 0; var2 < 4; ++var2) {
this.playerNamesDisplayModeChoicer.addItem(this.gameContainer.textManager.getGame("GameControl_Names" + var2));
for (int option = 0; option < 4; ++option) {
this.playerNamesDisplayModeChoicer.addItem(this.gameContainer.textManager.getGame("GameControl_Names" + option));
}

this.playerNamesDisplayModeChoicer.select(this.playerCount <= 2 ? 0 : 3);
Expand Down Expand Up @@ -159,7 +159,7 @@ protected void method329() {
this.remove(this.buttonNewGame);
}

protected void method330() {
protected void refreshBackButton() {
if (this.playerCount != 1) {
this.setVisible(false);
this.remove(this.buttonBack);
Expand Down
42 changes: 21 additions & 21 deletions client/src/main/java/agolf/game/GamePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ else if (args[1].equals("part")) { // player left game
String playerName = this.gamePlayerInfoPanel.playerNames[playerId];
this.gameChatPanel.addMessage(this.gameContainer.textManager.getGame("GameChat_Part", playerName));
this.gameChatPanel.removeUserColour(playerName);
this.gameControlPanel.method330();
this.gameControlPanel.refreshBackButton();
} else if (args[1].equals("say")) {
int playerId = Integer.parseInt(args[2]);
this.gameChatPanel.addSay(playerId, this.gamePlayerInfoPanel.playerNames[playerId], args[3], false);
Expand Down Expand Up @@ -219,7 +219,7 @@ else if (args[1].equals("part")) { // player left game

this.aBoolean363 = false;
this.gameCanvas.createMap(16777216);
this.gamePlayerInfoPanel.method359();
this.gamePlayerInfoPanel.reset();
this.gameTrackInfoPanel.resetCurrentTrack();
this.setState(1);
}
Expand Down Expand Up @@ -333,7 +333,7 @@ else if (args[1].equals("starttrack")) {
}
} else if (args[1].equals("beginstroke")) {
int playerId = Integer.parseInt(args[2]);
this.gamePlayerInfoPanel.method363(playerId, false);
this.gamePlayerInfoPanel.strokeStartedOrEnded(playerId, false);
this.gameContainer.soundManager.playGameMove();
this.gameCanvas.decodeCoords(playerId, false, args[3]);

Expand Down Expand Up @@ -394,7 +394,7 @@ protected void sendChatMessage(String message) {

protected void setBeginStroke(int playerId, int x, int y, int shootingMode) {
this.gameTrackInfoPanel.method384();
this.gamePlayerInfoPanel.method363(playerId, false);
this.gamePlayerInfoPanel.strokeStartedOrEnded(playerId, false);
String data = "beginstroke\t" + this.encodeCoords(x, y, shootingMode);
this.gameContainer.connection.writeData("game\t" + data);
this.gameContainer.soundManager.playGameMove();
Expand All @@ -403,23 +403,23 @@ protected void setBeginStroke(int playerId, int x, int y, int shootingMode) {
protected void method336() {
String var1 = this.gameCanvas.method142();
if (var1 != null) {
this.gamePlayerInfoPanel.method363(0, false);
this.gamePlayerInfoPanel.strokeStartedOrEnded(0, false);
String var2 = "beginstroke\t" + var1;
this.gameContainer.connection.writeData("game\t" + var2);
this.gameCanvas.decodeCoords(0, true, var1);
}
}

protected boolean isValidPlayerID(int var1) {
return this.gamePlayerInfoPanel.method361(var1);
protected boolean isValidPlayerID(int player) {
return this.gamePlayerInfoPanel.isOverStrokeLimit(player);
}

protected void sendEndStroke(int playerid, SynchronizedBool[] settings, int var3) {
String data = "endstroke\t" + playerid + "\t";

for (int index = 0; index < settings.length; ++index) {
if (var3 == index && !settings[index].get()) {
this.gamePlayerInfoPanel.method363(index, true);
this.gamePlayerInfoPanel.strokeStartedOrEnded(index, true);
data = data + "p";
} else {
data = data + (settings[index].get() ? "t" : "f");
Expand Down Expand Up @@ -469,18 +469,18 @@ protected void leaveGame() {
}

protected void rateTrack(int track, int rating) {
String var3 = "rate\t" + track + "\t" + rating;
this.gameContainer.connection.writeData("game\t" + var3);
String message = "rate\t" + track + "\t" + rating;
this.gameContainer.connection.writeData("game\t" + message);
}

protected void respondNewGame(int track, boolean accept) {// why track
String var3 = "rejectaccept\t" + track + "\t" + (accept ? "t" : "f");
this.gameContainer.connection.writeData("game\t" + var3);
String message = "rejectaccept\t" + track + "\t" + (accept ? "t" : "f");
this.gameContainer.connection.writeData("game\t" + message);
}

protected void method345(int var1) {
String var2 = "backtoprivate\t" + var1;
this.gameContainer.connection.writeData("game\t" + var2);
protected void backToPrivate(int currentTrack) {
String message = "backtoprivate\t" + currentTrack;
this.gameContainer.connection.writeData("game\t" + message);
}

protected boolean maxFps() {
Expand All @@ -499,7 +499,7 @@ public void broadcastMessage(String message) {
this.gameChatPanel.addBroadcastMessage(message);
}

protected boolean canStroke(boolean stopInfoPanel) {
protected boolean tryStroke(boolean didNotTimeout) {
synchronized (canStrokeLock) {
if (this.isWaitingForTurnStart) {
return false;
Expand All @@ -508,7 +508,7 @@ protected boolean canStroke(boolean stopInfoPanel) {
this.isWaitingForTurnStart = true;
}

if (stopInfoPanel) {// ???????????????????????????????????
if (didNotTimeout) {
this.gamePlayerInfoPanel.stopTimer();
} else {
this.gameCanvas.doZeroLengthStroke();
Expand Down Expand Up @@ -549,13 +549,13 @@ private void addMultiPlayerPanels(int mode) {
private void setState(int state) {
if (state != this.state) {
this.state = state;
this.gamePlayerInfoPanel.method371(state);
this.gameControlPanel.method327(state);
this.gamePlayerInfoPanel.setState(state);
this.gameControlPanel.setState(state);
}
}

private String encodeCoords(int x, int y, int mod) {
int var4 = x * 375 * 4 + y * 4 + mod;//mod.. or something, possible values 0..3
private String encodeCoords(int x, int y, int shootingMode) {
int var4 = x * 375 * 4 + y * 4 + shootingMode;

String out = Integer.toString(var4, 36);
while (out.length() < 4) {
Expand Down
25 changes: 13 additions & 12 deletions client/src/main/java/agolf/game/GamePlayerInfoPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,8 @@ protected void init(int playerCount, int trackCount, int maxStrokes, int strokeT
this.playerReadyForNewGame = new boolean[playerCount];

for (int player = 0; player < playerCount; ++player) {
this.playerNames[player] = this.playerClans[player] = null;
this.playerNames[player] = null;
this.playerClans[player] = null;
this.playerLeaveReasons[player] = 0;
}

Expand All @@ -306,7 +307,7 @@ protected void init(int playerCount, int trackCount, int maxStrokes, int strokeT
}

this.playerId = -1;
this.method359();
this.reset();
this.initialized = true;
this.repaint();
}
Expand Down Expand Up @@ -344,7 +345,7 @@ protected boolean setPlayerPartStatus(int playerId, int status) {
return false;
}

protected void method359() {
protected void reset() {
for (int player = 0; player < this.playerCount; ++player) {
for (int track = 0; track < this.trackCount; ++track) {
this.trackStrokes[player][track].set(0);
Expand All @@ -370,16 +371,16 @@ protected int startNextTrack() {
return this.trackScoresMultipliers[this.currentTrackIndex];
}

protected boolean method361(int var1) {
protected boolean isOverStrokeLimit(int player) {
if (this.maxStrokes == 0) {
return false;
} else {
int var2 = this.trackStrokes[var1][this.currentTrackIndex].get();
int strokes = this.trackStrokes[player][this.currentTrackIndex].get();
if (this.trackScoring == 0) {
var2 /= this.trackScoresMultipliers[this.currentTrackIndex];
strokes /= this.trackScoresMultipliers[this.currentTrackIndex];
}

return var2 >= this.maxStrokes;
return strokes >= this.maxStrokes;
}
}

Expand All @@ -397,7 +398,7 @@ protected boolean startTurn(int playerId) {
return playerId == this.playerId;
}

protected void method363(int playerId, boolean isStrokeEnd) {
protected void strokeStartedOrEnded(int playerId, boolean isStrokeEnd) {
if (this.trackScoring == 0) {
int var3 = !isStrokeEnd ? this.trackScoresMultipliers[this.currentTrackIndex] : 1;
this.trackStrokes[playerId][this.currentTrackIndex].get_upd(var3);
Expand Down Expand Up @@ -462,12 +463,12 @@ protected void readyForNewGameLocal() {
this.readyForNewGame(this.playerId);
}

protected void readyForNewGame(int var1) {
this.playerReadyForNewGame[var1] = true;
protected void readyForNewGame(int player) {
this.playerReadyForNewGame[player] = true;
this.repaint();
}

protected void method371(int state) {
protected void setState(int state) {
if (state == 2) {
for (int player = 0; player < this.playerCount && state == 2; ++player) {
if (this.playerLeaveReasons[player] != 0) {
Expand Down Expand Up @@ -577,7 +578,7 @@ protected boolean run() {
--this.currentTimeForShot;
this.repaint();
if (this.currentTimeForShot <= 0) {
this.gameContainer.gamePanel.canStroke(false);
this.gameContainer.gamePanel.tryStroke(false);
this.stopTimer();
return false;
} else {
Expand Down
63 changes: 33 additions & 30 deletions client/src/main/java/agolf/game/GameTrackInfoPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ class GameTrackInfoPanel extends Panel implements ActionListener {
private ConfirmButton buttonBack;
private boolean hasNotRatedTrack;
private boolean trackPending;
private boolean aBoolean436;
private boolean aBoolean437;
private boolean backButtonVisible;
private boolean rButtonVisible;
private Image image;
private Graphics graphics;
private boolean created;
Expand All @@ -65,7 +65,11 @@ protected GameTrackInfoPanel(GameContainer gameContainer, int width, int height,
this.height = height;
this.setSize(width, height);
this.showLongAvgResult = var4;
this.created = this.hasNotRatedTrack = this.trackPending = this.aBoolean436 = this.aBoolean437 = false;
this.created = false;
this.hasNotRatedTrack = false;
this.trackPending = false;
this.backButtonVisible = false;
this.rButtonVisible = false;
this.numTracks = -1;
this.resetCurrentTrack();
}
Expand Down Expand Up @@ -200,8 +204,8 @@ public void actionPerformed(ActionEvent evt) {
this.repaint();
}
else if (evtSource == this.buttonBack) {
this.gameContainer.gamePanel.method345(this.currentTrack);
this.method390(false);
this.gameContainer.gamePanel.backToPrivate(this.currentTrack);
this.setBackButtonVisible(false);
this.repaint();
} else if (evtSource == this.buttonR) {
this.gameContainer.gamePanel.method336();
Expand Down Expand Up @@ -262,18 +266,17 @@ protected void parseTrackInfoStats(String trackAuthor, String trackName, int[] p
this.setHasNotRatedTrack(true);
} else {
this.toggleAcceptRejectButtons(trackTestMode1);
this.method390(trackTestMode2);
this.method391(var9);
this.setBackButtonVisible(trackTestMode2);
this.setRButtonVisible(var9);
}

this.repaint();
}

protected void method384() {
if (this.aBoolean437) {
this.method391(false);
if (this.rButtonVisible) {
this.setRButtonVisible(false);
}

}

protected int method385() {
Expand Down Expand Up @@ -312,22 +315,22 @@ private void create() {
this.buttonR.addActionListener(this);
}

private String[] parseBestPlayerInformation(String var1) {
String[] var2 = new String[]{null, null};
if (var1 != null) {
int var3 = var1.indexOf(44);
var2[0] = var1.substring(0, var3);
var2[1] = var1.substring(var3 + 1);
var3 = var2[1].indexOf(44);
if (var3 > 0) {
var2[1] = var2[1].substring(0, var3);
private String[] parseBestPlayerInformation(String data) {
String[] bestPlayerInformation = new String[]{null, null};
if (data != null) {
int splitPosition = data.indexOf(',');
bestPlayerInformation[0] = data.substring(0, splitPosition);
bestPlayerInformation[1] = data.substring(splitPosition + 1);
splitPosition = bestPlayerInformation[1].indexOf(',');
if (splitPosition > 0) {
bestPlayerInformation[1] = bestPlayerInformation[1].substring(0, splitPosition);
}

long var4 = Long.parseLong(var2[1]);
var2[1] = this.gameContainer.textManager.getDateWithTodayYesterday(var4);
long bestPlayerTimestamp = Long.parseLong(bestPlayerInformation[1]);
bestPlayerInformation[1] = this.gameContainer.textManager.getDateWithTodayYesterday(bestPlayerTimestamp);
}

return var2;
return bestPlayerInformation;
}

private void setHasNotRatedTrack(boolean hasNotRatedTrack) {
Expand Down Expand Up @@ -366,12 +369,12 @@ private void toggleAcceptRejectButtons(boolean trackPending) {
}
}

private void method390(boolean var1) {
private void setBackButtonVisible(boolean backButtonVisible) {
if (!this.gameContainer.safeMode) {
if (var1 != this.aBoolean436) {
this.aBoolean436 = var1;
if (backButtonVisible != this.backButtonVisible) {
this.backButtonVisible = backButtonVisible;
this.setVisible(false);
if (var1) {
if (backButtonVisible) {
this.add(this.buttonBack);
} else {
this.remove(this.buttonBack);
Expand All @@ -382,11 +385,11 @@ private void method390(boolean var1) {
}
}

private void method391(boolean var1) {
if (var1 != this.aBoolean437) {
this.aBoolean437 = var1;
private void setRButtonVisible(boolean rButtonVisible) {
if (rButtonVisible != this.rButtonVisible) {
this.rButtonVisible = rButtonVisible;
this.setVisible(false);
if (var1) {
if (rButtonVisible) {
this.add(this.buttonR);
} else {
this.remove(this.buttonR);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,7 @@ protected void reset() {
public void startGame() {
writeAll(new Packet(PacketType.DATA, Tools.tabularize("game", "start")));
StringBuilder buff = new StringBuilder();
for (int i = 0; i < getPlayers().size(); i++) {
buff.append("t");
}
buff.append("t".repeat(getPlayers().size()));
playStatus = buff.toString().replace("t", "f");
TrackStats track = statsManager.getStats(tracks.get(0));
writeAll(new Packet(PacketType.DATA, Tools.tabularize("game", "resetvoteskip")));
Expand Down

0 comments on commit 87324a3

Please sign in to comment.