Chronicle of major events, and livelog

Log game events, such as entering a new dungeon level, breaking
a conduct, or killing a unique monster, in a new "Major events"
chronicle. The entries record the turn when the event happened.
The log can be viewed with #chronicle -command, and the entries
also show up in the end-of-game dump, if that is available.

This feature is on by default, but can be disabled by
defining NO_CHRONICLE compile-time option.

This also contains "live logging", writing the events as they
happen into a single livelog-file. This is mostly useful for
public servers. The livelog is off by default, and must be
compiled in with LIVELOG, and then turned on in sysconf.

Mostly this a version of livelogging from the Hardfought server,
with some changes.
This commit is contained in:
Pasi Kallinen
2022-02-09 22:49:25 +02:00
parent cfcfc3429f
commit 1e90f89203
43 changed files with 624 additions and 53 deletions
+49
View File
@@ -398,6 +398,55 @@ verbalize(const char *line, ...)
va_end(the_args);
}
#ifdef CHRONICLE
void
gamelog_add(unsigned int glflags, long gltime, const char *str)
{
struct gamelog_line *tmp;
struct gamelog_line *lst = g.gamelog;
tmp = (struct gamelog_line *)alloc(sizeof(struct gamelog_line));
tmp->turn = gltime;
tmp->flags = glflags;
tmp->text = strdup(str);
tmp->next = NULL;
while (lst && lst->next)
lst = lst->next;
if (!lst)
g.gamelog = tmp;
else
lst->next = tmp;
}
void
livelog_printf(unsigned int ll_type, const char *line, ...)
{
char gamelogbuf[BUFSZ * 2];
va_list the_args;
va_start(the_args, line);
vsnprintf(gamelogbuf, sizeof gamelogbuf, line, the_args);
va_end(the_args);
gamelog_add(ll_type, g.moves, gamelogbuf);
strNsubst(gamelogbuf, "\t", "_", 0);
livelog_add(ll_type, gamelogbuf);
}
#else
void
gamelog_add(unsigned int glflags UNUSED, long gltime UNUSED, const char *msg UNUSED)
{
/* nothing here */
}
void
livelog_printf(unsigned int ll_type UNUSED, const char *line UNUSED, ...)
{
/* nothing here */
}
#endif /* !CHRONICLE */
static void vraw_printf(const char *, va_list);
void