From: Andy D. <kha...@us...> - 2005-08-18 20:58:15
|
Update of /cvsroot/planeshift/planeshift/src/common/util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32109/src/common/util Modified Files: serverconsole.cpp Log Message: The server console no longer blocks the server/npcclient when waiting for input and checks the running flag every second (should allow for automatic shutdowns) but does not work in Windows. Index: serverconsole.cpp =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/common/util/serverconsole.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** serverconsole.cpp 17 Jun 2005 14:09:54 -0000 1.13 --- serverconsole.cpp 18 Aug 2005 04:02:27 -0000 1.14 *************** *** 191,195 **** } ! #ifndef USE_READLINE // simple version without readline... --- 191,195 ---- } ! #include "..\net\netbase.h" #ifndef USE_READLINE // simple version without readline... *************** *** 202,206 **** --- 202,220 ---- { CPrintf (CON_CMDOUTPUT, COL_BLUE "%s: " COL_NORMAL, prompt); + #ifndef WIN32 + struct timeval tv; + fd_set readfds; + + tv.tv_sec = 1; + tv.tv_usec = 0; + FD_ZERO(&readfds); + FD_SET(STDIN, &readfds); + + // This allows the running flag to be checked every second but only works on Unix. + int retval = select(STDIN+1, &readfds, NULL, NULL, &tv); + if(retval == 0) + continue; + #endif while (fgets(line,319,stdin) == NULL) { |