"condump" is a command that dumps the console text to a file, it first appeared in Quake 2 but was (to my knowledge) never added to any Quake engine so I decided to make it myself. Now that I got it working I thought I could share it, so here's how to do it:
Open console.c and put this function in it:
And put this in Con_Init function in console.c:
That's it! Run Quake and try it.
I've tested this to work with QRACK and ProQuake.
Open console.c and put this function in it:
Code:
/*
================
Con_Dump_f
From Quake 2, modified by RocketGuy to be Quake 1 compatible.
Save the console contents out to a file
================
*/
void Con_Dump_f (void)
{
int l, x;
char *line;
FILE *f;
char buffer[1024];
char *n;
n = Cmd_Args();
if (n == "")
{
Con_Printf ("usage: condump <filename>\n");
return;
}
Con_Printf ("Dumped console text to %s/%s.%s\n", com_gamedir, n, "txt");
f = fopen(va("%s/%s.%s", com_gamedir, n, "txt"), "w");
if (!f)
{
Con_Printf ("ERROR: couldn't open.\n");
return;
}
// skip empty lines
for (l = con_current - con_totallines + 1 ; l <= con_current ; l++)
{
line = con_text + (l%con_totallines)*con_linewidth;
for (x=0 ; x<con_linewidth ; x++)
if (line[x] != ' ')
break;
if (x != con_linewidth)
break;
}
// write the remaining lines
buffer[con_linewidth] = 0;
for ( ; l <= con_current ; l++)
{
line = con_text + (l%con_totallines)*con_linewidth;
strncpy (buffer, line, con_linewidth);
for (x=con_linewidth-1 ; x>=0 ; x--)
{
if (buffer[x] == ' ')
buffer[x] = 0;
else
break;
}
for (x=0; buffer[x]; x++)
buffer[x] &= 0x7f;
fprintf (f, "%s\n", buffer);
}
fclose (f);
}
Code:
Cmd_AddCommand ("condump", Con_Dump_f);
I've tested this to work with QRACK and ProQuake.
Comment