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.
This commit is contained in:
parent
83fcc79bca
commit
221471af6f
3 changed files with 22 additions and 1 deletions
|
@ -34,12 +34,15 @@
|
||||||
#ifndef JOURNAL_H
|
#ifndef JOURNAL_H
|
||||||
#define JOURNAL_H
|
#define JOURNAL_H
|
||||||
|
|
||||||
|
struct player; /* FIXME temporary hack */
|
||||||
|
|
||||||
int journal_startup(void);
|
int journal_startup(void);
|
||||||
void journal_shutdown(void);
|
void journal_shutdown(void);
|
||||||
int journal_reopen(void);
|
int journal_reopen(void);
|
||||||
void journal_login(void);
|
void journal_login(void);
|
||||||
void journal_logout(void);
|
void journal_logout(void);
|
||||||
void journal_prng(unsigned);
|
void journal_prng(unsigned);
|
||||||
|
void journal_output(struct player *, int, char *);
|
||||||
void journal_input(char *);
|
void journal_input(char *);
|
||||||
void journal_command(char *);
|
void journal_command(char *);
|
||||||
void journal_update(int);
|
void journal_update(int);
|
||||||
|
|
|
@ -46,6 +46,7 @@
|
||||||
* logout CNUM
|
* logout CNUM
|
||||||
* command NAME
|
* command NAME
|
||||||
* input INPUT
|
* input INPUT
|
||||||
|
* output THREAD ID OUTPUT
|
||||||
* update ETU
|
* update ETU
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -99,6 +100,7 @@ journal_entry(char *fmt, ...)
|
||||||
fprintf(journal, "\\%03o", *p);
|
fprintf(journal, "\\%03o", *p);
|
||||||
}
|
}
|
||||||
fputs("\n", journal);
|
fputs("\n", journal);
|
||||||
|
if (fmt[0] != 'o') /* FIXME disgusting hack */
|
||||||
fflush(journal);
|
fflush(journal);
|
||||||
if (ferror(journal)) {
|
if (ferror(journal)) {
|
||||||
logerror("Error writing journal (%s)", strerror(errno));
|
logerror("Error writing journal (%s)", strerror(errno));
|
||||||
|
@ -168,6 +170,17 @@ journal_logout(void)
|
||||||
journal_entry("logout %d", player->cnum);
|
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
|
void
|
||||||
journal_input(char *input)
|
journal_input(char *input)
|
||||||
{
|
{
|
||||||
|
|
|
@ -56,6 +56,7 @@
|
||||||
#include "com.h"
|
#include "com.h"
|
||||||
#include "empio.h"
|
#include "empio.h"
|
||||||
#include "file.h"
|
#include "file.h"
|
||||||
|
#include "journal.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "nat.h"
|
#include "nat.h"
|
||||||
#include "player.h"
|
#include "player.h"
|
||||||
|
@ -242,6 +243,8 @@ pr_player(struct player *pl, int id, char *buf)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
journal_output(pl, id, buf);
|
||||||
|
|
||||||
if (player == pl) {
|
if (player == pl) {
|
||||||
while (io_output_if_queue_long(pl->iop,
|
while (io_output_if_queue_long(pl->iop,
|
||||||
pl->may_sleep == PLAYER_SLEEP_FREELY) > 0)
|
pl->may_sleep == PLAYER_SLEEP_FREELY) > 0)
|
||||||
|
@ -298,6 +301,8 @@ upr_player(struct player *pl, int id, char *buf)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
journal_output(pl, id, buf);
|
||||||
|
|
||||||
if (player == pl) {
|
if (player == pl) {
|
||||||
while (io_output_if_queue_long(pl->iop,
|
while (io_output_if_queue_long(pl->iop,
|
||||||
pl->may_sleep == PLAYER_SLEEP_FREELY) > 0)
|
pl->may_sleep == PLAYER_SLEEP_FREELY) > 0)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue