q3map2 * colored warnings and errors in Windows console
This commit is contained in:
parent
968e210f2d
commit
0f65e67896
|
|
@ -226,6 +226,32 @@ void xml_Winding( char *msg, vec3_t p[], int numpoints, qboolean die ){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void set_console_colour_for_flag( int flag ){
|
||||||
|
#ifdef WIN32
|
||||||
|
static int curFlag = SYS_STD;
|
||||||
|
static qboolean ok = qtrue;
|
||||||
|
static qboolean initialized = qfalse;
|
||||||
|
static HANDLE hConsole;
|
||||||
|
static WORD colour_saved;
|
||||||
|
if( !ok )
|
||||||
|
return;
|
||||||
|
if( !initialized ){
|
||||||
|
hConsole = GetStdHandle( STD_OUTPUT_HANDLE );
|
||||||
|
CONSOLE_SCREEN_BUFFER_INFO consoleInfo;
|
||||||
|
if( hConsole == INVALID_HANDLE_VALUE || !GetConsoleScreenBufferInfo( hConsole, &consoleInfo ) ){
|
||||||
|
ok = qfalse;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
colour_saved = consoleInfo.wAttributes;
|
||||||
|
initialized = qtrue;
|
||||||
|
}
|
||||||
|
if( curFlag != flag ){
|
||||||
|
curFlag = flag;
|
||||||
|
SetConsoleTextAttribute( hConsole, flag == SYS_WRN ? FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY : flag == SYS_ERR ? FOREGROUND_RED | FOREGROUND_INTENSITY : colour_saved );
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
// in include
|
// in include
|
||||||
#include "stream_version.h"
|
#include "stream_version.h"
|
||||||
|
|
||||||
|
|
@ -252,6 +278,7 @@ void Broadcast_Shutdown(){
|
||||||
Net_Disconnect( brdcst_socket );
|
Net_Disconnect( brdcst_socket );
|
||||||
brdcst_socket = NULL;
|
brdcst_socket = NULL;
|
||||||
}
|
}
|
||||||
|
set_console_colour_for_flag( SYS_STD ); //restore default on exit
|
||||||
}
|
}
|
||||||
|
|
||||||
#define MAX_MESEGE MAX_NETMESSAGE / 2
|
#define MAX_MESEGE MAX_NETMESSAGE / 2
|
||||||
|
|
@ -306,6 +333,7 @@ void xml_message_push( int flag, const char* characters, size_t length ){
|
||||||
void FPrintf( int flag, char *buf ){
|
void FPrintf( int flag, char *buf ){
|
||||||
static qboolean bGotXML = qfalse;
|
static qboolean bGotXML = qfalse;
|
||||||
|
|
||||||
|
set_console_colour_for_flag( flag );
|
||||||
printf( "%s", buf );
|
printf( "%s", buf );
|
||||||
|
|
||||||
// the following part is XML stuff only.. but maybe we don't want that message to go down the XML pipe?
|
// the following part is XML stuff only.. but maybe we don't want that message to go down the XML pipe?
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user