diff --git a/include/extern.h b/include/extern.h index c57639846..71f870426 100644 --- a/include/extern.h +++ b/include/extern.h @@ -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); diff --git a/src/botl.c b/src/botl.c index f5314647c..8ec54885d 100644 --- a/src/botl.c +++ b/src/botl.c @@ -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 */ - Strcat(buf, " "); + if (!addbranch) + (void) strsubst(buf, "Plane of ", ""); /* just keep */ + 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 */ diff --git a/src/do.c b/src/do.c index d00a30f50..8f11b5b53 100644 --- 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 diff --git a/src/insight.c b/src/insight.c index ad94d9eaf..e5e193698 100644 --- a/src/insight.c +++ b/src/insight.c @@ -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."); } diff --git a/src/mon.c b/src/mon.c index 6d08a9afe..d3fef5322 100644 --- 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 monst* mon, 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 monst* mon) +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) diff --git a/src/sp_lev.c b/src/sp_lev.c index 19af374d9..19e1e1e28 100644 --- a/src/sp_lev.c +++ b/src/sp_lev.c @@ -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)); } diff --git a/src/steed.c b/src/steed.c index bbca3f729..00b8b614c 100644 --- a/src/steed.c +++ b/src/steed.c @@ -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?", diff --git a/win/Qt/qt_stat.cpp b/win/Qt/qt_stat.cpp index f5b03fd0f..6e33f7752 100644 --- a/win/Qt/qt_stat.cpp +++ b/win/Qt/qt_stat.cpp @@ -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)); } diff --git a/win/X11/winstat.c b/win/X11/winstat.c index 87d6b7be3..ed7669bda 100644 --- a/win/X11/winstat.c +++ b/win/X11/winstat.c @@ -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)); } diff --git a/win/curses/cursstat.c b/win/curses/cursstat.c index be4c57c50..a47abb287 100644 --- a/win/curses/cursstat.c +++ b/win/curses/cursstat.c @@ -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;