Prevent getpos queueing mouse commands

My change to allow binding the mouse buttons made getpos
push the mouse commands into a command queue, so when you
were asked for a map location, clicked on it with a mouse,
you'd first get the expected effect, and then (most likely)
immediately traveled there.

Change getpos to clear the commands bound to the mouse buttons,
and restore the binds afterwards.
This commit is contained in:
Pasi Kallinen
2022-08-24 14:21:24 +03:00
parent 282b2a7bbe
commit 7c8ccb8ccd
3 changed files with 24 additions and 1 deletions

View File

@@ -4280,6 +4280,24 @@ parseautocomplete(char *autocomplete, boolean condition)
wait_synch();
}
/* save&clear the mouse button actions, or restore the saved ones */
void
lock_mouse_buttons(boolean savebtns)
{
static const struct ext_func_tab *mousebtn[NUM_MOUSE_BUTTONS] = { 0 };
int i;
if (savebtns) {
for (i = 0; i < NUM_MOUSE_BUTTONS; i++) {
mousebtn[i] = g.Cmd.mousebtn[i];
g.Cmd.mousebtn[i] = NULL;
}
} else {
for (i = 0; i < NUM_MOUSE_BUTTONS; i++)
g.Cmd.mousebtn[i] = mousebtn[i];
}
}
/* called at startup and after number_pad is twiddled */
void
reset_commands(boolean initial)