mousequery: Fix some more instances of map boundary checks

develop
lethosor 2019-05-16 23:30:03 -04:00
parent c3b06b81c7
commit 92717a7f71
1 changed files with 5 additions and 6 deletions

@ -369,8 +369,7 @@ struct mousequery_hook : public df::viewscreen_dwarfmodest
// Can't check limits earlier as we must be sure we are in query or default mode // Can't check limits earlier as we must be sure we are in query or default mode
// (so we can clear the button down flag) // (so we can clear the button down flag)
auto dims = Gui::getDwarfmodeViewDims(); auto dims = Gui::getDwarfmodeViewDims();
int right_bound = (dims.menu_x1 > 0) ? dims.menu_x1 - 2 : gps->dimx - 2; if (mx < 1 || mx > dims.map_x2 || my < 1 || my > dims.map_y2)
if (mx < 1 || mx > right_bound || my < 1 || my > gps->dimy - 2)
return false; return false;
if (ui->main.mode == df::ui_sidebar_mode::Zones || if (ui->main.mode == df::ui_sidebar_mode::Zones ||
@ -435,13 +434,13 @@ struct mousequery_hook : public df::viewscreen_dwarfmodest
if (mx < scroll_trigger_x) if (mx < scroll_trigger_x)
sendKey(interface_key::CURSOR_LEFT_FAST); sendKey(interface_key::CURSOR_LEFT_FAST);
if (mx > ((dims.menu_x1 > 0) ? dims.menu_x1 : gps->dimx) - scroll_trigger_x) if (mx > dims.map_x2 - scroll_trigger_x)
sendKey(interface_key::CURSOR_RIGHT_FAST); sendKey(interface_key::CURSOR_RIGHT_FAST);
if (my < scroll_trigger_y) if (my < scroll_trigger_y)
sendKey(interface_key::CURSOR_UP_FAST); sendKey(interface_key::CURSOR_UP_FAST);
if (my > gps->dimy - scroll_trigger_y) if (my > dims.map_y2 - scroll_trigger_y)
sendKey(interface_key::CURSOR_DOWN_FAST); sendKey(interface_key::CURSOR_DOWN_FAST);
} }
@ -731,9 +730,9 @@ struct mousequery_hook : public df::viewscreen_dwarfmodest
if (shouldTrack()) if (shouldTrack())
{ {
if (delta_t <= scroll_delay && (mx < scroll_buffer || if (delta_t <= scroll_delay && (mx < scroll_buffer ||
mx > dims.menu_x1 - scroll_buffer || mx > dims.map_x2 - scroll_buffer ||
my < scroll_buffer || my < scroll_buffer ||
my > gps->dimy - scroll_buffer)) my > dims.map_y2 - scroll_buffer))
{ {
return; return;
} }