From b530da0ed507718834d845824a344c7a0d14cfcf Mon Sep 17 00:00:00 2001 From: havoc Date: Thu, 25 Feb 2010 16:01:54 +0000 Subject: [PATCH] use CONFIGFILENAME and STARTCONFIGFILENAME macros instead of config.cfg and quake.rc git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10000 d7cf8633-e32d-0410-b094-e92efae38249 --- cmd.c | 13 +++++++++---- host.c | 14 +++++++------- quakedef.h | 3 +++ 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/cmd.c b/cmd.c index d68a289a..47e40a4f 100644 --- a/cmd.c +++ b/cmd.c @@ -454,6 +454,7 @@ Cmd_Exec_f static void Cmd_Exec_f (void) { char *f; + const char *filename; if (Cmd_Argc () != 2) { @@ -461,18 +462,22 @@ static void Cmd_Exec_f (void) 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) diff --git a/host.c b/host.c index d3e17cd1..31ff4491 100644 --- a/host.c +++ b/host.c @@ -271,11 +271,11 @@ void Host_SaveConfig_to(const char *file) } 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); @@ -297,7 +297,7 @@ void Host_LoadConfig_f(void) // 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"); } /* @@ -1122,19 +1122,19 @@ static void Host_Init (void) // 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(); } diff --git a/quakedef.h b/quakedef.h index 98a997ff..c680ccd5 100644 --- a/quakedef.h +++ b/quakedef.h @@ -394,6 +394,9 @@ extern cvar_t developer_insane; 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 -- 2.39.2