mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-02-17 01:11:45 +00:00
Move the config file/command line parsing into qargs.c
I don't like the COM prefix, but it will do for now.
This commit is contained in:
parent
a71acc9ae5
commit
d9ab3a1f54
7 changed files with 54 additions and 137 deletions
|
@ -37,9 +37,11 @@
|
||||||
|
|
||||||
#include "QF/qtypes.h"
|
#include "QF/qtypes.h"
|
||||||
|
|
||||||
extern int com_argc;
|
extern int com_argc;
|
||||||
extern const char **com_argv;
|
extern const char **com_argv;
|
||||||
extern const char *com_cmdline;
|
extern const char *com_cmdline;
|
||||||
|
extern struct cvar_s *fs_globalcfg;
|
||||||
|
extern struct cvar_s *fs_usercfg;
|
||||||
|
|
||||||
int COM_CheckParm (const char *parm);
|
int COM_CheckParm (const char *parm);
|
||||||
void COM_AddParm (const char *parm);
|
void COM_AddParm (const char *parm);
|
||||||
|
@ -47,6 +49,7 @@ void COM_AddParm (const char *parm);
|
||||||
void COM_Init (void);
|
void COM_Init (void);
|
||||||
void COM_Init_Cvars (void);
|
void COM_Init_Cvars (void);
|
||||||
void COM_InitArgv (int argc, const char **argv);
|
void COM_InitArgv (int argc, const char **argv);
|
||||||
|
void COM_ParseConfig (void);
|
||||||
|
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
|
|
|
@ -59,8 +59,6 @@ HWND mainwindow;
|
||||||
|
|
||||||
cbuf_t *testsound_cbuf;
|
cbuf_t *testsound_cbuf;
|
||||||
cbuf_args_t *testsound_args;
|
cbuf_args_t *testsound_args;
|
||||||
static cvar_t *fs_globalcfg;
|
|
||||||
static cvar_t *fs_usercfg;
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -70,28 +68,9 @@ init (void)
|
||||||
testsound_args = Cbuf_ArgsNew ();
|
testsound_args = Cbuf_ArgsNew ();
|
||||||
|
|
||||||
Sys_Init ();
|
Sys_Init ();
|
||||||
|
COM_ParseConfig ();
|
||||||
Cvar_Get ("cmd_warncmd", "1", CVAR_NONE, NULL, NULL);
|
Cvar_Get ("cmd_warncmd", "1", CVAR_NONE, NULL, NULL);
|
||||||
|
|
||||||
Cmd_StuffCmds (testsound_cbuf);
|
|
||||||
Cbuf_Execute_Sets (testsound_cbuf);
|
|
||||||
|
|
||||||
fs_globalcfg = Cvar_Get ("fs_globalcfg", FS_GLOBALCFG,
|
|
||||||
CVAR_ROM, 0, "global configuration file");
|
|
||||||
Cmd_Exec_File (testsound_cbuf, fs_globalcfg->string, 0);
|
|
||||||
Cbuf_Execute_Sets (testsound_cbuf);
|
|
||||||
|
|
||||||
// execute +set again to override the config file
|
|
||||||
Cmd_StuffCmds (testsound_cbuf);
|
|
||||||
Cbuf_Execute_Sets (testsound_cbuf);
|
|
||||||
fs_usercfg = Cvar_Get ("fs_usercfg", FS_USERCFG,
|
|
||||||
CVAR_ROM, 0, "user configuration file");
|
|
||||||
Cmd_Exec_File (testsound_cbuf, fs_usercfg->string, 0);
|
|
||||||
Cbuf_Execute_Sets (testsound_cbuf);
|
|
||||||
|
|
||||||
// execute +set again to override the config file
|
|
||||||
Cmd_StuffCmds (testsound_cbuf);
|
|
||||||
Cbuf_Execute_Sets (testsound_cbuf);
|
|
||||||
|
|
||||||
Memory_Init (malloc (MEMSIZE), MEMSIZE);
|
Memory_Init (malloc (MEMSIZE), MEMSIZE);
|
||||||
|
|
||||||
QFS_Init ("qw");
|
QFS_Init ("qw");
|
||||||
|
|
|
@ -30,8 +30,7 @@
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static __attribute__ ((used)) const char rcsid[] =
|
static __attribute__ ((used)) const char rcsid[] = "$Id$";
|
||||||
"$Id$";
|
|
||||||
|
|
||||||
#ifdef HAVE_STRING_H
|
#ifdef HAVE_STRING_H
|
||||||
# include <string.h>
|
# include <string.h>
|
||||||
|
@ -46,10 +45,15 @@ static __attribute__ ((used)) const char rcsid[] =
|
||||||
|
|
||||||
#include "QF/cmd.h"
|
#include "QF/cmd.h"
|
||||||
#include "QF/crc.h"
|
#include "QF/crc.h"
|
||||||
|
#include "QF/cvar.h"
|
||||||
|
#include "QF/idparse.h"
|
||||||
#include "QF/qargs.h"
|
#include "QF/qargs.h"
|
||||||
#include "QF/qtypes.h"
|
#include "QF/qtypes.h"
|
||||||
#include "QF/sys.h"
|
#include "QF/sys.h"
|
||||||
|
|
||||||
|
cvar_t *fs_globalcfg;
|
||||||
|
cvar_t *fs_usercfg;
|
||||||
|
|
||||||
static const char **largv;
|
static const char **largv;
|
||||||
static const char *argvdummy = " ";
|
static const char *argvdummy = " ";
|
||||||
|
|
||||||
|
@ -147,3 +151,39 @@ COM_AddParm (const char *parm)
|
||||||
{
|
{
|
||||||
largv[com_argc++] = parm;
|
largv[com_argc++] = parm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
COM_ParseConfig (void)
|
||||||
|
{
|
||||||
|
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).
|
||||||
|
fs_globalcfg = Cvar_Get ("fs_globalcfg", FS_GLOBALCFG, CVAR_ROM, NULL,
|
||||||
|
"global configuration file");
|
||||||
|
Cmd_Exec_File (cbuf, fs_globalcfg->string, 0);
|
||||||
|
Cbuf_Execute_Sets (cbuf);
|
||||||
|
|
||||||
|
// execute +set again to override the config file
|
||||||
|
Cmd_StuffCmds (cbuf);
|
||||||
|
Cbuf_Execute_Sets (cbuf);
|
||||||
|
|
||||||
|
fs_usercfg = Cvar_Get ("fs_usercfg", FS_USERCFG, CVAR_ROM, NULL,
|
||||||
|
"user configuration file");
|
||||||
|
Cmd_Exec_File (cbuf, fs_usercfg->string, 0);
|
||||||
|
Cbuf_Execute_Sets (cbuf);
|
||||||
|
|
||||||
|
// execute +set again to override the config file
|
||||||
|
Cmd_StuffCmds (cbuf);
|
||||||
|
Cbuf_Execute_Sets (cbuf);
|
||||||
|
|
||||||
|
Cbuf_Delete (cbuf);
|
||||||
|
}
|
||||||
|
|
|
@ -109,9 +109,6 @@ jmp_buf host_abortserver;
|
||||||
|
|
||||||
byte *host_basepal;
|
byte *host_basepal;
|
||||||
|
|
||||||
cvar_t *fs_globalcfg;
|
|
||||||
cvar_t *fs_usercfg;
|
|
||||||
|
|
||||||
cvar_t *host_mem_size;
|
cvar_t *host_mem_size;
|
||||||
|
|
||||||
cvar_t *host_framerate;
|
cvar_t *host_framerate;
|
||||||
|
@ -900,32 +897,7 @@ Host_Init (void)
|
||||||
|
|
||||||
Sys_Init ();
|
Sys_Init ();
|
||||||
GIB_Init (true);
|
GIB_Init (true);
|
||||||
|
COM_ParseConfig ();
|
||||||
// execute +set as early as possible
|
|
||||||
Cmd_StuffCmds (host_cbuf);
|
|
||||||
Cbuf_Execute_Sets (host_cbuf);
|
|
||||||
|
|
||||||
// execute the global configuration file if it exists
|
|
||||||
// would have been nice if Cmd_Exec_f could have been used, but it
|
|
||||||
// reads only from within the quake file system, and changing that is
|
|
||||||
// probably Not A Good Thing (tm).
|
|
||||||
fs_globalcfg = Cvar_Get ("fs_globalcfg", FS_GLOBALCFG,
|
|
||||||
CVAR_ROM, NULL, "global configuration file");
|
|
||||||
Cmd_Exec_File (host_cbuf, fs_globalcfg->string, 0);
|
|
||||||
Cbuf_Execute_Sets (host_cbuf);
|
|
||||||
|
|
||||||
// execute +set again to override the config file
|
|
||||||
Cmd_StuffCmds (host_cbuf);
|
|
||||||
Cbuf_Execute_Sets (host_cbuf);
|
|
||||||
|
|
||||||
fs_usercfg = Cvar_Get ("fs_usercfg", FS_USERCFG, CVAR_ROM, NULL,
|
|
||||||
"user configuration file");
|
|
||||||
Cmd_Exec_File (host_cbuf, fs_usercfg->string, 0);
|
|
||||||
Cbuf_Execute_Sets (host_cbuf);
|
|
||||||
|
|
||||||
// execute +set again to override the config file
|
|
||||||
Cmd_StuffCmds (host_cbuf);
|
|
||||||
Cbuf_Execute_Sets (host_cbuf);
|
|
||||||
|
|
||||||
CL_Init_Memory ();
|
CL_Init_Memory ();
|
||||||
|
|
||||||
|
|
|
@ -84,8 +84,6 @@ cbuf_args_t *qtv_args;
|
||||||
static cvar_t *qtv_console_plugin;
|
static cvar_t *qtv_console_plugin;
|
||||||
static cvar_t *qtv_port;
|
static cvar_t *qtv_port;
|
||||||
static cvar_t *qtv_mem_size;
|
static cvar_t *qtv_mem_size;
|
||||||
static cvar_t *fs_globalcfg;
|
|
||||||
static cvar_t *fs_usercfg;
|
|
||||||
|
|
||||||
redirect_t qtv_redirected;
|
redirect_t qtv_redirected;
|
||||||
client_t *qtv_redirect_client;
|
client_t *qtv_redirect_client;
|
||||||
|
@ -260,28 +258,9 @@ qtv_init (void)
|
||||||
Sys_RegisterShutdown (qtv_shutdown);
|
Sys_RegisterShutdown (qtv_shutdown);
|
||||||
|
|
||||||
Sys_Init ();
|
Sys_Init ();
|
||||||
|
COM_ParseConfig ();
|
||||||
Cvar_Get ("cmd_warncmd", "1", CVAR_NONE, NULL, NULL);
|
Cvar_Get ("cmd_warncmd", "1", CVAR_NONE, NULL, NULL);
|
||||||
|
|
||||||
Cmd_StuffCmds (qtv_cbuf);
|
|
||||||
Cbuf_Execute_Sets (qtv_cbuf);
|
|
||||||
|
|
||||||
fs_globalcfg = Cvar_Get ("fs_globalcfg", FS_GLOBALCFG,
|
|
||||||
CVAR_ROM, 0, "global configuration file");
|
|
||||||
Cmd_Exec_File (qtv_cbuf, fs_globalcfg->string, 0);
|
|
||||||
Cbuf_Execute_Sets (qtv_cbuf);
|
|
||||||
|
|
||||||
// execute +set again to override the config file
|
|
||||||
Cmd_StuffCmds (qtv_cbuf);
|
|
||||||
Cbuf_Execute_Sets (qtv_cbuf);
|
|
||||||
fs_usercfg = Cvar_Get ("fs_usercfg", FS_USERCFG,
|
|
||||||
CVAR_ROM, 0, "user configuration file");
|
|
||||||
Cmd_Exec_File (qtv_cbuf, fs_usercfg->string, 0);
|
|
||||||
Cbuf_Execute_Sets (qtv_cbuf);
|
|
||||||
|
|
||||||
// execute +set again to override the config file
|
|
||||||
Cmd_StuffCmds (qtv_cbuf);
|
|
||||||
Cbuf_Execute_Sets (qtv_cbuf);
|
|
||||||
|
|
||||||
qtv_memory_init ();
|
qtv_memory_init ();
|
||||||
|
|
||||||
QFS_Init ("qw");
|
QFS_Init ("qw");
|
||||||
|
|
|
@ -127,9 +127,6 @@ qboolean noclip_anglehack; // remnant from old quake
|
||||||
cbuf_t *cl_cbuf;
|
cbuf_t *cl_cbuf;
|
||||||
cbuf_t *cl_stbuf;
|
cbuf_t *cl_stbuf;
|
||||||
|
|
||||||
cvar_t *fs_globalcfg;
|
|
||||||
cvar_t *fs_usercfg;
|
|
||||||
|
|
||||||
cvar_t *cl_mem_size;
|
cvar_t *cl_mem_size;
|
||||||
|
|
||||||
cvar_t *rcon_password;
|
cvar_t *rcon_password;
|
||||||
|
@ -1715,32 +1712,7 @@ Host_Init (void)
|
||||||
|
|
||||||
Sys_Init ();
|
Sys_Init ();
|
||||||
GIB_Init (true);
|
GIB_Init (true);
|
||||||
|
COM_ParseConfig ();
|
||||||
// execute +set as early as possible
|
|
||||||
Cmd_StuffCmds (cl_cbuf);
|
|
||||||
Cbuf_Execute_Sets (cl_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).
|
|
||||||
fs_globalcfg = Cvar_Get ("fs_globalcfg", FS_GLOBALCFG, CVAR_ROM, NULL,
|
|
||||||
"global configuration file");
|
|
||||||
Cmd_Exec_File (cl_cbuf, fs_globalcfg->string, 0);
|
|
||||||
Cbuf_Execute_Sets (cl_cbuf);
|
|
||||||
|
|
||||||
// execute +set again to override the config file
|
|
||||||
Cmd_StuffCmds (cl_cbuf);
|
|
||||||
Cbuf_Execute_Sets (cl_cbuf);
|
|
||||||
|
|
||||||
fs_usercfg = Cvar_Get ("fs_usercfg", FS_USERCFG, CVAR_ROM, NULL,
|
|
||||||
"user configuration file");
|
|
||||||
Cmd_Exec_File (cl_cbuf, fs_usercfg->string, 0);
|
|
||||||
Cbuf_Execute_Sets (cl_cbuf);
|
|
||||||
|
|
||||||
// execute +set again to override the config file
|
|
||||||
Cmd_StuffCmds (cl_cbuf);
|
|
||||||
Cbuf_Execute_Sets (cl_cbuf);
|
|
||||||
|
|
||||||
CL_Init_Memory ();
|
CL_Init_Memory ();
|
||||||
|
|
||||||
|
|
|
@ -123,9 +123,6 @@ qboolean rcon_from_user;
|
||||||
double netdosexpire[DOSFLOODCMDS] = { 1, 1, 2, 0.9, 1, 5 };
|
double netdosexpire[DOSFLOODCMDS] = { 1, 1, 2, 0.9, 1, 5 };
|
||||||
double netdosvalues[DOSFLOODCMDS] = { 12, 1, 3, 1, 1, 1 };
|
double netdosvalues[DOSFLOODCMDS] = { 12, 1, 3, 1, 1, 1 };
|
||||||
|
|
||||||
cvar_t *fs_globalcfg;
|
|
||||||
cvar_t *fs_usercfg;
|
|
||||||
|
|
||||||
cvar_t *sv_mem_size;
|
cvar_t *sv_mem_size;
|
||||||
|
|
||||||
cvar_t *sv_console_plugin;
|
cvar_t *sv_console_plugin;
|
||||||
|
@ -2493,39 +2490,14 @@ SV_Init (void)
|
||||||
Sys_RegisterShutdown (SV_Shutdown);
|
Sys_RegisterShutdown (SV_Shutdown);
|
||||||
|
|
||||||
Sys_Init ();
|
Sys_Init ();
|
||||||
|
GIB_Init (true);
|
||||||
|
COM_ParseConfig ();
|
||||||
|
|
||||||
Cvar_Get ("cmd_warncmd", "1", CVAR_NONE, NULL, NULL);
|
Cvar_Get ("cmd_warncmd", "1", CVAR_NONE, NULL, NULL);
|
||||||
GIB_Init (true);
|
|
||||||
|
|
||||||
// execute +set as early as possible
|
|
||||||
Cmd_StuffCmds (sv_cbuf);
|
|
||||||
Cbuf_Execute_Sets (sv_cbuf);
|
|
||||||
|
|
||||||
// snax: Init experimental object system and run a test
|
// snax: Init experimental object system and run a test
|
||||||
//Object_Init();
|
//Object_Init();
|
||||||
|
|
||||||
// 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).
|
|
||||||
fs_globalcfg = Cvar_Get ("fs_globalcfg", FS_GLOBALCFG,
|
|
||||||
CVAR_ROM, 0, "global configuration file");
|
|
||||||
Cmd_Exec_File (sv_cbuf, fs_globalcfg->string, 0);
|
|
||||||
Cbuf_Execute_Sets (sv_cbuf);
|
|
||||||
|
|
||||||
// execute +set again to override the config file
|
|
||||||
Cmd_StuffCmds (sv_cbuf);
|
|
||||||
Cbuf_Execute_Sets (sv_cbuf);
|
|
||||||
|
|
||||||
fs_usercfg = Cvar_Get ("fs_usercfg", FS_USERCFG,
|
|
||||||
CVAR_ROM, 0, "user configuration file");
|
|
||||||
Cmd_Exec_File (sv_cbuf, fs_usercfg->string, 0);
|
|
||||||
Cbuf_Execute_Sets (sv_cbuf);
|
|
||||||
|
|
||||||
// execute +set again to override the config file
|
|
||||||
Cmd_StuffCmds (sv_cbuf);
|
|
||||||
Cbuf_Execute_Sets (sv_cbuf);
|
|
||||||
|
|
||||||
SV_Init_Memory ();
|
SV_Init_Memory ();
|
||||||
|
|
||||||
QFS_GamedirCallback (gamedir_f);
|
QFS_GamedirCallback (gamedir_f);
|
||||||
|
|
Loading…
Reference in a new issue