found_artifact() groundwork

Lay groundwork for generating a log event when finding an artifact
on the floor or carried by a monster.  This part should not produce
any change in behavior.

Move g.artidisco[] and g.artiexist[] out of the instance_globals
struct back to local within artifact.c.  They are both initialized
at the start of a game (and only used in that file) so don't need
to be part of any bulk reinitialization if restart-instead-of-exit
ever gets implemented.

Convert artiexist[] from an array of booleans to an array of structs
containing a pair of bitfields.  artiexist[].exists is a direct
replacement for the boolean; artiexist[].found is new but not put to
any significant use yet.  If will be used to suppress the future
found-an-artifact event for cases where a more specific event (like
crowning or divine gift as #offer reward) is already produced.

Remove g.via_naming altogether and add an extra argument to oname()
calls to replace it.

Add an extra argument to artifact_exists() calls.
This commit is contained in:
PatR
2022-03-07 02:06:55 -08:00
parent 90fc7402b8
commit d37fa4138a
20 changed files with 137 additions and 85 deletions

View File

@@ -352,7 +352,7 @@ copy_oextra(struct obj *obj2, struct obj *obj1)
if (!obj2->oextra)
obj2->oextra = newoextra();
if (has_oname(obj1))
oname(obj2, ONAME(obj1));
oname(obj2, ONAME(obj1), ONAME_NO_FLAGS);
if (has_omonst(obj1)) {
if (!OMONST(obj2))
newomonst(obj2);
@@ -1127,7 +1127,7 @@ mksobj(int otyp, boolean init, boolean artif)
break;
case SPE_NOVEL:
otmp->novelidx = -1; /* "none of the above"; will be changed */
otmp = oname(otmp, noveltitle(&otmp->novelidx));
otmp = oname(otmp, noveltitle(&otmp->novelidx), ONAME_NO_FLAGS);
break;
}
@@ -2044,7 +2044,7 @@ mk_named_object(
otmp = mkcorpstat(objtype, (struct monst *) 0, ptr, x, y, corpstatflags);
if (nm)
otmp = oname(otmp, nm);
otmp = oname(otmp, nm, ONAME_NO_FLAGS);
return otmp;
}
@@ -2280,7 +2280,7 @@ discard_minvent(struct monst *mtmp, boolean uncreate_artifacts)
/* this has now become very similar to m_useupall()... */
extract_from_minvent(mtmp, otmp, TRUE, TRUE);
if (uncreate_artifacts && otmp->oartifact)
artifact_exists(otmp, safe_oname(otmp), FALSE);
artifact_exists(otmp, safe_oname(otmp), FALSE, FALSE);
obfree(otmp, (struct obj *) 0); /* dealloc_obj() isn't sufficient */
}
}