mirror of
https://github.com/Shpoike/Quakespasm.git
synced 2024-11-14 17:10:53 +00:00
35d839abc7
the latset changes. git-svn-id: http://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@391 af15c1b1-3010-417e-b628-4374ebc0bcbd
117 lines
3.1 KiB
Diff
117 lines
3.1 KiB
Diff
support for user directories, based on a patch by Piotr Szymaniak.
|
|
** against quakespasm svn revision 390.
|
|
** 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 390)
|
|
+++ Quake/common.c (working copy)
|
|
@@ -1825,32 +1825,36 @@
|
|
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 @@
|
|
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;
|
|
+ }
|
|
}
|
|
|
|
static void kill_id1_conback (void) /* QuakeSpasm customization: */
|
|
@@ -1894,6 +1906,10 @@
|
|
{
|
|
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]);
|
|
@@ -1908,8 +1924,7 @@
|
|
}
|
|
|
|
// 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 (!fitzmode)
|
|
{ /* QuakeSpasm customization: */
|
|
@@ -1921,17 +1936,17 @@
|
|
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
|
|
@@ -1940,7 +1955,7 @@
|
|
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]);
|
|
}
|
|
}
|
|
|