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

Function get_obj_location

src/zap.c:653–689  ·  view source on GitHub ↗

* Return the object's physical location. This only makes sense for * objects that are currently on the level (i.e. migrating objects * are nowhere). By default, only things that can be seen (in hero's * inventory, monster's inventory, or on the ground) are reported. * By adding BURIED_TOO and/or CONTAINED_TOO flags, you can also get * the location of buried and contained objects. Note that

Source from the content-addressed store, hash-verified

651 * is not available or subject to the constraints above.
652 */
653boolean
654get_obj_location(
655 struct obj *obj,
656 coordxy *xp, coordxy *yp,
657 int locflags)
658{
659 switch (obj->where) {
660 case OBJ_INVENT:
661 *xp = u.ux;
662 *yp = u.uy;
663 return TRUE;
664 case OBJ_FLOOR:
665 *xp = obj->ox;
666 *yp = obj->oy;
667 return TRUE;
668 case OBJ_MINVENT:
669 if (obj->ocarry->mx) {
670 *xp = obj->ocarry->mx;
671 *yp = obj->ocarry->my;
672 return TRUE;
673 }
674 break; /* !mx => migrating monster */
675 case OBJ_BURIED:
676 if (locflags & BURIED_TOO) {
677 *xp = obj->ox;
678 *yp = obj->oy;
679 return TRUE;
680 }
681 break;
682 case OBJ_CONTAINED:
683 if (locflags & CONTAINED_TOO)
684 return get_obj_location(obj->ocontainer, xp, yp, locflags);
685 break;
686 }
687 *xp = *yp = 0;
688 return FALSE;
689}
690
691boolean
692get_mon_location(

Callers 15

resetobjsFunction · 0.85
detect_obj_trapsFunction · 0.85
do_light_sourcesFunction · 0.85
revive_corpseFunction · 0.85
revive_monFunction · 0.85
distant_nameFunction · 0.85
hatch_eggFunction · 0.85
burn_objectFunction · 0.85
begin_burnFunction · 0.85
timer_sanity_checkFunction · 0.85
count_contentsFunction · 0.85
pick_objFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected