simulated mouse again

Change u.{dx,dy,dz} from schar to int and get rid of unused u.di.

Remove just added getdir_ok2click; it was declared as int but being
assigned booleans.  Rename getloc_click to getdir_click and have
getdir() use it for both input and output.

A simulated mouse is becoming quite a nuisance for something which
will probably never be used by anyone in actual play.
This commit is contained in:
PatR
2022-07-10 11:14:10 -07:00
parent 6ac5525239
commit fed367ccbd
4 changed files with 23 additions and 19 deletions

View File

@@ -212,12 +212,14 @@ struct instance_flags {
#define TER_OBJ 0x04
#define TER_MON 0x08
#define TER_DETECT 0x10 /* detect_foo magic rather than #terrain */
boolean getloc_travelmode;
int getdir_ok2click; /* for #therecmdmenu */
int getloc_click; /* 0 or CLICK_1 (left) or CLICK_2 (right) */
int getdir_click; /* as input to getdir(): non-zero, accept simulated
* click that's not adjacent to or on hero;
* as output from getdir(): simulated button used
* 0 (none) or CLICK_1 (left) or CLICK_2 (right) */
int getloc_filter; /* GFILTER_foo */
boolean getloc_usemenu;
boolean getloc_moveskip;
boolean getloc_travelmode;
boolean getloc_usemenu;
coord travelcc; /* coordinates for travel_cache */
boolean trav_debug; /* display travel path (#if DEBUG only) */
boolean window_inited; /* true if init_nhwindows() completed */

View File

@@ -347,17 +347,17 @@ enum utotypes {
/*** Information about the player ***/
struct you {
coordxy ux, uy; /* current map coordinates */
schar dx, dy, dz; /* direction of move (or zap or ... ) */
schar di; /* direction of FF */
coordxy tx, ty; /* destination of travel */
coordxy ux0, uy0; /* initial position FF */
coordxy ux, uy; /* current map coordinates */
int dx, dy, dz; /* x,y,z deltas; direction of move (or zap or ... )
* usually +1 or 0 or -1 */
coordxy tx, ty; /* destination of travel */
coordxy ux0, uy0; /* previous ux,uy */
d_level uz, uz0; /* your level on this and the previous turn */
d_level utolev; /* level monster teleported you to, or uz */
uchar utotype; /* bitmask of goto_level() flags for utolev */
boolean umoved; /* changed map location (post-move) */
int last_str_turn; /* 0: none, 1: half turn, 2: full turn
+: turn right, -: turn left */
* +: turn right, -: turn left */
int ulevel; /* 1 to MAXULEV (30) */
int ulevelmax; /* highest level, but might go down (to throttle
* lost level recovery via blessed full healing) */

View File

@@ -4490,9 +4490,9 @@ getdir(const char *s)
/* caller expects simulated click to be relative to hero's spot */
u.dx = cc.x - u.ux;
u.dy = cc.y - u.uy;
/* getdir_ok2click actually means ok to click farther than
/* non-zero getdir_click actually means ok to click farther than
one spot away from hero; adjacent click is always allowed */
if (!iflags.getdir_ok2click) {
if (!iflags.getdir_click) {
u.dx = sgn(u.dx);
u.dy = sgn(u.dy);
}
@@ -4518,7 +4518,7 @@ getdir(const char *s)
break;
}
}
iflags.getloc_click = mod;
iflags.getdir_click = mod;
return (pos >= 0);
} else if (!(is_mov = movecmd(dirsym, MV_ANY)) && !u.dz) {
boolean did_help = FALSE, help_requested;
@@ -4767,16 +4767,18 @@ static int
dotherecmdmenu(void)
{
char ch;
int dir;
int dir, click;
iflags.getdir_ok2click = TRUE;
iflags.getdir_click = CLICK_1 | CLICK_2; /* allow 'far' click */
dir = getdir((const char *) 0);
iflags.getdir_ok2click = FALSE;
click = iflags.getdir_click;
iflags.getdir_click = 0;
if (!dir || !isok(u.ux + u.dx, u.uy + u.dy))
return ECMD_CANCEL;
if (u.dx || u.dy)
ch = there_cmd_menu(u.ux + u.dx, u.uy + u.dy, iflags.getloc_click);
ch = there_cmd_menu(u.ux + u.dx, u.uy + u.dy, click);
else
ch = here_cmd_menu();
@@ -5229,7 +5231,8 @@ act_on_act(
}
}
/* offer choice of actions to perform at adjacent location <x,y> */
/* offer choice of actions to perform at adjacent location <x,y>;
a few choices can be farther away */
static char
there_cmd_menu(coordxy x, coordxy y, int mod)
{

View File

@@ -782,7 +782,6 @@ getpos(coord *ccp, boolean force, const char *goal)
}
if (c == cmd_from_func(do_run) || c == cmd_from_func(do_rush)) {
c = readchar_poskey(&tx, &ty, &sidx);
iflags.getloc_click = sidx; /* [is this useful?] */
rushrun = TRUE;
}
if (c == 0) {