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:
@@ -351,6 +351,8 @@ E void NDECL(heal_legs);
|
||||
E int FDECL(getpos, (coord *,BOOLEAN_P,const char *));
|
||||
E void FDECL(new_mname, (struct monst *,int));
|
||||
E void FDECL(free_mname, (struct monst *));
|
||||
E void FDECL(new_oname, (struct obj *,int));
|
||||
E void FDECL(free_oname, (struct obj *));
|
||||
E struct monst *FDECL(christen_monst, (struct monst *,const char *));
|
||||
E int NDECL(do_mname);
|
||||
E struct obj *FDECL(oname, (struct obj *,const char *));
|
||||
@@ -974,6 +976,7 @@ E struct monst *FDECL(clone_mon, (struct monst *,XCHAR_P,XCHAR_P));
|
||||
E int FDECL(monhp_per_lvl, (struct monst *));
|
||||
E void FDECL(newmonhp, (struct monst *,int));
|
||||
E struct mextra *NDECL(newmextra);
|
||||
E void FDECL(copy_mextra, (struct monst *,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);
|
||||
@@ -1100,6 +1103,17 @@ E const char *FDECL(waterbody_name, (XCHAR_P,XCHAR_P));
|
||||
|
||||
/* ### mkobj.c ### */
|
||||
|
||||
E struct oextra *NDECL(newoextra);
|
||||
E void FDECL(copy_oextra, (struct obj *,struct obj *));
|
||||
E void FDECL(dealloc_oextra, (struct oextra *));
|
||||
E void FDECL(newomonst, (struct obj *));
|
||||
E void FDECL(free_omonst, (struct obj *));
|
||||
E void FDECL(newomid, (struct obj *));
|
||||
E void FDECL(free_omid, (struct obj *));
|
||||
E void FDECL(newolong, (struct obj *));
|
||||
E void FDECL(free_olong, (struct obj *));
|
||||
E void FDECL(new_omailcmd, (struct obj *,char *));
|
||||
E void FDECL(free_omailcmd, (struct obj *));
|
||||
E struct obj *FDECL(mkobj_at, (CHAR_P,int,int,BOOLEAN_P));
|
||||
E struct obj *FDECL(mksobj_at, (int,int,int,BOOLEAN_P,BOOLEAN_P));
|
||||
E struct obj *FDECL(mkobj, (CHAR_P,BOOLEAN_P));
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* SCCS Id: @(#)mextra.h 3.5 2006/02/19 */
|
||||
/* SCCS Id: @(#)mextra.h 3.5 2006/04/14 */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
@@ -47,15 +47,12 @@
|
||||
* 6. Adjust size_monst() in src/cmd.c appropriately.
|
||||
* 7. Adjust dealloc_mextra() in src/mon.c to clean up
|
||||
* properly during monst deallocation.
|
||||
* 8. Adjust restmonchn() in src/restore.c to deal with your
|
||||
* struct during a restore.
|
||||
* 9. Adjust buffer_to_mon() in src/restore.c to properly
|
||||
* unpackage the mextra fields during revival.
|
||||
* 10. Adjust savemonchn() in src/save.c to deal with your
|
||||
* struct during a save.
|
||||
* 11. Adjust mon_to_buffer() in src/save.c to properly package
|
||||
* up your struct when the rest of the monst struct is
|
||||
* packaged up.
|
||||
* 8. Adjust copy_mextra() in src/mon.c to make duplicate
|
||||
* copies of your struct or data on another monst struct.
|
||||
* 9. Adjust restmon() in src/restore.c to deal with your
|
||||
* struct or data during a restore.
|
||||
* 10. Adjust savemon() in src/save.c to deal with your
|
||||
* struct or data during a save.
|
||||
*/
|
||||
|
||||
/***
|
||||
@@ -184,6 +181,6 @@ struct mextra {
|
||||
#define ESHK(mon) ((mon)->mextra->eshk)
|
||||
#define EMIN(mon) ((mon)->mextra->emin)
|
||||
#define EDOG(mon) ((mon)->mextra->edog)
|
||||
#define has_name(mon) ((mon)->mextra && MNAME(mon))
|
||||
#define has_mname(mon) ((mon)->mextra && MNAME(mon))
|
||||
|
||||
#endif /* MEXTRA_H */
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* SCCS Id: @(#)obj.h 3.5 2002/01/07 */
|
||||
/* SCCS Id: @(#)obj.h 3.5 2006/04/14 */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
@@ -14,6 +14,17 @@ union vptrs {
|
||||
struct monst *v_ocarry; /* point back to carrying monst */
|
||||
};
|
||||
|
||||
/***
|
||||
** oextra -- collection of all object extensions
|
||||
*/
|
||||
struct oextra {
|
||||
char *oname; /* ptr to name of object */
|
||||
struct monst *omonst; /* ptr to attached monst struct */
|
||||
unsigned *omid; /* ptr to m_id */
|
||||
long *olong; /* ptr to misc long (temporary gold object) */
|
||||
char *omailcmd; /* response_cmd for mail deliver */
|
||||
};
|
||||
|
||||
struct obj {
|
||||
struct obj *nobj;
|
||||
union vptrs v;
|
||||
@@ -84,11 +95,7 @@ struct obj {
|
||||
Bitfield(oinvis,1); /* invisible */
|
||||
#endif
|
||||
Bitfield(greased,1); /* covered with grease */
|
||||
Bitfield(oattached,2); /* obj struct has special attachment */
|
||||
#define OATTACHED_NOTHING 0
|
||||
#define OATTACHED_MONST 1 /* monst struct in oextra */
|
||||
#define OATTACHED_M_ID 2 /* monst id in oextra */
|
||||
#define OATTACHED_UNUSED3 3
|
||||
/* 2 free bits */
|
||||
|
||||
Bitfield(in_use,1); /* for magic items before useup items */
|
||||
Bitfield(bypass,1); /* mark this as an object to be skipped by bhito() */
|
||||
@@ -102,18 +109,23 @@ struct obj {
|
||||
#define fromsink corpsenm /* a potion from a sink */
|
||||
unsigned oeaten; /* nutrition left in food, if partly eaten */
|
||||
long age; /* creation date */
|
||||
|
||||
uchar onamelth; /* length of name (following oxlth) */
|
||||
short oxlth; /* length of following data */
|
||||
/* in order to prevent alignment problems oextra should
|
||||
be (or follow) a long int */
|
||||
long owornmask;
|
||||
long oextra[1]; /* used for name of ordinary objects - length
|
||||
is flexible; amount for tmp gold objects */
|
||||
struct oextra *oextra; /* pointer to oextra struct */
|
||||
};
|
||||
|
||||
#define newobj(xl) (struct obj *)alloc((unsigned)(xl) + sizeof(struct obj))
|
||||
#define ONAME(otmp) (((char *)(otmp)->oextra) + (otmp)->oxlth)
|
||||
#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))
|
||||
|
||||
#define newobj() (struct obj *)alloc(sizeof(struct obj))
|
||||
|
||||
/* Weapons and weapon-tools */
|
||||
/* KMH -- now based on skill categories. Formerly:
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* SCCS Id: @(#)patchlevel.h 3.5 2006/03/25 */
|
||||
/* SCCS Id: @(#)patchlevel.h 3.5 2006/04/14 */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
* Incrementing EDITLEVEL can be used to force invalidation of old bones
|
||||
* and save files.
|
||||
*/
|
||||
#define EDITLEVEL 28
|
||||
#define EDITLEVEL 29
|
||||
|
||||
#define COPYRIGHT_BANNER_A \
|
||||
"NetHack, Copyright 1985-2006"
|
||||
|
||||
Reference in New Issue
Block a user