From abcdb713d5cf525cf28a38690f3698b3e3928269 Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Sun, 13 Jan 2019 17:27:17 +0200 Subject: [PATCH 1/5] wizmakemap should reset lockpicking --- src/cmd.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cmd.c b/src/cmd.c index 061b15690..ef829a884 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -809,6 +809,7 @@ wiz_makemap(VOID_ARGS) ballrelease(FALSE); unplacebc(); } + maybe_reset_pick(); reset_utrap(FALSE); /* also done by safe_teleds() for new level */ check_special_room(TRUE); dmonsfree(); From 355dec4d842a261ad8dfbdb0ac5748eb3f7c12af Mon Sep 17 00:00:00 2001 From: PatR Date: Sun, 13 Jan 2019 15:17:40 -0800 Subject: [PATCH 2/5] blocking or unblocking levitation or flight when level teleporting or digging. Level teleporting while levitation was blocked due to being inside solid rock didn't notice that it should be unblocked until you moved from whatever type of terrain you landed on (room, for instance) to some other type (such as corridor). Digging down to make a pit or hole while inside solid rock converts that spot to floor so should also check whether to unblock levitation/flying, and not fall if unblocking occurs. --- doc/fixes36.2 | 4 +++- src/dig.c | 19 ++++++++++++++++--- src/dungeon.c | 7 +++++-- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/doc/fixes36.2 b/doc/fixes36.2 index 9b01667ad..b63630534 100644 --- a/doc/fixes36.2 +++ b/doc/fixes36.2 @@ -1,4 +1,4 @@ -$NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.228 $ $NHDT-Date: 1547343820 2019/01/13 01:43:40 $ +$NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.229 $ $NHDT-Date: 1547421445 2019/01/13 23:17:25 $ This fixes36.2 file is here to capture information about updates in the 3.6.x lineage following the release of 3.6.1 in April 2018. Please note, however, @@ -266,6 +266,8 @@ when blocking/unblocking of levitation or flying was updated due to walking if levitating hero in pass-wall creature form jumped or teleported from terrain that allowed levitation to terrain that didn't or vice versa, blocking of levitation wasn't updated properly +digging down or level teleporting while stuck in solid rock which is blocking + levitation or flight didn't notice when that should become unblocked make it easier to clear 'pickup_types' (menustyles Traditional and Combination could do so by setting it to 'a'; now ' ' works too; Full and Partial allowed unselecting every object class; now 'all classes' is a choice) diff --git a/src/dig.c b/src/dig.c index 29d0941d4..dbf5eb5ca 100644 --- a/src/dig.c +++ b/src/dig.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 dig.c $NHDT-Date: 1544442710 2018/12/10 11:51:50 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.116 $ */ +/* NetHack 3.6 dig.c $NHDT-Date: 1547421446 2019/01/13 23:17:26 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.117 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Michael Allison, 2012. */ /* NetHack may be freely redistributed. See license for details. */ @@ -612,10 +612,16 @@ int ttyp; You("dig a pit in the %s.", surface_type); if (shopdoor) pay_for_damage("ruin", FALSE); - } else if (!madeby_obj && canseemon(madeby)) + } else if (!madeby_obj && canseemon(madeby)) { pline("%s digs a pit in the %s.", Monnam(madeby), surface_type); - else if (cansee(x, y) && flags.verbose) + } else if (cansee(x, y) && flags.verbose) { pline("A pit appears in the %s.", surface_type); + } + /* in case we're digging down while encased in solid rock + which is blocking levitation or flight */ + switch_terrain(); + if (Levitation || Flying) + wont_fall = TRUE; if (at_u) { if (!wont_fall) { @@ -644,6 +650,13 @@ int ttyp; pline("A hole appears in the %s.", surface_type); if (at_u) { + /* in case we're digging down while encased in solid rock + which is blocking levitation or flight */ + switch_terrain(); + if (Levitation || Flying) + wont_fall = TRUE; + + /* check for leashed pet that can't fall right now */ if (!u.ustuck && !wont_fall && !next_to_u()) { You("are jerked back by your pet!"); wont_fall = TRUE; diff --git a/src/dungeon.c b/src/dungeon.c index 335ca15da..6df9fda37 100644 --- a/src/dungeon.c +++ b/src/dungeon.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 dungeon.c $NHDT-Date: 1523308357 2018/04/09 21:12:37 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.87 $ */ +/* NetHack 3.6 dungeon.c $NHDT-Date: 1547421449 2019/01/13 23:17:29 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.90 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2012. */ /* NetHack may be freely redistributed. See license for details. */ @@ -1202,7 +1202,7 @@ int x, y; u.ux0 = u.ux, u.uy0 = u.uy; } -/* place you on a random location */ +/* place you on a random location when arriving on a level */ void u_on_rndspot(upflag) int upflag; @@ -1230,6 +1230,9 @@ int upflag; place_lregion(dndest.lx, dndest.ly, dndest.hx, dndest.hy, dndest.nlx, dndest.nly, dndest.nhx, dndest.nhy, LR_DOWNTELE, (d_level *) 0); + + /* might have just left solid rock and unblocked levitation */ + switch_terrain(); } /* place you on the special staircase */ From d735d04b5b9f43ebcaefa41407db5e808fa9259b Mon Sep 17 00:00:00 2001 From: PatR Date: Sun, 13 Jan 2019 15:24:08 -0800 Subject: [PATCH 3/5] \#wizmakemap update The need for resetting lock picking when swapping in a new level made me wonder whether other things should be reset too, and there were a bunch: digging, travel destination, polearm target, being in water, being swallowed or held, hiding. Hero placement was ignoring arrival region. Also, it turned out to be pretty easy to fix the FIXME about steed. --- src/cmd.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 53 insertions(+), 7 deletions(-) diff --git a/src/cmd.c b/src/cmd.c index ef829a884..39e34cc77 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 cmd.c $NHDT-Date: 1546565813 2019/01/04 01:36:53 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.324 $ */ +/* NetHack 3.6 cmd.c $NHDT-Date: 1547421842 2019/01/13 23:24:02 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.326 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2013. */ /* NetHack may be freely redistributed. See license for details. */ @@ -794,37 +794,83 @@ wiz_identify(VOID_ARGS) return 0; } +/* #wizmakemap - discard current dungeon level and replace with a new one */ STATIC_PTR int wiz_makemap(VOID_ARGS) { - /* FIXME: doesn't handle riding */ if (wizard) { struct monst *mtmp; rm_mapseen(ledger_no(&u.uz)); - for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) + for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) { + if (mtmp->isgd) { /* vault is going away; get rid of guard */ + mtmp->isgd = 0; + mongone(mtmp); + } + if (DEADMONSTER(mtmp)) + continue; if (mtmp->isshk) setpaid(mtmp); + /* TODO? + * Reduce 'born' tally for each monster about to be discarded + * by savelev(), otherwise replacing heavily populated levels + * tends to make their inhabitants become extinct. + */ + } if (Punished) { ballrelease(FALSE); unplacebc(); } + /* reset lock picking unless it's for a carried container */ maybe_reset_pick(); - reset_utrap(FALSE); /* also done by safe_teleds() for new level */ - check_special_room(TRUE); - dmonsfree(); + /* reset interrupted digging if it was taking place on this level */ + if (on_level(&context.digging.level, &u.uz)) + (void) memset((genericptr_t) &context.digging, 0, + sizeof (struct dig_info)); + /* reset cached targets */ + iflags.travelcc.x = iflags.travelcc.y = 0; /* travel destination */ + context.polearm.hitmon = (struct monst *) 0; /* polearm target */ + /* escape from trap */ + reset_utrap(FALSE); + check_special_room(TRUE); /* room exit */ + u.ustuck = (struct monst *) 0; + u.uswallow = 0; + u.uinwater = 0; + u.uundetected = 0; /* not hidden, even if means are available */ + dmonsfree(); /* purge dead monsters from 'fmon' */ + /* keep steed and other adjacent pets after releasing them + from traps, stopping eating, &c as if hero were ascending */ + keepdogs(TRUE); /* (pets-only; normally we'd be using 'FALSE' here) */ + + /* discard current level; "saving" is used to release dynamic data */ savelev(-1, ledger_no(&u.uz), FREE_SAVE); + /* create a new level; various things like bestowing a guardian + angel on Astral or setting off alarm on Ft.Ludios are handled + by goto_level(do.c) so won't occur for replacement levels */ mklev(); + vision_reset(); vision_full_recalc = 1; cls(); - (void) safe_teleds(TRUE); + /* was using safe_teleds() but that doesn't honor arrival region + on levels which have such; we don't force stairs, just area */ + u_on_rndspot((u.uhave.amulet ? 1 : 0) /* 'going up' flag */ + | (In_W_tower(u.ux, u.uy, &u.uz) ? 2 : 0)); + losedogs(); + initrack(); if (Punished) { unplacebc(); placebc(); } docrt(); flush_screen(1); + deliver_splev_message(); /* level entry */ + check_special_room(FALSE); /* room entry */ +#ifdef INSURANCE + save_currentstate(); +#endif + } else { + pline(unavailcmd, "#wizmakemap"); } return 0; } From 64821f4ad51850e7c1b6e7e4ca61858ef0cea59d Mon Sep 17 00:00:00 2001 From: PatR Date: Sun, 13 Jan 2019 17:19:39 -0800 Subject: [PATCH 4/5] more enums with explicit values As before, it's an aid to finding things if you're looking for something by its numeric value. --- include/mextra.h | 18 +++---- include/monst.h | 25 +++++----- include/monsym.h | 124 +++++++++++++++++++++++------------------------ 3 files changed, 84 insertions(+), 83 deletions(-) diff --git a/include/mextra.h b/include/mextra.h index b4c1aa989..e942c9554 100644 --- a/include/mextra.h +++ b/include/mextra.h @@ -1,4 +1,4 @@ -/* NetHack 3.6 mextra.h $NHDT-Date: 1451836000 2016/01/03 15:46:40 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.18 $ */ +/* NetHack 3.6 mextra.h $NHDT-Date: 1547428759 2019/01/14 01:19:19 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.22 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Michael Allison, 2006. */ /* NetHack may be freely redistributed. See license for details. */ @@ -144,16 +144,16 @@ struct emin { /*** ** formerly edog.h -- pet extension */ -/* various types of pet food, the lower, the better liked */ +/* various types of pet food, the lower the value, the better liked */ enum dogfood_types { DOGFOOD = 0, - CADAVER, - ACCFOOD, - MANFOOD, - APPORT, - POISON, - UNDEF, - TABU + CADAVER = 1, + ACCFOOD = 2, + MANFOOD = 3, + APPORT = 4, + POISON = 5, + UNDEF = 6, + TABU = 7 }; struct edog { diff --git a/include/monst.h b/include/monst.h index cc655c9ba..d0dee04b0 100644 --- a/include/monst.h +++ b/include/monst.h @@ -1,4 +1,4 @@ -/* NetHack 3.6 monst.h $NHDT-Date: 1461028522 2016/04/19 01:15:22 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.24 $ */ +/* NetHack 3.6 monst.h $NHDT-Date: 1547428769 2019/01/14 01:19:29 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.27 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2016. */ /* NetHack may be freely redistributed. See license for details. */ @@ -21,13 +21,13 @@ * weapon that this is impractical. --KAA */ enum wpn_chk_flags { - NO_WEAPON_WANTED = 0, - NEED_WEAPON, - NEED_RANGED_WEAPON, - NEED_HTH_WEAPON, - NEED_PICK_AXE, - NEED_AXE, - NEED_PICK_OR_AXE + NO_WEAPON_WANTED = 0, + NEED_WEAPON = 1, + NEED_RANGED_WEAPON = 2, + NEED_HTH_WEAPON = 3, + NEED_PICK_AXE = 4, + NEED_AXE = 5, + NEED_PICK_OR_AXE = 6 }; /* The following flags are used for the second argument to display_minventory @@ -42,11 +42,12 @@ enum wpn_chk_flags { #define MINV_NOLET 0x04 #define MINV_ALL 0x08 +/* monster appearance types */ enum m_ap_types { - M_AP_NOTHING = 0, /* mappearance unused--monster appears as itself */ - M_AP_FURNITURE, /* stairs, a door, an altar, etc. */ - M_AP_OBJECT, /* an object */ - M_AP_MONSTER /* a monster */ + M_AP_NOTHING = 0, /* mappearance unused--monster appears as itself */ + M_AP_FURNITURE = 1, /* stairs, a door, an altar, etc. */ + M_AP_OBJECT = 2, /* an object */ + M_AP_MONSTER = 3 /* a monster; mostly used for cloned Wizard */ }; struct monst { diff --git a/include/monsym.h b/include/monsym.h index e4b68a05a..68737fd83 100644 --- a/include/monsym.h +++ b/include/monsym.h @@ -1,4 +1,4 @@ -/* NetHack 3.6 monsym.h $NHDT-Date: 1524689515 2018/04/25 20:51:55 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.11 $ */ +/* NetHack 3.6 monsym.h $NHDT-Date: 1547428769 2019/01/14 01:19:29 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.12 $ */ /* Copyright (c) 2016 by Pasi Kallinen */ /* NetHack may be freely redistributed. See license for details. */ /* Monster symbols and creation information rev 1.0 */ @@ -12,69 +12,69 @@ * NULL character. */ enum mon_class_types { - S_ANT = 1, - S_BLOB, - S_COCKATRICE, - S_DOG, - S_EYE, - S_FELINE, - S_GREMLIN, - S_HUMANOID, - S_IMP, - S_JELLY, - S_KOBOLD, - S_LEPRECHAUN, - S_MIMIC, - S_NYMPH, - S_ORC, - S_PIERCER, - S_QUADRUPED, - S_RODENT, - S_SPIDER, - S_TRAPPER, - S_UNICORN, - S_VORTEX, - S_WORM, - S_XAN, - S_LIGHT, - S_ZRUTY, - S_ANGEL, - S_BAT, - S_CENTAUR, - S_DRAGON, - S_ELEMENTAL, - S_FUNGUS, - S_GNOME, - S_GIANT, - S_invisible, /* non-class present in def_monsyms[] */ - S_JABBERWOCK, - S_KOP, - S_LICH, - S_MUMMY, - S_NAGA, - S_OGRE, - S_PUDDING, - S_QUANTMECH, - S_RUSTMONST, - S_SNAKE, - S_TROLL, - S_UMBER, - S_VAMPIRE, - S_WRAITH, - S_XORN, - S_YETI, - S_ZOMBIE, - S_HUMAN, - S_GHOST, - S_GOLEM, - S_DEMON, - S_EEL, - S_LIZARD, + S_ANT = 1, /* a */ + S_BLOB = 2, /* b */ + S_COCKATRICE = 3, /* c */ + S_DOG = 4, /* d */ + S_EYE = 5, /* e */ + S_FELINE = 6, /* f: cats */ + S_GREMLIN = 7, /* g */ + S_HUMANOID = 8, /* h: small humanoids: hobbit, dwarf */ + S_IMP = 9, /* i: minor demons */ + S_JELLY = 10, /* j */ + S_KOBOLD = 11, /* k */ + S_LEPRECHAUN = 12, /* l */ + S_MIMIC = 13, /* m */ + S_NYMPH = 14, /* n */ + S_ORC = 15, /* o */ + S_PIERCER = 16, /* p */ + S_QUADRUPED = 17, /* q: excludes horses */ + S_RODENT = 18, /* r */ + S_SPIDER = 19, /* s */ + S_TRAPPER = 20, /* t */ + S_UNICORN = 21, /* u: includes horses */ + S_VORTEX = 22, /* v */ + S_WORM = 23, /* w */ + S_XAN = 24, /* x */ + S_LIGHT = 25, /* y: yellow light, black light */ + S_ZRUTY = 26, /* z */ + S_ANGEL = 27, /* A */ + S_BAT = 28, /* B */ + S_CENTAUR = 29, /* C */ + S_DRAGON = 30, /* D */ + S_ELEMENTAL = 31, /* E: includes invisible stalker */ + S_FUNGUS = 32, /* F */ + S_GNOME = 33, /* G */ + S_GIANT = 34, /* H: large humanoid: giant, ettin, minotaur */ + S_invisible = 35, /* I: non-class present in def_monsyms[] */ + S_JABBERWOCK = 36, /* J */ + S_KOP = 37, /* K */ + S_LICH = 38, /* L */ + S_MUMMY = 39, /* M */ + S_NAGA = 40, /* N */ + S_OGRE = 41, /* O */ + S_PUDDING = 42, /* P */ + S_QUANTMECH = 43, /* Q */ + S_RUSTMONST = 44, /* R */ + S_SNAKE = 45, /* S */ + S_TROLL = 46, /* T */ + S_UMBER = 47, /* U: umber hulk */ + S_VAMPIRE = 48, /* V */ + S_WRAITH = 49, /* W */ + S_XORN = 50, /* X */ + S_YETI = 51, /* Y: includes owlbear, monkey */ + S_ZOMBIE = 52, /* Z */ + S_HUMAN = 53, /* @ */ + S_GHOST = 54, /* */ + S_GOLEM = 55, /* ' */ + S_DEMON = 56, /* & */ + S_EEL = 57, /* ; (fish) */ + S_LIZARD = 58, /* : (reptiles) */ - S_WORM_TAIL, - S_MIMIC_DEF, + S_WORM_TAIL = 59, /* ~ */ + S_MIMIC_DEF = 60, /* ] */ - MAXMCLASSES /* number of monster classes */ + MAXMCLASSES = 61 /* number of monster classes */ }; /* From 992f141ab764cf1bf074af9dfb12bd9792fb26f2 Mon Sep 17 00:00:00 2001 From: PatR Date: Mon, 14 Jan 2019 09:28:10 -0800 Subject: [PATCH 5/5] \#wizmakemap followup Both u_on_rndspot() and losedogs() might result in having a monster and the hero be at the same location. Have wiz_makemap() use the same fixup for that as goto_level(). --- include/extern.h | 3 ++- src/cmd.c | 7 ++++- src/do.c | 66 ++++++++++++++++++++++++++++-------------------- 3 files changed, 47 insertions(+), 29 deletions(-) diff --git a/include/extern.h b/include/extern.h index 9a2be9e11..dd27db8aa 100644 --- a/include/extern.h +++ b/include/extern.h @@ -1,4 +1,4 @@ -/* NetHack 3.6 extern.h $NHDT-Date: 1546687295 2019/01/05 11:21:35 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.681 $ */ +/* NetHack 3.6 extern.h $NHDT-Date: 1547486885 2019/01/14 17:28:05 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.682 $ */ /* Copyright (c) Steve Creps, 1988. */ /* NetHack may be freely redistributed. See license for details. */ @@ -384,6 +384,7 @@ E int NDECL(doup); #ifdef INSURANCE E void NDECL(save_currentstate); #endif +E void FDECL(u_collide_m, (struct monst *)); E void FDECL(goto_level, (d_level *, BOOLEAN_P, BOOLEAN_P, BOOLEAN_P)); E void FDECL(schedule_goto, (d_level *, BOOLEAN_P, BOOLEAN_P, int, const char *, const char *)); diff --git a/src/cmd.c b/src/cmd.c index 39e34cc77..0d9e284b1 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 cmd.c $NHDT-Date: 1547421842 2019/01/13 23:24:02 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.326 $ */ +/* NetHack 3.6 cmd.c $NHDT-Date: 1547486885 2019/01/14 17:28:05 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.327 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2013. */ /* NetHack may be freely redistributed. See license for details. */ @@ -857,6 +857,11 @@ wiz_makemap(VOID_ARGS) u_on_rndspot((u.uhave.amulet ? 1 : 0) /* 'going up' flag */ | (In_W_tower(u.ux, u.uy, &u.uz) ? 2 : 0)); losedogs(); + /* u_on_rndspot() might pick a spot that has a monster, or losedogs() + might pick the hero's spot (only if there isn't already a monster + there), so we might have to move hero or the co-located monster */ + if ((mtmp = m_at(u.ux, u.uy)) != 0 && mtmp != u.usteed) + u_collide_m(mtmp); initrack(); if (Punished) { unplacebc(); diff --git a/src/do.c b/src/do.c index 53d0c60ae..346b77adb 100644 --- a/src/do.c +++ b/src/do.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 do.c $NHDT-Date: 1547086513 2019/01/10 02:15:13 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.183 $ */ +/* NetHack 3.6 do.c $NHDT-Date: 1547486886 2019/01/14 17:28:06 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.184 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Derek S. Ray, 2015. */ /* NetHack may be freely redistributed. See license for details. */ @@ -1157,6 +1157,39 @@ register xchar x, y; } */ +/* extracted from goto_level(); also used by wiz_makemap() */ +void +u_collide_m(mtmp) +struct monst *mtmp; +{ + coord cc; + + if (!mtmp || mtmp->mx != u.ux || mtmp->my != u.uy) + return; + + /* There's a monster at your target destination; it might be one + which accompanied you--see mon_arrive(dogmove.c)--or perhaps + it was already here. Randomly move you to an adjacent spot + or else the monster to any nearby location. Prior to 3.3.0 + the latter was done unconditionally. */ + if (!rn2(2) && enexto(&cc, u.ux, u.uy, youmonst.data) + && distu(cc.x, cc.y) <= 2) + u_on_newpos(cc.x, cc.y); /*[maybe give message here?]*/ + else + mnexto(mtmp); + + if ((mtmp = m_at(u.ux, u.uy)) != 0) { + /* there was an unconditional impossible("mnearto failed") + here, but it's not impossible and we're prepared to cope + with the situation, so only say something when debugging */ + if (wizard) + pline("(monster in hero's way)"); + if (!rloc(mtmp, TRUE) || (mtmp = m_at(u.ux, u.uy)) != 0) + /* no room to move it; send it away, to return later */ + m_into_limbo(mtmp); + } +} + void goto_level(newlevel, at_stairs, falling, portal) d_level *newlevel; @@ -1445,34 +1478,13 @@ boolean at_stairs, falling, portal; */ run_timers(); + /* hero might be arriving at a spot containing a monster; + if so, move one or the other to another location */ + if ((mtmp = m_at(u.ux, u.uy)) != 0 && mtmp != u.usteed) + u_collide_m(mtmp); + initrack(); - if ((mtmp = m_at(u.ux, u.uy)) != 0 && mtmp != u.usteed) { - /* There's a monster at your target destination; it might be one - which accompanied you--see mon_arrive(dogmove.c)--or perhaps - it was already here. Randomly move you to an adjacent spot - or else the monster to any nearby location. Prior to 3.3.0 - the latter was done unconditionally. */ - coord cc; - - if (!rn2(2) && enexto(&cc, u.ux, u.uy, youmonst.data) - && distu(cc.x, cc.y) <= 2) - u_on_newpos(cc.x, cc.y); /*[maybe give message here?]*/ - else - mnexto(mtmp); - - if ((mtmp = m_at(u.ux, u.uy)) != 0) { - /* there was an unconditional impossible("mnearto failed") - here, but it's not impossible and we're prepared to cope - with the situation, so only say something when debugging */ - if (wizard) - pline("(monster in hero's way)"); - if (!rloc(mtmp, TRUE) || (mtmp = m_at(u.ux, u.uy)) != 0) - /* no room to move it; send it away, to return later */ - m_into_limbo(mtmp); - } - } - /* initial movement of bubbles just before vision_recalc */ if (Is_waterlevel(&u.uz) || Is_airlevel(&u.uz)) movebubbles();