diff --git a/code/client/cl_console.c b/code/client/cl_console.c index 29b98942..bc34e151 100644 --- a/code/client/cl_console.c +++ b/code/client/cl_console.c @@ -178,7 +178,9 @@ void Con_Dump_f (void) int l, x, i; short *line; fileHandle_t f; - char buffer[1024]; + int bufferlen; + char *buffer; + char filename[MAX_QPATH]; if (Cmd_Argc() != 2) { @@ -186,12 +188,15 @@ void Con_Dump_f (void) return; } - Com_Printf ("Dumped console text to %s.\n", Cmd_Argv(1) ); + Q_strncpyz( filename, Cmd_Argv( 1 ), sizeof( filename ) ); + COM_DefaultExtension( filename, sizeof( filename ), ".txt" ); - f = FS_FOpenFileWrite( Cmd_Argv( 1 ) ); + Com_Printf ("Dumped console text to %s.\n", filename ); + + f = FS_FOpenFileWrite( filename ); if (!f) { - Com_Printf ("ERROR: couldn't open.\n"); + Com_Printf ("ERROR: couldn't open %s.\n", filename); return; } @@ -206,8 +211,16 @@ void Con_Dump_f (void) break; } +#ifdef _WIN32 + bufferlen = con.linewidth + 3 * sizeof ( char ); +#else + bufferlen = con.linewidth + 2 * sizeof ( char ); +#endif + + buffer = Hunk_AllocateTempMemory( bufferlen ); + // write the remaining lines - buffer[con.linewidth] = 0; + buffer[bufferlen-1] = 0; for ( ; l <= con.current ; l++) { line = con.text + (l%con.totallines)*con.linewidth; @@ -220,10 +233,15 @@ void Con_Dump_f (void) else break; } - strcat( buffer, "\n" ); +#ifdef _WIN32 + Q_strcat(buffer, bufferlen, "\r\n"); +#else + Q_strcat(buffer, bufferlen, "\n"); +#endif FS_Write(buffer, strlen(buffer), f); } + Hunk_FreeTempMemory( buffer ); FS_FCloseFile( f ); }