]> git.pond.sub.org Git - empserver/blobdiff - src/lib/subs/pr.c
Fix journalling of output ids
[empserver] / src / lib / subs / pr.c
index 79fbd1d7bd7c116a656c48311270c903d7aab735..358bdc1f25c28b3b8d71d6bee63196f122b1a62f 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2009, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *  Copyright (C) 1986-2010, Dave Pare, Jeff Bailey, Thomas Ruschak,
  *                           Ken Stevens, Steve McClure
  *
  *  This program is free software; you can redistribute it and/or modify
@@ -31,7 +31,7 @@
  *     Dave Pare, 1986, 1989
  *     Steve McClure, 1998-2000
  *     Ron Koenderink, 2005
- *     Markus Armbruster, 2005-2008
+ *     Markus Armbruster, 2005-2009
  */
 
 /*
@@ -56,6 +56,7 @@
 #include "com.h"
 #include "empio.h"
 #include "file.h"
+#include "journal.h"
 #include "misc.h"
 #include "nat.h"
 #include "player.h"
@@ -124,6 +125,7 @@ pr_id(struct player *p, int id, char *format, ...)
 
     if (p->curid >= 0) {
        io_puts(p->iop, "\n");
+       journal_output(p, p->curid, "\n");
        p->curid = -1;
     }
     va_start(ap, format);
@@ -152,7 +154,7 @@ pr_flash(struct player *pl, char *format, ...)
     if (!(pl->flags & PF_UTF8))
        copy_utf8_to_ascii_no_funny(buf, buf);
     pr_player(pl, C_FLASH, buf);
-    io_output(pl->iop, IO_NOWAIT);
+    io_output(pl->iop, 0);
 }
 
 /*
@@ -173,7 +175,7 @@ pr_inform(struct player *pl, char *format, ...)
     (void)vsprintf(buf, format, ap);
     va_end(ap);
     pr_player(pl, C_INFORM, buf);
-    io_output(pl->iop, IO_NOWAIT);
+    io_output(pl->iop, 0);
 }
 
 /*
@@ -205,7 +207,7 @@ pr_wall(char *format, ...)
        if (p->state != PS_PLAYING)
            continue;
        pr_player(p, C_FLASH, buf);
-       io_output(p->iop, IO_NOWAIT);
+       io_output(p->iop, 0);
     }
 }
 
@@ -233,11 +235,7 @@ pr_player(struct player *pl, int id, char *buf)
        p = strchr(bp, '\n');
        if (p != NULL) {
            len = (p - bp) + 1;
-           if ((pl->command && (pl->command->c_flags & C_MOD)) ||
-               (player != pl))
-               io_write(pl->iop, bp, len, IO_NOWAIT);
-           else
-               io_write(pl->iop, bp, len, IO_WAIT);
+           io_write(pl->iop, bp, len);
            bp += len;
            pl->curid = -1;
        } else {
@@ -245,6 +243,14 @@ pr_player(struct player *pl, int id, char *buf)
            bp += len;
        }
     }
+
+    journal_output(pl, id, buf);
+
+    if (player == pl) {
+       while (io_output_if_queue_long(pl->iop,
+                       pl->may_sleep == PLAYER_SLEEP_FREELY) > 0)
+           ;
+    }
 }
 
 /*
@@ -288,17 +294,21 @@ upr_player(struct player *pl, int id, char *buf)
            }
        }
        if (ch == '\n') {
-           if ((pl->command && (pl->command->c_flags & C_MOD)) ||
-               (player != pl))
-               io_write(pl->iop, &ch, 1, IO_NOWAIT);
-           else
-               io_write(pl->iop, &ch, 1, IO_WAIT);
+           io_write(pl->iop, &ch, 1);
            pl->curid = -1;
        } else {
            printbuf[0] = ch;
            io_puts(pl->iop, printbuf);
        }
     }
+
+    journal_output(pl, id, buf);
+
+    if (player == pl) {
+       while (io_output_if_queue_long(pl->iop,
+                       pl->may_sleep == PLAYER_SLEEP_FREELY) > 0)
+           ;
+    }
 }
 
 /*