From 6eb2eb7df7c84b5faaa1e3598ce4f4b2ce48d300 Mon Sep 17 00:00:00 2001 From: Alex Smith Date: Tue, 25 Nov 2025 23:01:46 +0000 Subject: [PATCH] Accurate dknown when writing scrolls while blind If you write the scroll by description, you obviously know what the label is because you specified the label (even if you didn't know what the scroll was). When writing an unidentified scroll by type, though, and getting lucky, you don't necessarily know the label of the resulting scroll. --- src/write.c | 36 +++++------------------------------- 1 file changed, 5 insertions(+), 31 deletions(-) diff --git a/src/write.c b/src/write.c index 312072a58..538406f34 100644 --- a/src/write.c +++ b/src/write.c @@ -4,7 +4,6 @@ #include "hack.h" staticfn int cost(struct obj *) NONNULLARG1; -staticfn boolean label_known(int, struct obj *) NO_NNARGS; staticfn int write_ok(struct obj *) NO_NNARGS; staticfn char *new_book_description(int, char *) NONNULL NONNULLPTRS; @@ -57,34 +56,6 @@ cost(struct obj *otmp) return 1000; } -/* decide whether the hero knowns a particular scroll's label; - unfortunately, we can't track things that haven't been added to - the discoveries list and aren't present in current inventory, - so some scrolls with ought to yield True will end up False */ -staticfn boolean -label_known(int scrolltype, struct obj *objlist) -{ - struct obj *otmp; - - /* only scrolls */ - if (objects[scrolltype].oc_class != SCROLL_CLASS) - return FALSE; - /* type known implies full discovery; otherwise, - user-assigned name implies partial discovery */ - if (objects[scrolltype].oc_name_known || objects[scrolltype].oc_uname) - return TRUE; - /* check inventory, including carried containers with known contents */ - for (otmp = objlist; otmp; otmp = otmp->nobj) { - if (otmp->otyp == scrolltype && otmp->dknown) - return TRUE; - if (Has_contents(otmp) && otmp->cknown - && label_known(scrolltype, otmp->cobj)) - return TRUE; - } - /* not found */ - return FALSE; -} - /* getobj callback for object to write on */ staticfn int write_ok(struct obj *obj) @@ -399,8 +370,11 @@ dowrite(struct obj *pen) /* unlike alchemy, for example, a successful result yields the specifically chosen item so hero recognizes it even if blind; the exception is for being lucky writing an undiscovered scroll, - where the label associated with the type-name isn't known yet */ - new_obj->dknown = label_known(new_obj->otyp, gi.invent) ? 1 : 0; + where the label associated with the type-name isn't known yet; + but if writing by description, the description is always known */ + new_obj->dknown = FALSE; + if (objects[new_obj->otyp].oc_name_known || by_descr) + observe_object(new_obj); new_obj = hold_another_object(new_obj, "Oops! %s out of your grasp!", The(aobjnam(new_obj, "slip")),