]> granicus.if.org Git - nethack/commitdiff
boulder/statue/landmine reversal and new fix
authornethack.allison <nethack.allison>
Sat, 30 Mar 2002 14:46:31 +0000 (14:46 +0000)
committernethack.allison <nethack.allison>
Sat, 30 Mar 2002 14:46:31 +0000 (14:46 +0000)
This includes a reversal of my earlier
boulder/statue/landmine fix,
and places a check for obj->where==OBJ_FLOOR into
fracture_rock().  I think this is a better approach
because:
- if eliminates the pointless extract/place in
fracture_rock, followed by extract/place in
the caller in the two places causing the crash
- it covers any similar situations that we
might have missed or that someone might add
accidentally (you might not expect the location
of an object to change inside fracture_rock())
- it allows fracturing to take place on the
other object chains if we ever need it (statues
falling down stairs, perhaps?)
- it doesn't move objects from other chains onto
the floor briefly as the current code does

src/explode.c
src/zap.c

index cd8e92f1f0553fbf8269c30c1bb47b1b90a90e63..b755e1f9cbf9e5c939fe5f79615d8f5b5fe9030b 100644 (file)
@@ -441,8 +441,7 @@ struct obj *obj;                    /* only scatter this obj        */
                        && rn2(10)) {
                if (otmp->otyp == BOULDER) {
                    pline("%s apart.", Tobjnam(otmp, "break"));
-                   fracture_rock(otmp); /* this will place fragments on floor */
-                   obj_extract_self(otmp);
+                   fracture_rock(otmp);
                    place_object(otmp, sx, sy);
                    if ((otmp = sobj_at(BOULDER, sx, sy)) != 0) {
                        /* another boulder here, restack it to the top */
@@ -455,8 +454,7 @@ struct obj *obj;                    /* only scatter this obj        */
                    if ((trap = t_at(sx,sy)) && trap->ttyp == STATUE_TRAP)
                            deltrap(trap);
                    pline("%s.", Tobjnam(otmp, "crumble"));
-                   (void) break_statue(otmp); /*this will place fragments on floor */
-                   obj_extract_self(otmp);
+                   (void) break_statue(otmp);
                    place_object(otmp, sx, sy); /* put fragments on floor */
                }
                used_up = TRUE;
index 62ba27b0cb3f8dcea4a6bb03882fe15f4f22f935..ca26d524c4248c4e51a90c0267794ac0236d99e4 100644 (file)
--- a/src/zap.c
+++ b/src/zap.c
@@ -3708,12 +3708,14 @@ register struct obj *obj;                  /* no texts here! */
        obj->onamelth = 0;              /* no names */
        obj->oxlth = 0;                 /* no extra data */
        obj->oattached = OATTACHED_NOTHING;
-       obj_extract_self(obj);          /* move rocks back on top */
-       place_object(obj, obj->ox, obj->oy);
-       if(!does_block(obj->ox,obj->oy,&levl[obj->ox][obj->oy]))
-           unblock_point(obj->ox,obj->oy);
-       if(cansee(obj->ox,obj->oy))
-           newsym(obj->ox,obj->oy);
+       if (obj->where == OBJ_FLOOR) {
+               obj_extract_self(obj);          /* move rocks back on top */
+               place_object(obj, obj->ox, obj->oy);
+               if(!does_block(obj->ox,obj->oy,&levl[obj->ox][obj->oy]))
+                       unblock_point(obj->ox,obj->oy);
+               if(cansee(obj->ox,obj->oy))
+                   newsym(obj->ox,obj->oy);
+       }
 }
 
 /* handle statue hit by striking/force bolt/pick-axe */