]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
implemented condump command (I was told by [515] that he implemented this command...
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 30 Sep 2006 20:52:54 +0000 (20:52 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 30 Sep 2006 20:52:54 +0000 (20:52 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6596 d7cf8633-e32d-0410-b094-e92efae38249

console.c

index f6d408083477a9380ebef5415f21d840f9f43ab8..f2226351c3fd3cb69a655902cc42f299eed73cc8 100644 (file)
--- a/console.c
+++ b/console.c
@@ -391,6 +391,47 @@ static void Con_Maps_f (void)
                GetMapList("", NULL, 0);
 }
 
                GetMapList("", NULL, 0);
 }
 
+void Con_ConDump_f (void)
+{
+       int i, l;
+       qboolean allblankssofar;
+       const char *text;
+       qfile_t *file;
+       char temp[MAX_INPUTLINE+2];
+       if (Cmd_Argc() != 2)
+       {
+               Con_Printf("usage: condump <filename>\n");
+               return;
+       }
+       file = FS_Open(Cmd_Argv(1), "wb", false, false);
+       if (!file)
+       {
+               Con_Printf("condump: unable to write file \"%s\"\n", file);
+               return;
+       }
+       // iterate over the entire console history buffer line by line
+       allblankssofar = true;
+       for (i = 0;i < con_totallines;i++)
+       {
+               text = con_text + ((con_current + 1 + i) % con_totallines)*con_linewidth;
+               // count the used characters on this line
+               for (l = min(con_linewidth, (int)sizeof(temp));l > 0 && text[l-1] == ' ';l--);
+               // if not a blank line, begin output
+               if (l)
+                       allblankssofar = false;
+               // output the current line to the file
+               if (!allblankssofar)
+               {
+                       if (l)
+                               memcpy(temp, text, l);
+                       temp[l] = '\n';
+                       temp[l+1] = 0;
+                       FS_Print(file, temp);
+               }
+       }
+       FS_Close(file);
+}
+
 /*
 ================
 Con_Init
 /*
 ================
 Con_Init
@@ -428,6 +469,7 @@ void Con_Init (void)
        Cmd_AddCommand ("messagemode2", Con_MessageMode2_f, "input a chat message to say to only your team");
        Cmd_AddCommand ("clear", Con_Clear_f, "clear console history");
        Cmd_AddCommand ("maps", Con_Maps_f, "list information about available maps");   // By [515]
        Cmd_AddCommand ("messagemode2", Con_MessageMode2_f, "input a chat message to say to only your team");
        Cmd_AddCommand ("clear", Con_Clear_f, "clear console history");
        Cmd_AddCommand ("maps", Con_Maps_f, "list information about available maps");   // By [515]
+       Cmd_AddCommand ("condump", Con_ConDump_f, "output console history to a file (see also log_file)");
 
        con_initialized = true;
        Con_Print("Console initialized.\n");
 
        con_initialized = true;
        Con_Print("Console initialized.\n");