]> granicus.if.org Git - nethack/commitdiff
Fix crystal ball use after being destroyed
authorPasi Kallinen <paxed@alt.org>
Sun, 1 Nov 2015 16:49:38 +0000 (18:49 +0200)
committerPasi Kallinen <paxed@alt.org>
Sun, 1 Nov 2015 16:49:43 +0000 (18:49 +0200)
Crystal ball can be destroyed when used, so pass the object parameter
back as null in that case.

include/extern.h
src/apply.c
src/artifact.c
src/detect.c

index d3754352e5c326fe8d3ac8e71a70a1435f1e8040..8d6fda3d2944150881e97ea2dedf08f3017d3c78 100644 (file)
@@ -243,7 +243,7 @@ E int FDECL(object_detect, (struct obj *, int));
 E int FDECL(monster_detect, (struct obj *, int));
 E int FDECL(trap_detect, (struct obj *));
 E const char *FDECL(level_distance, (d_level *));
-E void FDECL(use_crystal_ball, (struct obj *));
+E void FDECL(use_crystal_ball, (struct obj **));
 E void NDECL(do_mapping);
 E void NDECL(do_vicinity_map);
 E void FDECL(cvt_sdoor_to_door, (struct rm *));
index f1e46b65605e618b5f0d5542b8a0617a22f1410c..31800d8f8bb237bc30d0870c59a7c4b215fe0809 100644 (file)
@@ -3486,7 +3486,7 @@ doapply()
         res = use_towel(obj);
         break;
     case CRYSTAL_BALL:
-        use_crystal_ball(obj);
+        use_crystal_ball(&obj);
         break;
     case MAGIC_MARKER:
         res = dowrite(obj);
index 4e6c22015f135c2ae2b8ee69496735a4031b26f5..78905793255bd30677bd696e33c3bb96aa3f3d9d 100644 (file)
@@ -1401,13 +1401,13 @@ doinvoke()
 
 STATIC_OVL int
 arti_invoke(obj)
-register struct obj *obj;
+struct obj *obj;
 {
     register const struct artifact *oart = get_artifact(obj);
 
     if (!oart || !oart->inv_prop) {
         if (obj->otyp == CRYSTAL_BALL)
-            use_crystal_ball(obj);
+            use_crystal_ball(&obj);
         else
             pline1(nothing_happens);
         return 1;
index 41ee1f4d307b5c838436012fcb39c5659a7f9e41..c8f824eedadcb16e3a6407fc496d96a24d9bf920 100644 (file)
@@ -891,11 +891,12 @@ static const struct {
 };
 
 void
-use_crystal_ball(obj)
-struct obj *obj;
+use_crystal_ball(optr)
+struct obj **optr;
 {
     char ch;
     int oops;
+    struct obj *obj = *optr;
 
     if (Blind) {
         pline("Too bad you can't see %s.", the(xname(obj)));
@@ -930,7 +931,7 @@ struct obj *obj;
         case 5:
             pline("%s!", Tobjnam(obj, "explode"));
             useup(obj);
-            obj = 0; /* it's gone */
+            *optr = obj = 0; /* it's gone */
             /* physical damage cause by the shards and force */
             losehp(Maybe_Half_Phys(rnd(30)), "exploding crystal ball",
                    KILLED_BY_AN);