fix github issue #687 - logging of major events

Reported by k21971, the dumplog section labeled "major events" showed
all logged events rather than just the ones classified as major.
Filter out the non-major ones when writing dumplog.

At the moment only a couple of ones other than achievements are major.
Probably various other types should be too.

The #chronicle command still lists all logged events unless they're
flagged as 'spoiler'.  So far the mines' end luckstone is the only
one flagged that way.  Unfortunately a player with access to live
logging could still learn whether or not the gray stone that has just
been picked up on the last mines level is the target luckstone by
viewing the log from outside of the game.

The #chronicle command would be more useful if it gathered all the
categories of events present and put up a menu allowing the player to
choose which ones to view.  I haven't attempted to implement that.

Closes #687
This commit is contained in:
PatR
2022-03-01 04:15:55 -08:00
parent 0ac3b08825
commit 77bd50fd77
8 changed files with 96 additions and 64 deletions

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 allmain.c $NHDT-Date: 1645223894 2022/02/18 22:38:14 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.177 $ */
/* NetHack 3.7 allmain.c $NHDT-Date: 1646136934 2022/03/01 12:15:34 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.178 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2012. */
/* NetHack may be freely redistributed. See license for details. */
@@ -761,8 +761,8 @@ welcome(boolean new_game) /* false => restoring an old game */
Hello((struct monst *) 0), g.plname, buf);
l_nhcore_call(new_game ? NHCORE_START_NEW_GAME : NHCORE_RESTORE_OLD_GAME);
if (new_game)
livelog_printf(LL_MINORAC, "%s the%s entered the dungeon",
if (new_game) /* guarantee that 'major' event category is never empty */
livelog_printf(LL_ACHIEVE, "%s the%s entered the dungeon",
g.plname, buf);
}

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 cmd.c $NHDT-Date: 1644610344 2022/02/11 20:12:24 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.519 $ */
/* NetHack 3.7 cmd.c $NHDT-Date: 1646136938 2022/03/01 12:15:38 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.528 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2013. */
/* NetHack may be freely redistributed. See license for details. */
@@ -850,36 +850,6 @@ enter_explore_mode(void)
return ECMD_OK;
}
int
do_gamelog(void)
{
#ifdef CHRONICLE
struct gamelog_line *tmp = g.gamelog;
winid win;
char buf[BUFSZ];
if (!tmp) {
pline("No chronicled events.");
return ECMD_OK;
}
win = create_nhwindow(NHW_TEXT);
putstr(win, 0, "Major events:");
putstr(win, 0, "");
putstr(win, 0, " Turn");
while (tmp) {
Sprintf(buf, "%5li: %s", tmp->turn, tmp->text);
putstr(win, 0, buf);
tmp = tmp->next;
}
display_nhwindow(win, TRUE);
destroy_nhwindow(win);
#else
pline("Chronicle was turned off during compile-time.");
#endif /* !CHRONICLE */
return ECMD_OK;
}
/* #wizwish command - wish for something */
static int
wiz_wish(void) /* Unlimited wishes for debug mode by Paul Polderman */

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 do.c $NHDT-Date: 1646084773 2022/02/28 21:46:13 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.294 $ */
/* NetHack 3.7 do.c $NHDT-Date: 1646136939 2022/03/01 12:15:39 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.295 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Derek S. Ray, 2015. */
/* NetHack may be freely redistributed. See license for details. */
@@ -1759,7 +1759,7 @@ goto_level(
if (!In_quest(&u.uz0) && at_dgn_entrance("The Quest")
&& !(u.uevent.qcompleted || u.uevent.qexpelled
|| g.quest_status.leader_is_dead)) {
/* [TODO: copy of same TODO below; if an anchievement for
/* [TODO: copy of same TODO below; if an achievement for
receiving quest call from leader gets added, that should
come after logging new level entry] */
if (!u.uevent.qcalled) {
@@ -1775,7 +1775,7 @@ goto_level(
/* this was originally done earlier; moved here to be logged after
any achievement related to entering a dungeon branch
[TODO: if an anchievement for receiving quest call from leader
[TODO: if an achievement for receiving quest call from leader
gets added, that should come after this rather than take place
where the message is delivered above] */
if (new)

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 end.c $NHDT-Date: 1646084789 2022/02/28 21:46:29 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.238 $ */
/* NetHack 3.7 end.c $NHDT-Date: 1646136940 2022/03/01 12:15:40 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.239 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2012. */
/* NetHack may be freely redistributed. See license for details. */
@@ -793,7 +793,7 @@ dump_everything(
dump_plines();
putstr(0, 0, "");
(void) do_gamelog();
show_gamelog((how >= PANICKED) ? ENL_GAMEOVERALIVE : ENL_GAMEOVERDEAD);
putstr(0, 0, "");
putstr(0, 0, "Inventory:");
(void) display_inventory((char *) 0, TRUE);
@@ -1393,7 +1393,7 @@ really_done(int how)
/* it would be better to do this after killer.name fixups but
that comes too late; end-of-game is classified as a "major
achievement" even if it happens to be ending in failure */
achievement" even if game happens to be ending in failure */
formatkiller(pbuf, (unsigned) sizeof pbuf, how, TRUE);
if (!*pbuf)
Strcpy(pbuf, deaths[how]);

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 insight.c $NHDT-Date: 1646084789 2022/02/28 21:46:29 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.52 $ */
/* NetHack 3.7 insight.c $NHDT-Date: 1646136941 2022/03/01 12:15:41 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.53 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -62,8 +62,10 @@ static struct ll_achieve_msg achieve_msg [] = {
{ LL_ACHIEVE, "entered the Planes" },
{ LL_ACHIEVE, "entered the Astral Plane" },
{ LL_ACHIEVE, "ascended" },
{ LL_ACHIEVE, "acquired the Mines' End luckstone" },
{ LL_ACHIEVE, "completed Sokoban" },
{ LL_ACHIEVE | LL_SPOILER, "acquired the Mines' End luckstone" },
{ LL_ACHIEVE, "completed Sokoban" }, /* actually, acquired the prize item
* which doesn't necessarily mean all
* four levels have been solved */
{ LL_ACHIEVE | LL_UMONST, "killed Medusa" },
/* these two are not logged */
{ 0, "hero was always blond, no, blind" },
@@ -89,11 +91,12 @@ static struct ll_achieve_msg achieve_msg [] = {
{ LL_ACHIEVE, "" }, /* Xp 22 */
{ LL_ACHIEVE, "" }, /* Xp 26 */
{ LL_ACHIEVE, "" }, /* Xp 30 */
{ LL_MINORAC, "learned castle drawbridge's tune" },
{ LL_MINORAC, "learned castle drawbridge's tune" }, /* achievement #31 */
{ 0, "" } /* keep this one at the end */
};
/* macros to simplify output of enlightenment messages; also used by
conduct and achievements */
#define enl_msg(prefix, present, past, suffix, ps) \
enlght_line(prefix, final ? past : present, suffix, ps)
#define you_are(attr, ps) enl_msg(You_, are, were, attr, ps)
@@ -2360,6 +2363,61 @@ sokoban_in_play(void)
return FALSE;
}
#define majorevent(llmsg) (((llmsg)->flags & LL_ACHIEVE) != 0)
#define spoilerevent(llmsg) (((llmsg)->flags & LL_SPOILER) != 0)
/* #chronicle command */
int
do_gamelog(void)
{
#ifdef CHRONICLE
if (g.gamelog) {
show_gamelog(0);
} else {
pline("No chronicled events.");
}
#else
pline("Chronicle was turned off during compile-time.");
#endif /* !CHRONICLE */
return ECMD_OK;
}
/* #chronicle details */
void
show_gamelog(int final)
{
#ifdef CHRONICLE
struct gamelog_line *llmsg;
winid win;
char buf[BUFSZ];
int eventcnt = 0;
win = create_nhwindow(NHW_TEXT);
Sprintf(buf, "%s events:", final ? "Major" : "Logged");
putstr(win, 0, buf);
for (llmsg = g.gamelog; llmsg; llmsg = llmsg->next) {
if (final && !majorevent(llmsg))
continue;
if (!final && !wizard && spoilerevent(llmsg))
continue;
if (!eventcnt++)
putstr(win, 0, " Turn");
Sprintf(buf, "%5ld: %s", llmsg->turn, llmsg->text);
putstr(win, 0, buf);
}
/* since start of game is logged as a major event, 'eventcnt' should
never end up as 0; for 'final', end of game is a major event too */
if (!eventcnt)
putstr(win, 0, " none");
display_nhwindow(win, TRUE);
destroy_nhwindow(win);
#else
nhUse(final);
#endif /* !CHRONICLE */
return;
}
/*
* Vanquished monsters.
*/