Skip to content

Commit

Permalink
Merge pull request #107 from StenAL/deobfuscation
Browse files Browse the repository at this point in the history
More deobfuscation
  • Loading branch information
PhilippvK authored May 22, 2024
2 parents 8744009 + 068ddc1 commit 718b60f
Show file tree
Hide file tree
Showing 34 changed files with 1,026 additions and 1,235 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 @@ -38,16 +38,16 @@ public class GameApplet extends AApplet {
private boolean verbose = false;


public void initApplet(Parameters var1) {
public void initApplet(Parameters parameters) {
this.syncIsValidSite = new SynchronizedBool(this.isValidSite());
this.setBackground(colourGameBackground);
this.setForeground(colourTextBlack);
this.gameContainer = new GameContainer(this, var1);
this.gameContainer = new GameContainer(this, parameters);
this.aBoolean3773 = false;
}

public void textsLoadedNotify(TextManager var1) {
this.gameContainer.textManager = var1;
public void textsLoadedNotify(TextManager textManager) {
this.gameContainer.textManager = textManager;
}

public void defineSounds(SoundManager soundManager) {
Expand Down
32 changes: 13 additions & 19 deletions client/src/main/java/agolf/SynchronizedInteger.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,35 @@

public class SynchronizedInteger {

private long aLong996;
private int anInt997;
private long n;


public SynchronizedInteger() {
this(0);
}

protected SynchronizedInteger(int var1) {
this.set(var1);
protected SynchronizedInteger(int n) {
this.set(n);
}

public synchronized int set(int var1) {
this.priv_set(var1);
this.anInt997 = var1;
return var1;
public synchronized int set(int n) {
this.priv_set(n);
return n;
}

public synchronized int get_upd() {
return this.set((this.aLong996 > 0L ? (int) ((2269700342778490L - this.aLong996) / 31L) : (int) ((this.aLong996 + 110157223978885L) / 7L)) + 1);
}

public synchronized int get_upd(int var1) {
return this.set((this.aLong996 > 0L ? (int) ((2269700342778490L - this.aLong996) / 31L) : (int) ((this.aLong996 + 110157223978885L) / 7L)) + var1);
public synchronized void add(int i) {
this.set((this.n > 0L ? (int) ((2269700342778490L - this.n) / 31L) : (int) ((this.n + 110157223978885L) / 7L)) + i);
}

public synchronized int get() {
return this.aLong996 > 0L ? (int) ((2269700342778490L - this.aLong996) / 31L) : (int) ((this.aLong996 + 110157223978885L) / 7L);
return this.n > 0L ? (int) ((2269700342778490L - this.n) / 31L) : (int) ((this.n + 110157223978885L) / 7L);
}

private void priv_set(int var1) {
if (var1 % 2 == 0) {
this.aLong996 = 2269700342778490L - (long) var1 * 31L;
private void priv_set(int n) {
if (n % 2 == 0) {
this.n = 2269700342778490L - (long) n * 31L;
} else {
this.aLong996 = -110157223978885L + (long) var1 * 7L;
this.n = -110157223978885L + (long) n * 7L;
}
}
}
88 changes: 38 additions & 50 deletions client/src/main/java/agolf/game/GameBackgroundCanvas.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class GameBackgroundCanvas extends Canvas {
protected GameContainer gameContainer;
private Image backgroundImg;
protected Image image;
private Graphics aGraphics85;
private Graphics graphics;
private String trackAuthor;
private String trackName;
private String trackComment;
Expand All @@ -33,8 +33,6 @@ public class GameBackgroundCanvas extends Canvas {
private int[][] anIntArrayArray97;
private boolean[] aBooleanArray98;
public static int anInt99;
private static final String[] aStringArray100 = new String[11];


protected GameBackgroundCanvas(GameContainer gameContainer, Image backgroundImage) {
this.gameContainer = gameContainer;
Expand Down Expand Up @@ -69,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 All @@ -90,21 +86,21 @@ protected void createMap(int var1) {
this.image = this.backgroundImg;
}

this.aGraphics85 = this.image.getGraphics();
this.graphics = this.image.getGraphics();
}

Image var2 = this.gameContainer.imageManager.createImage(this.gameContainer.spriteManager.getPixelsFromTileCode(var1), 15, 15);
this.aGraphics85.setColor(aColor75);
this.graphics.setColor(aColor75);


for (int y = 0; y < 25; ++y) {
for (int x = 0; x < 49; ++x) {

this.trackTiles[x][y] = var1;
if (var1 == 0) {
this.aGraphics85.fillRect(x * 15, y * 15, 15, 15);
this.graphics.fillRect(x * 15, y * 15, 15, 15);
} else {
this.aGraphics85.drawImage(var2, x * 15, y * 15, this);
this.graphics.drawImage(var2, x * 15, y * 15, this);
}
}
}
Expand All @@ -113,10 +109,10 @@ protected void createMap(int var1) {
this.repaint();
}

protected boolean parseMapCommands(String var1) {
protected boolean parseMapCommands(String map) {
try {
return this.parseMapInstruction(var1);
} catch (Exception var3) {
return this.parseMapInstruction(map);
} catch (Exception e) {
return false;
}
}
Expand All @@ -138,7 +134,7 @@ protected Image getTileAt(int var1, int var2) {
}

Image var7 = this.gameContainer.imageManager.createImage(imageData, 15, 15);
this.aGraphics85.drawImage(var7, var1 * 15, var2 * 15, this);
this.graphics.drawImage(var7, var1 * 15, var2 * 15, this);
return var7;
}

Expand Down Expand Up @@ -216,22 +212,25 @@ protected boolean[] method120() {
return this.aBooleanArray98;
}

private boolean parseMapInstruction(String var1) throws Exception {
private boolean parseMapInstruction(String map) throws Exception {
this.trackSettings = defaultTrackSettings;
this.trackFirstBest = this.trackLastBest = this.trackComment = null;
this.trackStats = this.trackRatings = null;

StringTokenizer tknzr = new StringTokenizer(var1, "\n");
int shiet = 0;
while(tknzr.hasMoreTokens()) {
String line = tknzr.nextToken();
this.trackFirstBest = null;
this.trackLastBest = null;
this.trackComment = null;
this.trackStats = null;
this.trackRatings = null;

StringTokenizer tokenizer = new StringTokenizer(map, "\n");
int requiredLinesParsed = 0;
while(tokenizer.hasMoreTokens()) {
String line = tokenizer.nextToken();
if(line.startsWith("V ") && Integer.parseInt(line.substring(2)) == 1) {
shiet++;
requiredLinesParsed++;
} else if(line.startsWith("A ")) {
shiet++;
requiredLinesParsed++;
this.trackAuthor = line.substring(2).trim();
} else if(line.startsWith("N ")) {
shiet++;
requiredLinesParsed++;
this.trackName = line.substring(2).trim();
} else if(line.startsWith("C ")) {
this.trackComment = line.substring(2).trim();
Expand Down Expand Up @@ -260,19 +259,19 @@ private boolean parseMapInstruction(String var1) throws Exception {
} else if(line.startsWith("L ")) {
this.trackLastBest = line.substring(2);
} else if(line.startsWith("R ")) {
StringTokenizer subtknzr = new StringTokenizer(line.substring(2), ",");
if(subtknzr.countTokens() != 11) {
StringTokenizer subTokenizer = new StringTokenizer(line.substring(2), ",");
if(subTokenizer.countTokens() != 11) {
return false;
}
this.trackRatings = new int[11];
for(int i = 0; i < 11; i++) {
this.trackRatings[i] = Integer.parseInt(subtknzr.nextToken());
this.trackRatings[i] = Integer.parseInt(subTokenizer.nextToken());
}
} else if(line.startsWith("T ")) {
shiet++;
/**
requiredLinesParsed++;
/*
*
* The below is the map parsing shit
* The below is the map parsing:
* firstly the input map is "expanded", any letter preceeding by a number is duplicated that number times.
* If input letter is A,B,C, the letter + the next three are concatenated into one int (4 * bytes)
* If input letters are D,E,F,G,H,I, the current tile is exactly the same as an adjacent one so
Expand All @@ -282,8 +281,8 @@ private boolean parseMapInstruction(String var1) throws Exception {
*/
String mapData = line.substring(2);

StringTokenizer subtknzr = new StringTokenizer(mapData, ",");
mapData = this.expandMap(subtknzr.nextToken());
StringTokenizer subTokenizer = new StringTokenizer(mapData, ",");
mapData = this.expandMap(subTokenizer.nextToken());
int cursorIndex = 0;

int tileX;
Expand Down Expand Up @@ -347,8 +346,8 @@ private boolean parseMapInstruction(String var1) throws Exception {

int var12;
int var14;
if (subtknzr.hasMoreTokens()) {
mapData = subtknzr.nextToken();
if (subTokenizer.hasMoreTokens()) {
mapData = subTokenizer.nextToken();
if (!mapData.startsWith("Ads:")) {
return false;
}
Expand All @@ -364,7 +363,7 @@ private boolean parseMapInstruction(String var1) throws Exception {
}
}
}
if(shiet != 4) {
if(requiredLinesParsed != 4) {
return false;
}

Expand Down Expand Up @@ -660,11 +659,11 @@ private void drawMap() {
var20 = 0;
}
}
} catch (OutOfMemoryError var24) {
} catch (OutOfMemoryError e) {
;
}

this.aGraphics85.drawImage(this.gameContainer.imageManager.createImage(mapPixels, 735, 375), 0, 0, this);
this.graphics.drawImage(this.gameContainer.imageManager.createImage(mapPixels, 735, 375), 0, 0, this);
}

private boolean castsShadow(int x, int y) {
Expand Down Expand Up @@ -735,17 +734,6 @@ private int method129(int var1, int var2, double var3) {
}

static {
aStringArray100[0] = "A ";
aStringArray100[1] = "T ";
aStringArray100[2] = "S ";
aStringArray100[3] = "R ";
aStringArray100[4] = "Ads:";
aStringArray100[5] = "I ";
aStringArray100[6] = "L ";
aStringArray100[7] = "N ";
aStringArray100[8] = "B ";
aStringArray100[9] = "C ";
aStringArray100[10] = "V ";
aColor75 = new Color(240, 240, 255);
anIntArray78 = new int[]{3, 5, 8, 49};
anIntArray79 = new int[]{2, 3, 5, 25};
Expand Down
Loading

0 comments on commit 718b60f

Please sign in to comment.