---files.c

Fixed mod loading by localizing game filesystem to PKGLIBDIR and PKGDATADIR.
This way, mods can be installed in PKGDATADIR/modname, like everyone is used
to.

Also export fs_basedir to environment as QUAKE2_HOME if it has been resolved
to a valid path.  Mods may opt to use this variable to perform fileio in
their respective homes.

---snd_dma.c
Removed superfluous fopen/fclose when registering sexed (per-model) sounds.
This removes a "hiccup" when the game first resolves a female, cyborg, ..
sound.
This commit is contained in:
Jay Dolan 2006-01-07 18:51:20 +00:00
parent e5027aefb5
commit 712be75e22
2 changed files with 32 additions and 25 deletions

View File

@ -85,12 +85,21 @@ searchpath_t *fs_base_searchpaths; // without gamedirs
/*
All of Quake's data access is through a hierchal file system, but the contents of the file system can be transparently merged from several sources.
All of Quake's data access is through a hierchal file system, but the contents
of the file system can be transparently merged from several sources.
The "base directory" is the path to the directory holding the quake.exe and all game directories. The sys_* files pass this to host_init in quakeparms_t->basedir. This can be overridden with the "-basedir" command line parm to allow code debugging in a different directory. The base directory is
only used during filesystem initialization.
The "base directory" is the path to the directory holding the quake.exe and
all game directories. The sys_* files pass this to host_init in quakeparms_t->basedir.
This can be overridden with the "-basedir" command line parm to allow code
debugging in a different directory. The base directory is only used during
filesystem initialization.
The "game directory" is the first tree on the search path and directory that all generated files (savegames, screenshots, demos, config files) will be saved to. This can be overridden with the "-game" command line parameter. The game directory can never be changed while quake is executing. This is a precacution against having a malicious server instruct clients to write files over areas they shouldn't.
The "game directory" is the first tree on the search path and directory that all
generated files (savegames, screenshots, demos, config files) will be saved to.
This can be overridden with the "-game" command line parameter. The game
directory can never be changed while quake is executing. This is a precacution
against having a malicious server instruct clients to write files over areas they
shouldn't.
*/
@ -721,7 +730,8 @@ void FS_SetGamedir (char *dir)
Cvar_FullSet ("gamedir", dir, CVAR_SERVERINFO|CVAR_NOSET);
if (fs_cddir->string[0])
FS_AddGameDirectory (va("%s/%s", fs_cddir->string, dir) );
FS_AddGameDirectory (va("%s/%s", fs_basedir->string, dir) );
FS_AddGameDirectory (va(PKGLIBDIR"/%s", dir));
FS_AddGameDirectory (va(PKGDATADIR"/%s", dir));
FS_AddHomeAsGameDirectory (dir);
}
}
@ -940,7 +950,16 @@ void FS_InitFilesystem (void)
// allows the game to run from outside the data tree
//
fs_basedir = Cvar_Get ("basedir", ".", CVAR_NOSET);
#ifndef _WIN32
//export q2 home
if(fs_basedir->string && strcmp(fs_basedir->string, "."))
setenv("QUAKE2_HOME", fs_basedir->string, 0);
else setenv("QUAKE2_HOME", PKGDATADIR, 0);
#endif
//
// cddir <path>
// Logically concatenates the cddir after the basedir for

View File

@ -675,7 +675,6 @@ struct sfx_s *S_RegisterSexedSound (entity_state_t *ent, char *base)
int n;
char *p;
struct sfx_s *sfx;
FILE *f;
char model[MAX_QPATH];
char sexedFilename[MAX_QPATH];
char maleFilename[MAX_QPATH];
@ -696,29 +695,18 @@ struct sfx_s *S_RegisterSexedSound (entity_state_t *ent, char *base)
}
}
// if we can't figure it out, they're male
if (!model[0])
strcpy(model, "male");
if (!model[0]) strcpy(model, "male");
// see if we already know of the model specific sound
Com_sprintf (sexedFilename, sizeof(sexedFilename), "#players/%s/%s", model, base+1);
sfx = S_FindName (sexedFilename, false);
if (!sfx)
{
// no, so see if it exists
FS_FOpenFile (&sexedFilename[1], &f);
if (f)
{
// yes, close the file and register it
FS_FCloseFile (f);
sfx = S_RegisterSound (sexedFilename);
}
else
{
// no, revert to the male sound in the pak0.pak
Com_sprintf (maleFilename, sizeof(maleFilename), "player/%s/%s", "male", base+1);
sfx = S_AliasName (sexedFilename, maleFilename);
}
if (!sfx){ //not yet registered, so try model specific sound
sfx = S_RegisterSound (sexedFilename);
}
if (!sfx) { //that didn't work, so use male, and alias it for future calls
Com_sprintf (maleFilename, sizeof(maleFilename), "player/male/%s", base+1);
sfx = S_AliasName (sexedFilename, maleFilename);
}
return sfx;