support for user directories, based on a patch by Piotr Szymaniak.
** against quakespasm svn revision 411.
** in alpha state, minimally tested.
** on-the-fly game directory changes not supported yet.
** needs more work.

Index: Quake/common.c
===================================================================
--- Quake/common.c	(revision 411)
+++ Quake/common.c	(working copy)
@@ -1844,32 +1844,36 @@ pack_t *COM_LoadPackFile (const char *pa
 COM_AddGameDirectory -- johnfitz -- modified based on topaz's tutorial
 =================
 */
-void COM_AddGameDirectory (const char *dir)
+#define SYS_USERDIR ".quakespasm"
+static char *homedir = NULL;
+void COM_AddGameDirectory (const char *base, const char *dir)
 {
 	int i;
 	unsigned int path_id;
 	searchpath_t *search;
 	pack_t *pak;
 	char pakfile[MAX_OSPATH];
+	qboolean been_here = false;
 
-	strcpy (com_gamedir, dir);
+	strcpy (com_gamedir, va("%s/%s", base, dir));
 
 	// assign a path_id to this game directory
 	if (com_searchpaths)
 		path_id = com_searchpaths->path_id << 1;
 	else	path_id = 1U;
 
+_add_path:
 	// add the directory to the search path
 	search = (searchpath_t *) Z_Malloc(sizeof(searchpath_t));
 	search->path_id = path_id;
-	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;
@@ -1879,6 +1883,14 @@ void COM_AddGameDirectory (const char *d
 		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;
+	}
 }
 
 #if defined(USE_QS_CONBACK)
@@ -1915,6 +1927,10 @@ void COM_InitFilesystem (void) //johnfit
 {
 	int i, j;
 
+	homedir = getenv("HOME");
+	if (homedir)
+		Sys_mkdir (va("%s/%s", homedir, SYS_USERDIR));
+
 	i = COM_CheckParm ("-basedir");
 	if (i && i < com_argc-1)
 		strcpy (com_basedir, com_argv[i + 1]);
@@ -1929,8 +1945,7 @@ void COM_InitFilesystem (void) //johnfit
 	}
 
 	// start up with GAMENAME by default (id1)
-	COM_AddGameDirectory (va("%s/"GAMENAME, com_basedir));
-	strcpy (com_gamedir, va("%s/"GAMENAME, com_basedir));
+	COM_AddGameDirectory (com_basedir, GAMENAME);
 
 #if defined(USE_QS_CONBACK)
 	if (!fitzmode)
@@ -1944,17 +1959,17 @@ void COM_InitFilesystem (void) //johnfit
 	com_nummissionpacks = 0;
 	if (COM_CheckParm ("-rogue"))
 	{
-		COM_AddGameDirectory (va("%s/rogue", com_basedir));
+		COM_AddGameDirectory (com_basedir, "rogue");
 		com_nummissionpacks++;
 	}
 	if (COM_CheckParm ("-hipnotic"))
 	{
-		COM_AddGameDirectory (va("%s/hipnotic", com_basedir));
+		COM_AddGameDirectory (com_basedir, "hipnotic");
 		com_nummissionpacks++;
 	}
 	if (COM_CheckParm ("-quoth"))
 	{
-		COM_AddGameDirectory (va("%s/quoth", com_basedir));
+		COM_AddGameDirectory (com_basedir, "quoth");
 		com_nummissionpacks++;
 	}
 	//johnfitz
@@ -1963,7 +1978,7 @@ void COM_InitFilesystem (void) //johnfit
 	if (i && i < com_argc-1)
 	{
 		com_modified = true;
-		COM_AddGameDirectory (va("%s/%s", com_basedir, com_argv[i + 1]));
+		COM_AddGameDirectory (com_basedir, com_argv[i + 1]);
 	}
 }
 
