]> granicus.if.org Git - nethack/commitdiff
Fix several touchstone-related things:
authornethack.allison <nethack.allison>
Thu, 24 Jan 2002 02:39:55 +0000 (02:39 +0000)
committernethack.allison <nethack.allison>
Thu, 24 Jan 2002 02:39:55 +0000 (02:39 +0000)
1. The switch statement was using the material "GOLD"
   rather than GOLD_CLASS.
2. If getobj() had been working for gold when it
   came to touchstones, there would have been a
   memory leak here because the object returned
   would have been from mkgoldobj().  The goldobj
   was not being freed anywhere, nor was it being
   put on a chain. You also would have had zero
   gold after rubbing it on the stone. The intent
   was clearly to allow gold since there was a
   case in the switch statement.
3. getobj() wasn't working properly for gold
   selection here anyway, so this was
   not the cause of <Someone>'s gold obj in inventory.
   You ended up dropping through to code that
   was supposed to print "You cannot verb object."
   For touchstones that came out as:
   "You cannot rub on the stone gold."

src/apply.c
src/invent.c

index 7f7d95a6fe1d264d8dd7b8b639ba70be7343f8c6..17d6cd6440bc630d8ef49d4ac114e66c528ab9ce 100644 (file)
@@ -1838,8 +1838,15 @@ struct obj *otmp;
        }
 
        switch (obj->oclass) {
-         case GOLD:
+         case GOLD_CLASS:
            color = "golden";
+#ifndef GOLDOBJ
+           /* goldobj back to u.ugold */
+           u.ugold = obj->quan;
+           obj->quan = 0L;
+           dealloc_obj(obj);
+           obj = (struct obj *)0;
+#endif
            break;
          case GEM_CLASS:
            if (otmp->blessed) {
index 2eb2291e1958091d4adbd1449a52350d68fa79fb..808b3683cfba9d2310824c764ce07585d5d26af9 100644 (file)
@@ -729,6 +729,10 @@ register const char *let,*word;
 #else
        if(*let == GOLD_CLASS) let++, usegold = TRUE;
 #endif
+       /* Ugly check for touchstone */
+       if (!strncmp(word, "rub on", 6) && u.ugold)
+               allowgold = usegold = TRUE;
+
        /* Equivalent of an "ugly check" for gold */
        if (usegold && !strcmp(word, "eat") && !metallivorous(youmonst.data))
 #ifndef GOLDOBJ