]> git.pond.sub.org Git - empserver/commitdiff
Fix journalling of output ids
authorMarkus Armbruster <armbru@pond.sub.org>
Sat, 2 Aug 2008 13:04:16 +0000 (09:04 -0400)
committerMarkus Armbruster <armbru@pond.sub.org>
Tue, 26 Jan 2010 21:49:40 +0000 (22:49 +0100)
include/journal.h
src/lib/subs/journal.c
src/lib/subs/pr.c

index d2ee2159386cf265b53c4532f1b1de83638ba013..d2029d30b6656f98a10770706311fb0d47932f86 100644 (file)
@@ -42,7 +42,7 @@ int journal_reopen(void);
 void journal_login(void);
 void journal_logout(void);
 void journal_prng(unsigned);
 void journal_login(void);
 void journal_logout(void);
 void journal_prng(unsigned);
-void journal_output(struct player *, char *);
+void journal_output(struct player *, int, char *);
 void journal_input(char *);
 void journal_command(char *);
 void journal_update(int);
 void journal_input(char *);
 void journal_command(char *);
 void journal_update(int);
index 3fafb6bf1469368033bac35e5cf8171c7574ecd6..e5354402090d2b2b684747006878031409979193 100644 (file)
@@ -69,7 +69,7 @@ static FILE *journal;
 
 static void journal_entry(char *fmt, ...)
     ATTRIBUTE((format (printf, 1, 2)));
 
 static void journal_entry(char *fmt, ...)
     ATTRIBUTE((format (printf, 1, 2)));
-static void journal_output_1(struct player *, char *, char *, int);
+static void journal_output_1(struct player *, int, char *, char *, int);
 
 static FILE *
 journal_open(void)
 
 static FILE *
 journal_open(void)
@@ -172,35 +172,45 @@ journal_logout(void)
 }
 
 void
 }
 
 void
-journal_output(struct player *pl, char *output)
+journal_output(struct player *pl, int id, char *output)
 {
     static char buf[1024];
 {
     static char buf[1024];
+    static struct player *bpl;
+    static int bid;
     char *s, *e;
 
     if (keep_journal < 2)
        return;
 
     char *s, *e;
 
     if (keep_journal < 2)
        return;
 
+    if (buf[0] && (pl != bpl && id != bid)) {
+       journal_output_1(bpl, bid, buf, "", -1);
+       buf[0] = 0;
+    }
+
     for (s = output; (e = strchr(s, '\n')); s = e + 1) {
     for (s = output; (e = strchr(s, '\n')); s = e + 1) {
-       journal_output_1(pl, buf, s, (int)(e + 1 - s));
+       journal_output_1(pl, id, buf, s, (int)(e + 1 - s));
        buf[0] = 0;
     }
        buf[0] = 0;
     }
-    if (strlen(buf) + strlen(s) < 1024)
+    if (strlen(buf) + strlen(s) < 1024) {
        strcpy(buf + strlen(buf), s);
        strcpy(buf + strlen(buf), s);
-    else {
-       journal_output_1(pl, buf, s, -1);
+       bpl = pl;
+       bid = id;
+    } else {
+       journal_output_1(pl, id, buf, s, -1);
        buf[0] = 0;
     }
 }
 
 void
        buf[0] = 0;
     }
 }
 
 void
-journal_output_1(struct player *pl, char *buf1, char *buf2, int buf2prec)
+journal_output_1(struct player *pl, int id,
+                char *buf1, char *buf2, int buf2prec)
 {
     if (pl && pl->state == PS_PLAYING)
 {
     if (pl && pl->state == PS_PLAYING)
-       journal_entry("output %d %s%.*s",
-                     pl->cnum, buf1, buf2prec, buf2);
+       journal_entry("output %d %d %s%.*s",
+                     pl->cnum, id, buf1, buf2prec, buf2);
     else
     else
-       journal_entry("output %p %s%.*s",
-                     pl, buf1, buf2prec, buf2);
+       journal_entry("output %p %d %s%.*s",
+                     pl, id, buf1, buf2prec, buf2);
 }
 
 void
 }
 
 void
index ff56f893fce03d09b68613e05664eb290df5a6ea..358bdc1f25c28b3b8d71d6bee63196f122b1a62f 100644 (file)
@@ -125,7 +125,7 @@ pr_id(struct player *p, int id, char *format, ...)
 
     if (p->curid >= 0) {
        io_puts(p->iop, "\n");
 
     if (p->curid >= 0) {
        io_puts(p->iop, "\n");
-       journal_output(p, "\n");
+       journal_output(p, p->curid, "\n");
        p->curid = -1;
     }
     va_start(ap, format);
        p->curid = -1;
     }
     va_start(ap, format);
@@ -244,7 +244,7 @@ pr_player(struct player *pl, int id, char *buf)
        }
     }
 
        }
     }
 
-    journal_output(pl, buf);
+    journal_output(pl, id, buf);
 
     if (player == pl) {
        while (io_output_if_queue_long(pl->iop,
 
     if (player == pl) {
        while (io_output_if_queue_long(pl->iop,
@@ -302,7 +302,7 @@ upr_player(struct player *pl, int id, char *buf)
        }
     }
 
        }
     }
 
-    journal_output(pl, buf);
+    journal_output(pl, id, buf);
 
     if (player == pl) {
        while (io_output_if_queue_long(pl->iop,
 
     if (player == pl) {
        while (io_output_if_queue_long(pl->iop,
@@ -330,7 +330,6 @@ outid(struct player *pl, int n)
     buf[1] = ' ';
     buf[2] = '\0';
     io_puts(pl->iop, buf);
     buf[1] = ' ';
     buf[2] = '\0';
     io_puts(pl->iop, buf);
-    journal_output(pl, buf);
     pl->curid = n;
 }
 
     pl->curid = n;
 }