mirror of
https://github.com/YGGverse/xash3d-fwgs.git
synced 2025-01-23 05:14:15 +00:00
Prepend USE_SELECT and COLORIZE_CONSOLE with XASH_
This commit is contained in:
parent
362217935f
commit
ec41db7ef8
@ -19,11 +19,13 @@ GNU General Public License for more details.
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined( _WIN32 ) && !defined( XASH_MOBILE_PLATFORM )
|
#if !defined( _WIN32 ) && !defined( XASH_MOBILE_PLATFORM )
|
||||||
#define COLORIZE_CONSOLE
|
#define XASH_COLORIZE_CONSOLE
|
||||||
#define USE_SELECT
|
// use with caution, running engine in Qt Creator may cause a freeze in read() call
|
||||||
|
// I was never encountered this bug anywhere else, so still enable by default
|
||||||
|
#define XASH_USE_SELECT
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USE_SELECT
|
#ifdef XASH_USE_SELECT
|
||||||
// non-blocking console input
|
// non-blocking console input
|
||||||
#include <sys/select.h>
|
#include <sys/select.h>
|
||||||
#endif
|
#endif
|
||||||
@ -40,7 +42,7 @@ static LogData s_ld;
|
|||||||
|
|
||||||
char *Sys_Input( void )
|
char *Sys_Input( void )
|
||||||
{
|
{
|
||||||
#ifdef USE_SELECT
|
#ifdef XASH_USE_SELECT
|
||||||
{
|
{
|
||||||
fd_set rfds;
|
fd_set rfds;
|
||||||
static char line[1024];
|
static char line[1024];
|
||||||
@ -48,9 +50,9 @@ char *Sys_Input( void )
|
|||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
tv.tv_sec = 0;
|
tv.tv_sec = 0;
|
||||||
tv.tv_usec = 0;
|
tv.tv_usec = 0;
|
||||||
FD_ZERO(&rfds);
|
FD_ZERO( &rfds );
|
||||||
FD_SET(0, &rfds); // stdin
|
FD_SET( 0, &rfds); // stdin
|
||||||
while( select(1, &rfds, NULL, NULL, &tv ) > 0 )
|
while( select( 1, &rfds, NULL, NULL, &tv ) > 0 )
|
||||||
{
|
{
|
||||||
if( read( 0, &line[len], 1 ) != 1 )
|
if( read( 0, &line[len], 1 ) != 1 )
|
||||||
break;
|
break;
|
||||||
@ -163,7 +165,7 @@ void Sys_PrintLog( const char *pMsg )
|
|||||||
if( !lastchar || lastchar == '\n')
|
if( !lastchar || lastchar == '\n')
|
||||||
strftime( logtime, sizeof( logtime ), "[%H:%M:%S] ", crt_tm ); //short time
|
strftime( logtime, sizeof( logtime ), "[%H:%M:%S] ", crt_tm ); //short time
|
||||||
|
|
||||||
#ifdef COLORIZE_CONSOLE
|
#ifdef XASH_COLORIZE_CONSOLE
|
||||||
{
|
{
|
||||||
char colored[4096];
|
char colored[4096];
|
||||||
const char *msg = pMsg;
|
const char *msg = pMsg;
|
||||||
@ -293,4 +295,4 @@ void Con_Reportf( char *szFmt, ... )
|
|||||||
va_end( args );
|
va_end( args );
|
||||||
|
|
||||||
Sys_Print( buffer );
|
Sys_Print( buffer );
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user