couple of revive() bits
Noticed while hunting for the panic. They don't fix it but also won't interfere with the eventual fix.
This commit is contained in:
51
src/zap.c
51
src/zap.c
@@ -1,4 +1,4 @@
|
|||||||
/* NetHack 3.7 zap.c $NHDT-Date: 1654181493 2022/06/02 14:51:33 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.421 $ */
|
/* NetHack 3.7 zap.c $NHDT-Date: 1654881021 2022/06/10 17:10:21 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.425 $ */
|
||||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||||
/*-Copyright (c) Robert Patrick Rankin, 2013. */
|
/*-Copyright (c) Robert Patrick Rankin, 2013. */
|
||||||
/* NetHack may be freely redistributed. See license for details. */
|
/* NetHack may be freely redistributed. See license for details. */
|
||||||
@@ -558,7 +558,10 @@ probe_monster(struct monst *mtmp)
|
|||||||
* is not available or subject to the constraints above.
|
* is not available or subject to the constraints above.
|
||||||
*/
|
*/
|
||||||
boolean
|
boolean
|
||||||
get_obj_location(struct obj *obj, xchar *xp, xchar *yp, int locflags)
|
get_obj_location(
|
||||||
|
struct obj *obj,
|
||||||
|
xchar *xp, xchar *yp,
|
||||||
|
int locflags)
|
||||||
{
|
{
|
||||||
switch (obj->where) {
|
switch (obj->where) {
|
||||||
case OBJ_INVENT:
|
case OBJ_INVENT:
|
||||||
@@ -614,9 +617,11 @@ get_mon_location(
|
|||||||
|
|
||||||
/* used by revive() and animate_statue() */
|
/* used by revive() and animate_statue() */
|
||||||
struct monst *
|
struct monst *
|
||||||
montraits(struct obj *obj, coord *cc,
|
montraits(
|
||||||
boolean adjacentok) /* False: at obj's spot only, True: nearby is
|
struct obj *obj,
|
||||||
allowed */
|
coord *cc,
|
||||||
|
boolean adjacentok) /* False: at obj's spot only,
|
||||||
|
* True: nearby is allowed */
|
||||||
{
|
{
|
||||||
struct monst *mtmp = (struct monst *) 0,
|
struct monst *mtmp = (struct monst *) 0,
|
||||||
*mtmp2 = has_omonst(obj) ? get_mtraits(obj, TRUE) : 0;
|
*mtmp2 = has_omonst(obj) ? get_mtraits(obj, TRUE) : 0;
|
||||||
@@ -625,7 +630,7 @@ montraits(struct obj *obj, coord *cc,
|
|||||||
/* save_mtraits() validated mtmp2->mnum */
|
/* save_mtraits() validated mtmp2->mnum */
|
||||||
mtmp2->data = &mons[mtmp2->mnum];
|
mtmp2->data = &mons[mtmp2->mnum];
|
||||||
|
|
||||||
if (!(mtmp2->mhpmax <= 0 && !is_rider(mtmp2->data))) {
|
if (mtmp2->mhpmax > 0 || is_rider(mtmp2->data)) {
|
||||||
mtmp = makemon(mtmp2->data, cc->x, cc->y,
|
mtmp = makemon(mtmp2->data, cc->x, cc->y,
|
||||||
(NO_MINVENT | MM_NOWAIT | MM_NOCOUNTBIRTH
|
(NO_MINVENT | MM_NOWAIT | MM_NOCOUNTBIRTH
|
||||||
/* in case mtmp2 is a long worm; saved traits for
|
/* in case mtmp2 is a long worm; saved traits for
|
||||||
@@ -740,11 +745,11 @@ montraits(struct obj *obj, coord *cc,
|
|||||||
* if applicable.
|
* if applicable.
|
||||||
*/
|
*/
|
||||||
struct monst *
|
struct monst *
|
||||||
get_container_location(struct obj *obj, int *loc, int *container_nesting)
|
get_container_location(
|
||||||
|
struct obj *obj,
|
||||||
|
int *loc,
|
||||||
|
int *container_nesting)
|
||||||
{
|
{
|
||||||
if (!obj || !loc)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (container_nesting)
|
if (container_nesting)
|
||||||
*container_nesting = 0;
|
*container_nesting = 0;
|
||||||
while (obj && obj->where == OBJ_CONTAINED) {
|
while (obj && obj->where == OBJ_CONTAINED) {
|
||||||
@@ -764,7 +769,7 @@ get_container_location(struct obj *obj, int *loc, int *container_nesting)
|
|||||||
static boolean
|
static boolean
|
||||||
zombie_can_dig(xchar x, xchar y)
|
zombie_can_dig(xchar x, xchar y)
|
||||||
{
|
{
|
||||||
if (isok(x,y)) {
|
if (isok(x, y)) {
|
||||||
schar typ = levl[x][y].typ;
|
schar typ = levl[x][y].typ;
|
||||||
struct trap *ttmp;
|
struct trap *ttmp;
|
||||||
|
|
||||||
@@ -829,6 +834,9 @@ revive(struct obj *corpse, boolean by_hero)
|
|||||||
break; /* x,y are 0 */
|
break; /* x,y are 0 */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (x) /* update corpse's location now that we're sure where it is */
|
||||||
|
corpse->ox = x, corpse->oy = y;
|
||||||
|
|
||||||
if (!x
|
if (!x
|
||||||
/* Rules for revival from containers:
|
/* Rules for revival from containers:
|
||||||
* - the container cannot be locked
|
* - the container cannot be locked
|
||||||
@@ -838,16 +846,11 @@ revive(struct obj *corpse, boolean by_hero)
|
|||||||
*/
|
*/
|
||||||
|| (container && (container->olocked || container_nesting > 2
|
|| (container && (container->olocked || container_nesting > 2
|
||||||
|| container->otyp == STATUE
|
|| container->otyp == STATUE
|
||||||
|| (container->otyp == BAG_OF_HOLDING && rn2(40)))))
|
|| (container->otyp == BAG_OF_HOLDING && rn2(40))))
|
||||||
|
/* if buried zombie cannot dig itself out, do not revive */
|
||||||
|
|| (is_zomb && corpse->where == OBJ_BURIED && !zombie_can_dig(x, y)))
|
||||||
return (struct monst *) 0;
|
return (struct monst *) 0;
|
||||||
|
|
||||||
/* buried zombie cannot dig itself out, do not revive */
|
|
||||||
if (is_zomb && corpse->where == OBJ_BURIED && !zombie_can_dig(x, y))
|
|
||||||
return (struct monst *) 0;
|
|
||||||
|
|
||||||
/* record the object's location now that we're sure where it is */
|
|
||||||
corpse->ox = x, corpse->oy = y;
|
|
||||||
|
|
||||||
/* prepare for the monster */
|
/* prepare for the monster */
|
||||||
montype = corpse->corpsenm;
|
montype = corpse->corpsenm;
|
||||||
mptr = &mons[montype];
|
mptr = &mons[montype];
|
||||||
@@ -1003,13 +1006,9 @@ revive(struct obj *corpse, boolean by_hero)
|
|||||||
useup(corpse);
|
useup(corpse);
|
||||||
break;
|
break;
|
||||||
case OBJ_FLOOR:
|
case OBJ_FLOOR:
|
||||||
/* in case MON_AT+enexto for invisible mon */
|
/* not useupf(), which charges;
|
||||||
x = corpse->ox, y = corpse->oy;
|
delobj() won't use up a Rider's corpse, delobj_core(,TRUE) will */
|
||||||
/* not useupf(), which charges */
|
delobj_core(corpse, TRUE); /* for floor, also calls newsym() */
|
||||||
if (corpse->quan > 1L)
|
|
||||||
corpse = splitobj(corpse, 1L);
|
|
||||||
delobj_core(corpse, TRUE);
|
|
||||||
newsym(x, y);
|
|
||||||
break;
|
break;
|
||||||
case OBJ_MINVENT:
|
case OBJ_MINVENT:
|
||||||
m_useup(corpse->ocarry, corpse);
|
m_useup(corpse->ocarry, corpse);
|
||||||
|
|||||||
Reference in New Issue
Block a user