]> git.cworth.org Git - loa/commitdiff
Ignore clicks outside the current board
authorCarl Worth <cworth@cworth.org>
Fri, 29 Feb 2008 05:17:46 +0000 (21:17 -0800)
committerCarl Worth <cworth@cworth.org>
Fri, 29 Feb 2008 05:17:46 +0000 (21:17 -0800)
This prevents crashing and moving pieces off of the board.

loa.c

diff --git a/loa.c b/loa.c
index 5716a3627ef1e90e8f91822afd65c60c4c5f6e32..355c66744df9dba359db3b54c2ed2801683b41ce 100644 (file)
--- a/loa.c
+++ b/loa.c
@@ -80,6 +80,13 @@ on_button_press_event (GtkWidget     *widget,
        return TRUE;
     }
 
+    /* Do nothing for out-of-bounds clicks */
+    if (x < 0 || x >= LOA_BOARD_SIZE ||
+       y < 0 || y >= LOA_BOARD_SIZE)
+    {
+       return TRUE;
+    }
+
     if (x == game->selected_x &&
        y == game->selected_y)
     {