From: nethack.allison Date: Sat, 15 Apr 2006 13:37:58 +0000 (+0000) Subject: oextra follow-up - merging (trunk only) X-Git-Tag: MOVE2GIT~1061 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d156b95e0d85482ca5983718e473d0616d2872dd;p=nethack oextra follow-up - merging (trunk only) It seemed inappropriate to allocate and tack on an oextra structure just to mark it as unmergable, and the oextra struct itself wouldn't be released until a save/restore took place. This uses one of the freed up oattached bits to prevent the merge. --- diff --git a/include/obj.h b/include/obj.h index cfb427359..634291db8 100644 --- a/include/obj.h +++ b/include/obj.h @@ -94,9 +94,12 @@ struct obj { Bitfield(lamplit,1); /* a light-source -- can be lit */ #ifdef INVISIBLE_OBJECTS Bitfield(oinvis,1); /* invisible */ +#else + Bitfield(oreserved1,1); #endif Bitfield(greased,1); /* covered with grease */ - /* 2 free bits */ + Bitfield(nomerge,1); /* set temporarily to prevent merging */ + /* 1 free bit */ Bitfield(in_use,1); /* for magic items before useup items */ Bitfield(bypass,1); /* mark this as an object to be skipped by bhito() */ diff --git a/src/eat.c b/src/eat.c index ee2f0d146..0553ef493 100644 --- a/src/eat.c +++ b/src/eat.c @@ -297,9 +297,9 @@ register struct obj *otmp; dropy(otmp); sellobj_state(SELL_NORMAL); } else { - newolong(otmp); /* hack to prevent merge */ + otmp->nomerge = 1; /* used to prevent merge */ otmp = addinv(otmp); - free_olong(otmp); + otmp->nomerge = 0; } } return(otmp); diff --git a/src/invent.c b/src/invent.c index 7de82850b..6acf4212f 100644 --- a/src/invent.c +++ b/src/invent.c @@ -2416,6 +2416,9 @@ mergable(otmp, obj) /* returns TRUE if obj & otmp can be merged */ obj->bypass != otmp->bypass) return(FALSE); + if (obj->nomerge) /* explicitly marked to prevent merge */ + return FALSE; + if ((obj->oclass==WEAPON_CLASS || obj->oclass==ARMOR_CLASS) && (obj->oerodeproof!=otmp->oerodeproof || obj->rknown!=otmp->rknown)) return FALSE;