From: nethack.allison Date: Thu, 24 Jan 2002 02:39:55 +0000 (+0000) Subject: Fix several touchstone-related things: X-Git-Tag: MOVE2GIT~3365 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4c46f6eb2b84fcc0f6353f298091de6e6e1e7797;p=nethack Fix several touchstone-related things: 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 '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." --- diff --git a/src/apply.c b/src/apply.c index 7f7d95a6f..17d6cd644 100644 --- a/src/apply.c +++ b/src/apply.c @@ -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) { diff --git a/src/invent.c b/src/invent.c index 2eb2291e1..808b3683c 100644 --- a/src/invent.c +++ b/src/invent.c @@ -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