fail if mouse cursor isn't over the map area

develop
Myk Taylor 2022-09-18 13:27:13 -07:00
parent 8fd86f6e56
commit dbc5001bd8
No known key found for this signature in database
1 changed files with 6 additions and 0 deletions

@ -1836,6 +1836,12 @@ df::coord Gui::getMousePos()
{
df::coord pos;
if (gps && gps->mouse_x > -1) {
// return invalid coords if the cursor is not over the map
DwarfmodeDims dims = getDwarfmodeViewDims();
if (gps->mouse_x < dims.map_x1 || gps->mouse_x > dims.map_x2 ||
gps->mouse_y < dims.map_y1 || gps->mouse_y > dims.map_y2) {
return pos;
}
pos = getViewportPos();
pos.x += gps->mouse_x - 1;
pos.y += gps->mouse_y - 1;