static void Cmd_Exec_f (void)
{
char *f;
+ const char *filename;
if (Cmd_Argc () != 2)
{
return;
}
- f = (char *)FS_LoadFile (Cmd_Argv(1), tempmempool, false, NULL);
+ filename = Cmd_Argv(1);
+ if (!strcmp(filename, "config.cfg"))
+ filename = CONFIGFILENAME;
+
+ f = (char *)FS_LoadFile (filename, tempmempool, false, NULL);
if (!f)
{
- Con_Printf("couldn't exec %s\n",Cmd_Argv(1));
+ Con_Printf("couldn't exec %s\n",filename);
return;
}
- Con_Printf("execing %s\n",Cmd_Argv(1));
+ Con_Printf("execing %s\n",filename);
// if executing default.cfg for the first time, lock the cvar defaults
// it may seem backwards to insert this text BEFORE the default.cfg
// but Cbuf_InsertText inserts before, so this actually ends up after it.
- if (!strcmp(Cmd_Argv(1), "default.cfg"))
+ if (strlen(filename) >= 11 && !strcmp(filename + strlen(filename) - 11, "default.cfg"))
Cbuf_InsertText("\ncvar_lockdefaults\n");
// insert newline after the text to make sure the last line is terminated (some text editors omit the trailing newline)
}
void Host_SaveConfig(void)
{
- Host_SaveConfig_to("config.cfg");
+ Host_SaveConfig_to(CONFIGFILENAME);
}
void Host_SaveConfig_f(void)
{
- const char *file = "config.cfg";
+ const char *file = CONFIGFILENAME;
if(Cmd_Argc() >= 2) {
file = Cmd_Argv(1);
// unlock the cvar default strings so they can be updated by the new default.cfg
Cvar_UnlockDefaults();
// reset cvars to their defaults, and then exec startup scripts again
- Cbuf_InsertText("cvar_resettodefaults_all;exec quake.rc\n");
+ Cbuf_InsertText("cvar_resettodefaults_all;exec " STARTCONFIGFILENAME "\n");
}
/*
// set up the default startmap_sp and startmap_dm aliases (mods can
// override these) and then execute the quake.rc startup script
if (gamemode == GAME_NEHAHRA)
- Cbuf_AddText("alias startmap_sp \"map nehstart\"\nalias startmap_dm \"map nehstart\"\nexec quake.rc\n");
+ Cbuf_AddText("alias startmap_sp \"map nehstart\"\nalias startmap_dm \"map nehstart\"\nexec " STARTCONFIGFILENAME "\n");
else if (gamemode == GAME_TRANSFUSION)
- Cbuf_AddText("alias startmap_sp \"map e1m1\"\n""alias startmap_dm \"map bb1\"\nexec quake.rc\n");
+ Cbuf_AddText("alias startmap_sp \"map e1m1\"\n""alias startmap_dm \"map bb1\"\nexec " STARTCONFIGFILENAME "\n");
else if (gamemode == GAME_TEU)
Cbuf_AddText("alias startmap_sp \"map start\"\nalias startmap_dm \"map start\"\nexec teu.rc\n");
else
- Cbuf_AddText("alias startmap_sp \"map start\"\nalias startmap_dm \"map start\"\nexec quake.rc\n");
+ Cbuf_AddText("alias startmap_sp \"map start\"\nalias startmap_dm \"map start\"\nexec " STARTCONFIGFILENAME "\n");
Cbuf_Execute();
// if stuffcmds wasn't run, then quake.rc is probably missing, use default
if (!host_stuffcmdsrun)
{
- Cbuf_AddText("exec default.cfg\nexec config.cfg\nexec autoexec.cfg\nstuffcmds\n");
+ Cbuf_AddText("exec default.cfg\nexec " CONFIGFILENAME "\nexec autoexec.cfg\nstuffcmds\n");
Cbuf_Execute();
}
extern cvar_t developer_loadfile;
extern cvar_t developer_loading;
+#define STARTCONFIGFILENAME "quake.rc"
+#define CONFIGFILENAME "config.cfg"
+
/* Preprocessor macros to identify platform
DP_OS_NAME - "friendly" name of the OS, for humans to read
DP_OS_STR - "identifier" of the OS, more suited for code to use