diff --git a/radiant/console.cpp b/radiant/console.cpp index df2f3031..d8f8a67f 100644 --- a/radiant/console.cpp +++ b/radiant/console.cpp @@ -28,7 +28,6 @@ #include "gtkutil/menu.h" #include "gtkutil/nonmodal.h" #include "stream/stringstream.h" -#include "convert.h" #include "version.h" #include "aboutmsg.h" @@ -190,14 +189,7 @@ std::size_t Sys_Print( int level, const char* buf, std::size_t length ){ { GtkTextBufferOutputStream textBuffer( g_console ); - if ( !globalCharacterSet().isUTF8() ) { - BufferedTextOutputStream buffered( textBuffer ); - buffered << StringRange( buf, length ); - } - else - { - textBuffer << StringRange( buf, length ); - } + textBuffer << StringRange( buf, length ); } if ( contains_newline ) { diff --git a/radiant/watchbsp.cpp b/radiant/watchbsp.cpp index 0cb7fa2c..6b181eda 100644 --- a/radiant/watchbsp.cpp +++ b/radiant/watchbsp.cpp @@ -51,31 +51,6 @@ #include "mainframe.h" #include "sockets.h" #include "timer.h" - -void message_flush( message_info_t* self ){ - Sys_Print( self->msg_level, self->m_buffer, self->m_length ); - self->m_length = 0; -} - -void message_print( message_info_t* self, const char* characters, std::size_t length ){ - const char* end = characters + length; - while ( characters != end ) - { - std::size_t space = std::size( self->m_buffer ) - 1 - self->m_length; - if ( space == 0 ) { - message_flush( self ); - } - else - { - std::size_t size = std::min( space, std::size_t( end - characters ) ); - memcpy( self->m_buffer + self->m_length, characters, size ); - self->m_length += size; - characters += size; - } - } -} - - #include "xmlstuff.h" class CWatchBSP @@ -352,14 +327,12 @@ static void saxStartElement( message_info_t *data, const xmlChar *name, const xm // old q3map don't send a version attribute // the ones we support .. send Q3MAP_STREAM_VERSION if ( !attrs[0] || !attrs[1] || ( strcmp( reinterpret_cast( attrs[0] ), "version" ) != 0 ) ) { - message_flush( data ); globalErrorStream() << "No stream version given in the feedback stream, this is an old q3map version.\n" "Please turn off monitored compiling if you still wish to use this q3map executable\n"; abortStream( data ); return; } else if ( strcmp( reinterpret_cast( attrs[1] ), Q3MAP_STREAM_VERSION ) != 0 ) { - message_flush( data ); globalErrorStream() << "This version of Radiant reads version " Q3MAP_STREAM_VERSION " debug streams, I got an incoming connection with version " << reinterpret_cast( attrs[1] ) << "\n" "Please make sure your versions of Radiant and q3map are matching.\n"; @@ -371,7 +344,6 @@ static void saxStartElement( message_info_t *data, const xmlChar *name, const xm else if ( strcmp( reinterpret_cast( name ), "message" ) == 0 ) { int msg_level = atoi( reinterpret_cast( attrs[1] ) ); if ( msg_level != data->msg_level ) { - message_flush( data ); data->msg_level = msg_level; } } @@ -382,21 +354,18 @@ static void saxStartElement( message_info_t *data, const xmlChar *name, const xm data->pGeometry->saxStartElement( data, name, attrs ); } else if ( strcmp( reinterpret_cast( name ), "select" ) == 0 ) { - message_flush( data ); CSelectMsg *pSelect = new CSelectMsg(); data->geometry_depth = data->recurse; data->pGeometry = pSelect; data->pGeometry->saxStartElement( data, name, attrs ); } else if ( strcmp( reinterpret_cast( name ), "pointmsg" ) == 0 ) { - message_flush( data ); CPointMsg *pPoint = new CPointMsg(); data->geometry_depth = data->recurse; data->pGeometry = pPoint; data->pGeometry->saxStartElement( data, name, attrs ); } else if ( strcmp( reinterpret_cast( name ), "windingmsg" ) == 0 ) { - message_flush( data ); CWindingMsg *pWinding = new CWindingMsg(); data->geometry_depth = data->recurse; data->pGeometry = pWinding; @@ -404,7 +373,6 @@ static void saxStartElement( message_info_t *data, const xmlChar *name, const xm } else { - message_flush( data ); globalWarningStream() << "Warning: ignoring unrecognized node in XML stream (" << reinterpret_cast( name ) << ")\n"; // we don't recognize this node, jump over it // (NOTE: the ignore mechanism is a bit screwed, only works when starting an ignore at the highest level) @@ -435,7 +403,6 @@ static void saxEndElement( message_info_t *data, const xmlChar *name ){ } } if ( data->recurse == data->stop_depth ) { - message_flush( data ); #ifdef _DEBUG globalWarningStream() << "Received error msg .. shutting down..\n"; #endif @@ -464,7 +431,7 @@ public: { if ( m_data->ignore_depth == 0 ) { // output the message using the level - message_print( m_data, buffer, length ); + Sys_Print( m_data->msg_level, buffer, length ); // if this message has error level flag, we mark the depth to stop the compilation when we get out // we don't set the msg level if we don't stop on leak if ( m_data->msg_level == 3 ) { @@ -702,7 +669,6 @@ void CWatchBSP::RoutineProcessing(){ } else { - message_flush( &m_message_info ); // error or connection closed/reset // NOTE: if we get an error down the XML stream we don't reach here Net_Disconnect( m_pInSocket ); diff --git a/radiant/xmlstuff.h b/radiant/xmlstuff.h index 99ca6c79..28f5b739 100644 --- a/radiant/xmlstuff.h +++ b/radiant/xmlstuff.h @@ -56,9 +56,6 @@ struct message_info_t int stop_depth; // the depth we need to stop at the end int geometry_depth; // are we parsing some geometry information (i.e. do we forward the SAX calls?) ISAXHandler* pGeometry; // the handler - - char m_buffer[1024]; - std::size_t m_length; }; class IGL2DWindow; diff --git a/tools/quake3/common/inout.cpp b/tools/quake3/common/inout.cpp index ae6c6075..fbfb3dd5 100644 --- a/tools/quake3/common/inout.cpp +++ b/tools/quake3/common/inout.cpp @@ -32,6 +32,7 @@ #include #include #include "generic/vector.h" +#include "timer.h" #ifdef WIN32 #include @@ -45,8 +46,8 @@ // utf8 conversion #include -socket_t *brdcst_socket; -netmessage_t msg; +static socket_t *brdcst_socket; +static netmessage_t msg; bool verbose = false; @@ -54,7 +55,7 @@ bool verbose = false; // is streamed through the network to Radiant // possibly written to disk at the end of the run //++timo FIXME: need to be global, required when creating nodes? -xmlDocPtr doc; +static xmlDocPtr doc; // some useful stuff xmlNodePtr xml_NodeForVec( const Vector3& v ){ @@ -67,7 +68,7 @@ xmlNodePtr xml_NodeForVec( const Vector3& v ){ return ret; } -void xml_message_flush(); +static void xml_message_flush(); // send a node down the stream, add it to the document void xml_SendNode( xmlNodePtr node ){ @@ -227,7 +228,7 @@ void xml_Winding( const char *msg, const Vector3 p[], int numpoints, bool die ){ } } -void set_console_colour_for_flag( int flag ){ +static void set_console_colour_for_flag( int flag ){ #ifdef WIN32 static int curFlag = SYS_STD; static bool ok = true; @@ -285,11 +286,12 @@ void Broadcast_Shutdown(){ } #define MAX_MESEGE MAX_NETMESSAGE / 2 -char mesege[MAX_MESEGE]; -size_t mesege_len = 0; -int mesege_flag = SYS_STD; +static char mesege[MAX_MESEGE]; +static size_t mesege_len = 0; +static int mesege_flag = SYS_STD; +static Timer mesege_send_timer; -void xml_message_flush(){ +static void xml_message_flush(){ if( mesege_len == 0 ) return; xmlNodePtr node; @@ -307,9 +309,11 @@ void xml_message_flush(){ xmlSetProp( node, (const xmlChar*)"level", (const xmlChar *)level ); xml_SendNode( node ); + + mesege_send_timer.start(); } -void xml_message_push( int flag, const char* characters, size_t length ){ +static void xml_message_push( int flag, const char* characters, size_t length ){ if( flag != mesege_flag ){ xml_message_flush(); mesege_flag = flag; @@ -318,22 +322,26 @@ void xml_message_push( int flag, const char* characters, size_t length ){ const char* end = characters + length; while ( characters != end ) { - size_t space = MAX_MESEGE - 1 - mesege_len; + const size_t space = MAX_MESEGE - 1 - mesege_len; if ( space == 0 ) { xml_message_flush(); } else { - size_t size = std::min( space, static_cast( end - characters ) ); + const size_t size = std::min( space, static_cast( end - characters ) ); memcpy( mesege + mesege_len, characters, size ); mesege_len += size; characters += size; } } + + if( mesege_send_timer.elapsed_msec() + 1000 * mesege_len / MAX_MESEGE > 2000 ){ // force send if >1-2 seconds has passed + xml_message_flush(); + } } // all output ends up through here -void FPrintf( int flag, char *buf ){ +static void FPrintf( int flag, char *buf ){ static bool bGotXML = false; set_console_colour_for_flag( flag & ~( SYS_NOXMLflag | SYS_VRBflag ) );