mirror of
https://git.code.sf.net/p/quake/quake2forge
synced 2024-11-10 07:12:01 +00:00
---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:
parent
e5027aefb5
commit
712be75e22
2 changed files with 32 additions and 25 deletions
31
src/files.c
31
src/files.c
|
@ -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
|
The "base directory" is the path to the directory holding the quake.exe and
|
||||||
only used during filesystem initialization.
|
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);
|
Cvar_FullSet ("gamedir", dir, CVAR_SERVERINFO|CVAR_NOSET);
|
||||||
if (fs_cddir->string[0])
|
if (fs_cddir->string[0])
|
||||||
FS_AddGameDirectory (va("%s/%s", fs_cddir->string, dir) );
|
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);
|
FS_AddHomeAsGameDirectory (dir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -940,7 +950,16 @@ void FS_InitFilesystem (void)
|
||||||
// allows the game to run from outside the data tree
|
// allows the game to run from outside the data tree
|
||||||
//
|
//
|
||||||
fs_basedir = Cvar_Get ("basedir", ".", CVAR_NOSET);
|
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>
|
// cddir <path>
|
||||||
// Logically concatenates the cddir after the basedir for
|
// Logically concatenates the cddir after the basedir for
|
||||||
|
|
|
@ -675,7 +675,6 @@ struct sfx_s *S_RegisterSexedSound (entity_state_t *ent, char *base)
|
||||||
int n;
|
int n;
|
||||||
char *p;
|
char *p;
|
||||||
struct sfx_s *sfx;
|
struct sfx_s *sfx;
|
||||||
FILE *f;
|
|
||||||
char model[MAX_QPATH];
|
char model[MAX_QPATH];
|
||||||
char sexedFilename[MAX_QPATH];
|
char sexedFilename[MAX_QPATH];
|
||||||
char maleFilename[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 we can't figure it out, they're male
|
||||||
if (!model[0])
|
if (!model[0]) strcpy(model, "male");
|
||||||
strcpy(model, "male");
|
|
||||||
|
|
||||||
// see if we already know of the model specific sound
|
// see if we already know of the model specific sound
|
||||||
Com_sprintf (sexedFilename, sizeof(sexedFilename), "#players/%s/%s", model, base+1);
|
Com_sprintf (sexedFilename, sizeof(sexedFilename), "#players/%s/%s", model, base+1);
|
||||||
sfx = S_FindName (sexedFilename, false);
|
sfx = S_FindName (sexedFilename, false);
|
||||||
|
|
||||||
if (!sfx)
|
if (!sfx){ //not yet registered, so try model specific sound
|
||||||
{
|
sfx = S_RegisterSound (sexedFilename);
|
||||||
// no, so see if it exists
|
}
|
||||||
FS_FOpenFile (&sexedFilename[1], &f);
|
if (!sfx) { //that didn't work, so use male, and alias it for future calls
|
||||||
if (f)
|
Com_sprintf (maleFilename, sizeof(maleFilename), "player/male/%s", base+1);
|
||||||
{
|
sfx = S_AliasName (sexedFilename, maleFilename);
|
||||||
// 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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return sfx;
|
return sfx;
|
||||||
|
|
Loading…
Reference in a new issue