diff --git a/acconfig.h b/acconfig.h index cfbfb03..97fc7c4 100644 --- a/acconfig.h +++ b/acconfig.h @@ -19,6 +19,9 @@ /* Define this to the location of the global config file */ #undef FS_GLOBALCFG +/* Define this to the location of the user config file */ +#undef FS_USERCFG + /* Define this to the shared game directory root */ #undef FS_SHAREPATH diff --git a/configure.in b/configure.in index f108d10..738b0ef 100644 --- a/configure.in +++ b/configure.in @@ -1038,6 +1038,7 @@ if test "x$newstyle" = xyes -o "x$newstyle" = "x"; then AC_DEFINE(BASEGAME, "base") AC_DEFINE(SKINBASE, "base") default_globalconf="/etc/$PACKAGE.conf" + default_userconf="~/.${PACKAGE}rc" eval foo="$datadir" default_sharepath="$foo/games/$PACKAGE" default_userpath="~/.$PACKAGE" @@ -1047,8 +1048,10 @@ else AC_DEFINE(SKINBASE, "qw") if test "x$SYSTYPE" = xWIN32; then default_globalconf="%WINDIR%/$PACKAGE.conf" + default_userconf="" else default_globalconf="/etc/$PACKAGE.conf" + default_userconf="" fi default_sharepath="." default_userpath="." @@ -1065,6 +1068,17 @@ if test "x$globalconf" = "xauto" || test "x$globalconf" = "xyes" || \ fi AC_DEFINE_UNQUOTED(FS_GLOBALCFG, "$globalconf") +AC_ARG_WITH(user-cfg, +[ --with-user-cfg=FILE If set will change the name and location of the + global config file used by QuakeForge. Defaults to + /etc/quakeforge.conf.], +globalconf="$withval", userconf="auto") +if test "x$userconf" = "xauto" || test "x$userconf" = "xyes" || \ + test "x$userconf" = "xno"; then dnl yes/no sanity checks + userconf="$default_userconf" +fi +AC_DEFINE_UNQUOTED(FS_USERCFG, "$userconf") + AC_ARG_WITH(sharepath, [ --with-sharepath=DIR Use DIR for shared game data, defaults to '.' or \${datadir}/games/quakeforge (if new style)], @@ -1416,6 +1430,7 @@ AC_MSG_RESULT([ Shared game data directory: $sharepath Per-user game data directory: $userpath Global configuration file: $globalconf + User configuration file: $userconf ]) if test -d $srcdir/CVS; then echo "WARNING: Hackers at work, watch for falling bits of code." diff --git a/include/win32/mingw/config.h b/include/win32/mingw/config.h index 7ed9702..67211b6 100644 --- a/include/win32/mingw/config.h +++ b/include/win32/mingw/config.h @@ -268,6 +268,9 @@ /* Location of QuakeForge's global config file */ #define FS_GLOBALCFG "./quakeforge.conf" +/* Location of QuakeForge's user config file */ +#define FS_USERCFG "" + //#define strcasecmp(s1, s2) stricmp((s1), (s2)) //#define strncasecmp(s1, s2, n) strnicmp((s1), (s2), (n)) diff --git a/include/win32/vc/config.h b/include/win32/vc/config.h index e6696c3..e675317 100644 --- a/include/win32/vc/config.h +++ b/include/win32/vc/config.h @@ -290,6 +290,9 @@ /* Location of QuakeForge's global config file */ #define FS_GLOBALCFG "~/quakeforge.conf" +/* Location of QuakeForge's user config file */ +#define FS_USERCFG "" + #define strcasecmp(s1, s2) stricmp((s1), (s2)) #define strncasecmp(s1, s2, n) strnicmp((s1), (s2), (n)) diff --git a/source/cl_main.c b/source/cl_main.c index 930b420..302a163 100644 --- a/source/cl_main.c +++ b/source/cl_main.c @@ -105,6 +105,7 @@ qboolean noclip_anglehack; // remnant from old quake cvar_t *fs_globalcfg; +cvar_t *fs_usercfg; cvar_t *rcon_password; cvar_t *rcon_address; @@ -1561,6 +1562,15 @@ Host_Init (void) Cmd_StuffCmds_f (); Cbuf_Execute_Sets (); + fs_usercfg = Cvar_Get ("fs_usercfg", FS_USERCFG, + CVAR_ROM, "user configuration file"); + Cmd_Exec_File (fs_usercfg->string); + Cbuf_Execute_Sets (); + + // execute +set again to override the config file + Cmd_StuffCmds_f (); + Cbuf_Execute_Sets (); + CL_Cam_Init_Cvars (); CL_Input_Init_Cvars (); Skin_Init_Cvars (); diff --git a/source/cmd.c b/source/cmd.c index c732050..b5d159b 100644 --- a/source/cmd.c +++ b/source/cmd.c @@ -303,24 +303,18 @@ void Cmd_Exec_File (char *path) { char *f; - int mark; int len; - char base[32]; QFile *file; if ((file = Qopen (path, "r")) != NULL) { - // extract the filename base name for hunk tag - COM_FileBase (path, base); len = COM_filelength (file); - mark = Hunk_LowMark (); - f = (char *) Hunk_AllocName (len + 1, base); + f = (char *) Hunk_TempAlloc (len + 1); if (f) { f[len] = 0; Qread (file, f, len); Qclose (file); Cbuf_InsertText (f); } - Hunk_FreeToLowMark (mark); } } diff --git a/source/sv_main.c b/source/sv_main.c index 6a2faf2..e7cc87b 100644 --- a/source/sv_main.c +++ b/source/sv_main.c @@ -80,6 +80,7 @@ cvar_t *sv_allow_log; cvar_t *sv_allow_ping; cvar_t *fs_globalcfg; +cvar_t *fs_usercfg; cvar_t *sv_mintic; // bound the size of the cvar_t *sv_maxtic; // physics time tic @@ -1900,6 +1901,16 @@ SV_Init (void) Cmd_StuffCmds_f (); Cbuf_Execute_Sets (); + fs_usercfg = Cvar_Get ("fs_usercfg", FS_USERCFG, + CVAR_ROM, "user configuration file"); + Cmd_Exec_File (fs_usercfg->string); + Cbuf_Execute_Sets (); + + // execute +set again to override the config file + Cmd_StuffCmds_f (); + Cbuf_Execute_Sets (); + + COM_Filesystem_Init_Cvars (); COM_Init_Cvars (); Mod_Init_Cvars ();