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

@@ -2155,7 +2155,8 @@ extern boolean objdescr_is(struct obj *, const char *) NONNULLARG2;
extern void oinit(void);
extern void savenames(NHFILE *) NONNULLARG1;
extern void restnames(NHFILE *) NONNULLARG1;
extern void discover_object(int, boolean, boolean);
extern void observe_object(struct obj *) NONNULLARG1;
extern void discover_object(int, boolean, boolean, boolean);
extern void undiscover_object(int);
extern boolean interesting_to_discover(int);
extern int choose_disco_sort(int);

View File

@@ -1527,7 +1527,7 @@ typedef uint32_t mmflags_nht; /* makemon MM_ flags */
(objects[(obj)->otyp].a_ac + (obj)->spe \
- min((int) greatest_erosion(obj), objects[(obj)->otyp].a_ac))
#define makeknown(x) discover_object((x), TRUE, TRUE)
#define makeknown(x) discover_object((x), TRUE, TRUE, TRUE)
#define distu(xx, yy) dist2((coordxy) (xx), (coordxy) (yy), u.ux, u.uy)
#define mdistu(mon) distu((mon)->mx, (mon)->my)
#define onlineu(xx, yy) online2((coordxy)(xx), (coordxy)(yy), u.ux, u.uy)

View File

@@ -107,7 +107,9 @@ struct obj {
* or enchantment); many items have this preset if
* they lack anything interesting to discover */
Bitfield(dknown, 1); /* description known (item seen "up close");
* some types of items always have dknown set */
* some types of items always have dknown set;
* use observe_object to set to TRUE so that the
* discoveries list is still correct */
Bitfield(bknown, 1); /* BUC (blessed/uncursed/cursed) known */
Bitfield(rknown, 1); /* rustproofing status known */
Bitfield(cknown, 1); /* for containers (including statues): the contents

View File

@@ -54,8 +54,8 @@ struct objclass {
* otherwise, obj->dknown and obj->bknown
* tell all, and obj->known should always
* be set for proper merging behavior. */
Bitfield(oc_pre_discovered, 1); /* already known at start of game; flagged
* as such when discoveries are listed */
Bitfield(oc_encountered, 1); /* hero has observed such an item at least
once (perhaps without naming it) */
Bitfield(oc_magic, 1); /* inherently magical object */
Bitfield(oc_charged, 1); /* may have +n or (n) charges */
Bitfield(oc_unique, 1); /* special one-of-a-kind object */

View File

@@ -17,7 +17,7 @@
* Incrementing EDITLEVEL can be used to force invalidation of old bones
* and save files.
*/
#define EDITLEVEL 130
#define EDITLEVEL 131
/*
* Development status possibilities.