From 83410a3d4fd816aad05dca0555a125fdf9af2341 Mon Sep 17 00:00:00 2001 From: PatR Date: Sun, 23 Jun 2019 11:31:21 -0700 Subject: [PATCH 1/2] \#wizidentify bug - 'Not carrying anything.' when carrying things. The fuzzer toggled on 'perm_invent' and after interrupting it I used ^I. Having 'perm_invent' enabled makes the inventory code avoid having a totally empty inventory display (by supplying "Not carrying anything" instead--in the menu rather than via normal pline) so that interface code will see a change and know that an update is needed. But to decide whether the menu was empty, the inventory code was testing union 'any' field 'a_char' to check whether some item had used the union (implying that something had been passed to add_menu()), but wizidentify (^I) uses field 'a_obj' instead. Apparently the a_char bits stayed 0 because the menu ended up with "Not carrying anything" after a list of inventory items. Switch to a separate variable to track whether anything has been put into the menu instead of trying to rely on the union. Unrelated but noticed when checking other "Not carrying anything" instances, the #adjust command ends early when there's no inventory but it was asking for a letter to adjust even when the only thing in inventory was gold in '$' slot, which isn't allowed to be adjusted away from that slot. Treat gold-only like no-invent. --- doc/fixes36.3 | 5 ++++- src/invent.c | 25 ++++++++++++++++--------- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/doc/fixes36.3 b/doc/fixes36.3 index bbc324668..c71dc5bb6 100644 --- a/doc/fixes36.3 +++ b/doc/fixes36.3 @@ -1,4 +1,4 @@ -$NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.64 $ $NHDT-Date: 1561233801 2019/06/22 20:03:21 $ +$NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.65 $ $NHDT-Date: 1561314651 2019/06/23 18:30:51 $ This fixes36.3 file is here to capture information about updates in the 3.6.x lineage following the release of 3.6.2 in May 2019. Please note, however, @@ -84,6 +84,9 @@ partly eaten food with one bite left had message anomalies when eaten; the usual "you resume your meal" case lacked the "you're finished" message when done; eating something else in between to clobber meal context resulted in no messages at all when restarting and finishing last bite +wizard mode ^I menu could list "Not carrying anything" after inventory items + if perm_invent option was On (even on tty where that's not supported) +change #adjust to treat carrying only gold as not having anything to adjust Fixes to Post-3.6.2 Problems that Were Exposed Via git Repository diff --git a/src/invent.c b/src/invent.c index 94e0053ca..a4175e2a8 100644 --- a/src/invent.c +++ b/src/invent.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 invent.c $NHDT-Date: 1558234540 2019/05/19 02:55:40 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.258 $ */ +/* NetHack 3.6 invent.c $NHDT-Date: 1561314651 2019/06/23 18:30:51 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.259 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Derek S. Ray, 2015. */ /* NetHack may be freely redistributed. See license for details. */ @@ -2550,7 +2550,7 @@ long *out_cnt; menu_item *selected; unsigned sortflags; Loot *sortedinvent, *srtinv; - boolean wizid = FALSE; + boolean wizid = FALSE, gotsomething = FALSE; if (lets && !*lets) lets = 0; /* simplify tests: (lets) instead of (lets && *lets) */ @@ -2654,13 +2654,14 @@ long *out_cnt; /* wiz_identify stuffed the wiz_identify command character (^I) into iflags.override_ID for our use as an accelerator; it could be ambiguous if player has assigned a letter to - the #wizidentify command */ + the #wizidentify command, so include it as a group accelator + but use '_' as the primary selector */ if (unid_cnt > 1) Sprintf(eos(prompt), " (%s for all)", visctrl(iflags.override_ID)); add_menu(win, NO_GLYPH, &any, '_', iflags.override_ID, ATR_NONE, prompt, MENU_UNSELECTED); - wizid = TRUE; + wizid = gotsomething = TRUE; } } else if (xtra_choice) { /* wizard override ID and xtra_choice are mutually exclusive */ @@ -2670,6 +2671,7 @@ long *out_cnt; any.a_char = HANDS_SYM; /* '-' */ add_menu(win, NO_GLYPH, &any, HANDS_SYM, 0, ATR_NONE, xtra_choice, MENU_UNSELECTED); + gotsomething = TRUE; } nextclass: classcount = 0; @@ -2695,6 +2697,7 @@ long *out_cnt; add_menu(win, obj_to_glyph(otmp, rn2_on_display_rng), &any, ilet, wizid ? def_oc_syms[(int) otmp->oclass].sym : 0, ATR_NONE, doname(otmp), MENU_UNSELECTED); + gotsomething = TRUE; } } if (flags.sortpack) { @@ -2712,13 +2715,14 @@ long *out_cnt; any.a_char = '*'; add_menu(win, NO_GLYPH, &any, '*', 0, ATR_NONE, "(list everything)", MENU_UNSELECTED); + gotsomething = TRUE; } unsortloot(&sortedinvent); /* for permanent inventory where we intend to show everything but nothing has been listed (because there isn't anyhing to list; - recognized via any.a_char still being zero; the n==0 case above - gets skipped for perm_invent), put something into the menu */ - if (iflags.perm_invent && !lets && !any.a_char) { + the n==0 case above gets skipped for perm_invent), put something + into the menu */ + if (iflags.perm_invent && !lets && !gotsomething) { any = zeroany; add_menu(win, NO_GLYPH, &any, 0, 0, 0, not_carrying_anything, MENU_UNSELECTED); @@ -4016,8 +4020,11 @@ doorganize() /* inventory organizer by Del Lamb */ const char *adj_type; boolean ever_mind = FALSE, collect; - if (!invent) { - You("aren't carrying anything to adjust."); + /* when no invent, or just gold in '$' slot, there's nothing to adjust */ + if (!invent || (invent->oclass == COIN_CLASS + && invent->invlet == GOLD_SYM && !invent->nobj)) { + You("aren't carrying anything %s.", + !invent ? "to adjust" : "adjustable"); return 0; } From 68d28bd7484de3bda3861ccae48b29f8119edf2e Mon Sep 17 00:00:00 2001 From: PatR Date: Sun, 23 Jun 2019 17:27:15 -0700 Subject: [PATCH 2/2] level overcrowding tweaks A couple changes dealing with overcrowded levels. So many monsters are moving from the Plane of Water to the Astral Plane that the latter can start out completely full. Give monsters who trigger the endgame portals a 6/7 chance to not go through ('home' elementals or any monster carrying the Amulet already wouldn't go through). They should learn about magic portal trap in the process and not voluntarily step on that afterward. When the Wizard or other covetous monster tries to teleport next to the hero and fails, he was being sent to limbo. There's no need for that; he's already on the map and can just stay where he is. That doesn't actually help with the endgame population issue, it just fixes a couple of uses of mnearto(). I have significant changes for mnearto() and elemental_clog() that also help with this but will test those more before committing. --- src/teleport.c | 7 ++++--- src/wizard.c | 25 +++++++++++++++---------- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/src/teleport.c b/src/teleport.c index 61ca40fa7..100a74d3b 100644 --- a/src/teleport.c +++ b/src/teleport.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 teleport.c $NHDT-Date: 1559733391 2019/06/05 11:16:31 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.88 $ */ +/* NetHack 3.6 teleport.c $NHDT-Date: 1561336020 2019/06/24 00:27:00 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.89 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2011. */ /* NetHack may be freely redistributed. See license for details. */ @@ -1353,8 +1353,9 @@ int in_sight; get_level(&tolevel, depth(&u.uz) + 1); } } else if (tt == MAGIC_PORTAL) { - if (In_endgame(&u.uz) - && (mon_has_amulet(mtmp) || is_home_elemental(mtmp->data))) { + if (In_endgame(&u.uz) && (mon_has_amulet(mtmp) + || is_home_elemental(mtmp->data) + || rn2(7))) { if (in_sight && mtmp->data->mlet != S_ELEMENTAL) { pline("%s seems to shimmer for a moment.", Monnam(mtmp)); seetrap(trap); diff --git a/src/wizard.c b/src/wizard.c index df64a4d2d..b1dae1e59 100644 --- a/src/wizard.c +++ b/src/wizard.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 wizard.c $NHDT-Date: 1539804905 2018/10/17 19:35:05 $ $NHDT-Branch: keni-makedefsm $:$NHDT-Revision: 1.53 $ */ +/* NetHack 3.6 wizard.c $NHDT-Date: 1561336025 2019/06/24 00:27:05 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.56 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2016. */ /* NetHack may be freely redistributed. See license for details. */ @@ -356,7 +356,6 @@ xchar *sy; *sx = x; *sy = y; } - } int @@ -364,28 +363,33 @@ tactics(mtmp) register struct monst *mtmp; { unsigned long strat = strategy(mtmp); - xchar sx = 0, sy = 0; + xchar sx = 0, sy = 0, mx, my; mtmp->mstrategy = (mtmp->mstrategy & (STRAT_WAITMASK | STRAT_APPEARMSG)) | strat; switch (strat) { case STRAT_HEAL: /* hide and recover */ + mx = mtmp->mx, my = mtmp->my; /* if wounded, hole up on or near the stairs (to block them) */ choose_stairs(&sx, &sy); mtmp->mavenge = 1; /* covetous monsters attack while fleeing */ - if (In_W_tower(mtmp->mx, mtmp->my, &u.uz) + if (In_W_tower(mx, my, &u.uz) || (mtmp->iswiz && !sx && !mon_has_amulet(mtmp))) { if (!rn2(3 + mtmp->mhp / 10)) (void) rloc(mtmp, TRUE); - } else if (sx && (mtmp->mx != sx || mtmp->my != sy)) { + } else if (sx && (mx != sx || my != sy)) { if (!mnearto(mtmp, sx, sy, TRUE)) { - m_into_limbo(mtmp); + /* couldn't move to the target spot for some reason, + so stay where we are (don't actually need rloc_to() + because mtmp is still on the map at ... */ + rloc_to(mtmp, mx, my); return 0; } + mx = mtmp->mx, my = mtmp->my; /* update cached location */ } /* if you're not around, cast healing spells */ - if (distu(mtmp->mx, mtmp->my) > (BOLT_LIM * BOLT_LIM)) + if (distu(mx, my) > (BOLT_LIM * BOLT_LIM)) if (mtmp->mhp <= mtmp->mhpmax - 8) { mtmp->mhp += rnd(8); return 1; @@ -435,12 +439,13 @@ register struct monst *mtmp; return 0; } } else { /* a monster has it - 'port beside it. */ + mx = mtmp->mx, my = mtmp->my; if (!mnearto(mtmp, tx, ty, FALSE)) - m_into_limbo(mtmp); + rloc_to(mtmp, mx, my); /* no room? stay put */ return 0; } - } - } + } /* default case */ + } /* switch */ /*NOTREACHED*/ return 0; }