Skip to content

Commit

Permalink
Merge pull request #130 from StenAL/features
Browse files Browse the repository at this point in the history
More deobfuscation, code quality improvements, and Applet decoupling
  • Loading branch information
PhilippvK authored Dec 31, 2024
2 parents f206f10 + 7eb0398 commit 77f4aac
Show file tree
Hide file tree
Showing 52 changed files with 1,465 additions and 1,840 deletions.
20 changes: 4 additions & 16 deletions client/src/main/java/agolf/GameApplet.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ public class GameApplet extends AApplet {
private Image anImage3774;
private boolean verbose = false;

public GameApplet(Parameters parameters) {
super(parameters);
}

public void initApplet(Parameters parameters) {
this.syncIsValidSite = new SynchronizedBool(this.isValidSite());
this.setBackground(colourGameBackground);
Expand Down Expand Up @@ -166,8 +170,6 @@ protected void setGameState(int activePanel, int lobbyId, int lobbyExtra) {
} else if (!this.gameContainer.synchronizedTrackTestMode.get()) {
this.gameContainer.connection.writeData("login");
this.activePanel = 0;
} else {

}
}

Expand Down Expand Up @@ -302,18 +304,4 @@ public void quit(String from) {
private boolean isValidSite() {
return true;
}

private boolean containsDomain(String host, String domain, String[] tld) {
for (String text : tld) {
if (host.equals(domain + "." + text)) {
return true;
}

if (host.endsWith("." + domain + "." + text)) {
return true;
}
}

return false;
}
}
176 changes: 88 additions & 88 deletions client/src/main/java/agolf/GolfConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -150,109 +150,109 @@ protected void disconnect() {

private void handlePacket(String cmd) {
String[] args = Tools.separateString(cmd, "\t");
if (args[0].equals("error")) {
if (args[1].equals("vernotok")) {
this.gameContainer.gameApplet.setEndState(AApplet.END_ERROR_VERSION);
} else if (args[1].equals("serverfull")) {
this.gameContainer.gameApplet.setEndState(AApplet.END_ERROR_SERVERFULL);
}

this.socketConnection.closeConnection();
} else if (args[0].equals("versok")) {
this.writeData("language\t" + this.gameContainer.params.getLocale());
this.writeData("logintype\t"
+ (this.gameContainer.synchronizedTrackTestMode.get()
? "ttm"
: (this.gameContainer.gameApplet.hasSession() ? "reg" : "nr")));
} else if (args[0].equals("basicinfo")) {
this.gameContainer.gameApplet.setGameSettings(
args[1].equals("t"), Integer.parseInt(args[2]), args[3].equals("t"), args[4].equals("t"));
} else if (args[0].equals("broadcast")) {
if (this.gameContainer.lobbyPanel != null) {
this.gameContainer.lobbyPanel.broadcastMessage(args[1]);
}

if (this.gameContainer.gamePanel != null) {
this.gameContainer.gamePanel.broadcastMessage(args[1]);
}

} else if (args[0].equals("status")) {
if (args[1].equals("login")) {
if (args.length == 2) {
this.gameContainer.gameApplet.setGameState(1);
return;
}

byte var3 = 0;
if (args[2].equals("nickinuse")) {
var3 = 4;
}

if (args[2].equals("rlf")) {
var3 = 5;
}

if (args[2].equals("invalidnick")) {
var3 = 6;
switch (args[0]) {
case "error" -> {
if (args[1].equals("vernotok")) {
this.gameContainer.gameApplet.setEndState(AApplet.END_ERROR_VERSION);
} else if (args[1].equals("serverfull")) {
this.gameContainer.gameApplet.setEndState(AApplet.END_ERROR_SERVERFULL);
}

if (args[2].equals("forbiddennick")) {
var3 = 7;
}

this.gameContainer.gameApplet.setGameState(1, var3);
return;
this.socketConnection.closeConnection();
}

if (args[1].equals("lobbyselect")) {
this.gameContainer.gameApplet.setGameState(2, args.length > 2 ? Integer.parseInt(args[2]) : 0);
return;
case "versok" -> {
this.writeData("language\t" + this.gameContainer.params.getLocale());
this.writeData("logintype\t"
+ (this.gameContainer.synchronizedTrackTestMode.get()
? "ttm"
: (this.gameContainer.gameApplet.hasSession() ? "reg" : "nr")));
}

if (args[1].equals("lobby")) {
if (args.length == 2) {
this.gameContainer.gameApplet.setGameState(3, Integer.MIN_VALUE);
return;
case "basicinfo" -> this.gameContainer.gameApplet.setGameSettings(
args[1].equals("t"), Integer.parseInt(args[2]), args[3].equals("t"), args[4].equals("t"));
case "broadcast" -> {
if (this.gameContainer.lobbyPanel != null) {
this.gameContainer.lobbyPanel.broadcastMessage(args[1]);
}

if (args[2].equals("tt")) {
this.gameContainer.gameApplet.setGameState(3, -1, args[3].equals("t") ? 1 : 0);
return;
if (this.gameContainer.gamePanel != null) {
this.gameContainer.gamePanel.broadcastMessage(args[1]);
}

if (!args[2].equals("1") && !args[2].equals("1h")) {
if (args[2].equals("2")) {
this.gameContainer.gameApplet.setGameState(3, 2);
}
case "status" -> {
switch (args[1]) {
case "login" -> {
if (args.length == 2) {
this.gameContainer.gameApplet.setGameState(1);
return;
}

byte var3 = 0;
if (args[2].equals("nickinuse")) {
var3 = 4;
}

if (args[2].equals("rlf")) {
var3 = 5;
}

if (args[2].equals("invalidnick")) {
var3 = 6;
}

if (args[2].equals("forbiddennick")) {
var3 = 7;
}

this.gameContainer.gameApplet.setGameState(1, var3);
return;
}

if (args.length == 3) {
this.gameContainer.gameApplet.setGameState(3, 3);
case "lobbyselect" -> {
this.gameContainer.gameApplet.setGameState(2, args.length > 2 ? Integer.parseInt(args[2]) : 0);
return;
}
case "lobby" -> {
if (args.length == 2) {
this.gameContainer.gameApplet.setGameState(3, Integer.MIN_VALUE);
return;
}

if (args[2].equals("tt")) {
this.gameContainer.gameApplet.setGameState(3, -1, args[3].equals("t") ? 1 : 0);
return;
}

if (!args[2].equals("1") && !args[2].equals("1h")) {
if (args[2].equals("2")) {
this.gameContainer.gameApplet.setGameState(3, 2);
return;
}

if (args.length == 3) {
this.gameContainer.gameApplet.setGameState(3, 3);
return;
}

this.gameContainer.gameApplet.setGameState(3, 3, Integer.parseInt(args[3]));
return;
}

this.gameContainer.gameApplet.setGameState(3, 1, args[2].equals("1") ? 1 : -1);
// enables tracklistadmin this.aGameContainer_2370.gameApplet.setGameState(3, -1,
// 1);
return;
}
case "game" -> {
this.gameContainer.gameApplet.setGameState(4);
return;
}

this.gameContainer.gameApplet.setGameState(3, 3, Integer.parseInt(args[3]));
return;
}

this.gameContainer.gameApplet.setGameState(3, 1, args[2].equals("1") ? 1 : -1);
// enables tracklistadmin this.aGameContainer_2370.gameApplet.setGameState(3, -1,
// 1);
return;
}

if (args[1].equals("game")) {
this.gameContainer.gameApplet.setGameState(4);
return;
}
}

if (args[0].equals("lobbyselect")) {
this.gameContainer.lobbySelectionPanel.handlePacket(args);
} else if (args[0].equals("lobby")) {
this.gameContainer.lobbyPanel.handlePacket(args);
} else if (args[0].equals("game")) {
this.gameContainer.gamePanel.handlePacket(args);
switch (args[0]) {
case "lobbyselect" -> this.gameContainer.lobbySelectionPanel.handlePacket(args);
case "lobby" -> this.gameContainer.lobbyPanel.handlePacket(args);
case "game" -> this.gameContainer.gamePanel.handlePacket(args);
}
}
}
10 changes: 3 additions & 7 deletions client/src/main/java/agolf/SpriteManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,17 @@ protected void loadSprites() {
GameBackgroundCanvas.anIntArray78[var1] * 15,
GameBackgroundCanvas.anIntArray79[var1] * 15);
}
} catch (Exception var4) {
this.anIntArrayArray968[var1] = null;
} catch (OutOfMemoryError var5) {
} catch (Exception | OutOfMemoryError e) {
this.anIntArrayArray968[var1] = null;
}
}
}

/**
* MOTHER FUCKING IMPORTANT. Converts the tile code into an array of pixels (presumably 15*15 as
* a 1-d array)
* Converts the tile code into an array of pixels (presumably 15*15 as a 1-d array)
*
* @param tileCode The Map Tile code to get pixels of.
* @return An linear array of the tiles pixels init br0
* @return A linear array of the tiles pixels
*/
public int[] getPixelsFromTileCode(int tileCode) {
if (tileCode == 0) {
Expand Down Expand Up @@ -107,7 +104,6 @@ private Image[] parseSpriteSheet(
int sheetHeight = this.imageManager.getHeight(spriteSheet);

int[] var9 = this.imageManager.getPixels(spriteSheet, sheetWidth, sheetHeight);
spriteSheet = null;
Image[] var10 = new Image[spriteCount];

for (int var11 = 0; var11 < spriteCount; ++var11) {
Expand Down
2 changes: 1 addition & 1 deletion client/src/main/java/agolf/game/ChatPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ protected void addMessage(String var1) {
}
}

protected void addSay(int unused, String name, String message, boolean isLocalPlayer) { // /me action
protected void addSay(String name, String message, boolean isLocalPlayer) { // /me action
if (this.gameExtra >= 2) {
if (isLocalPlayer) {
this.textAreaChat.addOwnSay(name, message);
Expand Down
3 changes: 1 addition & 2 deletions client/src/main/java/agolf/game/GameBackgroundCanvas.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ public class GameBackgroundCanvas extends Canvas {
private boolean[] trackSpecialSettings;
private int[][] anIntArrayArray97;
private boolean[] aBooleanArray98;
public static int anInt99;

protected GameBackgroundCanvas(GameContainer gameContainer, Image backgroundImage) {
this.gameContainer = gameContainer;
Expand Down Expand Up @@ -214,7 +213,7 @@ protected boolean[] method120() {
return this.aBooleanArray98;
}

private boolean parseMapInstruction(String map) throws Exception {
private boolean parseMapInstruction(String map) {
this.trackSettings = defaultTrackSettings;
this.trackFirstBest = null;
this.trackLastBest = null;
Expand Down
3 changes: 0 additions & 3 deletions client/src/main/java/agolf/game/GameCanvas.java
Original file line number Diff line number Diff line change
Expand Up @@ -1096,8 +1096,6 @@ private void doHackedStroke(int playerId, boolean isLocalPlayer, int mouseX, int
double[] coords = hs.getHackedCoordintes();
hackedX = coords[0];
hackedY = coords[1];
hs = null;
hack = null;
}

private void resetPosition(int playerId, boolean gameStart) {
Expand Down Expand Up @@ -1548,7 +1546,6 @@ private double getSpeedEffect(
}

private void handleTeleport(int teleportId, int playerId, int x, int y) {
boolean var5 = true;
int exitLen = this.teleportExists[teleportId].size();
int startLen;
int random;
Expand Down
Loading

0 comments on commit 77f4aac

Please sign in to comment.