updated on Sat Jan 21 20:03:50 UTC 2012
[aur-mirror.git] / fitzquake / fitzquake-homedir.patch
blob8571bea66a38d12a64e2ec7b08e85683dfdb34e9
1 --- common.c.orig 2008-01-16 19:08:00.000000000 +0100
2 +++ common.c 2008-10-19 22:59:55.000000000 +0200
3 @@ -1265,6 +1265,7 @@
5 char com_cachedir[MAX_OSPATH];
6 char com_gamedir[MAX_OSPATH];
7 +char com_basedir[MAX_OSPATH];
9 typedef struct searchpath_s
11 @@ -1707,25 +1708,30 @@
12 COM_AddGameDirectory -- johnfitz -- modified based on topaz's tutorial
13 =================
15 -void COM_AddGameDirectory (char *dir)
16 +//void COM_AddGameDirectory (char *dir)
17 +static void
18 +COM_AddGameDirectory (char *base, char *dir)
20 int i;
21 searchpath_t *search;
22 pack_t *pak;
23 char pakfile[MAX_OSPATH];
25 - strcpy (com_gamedir, dir);
26 + if (!base)
27 + return;
29 + strcpy(com_gamedir, va("%s/%s", base, dir));
31 // add the directory to the search path
32 search = Z_Malloc(sizeof(searchpath_t));
33 - strcpy (search->filename, dir);
34 + strcpy (search->filename, com_gamedir);
35 search->next = com_searchpaths;
36 com_searchpaths = search;
38 // add any pak files in the format pak0.pak pak1.pak, ...
39 for (i = 0; ; i++)
41 - sprintf (pakfile, "%s/pak%i.pak", dir, i);
42 + sprintf (pakfile, "%s/pak%i.pak", com_gamedir, i);
43 pak = COM_LoadPackFile (pakfile);
44 if (!pak)
45 break;
46 @@ -1743,21 +1749,23 @@
48 void COM_InitFilesystem () //johnfitz -- modified based on topaz's tutorial
50 + char *home;
51 int i, j;
52 - char basedir[MAX_OSPATH];
53 searchpath_t *search;
55 + home = getenv("HOME");
57 i = COM_CheckParm ("-basedir");
58 if (i && i < com_argc-1)
59 - strcpy (basedir, com_argv[i+1]);
60 + strcpy (com_basedir, com_argv[i+1]);
61 else
62 - strcpy (basedir, host_parms.basedir);
63 + strcpy (com_basedir, host_parms.basedir);
65 - j = strlen (basedir);
66 + j = strlen (com_basedir);
67 if (j > 0)
69 - if ((basedir[j-1] == '\\') || (basedir[j-1] == '/'))
70 - basedir[j-1] = 0;
71 + if ((com_basedir[j-1] == '\\') || (com_basedir[j-1] == '/'))
72 + com_basedir[j-1] = 0;
75 i = COM_CheckParm ("-cachedir");
76 @@ -1774,19 +1782,30 @@
77 com_cachedir[0] = 0;
79 // start up with GAMENAME by default (id1)
80 - COM_AddGameDirectory (va("%s/"GAMENAME, basedir) );
81 - strcpy (com_gamedir, va("%s/"GAMENAME, basedir));
82 + COM_AddGameDirectory(com_basedir, GAMENAME);
83 + COM_AddGameDirectory(home, ".fitzquake/" GAMENAME);
85 - if (COM_CheckParm ("-rogue"))
86 - COM_AddGameDirectory (va("%s/rogue", basedir) );
87 - if (COM_CheckParm ("-hipnotic"))
88 - COM_AddGameDirectory (va("%s/hipnotic", basedir) );
89 + if (COM_CheckParm ("-rogue")) {
90 + COM_AddGameDirectory(com_basedir, "rogue");
91 + COM_AddGameDirectory(home, ".fitzquake/rogue");
92 + }
93 + if (COM_CheckParm ("-hipnotic")) {
94 + COM_AddGameDirectory(com_basedir, "hipnotic");
95 + COM_AddGameDirectory(home, ".fitzquake/hipnotic");
96 + }
98 i = COM_CheckParm ("-game");
99 if (i && i < com_argc-1)
101 com_modified = true;
102 - COM_AddGameDirectory (va("%s/%s", basedir, com_argv[i+1]));
103 + COM_AddGameDirectory(com_basedir, com_argv[i + 1]);
104 + COM_AddGameDirectory(home, va(".fitzquake/%s", com_argv[i + 1]));
107 + /* If home is available, create the game directory */
108 + if (home) {
109 + COM_CreatePath(com_gamedir);
110 + Sys_mkdir(com_gamedir);
113 i = COM_CheckParm ("-path");
114 --- common.h.orig 2008-01-16 19:08:00.000000000 +0100
115 +++ common.h 2008-10-19 22:49:45.000000000 +0200
116 @@ -167,6 +167,7 @@
117 extern int com_filesize;
118 struct cache_user_s;
120 +extern char com_basedir[MAX_OSPATH];
121 extern char com_gamedir[MAX_OSPATH];
123 void COM_WriteFile (char *filename, void *data, int len);