query tool: check bounds before attempting query

git-svn-id: https://micropolis.googlecode.com/svn/trunk/micropolis-java@575 d9718cc8-9f43-0410-858b-315f434eb58c
This commit is contained in:
jason@long.name 2013-02-24 01:19:17 +00:00
parent 5219c6f1be
commit b1a1dea224
2 changed files with 4 additions and 1 deletions

View file

@ -431,7 +431,7 @@ public class Micropolis
} }
} }
final boolean testBounds(int xpos, int ypos) final public boolean testBounds(int xpos, int ypos)
{ {
return xpos >= 0 && xpos < getWidth() && return xpos >= 0 && xpos < getWidth() &&
ypos >= 0 && ypos < getHeight(); ypos >= 0 && ypos < getHeight();

View file

@ -898,6 +898,9 @@ public class MainWindow extends JFrame
void doQueryTool(int xpos, int ypos) void doQueryTool(int xpos, int ypos)
{ {
if (!engine.testBounds(xpos, ypos))
return;
ZoneStatus z = engine.queryZoneStatus(xpos, ypos); ZoneStatus z = engine.queryZoneStatus(xpos, ypos);
notificationPane.showZoneStatus(engine, xpos, ypos, z); notificationPane.showZoneStatus(engine, xpos, ypos, z);
} }