-/* NetHack 3.6 extern.h $NHDT-Date: 1447124656 2015/11/10 03:04:16 $ $NHDT-Branch: master $:$NHDT-Revision: 1.515 $ */
+/* NetHack 3.6 extern.h $NHDT-Date: 1447475941 2015/11/14 04:39:01 $ $NHDT-Branch: master $:$NHDT-Revision: 1.516 $ */
/* Copyright (c) Steve Creps, 1988. */
/* NetHack may be freely redistributed. See license for details. */
E void FDECL(newmonhp, (struct monst *, int));
E struct mextra *NDECL(newmextra);
E void FDECL(copy_mextra, (struct monst *, struct monst *));
+E void FDECL(dealloc_mextra, (struct monst *));
E struct monst *FDECL(makemon, (struct permonst *, int, int, int));
E boolean FDECL(create_critters, (int, struct permonst *, BOOLEAN_P));
E struct permonst *NDECL(rndmonst);
E struct oextra *NDECL(newoextra);
E void FDECL(copy_oextra, (struct obj *, struct obj *));
-E void FDECL(dealloc_oextra, (struct oextra *));
+E void FDECL(dealloc_oextra, (struct obj *));
E void FDECL(newomonst, (struct obj *));
E void FDECL(free_omonst, (struct obj *));
E void FDECL(newomid, (struct obj *));
-/* NetHack 3.6 mkobj.c $NHDT-Date: 1446892448 2015/11/07 10:34:08 $ $NHDT-Branch: master $:$NHDT-Revision: 1.112 $ */
+/* NetHack 3.6 mkobj.c $NHDT-Date: 1447475943 2015/11/14 04:39:03 $ $NHDT-Branch: master $:$NHDT-Revision: 1.113 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
}
void
-dealloc_oextra(x)
-struct oextra *x;
+dealloc_oextra(o)
+struct obj *o;
{
+ struct oextra *x = o->oextra;
+
if (x) {
if (x->oname)
free((genericptr_t) x->oname);
if (x->omonst)
- free((genericptr_t) x->omonst);
+ free_omonst(o); /* 'o' rather than 'x' */
if (x->omid)
free((genericptr_t) x->omid);
if (x->olong)
free((genericptr_t) x->olong);
if (x->omailcmd)
free((genericptr_t) x->omailcmd);
+
free((genericptr_t) x);
+ o->oextra = (struct oextra *) 0;
}
}
if (!otmp->oextra)
otmp->oextra = newoextra();
if (!OMONST(otmp)) {
- OMONST(otmp) = (struct monst *) alloc(sizeof (struct monst));
- (void) memset((genericptr_t) OMONST(otmp), 0, sizeof (struct monst));
+ struct monst *m = newmonst();
+
+ /* newmonst() allocates memory but doesn't initialize anything */
+ (void) memset((genericptr_t) m, 0, sizeof (struct monst));
+ m->mextra = (struct mextra *) 0;
+ m->nmon = (struct monst *) 0;
+ OMONST(otmp) = m;
}
}
free_omonst(otmp)
struct obj *otmp;
{
- if (otmp->oextra && OMONST(otmp)) {
- free((genericptr_t) OMONST(otmp));
- OMONST(otmp) = (struct monst *) 0;
+ if (otmp->oextra) {
+ struct monst *m = OMONST(otmp);
+
+ if (m) {
+ if (m->mextra)
+ dealloc_mextra(m);
+ free((genericptr_t) m);
+ OMONST(otmp) = (struct monst *) 0;
+ }
}
}
newomonst(obj);
if (has_omonst(obj)) {
struct monst *mtmp2 = OMONST(obj);
+
*mtmp2 = *mtmp;
mtmp2->mextra = (struct mextra *) 0;
if (mtmp->data)
kickedobj = 0;
if (obj->oextra)
- dealloc_oextra(obj->oextra);
+ dealloc_oextra(obj);
free((genericptr_t) obj);
}
-/* NetHack 3.6 mon.c $NHDT-Date: 1446458009 2015/11/02 09:53:29 $ $NHDT-Branch: master $:$NHDT-Revision: 1.194 $ */
+/* NetHack 3.6 mon.c $NHDT-Date: 1447475944 2015/11/14 04:39:04 $ $NHDT-Branch: master $:$NHDT-Revision: 1.196 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
STATIC_DCL long FDECL(mm_displacement, (struct monst *, struct monst *));
STATIC_DCL int NDECL(pick_animal);
STATIC_DCL void FDECL(kill_eggs, (struct obj *));
-STATIC_DCL void FDECL(dealloc_mextra, (struct mextra *));
STATIC_DCL int FDECL(pickvampshape, (struct monst *));
STATIC_DCL boolean FDECL(isspecmon, (struct monst *));
STATIC_DCL boolean FDECL(validspecmon, (struct monst *, int));
MCORPSENM(mtmp2) = MCORPSENM(mtmp1);
}
-STATIC_OVL void
-dealloc_mextra(x)
-struct mextra *x;
+void
+dealloc_mextra(m)
+struct monst *m;
{
+ struct mextra *x = m->mextra;
+
if (x) {
if (x->mname)
free((genericptr_t) x->mname);
if (x->edog)
free((genericptr_t) x->edog);
/* [no action needed for x->mcorpsenm] */
+
free((genericptr_t) x);
+ m->mextra = (struct mextra *) 0;
}
}
if (mon->nmon)
panic("dealloc_monst with nmon");
if (mon->mextra)
- dealloc_mextra(mon->mextra);
+ dealloc_mextra(mon);
free((genericptr_t) mon);
}
-/* NetHack 3.6 zap.c $NHDT-Date: 1446887542 2015/11/07 09:12:22 $ $NHDT-Branch: master $:$NHDT-Revision: 1.233 $ */
+/* NetHack 3.6 zap.c $NHDT-Date: 1447475947 2015/11/14 04:39:07 $ $NHDT-Branch: master $:$NHDT-Revision: 1.235 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
obj->owt = weight(obj);
obj->dknown = obj->bknown = obj->rknown = 0;
obj->known = objects[obj->otyp].oc_uses_known ? 0 : 1;
- if (obj->oextra)
- dealloc_oextra(obj->oextra);
- obj->oextra = (struct oextra *) 0;
+ dealloc_oextra(obj);
+
if (obj->where == OBJ_FLOOR) {
obj_extract_self(obj); /* move rocks back on top */
place_object(obj, obj->ox, obj->oy);