an artifact has just been created or is being "un-created" for a chance to be created again later */
| 368 | /* an artifact has just been created or is being "un-created" for a chance |
| 369 | to be created again later */ |
| 370 | void |
| 371 | artifact_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' */ |
| 408 | void |
no test coverage detected