diff options
author | Tim Angus <tim@ngus.net> | 2007-09-15 15:51:40 +0000 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2007-09-15 15:51:40 +0000 |
commit | 864246cc6eb58a46b669505cf4fe0aa07c6d741e (patch) | |
tree | b6747737a78f8dc3b0bb32ce14ae1ce7f2588fdf | |
parent | 9b6e4553e45720183eee347fe0a8d03770ff4e6d (diff) |
* Merge of ioq3-r1183
+ Windows dedicated console
+ MSVC project
+ Makefile tweaks
-rw-r--r-- | Makefile | 12 | ||||
-rwxr-xr-x | misc/msvc/tremulous.sln | 21 | ||||
-rwxr-xr-x | misc/msvc/tremulous.vcproj | 65 | ||||
-rw-r--r-- | src/qcommon/net_ip.c | 36 | ||||
-rw-r--r-- | src/qcommon/qcommon.h | 1 | ||||
-rw-r--r-- | src/server/sv_main.c | 2 | ||||
-rw-r--r-- | src/sys/con_win32.c | 485 | ||||
-rw-r--r-- | src/sys/sys_local.h | 2 | ||||
-rw-r--r-- | src/sys/sys_main.c | 3 | ||||
-rw-r--r-- | src/sys/sys_unix.c | 28 | ||||
-rw-r--r-- | src/sys/sys_win32.c | 17 | ||||
-rw-r--r-- | src/tools/lcc/etc/lcc.c | 14 |
12 files changed, 433 insertions, 253 deletions
@@ -703,7 +703,9 @@ ifeq ($(USE_LOCAL_HEADERS),1) endif ifeq ($(GENERATE_DEPENDENCIES),1) - BASE_CFLAGS += -MMD + DEPEND_CFLAGS = -MMD +else + DEPEND_CFLAGS = endif ifeq ($(USE_SVN),1) @@ -767,13 +769,15 @@ default: release all: debug release debug: - @$(MAKE) targets B=$(BD) CFLAGS="$(CFLAGS) $(DEBUG_CFLAGS)" V=$(V) + @$(MAKE) targets B=$(BD) CFLAGS="$(CFLAGS) $(DEPEND_CFLAGS) \ + $(DEBUG_CFLAGS)" V=$(V) ifeq ($(BUILD_MASTER_SERVER),1) $(MAKE) -C $(MASTERDIR) debug endif release: - @$(MAKE) targets B=$(BR) CFLAGS="$(CFLAGS) $(RELEASE_CFLAGS)" V=$(V) + @$(MAKE) targets B=$(BR) CFLAGS="$(CFLAGS) $(DEPEND_CFLAGS) \ + $(RELEASE_CFLAGS)" V=$(V) ifeq ($(BUILD_MASTER_SERVER),1) $(MAKE) -C $(MASTERDIR) release endif @@ -826,7 +830,7 @@ makedirs: # QVM BUILD TOOLS ############################################################################# -TOOLS_CFLAGS = -O2 -Wall -Werror -fno-strict-aliasing -MMD \ +TOOLS_CFLAGS = -O2 -Wall -fno-strict-aliasing -MMD \ -DTEMPDIR=\"$(TEMPDIR)\" -DSYSTEM=\"\" \ -I$(Q3LCCSRCDIR) \ -I$(LBURGDIR) diff --git a/misc/msvc/tremulous.sln b/misc/msvc/tremulous.sln new file mode 100755 index 00000000..8f52efc6 --- /dev/null +++ b/misc/msvc/tremulous.sln @@ -0,0 +1,21 @@ +¿
+Microsoft Visual Studio Solution File, Format Version 9.00
+# Visual C++ Express 2005
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tremulous", "tremulous.vcproj", "{0D5316E4-B20F-4E09-8989-3B9064358F0C}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Release|Win32 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {0D5316E4-B20F-4E09-8989-3B9064358F0C}.Debug|Win32.ActiveCfg = Debug|Win32
+ {0D5316E4-B20F-4E09-8989-3B9064358F0C}.Debug|Win32.Build.0 = Debug|Win32
+ {0D5316E4-B20F-4E09-8989-3B9064358F0C}.Release|Win32.ActiveCfg = Release|Win32
+ {0D5316E4-B20F-4E09-8989-3B9064358F0C}.Release|Win32.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
+
diff --git a/misc/msvc/tremulous.vcproj b/misc/msvc/tremulous.vcproj new file mode 100755 index 00000000..8b848208 --- /dev/null +++ b/misc/msvc/tremulous.vcproj @@ -0,0 +1,65 @@ +<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="8.00"
+ Name="tremulous"
+ ProjectGUID="{0D5316E4-B20F-4E09-8989-3B9064358F0C}"
+ RootNamespace="tremulous"
+ Keyword="MakeFileProj"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="../../build/$(ConfigurationName)-Win32-x86"
+ IntermediateDirectory="../../build/$(ConfigurationName)-Win32-x86"
+ ConfigurationType="0"
+ >
+ <Tool
+ Name="VCNMakeTool"
+ BuildCommandLine="make -C ../../ debug"
+ ReBuildCommandLine="make -C ../../ clean-debug debug"
+ CleanCommandLine="make -C ../../ clean-debug"
+ Output="$(Outdir)/ioquake3.x86.exe"
+ PreprocessorDefinitions=""
+ IncludeSearchPath=""
+ ForcedIncludes=""
+ AssemblySearchPath=""
+ ForcedUsingAssemblies=""
+ CompileAsManaged=""
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="../../build/$(ConfigurationName)-Win32-x86"
+ IntermediateDirectory="../../build/$(ConfigurationName)-Win32-x86"
+ ConfigurationType="0"
+ >
+ <Tool
+ Name="VCNMakeTool"
+ BuildCommandLine="make -C ../../ release"
+ ReBuildCommandLine="make -C ../../ clean-release release"
+ CleanCommandLine="make -C ../../ clean-release"
+ Output="$(Outdir)/ioquake3.x86.exe"
+ PreprocessorDefinitions=""
+ IncludeSearchPath=""
+ ForcedIncludes=""
+ AssemblySearchPath=""
+ ForcedUsingAssemblies=""
+ CompileAsManaged=""
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/src/qcommon/net_ip.c b/src/qcommon/net_ip.c index 47ccda73..258a6cba 100644 --- a/src/qcommon/net_ip.c +++ b/src/qcommon/net_ip.c @@ -1026,43 +1026,27 @@ void NET_Shutdown( void ) { ==================== NET_Sleep -Sleeps msec or until something happens on the network or stdin +Sleeps msec or until something happens on the network ==================== */ void NET_Sleep( int msec ) { struct timeval timeout; fd_set fdset; - int highestfd = 0; if (!com_dedicated->integer) return; // we're not a server, just run full speed - FD_ZERO(&fdset); - - FD_SET(fileno(stdin), &fdset); - highestfd = fileno(stdin) + 1; + if (!ip_socket) + return; - if(ip_socket) - { - FD_SET(ip_socket, &fdset); // network socket - if(ip_socket >= highestfd) - highestfd = ip_socket + 1; - } + if (msec < 0 ) + return; - if(highestfd) - { - if(msec >= 0) - { - timeout.tv_sec = msec/1000; - timeout.tv_usec = (msec%1000)*1000; - select(highestfd, &fdset, NULL, NULL, &timeout); - } - else - { - // Block indefinitely - select(highestfd, &fdset, NULL, NULL, NULL); - } - } + FD_ZERO(&fdset); + FD_SET(ip_socket, &fdset); + timeout.tv_sec = msec/1000; + timeout.tv_usec = (msec%1000)*1000; + select(ip_socket+1, &fdset, NULL, NULL, &timeout); } diff --git a/src/qcommon/qcommon.h b/src/qcommon/qcommon.h index e59490b7..7e6c40cd 100644 --- a/src/qcommon/qcommon.h +++ b/src/qcommon/qcommon.h @@ -1019,6 +1019,7 @@ char *Sys_ConsoleInput(void); char **Sys_ListFiles( const char *directory, const char *extension, char *filter, int *numfiles, qboolean wantsubs ); void Sys_FreeFileList( char **list ); +void Sys_Sleep(int msec); qboolean Sys_LowPhysicalMemory( void ); diff --git a/src/server/sv_main.c b/src/server/sv_main.c index 62973d9c..e67d9b47 100644 --- a/src/server/sv_main.c +++ b/src/server/sv_main.c @@ -777,7 +777,7 @@ void SV_Frame( int msec ) { // Running as a server, but no map loaded #ifdef DEDICATED // Block until something interesting happens - NET_Sleep(-1); + Sys_Sleep(-1); #endif return; diff --git a/src/sys/con_win32.c b/src/sys/con_win32.c index 55020e26..e4f1228a 100644 --- a/src/sys/con_win32.c +++ b/src/sys/con_win32.c @@ -22,21 +22,113 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "../qcommon/q_shared.h" #include "../qcommon/qcommon.h" +#include "sys_local.h" #include "windows.h" +#define QCONSOLE_HISTORY 32 -#define QCONSOLE_THEME FOREGROUND_RED | \ - BACKGROUND_RED | \ - BACKGROUND_GREEN | \ - BACKGROUND_BLUE +static WORD qconsole_attrib; -#define QCONSOLE_INPUT_RECORDS 1024 +// saved console status +static DWORD qconsole_orig_mode; +static CONSOLE_CURSOR_INFO qconsole_orig_cursorinfo; -// used to track key input -static int qconsole_chars = 0; +// cmd history +static char qconsole_history[ QCONSOLE_HISTORY ][ MAX_EDIT_LINE ]; +static int qconsole_history_pos = -1; +static int qconsole_history_oldest = 0; + +// current edit buffer +static char qconsole_line[ MAX_EDIT_LINE ]; +static int qconsole_linelen = 0; + +static HANDLE qconsole_hout; +static HANDLE qconsole_hin; + +/* +================== +CON_CtrlHandler + +The Windows Console doesn't use signals for terminating the application +with Ctrl-C, logging off, window closing, etc. Instead it uses a special +handler routine. Fortunately, the values for Ctrl signals don't seem to +overlap with true signal codes that Windows provides, so calling +Sys_SigHandler() with those numbers should be safe for generating unique +shutdown messages. +================== +*/ +static BOOL WINAPI CON_CtrlHandler( DWORD sig ) +{ + Sys_SigHandler( sig ); + return TRUE; +} + +/* +================== +CON_HistAdd +================== +*/ +static void CON_HistAdd( void ) +{ + Q_strncpyz( qconsole_history[ qconsole_history_oldest ], qconsole_line, + sizeof( qconsole_history[ qconsole_history_oldest ] ) ); + + if( qconsole_history_oldest >= QCONSOLE_HISTORY - 1 ) + qconsole_history_oldest = 0; + else + qconsole_history_oldest++; + + qconsole_history_pos = qconsole_history_oldest; +} + +/* +================== +CON_HistPrev +================== +*/ +static void CON_HistPrev( void ) +{ + int pos; + + pos = ( qconsole_history_pos < 1 ) ? + ( QCONSOLE_HISTORY - 1 ) : ( qconsole_history_pos - 1 ); + + // don' t allow looping through history + if( pos == qconsole_history_oldest ) + return; + + qconsole_history_pos = pos; + Q_strncpyz( qconsole_line, qconsole_history[ qconsole_history_pos ], + sizeof( qconsole_line ) ); + qconsole_linelen = strlen( qconsole_line ); +} + +/* +================== +CON_HistNext +================== +*/ +static void CON_HistNext( void ) +{ + int pos; + + pos = ( qconsole_history_pos >= QCONSOLE_HISTORY - 1 ) ? + 0 : ( qconsole_history_pos + 1 ); + + // clear the edit buffer if they try to advance to a future command + if( pos == qconsole_history_oldest ) + { + qconsole_line[ 0 ] = '\0'; + qconsole_linelen = 0; + return; + } + + qconsole_history_pos = pos; + Q_strncpyz( qconsole_line, qconsole_history[ qconsole_history_pos ], + sizeof( qconsole_line ) ); + qconsole_linelen = strlen( qconsole_line ); +} -// used to restore original color theme -static int qconsole_orig_attrib; /* ================== @@ -54,6 +146,46 @@ CON_Show */ void CON_Show( void ) { + CONSOLE_SCREEN_BUFFER_INFO binfo; + COORD writeSize = { MAX_EDIT_LINE, 1 }; + COORD writePos = { 0, 0 }; + SMALL_RECT writeArea = { 0, 0, 0, 0 }; + int i; + CHAR_INFO line[ MAX_EDIT_LINE ]; + + GetConsoleScreenBufferInfo( qconsole_hout, &binfo ); + + // if we' re in the middle of printf, don't bother writing the buffer + if( binfo.dwCursorPosition.X != 0 ) + return; + + writeArea.Left = 0; + writeArea.Top = binfo.dwCursorPosition.Y; + writeArea.Bottom = binfo.dwCursorPosition.Y; + writeArea.Right = MAX_EDIT_LINE; + + // build a space-padded CHAR_INFO array + for( i = 0; i < MAX_EDIT_LINE; i++ ) + { + if( i < qconsole_linelen ) + line[ i ].Char.AsciiChar = qconsole_line[ i ]; + else + line[ i ].Char.AsciiChar = ' '; + + line[ i ].Attributes = qconsole_attrib; + } + + if( qconsole_linelen > binfo.srWindow.Right ) + { + WriteConsoleOutput( qconsole_hout, + line + (qconsole_linelen - binfo.srWindow.Right ), + writeSize, writePos, &writeArea ); + } + else + { + WriteConsoleOutput( qconsole_hout, line, writeSize, + writePos, &writeArea ); + } } /* @@ -63,15 +195,10 @@ CON_Shutdown */ void CON_Shutdown( void ) { - HANDLE hout; - COORD screen = { 0, 0 }; - DWORD written; - - hout = GetStdHandle( STD_OUTPUT_HANDLE ); - - SetConsoleTextAttribute( hout, qconsole_orig_attrib ); - FillConsoleOutputAttribute( hout, qconsole_orig_attrib, 63999, - screen, &written ); + SetConsoleMode( qconsole_hin, qconsole_orig_mode ); + SetConsoleCursorInfo( qconsole_hout, &qconsole_orig_cursorinfo ); + CloseHandle( qconsole_hout ); + CloseHandle( qconsole_hin ); } /* @@ -81,34 +208,43 @@ CON_Init */ void CON_Init( void ) { - HANDLE hout; - COORD screen = { 0, 0 }; - DWORD written, read; - CONSOLE_SCREEN_BUFFER_INFO binfo; - SMALL_RECT rect; - WORD oldattrib; - - hout = GetStdHandle( STD_OUTPUT_HANDLE ); - - // remember original color theme - ReadConsoleOutputAttribute( hout, &oldattrib, 1, screen, &read ); - qconsole_orig_attrib = oldattrib; - - SetConsoleTitle("ioquake3 Dedicated Server Console"); + CONSOLE_CURSOR_INFO curs; + CONSOLE_SCREEN_BUFFER_INFO info; + int i; - SetConsoleTextAttribute( hout, QCONSOLE_THEME ); - FillConsoleOutputAttribute( hout, QCONSOLE_THEME, 63999, screen, &written ); - - // adjust console scroll to match up with cursor position - GetConsoleScreenBufferInfo( hout, &binfo ); - rect.Top = binfo.srWindow.Top; - rect.Left = binfo.srWindow.Left; - rect.Bottom = binfo.srWindow.Bottom; - rect.Right = binfo.srWindow.Right; - rect.Top += ( binfo.dwCursorPosition.Y - binfo.srWindow.Bottom ); - rect.Bottom = binfo.dwCursorPosition.Y; - SetConsoleWindowInfo( hout, TRUE, &rect ); + // handle Ctrl-C or other console termination + SetConsoleCtrlHandler( CON_CtrlHandler, TRUE ); + + qconsole_hin = GetStdHandle( STD_INPUT_HANDLE ); + if( qconsole_hin == INVALID_HANDLE_VALUE ) + return; + + qconsole_hout = GetStdHandle( STD_OUTPUT_HANDLE ); + if( qconsole_hout == INVALID_HANDLE_VALUE ) + return; + + GetConsoleMode( qconsole_hin, &qconsole_orig_mode ); + + // allow mouse wheel scrolling + SetConsoleMode( qconsole_hin, + qconsole_orig_mode & ~ENABLE_MOUSE_INPUT ); + + FlushConsoleInputBuffer( qconsole_hin ); + GetConsoleScreenBufferInfo( qconsole_hout, &info ); + qconsole_attrib = info.wAttributes; + + SetConsoleTitle("ioquake3 Dedicated Server Console"); + + // make cursor invisible + GetConsoleCursorInfo( qconsole_hout, &qconsole_orig_cursorinfo ); + curs.dwSize = 1; + curs.bVisible = FALSE; + SetConsoleCursorInfo( qconsole_hout, &curs ); + + // initialize history + for( i = 0; i < QCONSOLE_HISTORY; i++ ) + qconsole_history[ i ][ 0 ] = '\0'; } /* @@ -118,167 +254,102 @@ CON_ConsoleInput */ char *CON_ConsoleInput( void ) { - HANDLE hin, hout; - INPUT_RECORD buff[ QCONSOLE_INPUT_RECORDS ]; - DWORD count = 0; - int i; - static char input[ 1024 ] = { "" }; - int inputlen; - int newlinepos = -1; - CHAR_INFO line[ QCONSOLE_INPUT_RECORDS ]; - int linelen = 0; - - inputlen = 0; - input[ 0 ] = '\0'; - - hin = GetStdHandle( STD_INPUT_HANDLE ); - if( hin == INVALID_HANDLE_VALUE ) - return NULL; - hout = GetStdHandle( STD_OUTPUT_HANDLE ); - if( hout == INVALID_HANDLE_VALUE ) - return NULL; - - if( !PeekConsoleInput( hin, buff, QCONSOLE_INPUT_RECORDS, &count ) ) - return NULL; - - // if we have overflowed, start dropping oldest input events - if( count == QCONSOLE_INPUT_RECORDS ) - { - ReadConsoleInput( hin, buff, 1, &count ); - return NULL; - } - - for( i = 0; i < count; i++ ) - { - if( buff[ i ].EventType == KEY_EVENT && buff[ i ].Event.KeyEvent.bKeyDown ) - { - if( buff[ i ].Event.KeyEvent.wVirtualKeyCode == VK_RETURN ) - { - newlinepos = i; - break; - } - - if( linelen < QCONSOLE_INPUT_RECORDS && - buff[ i ].Event.KeyEvent.uChar.AsciiChar ) - { - if( buff[ i ].Event.KeyEvent.wVirtualKeyCode == VK_BACK ) - { - if( linelen > 0 ) - linelen--; - - } - else - { - line[ linelen ].Attributes = QCONSOLE_THEME; - line[ linelen++ ].Char.AsciiChar = - buff[ i ].Event.KeyEvent.uChar.AsciiChar; - } - } - } - } - - // provide visual feedback for incomplete commands - if( linelen != qconsole_chars ) - { - CONSOLE_SCREEN_BUFFER_INFO binfo; - COORD writeSize = { QCONSOLE_INPUT_RECORDS, 1 }; - COORD writePos = { 0, 0 }; - SMALL_RECT writeArea = { 0, 0, 0, 0 }; - int i; - - // keep track of this so we don't need to re-write to console every frame - qconsole_chars = linelen; - - GetConsoleScreenBufferInfo( hout, &binfo ); - - // adjust scrolling to cursor when typing - if( binfo.dwCursorPosition.Y > binfo.srWindow.Bottom ) - { - SMALL_RECT rect; - - rect.Top = binfo.srWindow.Top; - rect.Left = binfo.srWindow.Left; - rect.Bottom = binfo.srWindow.Bottom; - rect.Right = binfo.srWindow.Right; - - rect.Top += ( binfo.dwCursorPosition.Y - binfo.srWindow.Bottom ); - rect.Bottom = binfo.dwCursorPosition.Y; - - SetConsoleWindowInfo( hout, TRUE, &rect ); - GetConsoleScreenBufferInfo( hout, &binfo ); - } - - writeArea.Left = 0; - writeArea.Top = binfo.srWindow.Bottom; - writeArea.Bottom = binfo.srWindow.Bottom; - writeArea.Right = QCONSOLE_INPUT_RECORDS; - - // pad line with ' ' to handle VK_BACK - for( i = linelen; i < QCONSOLE_INPUT_RECORDS; i++ ) - { - line[ i ].Char.AsciiChar = ' '; - line[ i ].Attributes = QCONSOLE_THEME; - } - - if( linelen > binfo.srWindow.Right ) - { - WriteConsoleOutput( hout, line + (linelen - binfo.srWindow.Right ), - writeSize, writePos, &writeArea ); - } - else - { - WriteConsoleOutput( hout, line, writeSize, writePos, &writeArea ); - } - - if( binfo.dwCursorPosition.X != linelen ) - { - COORD cursorPos = { 0, 0 }; - - cursorPos.X = linelen; - cursorPos.Y = binfo.srWindow.Bottom; - SetConsoleCursorPosition( hout, cursorPos ); - } - } - - // don't touch the input buffer if this is an incomplete command - if( newlinepos < 0) - { - return NULL; - } - else - { - // add a newline - COORD cursorPos = { 0, 0 }; - CONSOLE_SCREEN_BUFFER_INFO binfo; - - GetConsoleScreenBufferInfo( hout, &binfo ); - cursorPos.Y = binfo.srWindow.Bottom + 1; - SetConsoleCursorPosition( hout, cursorPos ); - } - - - if( !ReadConsoleInput( hin, buff, newlinepos+1, &count ) ) - return NULL; - - for( i = 0; i < count; i++ ) - { - if( buff[ i ].EventType == KEY_EVENT && buff[ i ].Event.KeyEvent.bKeyDown ) - { - if( buff[ i ].Event.KeyEvent.wVirtualKeyCode == VK_BACK ) - { - if( inputlen > 0 ) - input[ --inputlen ] = '\0'; - continue; - } - if( inputlen < ( sizeof( input ) - 1 ) && - buff[ i ].Event.KeyEvent.uChar.AsciiChar ) - { - input[ inputlen++ ] = buff[ i ].Event.KeyEvent.uChar.AsciiChar; - input[ inputlen ] = '\0'; - } - } - } - if( !inputlen ) - return NULL; - return input; + INPUT_RECORD buff[ MAX_EDIT_LINE ]; + DWORD count = 0, events = 0; + WORD key = 0; + int i; + int newlinepos = -1; + + if( !GetNumberOfConsoleInputEvents( qconsole_hin, &events ) ) + return NULL; + + if( events < 1 ) + return NULL; + + // if we have overflowed, start dropping oldest input events + if( events >= MAX_EDIT_LINE ) + { + ReadConsoleInput( qconsole_hin, buff, 1, &events ); + return NULL; + } + + if( !ReadConsoleInput( qconsole_hin, buff, events, &count ) ) + return NULL; + + FlushConsoleInputBuffer( qconsole_hin ); + + for( i = 0; i < count; i++ ) + { + if( buff[ i ].EventType != KEY_EVENT ) + continue; + if( !buff[ i ].Event.KeyEvent.bKeyDown ) + continue; + + key = buff[ i ].Event.KeyEvent.wVirtualKeyCode; + + if( key == VK_RETURN ) + { + newlinepos = i; + break; + } + else if( key == VK_UP ) + { + CON_HistPrev(); + break; + } + else if( key == VK_DOWN ) + { + CON_HistNext(); + break; + } + else if( key == VK_TAB ) + { + field_t f; + + Q_strncpyz( f.buffer, qconsole_line, + sizeof( f.buffer ) ); + Field_AutoComplete( &f ); + Q_strncpyz( qconsole_line, f.buffer, + sizeof( qconsole_line ) ); + qconsole_linelen = strlen( qconsole_line ); + break; + } + + if( qconsole_linelen < sizeof( qconsole_line ) - 1 ) + { + char c = buff[ i ].Event.KeyEvent.uChar.AsciiChar; + + if( key == VK_BACK ) + { + int pos = ( qconsole_linelen > 0 ) ? + qconsole_linelen - 1 : 0; + + qconsole_line[ pos ] = '\0'; + qconsole_linelen = pos; + } + else if( c ) + { + qconsole_line[ qconsole_linelen++ ] = c; + qconsole_line[ qconsole_linelen ] = '\0'; + } + } + } + + CON_Show(); + + if( newlinepos < 0) + return NULL; + + if( !qconsole_linelen ) + { + Com_Printf( "\n" ); + return NULL; + } + + CON_HistAdd(); + Com_Printf( "%s\n", qconsole_line ); + + qconsole_linelen = 0; + + return qconsole_line; } diff --git a/src/sys/sys_local.h b/src/sys/sys_local.h index 03a0a095..f2a4dddc 100644 --- a/src/sys/sys_local.h +++ b/src/sys/sys_local.h @@ -38,3 +38,5 @@ char *CON_ConsoleInput(void); #ifdef MACOS_X char *Sys_StripAppBundle( char *pwd ); #endif + +void Sys_SigHandler( int signal ); diff --git a/src/sys/sys_main.c b/src/sys/sys_main.c index b7784b00..b235c6c0 100644 --- a/src/sys/sys_main.c +++ b/src/sys/sys_main.c @@ -573,7 +573,7 @@ void Sys_ParseArgs( int argc, char **argv ) Sys_SigHandler ================= */ -static void Sys_SigHandler( int signal ) +void Sys_SigHandler( int signal ) { static qboolean signalcaught = qfalse; @@ -641,6 +641,7 @@ int main( int argc, char **argv ) #ifndef _WIN32 // Windows doesn't have these signals + // see CON_CtrlHandler() in con_win32.c signal( SIGHUP, Sys_SigHandler ); signal( SIGQUIT, Sys_SigHandler ); signal( SIGTRAP, Sys_SigHandler ); diff --git a/src/sys/sys_unix.c b/src/sys/sys_unix.c index a170f21d..230d8c44 100644 --- a/src/sys/sys_unix.c +++ b/src/sys/sys_unix.c @@ -448,3 +448,31 @@ char *Sys_StripAppBundle( char *dir ) return cwd; } #endif // MACOS_X + + +/* +================== +Sys_Sleep + +Block execution for msec or until input is recieved. +================== +*/ +void Sys_Sleep( int msec ) +{ + fd_set fdset; + + FD_ZERO(&fdset); + FD_SET(fileno(stdin), &fdset); + if( msec < 0 ) + { + select((fileno(stdin) + 1), &fdset, NULL, NULL, NULL); + } + else + { + struct timeval timeout; + + timeout.tv_sec = msec/1000; + timeout.tv_usec = (msec%1000)*1000; + select((fileno(stdin) + 1), &fdset, NULL, NULL, &timeout); + } +} diff --git a/src/sys/sys_win32.c b/src/sys/sys_win32.c index df302ace..36d81a77 100644 --- a/src/sys/sys_win32.c +++ b/src/sys/sys_win32.c @@ -508,3 +508,20 @@ void Sys_FreeFileList( char **list ) Z_Free( list ); } + + +/* +============== +Sys_Sleep + +Block execution for msec or until input is recieved. +============== +*/ +void Sys_Sleep( int msec ) +{ + if( msec < 0 ) + WaitForSingleObject( GetStdHandle( STD_INPUT_HANDLE ), INFINITE ); + else + WaitForSingleObject( GetStdHandle( STD_INPUT_HANDLE ), msec ); +} + diff --git a/src/tools/lcc/etc/lcc.c b/src/tools/lcc/etc/lcc.c index cac01b92..13ed690b 100644 --- a/src/tools/lcc/etc/lcc.c +++ b/src/tools/lcc/etc/lcc.c @@ -526,10 +526,6 @@ static void help(void) { #define xx(v) if ((s = getenv(#v))) fprintf(stderr, #v "=%s\n", s) xx(LCCINPUTS); xx(LCCDIR); -#ifdef WIN32 - xx(include); - xx(lib); -#endif #undef xx } @@ -537,9 +533,6 @@ static void help(void) { static void initinputs(void) { char *s = getenv("LCCINPUTS"); List b; -#ifdef WIN32 - List list; -#endif if (s == 0 || (s = inputs)[0] == 0) s = "."; @@ -556,13 +549,6 @@ static void initinputs(void) { b->str = ""; } while (b != lccinputs); } -#ifdef WIN32 - if ((list = b = path2list(getenv("include")))) - do { - b = b->link; - ilist = append(stringf("-I\"%s\"", b->str), ilist); - } while (b != list); -#endif } /* interrupt - catch interrupt signals */ |