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

Function get_adjacent_loc

src/cmd.c:3930–3953  ·  view source on GitHub ↗

* uses getdir() but unlike getdir() it specifically * produces coordinates using the direction from getdir() * and verifies that those coordinates are ok. * * If the call to getdir() returns 0, Never_mind is displayed. * If the resulting coordinates are not okay, emsg is displayed. * * Returns non-zero if coordinates in cc are valid. */

Source from the content-addressed store, hash-verified

3928 * Returns non-zero if coordinates in cc are valid.
3929 */
3930int
3931get_adjacent_loc(
3932 const char *prompt,
3933 const char *emsg,
3934 coordxy x, coordxy y,
3935 coord *cc)
3936{
3937 coordxy new_x, new_y;
3938 if (!getdir(prompt)) {
3939 pline1(Never_mind);
3940 return 0;
3941 }
3942 new_x = x + u.dx;
3943 new_y = y + u.dy;
3944 if (cc && isok(new_x, new_y)) {
3945 cc->x = new_x;
3946 cc->y = new_y;
3947 } else {
3948 if (emsg)
3949 pline1(emsg);
3950 return 0;
3951 }
3952 return 1;
3953}
3954
3955/* prompt for a direction (specified via movement keystroke) and return it
3956 in u.dx, u.dy, and u.dz; function return value is 1 for ok, 0 otherwise */

Callers 4

pick_lockFunction · 0.85
doopen_indirFunction · 0.85
doloot_coreFunction · 0.85
use_leashFunction · 0.85

Calls 2

getdirFunction · 0.85
isokFunction · 0.85

Tested by

no test coverage detected