diff --git a/doc/fixes3-7-0.txt b/doc/fixes3-7-0.txt index 862456ef5..754291cfb 100644 --- a/doc/fixes3-7-0.txt +++ b/doc/fixes3-7-0.txt @@ -1,4 +1,4 @@ -NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.806 $ $NHDT-Date: 1645298657 2022/02/19 19:24:17 $ +NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.835 $ $NHDT-Date: 1646136928 2022/03/01 12:15:28 $ General Fixes and Modified Features ----------------------------------- @@ -1071,6 +1071,7 @@ counting "just picked up" items when deciding what pseudo-classes should be an uninitialized varaible changes to stair internals resulted in summoned Kops blockcading the stairs up rather than intended stairs down +dumplog's list of "major events" showed all logged events, not just major ones curses: 'msg_window' option wasn't functional for curses unless the binary also included tty support diff --git a/include/extern.h b/include/extern.h index 9fb0597ba..c57639846 100644 --- a/include/extern.h +++ b/include/extern.h @@ -1,4 +1,4 @@ -/* NetHack 3.7 extern.h $NHDT-Date: 1644524039 2022/02/10 20:13:59 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.1046 $ */ +/* NetHack 3.7 extern.h $NHDT-Date: 1646136928 2022/03/01 12:15:28 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.1062 $ */ /* Copyright (c) Steve Creps, 1988. */ /* NetHack may be freely redistributed. See license for details. */ @@ -263,7 +263,6 @@ extern void rhack(char *); extern int doextlist(void); extern int extcmd_via_menu(void); extern int enter_explore_mode(void); -extern int do_gamelog(void); extern boolean bind_key(uchar, const char *); extern void dokeylist(void); extern int xytod(schar, schar); @@ -1039,6 +1038,8 @@ extern boolean remove_achievement(schar); extern int count_achievements(void); extern schar achieve_rank(int); extern boolean sokoban_in_play(void); +extern int do_gamelog(void); +extern void show_gamelog(int); extern int dovanquished(void); extern int doborn(void); extern void list_vanquished(char, boolean); diff --git a/include/global.h b/include/global.h index 1aea2e939..39c7e13d2 100644 --- a/include/global.h +++ b/include/global.h @@ -1,4 +1,4 @@ -/* NetHack 3.7 global.h $NHDT-Date: 1642630918 2022/01/19 22:21:58 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.131 $ */ +/* NetHack 3.7 global.h $NHDT-Date: 1646136933 2022/03/01 12:15:33 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.134 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Michael Allison, 2006. */ /* NetHack may be freely redistributed. See license for details. */ @@ -464,20 +464,22 @@ extern struct nomakedefs_s nomakedefs; #define unmeta(c) (0x7f & (c)) /* Game log message type flags */ -#define LL_NONE 0x0000 /* No message is livelogged */ -#define LL_WISH 0x0001 /* Report stuff people type at the wish prompt */ -#define LL_ACHIEVE 0x0002 /* Achievements bitfield + invocation, planes */ -#define LL_UMONST 0x0004 /* Kill, Bribe or otherwise dispatch unique monsters */ -#define LL_DIVINEGIFT 0x0008 /* Sacrifice gifts, crowning */ -#define LL_LIFESAVE 0x0010 /* Use up amulet of lifesaving */ -#define LL_CONDUCT 0x0020 /* Break conduct - not reported early-game */ -#define LL_ARTIFACT 0x0040 /* Excalibur, Sting, Orcrist, plus sac gifts and artwishes */ -#define LL_GENOCIDE 0x0080 /* Logging of genocides */ -#define LL_KILLEDPET 0x0100 /* Killed a tame monster */ -#define LL_ALIGNMENT 0x0200 /* changed alignment temporarily or permanently */ -#define LL_DUMP_ASC 0x0400 /* Log URL for dumplog if ascended */ -#define LL_DUMP_ALL 0x0800 /* Log dumplog url for all games */ -#define LL_MINORAC 0x1000 /* Log 'minor' achievements - can be spammy */ -#define LL_DEBUG 0x8000 /* For debugging messages and other spam */ +#define LL_NONE 0x0000L /* No message is livelogged */ +#define LL_WISH 0x0001L /* Report stuff people type at the wish prompt */ +#define LL_ACHIEVE 0x0002L /* Achievements bitfield + invocation, planes */ +#define LL_UMONST 0x0004L /* defeated unique monster */ +#define LL_DIVINEGIFT 0x0008L /* Sacrifice gifts, crowning */ +#define LL_LIFESAVE 0x0010L /* Use up amulet of lifesaving */ +#define LL_CONDUCT 0x0020L /* Break conduct - not reported early-game */ +#define LL_ARTIFACT 0x0040L /* bestowed, found, or manifactured */ +#define LL_GENOCIDE 0x0080L /* Logging of genocides */ +#define LL_KILLEDPET 0x0100L /* Killed a tame monster */ +#define LL_ALIGNMENT 0x0200L /* changed alignment, temporary or permanent */ +#define LL_DUMP_ASC 0x0400L /* Log URL for dumplog if ascended */ +#define LL_DUMP_ALL 0x0800L /* Log dumplog url for all games */ +#define LL_MINORAC 0x1000L /* Log 'minor' achievements - can be spammy */ +#define LL_SPOILER 0x4000L /* reveals information so don't show in-game + * via #chronicle unless in wizard mode */ +#define LL_DEBUG 0x8000L /* For debugging messages and other spam */ #endif /* GLOBAL_H */ diff --git a/src/allmain.c b/src/allmain.c index 7e8839799..c0fda578b 100644 --- a/src/allmain.c +++ b/src/allmain.c @@ -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); } diff --git a/src/cmd.c b/src/cmd.c index 2fb413438..09c85b5f2 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -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 */ diff --git a/src/do.c b/src/do.c index 32b57f180..d00a30f50 100644 --- a/src/do.c +++ b/src/do.c @@ -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) diff --git a/src/end.c b/src/end.c index 1236134c8..84c9b7d94 100644 --- a/src/end.c +++ b/src/end.c @@ -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]); diff --git a/src/insight.c b/src/insight.c index abc3bfd77..ad94d9eaf 100644 --- a/src/insight.c +++ b/src/insight.c @@ -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. */