New cvar fs_basepath replaces -basedir param. It's a CVAR_ROM so you can

only set it from the cmdline (you now CAN set it from the cmdline BTW!),
it defaults to the current directory if you don't.

New cvar fs_sharepath.  Defaults to fs_basepath->string and is changed in
the same manner.  If you do change it, files in gamedirs under it will be
used first with basepath's files overriding them.

This allows you to keep your paks in a read-only location (cdrom or unix
/usr/share) and still be able to override those files and save configs.
This commit is contained in:
Joseph Carter 2000-04-18 09:24:29 +00:00
parent 80c33d051f
commit 3a8f38c217
4 changed files with 136 additions and 135 deletions

6
NEWS
View File

@ -48,7 +48,7 @@ QuakeForge 0.1.0
least-surprise principle. Set it to 0 if you want a qw-client like least-surprise principle. Set it to 0 if you want a qw-client like
HUD. HUD.
22 Jan 2000 - changes to command line option -game 22 Jan 2000 - changes to command line option -game [REMOVED!]
You may now specify multiple game directories with -game. If for You may now specify multiple game directories with -game. If for
example you wanted to use the original registered game with MegaTF example you wanted to use the original registered game with MegaTF
on a new style binary you would use -game id1,megatf. It does work on a new style binary you would use -game id1,megatf. It does work
@ -58,6 +58,10 @@ QuakeForge 0.1.0
One caveat: Most mods were designed to be the only one in use, it One caveat: Most mods were designed to be the only one in use, it
may be a Bad Thing to mix certain mods with other mods. may be a Bad Thing to mix certain mods with other mods.
NOTE: This feature has been removed because it can seriously cause
confusion to a game mod. The proper way to override part of
a game is to use different fs_basepath and fs_sharepath.
19 Jan 2000 - changes to cvar r_fog 19 Jan 2000 - changes to cvar r_fog
Fog color is once again white. The r_fog cvar is now a control for Fog color is once again white. The r_fog cvar is now a control for
the fog density rather than a simple toggle control. Eric Windisch the fog density rather than a simple toggle control. Eric Windisch

View File

@ -581,8 +581,9 @@ Draw_Crosshair(void)
glTexEnvf ( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE ); glTexEnvf ( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE );
} else if (crosshair->value) } else if (crosshair->value)
Draw_Character (scr_vrect.x + scr_vrect.width/2-4 + cl_crossx->value, Draw_Character (scr_vrect.x + scr_vrect.width/2-4
scr_vrect.y + scr_vrect.height/2-4 + cl_crossy->value, + cl_crossx->value, scr_vrect.y
+ scr_vrect.height/2-4 + cl_crossy->value,
'+'); '+');
} }

View File

