Add global config file loading. Fully autoconfiscated (Coderjoe: you'll need to add onother #define to wins/config.h). Currently, only set commands are executed (easy enough to change). if ${prefix} is /usr, the global config file is /etc/quakeforge.conf, otherwise it will be ${prefix}/etc/quakeforge.conf. The full path to the config file can be specified with (eg) --with-global-cfg-file=/usr/etc/quakeforge.rc.

This commit is contained in:
Bill Currie 2000-04-26 13:24:13 +00:00
parent aa42a88241
commit b7b9937dcb
4 changed files with 58 additions and 11 deletions

View file

@ -9,6 +9,9 @@
/* Define if you want .qz support */
#undef GENERATIONS
/* Define this to the default global configuration file */
#undef GLOBAL_CFG_FILE
/* Define this to the default location of the game directories */
#undef FS_BASEPATH

View file

@ -81,6 +81,7 @@ cvar_t *coop;
cvar_t *fraglimit;
cvar_t *skill;
cvar_t *timelimit;
cvar_t *global_cfg_file;
#ifdef UQUAKE
client_t *host_client; // current client
@ -553,15 +554,40 @@ Host_Init (quakeparms_t *parms)
Cmd_StuffCmds_f ();
Cbuf_Execute_Sets ();
// execute the global configuration file if it exists
// would have been nice if Cmd_Exec_f could have been used, but it only
// reads from within the quake file system, and changing that is probably
// Not A Good Thing (tm).
global_cfg_file = Cvar_Get("global_cfg_file", GLOBAL_CFG_FILE,
CVAR_ROM, "global configuration file");
if ((globalcfg = Qopen (global_cfg_file->string, "r")) != NULL) {
char *f;
int mark;
int len;
char base[32];
// extract the filename base name for hunk tag
COM_FileBase (global_cfg_file->string, base);
len = COM_filelength (globalcfg);
mark = Hunk_LowMark ();
f = (char *)Hunk_AllocName (len+1, base);
if (f) {
f[len] = 0;
Qread (globalcfg, f, len);
Qclose (globalcfg);
Cbuf_InsertText (f);
}
Hunk_FreeToLowMark (mark);
if (f)
// FIXME: just sets, or other commands as well?
Cbuf_Execute_Sets ();
}
CL_InitCvars ();
SCR_InitCvars ();
VID_InitCvars ();
if ((globalcfg = Qopen ("/etc/quakeforge.conf", "r")) != NULL)
{
Cbuf_InsertText ((char *)globalcfg);
}
// reparse the command line for + commands other than set (sets still done,
// but it doesn't matter)
Cmd_StuffCmds_f ();
@ -587,12 +613,6 @@ Host_Init (quakeparms_t *parms)
Con_Init ();
M_Init ();
if (globalcfg != NULL)
{
Cbuf_InsertText ((char *)globalcfg);
Qclose (globalcfg);
}
#ifdef UQUAKE
PR_Init ();
#endif

View file

@ -46,6 +46,7 @@ extern char com_gamedir[MAX_OSPATH];
void COM_WriteFile (char *filename, void *data, int len);
int COM_FOpenFile (char *filename, QFile **gzfile);
void COM_CloseFile (QFile *h);
int COM_filelength (QFile *f);
byte *COM_LoadStackFile (char *path, void *buffer, int bufsize);
byte *COM_LoadTempFile (char *path);

View file

@ -123,6 +123,29 @@ else
AC_DEFINE(GAMENAME, "id1")
fi
AC_ARG_WITH(global-cfg-file,
[ --with-global-cfg-file=FILE
define the default global config file. defaults to
/etc/quakeforge.conf or
/usr/local/etc/quakeforge.conf, depending on
\${prefix}.],
AC_DEFINE_UNQUOTED(GLOBAL_CFG_FILE, "$withval"),
if test "x$prefix" = xNONE; then
if test "${ac_default_prefix}" = /usr; then
AC_DEFINE_UNQUOTED(GLOBAL_CFG_FILE, "/etc/quakeforge.conf")
else
AC_DEFINE_UNQUOTED(GLOBAL_CFG_FILE,
"${ac_default_prefix}/etc/quakeforge.conf")
fi
else
if test "${prefix}" = /usr; then
AC_DEFINE_UNQUOTED(GLOBAL_CFG_FILE, "/etc/quakeforge.conf")
else
AC_DEFINE_UNQUOTED(GLOBAL_CFG_FILE, "${prefix}/etc/quakeforge.conf")
fi
fi
)
AC_ARG_ENABLE(basepath,
[ --enable-basepath use \${prefix}/games/quakeforge instead of . for game
data],