2010-08-14 05:01:12 +00:00
|
|
|
support for user directories, based on a patch by Piotr Szymaniak.
|
2011-01-12 09:32:22 +00:00
|
|
|
** against quakespasm svn revision 392.
|
2011-01-11 20:05:12 +00:00
|
|
|
** in alpha state, minimally tested.
|
|
|
|
** on-the-fly game directory changes not supported yet.
|
|
|
|
** needs more work.
|
2010-08-14 05:01:12 +00:00
|
|
|
|
|
|
|
Index: Quake/common.c
|
|
|
|
===================================================================
|
2011-01-12 09:32:22 +00:00
|
|
|
--- Quake/common.c (revision 392)
|
2010-08-14 05:01:12 +00:00
|
|
|
+++ Quake/common.c (working copy)
|
2011-01-12 09:32:22 +00:00
|
|
|
@@ -1825,32 +1825,36 @@ pack_t *COM_LoadPackFile (const char *pa
|
2010-08-14 05:01:12 +00:00
|
|
|
COM_AddGameDirectory -- johnfitz -- modified based on topaz's tutorial
|
|
|
|
=================
|
|
|
|
*/
|
2010-08-29 11:15:21 +00:00
|
|
|
-void COM_AddGameDirectory (const char *dir)
|
2011-01-11 20:05:12 +00:00
|
|
|
+#define SYS_USERDIR ".quakespasm"
|
|
|
|
+static char *homedir = NULL;
|
2010-08-29 11:15:21 +00:00
|
|
|
+void COM_AddGameDirectory (const char *base, const char *dir)
|
2010-08-14 05:01:12 +00:00
|
|
|
{
|
|
|
|
int i;
|
2011-01-11 20:05:12 +00:00
|
|
|
unsigned int path_id;
|
2010-08-14 05:01:12 +00:00
|
|
|
searchpath_t *search;
|
|
|
|
pack_t *pak;
|
|
|
|
char pakfile[MAX_OSPATH];
|
2011-01-11 20:05:12 +00:00
|
|
|
+ qboolean been_here = false;
|
2010-08-14 05:01:12 +00:00
|
|
|
|
|
|
|
- strcpy (com_gamedir, dir);
|
2011-01-11 20:05:12 +00:00
|
|
|
+ strcpy (com_gamedir, va("%s/%s", base, dir));
|
2010-08-14 05:01:12 +00:00
|
|
|
|
2011-01-11 20:05:12 +00:00
|
|
|
// assign a path_id to this game directory
|
|
|
|
if (com_searchpaths)
|
|
|
|
path_id = com_searchpaths->path_id << 1;
|
|
|
|
else path_id = 1U;
|
|
|
|
|
|
|
|
+_add_path:
|
2010-08-14 05:01:12 +00:00
|
|
|
// add the directory to the search path
|
2010-08-29 11:15:21 +00:00
|
|
|
search = (searchpath_t *) Z_Malloc(sizeof(searchpath_t));
|
2011-01-11 20:05:12 +00:00
|
|
|
search->path_id = path_id;
|
2010-08-14 05:01:12 +00:00
|
|
|
- strcpy (search->filename, dir);
|
|
|
|
+ strcpy (search->filename, com_gamedir);
|
|
|
|
search->next = com_searchpaths;
|
|
|
|
com_searchpaths = search;
|
|
|
|
|
|
|
|
// add any pak files in the format pak0.pak pak1.pak, ...
|
|
|
|
for (i = 0; ; i++)
|
|
|
|
{
|
|
|
|
- sprintf (pakfile, "%s/pak%i.pak", dir, i);
|
|
|
|
+ sprintf (pakfile, "%s/pak%i.pak", com_gamedir, i);
|
|
|
|
pak = COM_LoadPackFile (pakfile);
|
|
|
|
if (!pak)
|
|
|
|
break;
|
2011-01-12 09:32:22 +00:00
|
|
|
@@ -1860,6 +1864,14 @@ void COM_AddGameDirectory (const char *d
|
2011-01-11 20:05:12 +00:00
|
|
|
search->next = com_searchpaths;
|
|
|
|
com_searchpaths = search;
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ if (!been_here && homedir != NULL)
|
|
|
|
+ {
|
|
|
|
+ been_here = true;
|
|
|
|
+ strcpy(com_gamedir, va("%s/%s/%s", homedir, SYS_USERDIR, dir));
|
|
|
|
+ Sys_mkdir(com_gamedir);
|
|
|
|
+ goto _add_path;
|
|
|
|
+ }
|
|
|
|
}
|
|
|
|
|
2011-01-12 09:32:22 +00:00
|
|
|
#if defined(USE_QS_CONBACK)
|
|
|
|
@@ -1896,6 +1908,10 @@ void COM_InitFilesystem (void) //johnfit
|
2010-08-14 05:01:12 +00:00
|
|
|
{
|
|
|
|
int i, j;
|
|
|
|
|
2011-01-11 20:05:12 +00:00
|
|
|
+ homedir = getenv("HOME");
|
|
|
|
+ if (homedir)
|
|
|
|
+ Sys_mkdir (va("%s/%s", homedir, SYS_USERDIR));
|
2010-08-14 05:01:12 +00:00
|
|
|
+
|
|
|
|
i = COM_CheckParm ("-basedir");
|
|
|
|
if (i && i < com_argc-1)
|
|
|
|
strcpy (com_basedir, com_argv[i + 1]);
|
2011-01-12 09:32:22 +00:00
|
|
|
@@ -1910,8 +1926,7 @@ void COM_InitFilesystem (void) //johnfit
|
2010-08-14 05:01:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// start up with GAMENAME by default (id1)
|
|
|
|
- COM_AddGameDirectory (va("%s/"GAMENAME, com_basedir));
|
|
|
|
- strcpy (com_gamedir, va("%s/"GAMENAME, com_basedir));
|
2011-01-11 20:05:12 +00:00
|
|
|
+ COM_AddGameDirectory (com_basedir, GAMENAME);
|
2010-08-14 05:01:12 +00:00
|
|
|
|
2011-01-12 09:32:22 +00:00
|
|
|
#if defined(USE_QS_CONBACK)
|
2010-08-14 05:01:12 +00:00
|
|
|
if (!fitzmode)
|
2011-01-12 09:32:22 +00:00
|
|
|
@@ -1925,17 +1940,17 @@ void COM_InitFilesystem (void) //johnfit
|
2010-08-14 05:01:12 +00:00
|
|
|
com_nummissionpacks = 0;
|
|
|
|
if (COM_CheckParm ("-rogue"))
|
|
|
|
{
|
|
|
|
- COM_AddGameDirectory (va("%s/rogue", com_basedir));
|
2011-01-11 20:05:12 +00:00
|
|
|
+ COM_AddGameDirectory (com_basedir, "rogue");
|
2010-08-14 05:01:12 +00:00
|
|
|
com_nummissionpacks++;
|
|
|
|
}
|
|
|
|
if (COM_CheckParm ("-hipnotic"))
|
|
|
|
{
|
|
|
|
- COM_AddGameDirectory (va("%s/hipnotic", com_basedir));
|
2011-01-11 20:05:12 +00:00
|
|
|
+ COM_AddGameDirectory (com_basedir, "hipnotic");
|
2010-08-14 05:01:12 +00:00
|
|
|
com_nummissionpacks++;
|
|
|
|
}
|
|
|
|
if (COM_CheckParm ("-quoth"))
|
|
|
|
{
|
|
|
|
- COM_AddGameDirectory (va("%s/quoth", com_basedir));
|
2011-01-11 20:05:12 +00:00
|
|
|
+ COM_AddGameDirectory (com_basedir, "quoth");
|
2010-08-14 05:01:12 +00:00
|
|
|
com_nummissionpacks++;
|
|
|
|
}
|
|
|
|
//johnfitz
|
2011-01-12 09:32:22 +00:00
|
|
|
@@ -1944,7 +1959,7 @@ void COM_InitFilesystem (void) //johnfit
|
2010-08-14 05:01:12 +00:00
|
|
|
if (i && i < com_argc-1)
|
|
|
|
{
|
|
|
|
com_modified = true;
|
|
|
|
- COM_AddGameDirectory (va("%s/%s", com_basedir, com_argv[i + 1]));
|
2011-01-11 20:05:12 +00:00
|
|
|
+ COM_AddGameDirectory (com_basedir, com_argv[i + 1]);
|
2010-08-14 05:01:12 +00:00
|
|
|
}
|
2011-01-11 20:05:12 +00:00
|
|
|
}
|
2010-08-14 05:01:12 +00:00
|
|
|
|