mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-16 00:12:51 +00:00
(svn r1188) -Fix: [Network] Fixed that CTRL+<key> could sometimes hang a dedicated
server till enter was pressed. CTRL+D after a random key still does hang the dedicated server till enter is pressed.
This commit is contained in:
parent
c1ab4b58e3
commit
b9f2fd358a
14
dedicated.c
14
dedicated.c
@ -65,8 +65,8 @@ void DedicatedFork()
|
|||||||
/* Signal handlers */
|
/* Signal handlers */
|
||||||
static void DedicatedSignalHandler(int sig)
|
static void DedicatedSignalHandler(int sig)
|
||||||
{
|
{
|
||||||
_exit_game = true;
|
_exit_game = true;
|
||||||
signal(sig, DedicatedSignalHandler);
|
signal(sig, DedicatedSignalHandler);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -97,6 +97,7 @@ static bool InputWaiting()
|
|||||||
{
|
{
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
fd_set readfds;
|
fd_set readfds;
|
||||||
|
byte ret;
|
||||||
|
|
||||||
tv.tv_sec = 0;
|
tv.tv_sec = 0;
|
||||||
tv.tv_usec = 1;
|
tv.tv_usec = 1;
|
||||||
@ -105,9 +106,9 @@ static bool InputWaiting()
|
|||||||
FD_SET(STDIN, &readfds);
|
FD_SET(STDIN, &readfds);
|
||||||
|
|
||||||
/* don't care about writefds and exceptfds: */
|
/* don't care about writefds and exceptfds: */
|
||||||
select(STDIN+1, &readfds, NULL, NULL, &tv);
|
ret = select(STDIN + 1, &readfds, NULL, NULL, &tv);
|
||||||
|
|
||||||
if (FD_ISSET(STDIN, &readfds))
|
if (ret > 0)
|
||||||
return true;
|
return true;
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
@ -128,6 +129,9 @@ static void DedicatedHandleKeyInput()
|
|||||||
|
|
||||||
#ifdef UNIX
|
#ifdef UNIX
|
||||||
if (InputWaiting()) {
|
if (InputWaiting()) {
|
||||||
|
if (_exit_game)
|
||||||
|
return;
|
||||||
|
|
||||||
fgets(input_line, 200, stdin);
|
fgets(input_line, 200, stdin);
|
||||||
// Forget about the final \n (or \r)
|
// Forget about the final \n (or \r)
|
||||||
strtok(input_line, "\r\n");
|
strtok(input_line, "\r\n");
|
||||||
@ -167,7 +171,7 @@ static int DedicatedVideoMainLoop()
|
|||||||
#ifdef UNIX
|
#ifdef UNIX
|
||||||
signal(SIGTERM, DedicatedSignalHandler);
|
signal(SIGTERM, DedicatedSignalHandler);
|
||||||
signal(SIGINT, DedicatedSignalHandler);
|
signal(SIGINT, DedicatedSignalHandler);
|
||||||
signal(SIGABRT, DedicatedSignalHandler);
|
signal(SIGQUIT, DedicatedSignalHandler);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Load the dedicated server stuff
|
// Load the dedicated server stuff
|
||||||
|
Loading…
Reference in New Issue
Block a user