]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
use CONFIGFILENAME and STARTCONFIGFILENAME macros instead of config.cfg
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 25 Feb 2010 16:01:54 +0000 (16:01 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 25 Feb 2010 16:01:54 +0000 (16:01 +0000)
and quake.rc

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10000 d7cf8633-e32d-0410-b094-e92efae38249

cmd.c
host.c
quakedef.h

diff --git a/cmd.c b/cmd.c
index d68a289a90822fad3396b7c471fa483ee89a30f2..47e40a4faa343c6b2faa2def596e1ffa13496cb3 100644 (file)
--- 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 d3e17cd1b760d4c58b8080ab6adf6840bf17d3c4..31ff4491b1e13dca7ce5ca1efcc52fa91fd5a350 100644 (file)
--- 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();
        }
 
index 98a997ff590dc8de301daaf7b445c49bbafcc52e..c680ccd5d2cb1cccaad117ad65dc66f75e197823 100644 (file)
@@ -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