mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-03-21 18:01:15 +00:00
[nq,qw] Stop wring to config.cfg
QF now uses its own configuration file (quakeforge.cfg for now) rather than overwriting config.cfg so that people trying out QF in their normal quake installs don't trash their config.cfg for other quake clients. If quakeforge.cfg is present, all other config files are ignored except that quake.rc is scanned for a startdemos command and that is executed.
This commit is contained in:
parent
87eccb9e6f
commit
1e9329ccf6
11 changed files with 93 additions and 105 deletions
|
@ -79,7 +79,7 @@ int Cmd_Command (struct cbuf_args_s *args);
|
|||
int Cmd_ExecuteString (const char *text, cmd_source_t src);
|
||||
struct cbuf_s;
|
||||
void Cmd_StuffCmds (struct cbuf_s *cbuf);
|
||||
void Cmd_Exec_File (struct cbuf_s *cbuf, const char *path, int qfs);
|
||||
int Cmd_Exec_File (struct cbuf_s *cbuf, const char *path, int qfs);
|
||||
void Cmd_AddProvider(const char *name, struct cbuf_interpreter_s *interp);
|
||||
struct cbuf_interpreter_s *Cmd_GetProvider(const char *name);
|
||||
|
||||
|
|
|
@ -48,7 +48,9 @@ void COM_AddParm (const char *parm);
|
|||
void COM_Init (void);
|
||||
void COM_Init_Cvars (void);
|
||||
void COM_InitArgv (int argc, const char **argv);
|
||||
void COM_ParseConfig (void);
|
||||
struct cbuf_s;
|
||||
void COM_ParseConfig (struct cbuf_s *cbuf);
|
||||
void COM_ExecConfig (struct cbuf_s *cbuf, int skip_quakerc);
|
||||
|
||||
///@}
|
||||
|
||||
|
|
|
@ -497,6 +497,7 @@ Cmd_Help_f (void)
|
|||
|
||||
Sys_Printf ("variable/command not found\n");
|
||||
}
|
||||
|
||||
static void
|
||||
Cmd_Exec_f (void)
|
||||
{
|
||||
|
@ -649,7 +650,7 @@ Cmd_ExecuteString (const char *text, cmd_source_t src)
|
|||
return 0;
|
||||
}
|
||||
|
||||
VISIBLE void
|
||||
VISIBLE int
|
||||
Cmd_Exec_File (cbuf_t *cbuf, const char *path, int qfs)
|
||||
{
|
||||
char *f;
|
||||
|
@ -657,7 +658,7 @@ Cmd_Exec_File (cbuf_t *cbuf, const char *path, int qfs)
|
|||
QFile *file;
|
||||
|
||||
if (!path || !*path)
|
||||
return;
|
||||
return 0;
|
||||
if (qfs) {
|
||||
file = QFS_FOpenFile (path);
|
||||
} else {
|
||||
|
@ -675,7 +676,9 @@ Cmd_Exec_File (cbuf_t *cbuf, const char *path, int qfs)
|
|||
free (f);
|
||||
}
|
||||
Qclose (file);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
VISIBLE void
|
||||
|
|
|
@ -46,8 +46,10 @@
|
|||
#include "QF/cvar.h"
|
||||
#include "QF/idparse.h"
|
||||
#include "QF/qargs.h"
|
||||
#include "QF/quakefs.h"
|
||||
#include "QF/qtypes.h"
|
||||
#include "QF/sys.h"
|
||||
#include "QF/va.h"
|
||||
|
||||
cvar_t *fs_globalcfg;
|
||||
cvar_t *fs_usercfg;
|
||||
|
@ -151,20 +153,13 @@ COM_AddParm (const char *parm)
|
|||
}
|
||||
|
||||
void
|
||||
COM_ParseConfig (void)
|
||||
COM_ParseConfig (cbuf_t *cbuf)
|
||||
{
|
||||
cbuf_t *cbuf;
|
||||
|
||||
cbuf = Cbuf_New (&id_interp);
|
||||
|
||||
// execute +set as early as possible
|
||||
Cmd_StuffCmds (cbuf);
|
||||
Cbuf_Execute_Sets (cbuf);
|
||||
|
||||
// execute the global configuration file if it exists
|
||||
// would have been nice if Cmd_Exec_f could have been used, but it
|
||||
// reads from only within the quake file system, and changing that is
|
||||
// probably Not A Good Thing (tm).
|
||||
// execute set commands in the global configuration file if it exists
|
||||
fs_globalcfg = Cvar_Get ("fs_globalcfg", FS_GLOBALCFG, CVAR_ROM, NULL,
|
||||
"global configuration file");
|
||||
Cmd_Exec_File (cbuf, fs_globalcfg->string, 0);
|
||||
|
@ -174,6 +169,7 @@ COM_ParseConfig (void)
|
|||
Cmd_StuffCmds (cbuf);
|
||||
Cbuf_Execute_Sets (cbuf);
|
||||
|
||||
// execute set commands in the user configuration file if it exists
|
||||
fs_usercfg = Cvar_Get ("fs_usercfg", FS_USERCFG, CVAR_ROM, NULL,
|
||||
"user configuration file");
|
||||
Cmd_Exec_File (cbuf, fs_usercfg->string, 0);
|
||||
|
@ -182,6 +178,53 @@ COM_ParseConfig (void)
|
|||
// execute +set again to override the config file
|
||||
Cmd_StuffCmds (cbuf);
|
||||
Cbuf_Execute_Sets (cbuf);
|
||||
|
||||
Cbuf_Delete (cbuf);
|
||||
}
|
||||
|
||||
static int
|
||||
check_quakerc (const char *cmd, cbuf_t *cbuf)
|
||||
{
|
||||
const char *l, *p;
|
||||
int ret = 0;
|
||||
QFile *f;
|
||||
|
||||
f = QFS_FOpenFile ("quake.rc");
|
||||
while (f && (l = Qgetline (f))) {
|
||||
if ((p = strstr (l, cmd))) {
|
||||
if (p == l) {
|
||||
if (cbuf) {
|
||||
Cbuf_AddText (cbuf, l);
|
||||
}
|
||||
ret = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
Qclose (f);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
COM_ExecConfig (cbuf_t *cbuf, int skip_quakerc)
|
||||
{
|
||||
// quakeforge.cfg overrides quake.rc as it contains quakeforge-specific
|
||||
// commands. If it doesn't exist, then this is the first time quakeforge
|
||||
// has been used in this installation, thus any existing legacy config
|
||||
// should be used to set up defaults on the assumption that the user has
|
||||
// things set up to work with another (hopefully compatible) client
|
||||
if (Cmd_Exec_File (cbuf, "quakeforge.cfg", 1)) {
|
||||
Cmd_Exec_File (cbuf, fs_usercfg->string, 0);
|
||||
Cmd_StuffCmds (cbuf);
|
||||
check_quakerc ("startdemos", cbuf);
|
||||
} else {
|
||||
if (!skip_quakerc) {
|
||||
Cbuf_InsertText (cbuf, "exec quake.rc\n");
|
||||
}
|
||||
Cmd_Exec_File (cbuf, fs_usercfg->string, 0);
|
||||
// Reparse the command line for + commands.
|
||||
// (sets still done, but it doesn't matter)
|
||||
// (Note, no non-base commands exist yet)
|
||||
if (skip_quakerc || !check_quakerc ("stuffcmds", 0)) {
|
||||
Cmd_StuffCmds (cbuf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -103,21 +103,20 @@ client_state_t cl;
|
|||
static void
|
||||
CL_WriteConfiguration (void)
|
||||
{
|
||||
QFile *f;
|
||||
|
||||
// dedicated servers initialize the host but don't parse and set the
|
||||
// config.cfg cvars
|
||||
if (host_initialized && !isDedicated && cl_writecfg->int_val) {
|
||||
const char *path = va (0, "%s/config.cfg", qfs_gamedir->dir.def);
|
||||
f = QFS_WOpen (path, 0);
|
||||
const char *path = va (0, "%s/quakeforge.cfg", qfs_gamedir->dir.def);
|
||||
QFile *f = QFS_WOpen (path, 0);
|
||||
|
||||
if (!f) {
|
||||
Sys_Printf ("Couldn't write config.cfg.\n");
|
||||
Sys_Printf ("Couldn't write quakeforge.cfg.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
Key_WriteBindings (f);
|
||||
Cvar_WriteVariables (f);
|
||||
Joy_WriteBindings (f);
|
||||
Cvar_WriteVariables (f);
|
||||
|
||||
Qclose (f);
|
||||
}
|
||||
|
|
|
@ -808,28 +808,6 @@ Host_InitVCR (quakeparms_t *parms)
|
|||
|
||||
}
|
||||
|
||||
static int
|
||||
check_quakerc (void)
|
||||
{
|
||||
const char *l, *p;
|
||||
int ret = 1;
|
||||
QFile *f;
|
||||
|
||||
f = QFS_FOpenFile ("quake.rc");
|
||||
if (!f)
|
||||
return 1;
|
||||
while ((l = Qgetline (f))) {
|
||||
if ((p = strstr (l, "stuffcmds"))) {
|
||||
if (p == l) { // only known case so far
|
||||
ret = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
Qclose (f);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
Host_Init_Memory (void)
|
||||
{
|
||||
|
@ -886,7 +864,7 @@ Host_Init (void)
|
|||
|
||||
Sys_Init ();
|
||||
GIB_Init (true);
|
||||
COM_ParseConfig ();
|
||||
COM_ParseConfig (host_cbuf);
|
||||
|
||||
Host_Init_Memory ();
|
||||
|
||||
|
@ -926,13 +904,7 @@ Host_Init (void)
|
|||
CL_UpdateScreen (cl.time);
|
||||
CL_UpdateScreen (cl.time);
|
||||
|
||||
if (!isDedicated && cl_quakerc->int_val)
|
||||
Cbuf_InsertText (host_cbuf, "exec quake.rc\n");
|
||||
Cmd_Exec_File (host_cbuf, fs_usercfg->string, 0);
|
||||
// reparse the command line for + commands other than set
|
||||
// (sets still done, but it doesn't matter)
|
||||
if (isDedicated || !cl_quakerc->int_val || check_quakerc ())
|
||||
Cmd_StuffCmds (host_cbuf);
|
||||
COM_ExecConfig (host_cbuf, isDedicated || !cl_quakerc->int_val);
|
||||
|
||||
Hunk_AllocName (0, "-HOST_HUNKLEVEL-");
|
||||
host_hunklevel = Hunk_LowMark ();
|
||||
|
|
|
@ -255,7 +255,7 @@ qtv_init (void)
|
|||
Sys_RegisterShutdown (qtv_shutdown, 0);
|
||||
|
||||
Sys_Init ();
|
||||
COM_ParseConfig ();
|
||||
COM_ParseConfig (qtv_cbuf);
|
||||
Cvar_Get ("cmd_warncmd", "1", CVAR_NONE, NULL, NULL);
|
||||
|
||||
qtv_memory_init ();
|
||||
|
|
|
@ -72,6 +72,7 @@
|
|||
#include "QF/draw.h"
|
||||
#include "QF/image.h"
|
||||
#include "QF/input.h"
|
||||
#include "QF/joystick.h"
|
||||
#include "QF/keys.h"
|
||||
#include "QF/model.h"
|
||||
#include "QF/msg.h"
|
||||
|
@ -1505,26 +1506,20 @@ Host_Error (const char *error, ...)
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Host_WriteConfiguration
|
||||
|
||||
Writes key bindings and archived cvars to config.cfg
|
||||
*/
|
||||
void
|
||||
Host_WriteConfiguration (void)
|
||||
{
|
||||
QFile *f;
|
||||
|
||||
if (host_initialized && cl_writecfg->int_val) {
|
||||
const char *path = va (0, "%s/config.cfg", qfs_gamedir->dir.def);
|
||||
const char *path = va (0, "%s/quakeforge.cfg", qfs_gamedir->dir.def);
|
||||
QFile *f = QFS_WOpen (path, 0);
|
||||
|
||||
f = QFS_WOpen (path, 0);
|
||||
if (!f) {
|
||||
Sys_Printf ("Couldn't write config.cfg.\n");
|
||||
Sys_Printf ("Couldn't write quakeforge.cfg.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
Key_WriteBindings (f);
|
||||
Joy_WriteBindings (f);
|
||||
Cvar_WriteVariables (f);
|
||||
|
||||
Qclose (f);
|
||||
|
@ -1713,28 +1708,6 @@ Host_Frame (float time)
|
|||
fps_count++;
|
||||
}
|
||||
|
||||
static int
|
||||
check_quakerc (void)
|
||||
{
|
||||
const char *l, *p;
|
||||
int ret = 1;
|
||||
QFile *f;
|
||||
|
||||
f = QFS_FOpenFile ("quake.rc");
|
||||
if (!f)
|
||||
return 1;
|
||||
while ((l = Qgetline (f))) {
|
||||
if ((p = strstr (l, "stuffcmds"))) {
|
||||
if (p == l) { // only known case so far
|
||||
ret = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
Qclose (f);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
CL_Init_Memory (void)
|
||||
{
|
||||
|
@ -1773,19 +1746,21 @@ CL_Init_Memory (void)
|
|||
static void
|
||||
CL_Autoexec (int phase)
|
||||
{
|
||||
int cmd_warncmd_val = cmd_warncmd->int_val;
|
||||
|
||||
if (!phase)
|
||||
return;
|
||||
Cbuf_AddText (cl_cbuf, "cmd_warncmd 0\n");
|
||||
Cbuf_AddText (cl_cbuf, "exec config.cfg\n");
|
||||
Cbuf_AddText (cl_cbuf, "exec frontend.cfg\n");
|
||||
if (!Cmd_Exec_File (cl_cbuf, "quakeforge.cfg", 1)) {
|
||||
int cmd_warncmd_val = cmd_warncmd->int_val;
|
||||
|
||||
Cbuf_AddText (cl_cbuf, "cmd_warncmd 0\n");
|
||||
Cbuf_AddText (cl_cbuf, "exec config.cfg\n");
|
||||
Cbuf_AddText (cl_cbuf, "exec frontend.cfg\n");
|
||||
|
||||
Cbuf_AddText (cl_cbuf, va (0, "cmd_warncmd %d\n", cmd_warncmd_val));
|
||||
}
|
||||
|
||||
if (cl_autoexec->int_val) {
|
||||
Cbuf_AddText (cl_cbuf, "exec autoexec.cfg\n");
|
||||
}
|
||||
|
||||
Cbuf_AddText (cl_cbuf, va (0, "cmd_warncmd %d\n", cmd_warncmd_val));
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1796,7 +1771,7 @@ Host_Init (void)
|
|||
|
||||
Sys_Init ();
|
||||
GIB_Init (true);
|
||||
COM_ParseConfig ();
|
||||
COM_ParseConfig (cl_cbuf);
|
||||
|
||||
CL_Init_Memory ();
|
||||
|
||||
|
@ -1837,13 +1812,10 @@ Host_Init (void)
|
|||
CL_UpdateScreen (realtime);
|
||||
CL_UpdateScreen (realtime);
|
||||
|
||||
if (cl_quakerc->int_val)
|
||||
Cbuf_InsertText (cl_cbuf, "exec quake.rc\n");
|
||||
Cmd_Exec_File (cl_cbuf, fs_usercfg->string, 0);
|
||||
// Reparse the command line for + commands.
|
||||
// (Note, no non-base commands exist yet)
|
||||
if (!cl_quakerc->int_val || check_quakerc ())
|
||||
Cmd_StuffCmds (cl_cbuf);
|
||||
COM_ExecConfig (cl_cbuf, !cl_quakerc->int_val);
|
||||
|
||||
// make sure all + commands have been executed
|
||||
Cbuf_Execute_Stack (cl_cbuf);
|
||||
|
||||
Hunk_AllocName (0, "-HOST_HUNKLEVEL-");
|
||||
host_hunklevel = Hunk_LowMark ();
|
||||
|
@ -1853,9 +1825,6 @@ Host_Init (void)
|
|||
Sys_Printf ("\x80\x81\x81\x82 %s initialized \x80\x81\x81\x82\n",
|
||||
PACKAGE_NAME);
|
||||
|
||||
// make sure all + commands have been executed
|
||||
Cbuf_Execute_Stack (cl_cbuf);
|
||||
|
||||
host_initialized = true;
|
||||
|
||||
CL_UpdateScreen (realtime);
|
||||
|
|
|
@ -2488,7 +2488,7 @@ SV_Init (void)
|
|||
|
||||
Sys_Init ();
|
||||
GIB_Init (true);
|
||||
COM_ParseConfig ();
|
||||
COM_ParseConfig (sv_cbuf);
|
||||
|
||||
Cvar_Get ("cmd_warncmd", "1", CVAR_NONE, NULL, NULL);
|
||||
|
||||
|
|
|
@ -134,7 +134,7 @@ init_qf (void)
|
|||
qwaq_cbuf = Cbuf_New (&id_interp);
|
||||
|
||||
Sys_Init ();
|
||||
COM_ParseConfig ();
|
||||
COM_ParseConfig (qwaq_cbuf);
|
||||
|
||||
//Cvar_Set (developer, "1");
|
||||
|
||||
|
|
|
@ -110,7 +110,7 @@ init_qf (void)
|
|||
|
||||
Sys_Init ();
|
||||
GIB_Init (true);
|
||||
COM_ParseConfig ();
|
||||
COM_ParseConfig (qwaq_cbuf);
|
||||
|
||||
//Cvar_Set (developer, "1");
|
||||
|
||||
|
|
Loading…
Reference in a new issue