From d44e5a240e5d507160661e29b2e21f450ac7b70f Mon Sep 17 00:00:00 2001 From: Sten Laane <21343173+StenAL@users.noreply.github.com> Date: Fri, 23 Aug 2024 18:31:15 +0300 Subject: [PATCH] Client: Remove unused TrackDumper code Looks like this was originally used to fetch tracks and records from the Playforia servers. It is no longer used in the codebase though and can be removed. TrackDumper contains a copy of the client connection code package com.aapeli.connection which can all be removed as a better-debofuscated copy is available in the client codebase. --- .../org/moparforia/client/MD5Checksum.java | 65 --- .../org/moparforia/client/TrackDumper.java | 264 ----------- .../java/org/moparforia/client/recordz.java | 58 --- .../moparforia/client/trackdump/Class100.java | 33 -- .../moparforia/client/trackdump/Class98.java | 47 -- .../client/trackdump/ConnCrypto.java | 201 -------- .../client/trackdump/ConnListener.java | 13 - .../client/trackdump/Connection.java | 434 ------------------ .../client/trackdump/GameCrypto.java | 114 ----- .../client/trackdump/GamePacketQueue.java | 62 --- 10 files changed, 1291 deletions(-) delete mode 100644 client/src/main/java/org/moparforia/client/MD5Checksum.java delete mode 100644 client/src/main/java/org/moparforia/client/TrackDumper.java delete mode 100644 client/src/main/java/org/moparforia/client/recordz.java delete mode 100644 client/src/main/java/org/moparforia/client/trackdump/Class100.java delete mode 100644 client/src/main/java/org/moparforia/client/trackdump/Class98.java delete mode 100644 client/src/main/java/org/moparforia/client/trackdump/ConnCrypto.java delete mode 100644 client/src/main/java/org/moparforia/client/trackdump/ConnListener.java delete mode 100644 client/src/main/java/org/moparforia/client/trackdump/Connection.java delete mode 100644 client/src/main/java/org/moparforia/client/trackdump/GameCrypto.java delete mode 100644 client/src/main/java/org/moparforia/client/trackdump/GamePacketQueue.java diff --git a/client/src/main/java/org/moparforia/client/MD5Checksum.java b/client/src/main/java/org/moparforia/client/MD5Checksum.java deleted file mode 100644 index 82b231de..00000000 --- a/client/src/main/java/org/moparforia/client/MD5Checksum.java +++ /dev/null @@ -1,65 +0,0 @@ -package org.moparforia.client; - -import java.io.FileInputStream; -import java.io.InputStream; -import java.security.MessageDigest; - -public class MD5Checksum { - - public static String getMD5Checksum(byte[] data) throws Exception { - MessageDigest complete = MessageDigest.getInstance("MD5"); - byte[] digest = complete.digest(data); - String result = ""; - - for (byte b : digest) { - result += Integer.toString((b & 0xff) + 0x100, 16).substring(1); - } - return result; - } - - public static byte[] createChecksum(String filename) throws Exception { - InputStream fis = new FileInputStream(filename); - - byte[] buffer = new byte[1024]; - MessageDigest complete = MessageDigest.getInstance("MD5"); - int numRead; - - do { - numRead = fis.read(buffer); - if (numRead > 0) { - complete.update(buffer, 0, numRead); - } - } while (numRead != -1); - - fis.close(); - return complete.digest(); - } - - // see this How-to for a faster way to convert - // a byte array to a HEX string - public static String getMD5Checksum(String filename) throws Exception { - byte[] b = createChecksum(filename); - String result = ""; - - for (byte value : b) { - result += Integer.toString((value & 0xff) + 0x100, 16).substring(1); - } - return result; - } - - public static void main(String[] args) { - try { - System.out.println(getMD5Checksum("apache-tomcat-5.5.17.exe")); - // output : - // 0bb2827c5eacf570b6064e24e0e6653b - // ref : - // http://www.apache.org/dist/ - // tomcat/tomcat-5/v5.5.17/bin - // /apache-tomcat-5.5.17.exe.MD5 - // 0bb2827c5eacf570b6064e24e0e6653b *apache-tomcat-5.5.17.exe - } - catch (Exception e) { - e.printStackTrace(); - } - } -} diff --git a/client/src/main/java/org/moparforia/client/TrackDumper.java b/client/src/main/java/org/moparforia/client/TrackDumper.java deleted file mode 100644 index f2cedcab..00000000 --- a/client/src/main/java/org/moparforia/client/TrackDumper.java +++ /dev/null @@ -1,264 +0,0 @@ -package org.moparforia.client; - -import org.moparforia.client.trackdump.ConnListener; -import org.moparforia.client.trackdump.Connection; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.PrintStream; - -public class TrackDumper implements ConnListener { - - static int track_basic = 1; - static int track_traditional = 2; - static int track_modern = 3; - static int track_hio = 4; - static int track_short = 5; - static int track_long = 6; - int track_type = -1; - Connection conn = null; - String map_dir = "trackdump/"; - int tries = 0; - - public TrackDumper(int track_type, String map_dir) { - this.track_type = track_type; - this.map_dir = map_dir; - conn = new Connection(this, aStringArray2369); - conn.connect(); - System.out.println("started downloading " + track_type + " into " + map_dir); - } - - public static void main(String[] args) { - new TrackDumper(track_basic, "tracks/basic/"); - new TrackDumper(track_traditional, "tracks/traditional/"); - new TrackDumper(track_modern, "tracks/modern/"); - new TrackDumper(track_hio, "tracks/hio/"); - new TrackDumper(track_short, "tracks/short/"); - new TrackDumper(track_long, "tracks/long/"); - } - - @Override - public void dataReceived(String cmd) { - try { - String[] args = cmd.split("\t"); - if(args[0].equals("versok")) { - conn.writeData("language\ten_US"); - conn.writeData("logintype\tnr"); - } - else if(args[0].equals("status")) { - if(args[1].equals("login")) { - conn.writeData("login"); - } - else if(args[1].equals("lobbyselect")) { - String something = args[2]; - conn.writeData("lobbyselect\trnop"); - } - else if(args[1].equals("lobby")) { - String id = args[2]; - if(id.equals("1")) - conn.writeData("lobby\ttracksetlist"); - } - else if(args[1].equals("game")) { - // ok thanks - } - } - else if(args[0].equals("basicinfo")) { - // do nothing - } - else if(args[0].equals("lobbyselect")) { - if(args[1].equals("nop")) { - String single = args[2]; - String dual = args[3]; - String multi = args[4]; - conn.writeData("lobbyselect\tselect\t1"); - } - } - else if(args[0].equals("lobby")) { - if(args[1].equals("numberofusers")) { - // do nothing - } - else if(args[1].equals("users")) { - // fuck those losers - } - else if(args[1].equals("ownjoin")) { - // yyaaayy that's us right? - } - else if(args[1].equals("tracksetlist")) { - // >implying we give a fuck - - conn.writeData("lobby\tcspt\t20\t" + track_type + "\t0"); - } - } - else if(args[0].equals("game")) { - if(args[1].equals("gameinfo")) { - // didn't read lol - } - else if(args[1].equals("players")) { - // noope, singleplayer - } - else if(args[1].equals("owninfo")) { - // !! - } - else if(args[1].equals("start")) { - // ??? - } - else if(args[1].equals("starttrack")) { - boolean var17 = args[2].equals("ttm1"); - boolean canPlay = args[2].equals("ttm2"); - boolean var23 = var17 || canPlay; - boolean hasPlayed = false; - int startIndex = var23 ? 5 : 4; - int argsLen = args.length; - String author = null; - String name = null; - String data = null; - String fullInstruction = ""; - for (int commandIndex = startIndex; commandIndex < argsLen; ++commandIndex) { - char var12 = args[commandIndex].charAt(0); - if (var12 == 'A') { - author = args[commandIndex].substring(2); - //tabSplit[commandIndex] = "A fc_and_vortex_co"; - } - - if (var12 == 'N') { - name = args[commandIndex].substring(2); - //tabSplit[commandIndex] = "N DA REIGHSTAFFFFFFFGGG GHETTO"; - } - - if (var12 == 'T') { - data = args[commandIndex].substring(2); - } - - if (var12 == 'T' && args[commandIndex].charAt(2) == '!') {// a track we already played? - hasPlayed = true; - } - - fullInstruction = fullInstruction + args[commandIndex]; - if (commandIndex < argsLen - 1) { - fullInstruction = fullInstruction + '\n'; - } - } - if(!hasPlayed) { - String checksum = MD5Checksum.getMD5Checksum(fullInstruction.getBytes()); - File file = new File(map_dir, checksum + ".track"); - if(!file.exists()) { - System.out.println("track " + checksum); - PrintStream out = null; - try { - out = new PrintStream(new FileOutputStream(file, false)); - out.print(fullInstruction); - } - catch (Exception e) { } - finally { - if (out != null) out.close(); - } - } - } - } - else if(args[1].equals("startturn")) { - conn.writeData("game\tskip"); - } - else if(args[1].equals("end")) { - conn.writeData("game\tnewgame"); - } - } - } catch (Exception ex) { - System.err.println("dataReceived error: " + ex); - this.conn.disconnect(); - } - } - - @Override - public void connectionLost(int var1) { - System.err.println("connectionLost: " + var1); - if(tries < 5) { - conn.connect(); - tries++; - } - } - - @Override - public void notifyConnectionDown() { - System.out.println("disconnected"); - if(tries < 5) { - conn.connect(); - tries++; - } - } - - @Override - public void notifyConnectionUp() { - System.out.println("connected"); - } - - static String[] aStringArray2369 = new String[] { - "status\t", - "basicinfo\t", - "numberofusers\t", - "users\t", - "ownjoin\t", - "joinfromgame\t", - "say\t", - "logintype\t", - "login", - "lobbyselect\t", - "select\t", - "back", - "challenge\t", - "cancel\t", - "accept\t", - "cfail\t", - "nouser", - "nochall", - "cother", - "cbyother", - "refuse", - "afail", - "gsn\t", - "lobby\tnc\t", - "lobby\t", - "lobby", - "tracksetlist\t", - "tracksetlist", - "gamelist\t", - "full\t", - "add\t", - "change\t", - "remove\t", - "gameinfo\t", - "players", - "owninfo\t", - "game\tstarttrack\t", - "game\tstartturn\t", - "game\tstart", - "game\tbeginstroke\t", - "game\tendstroke\t", - "game\tresetvoteskip", - "game\t", - "game", - "quit", - "join\t", - "part\t", - "cspt\t", - "qmpt", - "cspc\t", - "jmpt\t", - "tracklist\t", - "Tiikoni", - "Leonardo", - "Ennaji", - "Hoeg", - "Darwin", - "Dante", - "ConTrick", - "Dewlor", - "Scope", - "SuperGenuis", - "Zwan", - "\tT !\t", - "\tcr\t", - "rnop", - "nop\t", - "error" - }; -} diff --git a/client/src/main/java/org/moparforia/client/recordz.java b/client/src/main/java/org/moparforia/client/recordz.java deleted file mode 100644 index 953d0f58..00000000 --- a/client/src/main/java/org/moparforia/client/recordz.java +++ /dev/null @@ -1,58 +0,0 @@ -package org.moparforia.client; - -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileReader; -import java.io.FileWriter; -import java.util.ArrayList; - -public class recordz { - - public static final void main(String[] args) throws Exception { - File[] tracks = listTracks("tracks/"); - BufferedWriter out = new BufferedWriter(new FileWriter("tracks/trackscores.trackscores")); - for(File trackfile : tracks) { - BufferedReader in = new BufferedReader(new FileReader(trackfile)); - String stats = null, firstbest = null, lastbest = null, ratings = null; - for(String line = ""; line != null; line = in.readLine()) { - if(line.startsWith("I ")) - stats = line.substring(2); - else if(line.startsWith("B ")) - firstbest = line.substring(2); - else if(line.startsWith("L ")) - lastbest = line.substring(2); - else if(line.startsWith("R ")) - ratings = line.substring(2); - } - out.write(trackfile.getName().substring(0, trackfile.getName().length() - 6)); - out.write('|'); - out.write(stats == null ? "" : stats); - out.write('|'); - out.write(firstbest == null ? "" : firstbest); - out.write('|'); - out.write(lastbest == null ? "" : lastbest); - out.write('|'); - out.write(ratings == null ? "" : ratings); - out.write('\n'); - out.flush(); - in.close(); - } - out.close(); - } - - private static File[] listTracks(String dir) { - ArrayList list = new ArrayList<>(); - File dirfile = new File(dir); - for(File subdir : dirfile.listFiles()) { - if(subdir.isDirectory()) { - for(File file : subdir.listFiles()) { - if(file.getName().endsWith(".track")) { - list.add(file); - } - } - } - } - return list.toArray(new File[0]); - } -} diff --git a/client/src/main/java/org/moparforia/client/trackdump/Class100.java b/client/src/main/java/org/moparforia/client/trackdump/Class100.java deleted file mode 100644 index 48ee0a77..00000000 --- a/client/src/main/java/org/moparforia/client/trackdump/Class100.java +++ /dev/null @@ -1,33 +0,0 @@ -package org.moparforia.client.trackdump; - - -class Class100 { - - private long aLong1632; - - - protected Class100(long var1) { - this.aLong1632 = (var1 ^ 25214903917L) & 281474976710655L; - } - - protected int method1799(int var1, int var2) { - return var1 + this.method1800() % (var2 - var1 + 1); - } - - private int method1800() { - int var1 = this.method1801(); - if (var1 < 0) { - var1 = -var1; - if (var1 < 0) { - var1 = 0; - } - } - - return var1; - } - - private int method1801() { - this.aLong1632 = this.aLong1632 * 25214903917L + 11L & 281474976710655L; - return (int) (this.aLong1632 >>> 16); - } -} diff --git a/client/src/main/java/org/moparforia/client/trackdump/Class98.java b/client/src/main/java/org/moparforia/client/trackdump/Class98.java deleted file mode 100644 index d8a1a3cc..00000000 --- a/client/src/main/java/org/moparforia/client/trackdump/Class98.java +++ /dev/null @@ -1,47 +0,0 @@ -package org.moparforia.client.trackdump; - -import java.util.Vector; - -class Class98 { - - private Vector aVector1604 = new Vector<>(); - private int anInt1605 = 0; - private ConnCrypto aConnCrypto_1606 = new ConnCrypto((int) (Math.random() * 19.0D)); - protected long aLong1607; - - - protected Class98() { - this.aConnCrypto_1606.setKey(ConnCrypto.method1763()); - this.aLong1607 = 0L; - } - - protected void method1772(String var1) { - long var2; - synchronized (this) { - var2 = this.aLong1607++; - } - - var1 = this.aConnCrypto_1606.encrypt(var2 + " " + var1); - this.aVector1604.addElement(var1); - } - - protected String method1773() { - if (this.aVector1604.size() <= this.anInt1605) { - return null; - } else { - String var1 = this.aVector1604.elementAt(this.anInt1605); - var1 = this.aConnCrypto_1606.decrypt(var1); - if (this.aVector1604.size() > 3) { - this.aVector1604.removeElementAt(0); - } else { - ++this.anInt1605; - } - - return var1; - } - } - - protected void method1774() { - this.anInt1605 = 0; - } -} diff --git a/client/src/main/java/org/moparforia/client/trackdump/ConnCrypto.java b/client/src/main/java/org/moparforia/client/trackdump/ConnCrypto.java deleted file mode 100644 index ea49134c..00000000 --- a/client/src/main/java/org/moparforia/client/trackdump/ConnCrypto.java +++ /dev/null @@ -1,201 +0,0 @@ -package org.moparforia.client.trackdump; - -public class ConnCrypto { - - private int key; - private int anInt1601; - private int[][] anIntArrayArray1602; - private int[][] anIntArrayArray1603; - - - public ConnCrypto(int var1) { - this.anInt1601 = var1; - this.key = -1; - this.anIntArrayArray1602 = new int[2][125]; - this.anIntArrayArray1603 = new int[2][1920]; - } - - protected static int method1763() { - int var0 = 100000000; - int var1 = 999999999; - int var2 = var0 + (int) (Math.random() * (double) (var1 - var0 + 1)); - return var2; - } - - public void setKey(int newKey) { - this.key = newKey; - - int var2; - for (var2 = 1; var2 <= 125; ++var2) { - this.anIntArrayArray1602[1][var2 - 1] = -1; - } - - for (var2 = 128; var2 <= 2047; ++var2) { - this.anIntArrayArray1603[1][var2 - 128] = -1; - } - - Class100 var5 = new Class100(newKey); - - int var3; - int var4; - for (var4 = 1; var4 <= 125; this.anIntArrayArray1602[1][var3 - 1] = var4++) { - do { - var3 = var5.method1799(1, 125); - } while (this.anIntArrayArray1602[1][var3 - 1] >= 0); - - this.anIntArrayArray1602[0][var4 - 1] = var3; - } - - for (var4 = 128; var4 <= 2047; this.anIntArrayArray1603[1][var3 - 128] = var4++) { - do { - var3 = var5.method1799(128, 2047); - } while (this.anIntArrayArray1603[1][var3 - 128] >= 0); - - this.anIntArrayArray1603[0][var4 - 128] = var3; - } - - } - - protected void resetKey() { - this.key = -1; - } - - public String encrypt(String var1) { - if (this.key == -1) { - return var1; - } else { - char[] var2 = var1.toCharArray(); - int var3 = var2.length; - StringBuffer var4 = new StringBuffer(var3 + 2); - int var5 = (int) (1.0D + Math.random() * 125.0D); - int var6 = (int) (1.0D + Math.random() * 125.0D); - int var7 = method1771(var5, 1, var3 + 1); - int var8 = this.method1769(var6); - var4.append((char) this.method1769(var5)); - int var10 = this.key % 99 - 49 + var5 - var6; - - for (int var11 = 0; var11 < var3; ++var11) { - if (var7 == var11 + 1) { - var4.append((char) var8); - } - - int var9 = var2[var11]; - if (var9 >= 1 && var9 <= 127) { - if (var9 != 10 && var9 != 13) { - var9 = this.method1768(var9); - var9 = method1770(var9, var10, 1, 125); - ++var10; - var9 = this.anIntArrayArray1602[0][var9 - 1]; - var9 = this.method1769(var9); - if (var9 >= 14 && var9 <= 127) { - var9 = method1770(var9, this.anInt1601 - 9, 14, 127); - } - } - } else if (var9 >= 128 && var9 <= 2047) { - var9 = method1770(var9, var10, 128, 2047); - var10 += 2; - var9 = this.anIntArrayArray1603[0][var9 - 128]; - } - - var4.append((char) var9); - ++var10; - } - - if (var7 == var3 + 1) { - var4.append((char) var8); - } - - return var4.toString(); - } - } - - public String decrypt(String var1) { - if (this.key == -1) { - return var1; - } else { - char[] var2 = var1.toCharArray(); - int var3 = var2.length; - StringBuffer var4 = new StringBuffer(var3 - 2); - int var5 = this.method1768(var2[0]); - int var6 = method1771(var5, 1, var3 - 1); - int var7 = this.method1768(var2[var6]); - int var9 = var7 - var5 - (this.key % 99 - 49); - int var10 = var6 < var3 - 1 ? var3 : var3 - 1; - - for (int var11 = 1; var11 < var10; ++var11) { - if (var11 == var6) { - ++var11; - } - - int var8 = var2[var11]; - if (var8 >= 1 && var8 <= 127) { - if (var8 != 10 && var8 != 13) { - if (var8 >= 14 && var8 <= 127) { - var8 = method1770(var8, 9 - this.anInt1601, 14, 127); - } - - var8 = this.method1768(var8); - var8 = this.anIntArrayArray1602[1][var8 - 1]; - var8 = method1770(var8, var9, 1, 125); - --var9; - var8 = this.method1769(var8); - } - } else if (var8 >= 128 && var8 <= 2047) { - var8 = this.anIntArrayArray1603[1][var8 - 128]; - var8 = method1770(var8, var9, 128, 2047); - var9 -= 2; - } - - var4.append((char) var8); - --var9; - } - - return var4.toString(); - } - } - - private int method1768(int var1) { - if (var1 > 13) { - --var1; - } - - if (var1 > 10) { - --var1; - } - - return var1; - } - - private int method1769(int var1) { - if (var1 >= 10) { - ++var1; - } - - if (var1 >= 13) { - ++var1; - } - - return var1; - } - - private static int method1770(int var0, int var1, int var2, int var3) { - return method1771(var0 + var1, var2, var3); - } - - private static int method1771(int var0, int var1, int var2) { - int var3 = var1; - boolean var6 = false; - var2 -= var3; - var0 -= var3; - int var4 = var2 + 1; - if (var0 > var2) { - var0 %= var4; - } else if (var0 < 0) { - int var5 = (-var0 - 1) / var4 + 1; - var0 += var5 * var4; - } - - var0 += var3; - return var0; - } -} diff --git a/client/src/main/java/org/moparforia/client/trackdump/ConnListener.java b/client/src/main/java/org/moparforia/client/trackdump/ConnListener.java deleted file mode 100644 index 2ec00e95..00000000 --- a/client/src/main/java/org/moparforia/client/trackdump/ConnListener.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.moparforia.client.trackdump; - - -public interface ConnListener { - - void dataReceived(String var1); - - void connectionLost(int var1); - - void notifyConnectionDown(); - - void notifyConnectionUp(); -} diff --git a/client/src/main/java/org/moparforia/client/trackdump/Connection.java b/client/src/main/java/org/moparforia/client/trackdump/Connection.java deleted file mode 100644 index cb7b6a21..00000000 --- a/client/src/main/java/org/moparforia/client/trackdump/Connection.java +++ /dev/null @@ -1,434 +0,0 @@ -package org.moparforia.client.trackdump; - -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.InterruptedIOException; -import java.io.OutputStream; -import java.io.OutputStreamWriter; -import java.net.Socket; -import java.util.Vector; - -public final class Connection implements Runnable { - - public static final int DCR_UNDEFINED = 0; - public static final int DCR_BYUSER = 1; - public static final int DCR_NORETRY = 2; - public static final int DCR_RETRYFAIL = 3; - public static final int DCR_VERSION = 4; - public static final int DCR_HANDLEFAILED = 5; - private ConnListener aConnListener1611; - private GameCrypto aGameCrypto_1612; - private int anInt1613; - private int disconnectReason; - private boolean aBoolean1615; - private boolean aBoolean1616; - private Socket aSocket1617; - private BufferedReader in; - private BufferedWriter out; - private long aLong1620; - private int anInt1621; - private Class98 aClass98_1622; - private GamePacketQueue aGamePacketQueue_1623; - private Vector aVector1624; - private long numReceivedGamePackets; - private long lastCmdReceived; - private ConnCrypto connCrypto; - private Thread aThread1628; - public static int anInt1629; - - public Connection(ConnListener var3, String[] var4) { - this.aConnListener1611 = var3; - - int cryptoseedmaybe = 4; - if (var4 != null) { - this.aGameCrypto_1612 = new GameCrypto(var4); - cryptoseedmaybe = this.aGameCrypto_1612.method1793(); - } - - this.aLong1620 = -1L; - this.anInt1621 = 25; - this.aClass98_1622 = new Class98(); - this.aVector1624 = new Vector<>(); - this.numReceivedGamePackets = -1L; - this.anInt1613 = 0; - this.disconnectReason = 0; - this.aBoolean1615 = this.aBoolean1616 = false; - this.connCrypto = new ConnCrypto(cryptoseedmaybe); - } - - public void run() { - this.aGamePacketQueue_1623 = new GamePacketQueue(this, this.aConnListener1611); - - try { - do { - if (this.anInt1613 == 1) { - this.method1778(); - } else if (this.anInt1613 == 2) { - this.method1777(); - } else if (this.anInt1613 == 3) { - this.method1791(); - } - - if (this.aBoolean1615) { - if (this.method1782()) { - this.writeLineC("end"); - } - - this.anInt1613 = 4; - this.disconnectReason = 1; - } - - if (this.aBoolean1616) { - this.anInt1613 = 4; - this.disconnectReason = 5; - } - } while (this.anInt1613 != 4); - } catch (Exception var2) { - } catch (Error var3) { - } - - this.method1792(); - this.aGamePacketQueue_1623.stop(); - this.aConnListener1611.connectionLost(this.disconnectReason); - } - - public boolean connect() { - if (this.anInt1613 != 0) { - throw new IllegalStateException("Connection already opened"); - } else if (!this.method1776()) { - this.anInt1613 = 4; - return false; - } else { - this.anInt1613 = 1; - this.aThread1628 = new Thread(this); - this.aThread1628.start(); - return true; - } - } - - public void writeData(String var1) { - if (this.anInt1613 == 0) { - throw new IllegalStateException("Connection not yet open"); - } else if (this.anInt1613 != 4) { - //System.out.println("CLIENT> WRITE \"d " + aClass98_1622.sendSeqNum + " " + var1 + "\""); - if (this.aGameCrypto_1612 != null) { - var1 = this.aGameCrypto_1612.encrypt(var1); - } - - this.aClass98_1622.method1772(var1); - } - } - - public void writeThriftLog(int var1, String var2, String var3) { - String var4 = "tlog\t" + var1 + "\t" + var2; - if (var3 != null) { - var4 = var4 + "\t" + var3; - } - - this.aVector1624.addElement(var4); - } - - public void disconnect() { - if (this.anInt1613 == 0) { - throw new IllegalStateException("Connection not yet even opened"); - } else if (this.anInt1613 != 4 || this.aThread1628 != null) { - this.aBoolean1615 = true; - this.anInt1613 = 4; - this.aThread1628.interrupt(); - } - } - - public String getLocalIP() { - return null; - } - - protected void method1775() { - this.aBoolean1616 = true; - this.anInt1613 = 4; - this.aThread1628.interrupt(); - } - - private boolean method1776() { - try { - this.aSocket1617 = new Socket("game05.playforia.net", 4242); - InputStream var3 = this.aSocket1617.getInputStream(); - OutputStream var4 = this.aSocket1617.getOutputStream(); - - InputStreamReader var5; - OutputStreamWriter var6; - var5 = new InputStreamReader(var3); - var6 = new OutputStreamWriter(var4); - - this.in = new BufferedReader(var5); - this.out = new BufferedWriter(var6); - this.aSocket1617.setSoTimeout(250); - this.lastCmdReceived = System.currentTimeMillis(); - return true; - } catch (Exception var9) { - var9.printStackTrace(); - return false; - } - } - - private void method1777() { - this.method1779(); - if (this.anInt1613 == 2) { - this.method1778(); - } - - } - - private void method1778() { - this.method1788(); - if (this.anInt1613 == 2) { - this.method1790(); - } - - } - - private void method1779() { - this.method1780(); - if (this.anInt1613 == 2) { - this.method1781(); - } - - } - - private void method1780() { - do { - String var1 = this.aClass98_1622.method1773(); - if (var1 == null) { - return; - } - - if (!this.writeLineD(var1)) { - this.method1783(); - } - } while (this.anInt1613 == 2); - - } - - private void method1781() { - while (true) { - if (this.anInt1613 == 2 && !this.aVector1624.isEmpty()) { - String var1 = this.aVector1624.firstElement(); - this.aVector1624.removeElementAt(0); - if (this.writeLineS(var1)) { - continue; - } - - this.method1783(); - return; - } - - return; - } - } - - private boolean method1782() { - String var1; - do { - var1 = this.aClass98_1622.method1773(); - if (var1 == null) { - return true; - } - } while (this.writeLineD(var1)); - - return false; - } - - private void method1783() { - if (this.anInt1613 == 2 && this.anInt1621 > 0) { - this.method1792(); - this.anInt1613 = 3; - this.aConnListener1611.notifyConnectionDown(); - } else { - this.anInt1613 = 4; - this.disconnectReason = 2; - } - - } - - private boolean writeLineC(String var1) { - return this.writeLine("c " + var1); - } - - private boolean writeLineD(String var1) { - return this.writeLine("d " + var1); - } - - private boolean writeLineS(String var1) { - return this.writeLine("s " + var1); - } - - private boolean writeLine(String var1) { - try { - //if(!var1.startsWith("d ")) - //System.out.println("CLIENT> WRITE \"" + var1 + "\""); - var1 = this.connCrypto.encrypt(var1); - this.out.write(var1); - this.out.newLine(); - this.out.flush(); - return true; - } catch (IOException var3) { - return false; - } - } - - private void method1788() { - String cmd = this.readLine(); - if (cmd != null) { - this.lastCmdReceived = System.currentTimeMillis(); - char cmdtype = cmd.charAt(0); - cmd = cmd.substring(2); - int firstSpace; - if (cmdtype == 'h') {// not sure what - firstSpace = Integer.parseInt(cmd);// it's always 1... ALWAYS - if (firstSpace != 1) { - this.anInt1613 = 4; - this.disconnectReason = 4; - } - } else if (cmdtype == 'c') {// connection related - if (cmd.startsWith("io ")) { - this.connCrypto.setKey(Integer.parseInt(cmd.substring(3))); - } else if (cmd.startsWith("crt ")) { - this.anInt1621 = Integer.parseInt(cmd.substring(4)); - } else if (cmd.equals("ctr")) { - if (this.aLong1620 == -1L) { - this.writeLineC("new"); - } else { - this.writeLineC("old " + this.aLong1620); - } - } else if (cmd.startsWith("id ")) { - long var6 = Long.parseLong(cmd.substring(3)); - this.aLong1620 = var6; - this.anInt1613 = 2; - writeData("version\t35"); - writeThriftLog(1, "clientconnect", "loadtime:i:664^loadertime:i:1366"); - } else if (cmd.equals("rcok")) { - this.anInt1613 = 2; - this.aConnListener1611.notifyConnectionUp(); - } else if (cmd.equals("rcf")) { - this.anInt1613 = 4; - this.disconnectReason = 3; - } else if (cmd.equals("ping")) { - this.writeLineC("pong"); - } - } else if (cmdtype == 'p') { - if (cmd.startsWith("kickban ")) { - firstSpace = Integer.parseInt(cmd.substring(8)); - - } - } else if (cmdtype == 's') { - if (cmd.startsWith("json ")) { - String var7 = cmd.substring(5); - - } - } else if (cmdtype == 'd') { - firstSpace = cmd.indexOf(' '); - long numServerSentPaketz = Long.parseLong(cmd.substring(0, firstSpace)); - if (numServerSentPaketz > this.numReceivedGamePackets) { - if (numServerSentPaketz > this.numReceivedGamePackets + 1L) { - this.anInt1613 = 4; - this.disconnectReason = 3; - } else { - cmd = cmd.substring(firstSpace + 1); - if (this.aGameCrypto_1612 != null) { - cmd = this.aGameCrypto_1612.decrypt(cmd); - } - - //System.out.println("CLIENT> READ \"d " + numServerSentPaketz + " " + cmd + "\""); - - this.aGamePacketQueue_1623.addGamePacket(cmd); - ++this.numReceivedGamePackets; - } - } - } - - } - } - - private String readLine() { - try { - String var1 = this.in.readLine(); - if (var1 != null) { - var1 = this.connCrypto.decrypt(var1); - //if(!var1.startsWith("d ")) - //System.out.println("CLIENT> READ \"" + var1 + "\""); - return var1; - } - } catch (InterruptedIOException var2) { - return null; - } catch (IOException var3) { - } - - this.method1783(); - return null; - } - - private void method1790() { - long var1 = System.currentTimeMillis(); - if (var1 > this.lastCmdReceived + 20000L) { - this.method1783(); - } - - } - - private void method1791() { - long var1 = System.currentTimeMillis() + (long) ((this.anInt1621 + 12) * 1000); - - do { - try { - Thread.sleep(3000L); - } catch (InterruptedException var4) { - } - - if (this.anInt1613 != 3) { - return; - } - - if (this.method1776()) { - this.connCrypto.resetKey(); - this.aClass98_1622.method1774(); - this.anInt1613 = 1; - return; - } - } while (System.currentTimeMillis() < var1); - - this.anInt1613 = 4; - this.disconnectReason = 3; - } - - private void method1792() { - if (this.in != null) { - try { - this.in.close(); - } catch (IOException var4) { - } - - this.in = null; - } - - if (this.out != null) { - try { - this.out.close(); - } catch (IOException var3) { - } - - this.out = null; - } - - if (this.aSocket1617 != null) { - try { - this.aSocket1617.close(); - } catch (IOException var2) { - } - - this.aSocket1617 = null; - } - - } -} diff --git a/client/src/main/java/org/moparforia/client/trackdump/GameCrypto.java b/client/src/main/java/org/moparforia/client/trackdump/GameCrypto.java deleted file mode 100644 index 92cb7e61..00000000 --- a/client/src/main/java/org/moparforia/client/trackdump/GameCrypto.java +++ /dev/null @@ -1,114 +0,0 @@ -package org.moparforia.client.trackdump; - - -class GameCrypto { - - private String[] aStringArray1631; - - - protected GameCrypto(String[] var1) { - this.aStringArray1631 = this.method1796(var1); - } - - protected int method1793() { - int var1 = this.aStringArray1631.length; - int var2 = var1 % 19; - - for (int var4 = 0; var4 < var1; ++var4) { - int var3 = this.aStringArray1631[var4].length(); - - for (int var5 = 0; var5 < var3; ++var5) { - var2 = (var2 + this.aStringArray1631[var4].charAt(var5) * (var4 + 1) * (var5 + 2)) % 19; - } - } - - return var2; - } - - protected String encrypt(String var1) { - char var2 = this.method1797(var1); - if (var2 == 0) { - return " " + var1; - } else { - int var3 = this.aStringArray1631.length; - - for (int var5 = 0; var5 < var3; ++var5) { - int var4 = 0; - - while ((var4 = var1.indexOf(this.aStringArray1631[var5], var4)) >= 0) { - if (!this.method1798(var1, var4, var2)) { - var1 = var1.substring(0, var4) + var2 + (char) (' ' + var5) + var1.substring(var4 + this.aStringArray1631[var5].length()); - var4 += 2; - } else { - ++var4; - } - } - } - - var1 = var2 + var1; - return var1; - } - } - - protected String decrypt(String var1) { - char var2 = var1.charAt(0); - var1 = var1.substring(1); - if (var2 == 0) { - return var1; - } else { - int var3; - while ((var3 = var1.indexOf(var2)) >= 0) { - var1 = var1.substring(0, var3) + this.aStringArray1631[var1.charAt(var3 + 1) - ' '] + var1.substring(var3 + 2); - } - - return var1; - } - } - - private String[] method1796(String[] var1) { - int var2 = var1.length; - int var3 = 0; - int[] var4 = new int[var2]; - - for (int var5 = 0; var5 < var2; ++var5) { - var4[var5] = var1[var5].length(); - if (var4[var5] > var3) { - var3 = var4[var5]; - } - } - - String[] var10 = new String[var2]; - int var6 = 0; - - for (int var8 = 0; var8 < var2; ++var8) { - int var7 = 0; - - for (int var9 = 0; var9 < var2; ++var9) { - if (var4[var9] == var3) { - var10[var6] = var1[var9]; - ++var6; - } else if (var4[var9] < var3 && var4[var9] > var7) { - var7 = var4[var9]; - } - } - - var3 = var7; - } - - return var10; - } - - private char method1797(String var1) { - for (char var2 = 1; var2 < 32; ++var2) { - if (var1.indexOf(var2) == -1) { - return var2; - } - } - - return '\u0000'; - } - - private boolean method1798(String var1, int var2, char var3) { - return var2 == 0 ? false : var1.charAt(var2 - 1) == var3; - } -} diff --git a/client/src/main/java/org/moparforia/client/trackdump/GamePacketQueue.java b/client/src/main/java/org/moparforia/client/trackdump/GamePacketQueue.java deleted file mode 100644 index 1e1b2af6..00000000 --- a/client/src/main/java/org/moparforia/client/trackdump/GamePacketQueue.java +++ /dev/null @@ -1,62 +0,0 @@ -package org.moparforia.client.trackdump; - -import java.util.Vector; - -class GamePacketQueue implements Runnable { - - private Connection conn; - private ConnListener connListener; - private Vector packets; - private boolean running; - private Thread thread; - - - protected GamePacketQueue(Connection conn, ConnListener connListener) { - this.conn = conn; - this.connListener = connListener; - this.packets = new Vector<>(); - this.running = true; - this.thread = new Thread(this); - this.thread.start(); - } - - public void run() { - while (true) { - try { - Thread.sleep(50L); - - String var1; - while ((var1 = this.nextGamePacket()) != null) { - this.connListener.dataReceived(var1); - } - - if (this.running) { - continue; - } - } catch (Exception var2) { - this.running = false; - this.conn.method1775(); - } - - return; - } - } - - protected synchronized void addGamePacket(String command) { - this.packets.addElement(command); - } - - protected void stop() { - this.running = false; - } - - private synchronized String nextGamePacket() { - if (!this.packets.isEmpty() && this.running) { - String var1 = this.packets.elementAt(0); - this.packets.removeElementAt(0); - return var1; - } else { - return null; - } - } -}