MCPcopy Create free account
hub / github.com/NetHack/NetHack / artifact_exists

Function artifact_exists

src/artifact.c:370–405  ·  view source on GitHub ↗

an artifact has just been created or is being "un-created" for a chance to be created again later */

Source from the content-addressed store, hash-verified

368/* an artifact has just been created or is being "un-created" for a chance
369 to be created again later */
370void
371artifact_exists(
372 struct obj *otmp,
373 const char *name,
374 boolean mod, /* True: exists, False: being un-created */
375 unsigned flgs) /* ONAME_xyz flags; not relevant if !mod */
376{
377 const struct artifact *a;
378
379 if (otmp && *name)
380 for (a = artilist + 1; a->otyp; a++)
381 if (a->otyp == otmp->otyp && !strcmp(a->name, name)) {
382 int m = (int) (a - artilist);
383
384 otmp->oartifact = (char) (mod ? m : 0);
385 otmp->age = 0;
386 if (otmp->otyp == RIN_INCREASE_DAMAGE)
387 otmp->spe = 0;
388 if (mod) { /* means being created rather than un-created */
389 /* one--and only one--of these should always be set */
390 if ((flgs & (ONAME_VIA_NAMING | ONAME_WISH | ONAME_GIFT
391 | ONAME_VIA_DIP | ONAME_LEVEL_DEF
392 | ONAME_BONES | ONAME_RANDOM)) == 0)
393 flgs |= ONAME_RANDOM; /* the default origin */
394 /* 'exists' bit will become set (in artifact_origin();
395 there's no ONAME_ flag) and flgs might also contain
396 the know_arti bit (hero knows that artifact exists) */
397 artifact_origin(otmp, flgs);
398 } else { /* uncreate */
399 /* clear all the flag bits */
400 artiexist[m] = zero_artiexist;
401 }
402 break;
403 }
404 return;
405}
406
407/* mark an artifact as 'found' */
408void

Callers 6

resetobjsFunction · 0.85
onameFunction · 0.85
readobjnamFunction · 0.85
xkilledFunction · 0.85
discard_minventFunction · 0.85
create_objectFunction · 0.85

Calls 1

artifact_originFunction · 0.85

Tested by

no test coverage detected