obj->oextra->{omid,olong}
Change obj->oextra->omid from a usually-Null pointer field in oextra to a simple 'unsigned' that doesn't need any allocation beyond obj->oextra itself. Value 0 means that it is not in use; it is used to hold a monst.m_id and those are always non-zero. Delete unused obj->oextra->olong. 'olong' used to be the last field in struct obj, put there to force alignment of anything which followed it back when obj structures were over-allocated to append extra information. It had a comment about being used for temporary gold but whatever that was, temporary gold was gone long before obj->oextra got introduced. Bump EDITLEVEL since this invalidates existing 3.7 save files. Remove a bunch of tabs from obj.h and save.c.
This commit is contained in:
56
src/mkobj.c
56
src/mkobj.c
@@ -75,9 +75,8 @@ newoextra()
|
||||
oextra = (struct oextra *) alloc(sizeof (struct oextra));
|
||||
oextra->oname = 0;
|
||||
oextra->omonst = 0;
|
||||
oextra->omid = 0;
|
||||
oextra->olong = 0;
|
||||
oextra->omailcmd = 0;
|
||||
oextra->omid = 0;
|
||||
return oextra;
|
||||
}
|
||||
|
||||
@@ -92,10 +91,6 @@ struct obj *o;
|
||||
free((genericptr_t) x->oname);
|
||||
if (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);
|
||||
|
||||
@@ -141,42 +136,14 @@ struct obj *otmp;
|
||||
{
|
||||
if (!otmp->oextra)
|
||||
otmp->oextra = newoextra();
|
||||
if (!OMID(otmp)) {
|
||||
OMID(otmp) = (unsigned *) alloc(sizeof (unsigned));
|
||||
(void) memset((genericptr_t) OMID(otmp), 0, sizeof (unsigned));
|
||||
}
|
||||
OMID(otmp) = 0;
|
||||
}
|
||||
|
||||
void
|
||||
free_omid(otmp)
|
||||
struct obj *otmp;
|
||||
{
|
||||
if (otmp->oextra && OMID(otmp)) {
|
||||
free((genericptr_t) OMID(otmp));
|
||||
OMID(otmp) = (unsigned *) 0;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
newolong(otmp)
|
||||
struct obj *otmp;
|
||||
{
|
||||
if (!otmp->oextra)
|
||||
otmp->oextra = newoextra();
|
||||
if (!OLONG(otmp)) {
|
||||
OLONG(otmp) = (long *) alloc(sizeof (long));
|
||||
(void) memset((genericptr_t) OLONG(otmp), 0, sizeof (long));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
free_olong(otmp)
|
||||
struct obj *otmp;
|
||||
{
|
||||
if (otmp->oextra && OLONG(otmp)) {
|
||||
free((genericptr_t) OLONG(otmp));
|
||||
OLONG(otmp) = (long *) 0;
|
||||
}
|
||||
OMID(otmp) = 0;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -406,20 +373,13 @@ struct obj *obj2, *obj1;
|
||||
if (OMONST(obj1)->mextra)
|
||||
copy_mextra(OMONST(obj2), OMONST(obj1));
|
||||
}
|
||||
if (has_omailcmd(obj1)) {
|
||||
new_omailcmd(obj2, OMAILCMD(obj1));
|
||||
}
|
||||
if (has_omid(obj1)) {
|
||||
if (!OMID(obj2))
|
||||
newomid(obj2);
|
||||
(void) memcpy((genericptr_t) OMID(obj2), (genericptr_t) OMID(obj1),
|
||||
sizeof (unsigned));
|
||||
}
|
||||
if (has_olong(obj1)) {
|
||||
if (!OLONG(obj2))
|
||||
newolong(obj2);
|
||||
(void) memcpy((genericptr_t) OLONG(obj2), (genericptr_t) OLONG(obj1),
|
||||
sizeof (long));
|
||||
}
|
||||
if (has_omailcmd(obj1)) {
|
||||
new_omailcmd(obj2, OMAILCMD(obj1));
|
||||
OMID(obj2) = OMID(obj1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1605,7 +1565,7 @@ unsigned mid;
|
||||
if (!mid || !obj)
|
||||
return (struct obj *) 0;
|
||||
newomid(obj);
|
||||
*OMID(obj) = mid;
|
||||
OMID(obj) = mid;
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user