Skip to content

Commit

Permalink
Merge pull request #106 from StenAL/deobfuscate-gamepanel
Browse files Browse the repository at this point in the history
Deobfuscate more code around GamePanel and GamePlayerInfoPanel
  • Loading branch information
PhilippvK authored Mar 28, 2024
2 parents 392c17d + 46ee568 commit 8744009
Show file tree
Hide file tree
Showing 9 changed files with 352 additions and 358 deletions.
1 change: 0 additions & 1 deletion client/src/main/java/agolf/GameContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ public class GameContainer {// some kind of a container for everything
protected String[] adverts;
public GamePanel gamePanel;
public int graphicsQualityIndex;
public static int anInt992;


public GameContainer(GameApplet gameApplet, Parameters params) {
Expand Down
150 changes: 80 additions & 70 deletions client/src/main/java/agolf/game/GameCanvas.java

Large diffs are not rendered by default.

33 changes: 12 additions & 21 deletions client/src/main/java/agolf/game/GameControlPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@ class GameControlPanel extends Panel implements ActionListener, ItemListener {
private ColorButton buttonSkip;
private ColorButton buttonNewGame;
private ColorButton buttonBack;
private Choicer choicerNames;
private Choicer playerNamesDisplayModeChoicer;
private Checkbox checkboxMaxFps;
private boolean skipButtonVisible;
private static final String[] aStringArray351 = new String[5];


protected GameControlPanel(GameContainer var1, GamePlayerInfoPanel var2, int var3, int var4) {
Expand Down Expand Up @@ -83,9 +82,9 @@ public void actionPerformed(ActionEvent var1) {
}
}

public void itemStateChanged(ItemEvent var1) {
if (var1.getSource() == this.choicerNames) {
this.gameContainer.gamePanel.method348(this.choicerNames.getSelectedIndex());
public void itemStateChanged(ItemEvent event) {
if (event.getSource() == this.playerNamesDisplayModeChoicer) {
this.gameContainer.gamePanel.setPlayerNamesDisplayMode(this.playerNamesDisplayModeChoicer.getSelectedIndex());
}

}
Expand All @@ -106,11 +105,11 @@ protected void displaySkipButton() {
this.setVisible(true);
}

protected void method327(int var1) {
protected void method327(int state) {
this.setVisible(false);
this.removeAll();
this.skipButtonVisible = false;
if (var1 == 2) {
if (state == 2) {
this.buttonNewGame = new ColorButton(this.gameContainer.textManager.getGame("GameControl_New"));
this.buttonNewGame.setBounds(0, this.anInt343 - 55, this.anInt342, 25);
this.buttonNewGame.setBackground(GameApplet.colourButtonGreen);
Expand All @@ -132,16 +131,16 @@ protected void method327(int var1) {
}

if (this.playerCount > 1) {
this.choicerNames = new Choicer();
this.playerNamesDisplayModeChoicer = new Choicer();

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

this.choicerNames.select(this.playerCount <= 2 ? 0 : 3);
this.choicerNames.setBounds(0, this.anInt343 - 80, this.anInt342, 20);
this.choicerNames.addItemListener(this);
this.add(this.choicerNames);
this.playerNamesDisplayModeChoicer.select(this.playerCount <= 2 ? 0 : 3);
this.playerNamesDisplayModeChoicer.setBounds(0, this.anInt343 - 80, this.anInt342, 20);
this.playerNamesDisplayModeChoicer.addItemListener(this);
this.add(this.playerNamesDisplayModeChoicer);
}
}

Expand Down Expand Up @@ -189,12 +188,4 @@ protected void showSkipButton() {
this.skipButtonVisible = true;
}
}

static {
aStringArray351[0] = "GameControl_Names";
aStringArray351[1] = "GameControl_Skip";
aStringArray351[2] = "Max FPS";
aStringArray351[3] = "GameControl_New";
aStringArray351[4] = "GameControl_Back";
}
}
72 changes: 35 additions & 37 deletions client/src/main/java/agolf/game/GamePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import java.awt.Graphics;
import java.awt.Image;
import java.awt.LayoutManager;
import java.awt.Panel;
import java.util.StringTokenizer;

Expand All @@ -26,8 +25,8 @@ public class GamePanel extends Panel {
private boolean isSinglePlayerGame;
private boolean aBoolean363;
private long aLong364;
private Object anObject365;
private boolean isWaitingForTurn;
private final Object canStrokeLock;
private boolean isWaitingForTurnStart;


public GamePanel(GameContainer gameContainer, int width, int height, Image image) {
Expand All @@ -37,7 +36,7 @@ public GamePanel(GameContainer gameContainer, int width, int height, Image image
this.setSize(width, height);
this.create(image);
this.aBoolean363 = true;
this.anObject365 = new Object();
this.canStrokeLock = new Object();
this.state = -1;
this.setState(0);
}
Expand Down Expand Up @@ -82,10 +81,10 @@ public void handlePacket(String[] args) {
}

this.addMultiPlayerPanels(mode);
this.gamePlayerInfoPanel.method355(this.playerCount, trackCount, maxStrokes, strokeTimeout, trackScoring);
this.gamePlayerInfoPanel.init(this.playerCount, trackCount, maxStrokes, strokeTimeout, trackScoring);
this.gameTrackInfoPanel.setNumTracks(trackCount);
this.gameControlPanel.setPlayerCount(this.playerCount);
this.gameCanvas.method132(this.playerCount, waterEvent, collision);
this.gameCanvas.init(this.playerCount, waterEvent, collision);
if (mode == 2) {
String settings = "";
if (passworded) {
Expand Down Expand Up @@ -308,7 +307,7 @@ else if (args[1].equals("starttrack")) {

this.gameTrackInfoPanel.parseTrackInfoStats(trackInformation[0], trackInformation[1], trackStats[0], trackStats[1], trackInformation[2], trackInformation[3], trackTestMode1, trackTestMode2, this.gameCanvas.method134());

int numberOfPlayers = this.gamePlayerInfoPanel.method360();
int numberOfPlayers = this.gamePlayerInfoPanel.startNextTrack();
if (numberOfPlayers > 1) {
this.gameChatPanel.addMessage(gameContainer.textManager.getGame("GameChat_ScoreMultiNotify", numberOfPlayers));
}
Expand All @@ -319,10 +318,10 @@ else if (args[1].equals("starttrack")) {
}

} else if (args[1].equals("startturn")) {
this.isWaitingForTurn = false;
this.isWaitingForTurnStart = false;
int playerId = Integer.parseInt(args[2]);

boolean canPlay = this.gamePlayerInfoPanel.canShoot(playerId);
boolean canPlay = this.gamePlayerInfoPanel.startTurn(playerId);
//canPlay = true;
this.gameCanvas.startTurn(playerId, canPlay, !this.gameChatPanel.haveFocus());

Expand Down Expand Up @@ -352,7 +351,7 @@ else if (args[1].equals("voteskip")) {
this.gamePlayerInfoPanel.voteSkip(Integer.parseInt(args[2]));
} else if (args[1].equals("resetvoteskip")) {
this.gamePlayerInfoPanel.voteSkipReset();
if (!this.gameCanvas.getSynchronizedBool(this.gamePlayerInfoPanel.currentPlayerId)) {
if (!this.gameCanvas.getSynchronizedBool(this.gamePlayerInfoPanel.playerId)) {
this.gameControlPanel.showSkipButton();
}

Expand All @@ -375,7 +374,7 @@ else if(args[1].equals("end")) {
this.gamePlayerInfoPanel.setGameOutcome(gameOutcome);
this.gameContainer.gameApplet.showPlayerListWinners(isWinner);
} else {
this.gamePlayerInfoPanel.setGameOutcome((int[]) null);
this.gamePlayerInfoPanel.setGameOutcome(null);
}

this.setState(2);// game state?
Expand All @@ -387,16 +386,16 @@ else if(args[1].equals("end")) {
}
}

protected void sendChatMessage(String var1) {
String var2 = "say\t" + var1;
protected void sendChatMessage(String message) {
String var2 = "say\t" + message;
this.gameContainer.connection.writeData("game\t" + var2);
this.gameChatPanel.addSay(this.gamePlayerInfoPanel.currentPlayerId, this.gamePlayerInfoPanel.playerNames[this.gamePlayerInfoPanel.currentPlayerId], var1, true);
this.gameChatPanel.addSay(this.gamePlayerInfoPanel.playerId, this.gamePlayerInfoPanel.playerNames[this.gamePlayerInfoPanel.playerId], message, true);
}

protected void setBeginStroke(int playerId, int x, int y, int keycount) {
protected void setBeginStroke(int playerId, int x, int y, int shootingMode) {
this.gameTrackInfoPanel.method384();
this.gamePlayerInfoPanel.method363(playerId, false);
String data = "beginstroke\t" + this.encodeCoords(x, y, keycount);
String data = "beginstroke\t" + this.encodeCoords(x, y, shootingMode);
this.gameContainer.connection.writeData("game\t" + data);
this.gameContainer.soundManager.playGameMove();
}
Expand Down Expand Up @@ -463,7 +462,7 @@ protected void requestNewGame() {

protected void method342() {
this.gameCanvas.restartGame();
this.gamePlayerInfoPanel.stop();
this.gamePlayerInfoPanel.stopTimer();
this.gameContainer.gameApplet.setGameState(0);
this.gameContainer.connection.writeData("game\tback");
this.gameContainer.gameApplet.removePlayerList();
Expand All @@ -488,40 +487,39 @@ protected boolean maxFps() {
return this.gameControlPanel.maxFps();
}

protected String[] getPlayerInfo(int playerId) {
return this.gamePlayerInfoPanel.getPlayerInfo(playerId);
protected String[] getPlayerName(int playerId) {
return this.gamePlayerInfoPanel.getPlayerName(playerId);
}

protected void method348(int var1) {
this.gameCanvas.method139(var1);
protected void setPlayerNamesDisplayMode(int mode) {
this.gameCanvas.setPlayerNamesDisplayMode(mode);
}

public void broadcastMessage(String message) {
this.gameChatPanel.addBroadcastMessage(message);
}

protected boolean canStroke(boolean stopInfoPanel) {
synchronized (anObject365) {
if (this.isWaitingForTurn) {
boolean var3 = false;
return var3;
synchronized (canStrokeLock) {
if (this.isWaitingForTurnStart) {
return false;
}

this.isWaitingForTurn = true;
this.isWaitingForTurnStart = true;
}

if (stopInfoPanel) {// ???????????????????????????????????
this.gamePlayerInfoPanel.stop();
this.gamePlayerInfoPanel.stopTimer();
} else {
this.gameCanvas.stop();
this.gameCanvas.doZeroLengthStroke();
}

return true;
}

private void create(Image image) {
if (this.gameContainer.gameApplet.syncIsValidSite.get()) {
this.setLayout((LayoutManager) null);
this.setLayout(null);
this.gamePlayerInfoPanel = new GamePlayerInfoPanel(this.gameContainer, 735, 60);
this.gamePlayerInfoPanel.setLocation(0, 0);
this.add(this.gamePlayerInfoPanel);
Expand All @@ -548,20 +546,20 @@ private void addMultiPlayerPanels(int mode) {
}
}

private void setState(int var1) {
if (var1 != this.state) {
this.state = var1;
this.gamePlayerInfoPanel.method371(var1);
this.gameControlPanel.method327(var1);
private void setState(int state) {
if (state != this.state) {
this.state = state;
this.gamePlayerInfoPanel.method371(state);
this.gameControlPanel.method327(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

String out;
for (out = Integer.toString(var4, 36); out.length() < 4; out = "0" + out) {
;
String out = Integer.toString(var4, 36);
while (out.length() < 4) {
out = "0" + out;
}

return out;
Expand Down
Loading

0 comments on commit 8744009

Please sign in to comment.