MCPcopy Index your code
hub / github.com/NetHack/NetHack / discover_object

Function discover_object

src/o_init.c:453–494  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

451}
452
453void
454discover_object(
455 int oindx, /* type of object */
456 boolean mark_as_known, /* discover the type */
457 boolean mark_as_encountered, /* mark the type as having been seen/felt */
458 boolean credit_hero) /* exercise wisdom */
459{
460 if (oindx < FIRST_OBJECT) /* don't discover generic objects */
461 return;
462
463 if ((!objects[oindx].oc_name_known && mark_as_known)
464 || (!objects[oindx].oc_encountered && mark_as_encountered)
465 || (Role_if(PM_SAMURAI)
466 && Japanese_item_name(oindx, (const char *) 0))) {
467 int dindx, acls = objects[oindx].oc_class;
468
469 /* Loop thru disco[] 'til we find the target (which may have been
470 uname'd) or the next open slot; one or the other will be found
471 before we reach the next class... */
472 for (dindx = svb.bases[acls]; svd.disco[dindx] != 0; dindx++)
473 if (svd.disco[dindx] == oindx)
474 break;
475 svd.disco[dindx] = oindx;
476
477 if (mark_as_encountered)
478 objects[oindx].oc_encountered = 1;
479
480 if (!objects[oindx].oc_name_known && mark_as_known) {
481 objects[oindx].oc_name_known = 1;
482 if (credit_hero)
483 exercise(A_WIS, TRUE);
484
485 /* !in_moveloop => initial inventory,
486 gameover => final disclosure */
487 if (program_state.in_moveloop && !program_state.gameover) {
488 if (objects[oindx].oc_class == GEM_CLASS)
489 gem_learned(oindx); /* could affect price of unpaid gems */
490 update_inventory();
491 }
492 }
493 }
494}
495
496/* if a class name has been cleared, we may need to purge it from disco[] */
497void

Callers 8

artifact_scoreFunction · 0.85
really_doneFunction · 0.85
container_contentsFunction · 0.85
observe_objectFunction · 0.85
docallFunction · 0.85
knows_objectFunction · 0.85
ini_inv_use_objFunction · 0.85
skill_based_spellbook_idFunction · 0.85

Calls 4

Japanese_item_nameFunction · 0.85
exerciseFunction · 0.85
gem_learnedFunction · 0.85
update_inventoryFunction · 0.85

Tested by

no test coverage detected