From a096796554e5bc9f3c2f842aecaaf9eed27cec18 Mon Sep 17 00:00:00 2001 From: Kevin Turner <83819+keturn@users.noreply.github.com> Date: Tue, 22 Sep 2020 13:30:47 -0700 Subject: [PATCH 01/18] chore[facade]: use picocli for processing command line options chore[facade]: remove extraneous TerasologyCommand class --- .idea/compiler.xml | 12 +- .idea/misc.xml | 4 +- facades/PC/build.gradle | 20 +- .../org/terasology/engine/Terasology.java | 347 ++++++++---------- 4 files changed, 181 insertions(+), 202 deletions(-) diff --git a/.idea/compiler.xml b/.idea/compiler.xml index 3058433f8e4..89cf7f9ed94 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -2,7 +2,17 @@ - + + + + + + + + + + + diff --git a/.idea/misc.xml b/.idea/misc.xml index d63e059fd87..82a1c024c17 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,14 +1,16 @@ - + + + diff --git a/facades/PC/build.gradle b/facades/PC/build.gradle index 9917a727293..8a998d21833 100644 --- a/facades/PC/build.gradle +++ b/facades/PC/build.gradle @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MovingBlocks - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2020 The Terasology Foundation +// SPDX-License-Identifier: Apache-2.0 // The PC facade is responsible for the primary distribution - a plain Java application runnable on PCs @@ -95,6 +82,9 @@ println "PC VERSION: $version" group = 'org.terasology.facades' dependencies { + compile 'info.picocli:picocli:4.5.1' + annotationProcessor 'info.picocli:picocli-codegen:4.5.1' + implementation project(':engine') implementation group: 'org.reflections', name: 'reflections', version: '0.9.10' diff --git a/facades/PC/src/main/java/org/terasology/engine/Terasology.java b/facades/PC/src/main/java/org/terasology/engine/Terasology.java index a3e73c3a411..a97d1609574 100644 --- a/facades/PC/src/main/java/org/terasology/engine/Terasology.java +++ b/facades/PC/src/main/java/org/terasology/engine/Terasology.java @@ -1,22 +1,7 @@ -/* - * Copyright 2020 MovingBlocks - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2020 The Terasology Foundation +// SPDX-License-Identifier: Apache-2.0 package org.terasology.engine; -import com.google.common.base.Joiner; -import com.google.common.collect.ImmutableList; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.terasology.config.Config; @@ -53,6 +38,8 @@ import org.terasology.splash.overlay.RectOverlay; import org.terasology.splash.overlay.TextOverlay; import org.terasology.splash.overlay.TriggerImageOverlay; +import picocli.CommandLine; +import picocli.CommandLine.Option; import java.awt.GraphicsEnvironment; import java.awt.Point; @@ -62,6 +49,7 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.util.List; +import java.util.concurrent.Callable; import static com.google.common.base.Verify.verifyNotNull; @@ -74,9 +62,9 @@ * to save resources while acting as a server or to run in an environment with * no graphics, audio or input support. Additional arguments are available to * reload the latest game on startup and to disable crash reporting. - *

+ *

* Available launch arguments: - *

+ * * * * @@ -91,53 +79,72 @@ * * *
-homedirUse the current directory as the home directory.
-serverPort=xxxxxChange the server port.
- *

+ *

* When used via command line an usage help and some examples can be obtained via: *

* terasology -help or terasology /? - *

