]> git.pond.sub.org Git - empserver/blobdiff - src/lib/subs/pr.c
Fix journalling of output ids
[empserver] / src / lib / subs / pr.c
index d9e7a5f07c82681dc7505149191ec294c9387a6b..496bde49ba2901164b051a6435301d12ca34a74b 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2007, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *  Copyright (C) 1986-2008, 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
+ *     Markus Armbruster, 2005-2007
  */
 
 /*
 
 #include <config.h>
 
-#include <fcntl.h>
-#include <ctype.h>
 #include <stdarg.h>
 #include <stdlib.h>
 #include "com.h"
 #include "empio.h"
 #include "file.h"
+#include "journal.h"
 #include "misc.h"
 #include "nat.h"
 #include "player.h"
@@ -126,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);
@@ -247,6 +247,7 @@ pr_player(struct player *pl, int id, char *buf)
            bp += len;
        }
     }
+    journal_output(pl, id, buf);
 }
 
 /*
@@ -301,6 +302,7 @@ upr_player(struct player *pl, int id, char *buf)
            io_puts(pl->iop, printbuf);
        }
     }
+    journal_output(pl, id, buf);
 }
 
 /*
@@ -370,12 +372,6 @@ prmptrd(char *prompt, char *buf, int size)
 {
     int r;
 
-    /*
-     * Each prompt must consume one line of input.  recvclient()
-     * doesn't do that while player->aborted.
-     */
-    CANT_HAPPEN(player->aborted);
-
     if (CANT_HAPPEN(!prompt))
        prompt = "? ";
 
@@ -405,9 +401,6 @@ uprmptrd(char *prompt, char *buf, int size)
 {
     int r;
 
-    /* See prmptrd() */
-    CANT_HAPPEN(player->aborted);
-
     if (CANT_HAPPEN(!prompt))
        prompt = "? ";
 
@@ -472,7 +465,7 @@ PR(int cn, char *format, ...)
     newline = strrchr(buf, '\n') ? 1 : 0;
     strcat(longline[cn], buf);
     if (newline) {
-       if (update_pending || (cn && cn != player->cnum))
+       if (update_running || (cn && cn != player->cnum))
            typed_wu(0, cn, longline[cn], TEL_BULLETIN);
        else
            pr_player(player, C_DATA, longline[cn]);
@@ -509,8 +502,9 @@ pr_beep(void)
 /*
  * Print to country CN similar to printf().
  * Use printf-style FORMAT with the optional arguments.
- * If CN is the current player and we're not in the update, print just
- * like pr().  Else print into a bulletin.
+ * If CN is zero, don't print anything.
+ * Else, if CN is the current player and we're not in the update,
+ * print just like pr().  Else print into a bulletin.
  * Because printing like pr() requires normal text, and bulletins
  * require user text, only plain ASCII is allowed.
  */
@@ -520,15 +514,15 @@ mpr(int cn, char *format, ...)
     char buf[4096];
     va_list ap;
 
+    if (!cn)
+       return;
     va_start(ap, format);
     (void)vsprintf(buf, format, ap);
     va_end(ap);
-    if (cn) {
-       if (update_pending || cn != player->cnum)
-           typed_wu(0, cn, buf, TEL_BULLETIN);
-       else
-           pr_player(player, C_DATA, buf);
-    }
+    if (update_running || cn != player->cnum)
+       typed_wu(0, cn, buf, TEL_BULLETIN);
+    else
+       pr_player(player, C_DATA, buf);
 }
 
 /*