]> git.pond.sub.org Git - empserver/blobdiff - src/lib/player/recvclient.c
Update copyright notice
[empserver] / src / lib / player / recvclient.c
index 7dacb4508c88a108372590ce980db3f19330d4af..4fcc0fa1106e42e4cfeb429c97e894216ff9f930 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2011, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *  Copyright (C) 1986-2017, Dave Pare, Jeff Bailey, Thomas Ruschak,
  *                Ken Stevens, Steve McClure, Markus Armbruster
  *
  *  Empire is free software: you can redistribute it and/or modify
  *
  *  Known contributors to this file:
  *     Dave Pare, 1986
- *     Markus Armbruster, 2006-2012
+ *     Markus Armbruster, 2006-2015
  *     Ron Koenderink, 2009
  */
 
 #include <config.h>
 
 #include "empio.h"
+#include "file.h"
 #include "journal.h"
-#include "optlist.h"
 #include "player.h"
 #include "prototypes.h"
 
@@ -44,7 +44,7 @@
  * Receive a line of input from the current player.
  * If the player's aborted flag is set, return -1 without receiving
  * input.
- * Else receive one line and store it in CMD[SIZE].
+ * Else receive one line and store it in @cmd[@size].
  * This may block for input, yielding the processor.  Flush buffered
  * output when blocking, to make sure player sees the prompt.
  * If the player's connection has the I/O error or EOF indicator set,
@@ -69,6 +69,8 @@ recvclient(char *cmd, int size)
        count = io_gets(player->iop, cmd, size);
        if (count >= 0) {
            /* got it */
+           if (player_io_deadline(player, 0))
+               ef_make_stale();
            if (strcmp(cmd, "ctld") == 0)
                player->aborted = player->got_ctld = 1;
            if (strcmp(cmd, "aborted") == 0)
@@ -81,19 +83,15 @@ recvclient(char *cmd, int size)
         * Flush all queued output before potentially sleeping in
         * io_input(), to make sure player sees the prompt.
         */
-       deadline = (time_t)(player->may_sleep >= PLAYER_SLEEP_ON_INPUT
-                           ? -1 : 0);
+       deadline = player_io_deadline(player, 0);
        while (io_output(player->iop, deadline) > 0)
            ;
 
        /*
-        * Try to receive some input.  Need to check player->may_sleep
-        * again; command abortion during io_output() might have
-        * changed it.
+        * Try to receive some input.  Need to recompute deadline;
+        * command abortion during io_output() might have changed it.
         */
-       deadline = player->curup + minutes(max_idle);
-       if (player->may_sleep < PLAYER_SLEEP_ON_INPUT)
-           deadline = 0;
+       deadline = player_io_deadline(player, 0);
        res = io_input(player->iop, deadline);
        if (res > 0)
            ;