mirror of
https://gitlab.com/2009scape/rt4-client.git
synced 2026-08-22 19:05:16 -06:00
Support optional config.json
This commit is contained in:
parent
60880455de
commit
2bb188a6a5
14 changed files with 107 additions and 8 deletions
|
|
@ -16,6 +16,8 @@ public class GlobalConfig {
|
|||
@OriginalMember(owner = "client!gm", name = "X", descriptor = "Ljava/math/BigInteger;")
|
||||
public static final BigInteger RSA_EXPONENT = new BigInteger("65537");
|
||||
|
||||
public static String EXTENDED_CONFIG_PATH = "config.json";
|
||||
|
||||
// Server IP
|
||||
public static String DEFAULT_HOSTNAME = "test.2009scape.org";
|
||||
|
||||
|
|
|
|||
28
client/src/main/java/rt4/GlobalJsonConfig.java
Normal file
28
client/src/main/java/rt4/GlobalJsonConfig.java
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
package rt4;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import java.io.FileReader;
|
||||
|
||||
public class GlobalJsonConfig {
|
||||
public static GlobalJsonConfig instance = null;
|
||||
|
||||
public static void load(String path) {
|
||||
Gson gson = new Gson();
|
||||
|
||||
try {
|
||||
instance = gson.fromJson(new FileReader(path), GlobalJsonConfig.class);
|
||||
} catch (Exception ex) {
|
||||
System.err.println("No config.json file, using defaults");
|
||||
}
|
||||
}
|
||||
|
||||
// ----
|
||||
|
||||
String ip_management;
|
||||
String ip_address;
|
||||
int world;
|
||||
int server_port;
|
||||
int wl_port;
|
||||
int js5_port;
|
||||
}
|
||||
|
|
@ -964,11 +964,11 @@ public final class JagString implements StringInterface {
|
|||
|
||||
@OriginalMember(owner = "client!na", name = "d", descriptor = "(Z)I")
|
||||
public final int method3154() {
|
||||
@Pc(7) int local7 = 0;
|
||||
for (@Pc(14) int local14 = 0; local14 < this.length; local14++) {
|
||||
local7 = (this.chars[local14] & 0xFF) + (local7 << 5) - local7;
|
||||
@Pc(7) int hash = 0;
|
||||
for (@Pc(14) int c = 0; c < this.length; c++) {
|
||||
hash = (this.chars[c] & 0xFF) + (hash << 5) - hash;
|
||||
}
|
||||
return local7;
|
||||
return hash;
|
||||
}
|
||||
|
||||
@OriginalMember(owner = "client!na", name = "a", descriptor = "(ILjava/awt/FontMetrics;)I")
|
||||
|
|
|
|||
|
|
@ -137,9 +137,9 @@ public final class Js5 {
|
|||
}
|
||||
|
||||
@OriginalMember(owner = "client!ve", name = "a", descriptor = "(Lclient!na;B)I")
|
||||
public final int getGroupId(@OriginalArg(0) JagString arg0) {
|
||||
public final int getGroupId(@OriginalArg(0) JagString name) {
|
||||
if (this.method4484()) {
|
||||
@Pc(16) JagString local16 = arg0.toLowerCase();
|
||||
@Pc(16) JagString local16 = name.toLowerCase();
|
||||
@Pc(27) int local27 = this.aClass70_2.aClass76_1.method2405(local16.method3154());
|
||||
return this.method4492(local27) ? local27 : -1;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -243,6 +243,10 @@ public class LoginManager {
|
|||
errors++;
|
||||
}
|
||||
if (step == 1) {
|
||||
if (GlobalJsonConfig.instance != null) {
|
||||
client.hostname = GlobalJsonConfig.instance.ip_management;
|
||||
client.port = GlobalJsonConfig.instance.server_port + client.worldListId;
|
||||
}
|
||||
Protocol.socketRequest = GameShell.signLink.openSocket(client.hostname, client.port);
|
||||
step = 2;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,6 +46,10 @@ public class WorldList {
|
|||
if (MonotonicClock.currentTimeMillis() - 5000L < closeTime) {
|
||||
return 0;
|
||||
}
|
||||
if (GlobalJsonConfig.instance != null) {
|
||||
client.worldListHostname = GlobalJsonConfig.instance.ip_management;
|
||||
client.worldListPort = GlobalJsonConfig.instance.wl_port;
|
||||
}
|
||||
Protocol.socketRequest = GameShell.signLink.openSocket(client.worldListHostname, client.worldListPort);
|
||||
openTime = MonotonicClock.currentTimeMillis();
|
||||
step = 1;
|
||||
|
|
|
|||
|
|
@ -195,6 +195,11 @@ public final class client extends GameShell {
|
|||
|
||||
@OriginalMember(owner = "client!client", name = "main", descriptor = "([Ljava/lang/String;)V")
|
||||
public static void main(@OriginalArg(0) String[] arg0) {
|
||||
try {
|
||||
GlobalJsonConfig.load(GlobalConfig.EXTENDED_CONFIG_PATH);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
try {
|
||||
if (arg0.length != 4) {
|
||||
arg0 = new String[4];
|
||||
|
|
@ -206,6 +211,9 @@ public final class client extends GameShell {
|
|||
}
|
||||
@Pc(15) int local15 = -1;
|
||||
worldListId = Integer.parseInt(arg0[0]);
|
||||
if (GlobalJsonConfig.instance != null) {
|
||||
worldListId = GlobalJsonConfig.instance.world;
|
||||
}
|
||||
modeWhere = 2;
|
||||
if (arg0[1].equals("live")) {
|
||||
modeWhat = 0;
|
||||
|
|
@ -892,10 +900,13 @@ public final class client extends GameShell {
|
|||
GameShell.method3662();
|
||||
js5CacheQueue = new Js5CacheQueue();
|
||||
js5NetQueue = new Js5NetQueue();
|
||||
|
||||
if (modeWhat != 0) {
|
||||
Static51.aByteArrayArray8 = new byte[50][];
|
||||
}
|
||||
|
||||
Preferences.read(GameShell.signLink);
|
||||
|
||||
if (modeWhere == 0) {
|
||||
worldListHostname = GlobalConfig.DEFAULT_HOSTNAME; // this.getCodeBase().getHost();
|
||||
worldListAlternatePort = GlobalConfig.ALTERNATE_PORT + 1;
|
||||
|
|
@ -909,6 +920,13 @@ public final class client extends GameShell {
|
|||
worldListAlternatePort = GlobalConfig.ALTERNATE_PORT + worldListId;
|
||||
worldListDefaultPort = GlobalConfig.DEFAULT_PORT + worldListId;
|
||||
}
|
||||
|
||||
if (GlobalJsonConfig.instance != null) {
|
||||
worldListHostname = GlobalJsonConfig.instance.ip_address;
|
||||
worldListAlternatePort = GlobalJsonConfig.instance.server_port + worldListId;
|
||||
worldListDefaultPort = GlobalJsonConfig.instance.server_port;
|
||||
}
|
||||
|
||||
if (game == 1) {
|
||||
Cheat.shiftClick = true;
|
||||
FogManager.anInt3923 = 16777215;
|
||||
|
|
@ -923,6 +941,7 @@ public final class client extends GameShell {
|
|||
PlayerAppearance.aShortArrayArray7 = PlayerAppearance.aShortArrayArray5;
|
||||
PlayerAppearance.aShortArray65 = PlayerAppearance.aShortArray71;
|
||||
}
|
||||
|
||||
alternatePort = worldListAlternatePort;
|
||||
defaultPort = worldListDefaultPort;
|
||||
hostname = worldListHostname;
|
||||
|
|
@ -932,6 +951,7 @@ public final class client extends GameShell {
|
|||
if ((SignLink.anInt5928 == 3 && modeWhere != 2) || GlobalConfig.SELECT_DEFAULT_WORLD) {
|
||||
Player.worldId = worldListId;
|
||||
}
|
||||
|
||||
Keyboard.init();
|
||||
Keyboard.start(GameShell.canvas);
|
||||
Mouse.start(GameShell.canvas);
|
||||
|
|
@ -1146,6 +1166,10 @@ public final class client extends GameShell {
|
|||
}
|
||||
try {
|
||||
if (js5ConnectState == 0) {
|
||||
if (GlobalJsonConfig.instance != null) {
|
||||
hostname = GlobalJsonConfig.instance.ip_management;
|
||||
port = GlobalJsonConfig.instance.server_port + worldListId;
|
||||
}
|
||||
js5SocketRequest = GameShell.signLink.openSocket(hostname, port);
|
||||
js5ConnectState++;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue