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

Function o_in

src/detect.c:200–223  ·  view source on GitHub ↗

recursively search obj for an object in class oclass, return 1st found */

Source from the content-addressed store, hash-verified

198
199/* recursively search obj for an object in class oclass, return 1st found */
200struct obj *
201o_in(struct obj *obj, char oclass)
202{
203 struct obj *otmp;
204 struct obj *temp;
205
206 if (obj->oclass == oclass)
207 return obj;
208 /*
209 * Note: we exclude SchroedingersBox because the corpse it contains
210 * isn't necessarily a corpse yet. Resolving the status would lead
211 * to complications if it turns out to be a live cat. We know that
212 * that Box can't contain anything else because putting something in
213 * would resolve the cat/corpse situation and convert to ordinary box.
214 */
215 if (Has_contents(obj) && !SchroedingersBox(obj)) {
216 for (otmp = obj->cobj; otmp; otmp = otmp->nobj)
217 if (otmp->oclass == oclass)
218 return otmp;
219 else if (Has_contents(otmp) && (temp = o_in(otmp, oclass)) != 0)
220 return temp;
221 }
222 return (struct obj *) 0;
223}
224
225/* Recursively search obj for an object made of specified material.
226 * Return first found.

Callers 4

check_map_spotFunction · 0.85
gold_detectFunction · 0.85
food_detectFunction · 0.85
object_detectFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected