From 865ef4ed291fd8ac86f030724bbebd5ed311ab4a Mon Sep 17 00:00:00 2001 From: Danial Date: Sun, 3 Oct 2021 06:38:17 +1300 Subject: [PATCH] Process client arguments, Auto login option (#506) * Process client arguments, Auto login 1st argument = server IP 2nd argument = username 3rd argument = password * Simplify * Fixup server XP rate --- 2006Scape Client/src/main/java/Client.java | 20 +-------- 2006Scape Client/src/main/java/Game.java | 3 ++ 2006Scape Client/src/main/java/Main.java | 41 +++++++++++++++---- .../src/main/java/com/rs2/GameConstants.java | 2 +- 4 files changed, 39 insertions(+), 27 deletions(-) diff --git a/2006Scape Client/src/main/java/Client.java b/2006Scape Client/src/main/java/Client.java index 367ab457..5c61c8c6 100644 --- a/2006Scape Client/src/main/java/Client.java +++ b/2006Scape Client/src/main/java/Client.java @@ -1,22 +1,6 @@ -import java.net.InetAddress; -import java.net.UnknownHostException; - public final class Client { - public static void main(String[] args) { - ClientSettings.SERVER_IP = "127.0.0.1"; - try { - Game game = new Game(); - Game.nodeID = 10; - Game.portOff = 0; - Game.setHighMem(); - Game.isMembers = true; - Signlink.storeid = 32; - Signlink.startpriv(InetAddress.getLocalHost()); - game.createClientFrame(503, 765); - } catch (UnknownHostException e) { - e.printStackTrace(); - } + ClientSettings.SERVER_IP = "localhost"; + Main.main(args); } - } \ No newline at end of file diff --git a/2006Scape Client/src/main/java/Game.java b/2006Scape Client/src/main/java/Game.java index 59042944..af9bb878 100644 --- a/2006Scape Client/src/main/java/Game.java +++ b/2006Scape Client/src/main/java/Game.java @@ -7274,6 +7274,9 @@ public class Game extends RSApplet { Animable_Sub5.clientInstance = this; ObjectDef.clientInstance = this; EntityDef.clientInstance = this; + + if (myUsername != "" && myPassword != "") + login(myUsername, myPassword, false); return; } catch (Exception exception) { Signlink.reporterror("loaderror " + aString1049 + " " + anInt1079); diff --git a/2006Scape Client/src/main/java/Main.java b/2006Scape Client/src/main/java/Main.java index 619a278e..bde63f3f 100644 --- a/2006Scape Client/src/main/java/Main.java +++ b/2006Scape Client/src/main/java/Main.java @@ -9,20 +9,46 @@ public final class Main { If you want to run the client locally, the easiest way to do that is run the class "Client.java" instead! - If you REALLY want to use this class, add two random program arguments. + If you REALLY want to use this class, add program arguments "-s localhost". But seriously, Client.java is just a copy-paste of this class and does it locally. Use that instead! - */ public static void main(String[] args) { - if (args.length > 1) - { - System.out.println("Running local"); - ClientSettings.SERVER_IP = "127.0.0.1"; - } try { + // Process server/ip address to connect to + for (int i = 0; i < args.length; i++) { + if (args[i].startsWith("-") && (i + 1) < args.length && !args[i + 1].startsWith("-")) { + switch(args[i]) { + case "-s": + case "-server": + case "-ip": + ClientSettings.SERVER_IP = args[++i]; + break; + } + } + } + Game game = new Game(); + + // Process other arguments + for (int i = 0; i < args.length; i++) { + if (args[i].startsWith("-") && (i + 1) < args.length && !args[i + 1].startsWith("-")) { + switch(args[i]) { + case "-u": + case "-user": + case "-username": + game.myUsername = args[++i]; + break; + case "-p": + case "-pass": + case "-password": + game.myPassword = args[++i]; + break; + } + } + } + Game.nodeID = 10; Game.portOff = 0; Game.setHighMem(); @@ -34,5 +60,4 @@ public final class Main { e.printStackTrace(); } } - } diff --git a/2006Scape Server/src/main/java/com/rs2/GameConstants.java b/2006Scape Server/src/main/java/com/rs2/GameConstants.java index aedc818b..5c749c97 100644 --- a/2006Scape Server/src/main/java/com/rs2/GameConstants.java +++ b/2006Scape Server/src/main/java/com/rs2/GameConstants.java @@ -52,7 +52,7 @@ public class GameConstants { public final static int CASTLE_WARS_Y = 3087; - public static double XP_RATE = 10; + public static double XP_RATE = 1; public final static int SAVE_TIMER = 120; // save every x seconds