]> granicus.if.org Git - nethack/commitdiff
oextra follow-up - merging (trunk only)
authornethack.allison <nethack.allison>
Sat, 15 Apr 2006 13:37:58 +0000 (13:37 +0000)
committernethack.allison <nethack.allison>
Sat, 15 Apr 2006 13:37:58 +0000 (13:37 +0000)
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.

include/obj.h
src/eat.c
src/invent.c

index cfb42735960842a822b5a4b4ce1e0ee8ea54a971..634291db872bf18a0633e8ff98672cb01cf94c6d 100644 (file)
@@ -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() */
index ee2f0d14610a4229ef5d91eb03b410012153e89c..0553ef493c2c9e8722390088d44ca2acd5a9b3e3 100644 (file)
--- 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);
index 7de82850b7e5eee484d3cea9f35bd6773a5c70d3..6acf4212fdf746dc6e5a76ffdc76c835c4557fe2 100644 (file)
@@ -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;