public Faction getFaction(String name) {
return factions.get(name);
}
-
- public static void main(String[] args) throws IOException {
- Game g = new Game();
-
- g.init(new File("/home/notzed/dusk/game"));
-
- String[] names = {"z", "fuckface", "god", "root", "default"};
- for (String n : names) {
- System.out.println("good name: " + n + " " + g.isGoodName(n));
- }
- }
}
MasterClock clockThread;
ConnectionManager connectionThread;
+ static void usage(String why) {
+ System.err.println();
+ System.err.println("Usage: gameserver [ path-to-game ]");
+ System.err.println();
+ System.err.println(" Game may also be started from within a game directory.");
+ System.err.println();
+ System.err.println(why);
+ }
+
/**
* Creates a new DuskServer object;
*/
public static void main(String args[]) {
// TODO: parse arguments for game data location
- File path = new File("/home/notzed/dusk/game");
+ File path = null;
+
+ for (int i = 0; i < args.length; i++) {
+ String cmd = args[i];
+
+ if (cmd.startsWith("-")) {
+ // some args
+ } else {
+ path = new File(cmd);
+ }
+ }
+
+ if (path == null) {
+ path = new File(".");
+
+ if (!new File(path, "config").exists()) {
+ usage("No game found");
+ return;
+ }
+ }
GameServer server = new GameServer();
serverSocket = new ServerSocket(game.port, 25);
} catch (Exception e) {
game.log.printf(e, "Server init failed", e);
- e.printStackTrace();
+ usage(e.getLocalizedMessage());
+ e.printStackTrace(System.err);
abort();
}
-
connectionThread.start();
clockThread.start();
}