]> git.cworth.org Git - kub/commitdiff
Fix tile_group_is_set
authorKevin Worth <kworth@kworth-laptop.(none)>
Thu, 7 May 2009 19:15:43 +0000 (15:15 -0400)
committerKevin Worth <kworth@kworth-laptop.(none)>
Thu, 7 May 2009 19:15:43 +0000 (15:15 -0400)
Previous version was validating sets with repeat colors.
The error appeared to be an incomplete check through the array;
when num_tiles was 3, it was checking index 0 and 1. Thus, if
index 0 and 2 had the same color, it wasn't being caught.

New version now steps through entire array.

kub.c

diff --git a/kub.c b/kub.c
index 213270901d3cd502be2afb4eb03989719a7ca6de..65b7d3e593d9c38e65409061b792c784f8b9bc49 100644 (file)
--- a/kub.c
+++ b/kub.c
@@ -290,7 +290,7 @@ static int tile_group_is_set(tile_group_t *tile_group)
         printf("fail set - invalid num tiles; ");
         return 0;
     }
-    for (i = 0; i < tile_group->num_tiles - 1; ++i) 
+    for (i = 0; i <= tile_group->num_tiles - 1; ++i) 
     {
         if (tile_group->tiles[i].number != tile_group->tiles[i + 1].number &&
             i+1 != tile_group->num_tiles)