Add some error checking

This commit is contained in:
Anna Rose 2012-04-13 01:48:04 -04:00
parent bcdd131be7
commit 01e64ec05f

View File

@ -99,6 +99,9 @@ class Goban:
def set_hover(self, pos): def set_hover(self, pos):
realpos = _real_pos(pos) realpos = _real_pos(pos)
if _i(realpos) < 0 or _i(realpos) > 18 or _j(realpos) < 0 or _j(realpos) > 18:
return
if self.hover == realpos: if self.hover == realpos:
return return
@ -136,7 +139,7 @@ class Goban:
board = p.in_dll(Goban.libboard, 'board') board = p.in_dll(Goban.libboard, 'board')
for pos in range(421): for pos in range(421):
if _i(pos) < 0 or _j(pos) < 0: if _i(pos) < 0 or _i(pos) > 18 or _j(pos) < 0 or _j(pos) > 18:
continue continue
code = self._get_draw_code(pos, board[pos]) code = self._get_draw_code(pos, board[pos])