+ * */ -public final class Terasology { - - private static final String[] PRINT_USAGE_FLAGS = {"--help", "-help", "/help", "-h", "/h", "-?", "/?"}; - private static final String USE_CURRENT_DIR_AS_HOME = "-homedir"; - private static final String USE_SPECIFIED_DIR_AS_HOME = "-homedir="; - private static final String START_HEADLESS = "-headless"; - private static final String LOAD_LAST_GAME = "-loadlastgame"; - private static final String CREATE_LAST_GAME = "-createlastgame"; - private static final String NO_CRASH_REPORT = "-noCrashReport"; - private static final String NO_SAVE_GAMES = "-noSaveGames"; - private static final String PERMISSIVE_SECURITY = "-permissiveSecurity"; - private static final String NO_SOUND = "-noSound"; - private static final String NO_SPLASH = "-noSplash"; - private static final String SERVER_PORT = "-serverPort="; - private static final String OVERRIDE_DEFAULT_CONFIG = "-overrideDefaultConfig="; - private static final Logger logger = LoggerFactory.getLogger(Terasology.class); +@CommandLine.Command(name = "terasology") +public final class Terasology implements Callable { + + @Option(names = {"--help", "-help", "/help", "-h", "/h", "-?", "/?"}, usageHelp = true, description = "show help") + private boolean helpRequested; + + @Option(names = "--headless", description = "Start headless") + private boolean isHeadless; + @Option(names = "--crash-report", defaultValue = "true", negatable = true, description = "Enable crash reporting") + private boolean crashReportEnabled; - private static boolean isHeadless; - private static boolean crashReportEnabled = true; - private static boolean soundEnabled = true; - private static boolean splashEnabled = true; - private static boolean loadLastGame; - private static boolean createLastGame; + @Option(names = "--sound", defaultValue = "true", negatable = true, description = "Enable sound") + private boolean soundEnabled; + @Option(names = "--splash", defaultValue = "true", negatable = true, description = "Enable splash screen") + private boolean splashEnabled; + + @Option(names = "--load-last-game", description = "Load the latest game on startup") + private boolean loadLastGame; + + @Option(names = "--create-last-game", description = "Recreates the world of the latest game with a new save file on startup") + private boolean createLastGame; + + @Option(names = "--permissive-security") + private boolean permissiveSecurity; + + @Option(names = "--save-games", defaultValue = "true", negatable = true, description = "Enable new save games") + private boolean saveGamesEnabled; + + @Option(names = "--server-port", description = "Change the server port") + private Integer serverPort; + + @Option(names = "--config", description = "Override default config") + private Path configPath; + + @Option(names = "--homedir", description = "Path to home directory") + private Path homeDir; + + @CommandLine.Spec CommandLine.Model.CommandSpec spec; + + private static final Logger logger = LoggerFactory.getLogger(Terasology.class); private Terasology() { } public static void main(String[] args) { + new CommandLine(new Terasology()).execute(args); + } - handlePrintUsageRequest(args); - handleLaunchArguments(args); + @Override + public Integer call() throws IOException { + handleLaunchArguments(); + setupLogging(); SplashScreen splashScreen = splashEnabled ? configureSplashScreen() : SplashScreenBuilder.createStub(); splashScreen.post("Java Runtime " + System.getProperty("java.version") + " loaded"); - setupLogging(); - try { TerasologyEngineBuilder builder = new TerasologyEngineBuilder(); populateSubsystems(builder); @@ -186,6 +193,8 @@ public static void main(String[] args) { splashScreen.close(); reportException(e); } + + return 0; } private static String getNewTitle(String title) { @@ -265,153 +274,121 @@ private static void setupLogging() { LoggingContext.initialize(path); } - private static void handlePrintUsageRequest(String[] args) { - for (String arg : args) { - for (String usageArg : PRINT_USAGE_FLAGS) { - if (usageArg.equals(arg.toLowerCase())) { - printUsageAndExit(); - } - } - } - } - private static void printUsageAndExit() { - - String printUsageFlags = Joiner.on("|").join(PRINT_USAGE_FLAGS); - - List opts = ImmutableList.of( - printUsageFlags, - USE_CURRENT_DIR_AS_HOME + "|" + USE_SPECIFIED_DIR_AS_HOME + "", - START_HEADLESS, - LOAD_LAST_GAME, - CREATE_LAST_GAME, - NO_CRASH_REPORT, - NO_SAVE_GAMES, - PERMISSIVE_SECURITY, - NO_SOUND, - NO_SPLASH, - OVERRIDE_DEFAULT_CONFIG + "", - SERVER_PORT + ""); - - StringBuilder optText = new StringBuilder(); - - for (String opt : opts) { - optText.append(" [").append(opt).append("]"); - } - - System.out.println("Usage:"); - System.out.println(); - System.out.println(" terasology" + optText.toString()); - System.out.println(); - System.out.println("By default Terasology saves data such as game saves and logs into subfolders of a platform-specific \"home directory\"."); - System.out.println("Saving can be explicitly disabled using the \"" + NO_SAVE_GAMES + "\" flag."); - System.out.println("Optionally, the user can override the default by using one of the following launch arguments:"); - System.out.println(); - System.out.println(" " + USE_CURRENT_DIR_AS_HOME + " Use the current directory as the home directory."); - System.out.println(" " + USE_SPECIFIED_DIR_AS_HOME + " Use the specified directory as the home directory."); - System.out.println(); - System.out.println("It is also possible to start Terasology in headless mode (no graphics), i.e. to act as a server."); - System.out.println("For this purpose use the " + START_HEADLESS + " launch argument."); - System.out.println(); - System.out.println("To automatically load the latest game on startup,"); - System.out.println("use the " + LOAD_LAST_GAME + " launch argument."); - System.out.println(); - System.out.println("To automatically recreate the last game played with a new save file,"); - System.out.println("use the " + CREATE_LAST_GAME + "launch argument"); - System.out.println(); - System.out.println("By default Crash Reporting is enabled."); - System.out.println("To disable this feature use the " + NO_CRASH_REPORT + " launch argument."); - System.out.println(); - System.out.println("To disable sound use the " + NO_SOUND + " launch argument (default in headless mode)."); - System.out.println(); - System.out.println("To disable the splash screen use the " + NO_SPLASH + " launch argument."); - System.out.println(); - System.out.println("To change the port the server is hosted on use the " + SERVER_PORT + " launch argument."); - System.out.println(); - System.out.println("To override the default generated config (useful for headless server) use the " + OVERRIDE_DEFAULT_CONFIG + " launch argument"); - System.out.println(); - System.out.println("Examples:"); - System.out.println(); - System.out.println(" Use the current directory as the home directory:"); - System.out.println(" terasology " + USE_CURRENT_DIR_AS_HOME); - System.out.println(); - System.out.println(" Use \"myPath\" as the home directory:"); - System.out.println(" terasology " + USE_SPECIFIED_DIR_AS_HOME + "myPath"); - System.out.println(); - System.out.println(" Start terasology in headless mode (no graphics) and enforce using the default port:"); - System.out.println(" terasology " + START_HEADLESS + " " + SERVER_PORT + TerasologyConstants.DEFAULT_PORT); - System.out.println(); - System.out.println(" Load the latest game on startup and disable crash reporting"); - System.out.println(" terasology " + LOAD_LAST_GAME + " " + NO_CRASH_REPORT); - System.out.println(); - System.out.println(" Don't start Terasology, just print this help:"); - System.out.println(" terasology " + PRINT_USAGE_FLAGS[1]); - System.out.println(); - System.out.println("Alternatively use our standalone Launcher from: https://github.com/MovingBlocks/TerasologyLauncher/releases"); - System.out.println(); - + // TODO: Add all this stuff back in to the help text. +// +// String printUsageFlags = Joiner.on("|").join(PRINT_USAGE_FLAGS); +// +// List opts = ImmutableList.of( +// printUsageFlags, +// USE_CURRENT_DIR_AS_HOME + "|" + USE_SPECIFIED_DIR_AS_HOME + "", +// START_HEADLESS, +// LOAD_LAST_GAME, +// CREATE_LAST_GAME, +// NO_CRASH_REPORT, +// NO_SAVE_GAMES, +// PERMISSIVE_SECURITY, +// NO_SOUND, +// NO_SPLASH, +// OVERRIDE_DEFAULT_CONFIG + "", +// SERVER_PORT + ""); +// +// StringBuilder optText = new StringBuilder(); +// +// for (String opt : opts) { +// optText.append(" [").append(opt).append("]"); +// } +// +// System.out.println("Usage:"); +// System.out.println(); +// System.out.println(" terasology" + optText.toString()); +// System.out.println(); +// System.out.println("By default Terasology saves data such as game saves and logs into subfolders of a platform-specific \"home directory\"."); +// System.out.println("Saving can be explicitly disabled using the \"" + NO_SAVE_GAMES + "\" flag."); +// System.out.println("Optionally, the user can override the default by using one of the following launch arguments:"); +// System.out.println(); +// System.out.println(" " + USE_CURRENT_DIR_AS_HOME + " Use the current directory as the home directory."); +// System.out.println(" " + USE_SPECIFIED_DIR_AS_HOME + " Use the specified directory as the home directory."); +// System.out.println(); +// System.out.println("It is also possible to start Terasology in headless mode (no graphics), i.e. to act as a server."); +// System.out.println("For this purpose use the " + START_HEADLESS + " launch argument."); +// System.out.println(); +// System.out.println("To automatically load the latest game on startup,"); +// System.out.println("use the " + LOAD_LAST_GAME + " launch argument."); +// System.out.println(); +// System.out.println("To automatically recreate the last game played with a new save file,"); +// System.out.println("use the " + CREATE_LAST_GAME + "launch argument"); +// System.out.println(); +// System.out.println("By default Crash Reporting is enabled."); +// System.out.println("To disable this feature use the " + NO_CRASH_REPORT + " launch argument."); +// System.out.println(); +// System.out.println("To disable sound use the " + NO_SOUND + " launch argument (default in headless mode)."); +// System.out.println(); +// System.out.println("To disable the splash screen use the " + NO_SPLASH + " launch argument."); +// System.out.println(); +// System.out.println("To change the port the server is hosted on use the " + SERVER_PORT + " launch argument."); +// System.out.println(); +// System.out.println("To override the default generated config (useful for headless server) use the " + OVERRIDE_DEFAULT_CONFIG + " launch argument"); +// System.out.println(); +// System.out.println("Examples:"); +// System.out.println(); +// System.out.println(" Use the current directory as the home directory:"); +// System.out.println(" terasology " + USE_CURRENT_DIR_AS_HOME); +// System.out.println(); +// System.out.println(" Use \"myPath\" as the home directory:"); +// System.out.println(" terasology " + USE_SPECIFIED_DIR_AS_HOME + "myPath"); +// System.out.println(); +// System.out.println(" Start terasology in headless mode (no graphics) and enforce using the default port:"); +// System.out.println(" terasology " + START_HEADLESS + " " + SERVER_PORT + TerasologyConstants.DEFAULT_PORT); +// System.out.println(); +// System.out.println(" Load the latest game on startup and disable crash reporting"); +// System.out.println(" terasology " + LOAD_LAST_GAME + " " + NO_CRASH_REPORT); +// System.out.println(); +// System.out.println(" Don't start Terasology, just print this help:"); +// System.out.println(" terasology " + PRINT_USAGE_FLAGS[1]); +// System.out.println(); +// System.out.println("Alternatively use our standalone Launcher from: https://github.com/MovingBlocks/TerasologyLauncher/releases"); +// System.out.println(); +// System.exit(0); } - private static void handleLaunchArguments(String[] args) { - - Path homePath = null; - - for (String arg : args) { - boolean recognized = true; - - if (arg.startsWith(USE_SPECIFIED_DIR_AS_HOME)) { - homePath = Paths.get(arg.substring(USE_SPECIFIED_DIR_AS_HOME.length())); - } else if (arg.equals(USE_CURRENT_DIR_AS_HOME)) { - homePath = Paths.get(""); - } else if (arg.equals(START_HEADLESS)) { - isHeadless = true; - crashReportEnabled = false; - splashEnabled = false; - } else if (arg.equals(NO_SAVE_GAMES)) { - System.setProperty(SystemConfig.SAVED_GAMES_ENABLED_PROPERTY, "false"); - } else if (arg.equals(PERMISSIVE_SECURITY)) { - System.setProperty(SystemConfig.PERMISSIVE_SECURITY_ENABLED_PROPERTY, "true"); - } else if (arg.equals(NO_CRASH_REPORT)) { - crashReportEnabled = false; - } else if (arg.equals(NO_SOUND)) { - soundEnabled = false; - } else if (arg.equals(NO_SPLASH)) { - splashEnabled = false; - } else if (arg.equals(LOAD_LAST_GAME)) { - loadLastGame = true; - } else if (arg.equals(CREATE_LAST_GAME)) { - createLastGame = true; - } else if (arg.startsWith(SERVER_PORT)) { - System.setProperty(ConfigurationSubsystem.SERVER_PORT_PROPERTY, arg.substring(SERVER_PORT.length())); - } else if (arg.startsWith(OVERRIDE_DEFAULT_CONFIG)) { - System.setProperty(Config.PROPERTY_OVERRIDE_DEFAULT_CONFIG, arg.substring(OVERRIDE_DEFAULT_CONFIG.length())); - } else { - recognized = false; + private void handleLaunchArguments() throws IOException { + if (homeDir != null) { + logger.info("homeDir is {}", homeDir); + if (homeDir.toString().startsWith("-")) { + // picocli shouldn't let this happen, but see + // https://github.com/remkop/picocli/issues/1197 + throw new CommandLine.ParameterException(spec.commandLine(), + "homedir starts with -, is a value missing?", + spec.findOption("--homedir"), homeDir.toString()); } - - System.out.println((recognized ? "Recognized" : "Invalid") + " argument: " + arg); + PathManager.getInstance().useOverrideHomePath(homeDir); + // TODO: what is this? + // PathManager.getInstance().chooseHomePathManually(); + } else { + PathManager.getInstance().useDefaultHomePath(); } - try { - if (homePath != null) { - PathManager.getInstance().useOverrideHomePath(homePath); - } else { - PathManager.getInstance().useDefaultHomePath(); - } - - } catch (IOException e) { - logger.warn("The game cannot detect default home directory"); - try { - PathManager.getInstance().chooseHomePathManually(); - } catch (IOException ex) { - reportException(ex); - System.exit(0); - } + if (isHeadless) { + crashReportEnabled = false; + splashEnabled = false; + } + if (!saveGamesEnabled) { + System.setProperty(SystemConfig.SAVED_GAMES_ENABLED_PROPERTY, "false"); + } + if (permissiveSecurity) { + System.setProperty(SystemConfig.PERMISSIVE_SECURITY_ENABLED_PROPERTY, "true"); + } + if (serverPort != null) { + System.setProperty(ConfigurationSubsystem.SERVER_PORT_PROPERTY, serverPort.toString()); + } + if (configPath != null) { + System.setProperty(Config.PROPERTY_OVERRIDE_DEFAULT_CONFIG, configPath.toString()); } } - private static void populateSubsystems(TerasologyEngineBuilder builder) { + private void populateSubsystems(TerasologyEngineBuilder builder) { if (isHeadless) { builder.add(new HeadlessGraphics()) .add(new HeadlessTimer()) @@ -430,7 +407,7 @@ private static void populateSubsystems(TerasologyEngineBuilder builder) { builder.add(new HibernationSubsystem()); } - private static void reportException(Throwable throwable) { + private void reportException(Throwable throwable) { Path logPath = LoggingContext.getLoggingPath(); if (!GraphicsEnvironment.isHeadless() && crashReportEnabled) { From ab816f5218da759df5c5225d3b948d690dacfa45 Mon Sep 17 00:00:00 2001 From: Kevin Turner <83819+keturn@users.noreply.github.com> Date: Wed, 30 Sep 2020 16:02:27 -0700 Subject: [PATCH 02/18] chore[facade]: update run configs to match new spellings --- .idea/runConfigurations/TerasologyPC.xml | 2 +- .idea/runConfigurations/TerasologyPC__2nd_client_.xml | 2 +- .idea/runConfigurations/TerasologyPC__3rd_client_.xml | 2 +- .idea/runConfigurations/TerasologyPC__CR_enabled_.xml | 2 +- .idea/runConfigurations/TerasologyPC__EXTREME_8GB_.xml | 2 +- .idea/runConfigurations/TerasologyPC__Headless_.xml | 2 +- .../runConfigurations/TerasologyPC__Java_FlightRecorder_.xml | 2 +- .idea/runConfigurations/TerasologyPC__Splash_disabled_.xml | 2 +- .idea/runConfigurations/TerasologyPC__load_latest_.xml | 2 +- .idea/runConfigurations/TerasologyPC__no_audio_.xml | 2 +- .idea/runConfigurations/TerasologyPC__no_saves_.xml | 2 +- .../runConfigurations/TerasologyPC__permissive_security_.xml | 4 ++-- .idea/runConfigurations/TerasologyPC__recreate_latest_.xml | 2 +- 13 files changed, 14 insertions(+), 14 deletions(-) diff --git a/.idea/runConfigurations/TerasologyPC.xml b/.idea/runConfigurations/TerasologyPC.xml index e5bca66112f..2355a6619cc 100644 --- a/.idea/runConfigurations/TerasologyPC.xml +++ b/.idea/runConfigurations/TerasologyPC.xml @@ -2,7 +2,7 @@

* Through the following launch arguments default locations to store logs and game saves can be overridden, by using the * current directory or a specified one as the home directory. Furthermore, Terasology can be launched headless, to save * resources while acting as a server or to run in an environment with no graphics, audio or input support. Additional * arguments are available to reload the latest game on startup and to disable crash reporting. *

- * Available launch arguments: - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
-homedirUse the current directory as the home directory.
-homedir=pathUse the specified path as the home directory.
-headlessStart headless.
-loadlastgameLoad the latest game on startup.
-createlastgameRecreates the world of the latest game with a new save file on startup.
-noSaveGamesDisable writing of save games.
-noCrashReportDisable crash reporting.
-noSoundDisable sound.
-noSplashDisable splash screen.
-serverPort=xxxxxChange the server port.
- *

* When used via command line an usage help and some examples can be obtained via: - *

- * terasology -help or terasology /? + *

+ * terasology --help or terasology /? * */ From bdd524c489724404cc61a66c46f2aae2c444d86a Mon Sep 17 00:00:00 2001 From: Kevin Turner <83819+keturn@users.noreply.github.com> Date: Sat, 19 Dec 2020 19:23:31 -0800 Subject: [PATCH 17/18] chore (facade): add link to launcher in help footer With that, we can remove the old printUsageAndExit text. Its contents is covered by `--help` and docs/Playing.md. --- .../org/terasology/engine/Terasology.java | 84 +------------------ 1 file changed, 3 insertions(+), 81 deletions(-) diff --git a/facades/PC/src/main/java/org/terasology/engine/Terasology.java b/facades/PC/src/main/java/org/terasology/engine/Terasology.java index 060f5b2854c..992c90d2962 100644 --- a/facades/PC/src/main/java/org/terasology/engine/Terasology.java +++ b/facades/PC/src/main/java/org/terasology/engine/Terasology.java @@ -59,7 +59,8 @@ * */ -@CommandLine.Command(name = "terasology") +@CommandLine.Command(name = "terasology", usageHelpAutoWidth = true, +footer = "%nAlternatively use our standalone Launcher from%n https://github.com/MovingBlocks/TerasologyLauncher/releases") public final class Terasology implements Callable { private static final Logger logger = LoggerFactory.getLogger(Terasology.class); @@ -69,7 +70,7 @@ public final class Terasology implements Callable { @Option(names = {"--help", "-help", "/help", "-h", "/h", "-?", "/?"}, usageHelp = true, description = "show help") private boolean helpRequested; - @Option(names = "--headless", description = "Start headless") + @Option(names = "--headless", description = "Start headless (no graphics)") private boolean isHeadless; @Option(names = "--crash-report", defaultValue = "true", negatable = true, description = "Enable crash reporting") @@ -201,85 +202,6 @@ private static void setupLogging() { LoggingContext.initialize(path); } - private static void printUsageAndExit() { - // TODO: Add all this stuff back in to the help text. -// -// String printUsageFlags = Joiner.on("|").join(PRINT_USAGE_FLAGS); -// -// List opts = ImmutableList.of( -// printUsageFlags, -// USE_CURRENT_DIR_AS_HOME + "|" + USE_SPECIFIED_DIR_AS_HOME + "", -// START_HEADLESS, -// LOAD_LAST_GAME, -// CREATE_LAST_GAME, -// NO_CRASH_REPORT, -// NO_SAVE_GAMES, -// PERMISSIVE_SECURITY, -// NO_SOUND, -// NO_SPLASH, -// OVERRIDE_DEFAULT_CONFIG + "", -// SERVER_PORT + ""); -// -// StringBuilder optText = new StringBuilder(); -// -// for (String opt : opts) { -// optText.append(" [").append(opt).append("]"); -// } -// -// System.out.println("Usage:"); -// System.out.println(); -// System.out.println(" terasology" + optText.toString()); -// System.out.println(); -// System.out.println("By default Terasology saves data such as game saves and logs into subfolders of a platform-specific \"home directory\"."); -// System.out.println("Saving can be explicitly disabled using the \"" + NO_SAVE_GAMES + "\" flag."); -// System.out.println("Optionally, the user can override the default by using one of the following launch arguments:"); -// System.out.println(); -// System.out.println(" " + USE_CURRENT_DIR_AS_HOME + " Use the current directory as the home directory."); -// System.out.println(" " + USE_SPECIFIED_DIR_AS_HOME + " Use the specified directory as the home directory."); -// System.out.println(); -// System.out.println("It is also possible to start Terasology in headless mode (no graphics), i.e. to act as a server."); -// System.out.println("For this purpose use the " + START_HEADLESS + " launch argument."); -// System.out.println(); -// System.out.println("To automatically load the latest game on startup,"); -// System.out.println("use the " + LOAD_LAST_GAME + " launch argument."); -// System.out.println(); -// System.out.println("To automatically recreate the last game played with a new save file,"); -// System.out.println("use the " + CREATE_LAST_GAME + "launch argument"); -// System.out.println(); -// System.out.println("By default Crash Reporting is enabled."); -// System.out.println("To disable this feature use the " + NO_CRASH_REPORT + " launch argument."); -// System.out.println(); -// System.out.println("To disable sound use the " + NO_SOUND + " launch argument (default in headless mode)."); -// System.out.println(); -// System.out.println("To disable the splash screen use the " + NO_SPLASH + " launch argument."); -// System.out.println(); -// System.out.println("To change the port the server is hosted on use the " + SERVER_PORT + " launch argument."); -// System.out.println(); -// System.out.println("To override the default generated config (useful for headless server) use the " + OVERRIDE_DEFAULT_CONFIG + " launch argument"); -// System.out.println(); -// System.out.println("Examples:"); -// System.out.println(); -// System.out.println(" Use the current directory as the home directory:"); -// System.out.println(" terasology " + USE_CURRENT_DIR_AS_HOME); -// System.out.println(); -// System.out.println(" Use \"myPath\" as the home directory:"); -// System.out.println(" terasology " + USE_SPECIFIED_DIR_AS_HOME + "myPath"); -// System.out.println(); -// System.out.println(" Start terasology in headless mode (no graphics) and enforce using the default port:"); -// System.out.println(" terasology " + START_HEADLESS + " " + SERVER_PORT + TerasologyConstants.DEFAULT_PORT); -// System.out.println(); -// System.out.println(" Load the latest game on startup and disable crash reporting"); -// System.out.println(" terasology " + LOAD_LAST_GAME + " " + NO_CRASH_REPORT); -// System.out.println(); -// System.out.println(" Don't start Terasology, just print this help:"); -// System.out.println(" terasology " + PRINT_USAGE_FLAGS[1]); -// System.out.println(); -// System.out.println("Alternatively use our standalone Launcher from: https://github.com/MovingBlocks/TerasologyLauncher/releases"); -// System.out.println(); -// - System.exit(0); - } - private void handleLaunchArguments() throws IOException { if (homeDir != null) { logger.info("homeDir is {}", homeDir); From d4c11dcb58c5d8e039a0412c38d38f3676330d84 Mon Sep 17 00:00:00 2001 From: Kevin Turner <83819+keturn@users.noreply.github.com> Date: Sat, 14 Aug 2021 11:19:32 -0700 Subject: [PATCH 18/18] fix(PathManager): remove redundant elements from home path Cleans up the path for the common `--homedir=.` case. --- .../src/main/java/org/terasology/engine/core/PathManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engine/src/main/java/org/terasology/engine/core/PathManager.java b/engine/src/main/java/org/terasology/engine/core/PathManager.java index 3aff771c80d..2a2f014fae7 100644 --- a/engine/src/main/java/org/terasology/engine/core/PathManager.java +++ b/engine/src/main/java/org/terasology/engine/core/PathManager.java @@ -160,7 +160,7 @@ static PathManager setInstance(PathManager pathManager) { * @throws IOException Thrown when required directories cannot be accessed. */ public void useOverrideHomePath(Path rootPath) throws IOException { - this.homePath = rootPath.toAbsolutePath(); + this.homePath = rootPath.toRealPath(); updateDirs(); }