fix knghtbrd's segfault. Make two passes at the config file just like the command line.

This commit is contained in:
Bill Currie 2000-04-27 02:07:29 +00:00
parent ede51b8e01
commit e0d55e9c19
3 changed files with 36 additions and 23 deletions

View file

@ -201,6 +201,7 @@ Cbuf_Execute (void)
while (cmd_text.cursize) { while (cmd_text.cursize) {
extract_line (line); extract_line (line);
// execute the command line // execute the command line
printf("+%s\n",line),
Cmd_ExecuteString (line, src_command); Cmd_ExecuteString (line, src_command);
if (cmd_wait) if (cmd_wait)
@ -292,6 +293,35 @@ void Cmd_StuffCmds_f (void)
Z_Free (build); Z_Free (build);
} }
/*
Cmd_Exec_File
*/
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);
if (f) {
f[len] = 0;
Qread (file, f, len);
Qclose (file);
Cbuf_InsertText (f);
}
Hunk_FreeToLowMark (mark);
}
}
/* /*
=============== ===============

View file

@ -128,5 +128,6 @@ void Cmd_ForwardToServer (void);
void Cmd_StuffCmds_f (void); void Cmd_StuffCmds_f (void);
void Cmd_Echo_f (void); void Cmd_Echo_f (void);
void Cmd_Exec_File (char *path);
#endif // _CMD_H #endif // _CMD_H

View file

@ -532,8 +532,6 @@ extern cvar_t *fs_basepath;
void void
Host_Init (quakeparms_t *parms) Host_Init (quakeparms_t *parms)
{ {
QFile *globalcfg;
COM_InitArgv (parms->argc, parms->argv); COM_InitArgv (parms->argc, parms->argv);
if ( COM_CheckParm ("-minmemory") ) if ( COM_CheckParm ("-minmemory") )
@ -560,33 +558,17 @@ Host_Init (quakeparms_t *parms)
// probably Not A Good Thing (tm). // probably Not A Good Thing (tm).
global_cfg_file = Cvar_Get("global_cfg_file", GLOBAL_CFG_FILE, global_cfg_file = Cvar_Get("global_cfg_file", GLOBAL_CFG_FILE,
CVAR_ROM, "global configuration 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)
Cbuf_Execute ();
}
Cmd_Exec_File (global_cfg_file->string);
Cbuf_Execute_Sets ();
CL_InitCvars (); CL_InitCvars ();
SCR_InitCvars (); SCR_InitCvars ();
VID_InitCvars (); VID_InitCvars ();
Cmd_Exec_File (global_cfg_file->string);
Cbuf_Execute ();
// reparse the command line for + commands other than set (sets still done, // reparse the command line for + commands other than set (sets still done,
// but it doesn't matter) // but it doesn't matter)
Cmd_StuffCmds_f (); Cmd_StuffCmds_f ();