quakespasm/Misc/homedir_0.patch
2010-08-14 19:44:58 +00:00

105 lines
2.9 KiB
Diff

support for user directories, based on a patch by Piotr Szymaniak.
against quakespasm svn revision 97.
** !! in alpha state, minimally tested, and certainly outdated !! **
Index: Quake/common.c
===================================================================
--- Quake/common.c (revision 97)
+++ Quake/common.c (working copy)
@@ -1776,25 +1776,27 @@
COM_AddGameDirectory -- johnfitz -- modified based on topaz's tutorial
=================
*/
-void COM_AddGameDirectory (char *dir)
+void COM_AddGameDirectory (char *base, char *dir)
{
int i;
searchpath_t *search;
pack_t *pak;
char pakfile[MAX_OSPATH];
- strcpy (com_gamedir, dir);
+ if (!base)
+ return;
+ strcpy(com_gamedir, va("%s/%s", base, dir));
// add the directory to the search path
search = Z_Malloc(sizeof(searchpath_t));
- 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;
@@ -1837,7 +1839,12 @@
{
int i, j;
searchpath_t *search;
+ char *home;
+ home = getenv("HOME");
+ if (home)
+ Sys_mkdir (va("%s/.quakespasm", home));
+
i = COM_CheckParm ("-basedir");
if (i && i < com_argc-1)
strcpy (com_basedir, com_argv[i + 1]);
@@ -1852,8 +1859,8 @@
}
// 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);
+ COM_AddGameDirectory(home, ".quakespasm/" GAMENAME);
if (!fitzmode)
{ /* QuakeSpasm customization: */
@@ -1865,17 +1872,20 @@
com_nummissionpacks = 0;
if (COM_CheckParm ("-rogue"))
{
- COM_AddGameDirectory (va("%s/rogue", com_basedir));
+ COM_AddGameDirectory(com_basedir, "rogue");
+ COM_AddGameDirectory(home, ".quakespasm/rogue");
com_nummissionpacks++;
}
if (COM_CheckParm ("-hipnotic"))
{
- COM_AddGameDirectory (va("%s/hipnotic", com_basedir));
+ COM_AddGameDirectory(com_basedir, "hipnotic");
+ COM_AddGameDirectory(home, ".quakespasm/hipnotic");
com_nummissionpacks++;
}
if (COM_CheckParm ("-quoth"))
{
- COM_AddGameDirectory (va("%s/quoth", com_basedir));
+ COM_AddGameDirectory(com_basedir, "quoth");
+ COM_AddGameDirectory(home, ".quakespasm/quoth");
com_nummissionpacks++;
}
//johnfitz
@@ -1884,9 +1894,14 @@
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]);
+ COM_AddGameDirectory(home, va(".quakespasm/%s", com_argv[i + 1]));
}
+ /* If home is available, create the game directory */
+ if (home)
+ Sys_mkdir(com_gamedir);
+
i = COM_CheckParm ("-path");
if (i)
{