diff --git a/doc/fixes36.2 b/doc/fixes36.2 index d7348a2ee..b4437d63a 100644 --- a/doc/fixes36.2 +++ b/doc/fixes36.2 @@ -289,6 +289,10 @@ diluted potion of oil is less effective when filling lamps (adds less fuel) apply fix from grunthack to prevent panic "fakecorr overflow" when vault guard couldn't figure out how to lead the hero from vault to civilization; fixes longstanding bug C343-23 +vibrating square is not really a trap so monsters don't need to avoid it +if hero kicks some embedded gold out of a wall while following vault gaurd + away from vault, don't report "the guard _calms_down_and_ picks up + the gold" unless he's on brink of going ballistic Fixes to Post-3.6.1 Problems that Were Exposed Via git Repository diff --git a/include/tradstdc.h b/include/tradstdc.h index e6a8f3e8f..468ebdea8 100644 --- a/include/tradstdc.h +++ b/include/tradstdc.h @@ -1,4 +1,4 @@ -/* NetHack 3.6 tradstdc.h $NHDT-Date: 1543371689 2018/11/28 02:21:29 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.32 $ */ +/* NetHack 3.6 tradstdc.h $NHDT-Date: 1545270756 2018/12/20 01:52:36 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.34 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2006. */ /* NetHack may be freely redistributed. See license for details. */ @@ -390,8 +390,10 @@ typedef genericptr genericptr_t; /* (void *) or (char *) */ #endif #ifdef __clang__ -#define UNUSED __attribute__((unused)) -#define NORETURN __attribute__((noreturn)) +/* clang's gcc emulation is sufficient for nethack's usage */ +#ifndef __GNUC__ +#define __GNUC__ 4 +#endif #endif /* diff --git a/src/mon.c b/src/mon.c index de037e42b..88aaf3dce 100644 --- a/src/mon.c +++ b/src/mon.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 mon.c $NHDT-Date: 1544658160 2018/12/12 23:42:40 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.274 $ */ +/* NetHack 3.6 mon.c $NHDT-Date: 1545259929 2018/12/19 22:52:09 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.275 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Derek S. Ray, 2015. */ /* NetHack may be freely redistributed. See license for details. */ @@ -1476,6 +1476,7 @@ nexttry: /* eels prefer the water, but if there is no water nearby, if ((ttmp->ttyp != RUST_TRAP || mdat == &mons[PM_IRON_GOLEM]) && ttmp->ttyp != STATUE_TRAP + && ttmp->ttyp != VIBRATING_SQUARE && ((!is_pit(ttmp->ttyp) && !is_hole(ttmp->ttyp)) || (!is_flyer(mdat) && !is_floater(mdat) && !is_clinger(mdat)) || Sokoban) diff --git a/src/trap.c b/src/trap.c index d8d4018e7..965c9347e 100644 --- a/src/trap.c +++ b/src/trap.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 trap.c $NHDT-Date: 1543515862 2018/11/29 18:24:22 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.312 $ */ +/* NetHack 3.6 trap.c $NHDT-Date: 1545259936 2018/12/19 22:52:16 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.313 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2013. */ /* NetHack may be freely redistributed. See license for details. */ @@ -2691,13 +2691,29 @@ register struct monst *mtmp; break; case VIBRATING_SQUARE: if (see_it && !Blind) { - if (in_sight) - pline("You see a strange vibration beneath %s %s.", - s_suffix(mon_nam(mtmp)), - makeplural(mbodypart(mtmp, FOOT))); - else - pline("You see the ground vibrate in the distance."); - seetrap(trap); + seetrap(trap); /* before messages */ + if (in_sight) { + char buf[BUFSZ], *p, *monnm = mon_nam(mtmp); + + if (nolimbs(mtmp->data) + || is_floater(mtmp->data) || is_flyer(mtmp->data)) { + /* just "beneath " */ + Strcpy(buf, monnm); + } else { + Strcpy(buf, s_suffix(monnm)); + p = eos(strcat(buf, " ")); + Strcpy(p, makeplural(mbodypart(mtmp, FOOT))); + /* avoid "beneath 'rear paws'" or 'rear hooves' */ + (void) strsubst(p, "rear ", ""); + } + You_see("a strange vibration beneath %s.", buf); + } else { + /* notice something (hearing uses a larger threshold + for 'nearby') */ + You_see("the ground vibrate %s.", + (distu(mtmp->mx, mtmp->my) <= 2 * 2) + ? "nearby" : "in the distance"); + } } break; default: diff --git a/src/vault.c b/src/vault.c index c23f55595..3945f215d 100644 --- a/src/vault.c +++ b/src/vault.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 vault.c $NHDT-Date: 1545217597 2018/12/19 11:06:37 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.58 $ */ +/* NetHack 3.6 vault.c $NHDT-Date: 1545269451 2018/12/20 01:30:51 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.59 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2011. */ /* NetHack may be freely redistributed. See license for details. */ @@ -15,6 +15,7 @@ STATIC_DCL boolean FDECL(find_guard_dest, (struct monst *, xchar *, xchar *)); STATIC_DCL void FDECL(move_gold, (struct obj *, int)); STATIC_DCL void FDECL(wallify_vault, (struct monst *)); STATIC_DCL void FDECL(gd_mv_monaway, (struct monst *, int, int)); +STATIC_OVL void FDECL(gd_pick_corridor_gold, (struct monst *, int, int)); void newegd(mtmp) @@ -604,9 +605,9 @@ struct monst *grd; } STATIC_OVL void -gd_mv_monaway(grd, nx,ny) +gd_mv_monaway(grd, nx, ny) register struct monst *grd; -int nx,ny; +int nx, ny; { if (MON_AT(nx, ny) && !(nx == grd->mx && ny == grd->my)) { if (!Deaf) @@ -616,6 +617,97 @@ int nx,ny; } } +/* have guard pick gold off the floor, possibly moving to the gold's + position before message and back to his current spot after */ +STATIC_OVL void +gd_pick_corridor_gold(grd, goldx, goldy) +struct monst *grd; +int goldx, goldy; /* ox, gold->oy> */ +{ + struct obj *gold; + coord newcc, bestcc; + int gdelta, newdelta, bestdelta, tryct, + guardx = grd->mx, guardy = grd->my; + boolean under_u = (goldx == u.ux && goldy == u.uy), + see_it = cansee(goldx, goldy); + + if (under_u) { + /* Grab the gold from between the hero's feet. + If guard is two or more steps away; bring him closer first. */ + gold = g_at(goldx, goldy); + if (!gold) { + impossible("vault guard: no gold at hero's feet?"); + return; + } + gdelta = distu(guardx, guardy); + if (gdelta > 2 && see_it) { /* skip if player won't see it */ + bestdelta = gdelta; + bestcc.x = (xchar) guardx, bestcc.y = (xchar) guardy; + tryct = 9; + do { + /* pick an available spot nearest the hero and also try + to find the one meeting that criterium which is nearest + the guard's current location */ + if (enexto(&newcc, goldx, goldy, grd->data)) { + if ((newdelta = distu(newcc.x, newcc.y)) < bestdelta + || (newdelta == bestdelta + && dist2(newcc.x, newcc.y, guardx, guardy) + < dist2(bestcc.x, bestcc.y, guardx, guardy))) { + bestdelta = newdelta; + bestcc = newcc; + } + } + } while (--tryct >= 0); + + if (bestdelta < gdelta) { + remove_monster(guardx, guardy); + newsym(guardx, guardy); + place_monster(grd, (int) bestcc.x, (int) bestcc.y); + newsym(grd->mx, grd->my); + } + } + obj_extract_self(gold); + add_to_minv(grd, gold); + newsym(goldx, goldy); + + /* guard is already at gold's location */ + } else if (goldx == guardx && goldy == guardy) { + mpickgold(grd); /* does a newsym */ + + /* gold is at some third spot, neither guard's nor hero's */ + } else { + /* just for insurance... */ + gd_mv_monaway(grd, goldx, goldy); /* make room for guard */ + if (see_it) { /* skip if player won't see the message */ + remove_monster(grd->mx, grd->my); + newsym(grd->mx, grd->my); + place_monster(grd, goldx, goldy); /* sets mx, grd->my> */ + } + mpickgold(grd); /* does a newsym */ + } + + if (see_it) { /* cansee(goldx, goldy) */ + char monnambuf[BUFSZ]; + + Strcpy(monnambuf, Monnam(grd)); + if (!strcmpi(monnambuf, "It")) + Strcpy(monnambuf, "Someone"); + pline("%s%s picks up the gold%s.", monnambuf, + (grd->mpeaceful && EGD(grd)->warncnt > 5) + ? " calms down and" : "", + under_u ? " from beneath you" : ""); + } + + /* if guard was moved to get the gold, move him back */ + if (grd->mx != guardx || grd->my != guardy) { + remove_monster(grd->mx, grd->my); + newsym(grd->mx, grd->my); + place_monster(grd, guardx, guardy); + newsym(guardx, guardy); + } + return; +} + /* * return 1: guard moved, 0: guard didn't, -1: let m_move do it, -2: died */ @@ -774,35 +866,12 @@ register struct monst *grd; m = egrd->fakecorr[fci].fx; n = egrd->fakecorr[fci].fy; goldincorridor = TRUE; + break; } + /* new gold can appear if it was embedded in stone and hero kicks it + (on even via wish and drop) so don't assume hero has been warned */ if (goldincorridor && !egrd->gddone) { - x = grd->mx; - y = grd->my; - if (m == u.ux && n == u.uy) { - struct obj *gold = g_at(m, n); - /* Grab the gold from between the hero's feet. */ - obj_extract_self(gold); - add_to_minv(grd, gold); - newsym(m, n); - } else if (m == x && n == y) { - mpickgold(grd); /* does a newsym */ - } else { - /* just for insurance... */ - gd_mv_monaway(grd, m,n); - remove_monster(grd->mx, grd->my); - newsym(grd->mx, grd->my); - place_monster(grd, m, n); - mpickgold(grd); /* does a newsym */ - } - if (cansee(m, n)) - pline("%s%s picks up the gold.", Monnam(grd), - grd->mpeaceful ? " calms down and" : ""); - if (x != grd->mx || y != grd->my) { - remove_monster(grd->mx, grd->my); - newsym(grd->mx, grd->my); - place_monster(grd, x, y); - newsym(x, y); - } + gd_pick_corridor_gold(grd, m, n); if (!grd->mpeaceful) return -1; egrd->warncnt = 5;