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

View File

@@ -562,8 +562,8 @@ knows_object(int obj, boolean override_pauper)
{
if (u.uroleplay.pauper && !override_pauper)
return;
discover_object(obj, TRUE, FALSE);
objects[obj].oc_pre_discovered = 1; /* not a "discovery" */
/* mark as known, but not yet encountered */
discover_object(obj, TRUE, FALSE, FALSE);
}
/* Know ordinary (non-magical) objects of a certain class,
@@ -1207,6 +1207,7 @@ ini_inv_adjust_obj(struct trobj *trop, struct obj *obj)
} else {
if (objects[obj->otyp].oc_uses_known)
obj->known = 1;
/* not observe_object during startup, that's handled later */
obj->dknown = obj->bknown = obj->rknown = 1;
if (Is_container(obj) || obj->otyp == STATUE) {
obj->cknown = obj->lknown = 1;
@@ -1246,9 +1247,9 @@ ini_inv_use_obj(struct obj *obj)
{
/* Make the type known if necessary */
if (OBJ_DESCR(objects[obj->otyp]) && obj->known)
discover_object(obj->otyp, TRUE, FALSE);
discover_object(obj->otyp, TRUE, TRUE, FALSE);
if (obj->otyp == OIL_LAMP)
discover_object(POT_OIL, TRUE, FALSE);
discover_object(POT_OIL, TRUE, TRUE, FALSE);
if (obj->oclass == ARMOR_CLASS) {
if (is_shield(obj) && !uarms && !(uwep && bimanual(uwep))) {