code change - oextra

move oattached and oname and other things that vary
the size of the obj structure into a separate
non-adjacent oextra structure, similar to what has
already been done for mextra. The obj structure
itself becomes a fixed size.

New macros:

#define ONAME(o)	((o)->oextra->oname)
#define OMID(o)		((o)->oextra->omid)
#define OMONST(o)	((o)->oextra->omonst)
#define OLONG(o)	((o)->oextra->olong)
#define OMAILCMD(o)	((o)->oextra->omailcmd)

#define has_oname(o)	((o)->oextra && ONAME(o))
#define has_omid(o)	((o)->oextra && OMID(o))
#define has_omonst(o)	((o)->oextra && OMONST(o))
#define has_olong(o)	((o)->oextra && OLONG(o))
#define has_omailcmd(o)	((o)->oextra && OMAILCMD(o))

changed macros:
has_name(mon) becomes has_mname(mon)  to correspond.

The CVS repository was tagged with
	NETHACK_PRE_OEXTRA
before commiting these, and
tagged with
	NETHACK_POST_OEXTRA
immediately after. The diff
between those two tags is this oextra patch.

The associated mail daemon changes to use an oextra
structure instead of a hidden command located in the
name after the terminating NUL, have not been tried
or tested.
This commit is contained in:
nethack.allison
2006-04-14 16:23:56 +00:00
parent f9314448f7
commit f55210be79
31 changed files with 688 additions and 518 deletions

View File

@@ -1,4 +1,4 @@
/* SCCS Id: @(#)zap.c 3.5 2006/04/05 */
/* SCCS Id: @(#)zap.c 3.5 2006/04/14 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -510,7 +510,7 @@ coord *cc;
struct monst *mtmp = (struct monst *)0;
struct monst *mtmp2 = (struct monst *)0;
if (obj->oxlth && (obj->oattached == OATTACHED_MONST))
if (has_omonst(obj))
mtmp2 = get_mtraits(obj, TRUE);
if (mtmp2) {
/* save_mtraits() validated mtmp2->mnum */
@@ -694,7 +694,9 @@ boolean by_hero;
/* note: montype has changed; mptr keeps old value for newcham() */
mtmp = makemon(&mons[montype], x, y, NO_MINVENT|MM_NOWAIT);
if (mtmp) {
corpse->oattached = OATTACHED_NOTHING; /* skip ghost handling */
/* skip ghost handling */
if (has_omid(corpse)) free_omid(corpse);
if (has_omonst(corpse)) free_omonst(corpse);
if (mtmp->cham == PM_DOPPELGANGER) {
/* change shape to match the corpse */
(void) newcham(mtmp, mptr, FALSE, FALSE);
@@ -703,7 +705,7 @@ boolean by_hero;
mon_adjust_speed(mtmp, 2, (struct obj *)0); /* MFAST */
}
}
} else if (corpse->oxlth && corpse->oattached == OATTACHED_MONST) {
} else if (has_omonst(corpse)) {
/* use saved traits */
xy.x = x, xy.y = y;
mtmp = montraits(corpse, &xy);
@@ -739,13 +741,13 @@ boolean by_hero;
}
/* handle recorporealization of an active ghost */
if (corpse->oxlth && corpse->oattached == OATTACHED_M_ID) {
if (has_omid(corpse)) {
unsigned m_id;
struct monst *ghost;
struct obj *otmp;
(void) memcpy((genericptr_t)&m_id,
(genericptr_t)corpse->oextra, sizeof m_id);
(genericptr_t)OMID(corpse), sizeof m_id);
ghost = find_mid(m_id, FM_FMON);
if (ghost && ghost->data == &mons[PM_GHOST]) {
if (canseemon(ghost))
@@ -768,11 +770,11 @@ boolean by_hero;
/* separate ghost monster no longer exists */
mongone(ghost);
}
corpse->oattached = OATTACHED_NOTHING;
free_omid(corpse);
}
/* monster retains its name */
if (corpse->onamelth)
if (has_oname(corpse))
mtmp = christen_monst(mtmp, ONAME(corpse));
/* partially eaten corpse yields wounded monster */
if (corpse->oeaten)
@@ -4013,9 +4015,8 @@ register struct obj *obj; /* no texts here! */
obj->owt = weight(obj);
obj->dknown = obj->bknown = obj->rknown = 0;
obj->known = objects[obj->otyp].oc_uses_known ? 0 : 1;
obj->onamelth = 0; /* no names */
obj->oxlth = 0; /* no extra data */
obj->oattached = OATTACHED_NOTHING;
if (obj->oextra) dealloc_oextra(obj->oextra);
obj->oextra = (struct oextra *)0;
if (obj->where == OBJ_FLOOR) {
obj_extract_self(obj); /* move rocks back on top */
place_object(obj, obj->ox, obj->oy);