* Add con_log.c to log all console output

* Add con_passive.c to cut down on #ifdef DEDICATED in sys_main.c
* Add Sys_ErrorDialog to report ERR_FATALs to the user
  + On Windows use a MessageBox and offer to copy the console log to the
    clipboard
  + On everything else print to the terminal and save the console log as
    crashlog.txt
This commit is contained in:
Tim Angus 2007-11-30 18:32:52 +00:00
parent ccc66aadff
commit 3cde9bf0dc
10 changed files with 340 additions and 95 deletions

View file

@ -19,6 +19,11 @@ along with Quake III Arena source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#include "../qcommon/q_shared.h"
#include "../qcommon/qcommon.h"
#include "sys_local.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
@ -30,9 +35,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include <pwd.h>
#include <libgen.h>
#include "../qcommon/q_shared.h"
#include "../qcommon/qcommon.h"
// Used to determine where to store user-specific files
static char homePath[ MAX_OSPATH ] = { 0 };
@ -476,3 +478,33 @@ void Sys_Sleep( int msec )
select((fileno(stdin) + 1), &fdset, NULL, NULL, &timeout);
}
}
/*
==============
Sys_ErrorDialog
Display an error message
==============
*/
void Sys_ErrorDialog( const char *error )
{
char buffer[ 1024 ];
unsigned int size;
fileHandle_t f;
const char *fileName = "crashlog.txt";
Sys_Print( va( "%s\n", error ) );
// Write console log to file
f = FS_FOpenFileWrite( fileName );
if( !f )
{
Com_Printf( "ERROR: couldn't open %s\n", fileName );
return;
}
while( ( size = CON_LogRead( buffer, sizeof( buffer ) ) ) > 0 )
FS_Write( buffer, size, f );
FS_FCloseFile( f );
}