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

Function find_oid

src/shk.c:2776–2804  ·  view source on GitHub ↗

* Look for o_id on all lists but billobj. Return obj or NULL if not found. * Its OK for restore_timers() to call this function, there should not * be any timeouts on the gb.billobjs chain. */

Source from the content-addressed store, hash-verified

2774 * be any timeouts on the gb.billobjs chain.
2775 */
2776struct obj *
2777find_oid(unsigned int id)
2778{
2779 struct obj *obj;
2780 struct monst *mon, *mmtmp[3];
2781 int i;
2782
2783 /* first check various obj lists directly */
2784 if ((obj = o_on(id, gi.invent)) != 0)
2785 return obj;
2786 if ((obj = o_on(id, fobj)) != 0)
2787 return obj;
2788 if ((obj = o_on(id, svl.level.buriedobjlist)) != 0)
2789 return obj;
2790 if ((obj = o_on(id, gm.migrating_objs)) != 0)
2791 return obj;
2792
2793 /* not found yet; check inventory for members of various monst lists */
2794 mmtmp[0] = fmon;
2795 mmtmp[1] = gm.migrating_mons;
2796 mmtmp[2] = gm.mydogs; /* for use during level changes */
2797 for (i = 0; i < 3; i++)
2798 for (mon = mmtmp[i]; mon; mon = mon->nmon)
2799 if ((obj = o_on(id, mon->minvent)) != 0)
2800 return obj;
2801
2802 /* not found at all */
2803 return (struct obj *) 0;
2804}
2805
2806/* Returns the price of an arbitrary item in the shop,
2807 0 if the item doesn't belong to a shopkeeper or hero is not in the shop. */

Callers 6

relink_light_sourcesFunction · 0.85
write_lsFunction · 0.85
relink_timersFunction · 0.85
bp_to_objFunction · 0.85
gem_learnedFunction · 0.85

Calls 1

o_onFunction · 0.85

Tested by

no test coverage detected