* 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

@ -525,3 +525,43 @@ void Sys_Sleep( int msec )
WaitForSingleObject( GetStdHandle( STD_INPUT_HANDLE ), msec );
}
/*
==============
Sys_ErrorDialog
Display an error message
==============
*/
void Sys_ErrorDialog( const char *error )
{
if( MessageBox( NULL, va( "%s. Copy console log to clipboard?", error ),
NULL, MB_YESNO|MB_ICONERROR ) == IDYES )
{
HGLOBAL memoryHandle;
char *clipMemory;
memoryHandle = GlobalAlloc( GMEM_MOVEABLE|GMEM_DDESHARE, CON_LogSize( ) + 1 );
clipMemory = (char *)GlobalLock( memoryHandle );
if( clipMemory )
{
char *p = clipMemory;
char buffer[ 1024 ];
unsigned int size;
while( ( size = CON_LogRead( buffer, sizeof( buffer ) ) ) > 0 )
{
Com_Memcpy( p, buffer, size );
p += size;
}
*p = '\0';
if( OpenClipboard( NULL ) && EmptyClipboard( ) )
SetClipboardData( CF_TEXT, memoryHandle );
GlobalUnlock( clipMemory );
CloseClipboard( );
}
}
}