diff --git a/README b/README index cb47c645..87697954 100644 --- a/README +++ b/README @@ -428,4 +428,10 @@ Can I use texture sets with Yamagi Quake 2? - No, you can't. Yamagi Quake 2 is dedicated to a game experience like in 1997 and thus texture packs are not supported. Use another client. +I'm creating a package or port for my system. Is a system wide install +possible without patching the source? + - Yes. Just set -DSYSTEMWIDE. If you want to change the default + directory from /usr/share/games/quake2/, just set -DSYSTEMDIR + to the desired path. + =============================================================================== diff --git a/TODO b/TODO index 07ceb12c..32bf378f 100644 --- a/TODO +++ b/TODO @@ -5,7 +5,6 @@ game.so: client: - Integrate a signalhandler and print an backtrace with Maxims libexecinfo (only 2 sourcefiles, BSD licensed) -- Integrate caedes systemwide installation patches - Add a optional overwrite for the defaults.cfg - Rename the config.cfg to yq2config.cfg for compatiblity with other sourceports diff --git a/src/common/filesystem.c b/src/common/filesystem.c index 04bdd9e3..298da9ca 100644 --- a/src/common/filesystem.c +++ b/src/common/filesystem.c @@ -35,6 +35,12 @@ #define MAX_FIND_FILES 0x04000 #define MAX_PAKS 100 +#ifdef SYSTEMWIDE + #ifndef SYSTEMDIR + #define SYSTEMDIR "/usr/share/games/quake2/" + #endif +#endif + typedef struct { char name[MAX_QPATH]; @@ -1234,6 +1240,26 @@ FS_AddHomeAsGameDirectory(char *dir) } } +#ifdef SYSTEMWIDE + +void FS_AddSystemwideGameDirectory(char *dir) +{ + char gdir[MAX_OSPATH]; + char *datadir = SYSTEMDIR; + int len = snprintf(gdir, sizeof(gdir), "%s/%s/", datadir, dir); + + printf("Using %s to fetch paks\n", gdir); + + if ((len > 0) && (len < sizeof(gdir)) && (gdir[len-1] == '/')) + { + gdir[len-1] = 0; + } + + FS_AddGameDirectory (gdir); +} + +#endif + /* * Allows enumerating all of the directories in the search path. */ @@ -1439,6 +1465,10 @@ FS_SetGamedir(char *dir) if (fs_cddir->string[0] == '\0') FS_AddGameDirectory(va("%s/%s", fs_cddir->string, dir)); +#ifdef SYSTEMWIDE + FS_AddSystemwideGameDirectory(dir); +#endif + FS_AddGameDirectory(va("%s/%s", fs_basedir->string, dir)); FS_AddHomeAsGameDirectory(dir); } @@ -1809,6 +1839,10 @@ FS_InitFilesystem(void) /* Current directory. */ fs_homepath = Cvar_Get("homepath", Sys_GetCurrentDirectory(), CVAR_NOSET); +#ifdef SYSTEMWIDE + FS_AddSystemwideGameDirectory(BASEDIRNAME); +#endif + /* Add baseq2 to search path. */ FS_AddGameDirectory(va("%s/" BASEDIRNAME, fs_basedir->string)); FS_AddHomeAsGameDirectory(BASEDIRNAME);