@ -521,6 +521,8 @@ Host_InitDisplay ()
{ {
} }
extern cvar_t *fs_basepath;
/* /*
Host_Init Host_Init
@ -531,7 +533,8 @@ Host_Init (quakeparms_t *parms)
{ {
COM_InitArgv (parms->argc, parms->argv); COM_InitArgv (parms->argc, parms->argv);
#ifdef QUAKEWORLD #if 0
//#ifdef QUAKEWORLD
COM_AddParm ("-game"); COM_AddParm ("-game");
COM_AddParm ("qw"); COM_AddParm ("qw");
Sys_mkdir("qw"); Sys_mkdir("qw");
@ -546,12 +549,17 @@ Host_Init (quakeparms_t *parms)
Sys_Error ("Only %4.1fMB of memory reported, can't execute game", parms->memsize / (float) 0x100000); Sys_Error ("Only %4.1fMB of memory reported, can't execute game", parms->memsize / (float) 0x100000);
Memory_Init (parms->membase, parms->memsize); Memory_Init (parms->membase, parms->memsize);
CL_InitCvars();
SCR_InitCvars();
VID_InitCvars ();
Cbuf_Init (); Cbuf_Init ();
Cmd_Init (); Cmd_Init ();
Cvar_Init (); Cvar_Init ();
CL_InitCvars ();
SCR_InitCvars ();
VID_InitCvars ();
// FIXME: stuff only +set here, shouldn't stuff all commands --KB
Cmd_StuffCmds_f ();
Cbuf_Execute ();
V_Init (); V_Init ();
Chase_Init (); Chase_Init ();

View File

@ -74,6 +74,9 @@ QUAKE FILESYSTEM
char gamedirfile[MAX_OSPATH]; char gamedirfile[MAX_OSPATH];
cvar_t *fs_basepath;
cvar_t *fs_sharepath;
#ifdef GENERATIONS #ifdef GENERATIONS
#include <unzip.h> #include <unzip.h>
typedef unsigned char byte_t; typedef unsigned char byte_t;
@ -123,7 +126,6 @@ typedef struct
#define MAX_FILES_IN_PACK 2048 #define MAX_FILES_IN_PACK 2048
char com_gamedir[MAX_OSPATH]; char com_gamedir[MAX_OSPATH];
char com_basedir[MAX_OSPATH];
typedef struct searchpath_s typedef struct searchpath_s
{ {
@ -136,11 +138,10 @@ searchpath_t *com_searchpaths;
searchpath_t *com_base_searchpaths; // without gamedirs searchpath_t *com_base_searchpaths; // without gamedirs
/* /*
================ COM_filelength
COM_filelength
================
*/ */
int COM_filelength (QFile *f) int
COM_filelength (QFile *f)
{ {
int pos; int pos;
int end; int end;
@ -153,7 +154,11 @@ int COM_filelength (QFile *f)
return end; return end;
} }
int COM_FileOpenRead (char *path, QFile **hndl) /*
COM_FileOpenRead
*/
int
COM_FileOpenRead (char *path, QFile **hndl)
{ {
QFile *f; QFile *f;
@ -169,12 +174,10 @@ int COM_FileOpenRead (char *path, QFile **hndl)
} }
/* /*
============ COM_Path_f
COM_Path_f
============
*/ */
void COM_Path_f (void) void
COM_Path_f (void)
{ {
searchpath_t *s; searchpath_t *s;
@ -277,14 +280,14 @@ COM_CreatePath ( char *path )
/* /*
=========== COM_CopyFile
COM_CopyFile
Copies a file over from the net to the local cache, creating any directories Copies a file over from the net to the local cache, creating any
needed. This is for the convenience of developers using ISDN from home. directories needed. This is for the convenience of developers using
=========== ISDN from home.
*/ */
void COM_CopyFile (char *netpath, char *cachepath) void
COM_CopyFile (char *netpath, char *cachepath)
{ {
QFile *in, *out; QFile *in, *out;
int remaining, count; int remaining, count;
@ -311,8 +314,11 @@ void COM_CopyFile (char *netpath, char *cachepath)
Qclose (out); Qclose (out);
} }
/*
QFile *COM_OpenRead(const char *path, int offs, int len) COM_OpenRead
*/
QFile *
COM_OpenRead (const char *path, int offs, int len)
{ {
int fd=open(path,O_RDONLY); int fd=open(path,O_RDONLY);
unsigned char id[2]; unsigned char id[2];
@ -342,17 +348,16 @@ QFile *COM_OpenRead(const char *path, int offs, int len)
return 0; return 0;
} }
/*
===========
COM_FOpenFile
Finds the file in the search path.
Sets com_filesize and one of handle or file
===========
*/
int file_from_pak; // global indicating file came from pack file ZOID int file_from_pak; // global indicating file came from pack file ZOID
int COM_FOpenFile (char *filename, QFile **gzfile) /*
COM_FOpenFile
Finds the file in the search path.
Sets com_filesize and one of handle or file
*/
int
COM_FOpenFile (char *filename, QFile **gzfile)
{ {
searchpath_t *search; searchpath_t *search;
char netpath[MAX_OSPATH]; char netpath[MAX_OSPATH];
@ -418,8 +423,6 @@ int COM_FOpenFile (char *filename, QFile **gzfile)
if(developer->value) if(developer->value)
Sys_Printf ("FindFile: %s\n",netpath); Sys_Printf ("FindFile: %s\n",netpath);
//*file = fopen (netpath, "rb");
//return COM_filelength (*file);
*gzfile=COM_OpenRead(netpath,-1,-1); *gzfile=COM_OpenRead(netpath,-1,-1);
return com_filesize; return com_filesize;
} }
@ -433,18 +436,18 @@ int COM_FOpenFile (char *filename, QFile **gzfile)
return -1; return -1;
} }
/*
============
COM_LoadFile
Filename are relative to the quake directory.
Allways appends a 0 byte to the loaded data.
============
*/
cache_user_t *loadcache; cache_user_t *loadcache;
byte *loadbuf; byte *loadbuf;
int loadsize; int loadsize;
byte *COM_LoadFile (char *path, int usehunk)
/*
COM_LoadFile
Filename are relative to the quake directory.
Allways appends a 0 byte to the loaded data.
*/
byte *
COM_LoadFile (char *path, int usehunk)
{ {
QFile *h; QFile *h;
byte *buf; byte *buf;
@ -495,24 +498,28 @@ byte *COM_LoadFile (char *path, int usehunk)
return buf; return buf;
} }
byte *COM_LoadHunkFile (char *path) byte *
COM_LoadHunkFile (char *path)
{ {
return COM_LoadFile (path, 1); return COM_LoadFile (path, 1);
} }
byte *COM_LoadTempFile (char *path) byte *
COM_LoadTempFile (char *path)
{ {
return COM_LoadFile (path, 2); return COM_LoadFile (path, 2);
} }
void COM_LoadCacheFile (char *path, struct cache_user_s *cu) void
COM_LoadCacheFile (char *path, struct cache_user_s *cu)
{ {
loadcache = cu; loadcache = cu;
COM_LoadFile (path, 3); COM_LoadFile (path, 3);
} }
// uses temp hunk if larger than bufsize // uses temp hunk if larger than bufsize
byte *COM_LoadStackFile (char *path, void *buffer, int bufsize) byte *
COM_LoadStackFile (char *path, void *buffer, int bufsize)
{ {
byte *buf; byte *buf;
@ -524,16 +531,15 @@ byte *COM_LoadStackFile (char *path, void *buffer, int bufsize)
} }
/* /*
================= COM_LoadPackFile
COM_LoadPackFile
Takes an explicit (not game tree related) path to a pak file. Takes an explicit (not game tree related) path to a pak file.
Loads the header and directory, adding the files at the beginning Loads the header and directory, adding the files at the beginning
of the list so they override previous pack files. of the list so they override previous pack files.
=================
*/ */
pack_t *COM_LoadPackFile (char *packfile) pack_t *
COM_LoadPackFile (char *packfile)
{ {
dpackheader_t header; dpackheader_t header;
int i; int i;
@ -652,7 +658,8 @@ COM_pakzip_readfile(unzFile *pak, const char *path, uint_t bufsize, byte_t *buf)
} }
pack_t *COM_LoadPackZipFile (char *packfile) pack_t *
COM_LoadPackZipFile (char *packfile)
{ {
int i=0; int i=0;
packfile_t *newfiles; packfile_t *newfiles;
@ -723,6 +730,8 @@ COM_LoadGameDirectory(char *dir)
char **pakfiles = NULL; char **pakfiles = NULL;
int i = 0, bufsize = 0, count = 0; int i = 0, bufsize = 0, count = 0;
Con_DPrintf ("COM_LoadGameDirectory (\"%s\")\n", dir);
pakfiles = malloc(FBLOCK_SIZE * sizeof(char *)); pakfiles = malloc(FBLOCK_SIZE * sizeof(char *));
bufsize += FBLOCK_SIZE; bufsize += FBLOCK_SIZE;
if (!pakfiles) if (!pakfiles)
@ -798,14 +807,13 @@ COM_LoadGameDirectory_free:
} }
/* /*
================ COM_AddDirectory
COM_AddGameDirectory
Sets com_gamedir, adds the directory to the head of the path, Sets com_gamedir, adds the directory to the head of the path,
then loads and adds pak1.pak pak2.pak ... then loads and adds pak1.pak pak2.pak ...
================
*/ */
void COM_AddGameDirectory (char *dir) void
COM_AddDirectory (char *dir)
{ {
searchpath_t *search; searchpath_t *search;
char *p; char *p;
@ -815,7 +823,6 @@ void COM_AddGameDirectory (char *dir)
else else
strcpy(gamedirfile, dir); strcpy(gamedirfile, dir);
strcpy (com_gamedir, dir); strcpy (com_gamedir, dir);
Con_Printf ("com_gamedir changed to %s\n", com_gamedir);
// //
// add the directory to the search path // add the directory to the search path
@ -829,19 +836,37 @@ void COM_AddGameDirectory (char *dir)
// add any pak files in the format pak0.pak pak1.pak, ... // add any pak files in the format pak0.pak pak1.pak, ...
// //
COM_LoadGameDirectory(dir); COM_LoadGameDirectory (dir);
} }
/* /*
================ COM_AddGameDirectory
COM_Gamedir
Sets the gamedir and path to a different directory. FIXME: this is a wrapper for COM_AddDirectory (which used to be
================ this function) to have it load share and base paths. Whenver
someone goes through to clean up the fs code, this function should
merge with COM_AddGameDirectory.
*/ */
void COM_Gamedir (char *dir) void
COM_AddGameDirectory (char *dir)
{ {
searchpath_t *search, *next; Con_DPrintf ("COM_AddGameDirectory (\"%s/%s\"\n",
fs_sharepath->string, dir);
if (strcmp (fs_sharepath->string, fs_basepath->string) != 0)
COM_AddDirectory (va("%s/%s", fs_sharepath->string, dir));
COM_AddDirectory (va("%s/%s", fs_basepath->string, dir));
}
/*
COM_Gamedir
Sets the gamedir and path to a different directory.
*/
void
COM_Gamedir (char *dir)
{
searchpath_t *next;
if (strstr(dir, "..") || strstr(dir, "/") if (strstr(dir, "..") || strstr(dir, "/")
|| strstr(dir, "\\") || strstr(dir, ":") ) || strstr(dir, "\\") || strstr(dir, ":") )
@ -850,7 +875,7 @@ void COM_Gamedir (char *dir)
return; return;
} }
if (!strcmp(gamedirfile, dir)) if (strcmp (gamedirfile, dir) == 0)
return; // still the same return; // still the same
strcpy (gamedirfile, dir); strcpy (gamedirfile, dir);
@ -875,85 +900,48 @@ void COM_Gamedir (char *dir)
// //
Cache_Flush (); Cache_Flush ();
if (strcmp (dir, GAMENAME) == 0)
return;
#ifdef QUAKEWORLD #ifdef QUAKEWORLD
if (!strcmp(dir, GAMENAME) || !strcmp(dir, "qw")) if (strcmp (dir, "qw") == 0)
return; return;
#endif #endif
snprintf(com_gamedir, sizeof(com_gamedir), "%s/%s", com_basedir, dir); COM_AddGameDirectory (dir);
//
// add the directory to the search path
//
#if 1
//search = Hunk_Alloc (sizeof(searchpath_t));
search = Z_Malloc (sizeof(searchpath_t));
strcpy (search->filename, dir);
search->next = com_searchpaths;
com_searchpaths = search;
#else
search = Z_Malloc (sizeof(searchpath_t));
strcpy (search->filename, com_gamedir);
search->next = com_searchpaths;
com_searchpaths = search;
#endif
//
// add any pak files in the format pak0.pak pak1.pak, ...
//
COM_LoadGameDirectory(dir);
} }
/* /*
================ COM_InitFilesystem
COM_InitFilesystem
================
*/ */
void void
COM_InitFilesystem ( void ) COM_InitFilesystem ( void )
{ {
int i, len; #ifdef UQUAKE
char *p; int i;
char *games; #endif
/*
-basedir <path>
Overrides the system supplied base directory
*/
i = COM_CheckParm ("-basedir");
if (i && i < com_argc-1)
strcpy (com_basedir, com_argv[i+1]);
else
strcpy (com_basedir, host_parms.basedir);
fs_basepath = Cvar_Get ("fs_basepath", ".", CVAR_ROM,
"the location of your game directories");
fs_sharepath = Cvar_Get ("fs_sharepath", fs_basepath->string,
CVAR_ROM, "read-only game directories");
/* /*
start up with GAMENAME by default start up with GAMENAME by default
*/ */
COM_AddGameDirectory (va("%s/" GAMENAME, com_basedir) ); COM_AddGameDirectory (GAMENAME);
if (hipnotic)
COM_AddGameDirectory ("hipnotic");
if (rogue)
COM_AddGameDirectory ("rogue");
#ifdef QUAKEWORLD #ifdef QUAKEWORLD
COM_AddGameDirectory (va("%s/qw", com_basedir) ); COM_AddGameDirectory ("qw");
#endif // QUAKEWORLD #elif UQUAKE
if ( hipnotic ) {
COM_AddGameDirectory (va("%s/hipnotic", com_basedir) );
}
if ( rogue ) {
COM_AddGameDirectory (va("%s/rogue", com_basedir) );
}
i = COM_CheckParm ("-game"); i = COM_CheckParm ("-game");
if (i && i < com_argc-1) { if (i && i < com_argc-1)
COM_AddGameDirectory (com_argv[i+1]);
len = strlen(com_argv[i+1]) + 1; #endif
games = (char *) malloc(len);
strcpy(games, com_argv[i+1]);
for ( p = strtok(games, ",") ; p != NULL; p = strtok(NULL, ",")) {
COM_AddGameDirectory (va("%s/%s", com_basedir, p));
}
free(games);
}
// any set gamedirs will be freed up to here // any set gamedirs will be freed up to here
com_base_searchpaths = com_searchpaths; com_base_searchpaths = com_searchpaths;
} }