Skip to content

Commit

Permalink
Fixup command line argument handling for fs_game and fs_game_base, th…
Browse files Browse the repository at this point in the history
…is is now working again.
  • Loading branch information
codereader committed Dec 5, 2017
1 parent 0578da0 commit 4934e2e
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 20 deletions.
1 change: 1 addition & 0 deletions radiant/map/Map.cpp
Expand Up @@ -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;
Expand Down
51 changes: 31 additions & 20 deletions radiant/settings/GameManager.cpp
Expand Up @@ -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"
Expand Down Expand Up @@ -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);
}
Expand All @@ -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 <applicationpath>/games folder for .game files
loadGameFiles(ctx.getRuntimeDataPath());

Expand All @@ -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())
Expand Down

0 comments on commit 4934e2e

Please sign in to comment.