]> granicus.if.org Git - nethack/commitdiff
obj_no_longer_held consistency
authorcohrs <cohrs>
Sat, 9 Feb 2002 21:55:45 +0000 (21:55 +0000)
committercohrs <cohrs>
Sat, 9 Feb 2002 21:55:45 +0000 (21:55 +0000)
Call obj_no_longer_held whenever an object hits the floor, no matter what
previously held it.  Also handle stoning of prior holder.

src/apply.c
src/bones.c
src/do.c
src/mkobj.c
src/mon.c
src/muse.c
src/zap.c

index ae276232a96e34448ecbbd609e3b33dec1358687..848660942cdab6c0bb3951a596fbeb12701b66c2 100644 (file)
@@ -2178,7 +2178,6 @@ struct obj *obj;
                    /* to floor near you */
                    You("yank %s %s to the %s!", s_suffix(mon_nam(mtmp)),
                        onambuf, surface(u.ux, u.uy));
-                   obj_no_longer_held(otmp);
                    place_object(otmp, u.ux, u.uy);
                    stackobj(otmp);
                    break;
index c96834b07e8082bceccb081cd9f0bb32889d2cff..f1758cec39cfcdda923e31835e28c063036240fc 100644 (file)
@@ -126,11 +126,12 @@ struct obj *cont;
 
        while ((otmp = invent) != 0) {
                obj_extract_self(otmp);
+               obj_no_longer_held(otmp);
 
                otmp->owornmask = 0;
                /* lamps don't go out when dropped */
-               if ((cont || artifact_light(otmp)) && obj_is_burning(otmp))     /* smother in statue */
-                       end_burn(otmp, otmp->otyp != MAGIC_LAMP && !artifact_light(otmp));
+               if ((cont || artifact_light(otmp)) && obj_is_burning(otmp))
+                   end_burn(otmp, TRUE);       /* smother in statue */
 
                if(otmp->otyp == SLIME_MOLD) goodfruit(otmp->spe);
 
index ef261e787d9d8f20ff4cb81c9bff384d330c4c7d..2dd8ca8405ed2519494d76ca9a5afd32fd322d20 100644 (file)
--- a/src/do.c
+++ b/src/do.c
@@ -531,7 +531,6 @@ register struct obj *obj;
 
        if (!u.uswallow && flooreffects(obj,u.ux,u.uy,"drop")) return;
        /* uswallow check done by GAN 01/29/87 */
-       obj_no_longer_held(obj);
        if(u.uswallow) {
            boolean could_petrify;
            if (obj != uball) {         /* mon doesn't pick up ball */
@@ -557,25 +556,28 @@ register struct obj *obj;
        }
 }
 
+/* things that must change when not held; recurse into containers.
+   Called for both player and monsters */
 void
-obj_no_longer_held(obj)        /* things that must change when not held; recurse into containers */
+obj_no_longer_held(obj)
 struct obj *obj;
 {
        if (!obj) {
-               return;
+           return;
        } else if ((Is_container(obj) || obj->otyp == STATUE) && obj->cobj) {
-               struct obj *contents;
-               for(contents=obj->cobj; contents; contents=contents->nobj)
-                       obj_no_longer_held(contents);
+           struct obj *contents;
+           for(contents=obj->cobj; contents; contents=contents->nobj)
+               obj_no_longer_held(contents);
        }
        switch(obj->otyp) {
-               case CRYSKNIFE:
-                       /* KMH -- Fixed crysknives have only 10% chance of reverting */
-                       if (!obj->oerodeproof || !rn2(10)) {
-                               obj->otyp = WORM_TOOTH;
-                               obj->oerodeproof = 0;
-                       }
-                       break;
+       case CRYSKNIFE:
+           /* KMH -- Fixed crysknives have only 10% chance of reverting */
+           /* only changes when not held by player or monster */
+           if (!obj->oerodeproof || !rn2(10)) {
+               obj->otyp = WORM_TOOTH;
+               obj->oerodeproof = 0;
+           }
+           break;
        }
 }
 
index 81d29946b2922b29e651b5ae919819b1c6001bc5..658165cea208bf848471dc02e963c58ffff2830c 100644 (file)
@@ -1082,6 +1082,7 @@ int x, y;
     if (otmp->where != OBJ_FREE)
        panic("place_object: obj not free");
 
+    obj_no_longer_held(otmp);
     if (otmp->otyp == BOULDER) block_point(x,y);       /* vision */
 
     /* obj goes under boulders */
@@ -1393,6 +1394,8 @@ add_to_container(container, obj)
 
     if (obj->where != OBJ_FREE)
        panic("add_to_container: obj not free");
+    if (container->where != OBJ_INVENT && container->where != OBJ_MINVENT)
+       obj_no_longer_held(obj);
 
     /* merge if possible */
     for (otmp = container->cobj; otmp; otmp = otmp->nobj)
index af9253cdd3f57af3abfc54baa8c4815bf5b13ab9..721828e1616704486c60e9532b9c4ec363c4b15e 100644 (file)
--- a/src/mon.c
+++ b/src/mon.c
@@ -1488,6 +1488,7 @@ register struct monst *mdef;
                /* some objects may end up outside the statue */
                while ((obj = mdef->minvent) != 0) {
                    obj_extract_self(obj);
+                   obj_no_longer_held(obj);
                    if (obj->owornmask & W_WEP)
                        setmnotwielded(mdef,obj);
                    obj->owornmask = 0L;
index 79b4a0032a8e1b2c64b55d693cbb410b5ffd5c0e..a945ace2bbbec0dc3c1ceffd2c80cff62c2d5aa0 100644 (file)
@@ -1823,7 +1823,6 @@ skipmsg:
                        case 1:         /* onto floor beneath mon */
                            pline("%s yanks %s from your %s!", Monnam(mtmp),
                                  the_weapon, hand);
-                           obj_no_longer_held(obj);
                            place_object(obj, mtmp->mx, mtmp->my);
                            break;
                        case 2:         /* onto floor beneath you */
index 44cb174b4e75a671f7e8e9fb4c19aa9f56bb56af..157c2c82d19a4c0032c0c2f9edaaed93fb9ee5e4 100644 (file)
--- a/src/zap.c
+++ b/src/zap.c
@@ -4037,6 +4037,10 @@ retry:
        u.uconduct.wishes++;
 
        if (otmp != &zeroobj) {
+           /* place_object looses these */
+           boolean crysknife = (otmp->otyp == CRYSKNIFE);
+           int oerode = otmp->oerodeproof;
+
            /* in case touching this object turns out to be fatal */
            place_object(otmp, u.ux, u.uy);
 
@@ -4045,6 +4049,10 @@ retry:
                dropy(otmp);            /* now put it back again :-) */
            } else {
                obj_extract_self(otmp);
+               if (crysknife) {
+                   otmp->otyp = CRYSKNIFE;
+                   otmp->oerodeproof = oerode;
+               }
                /* The(aobjnam()) is safe since otmp is unidentified -dlc */
                (void) hold_another_object(otmp, u.uswallow ?
                                       "Oops!  %s out of your reach!" :