From: PatR Date: Tue, 15 Jan 2019 00:35:19 +0000 (-0800) Subject: level arrival X-Git-Tag: NetHack-3.6.2_Released~90^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=97b28bd846a264b4e2e7c420304656ec2cdc540b;p=nethack level arrival The check I added to make sure that a monster was at the hero's coordinates before deciding to move one or the other would have been confused by a long worm's tail. Check that they're at that spot but not by comparing monst. coordinates with . Also, don't have wiz_makemap() assume that each level of the Wizard's Tower has the same boundary coordinates. Keep track of whether hero is inside that tower before discarding the old level. --- diff --git a/src/cmd.c b/src/cmd.c index 0d9e284b1..be8862d24 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -1,4 +1,4 @@ -/* 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 $ */ +/* NetHack 3.6 cmd.c $NHDT-Date: 1547512504 2019/01/15 00:35:04 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.328 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2013. */ /* NetHack may be freely redistributed. See license for details. */ @@ -800,6 +800,7 @@ wiz_makemap(VOID_ARGS) { if (wizard) { struct monst *mtmp; + boolean was_in_W_tower = In_W_tower(u.ux, u.uy, &u.uz); rm_mapseen(ledger_no(&u.uz)); for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) { @@ -855,12 +856,12 @@ wiz_makemap(VOID_ARGS) /* 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)); + | (was_in_W_tower ? 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) + if ((mtmp = m_at(u.ux, u.uy)) != 0) u_collide_m(mtmp); initrack(); if (Punished) { diff --git a/src/do.c b/src/do.c index 346b77adb..3afac4ee6 100644 --- a/src/do.c +++ b/src/do.c @@ -1,4 +1,4 @@ -/* 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 $ */ +/* NetHack 3.6 do.c $NHDT-Date: 1547512513 2019/01/15 00:35:13 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.185 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Derek S. Ray, 2015. */ /* NetHack may be freely redistributed. See license for details. */ @@ -1157,15 +1157,21 @@ register xchar x, y; } */ -/* extracted from goto_level(); also used by wiz_makemap() */ +/* when arriving on a level, if hero and a monster are trying to share same + spot, move one; 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) + if (!mtmp || mtmp == u.usteed || mtmp != m_at(u.ux, u.uy)) { + impossible("level arrival collision: %s?", + !mtmp ? "no monster" + : (mtmp == u.usteed) ? "steed is on map" + : "monster not co-located"); return; + } /* There's a monster at your target destination; it might be one which accompanied you--see mon_arrive(dogmove.c)--or perhaps @@ -1179,7 +1185,7 @@ struct monst *mtmp; mnexto(mtmp); if ((mtmp = m_at(u.ux, u.uy)) != 0) { - /* there was an unconditional impossible("mnearto failed") + /* there was an unconditional impossible("mnexto failed") here, but it's not impossible and we're prepared to cope with the situation, so only say something when debugging */ if (wizard) @@ -1480,7 +1486,7 @@ boolean at_stairs, falling, portal; /* 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) + if ((mtmp = m_at(u.ux, u.uy)) != 0) u_collide_m(mtmp); initrack();