diff --git a/src/display.c b/src/display.c index 6486fc6d2..ebb44e872 100644 --- a/src/display.c +++ b/src/display.c @@ -1,4 +1,4 @@ -/* NetHack 3.7 display.c $NHDT-Date: 1682758082 2023/04/29 08:48:02 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.216 $ */ +/* NetHack 3.7 display.c $NHDT-Date: 1707462961 2024/02/09 07:16:01 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.231 $ */ /* Copyright (c) Dean Luick, with acknowledgements to Kevin Darcy */ /* and Dave Cohrs, 1990. */ /* NetHack may be freely redistributed. See license for details. */ @@ -128,7 +128,7 @@ static void display_monster(coordxy, coordxy, struct monst *, int, boolean) NONNULLPTRS; static int swallow_to_glyph(int, int); static void display_warning(struct monst *) NONNULLARG1; -static boolean next_to_gas(struct monst *) NONNULLARG1; +static boolean next_to_gas(struct monst *, coordxy, coordxy) NONNULLARG1; static int check_pos(coordxy, coordxy, int); static void get_bkglyph_and_framecolor(coordxy x, coordxy y, int *, uint32 *); @@ -654,13 +654,18 @@ warning_of(struct monst *mon) /* returns True if mon is adjacent and would be seen if vision wasn't blocked by being in a gas cloud (implicit; caller has already checked) */ static boolean -next_to_gas(struct monst *mon) +next_to_gas( + struct monst *mon, + coordxy mx, coordxy my) /* won't match mon->mx,my if long worm's tail */ { - int r = (u.xray_range > 1) ? (u.xray_range + 1) : 2; + int r = (u.xray_range > 1) ? u.xray_range : 1; - if (distu(mon->mx, mon->my) > r * (r - 1)) + if (distu(mx, my) > r * (r + 1)) return FALSE; - if (!_mon_visible(mon) && !_see_with_infrared(mon)) + /* decide whether monster at could be seen without couldsee() + because the gas cloud inhibits that (don't need to check infravision + when monster is adjacent) */ + if (Blind || !_mon_visible(mon)) return FALSE; return TRUE; } @@ -938,10 +943,8 @@ newsym(coordxy x, coordxy y) */ if (reg && (ACCESSIBLE(lev->typ) || (reg->visible && is_pool_or_lava(x, y)))) { - if (mon && !worm_tail && (sensemon(mon) || mon_warning(mon) - || next_to_gas(mon))) { - ; /* skip region; the 'if' is more comphrehensible this way */ - } else { + if (!(mon && (((sensemon(mon) || mon_warning(mon)) && !worm_tail) + || next_to_gas(mon, x, y)))) { /* even if tail */ show_region(reg, x, y); return; } diff --git a/src/region.c b/src/region.c index dac0bd116..15028e808 100644 --- a/src/region.c +++ b/src/region.c @@ -1,4 +1,4 @@ -/* NetHack 3.7 region.c $NHDT-Date: 1706272460 2024/01/26 12:34:20 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.88 $ */ +/* NetHack 3.7 region.c $NHDT-Date: 1707462965 2024/02/09 07:16:05 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.89 $ */ /* Copyright (c) 1996 by Jean-Christophe Collet */ /* NetHack may be freely redistributed. See license for details. */ @@ -161,6 +161,14 @@ add_mon_to_reg(NhRegion *reg, struct monst *mon) int i; unsigned *tmp_m; + /* if this is a long worm, it might already be present in the region; + only include it once no matter how segments the region contains */ + if (mon_in_region(reg, mon)) { + if (mon->data != &mons[PM_LONG_WORM]) + impossible("add_mon_to_reg: %s [#%u] already in region.", + m_monnam(mon), mon->m_id); + return; + } if (reg->max_monst <= reg->n_monst) { tmp_m = (unsigned *) alloc(sizeof (unsigned) * (reg->max_monst + MONST_INC)); @@ -290,13 +298,27 @@ add_region(NhRegion *reg) /* Check for monsters inside the region */ for (i = reg->bounding_box.lx; i <= reg->bounding_box.hx; i++) for (j = reg->bounding_box.ly; j <= reg->bounding_box.hy; j++) { - boolean is_inside = inside_region(reg, i, j); + struct monst *mtmp; + boolean is_inside = FALSE; /* Some regions can cross the level boundaries */ if (!isok(i, j)) continue; - if (is_inside && MON_AT(i, j)) - add_mon_to_reg(reg, gl.level.monsters[i][j]); + if (inside_region(reg, i, j)) { + is_inside = TRUE; + /* if there's a monster here, add it to the region */ + if ((mtmp = m_at(i, j)) != 0 +#if 0 + /* leave this bit (to exclude long worm tails) out; + assume that worms use "cutaneous respiration" (they + breath through their skin rather than nose/gills/&c) + so their tails are susceptible to poison gas */ + && mtmp->mx == i && mtmp->my == j +#endif + ) { + add_mon_to_reg(reg, mtmp); + } + } if (reg->visible) { if (is_inside) block_point(i, j);