Skip to content

Commit

Permalink
* rewrite of the win32 dedicated console:
Browse files Browse the repository at this point in the history
  1) NET_Sleep() no longer watches for input, Sys_Sleep() added for waiting
     on input.
  2) Added "CtrlHandler" for trapping Ctrl-C and other quit methods not
     handled by signals on windows
  3) Added history support
  4) Added tab completion
  5) Removed automatic cursor/scroll adjustment (too problematic)
  6) Enable mousewheel scrolling
  7) Stop using the InputBuffer for editing

  This seems to work pretty well now, but I jumped the gun on a previous
  commit message by saying you can scroll now without locking up your server.
  That was only true up until the point that a server tried to print to
  the console, at that point it will hang until you release the scroll bar :(
  It may be possible to get around this by using a seperate thread for
  console output, but that's a whole new can of worms.
  • Loading branch information
tjdub committed Sep 15, 2007
1 parent 2052b94 commit e46fe24
Show file tree
Hide file tree
Showing 8 changed files with 339 additions and 235 deletions.
36 changes: 10 additions & 26 deletions code/qcommon/net_ip.c
Expand Up @@ -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);
}


Expand Down
1 change: 1 addition & 0 deletions code/qcommon/qcommon.h
Expand Up @@ -1030,6 +1030,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 );

Expand Down
2 changes: 1 addition & 1 deletion code/server/sv_main.c
Expand Up @@ -774,7 +774,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;
Expand Down

0 comments on commit e46fe24

Please sign in to comment.