While going through the 4.0.5 code eliminating warnings (most of which are due to an evident complete disdain for type casting), I came across a bug in cmd_get_direction():
The validity check will always pass here as it is checking for a null pointer rather than a value of zero for dir. I corrected this:
But the result wasn't pretty. Whenever I used a mouse click to move @ I would get a direction prompt followed by multiple graphical images of @ along the direction of motion. I'm not sure how to debug this since it gets into sections of the code that I don't fully understand, but I found the way to solve (hack) the problem was to just forego the validity check altogether.
I downloaded the code for 4.1.2 and confirmed that this bug is still present there.
Code:
int cmd_get_direction(struct command *cmd, const char *arg, int *dir,
bool allow_5)
{
if (cmd_get_arg_direction(cmd, arg, dir) == CMD_OK) {
/* Validity check */
if (dir != DIR_UNKNOWN)
return CMD_OK;
}
/* We need to do extra work */
if (get_rep_dir(dir, allow_5)) {
cmd_set_arg_direction(cmd, arg, *dir);
return CMD_OK;
}
cmd_cancel_repeat();
return CMD_ARG_ABORTED;
}
Code:
if (*dir != DIR_UNKNOWN)
Code:
int cmd_get_direction(struct command *cmd, const char *arg, int *dir,
bool allow_5)
{
if (cmd_get_arg_direction(cmd, arg, dir) == CMD_OK) {
/* Validity check */
// if (*dir != DIR_UNKNOWN)
return CMD_OK;
}
/* We need to do extra work */
if (get_rep_dir(dir, allow_5)) {
cmd_set_arg_direction(cmd, arg, *dir);
return CMD_OK;
}
cmd_cancel_repeat();
return CMD_ARG_ABORTED;
}
Comment