From 11f68b7cfe0833b8d5b2dc9aee2256b499812e7e Mon Sep 17 00:00:00 2001 From: Michon van Dooren Date: Fri, 15 May 2009 17:38:01 +0200 Subject: Fixed the -S/--home-dir command line option. (cherry picked from commit e1b4184da2ece6c9e1518064ffe35b9404b3db18) --- src/main.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/main.cpp b/src/main.cpp index 07bcd3f8..3c98ed27 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -215,6 +215,7 @@ struct Options std::string configPath; std::string updateHost; std::string dataPath; + std::string homeDir; std::string serverName; short serverPort; @@ -303,11 +304,16 @@ static void setUpdatesDir() * Initializes the home directory. On UNIX and FreeBSD, ~/.tmw is used. On * Windows and other systems we use the current working directory. */ -static void initHomeDir() +static void initHomeDir(const Options &options) { - homeDir = std::string(PHYSFS_getUserDir()) + - "/." + - branding.getValue("appShort", "tmw"); + homeDir = options.homeDir; + + if (homeDir.empty()) + { + homeDir = std::string(PHYSFS_getUserDir()) + + "/." + + branding.getValue("appShort", "tmw"); + } #if defined WIN32 if (!CreateDirectory(homeDir.c_str(), 0) && GetLastError() != ERROR_ALREADY_EXISTS) @@ -660,7 +666,7 @@ static void parseOptions(int argc, char *argv[], Options &options) options.printVersion = true; break; case 'S': - homeDir = optarg; + options.homeDir = optarg; break; case 'O': options.noOpenGL = true; @@ -894,7 +900,7 @@ int main(int argc, char *argv[]) // Load branding information branding.init("data/branding.xml"); - initHomeDir(); + initHomeDir(options); // Configure logger logger = new Logger; -- cgit v1.2.3-70-g09d2