]> granicus.if.org Git - nethack/commitdiff
livelog level entry events
authorPatR <rankin@nethack.org>
Tue, 1 Mar 2022 21:53:57 +0000 (13:53 -0800)
committerPatR <rankin@nethack.org>
Tue, 1 Mar 2022 21:53:57 +0000 (13:53 -0800)
Fix up the level descriptions used when logging an "entered new level"
event.  Most of the change is for adding an extra argument to calls
to describe_level().  The curses portion is in a big chunk of old code
suppressed by #if 0.

I didn't notice that the level entry events are classified as LL_DEBUG
until all the work was done.  This promotes the entry events for the
four Plane of <Element> levels from debug events to major ones instead.
It doesn't do that for the Astral Plane because the entered-the-Astral-
Plane achievement already produces a major event for that.  Most other
key level entry events are in a similar situation--or will become that
way once another set of achievements eventually gets added--so there
aren't any other event classification promotions.

include/extern.h
src/botl.c
src/do.c
src/insight.c
src/mon.c
src/sp_lev.c
src/steed.c
win/Qt/qt_stat.cpp
win/X11/winstat.c
win/curses/cursstat.c

index c576398466dbbd0c3dbf2432ebacc2940e226346..71f8704266bc654a91dddd36b4fcc29602e1cb96 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.7 extern.h        $NHDT-Date: 1646136928 2022/03/01 12:15:28 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.1062 $ */
+/* NetHack 3.7 extern.h        $NHDT-Date: 1646171621 2022/03/01 21:53:41 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.1063 $ */
 /* Copyright (c) Steve Creps, 1988.                              */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -180,7 +180,7 @@ extern void max_rank_sz(void);
 #ifdef SCORE_ON_BOTL
 extern long botl_score(void);
 #endif
-extern int describe_level(char *);
+extern int describe_level(char *, int);
 extern void status_initialize(boolean);
 extern void status_finish(void);
 extern boolean exp_percent_changing(void);
index f5314647c6ddc87da97e30f972dcbaf8ee2e8d65..8ec54885d9fadfd9ac101429afb74a5f3b8bf1a3 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.7 botl.c  $NHDT-Date: 1606765211 2020/11/30 19:40:11 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.193 $ */
+/* NetHack 3.7 botl.c  $NHDT-Date: 1646171622 2022/03/01 21:53:42 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.209 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Michael Allison, 2006. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -128,7 +128,7 @@ do_statusline2(void)
      */
 
     /* dungeon location plus gold */
