Make sure getdir return values are in range

u.dx and u.dy should be [-1, +1]
This commit is contained in:
Pasi Kallinen
2022-07-10 11:00:27 +03:00
parent f3e2f08b54
commit 1dcd14bffd
+2 -2
View File
@@ -4488,8 +4488,8 @@ getdir(const char *s)
mod = 0; /* neither CLICK_1 nor CLICK_2 */ mod = 0; /* neither CLICK_1 nor CLICK_2 */
} else { } else {
/* caller expects simulated click to be relative to hero's spot */ /* caller expects simulated click to be relative to hero's spot */
u.dx = cc.x - u.ux; u.dx = sgn(cc.x - u.ux);
u.dy = cc.y - u.uy; u.dy = sgn(cc.y - u.uy);
u.dz = 0; u.dz = 0;
switch (pos + NHKF_GETPOS_PICK) { switch (pos + NHKF_GETPOS_PICK) {