diff --git a/include/QF/cmd.h b/include/QF/cmd.h index 4529c8c6d..281dfe09a 100644 --- a/include/QF/cmd.h +++ b/include/QF/cmd.h @@ -61,7 +61,7 @@ void 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); +void Cmd_Exec_File (struct cbuf_s *cbuf, const char *path, int qfs); void Cmd_Return (const char *value); void Cmd_Error (const char *message); diff --git a/libs/util/cmd.c b/libs/util/cmd.c index a183f46d8..05e4c7d8a 100644 --- a/libs/util/cmd.c +++ b/libs/util/cmd.c @@ -625,7 +625,7 @@ Cmd_ExecuteString (const char *text, cmd_source_t src) } void -Cmd_Exec_File (cbuf_t *cbuf, const char *path) +Cmd_Exec_File (cbuf_t *cbuf, const char *path, int qfs) { char *f; int len; @@ -633,17 +633,22 @@ Cmd_Exec_File (cbuf_t *cbuf, const char *path) if (!path || !*path) return; - if ((file = Qopen (path, "r")) != NULL) { + if (qfs) { + COM_FOpenFile (path, &file); + } else { + file = Qopen (path, "r"); + } + if (file) { len = Qfilesize (file); f = (char *) malloc (len + 1); if (f) { f[len] = 0; Qread (file, f, len); - Qclose (file); // Always insert into console Cbuf_InsertText (cbuf, f); free (f); } + Qclose (file); } } diff --git a/nq/source/cl_parse.c b/nq/source/cl_parse.c index e4d5ca323..233f78dfc 100644 --- a/nq/source/cl_parse.c +++ b/nq/source/cl_parse.c @@ -229,9 +229,9 @@ map_cfg (const char *mapname, int all) COM_FOpenFile (name, &f); if (f) { Qclose (f); - Cmd_Exec_File (host_cbuf, name); + Cmd_Exec_File (host_cbuf, name, 1); } else { - Cmd_Exec_File (host_cbuf, "maps_default.cfg"); + Cmd_Exec_File (host_cbuf, "maps_default.cfg", 1); } if (all) Cbuf_Execute_Stack (host_cbuf); diff --git a/nq/source/host.c b/nq/source/host.c index d71788990..f107250b5 100644 --- a/nq/source/host.c +++ b/nq/source/host.c @@ -877,7 +877,7 @@ Host_Init (void) // 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); + Cmd_Exec_File (host_cbuf, fs_globalcfg->string, 0); Cbuf_Execute_Sets (host_cbuf); // execute +set again to override the config file @@ -886,7 +886,7 @@ Host_Init (void) fs_usercfg = Cvar_Get ("fs_usercfg", FS_USERCFG, CVAR_ROM, NULL, "user configuration file"); - Cmd_Exec_File (host_cbuf, fs_usercfg->string); + Cmd_Exec_File (host_cbuf, fs_usercfg->string, 0); Cbuf_Execute_Sets (host_cbuf); // execute +set again to override the config file @@ -979,7 +979,7 @@ Host_Init (void) if (!isDedicated && cl_quakerc->int_val) Cbuf_InsertText (host_cbuf, "exec quake.rc\n"); - Cmd_Exec_File (host_cbuf, fs_usercfg->string); + 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 ())) diff --git a/qw/source/cl_main.c b/qw/source/cl_main.c index 89fa7ad87..d0d1f953e 100644 --- a/qw/source/cl_main.c +++ b/qw/source/cl_main.c @@ -1711,7 +1711,7 @@ Host_Init (void) // 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); + Cmd_Exec_File (cl_cbuf, fs_globalcfg->string, 0); Cbuf_Execute_Sets (cl_cbuf); // execute +set again to override the config file @@ -1720,7 +1720,7 @@ Host_Init (void) fs_usercfg = Cvar_Get ("fs_usercfg", FS_USERCFG, CVAR_ROM, NULL, "user configuration file"); - Cmd_Exec_File (cl_cbuf, fs_usercfg->string); + Cmd_Exec_File (cl_cbuf, fs_usercfg->string, 0); Cbuf_Execute_Sets (cl_cbuf); // execute +set again to override the config file @@ -1824,7 +1824,7 @@ Host_Init (void) if (cl_quakerc->int_val) Cbuf_InsertText (cl_cbuf, "exec quake.rc\n"); - Cmd_Exec_File (cl_cbuf, fs_usercfg->string); + 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 ()) diff --git a/qw/source/cl_parse.c b/qw/source/cl_parse.c index 7d40219c3..f658d4686 100644 --- a/qw/source/cl_parse.c +++ b/qw/source/cl_parse.c @@ -264,9 +264,9 @@ map_cfg (const char *mapname, int all) COM_FOpenFile (name, &f); if (f) { Qclose (f); - Cmd_Exec_File (cl_cbuf, name); + Cmd_Exec_File (cl_cbuf, name, 1); } else { - Cmd_Exec_File (cl_cbuf, "maps_default.cfg"); + Cmd_Exec_File (cl_cbuf, "maps_default.cfg", 1); } if (all) Cbuf_Execute_Stack (cl_cbuf); diff --git a/qw/source/sv_main.c b/qw/source/sv_main.c index 9a77d18d5..77869b181 100644 --- a/qw/source/sv_main.c +++ b/qw/source/sv_main.c @@ -2480,7 +2480,7 @@ SV_Init (void) // 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); + Cmd_Exec_File (sv_cbuf, fs_globalcfg->string, 0); Cbuf_Execute_Sets (sv_cbuf); // execute +set again to override the config file @@ -2489,7 +2489,7 @@ SV_Init (void) fs_usercfg = Cvar_Get ("fs_usercfg", FS_USERCFG, CVAR_ROM, 0, "user configuration file"); - Cmd_Exec_File (sv_cbuf, fs_usercfg->string); + Cmd_Exec_File (sv_cbuf, fs_usercfg->string, 0); Cbuf_Execute_Sets (sv_cbuf); // execute +set again to override the config file @@ -2561,7 +2561,7 @@ SV_Init (void) SV_Printf ("<==> %s initialized <==>\n", PROGRAM); // process command line arguments - Cmd_Exec_File (sv_cbuf, fs_usercfg->string); + Cmd_Exec_File (sv_cbuf, fs_usercfg->string, 0); Cmd_StuffCmds (sv_cbuf); Cbuf_Execute (sv_cbuf);