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

Function getpos

src/getpos.c:770–1167  ·  view source on GitHub ↗

have the player use movement keystrokes to position the cursor at a particular map location, then use one of [.,:;] to pick the spot */

Source from the content-addressed store, hash-verified

768/* have the player use movement keystrokes to position the cursor at a
769 particular map location, then use one of [.,:;] to pick the spot */
770int
771getpos(coord *ccp, boolean force, const char *goal)
772{
773 static struct {
774 int nhkf, ret;
775 } const pick_chars_def[] = {
776 { NHKF_GETPOS_PICK, LOOK_TRADITIONAL },
777 { NHKF_GETPOS_PICK_Q, LOOK_QUICK },
778 { NHKF_GETPOS_PICK_O, LOOK_ONCE },
779 { NHKF_GETPOS_PICK_V, LOOK_VERBOSE }
780 };
781 static const int mMoOdDxX_def[] = {
782 NHKF_GETPOS_MON_NEXT,
783 NHKF_GETPOS_MON_PREV,
784 NHKF_GETPOS_OBJ_NEXT,
785 NHKF_GETPOS_OBJ_PREV,
786 NHKF_GETPOS_DOOR_NEXT,
787 NHKF_GETPOS_DOOR_PREV,
788 NHKF_GETPOS_UNEX_NEXT,
789 NHKF_GETPOS_UNEX_PREV,
790 NHKF_GETPOS_INTERESTING_NEXT,
791 NHKF_GETPOS_INTERESTING_PREV,
792 NHKF_GETPOS_VALID_NEXT,
793 NHKF_GETPOS_VALID_PREV
794 };
795 struct _cmd_queue cq, *cmdq;
796 const char *cp;
797 char pick_chars[6];
798 char mMoOdDxX[13];
799 int result = 0;
800 int i, c;
801 int sidx;
802 coordxy cx, cy;
803 coordxy tx = u.ux, ty = u.uy;
804 boolean msg_given = TRUE; /* clear message window by default */
805 boolean show_goal_msg = FALSE;
806 coord *garr[NUM_GLOCS] = DUMMY;
807 int gcount[NUM_GLOCS] = DUMMY;
808 int gidx[NUM_GLOCS] = DUMMY;
809 schar udx = u.dx, udy = u.dy, udz = u.dz;
810 int dx, dy;
811 boolean rushrun = FALSE;
812
813 /* temporary? if we have a queued direction, return the adjacent spot
814 in that direction */
815 if (!gi.in_doagain) {
816 if ((cmdq = cmdq_pop()) != 0) {
817 cq = *cmdq;
818 free((genericptr_t) cmdq);
819 if (cq.typ == CMDQ_DIR && !cq.dirz) {
820 ccp->x = u.ux + cq.dirx;
821 ccp->y = u.uy + cq.diry;
822 } else {
823 cmdq_clear(CQ_CANNED);
824 result = -1;
825 }
826 return result;
827 }

Callers 15

do_mgivennameFunction · 0.85
namefloorobjFunction · 0.85
browse_mapFunction · 0.85
scrollteleFunction · 0.85
control_mon_teleFunction · 0.85
wiz_killFunction · 0.85
wiz_telekinesisFunction · 0.85
wiz_smellFunction · 0.85
throwspellFunction · 0.85
jumpFunction · 0.85
use_poleFunction · 0.85
use_grappleFunction · 0.85

Calls 15

cmdq_popFunction · 0.85
cmdq_clearFunction · 0.85
handle_tipFunction · 0.85
visctrlFunction · 0.85
flush_screenFunction · 0.85
lock_mouse_cursorFunction · 0.85
lock_mouse_buttonsFunction · 0.85
auto_describeFunction · 0.85
readchar_poskeyFunction · 0.85
cmdq_add_keyFunction · 0.85
cmd_from_funcFunction · 0.85
isokFunction · 0.85

Tested by

no test coverage detected