Ejemplo n.º 1
0
void Com_Error(bool exit, const char* format, ...)
{
	static char buffer[32768] = { 0 };

	va_list va;
	va_start(va, format);

	//vprintf(format, va);
	_vsnprintf(buffer, sizeof(buffer), format, va);
	va_end(va);

	if (console){
		Sys_Print("^1ERROR: ");
		Sys_Print(buffer);
		Sys_Print("^7\n");
	}
	else {
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 14);
		printf("ERROR: %s\n", buffer);
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 7);
	}

	if (exit)
	{
		if (IsDebuggerPresent())
		{
			DebugBreak();
		}
		TerminateProcess(GetCurrentProcess(), -1);
	}
}
Ejemplo n.º 2
0
/*
================
MsgDev

formatted developer message
================
*/
void MsgDev( int level, const char *pMsg, ... )
{
	va_list	argptr;
	char	text[8192];

	if( host.developer < level ) return;

	va_start( argptr, pMsg );
	Q_vsnprintf( text, sizeof( text ), pMsg, argptr );
	va_end( argptr );

	switch( level )
	{
	case D_WARN:
		Sys_Print( va( "^3Warning:^7 %s", text ));
		break;
	case D_ERROR:
		Sys_Print( va( "^1Error:^7 %s", text ));
		break;
	case D_INFO:
	case D_NOTE:
	case D_AICONSOLE:
		Sys_Print( text );
		break;
	}
}
Ejemplo n.º 3
0
/*
===============
Cmd_Echo_f

Just prints the rest of the line to the console
===============
*/
void Cmd_Echo_f( void )
{
	int	i;
	
	for( i = 1; i < Cmd_Argc(); i++ )
		Sys_Print( Cmd_Argv( i ));
	Sys_Print( "\n" );
}
Ejemplo n.º 4
0
/*
==============
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";

	// Shut down now so that the curses console doesn't clear the screen when it's really shut down
	CON_Shutdown( );

	Sys_Print( va( "%s\n", error ) );

	// Write console log to file and to stderr
	f = FS_SV_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 );
		fputs( buffer, stderr );
	}

	FS_FCloseFile( f );
}
/*
=============
Sys_Error

A raw string should NEVER be passed as fmt, because of "%f" type crashers.
=============
*/
__cdecl void QDECL Sys_Error( const char *fmt, ... ) {

	FILE * fdout;
	char* fileout = "sys_error.txt";
	va_list		argptr;
	char		msg[MAXPRINTMSG];
	char		buffer[MAXPRINTMSG];

	va_start (argptr,fmt);
	Q_vsnprintf (msg, sizeof(msg), fmt, argptr);
	va_end (argptr);

	Com_sprintf(buffer, sizeof(buffer), "\nSys_Error: %s\n", msg);

	//Print the error to our console
	Sys_Print( buffer );

	//Try to write the error into a file
	fdout=fopen(fileout, "w");
	if(fdout){
		fwrite(buffer, strlen(buffer), 1 ,fdout);
		fclose(fdout);
	}

	Sys_WaitForErrorConfirmation( msg );

	Sys_Exit( 1 ); // bk010104 - use single exit point.
}
Ejemplo n.º 6
0
static void Win_PrintMatches(const char *s)
{
	if(!Q_stricmpn(s, win_currentMatch, win_acLength))
	{
		Sys_Print(va("  ^9%s^0\n", s));
	}
}
Ejemplo n.º 7
0
/*
================
Sys_Break

same as Error
================
*/
void Sys_Break( const char *error, ... )
{
	va_list		argptr;
	char		text[MAX_SYSPATH];

	if( host.state == HOST_ERR_FATAL )
		return; // don't multiple executes

	error_on_exit = true;	
	host.state = HOST_ERR_FATAL;         
	va_start( argptr, error );
	Q_vsprintf( text, error, argptr );
	va_end( argptr );

	if( host.type == HOST_NORMAL )
	{
		if( host.hWnd ) ShowWindow( host.hWnd, SW_HIDE );
		VID_RestoreGamma();
	}

	if( host.type != HOST_NORMAL || host.developer > 0 )
	{
		Con_ShowConsole( true );
		Con_DisableInput();	// disable input line for dedicated server
		Sys_Print( text );
		Sys_WaitForQuit();
	}
	else
	{
		Con_ShowConsole( false );
		MSGBOX( text );
	}
	Sys_Quit();
}
Ejemplo n.º 8
0
// ydnar: to display cvar values
static void Win_PrintCvarMatches(const char *s)
{
	if(!Q_stricmpn(s, win_currentMatch, win_acLength))
	{
		Sys_Print(va("  ^9%s = ^5%s^0\n", s, Cvar_VariableString(s)));
	}
}
Ejemplo n.º 9
0
LONG WINAPI InputLineWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	char inputBuffer[1024];

	switch ( uMsg )
	{
	case WM_KILLFOCUS:
		if ( ( HWND ) wParam == s_wcd.hWnd ||
			 ( HWND ) wParam == s_wcd.hwndErrorBox )
		{
			SetFocus( hWnd );
			return 0;
		}
		break;

	case WM_CHAR:
		if ( wParam == 13 )
		{
			GetWindowText( s_wcd.hwndInputLine, inputBuffer, sizeof( inputBuffer ) );
			strncat( s_wcd.consoleText, inputBuffer, sizeof( s_wcd.consoleText ) - strlen( s_wcd.consoleText ) - 5 );
			strcat( s_wcd.consoleText, "\n" );
			SetWindowText( s_wcd.hwndInputLine, "" );

			Sys_Print( va( "]%s\n", inputBuffer ) );

			return 0;
		}
	}

	return CallWindowProc( s_wcd.SysInputLineWndProc, hWnd, uMsg, wParam, lParam );
}
Ejemplo n.º 10
0
/*
=============
Com_Printf

Both client and server can use this, and it will output
to the apropriate place.

A raw string should NEVER be passed as fmt, because of "%f" type crashers.
=============
*/
void QDECL Com_Printf( const char *fmt, ... ) {
	va_list		argptr;
	char		msg[MAXPRINTMSG];

	va_start (argptr,fmt);
	vsprintf (msg,fmt,argptr);
	va_end (argptr);

	if ( rd_buffer ) {
		if ((strlen (msg) + strlen(rd_buffer)) > (rd_buffersize - 1)) {
			rd_flush(rd_buffer);
			*rd_buffer = 0;
		}
		Q_strcat(rd_buffer, rd_buffersize, msg);
		rd_flush(rd_buffer);			
		*rd_buffer = 0;
		return;
	}

	// echo to console if we're not a dedicated server
	if ( com_dedicated && !com_dedicated->integer ) {
		CL_ConsolePrint( msg );
	}

	// echo to dedicated console and early console
	Sys_Print( msg );

	// logfile
#ifndef _XBOX
	if ( com_logfile && com_logfile->integer ) {
		if ( !logfile && FS_Initialized() ) {
			struct tm *newtime;
			time_t aclock;

			time( &aclock );
			newtime = localtime( &aclock );

			logfile = FS_FOpenFileWrite( "qconsole.log" );
			Com_Printf( "logfile opened on %s\n", asctime( newtime ) );
			if ( com_logfile->integer > 1 ) {
				// force it to not buffer so we get valid
				// data even if we are crashing
				FS_ForceFlush(logfile);
			}
		}
		if ( logfile && FS_Initialized()) {
			FS_Write(msg, strlen(msg), logfile);
		}
	}
#endif

#if defined(_WIN32) && defined(_DEBUG) && !defined(_XBOX)
	if ( *msg )
	{
		OutputDebugString ( Q_CleanStr(msg) );
		OutputDebugString ("\n");
	}
#endif
}
Ejemplo n.º 11
0
/**
 * @brief Displays an error message and writes the error into crashlog.txt
 * @param[in] error Error String
 */
void Sys_ErrorDialog(const char *error)
{
	char         buffer[1024];
	unsigned int size;
	int          f         = -1;
	const char   *homepath = Cvar_VariableString("fs_homepath");
	const char   *gamedir  = Cvar_VariableString("fs_gamedir");
	const char   *fileName = "crashlog.txt";
	char         *dirpath  = FS_BuildOSPath(homepath, gamedir, "");
	char         *ospath   = FS_BuildOSPath(homepath, gamedir, fileName);

	Sys_Print(va("%s\n", error));

#ifndef DEDICATED
	// We may have grabbed input devices. Need to release.
	if (SDL_WasInit(SDL_INIT_VIDEO))
	{
		SDL_WM_GrabInput(SDL_GRAB_OFF);
	}

	Sys_Dialog(DT_ERROR, va("%s\nSee \"%s\" for details.\n", error, ospath), "Error");
#endif

	// Make sure the write path for the crashlog exists...
	// check homepath
	if (!Sys_Mkdir(homepath))
	{
		Com_Printf("ERROR: couldn't create path '%s' to write file '%s'.\n", homepath, ospath);
		return;
	}
	// check gamedir (inside homepath)
	if (!Sys_Mkdir(dirpath))
	{
		Com_Printf("ERROR: couldn't create path '%s' to write file '%s'.\n", dirpath, ospath);
		return;
	}

	// We might be crashing because we maxed out the Quake MAX_FILE_HANDLES,
	// which will come through here, so we don't want to recurse forever by
	// calling FS_FOpenFileWrite()...use the Unix system APIs instead.
	f = open(ospath, O_CREAT | O_TRUNC | O_WRONLY, 0640);
	if (f == -1)
	{
		Com_Printf("ERROR: couldn't open '%s'\n", fileName);
		return;
	}

	// We're crashing, so we don't care much if write() or close() fails.
	while ((size = CON_LogRead(buffer, sizeof(buffer))) > 0)
	{
		if (write(f, buffer, size) != size)
		{
			Com_Printf("ERROR: couldn't fully write to '%s'\n", fileName);
			break;
		}
	}

	close(f);
}
Ejemplo n.º 12
0
/*
=================
Sys_Error
=================
*/
void Sys_Error( const char *error, ... ) {
	va_list argptr;
	char    string[4096];
#if defined (_WIN32) && !defined (_DEBUG)
	MSG		msg;
#endif

	va_start (argptr,error);
	idStr::vsnPrintf (string, sizeof(string), error, argptr);
	va_end (argptr);

#if defined (_WIN32) && !defined (_DEBUG)
	Conbuf_AppendText( string );
	Conbuf_AppendText( "\n" );
#else
	// Print text in the console window/box
	Sys_Print( string );
	Sys_Print( "\n" );
#endif

#if defined (_WIN32) && !defined (_DEBUG)
	Sys_SetErrorText( string );
	Sys_ShowConsole( 1, qtrue );

	timeEndPeriod( 1 );

	IN_Shutdown();

	// wait for the user to quit
	while ( 1 ) {
		if ( !GetMessage( &msg, NULL, 0, 0 ) ) {
			Com_Quit_f();
		}
		TranslateMessage( &msg );
		DispatchMessage( &msg );
	}

	Sys_DestroyConsole();
#endif

	CL_Shutdown( );
	Sys_ErrorDialog( string );

	Sys_Exit( 1 );
}
Ejemplo n.º 13
0
/*
================
Msg

formatted message
================
*/
void Msg( const char *pMsg, ... )
{
	va_list	argptr;
	char	text[8192];
	
	va_start( argptr, pMsg );
	Q_vsnprintf( text, sizeof( text ), pMsg, argptr );
	va_end( argptr );

	Sys_Print( text );
}
Ejemplo n.º 14
0
__cdecl void Com_PrintMessage( int dumbIWvar, char *msg, msgtype_t type) {

	//secures calls to Com_PrintMessage from recursion while redirect printing
	static qboolean lock = qfalse;

	if(dumbIWvar == 6) return;

	int msglen = strlen(msg);

	if(type != MSG_NORDPRINT && !lock)
	{
	
		Sys_EnterCriticalSection(CRIT_REDIRECTPRINT);

		if ( !lock) {

			lock = qtrue;
			Com_PrintRedirect(msg, msglen);
			lock = qfalse;

			if ( rd_buffer ) {
				if(!rd_flush){
					Sys_LeaveCriticalSection(CRIT_REDIRECTPRINT);
					return;
				}
				if ((msglen + strlen(rd_buffer)) > (rd_buffersize - 1)) {

					lock = qtrue;
					rd_flush(rd_buffer, qfalse);
					lock = qfalse;

					*rd_buffer = 0;
				}
				Q_strcat(rd_buffer, rd_buffersize, msg);
				// TTimo nooo .. that would defeat the purpose
				//rd_flush(rd_buffer);
				//*rd_buffer = 0;
				Sys_LeaveCriticalSection(CRIT_REDIRECTPRINT);
				return;
			}
		}
		
		Sys_LeaveCriticalSection(CRIT_REDIRECTPRINT);
	
	}

	
	// echo to dedicated console and early console
	Sys_Print( msg );

	// logfile
	Com_PrintLogfile( msg );

}
Ejemplo n.º 15
0
/*
===============
Cmd_Echo_f

Just prints the rest of the line to the console
===============
*/
void Cmd_Echo_f( void )
{
	int	i;
	static char buf[1024];
	for( i = 1; i < Cmd_Argc(); i++ )
	{
		Q_strncat( buf, Cmd_Argv( i ), 1024 );
		Q_strncat( buf, " ", 1024 );
	}
	Q_strncat( buf, "\n", 1024 );
	Sys_Print( buf );
}
Ejemplo n.º 16
0
void Com_Debug_(const char* format, ...)
{
	static char buffer[32768] = { 0 };

	va_list va;
	va_start(va, format);

	//vprintf(format, va);
	_vsnprintf(buffer, sizeof(buffer), format, va);
	va_end(va);

	if (console){
		Sys_Print("^3");
		Sys_Print(buffer);
		Sys_Print("^7");
	}
	else {
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 14);
		printf(buffer);
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 7);
	}
}
Ejemplo n.º 17
0
int main(int argc, char **argv)
{
	int i;
	byte *mvd_data = NULL;
	long mvd_len = 0;

	Sys_InitDoubleTime();
	LogVarHashTable_Init();

	if (!Cmdline_Parse(argc, argv))
	{
		ShowHelp(argv[0]);
		return 1;
	}

	if (!Log_ParseOutputTemplates(&logger, cmdargs.template_file) && !Log_ParseOutputTemplates(&logger, "template.dat"))
	{
		Sys_PrintError("Failed to load template file.\n");
		return 1;
	}

	if (!LoadFragFile(cmdargs.frag_file, false) && !LoadFragFile("fragfile.dat", false))
	{
		Sys_PrintError("Failed to load fragfile.dat\n");
		return 1;
	}

	for (i = 0; i < cmdargs.mvd_files_count; i++)
	{
		// Read the mvd demo file.
		if (!COM_ReadFile(cmdargs.mvd_files[i], &mvd_data, &mvd_len))
		{
			Sys_PrintError("Failed to read %s.\n", cmdargs.mvd_files[i]);
		}
		else
		{
			char *demopath = cmdargs.mvd_files[i];

			// Parse the demo.
			Sys_Print("Starting to parse %s\n", cmdargs.mvd_files[i]);
			MVD_Parser_StartParse(demopath, mvd_data, mvd_len);
		}

		Q_free(mvd_data);
	}

	Log_ClearLogger(&logger);
	CmdArgs_Clear();

	return 0;
}
Ejemplo n.º 18
0
void Sys_Error( const char *error, ... )
{
	va_list argptr;
	char    string[1024];

	va_start (argptr,error);
	vsnprintf (string, sizeof(string), error, argptr);
	va_end (argptr);

	//Sys_ErrorDialog( string );
	Sys_Print( string );

	Sys_Exit( 3 );
}
Ejemplo n.º 19
0
/*
=============
Con_Printf

=============
*/
void Con_Printf( char *szFmt, ... )
{
	static char	buffer[16384];	// must support > 1k messages
	va_list		args;

	if( host.developer <= 0 )
		return;

	va_start( args, szFmt );
	Q_vsnprintf( buffer, sizeof( buffer ), szFmt, args );
	va_end( args );

	Sys_Print( buffer );
}
Ejemplo n.º 20
0
/*
=============
Con_DPrintf

=============
*/
void Con_DPrintf( char *szFmt, ... )
{
	char	buffer[2048];	// must support > 1k messages
	va_list	args;

	if( host.developer < D_INFO )
		return;

	va_start( args, szFmt );
	Q_vsnprintf( buffer, 2048, szFmt, args );
	va_end( args );

	Sys_Print( buffer );
}
Ejemplo n.º 21
0
void Com_Printf(const char* format, ...)
{
	static char buffer[32768] = { 0 };

	va_list va;
	va_start(va, format);

	//vprintf(format, va);
	_vsnprintf(buffer, sizeof(buffer), format, va);
	va_end(va);

	if (console)
		Sys_Print(buffer);
	else
		printf(buffer);
}
Ejemplo n.º 22
0
void QDECL Com_PrintfAlways( const char *fmt, ... ) {
	va_list		argptr;
	char		msg[MAXPRINTMSG];

	va_start (argptr,fmt);
	vsprintf (msg,fmt,argptr);
	va_end (argptr);

#ifndef _XBOX
	if ( rd_buffer ) {
		if ((strlen (msg) + strlen(rd_buffer)) > (rd_buffersize - 1)) {
			rd_flush(rd_buffer);
			*rd_buffer = 0;
		}
		strcat (rd_buffer, msg);
		return;
	}
#endif

	CL_ConsolePrint( msg );

	// echo to dedicated console and early console
#ifndef FINAL_BUILD
	Sys_Print( msg );

#ifdef OUTPUT_TO_BUILD_WINDOW
	OutputDebugString(msg);
#endif
#endif

#ifndef _XBOX
	// logfile
	if ( com_logfile && com_logfile->integer ) {
		if ( !logfile ) {
			logfile = FS_FOpenFileWrite( "qconsole.log" );
			if ( com_logfile->integer > 1 ) {
				// force it to not buffer so we get valid
				// data even if we are crashing
				FS_ForceFlush(logfile);
			}
		}
		if ( logfile ) {
			FS_Write(msg, strlen(msg), logfile);
		}
	}
#endif
}
Ejemplo n.º 23
0
/*
================
Sys_Error

NOTE: we must prepare engine to shutdown
before call this
================
*/
void Sys_Error( const char *format, ... )
{
	va_list	argptr;
	char	text[MAX_SYSPATH];

	DEBUG_BREAK;

	if( host.state == HOST_ERR_FATAL )
		return; // don't execute more than once

	// make sure that console received last message
	if( host.change_game ) Sys_Sleep( 200 );

	error_on_exit = true;
	host.state = HOST_ERR_FATAL;	
	va_start( argptr, format );
	Q_vsprintf( text, format, argptr );
	va_end( argptr );

	SV_SysError( text );

	if( !Host_IsDedicated() )
	{
#ifdef XASH_SDL
		if( host.hWnd ) SDL_HideWindow( host.hWnd );
#endif
		VID_RestoreGamma();
	}

	if( host.developer > 0 )
	{
		Con_ShowConsole( true );
		Con_DisableInput();	// disable input line for dedicated server

		Sys_Print( text );	// print error message
		MSGBOX( text );
		Sys_WaitForQuit();
	}
	else
	{
		Con_ShowConsole( false );
		MSGBOX( text );
	}

	Sys_Quit();
}
Ejemplo n.º 24
0
/**
 * @brief Display an error message
 * @param[in] error Error String
 */
void Sys_ErrorDialog(const char *error)
{
	char         buffer[1024];
	unsigned int size;
	int          f         = -1;
	const char   *homepath = Cvar_VariableString("fs_homepath");
	const char   *gamedir  = Cvar_VariableString("fs_gamedir");
	const char   *fileName = "crashlog.txt";
	char         *ospath   = FS_BuildOSPath(homepath, gamedir, fileName);

	Sys_Print(va("%s\n", error));

#ifndef DEDICATED
	Sys_Dialog(DT_ERROR, va("%s\nSee \"%s\" for details.\n", error, ospath), "Error");
#endif

	// Make sure the write path for the crashlog exists...
	if (FS_CreatePath(ospath))
	{
		Com_Printf("ERROR: couldn't create path '%s' for crash log.\n", ospath);
		return;
	}

	// We might be crashing because we maxed out the Quake MAX_FILE_HANDLES,
	// which will come through here, so we don't want to recurse forever by
	// calling FS_FOpenFileWrite()...use the Unix system APIs instead.
	f = open(ospath, O_CREAT | O_TRUNC | O_WRONLY, 0640);
	if (f == -1)
	{
		Com_Printf("ERROR: couldn't open %s\n", fileName);
		return;
	}

	// We're crashing, so we don't care much if write() or close() fails.
	while ((size = CON_LogRead(buffer, sizeof(buffer))) > 0)
	{
		if (write(f, buffer, size) != size)
		{
			Com_Printf("ERROR: couldn't fully write to %s\n", fileName);
			break;
		}
	}

	close(f);
}
Ejemplo n.º 25
0
/*
=============
Com_Printf

Both client and server can use this, and it will output
to the apropriate place.

A raw string should NEVER be passed as fmt, because of "%f" type crashers.
=============
*/
void QDECL Com_Printf( const char *fmt, ... ) {
	va_list		argptr;
	char		msg[MAXPRINTMSG];

	va_start (argptr,fmt);
	Q_vsnprintf (msg, sizeof(msg), fmt, argptr);
	va_end (argptr);

	if ( rd_buffer ) {
		if ((strlen (msg) + strlen(rd_buffer)) > (unsigned)(rd_buffersize - 1)) {
			rd_flush(rd_buffer);
			*rd_buffer = 0;
		}
		Q_strcat (rd_buffer, strlen(rd_buffer), msg);
		return;
	}

	CL_ConsolePrint( msg );

	// Strip out color codes because these aren't needed in the log/viewlog or in the output window --eez
	Q_StripColor( msg );

	// echo to dedicated console and early console
	Sys_Print( msg );


#ifdef OUTPUT_TO_BUILD_WINDOW
	OutputDebugString(msg);
#endif

	// logfile
	if ( com_logfile && com_logfile->integer ) {
		if ( !logfile ) {
			logfile = FS_FOpenFileWrite( "qconsole.log" );
			if ( com_logfile->integer > 1 ) {
				// force it to not buffer so we get valid
				// data even if we are crashing
				FS_ForceFlush(logfile);
			}
		}
		if ( logfile ) {
			FS_Write(msg, strlen(msg), logfile);
		}
	}
}
Ejemplo n.º 26
0
/*
==============
Sys_ErrorDialog

Display an error message
==============
*/
void Sys_ErrorDialog( const char *error )
{
	char         buffer[ 1024 ];
	unsigned int size;
	int          f;
	const char   *fileName = "crashlog.txt";
	std::string ospath = FS::Path::Build(FS::GetHomePath(), fileName);

	Sys_Print( va( "%s\n", error ) );

#ifdef BUILD_CLIENT
	// We may have grabbed input devices. Need to release.
	if ( SDL_WasInit( SDL_INIT_VIDEO ) )
	{
		SDL_SetWindowGrab( (SDL_Window*) IN_GetWindow(), SDL_FALSE );
	}

	Sys_Dialog( DT_ERROR, va( "%s. See \"%s\" for details.", error, ospath.c_str() ), "Error" );
#endif

	// We might be crashing because we maxed out the Quake MAX_FILE_HANDLES,
	// which will come through here, so we don't want to recurse forever by
	// calling FS_FOpenFileWrite()...use the Unix system APIs instead.
	f = open( ospath.c_str(), O_CREAT | O_TRUNC | O_WRONLY, 0640 );

	if ( f == -1 )
	{
		Com_Printf( "ERROR: couldn't open %s\n", fileName );
		return;
	}

	// We're crashing, so we don't care much if write() or close() fails.
	while ( ( size = CON_LogRead( buffer, sizeof( buffer ) ) ) > 0 )
	{
		if ( write( f, buffer, size ) != size )
		{
			Com_Printf( "ERROR: couldn't fully write to %s\n", fileName );
			break;
		}
	}

	close( f );
}
Ejemplo n.º 27
0
void NORETURN QDECL Sys_Error( const char *error, ... )
{
	va_list argptr;
	char    string[1024];

	va_start (argptr,error);
	Q_vsnprintf (string, sizeof(string), error, argptr);
	va_end (argptr);

	Sys_Print( string );

	// Only print Sys_ErrorDialog for client binary. The dedicated
	// server binary is meant to be a command line program so you would
	// expect to see the error printed.
#if !defined(DEDICATED)
	Sys_ErrorDialog( string );
#endif

	Sys_Exit( 3 );
}
Ejemplo n.º 28
0
/*
================
Sys_Error

NOTE: we must prepare engine to shutdown
before call this
================
*/
void Sys_Error( const char *error, ... )
{
	va_list	argptr;
	char	text[MAX_SYSPATH];
         
	if( host.state == HOST_ERR_FATAL )
		return; // don't multiple executes

	// make sure what console received last message
	if( host.change_game ) Sys_Sleep( 200 );

	error_on_exit = true;
	host.state = HOST_ERR_FATAL;	
	va_start( argptr, error );
	Q_vsprintf( text, error, argptr );
	va_end( argptr );

	SV_SysError( text );

	if( host.type == HOST_NORMAL )
	{
		if( host.hWnd ) ShowWindow( host.hWnd, SW_HIDE );
		VID_RestoreGamma();
	}

	if( host.developer > 0 )
	{
		Con_ShowConsole( true );
		Con_DisableInput();	// disable input line for dedicated server
		Sys_Print( text );	// print error message
		Sys_WaitForQuit();
	}
	else
	{
		Con_ShowConsole( false );
		MSGBOX( text );
	}

	Sys_Quit();
}
Ejemplo n.º 29
0
/*
==============
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 );
}
Ejemplo n.º 30
0
/*
================
Sys_Break

same as Error
================
*/
void Sys_Break( const char *format, ... )
{
	va_list	argptr;
	char	text[MAX_SYSPATH];
	DEBUG_BREAK;
	if( host.state == HOST_ERR_FATAL )
		return; // don't multiple executes

	error_on_exit = true;	
	host.state = HOST_ERR_FATAL;         
	va_start( argptr, format );
	Q_vsprintf( text, format, argptr );
	va_end( argptr );

	if( !Host_IsDedicated() )
	{
#ifdef XASH_SDL
		if( host.hWnd ) SDL_HideWindow( host.hWnd );
#endif
		VID_RestoreGamma();
	}

	if( Host_IsDedicated() || host.developer > 0 )
	{
		Con_ShowConsole( true );
		Con_DisableInput();	// disable input line for dedicated server
		Sys_Print( text );
		MSGBOX( text );
		Sys_WaitForQuit();
	}
	else
	{
		Con_ShowConsole( false );
		MSGBOX( text );
	}

	Sys_Quit();
}