Accurately track which items have been discovered, even if not #named

This fixes a couple of bugs: a long-standing bug in which writing a
scroll by label could fail even if you've already seen a scroll with
that label (due to the game not tracking whether or not you've seen a
scroll if it doesn't have a name); and a somewhat newer bug in which
spellbooks auto-identified by Wizard knowledge were marked as having
been encountered (rather than as known but not encountered).

Breaks save file compatibility, but not bones files.
This commit is contained in:
Alex Smith
2025-11-25 22:42:38 +00:00
parent 10a5e67478
commit 8c29b20010
38 changed files with 155 additions and 122 deletions
+12 -6
View File
@@ -1547,7 +1547,8 @@ consume_tin(const char *mesg)
mnum = tin->corpsenm;
if (mnum == NON_PM) {
pline("It turns out to be empty.");
tin->dknown = tin->known = 1;
observe_object(tin);
tin->known = 1;
tin = costly_tin(COST_OPEN);
use_up_tin(tin);
if (always_eat)
@@ -1579,8 +1580,10 @@ consume_tin(const char *mesg)
if (y_n("Eat it?") == 'n') {
if (flags.verbose)
You("discard the open tin.");
if (!Hallucination)
tin->dknown = tin->known = 1;
if (!Hallucination) {
observe_object(tin);
tin->known = 1;
}
tin = costly_tin(COST_OPEN);
use_up_tin(tin);
return;
@@ -1594,7 +1597,8 @@ consume_tin(const char *mesg)
eating_conducts(&mons[mnum]);
tin->dknown = tin->known = 1;
observe_object(tin);
tin->known = 1;
/* charge for one at pre-eating cost */
tin = svc.context.tin.tin = costly_tin(COST_OPEN);
@@ -1641,7 +1645,8 @@ consume_tin(const char *mesg)
Blind ? "" : " ", Blind ? "" : hcolor(NH_GREEN));
} else {
pline("It contains spinach.");
tin->dknown = tin->known = 1;
observe_object(tin);
tin->known = 1;
}
if (!always_eat && y_n("Eat it?") == 'n') {
@@ -2265,7 +2270,8 @@ eataccessory(struct obj *otmp)
if (u.uhp <= 0)
return; /* died from sink fall */
}
otmp->known = otmp->dknown = 1; /* by taste */
observe_object(otmp);
otmp->known = 1; /* by taste */
if (!rn2(otmp->oclass == RING_CLASS ? 3 : 5)) {
switch (otmp->otyp) {
default: