quakespasm/Misc/homedir_0.patch
Ozkan Sezer 11270d5b2c changed makefiles to use 1/0 instead of yes/no for the codec options.
made quakespasm custom conback embedding optional, still defaulting to 1.
the code requires USE_QS_CONBACK preprocessor definition.


git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@392 af15c1b1-3010-417e-b628-4374ebc0bcbd
2011-01-12 09:32:22 +00:00

117 lines
3.3 KiB
Diff

support for user directories, based on a patch by Piotr Szymaniak.
** against quakespasm svn revision 392.
** 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 392)
+++ Quake/common.c (working copy)
@@ -1825,32 +1825,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;
@@ -1860,6 +1864,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)
@@ -1896,6 +1908,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]);
@@ -1910,8 +1926,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)
@@ -1925,17 +1940,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
@@ -1944,7 +1959,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]);
}
}