From 9398627ec4e4c8d96f76180b47b224a874ef38e8 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Tue, 29 Jul 2008 20:38:48 -0400 Subject: [PATCH] New journal event output To enable, set econfig key keep_journal to at least 2. Output events are *not* flushed to disk immediately. Put it in Hvy Metal II now to gather real data for future testing of a journal replay tool. --- include/journal.h | 3 +++ src/lib/subs/journal.c | 15 ++++++++++++++- src/lib/subs/pr.c | 3 +++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/include/journal.h b/include/journal.h index eed66ff25..7ef10ae1e 100644 --- a/include/journal.h +++ b/include/journal.h @@ -34,12 +34,15 @@ #ifndef JOURNAL_H #define JOURNAL_H +struct player; /* FIXME temporary hack */ + int journal_startup(void); void journal_shutdown(void); int journal_reopen(void); void journal_login(void); void journal_logout(void); void journal_prng(unsigned); +void journal_output(struct player *, int, char *); void journal_input(char *); void journal_command(char *); void journal_update(int); diff --git a/src/lib/subs/journal.c b/src/lib/subs/journal.c index 20d325681..d2521f129 100644 --- a/src/lib/subs/journal.c +++ b/src/lib/subs/journal.c @@ -45,6 +45,7 @@ * logout CNUM * command NAME * input INPUT + * output THREAD ID OUTPUT * update ETU */ @@ -98,7 +99,8 @@ journal_entry(char *fmt, ...) fprintf(journal, "\\%03o", *p); } fputs("\n", journal); - fflush(journal); + if (fmt[0] != 'o') /* FIXME disgusting hack */ + fflush(journal); if (ferror(journal)) { logerror("Error writing journal (%s)", strerror(errno)); clearerr(journal); @@ -167,6 +169,17 @@ journal_logout(void) journal_entry("logout %d", player->cnum); } +void +journal_output(struct player *pl, int id, char *output) +{ + if (keep_journal < 2) + return; + if (pl && pl->state == PS_PLAYING) + journal_entry("output %d %d %s", pl->cnum, id, output); + else + journal_entry("output %p %d %s", pl, id, output); +} + void journal_input(char *input) { diff --git a/src/lib/subs/pr.c b/src/lib/subs/pr.c index 711dd3f4a..44f5aee76 100644 --- a/src/lib/subs/pr.c +++ b/src/lib/subs/pr.c @@ -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" @@ -245,6 +246,7 @@ pr_player(struct player *pl, int id, char *buf) bp += len; } } + journal_output(pl, id, buf); } /* @@ -299,6 +301,7 @@ upr_player(struct player *pl, int id, char *buf) io_puts(pl->iop, printbuf); } } + journal_output(pl, id, buf); } /* -- 2.43.0