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
This commit is contained in:
Danial
2021-10-03 06:38:17 +13:00
committed by GitHub
parent bbe1587e20
commit 865ef4ed29
4 changed files with 39 additions and 27 deletions
+2 -18
View File
@@ -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);
}
}
+3
View File
@@ -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);
+33 -8
View File
@@ -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();
}
}
}
@@ -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