new options:
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 8 Jan 2008 09:30:48 +0000 (09:30 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 8 Jan 2008 09:30:48 +0000 (09:30 +0000)
-appdata (Windows)
-nohome (Linux)
-userdir /path/to/userdir/to/be/used/instead/of/home/username/.darkplaces

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@7934 d7cf8633-e32d-0410-b094-e92efae38249

fs.c

diff --git a/fs.c b/fs.c
index d37537a..759f29e 100644 (file)
--- a/fs.c
+++ b/fs.c
@@ -1012,19 +1012,36 @@ FS_AddGameHierarchy
 */
 void FS_AddGameHierarchy (const char *dir)
 {
-#ifndef WIN32
+       int i;
        const char *homedir;
-#endif
+       char userdir[MAX_QPATH];
 
        // Add the common game directory
        FS_AddGameDirectory (va("%s%s/", fs_basedir, dir));
 
-#ifndef WIN32
+       *userdir = 0;
+
        // Add the personal game directory
+#ifdef WIN32
+       homedir = getenv ("APPDATA");
+       dpsnprintf(userdir, sizeof(userdir), "%s/%s/", homedir, gameuserdirname);
+#else
        homedir = getenv ("HOME");
-       if (homedir != NULL && homedir[0] != '\0')
-               FS_AddGameDirectory (va("%s/.%s/%s/", homedir, gameuserdirname, dir));
+       dpsnprintf(userdir, sizeof(userdir), "%s/.%s/", homedir, gameuserdirname);
 #endif
+
+#ifdef WIN32
+       if(!COM_CheckParm("-appdata")) // TODO make this the default when fs_basedir isn't writable
+#else
+       if(COM_CheckParm("-nohome"))
+#endif
+               *userdir = 0;
+       
+       if((i = COM_CheckParm("-userdir")) && i < com_argc - 1)
+               dpsnprintf(userdir, sizeof(userdir), "%s/", com_argv[i+1]);
+
+       if (*userdir)
+               FS_AddGameDirectory(va("%s%s/", userdir, dir));
 }