From 4934e2e91515a5072cb475eaff9dd9b55d621e60 Mon Sep 17 00:00:00 2001 From: codereader Date: Tue, 5 Dec 2017 18:32:13 +0100 Subject: [PATCH] Fixup command line argument handling for fs_game and fs_game_base, this is now working again. --- radiant/map/Map.cpp | 1 + radiant/settings/GameManager.cpp | 51 +++++++++++++++++++------------- 2 files changed, 32 insertions(+), 20 deletions(-) diff --git a/radiant/map/Map.cpp b/radiant/map/Map.cpp index 42cf1510f6..3c5ac8d3cf 100644 --- a/radiant/map/Map.cpp +++ b/radiant/map/Map.cpp @@ -970,6 +970,7 @@ const StringSet& Map::getDependencies() const _dependencies.insert(MODULE_RADIANT); _dependencies.insert(MODULE_GAMEMANAGER); _dependencies.insert(MODULE_SCENEGRAPH); + _dependencies.insert(MODULE_FILETYPES); } return _dependencies; diff --git a/radiant/settings/GameManager.cpp b/radiant/settings/GameManager.cpp index 7f451c3070..243f2d069b 100644 --- a/radiant/settings/GameManager.cpp +++ b/radiant/settings/GameManager.cpp @@ -3,10 +3,7 @@ #include "i18n.h" #include "iregistry.h" #include "itextstream.h" -#include "ifiletypes.h" #include "ifilesystem.h" -#include "settings/PreferenceSystem.h" -#include "ui/prefdialog/PrefDialog.h" #include "ui/prefdialog/GameSetupDialog.h" #include "os/file.h" @@ -53,8 +50,6 @@ const StringSet& Manager::getDependencies() const if (_dependencies.empty()) { _dependencies.insert(MODULE_XMLREGISTRY); - _dependencies.insert(MODULE_PREFERENCESYSTEM); - _dependencies.insert(MODULE_FILETYPES); _dependencies.insert(MODULE_VIRTUALFILESYSTEM); _dependencies.insert(MODULE_COMMANDSYSTEM); } @@ -64,21 +59,6 @@ const StringSet& Manager::getDependencies() const void Manager::initialiseModule(const ApplicationContext& ctx) { - // Read command line parameters, these override any existing preference setting - const ApplicationContext::ArgumentList& args = ctx.getCmdLineArgs(); - - for (const std::string& arg : args) - { - if (string::istarts_with(arg, "fs_game=")) - { - GlobalRegistry().set(RKEY_FS_GAME, arg.substr(8)); - } - else if (string::istarts_with(arg, "fs_game_base=")) - { - GlobalRegistry().set(RKEY_FS_GAME_BASE, arg.substr(13)); - } - } - // Scan the /games folder for .game files loadGameFiles(ctx.getRuntimeDataPath()); @@ -90,6 +70,37 @@ void Manager::initialiseModule(const ApplicationContext& ctx) GameConfiguration config; config.loadFromRegistry(); + // Read command line parameters, these override any existing preference setting + // but only if we have a valid engine path + if (!config.enginePath.empty()) + { + const ApplicationContext::ArgumentList& args = ctx.getCmdLineArgs(); + + for (const std::string& arg : args) + { + if (string::istarts_with(arg, "fs_game=")) + { + rMessage() << "Found fs_game command line argument, overriding existing mod path." << std::endl; + + // Remove starting slash from argument and convert to standard paths + config.modPath = os::standardPathWithSlash(config.enginePath) + + os::standardPath(string::trim_left_copy(arg.substr(8), "/")); + + registry::setValue(RKEY_MOD_PATH, config.modPath); + } + else if (string::istarts_with(arg, "fs_game_base=")) + { + rMessage() << "Found fs_game_base command line argument, overriding existing mod base path." << std::endl; + + // Remove starting slash from argument and convert to standard paths + config.modBasePath = os::standardPathWithSlash(config.enginePath) + + os::standardPath(string::trim_left_copy(arg.substr(13), "/")); + + registry::setValue(RKEY_MOD_BASE_PATH, config.modBasePath); + } + } + } + // Check validity of the saved game configuration // and invoke the UI if it's not a valid one. if (config.pathsValid())