-    (void) describe_level(dloc); /* includes at least one trailing space */
+    (void) describe_level(dloc, 1); /* includes at least one trailing space */
     if ((money = money_cnt(g.invent)) < 0L)
         money = 0L; /* ought to issue impossible() and then discard gold */
     Sprintf(eos(dloc), "%s:%-2ld", /* strongest hero can lift ~300000 gold */
@@ -423,25 +423,39 @@ botl_score(void)
 
 /* provide the name of the current level for display by various ports */
 int
-describe_level(char *buf)
+describe_level(
+    char *buf, /* output buffer */
+    int dflgs) /* 1: append trailing space; 2: include dungeon branch name */
 {
+    boolean addspace = (dflgs & 1) != 0,  /* (used to be unconditional) */
+            addbranch = (dflgs & 2) != 0; /* False: status, True: livelog */
     int ret = 1;
 
-    /* TODO:    Add in dungeon name */
     if (Is_knox(&u.uz)) {
-        Sprintf(buf, "%s ", g.dungeons[u.uz.dnum].dname);
+        Sprintf(buf, "%s", g.dungeons[u.uz.dnum].dname);
+        addbranch = FALSE;
     } else if (In_quest(&u.uz)) {
-        Sprintf(buf, "Home %d ", dunlev(&u.uz));
+        Sprintf(buf, "Home %d", dunlev(&u.uz));
     } else if (In_endgame(&u.uz)) {
         /* [3.6.2: this used to be "Astral Plane" or generic "End Game"] */
         (void) endgamelevelname(buf, depth(&u.uz));
-        (void) strsubst(buf, "Plane of ", ""); /* just keep <element> */
-        Strcat(buf, " ");
+        if (!addbranch)
+            (void) strsubst(buf, "Plane of ", ""); /* just keep <element> */
+        addbranch = FALSE;
     } else {
         /* ports with more room may expand this one */
-        Sprintf(buf, "Dlvl:%-2d ", depth(&u.uz));
+        if (!addbranch)
+            Sprintf(buf, "Dlvl:%-2d", depth(&u.uz));
+        else
+            Sprintf(buf, "level %d", depth(&u.uz));
         ret = 0;
     }
+    if (addbranch) {
+        Sprintf(eos(buf), ", %s", g.dungeons[u.uz.dnum].dname);
+        (void) strsubst(buf, "The ", "the ");
+    }
+    if (addspace)
+        Strcat(buf, " ");
     return ret;
 }
 
@@ -779,7 +793,7 @@ bot_via_windowport(void)
     g.blstats[idx][BL_HPMAX].a.a_int = min(i, 9999);
 
     /*  Dungeon level. */
-    (void) describe_level(g.blstats[idx][BL_LEVELDESC].val);
+    (void) describe_level(g.blstats[idx][BL_LEVELDESC].val, 1);
     g.valset[BL_LEVELDESC] = TRUE; /* indicate val already set */
 
     /* Gold */
index d00a30f5072a83dfaf3ec8ea8d4a02a70d5abb18..8f11b5b53d9c4adc3f573d1ad1e8d9724f08b194 100644 (file)
--- a/src/do.c
+++ b/src/do.c
@@ -1,4 +1,4 @@
-/* NetHack 3.7 do.c    $NHDT-Date: 1646136939 2022/03/01 12:15:39 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.295 $ */
+/* NetHack 3.7 do.c    $NHDT-Date: 1646171623 2022/03/01 21:53:43 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.296 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Derek S. Ray, 2015. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -1778,15 +1778,15 @@ goto_level(
        [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)
-        /* FIXME: this shows level number relative to the start of the
-           branch (so "entered new level 3, Vlad's Tower" when going
-           into the first level of that branch); it should be changed
-           to show the level number that appears on the status lines;
-           also in the endgame it shows arbitrary level number instead
-           of elemental plane name */
-        livelog_printf(LL_DEBUG, "entered new level %d, %s",
-                       dunlev(&u.uz), g.dungeons[u.uz.dnum].dname);
+    if (new) {
+        char dloc[QBUFSZ];
+        /* Astral is excluded as a major event here because entry to it
+           is already one due to that being an achievement */
+        boolean major = In_endgame(&u.uz) && !Is_astralevel(&u.uz);
+
+        (void) describe_level(dloc, 2);
+        livelog_printf(major ? LL_ACHIEVE : LL_DEBUG, "entered %s", dloc);
+    }
 
     assign_level(&u.uz0, &u.uz); /* reset u.uz0 */
 #ifdef INSURANCE
index ad94d9eaf552877c433eb6de017f51cee66d970e..e5e19369861bb95108f39c66f2dad5f92309934e 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.7 insight.c       $NHDT-Date: 1646136941 2022/03/01 12:15:41 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.53 $ */
+/* NetHack 3.7 insight.c       $NHDT-Date: 1646171624 2022/03/01 21:53:44 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.54 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -59,7 +59,7 @@ static struct ll_achieve_msg achieve_msg [] = {
     { LL_ACHIEVE, "acquired the Book of the Dead" },
     { LL_ACHIEVE, "performed the invocation" },
     { LL_ACHIEVE, "acquired The Amulet of Yendor" },
-    { LL_ACHIEVE, "entered the Planes" },
+    { LL_ACHIEVE, "entered the Elemental Planes" },
     { LL_ACHIEVE, "entered the Astral Plane" },
     { LL_ACHIEVE, "ascended" },
     { LL_ACHIEVE | LL_SPOILER, "acquired the Mines' End luckstone" },
@@ -1957,7 +1957,7 @@ youhiding(boolean via_enlghtmt, /* englightment line vs topl message */
 int
 doconduct(void)
 {
-    show_conduct(0);
+    show_conduct(ENL_GAMEINPROGRESS);
     return ECMD_OK;
 }
 
@@ -2372,7 +2372,7 @@ do_gamelog(void)
 {
 #ifdef CHRONICLE
     if (g.gamelog) {
-        show_gamelog(0);
+        show_gamelog(ENL_GAMEINPROGRESS);
     } else {
         pline("No chronicled events.");
     }
index 6d08a9afe3b1715f3523118ffcd7eadf0abb1fb7..d3fef53225e4c9e8cf21afe5a6dc89e7fed0229b 100644 (file)
--- a/src/mon.c
+++ b/src/mon.c
@@ -1,4 +1,4 @@
-/* NetHack 3.7 mon.c   $NHDT-Date: 1629817677 2021/08/24 15:07:57 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.384 $ */
+/* NetHack 3.7 mon.c   $NHDT-Date: 1646171625 2022/03/01 21:53:45 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.410 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Derek S. Ray, 2015. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -2078,7 +2078,7 @@ mm_displacement(
 
 /* Is the square close enough for the monster to move or attack into? */
 boolean
-monnear(struct monstmon, int x, int y)
+monnear(struct monst *mon, int x, int y)
 {
     int distance = dist2(mon->mx, mon->my, x, y);
 
@@ -2108,7 +2108,7 @@ dmonsfree(void)
     }
 
     if (count != iflags.purge_monsters) {
-        describe_level(buf);
+        describe_level(buf, 2);
         impossible("dmonsfree: %d removed doesn't match %d pending on %s",
                    count, iflags.purge_monsters, buf);
     }
@@ -2117,7 +2117,7 @@ dmonsfree(void)
 
 /* called when monster is moved to larger structure */
 void
-replmon(struct monst* mtmp, struct monst* mtmp2)
+replmon(struct monst *mtmp, struct monst *mtmp2)
 {
     struct obj *otmp;
 
@@ -2287,13 +2287,13 @@ dealloc_mextra(struct monst* m)
 }
 
 void
-dealloc_monst(struct monstmon)
+dealloc_monst(struct monst *mon)
 {
     char buf[QBUFSZ];
 
     buf[0] = '\0';
     if (mon->nmon) {
-        describe_level(buf);
+        describe_level(buf, 2);
         panic("dealloc_monst with nmon on %s", buf);
     }
     if (mon->mextra)
index 19af374d9031b5f25286227557c973fcd36ba059..19e1e1e2863dfceb25736ee6b598ed3fde4c5c6c 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.7 sp_lev.c        $NHDT-Date: 1622361654 2021/05/30 08:00:54 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.233 $ */
+/* NetHack 3.7 sp_lev.c        $NHDT-Date: 1646171627 2022/03/01 21:53:47 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.257 $ */
 /*      Copyright (c) 1989 by Jean-Christophe Collet */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -2291,7 +2291,7 @@ create_object(object* o, struct mkroom* croom)
         } else if (!iflags.lua_testing) {
             char lbuf[QBUFSZ];
 
-            (void) describe_level(lbuf); /* always has a trailing space */
+            (void) describe_level(lbuf, 1 | 2);
             impossible("create_object: unknown achievement (%s\"%s\")",
                        lbuf, simpleonames(otmp));
         }
index bbca3f7293656399ace4b28e2a0456eeed138a76..00b8b614c31b14776f5da378c3defef6bb4e3c28 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.7 steed.c $NHDT-Date: 1582155885 2020/02/19 23:44:45 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.79 $ */
+/* NetHack 3.7 steed.c $NHDT-Date: 1646171628 2022/03/01 21:53:48 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.95 $ */
 /* Copyright (c) Kevin Hugo, 1998-1999. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -760,7 +760,7 @@ place_monster(struct monst* mon, int x, int y)
     /* normal map bounds are <1..COLNO-1,0..ROWNO-1> but sometimes
        vault guards (either living or dead) are parked at <0,0> */
     if (!isok(x, y) && (x != 0 || y != 0 || !mon->isgd)) {
-        describe_level(buf);
+        describe_level(buf, 0);
         impossible("trying to place %s at <%d,%d> mstate:%lx on %s",
                    minimal_monnam(mon, TRUE), x, y, mon->mstate, buf);
         x = y = 0;
@@ -768,14 +768,14 @@ place_monster(struct monst* mon, int x, int y)
     if (mon == u.usteed
         /* special case is for convoluted vault guard handling */
         || (DEADMONSTER(mon) && !(mon->isgd && x == 0 && y == 0))) {
-        describe_level(buf);
+        describe_level(buf, 0);
         impossible("placing %s onto map, mstate:%lx, on %s?",
                    (mon == u.usteed) ? "steed" : "defunct monster",
                    mon->mstate, buf);
         return;
     }
     if ((othermon = g.level.monsters[x][y]) != 0) {
-        describe_level(buf);
+        describe_level(buf, 0);
         monnm = minimal_monnam(mon, FALSE);
         othnm = (mon != othermon) ? minimal_monnam(othermon, TRUE) : "itself";
         impossible("placing %s over %s at <%d,%d>, mstates:%lx %lx on %s?",
index f5b03fd0f7f6fb3a478518dfe3acd4159098feea..6e33f7752e8a655c5ceb98c4b40e6a9379fa4286 100644 (file)
@@ -812,7 +812,7 @@ void NetHackQtStatusWindow::updateStats()
                  buf.toLatin1().constData());
     name.setLabel(buf2, NetHackQtLabelledIcon::NoNum, u.ulevel);
 
-    if (!describe_level(buf3)) {
+    if (!describe_level(buf3, 0)) {
        Sprintf(buf3, "%s, level %d",
                 g.dungeons[u.uz.dnum].dname, ::depth(&u.uz));
     }
index 87d6b7be37eeee9fbcfea7427a9d1aca414fa693..ed7669bda2bafdf585869c1f599b30efed3c762d 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.7 winstat.c       $NHDT-Date: 1641763638 2022/01/09 21:27:18 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.35 $ */
+/* NetHack 3.7 winstat.c       $NHDT-Date: 1646171629 2022/03/01 21:53:49 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.36 $ */
 /* Copyright (c) Dean Luick, 1992                                */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -1481,7 +1481,7 @@ update_val(struct X_status_value *attr_rec, long new_value)
                        rank_of(u.ulevel, g.pl_character[0], flags.female));
 
         } else if (attr_rec == &shown_stats[F_DLEVEL]) {
-            if (!describe_level(buf)) {
+            if (!describe_level(buf, 0)) {
                 Strcpy(buf, g.dungeons[u.uz.dnum].dname);
                 Sprintf(eos(buf), ", level %d", depth(&u.uz));
             }
index be4c57c50e9b6feebde03e801aae78ec67610209..a47abb2874d3cf0062bb59c97ab14806d4c2e70c 100644 (file)
@@ -1639,7 +1639,8 @@ curses_color_attr(int nh_color, int bg_color)
     return cattr;
 }
 
-/* Returns a complete curses attribute. Used to possibly bold/underline/etc HP/Pw. */
+/* Returns a complete curses attribute.
+   Used to possibly bold/underline/etc HP/Pw. */
 #ifdef STATUS_COLORS
 static attr_t
 hpen_color_attr(boolean is_hp, int cur, int max)
@@ -1665,17 +1666,18 @@ hpen_color_attr(boolean is_hp, int cur, int max)
 #endif
 
 /* Return color for the HP bar.
-   With status colors ON, this respect its configuration (defaulting to gray), but
-   only obeys the color (no weird attributes for the HP bar).
-   With status colors OFF, this returns reasonable defaults which are also used
-   for the HP/Pw text itself. */
+   With status colors ON, this respect its configuration (defaulting to gray),
+   but only obeys the color (no weird attributes for the HP bar).
+   With status colors OFF, this returns reasonable defaults which are also
+   used for the HP/Pw text itself. */
 static int
 hpen_color(boolean is_hp, int cur, int max)
 {
 #ifdef STATUS_COLORS
     if (iflags.use_status_colors) {
         struct color_option stat_color;
-        stat_color = percentage_color_of(cur, max, is_hp ? hp_colors : pw_colors);
+        stat_color = percentage_color_of(cur, max,
+                                         is_hp ? hp_colors : pw_colors);
 
         if (stat_color.color == NO_COLOR)
             return CLR_GRAY;
@@ -1872,7 +1874,7 @@ draw_horizontal(int x, int y, int hp, int hpmax)
     y++;
     wmove(win, y, x);
 
-    describe_level(buf);
+    describe_level(buf, 0);
 
     wprintw(win, "%s", buf);
 
@@ -2135,7 +2137,8 @@ draw_vertical(int x, int y, int hp, int hpmax)
     wmove(win, y++, x);
 
     if (Upolyd)
-        print_statdiff("Hit Dice:      ", &prevlevel, mons[u.umonnum].mlevel, STAT_OTHER);
+        print_statdiff("Hit Dice:      ", &prevlevel, mons[u.umonnum].mlevel,
+                       STAT_OTHER);
     else if (flags.showexp) {
         print_statdiff("Experience:    ", &prevlevel, u.ulevel, STAT_OTHER);
         /* use waddch, we don't want to highlight the '/' */
@@ -2153,7 +2156,8 @@ draw_vertical(int x, int y, int hp, int hpmax)
 
 #ifdef SCORE_ON_BOTL
     if (flags.showscore) {
-        print_statdiff("Score:         ", &prevscore, botl_score(), STAT_OTHER);
+        print_statdiff("Score:         ", &prevscore, botl_score(),
+                       STAT_OTHER);
         wmove(win, y++, x);
     }
 #endif /* SCORE_ON_BOTL */
@@ -2178,7 +2182,7 @@ curses_add_statuses(WINDOW *win, boolean align_right,
         *x = mx;
     }
 
-#define statprob(str, trouble)                                  \
+#define statprob(str, trouble) \
     curses_add_status(win, align_right, vertical, x, y, str, trouble)
 
     /* Hunger */
@@ -2214,7 +2218,8 @@ curses_add_status(WINDOW *win, boolean align_right, boolean vertical,
     if (!vertical && !align_right)
         waddch(win, ' ');
 
-    /* For whatever reason, hunger states have trailing spaces. Get rid of them. */
+    /* For whatever reason, hunger states have trailing spaces. Get rid of
+       them. */
     char buf[BUFSZ];
     Strcpy(buf, str);
     int i;