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:
@@ -30,6 +30,7 @@ static void ghostfruit(struct obj *);
|
||||
static boolean restgamestate(NHFILE *, unsigned int *, unsigned int *);
|
||||
static void restlevelstate(unsigned int, unsigned int);
|
||||
static int restlevelfile(xchar);
|
||||
static void restore_gamelog(NHFILE *);
|
||||
static void restore_msghistory(NHFILE *);
|
||||
static void reset_oattached_mids(boolean);
|
||||
static void rest_levl(NHFILE *, boolean);
|
||||
@@ -697,6 +698,7 @@ restgamestate(NHFILE* nhfp, unsigned int* stuckid, unsigned int* steedid)
|
||||
restnames(nhfp);
|
||||
restore_waterlevel(nhfp);
|
||||
restore_msghistory(nhfp);
|
||||
restore_gamelog(nhfp);
|
||||
/* must come after all mons & objs are restored */
|
||||
relink_timers(FALSE);
|
||||
relink_light_sources(FALSE);
|
||||
@@ -1233,6 +1235,29 @@ get_plname_from_file(NHFILE* nhfp, char *plbuf)
|
||||
return;
|
||||
}
|
||||
|
||||
static void
|
||||
restore_gamelog(NHFILE* nhfp)
|
||||
{
|
||||
int slen = 0;
|
||||
char msg[BUFSZ*2];
|
||||
struct gamelog_line tmp;
|
||||
|
||||
while (1) {
|
||||
if (nhfp->structlevel)
|
||||
mread(nhfp->fd, (genericptr_t)&slen, sizeof(slen));
|
||||
if (slen == -1)
|
||||
break;
|
||||
if (slen > ((BUFSZ*2) - 1))
|
||||
panic("restore_gamelog: msg too big (%d)", slen);
|
||||
if (nhfp->structlevel) {
|
||||
mread(nhfp->fd, (genericptr_t) msg, slen);
|
||||
mread(nhfp->fd, (genericptr_t) &tmp, sizeof(tmp));
|
||||
msg[slen] = '\0';
|
||||
gamelog_add(tmp.flags, tmp.turn, msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
restore_msghistory(NHFILE* nhfp)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user