* 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. */
| 3928 | * Returns non-zero if coordinates in cc are valid. |
| 3929 | */ |
| 3930 | int |
| 3931 | get_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 */ |
no test coverage detected