]> git.cworth.org Git - kub/commitdiff
Fix card_draw for multi-digit tiles.
authorCarl Worth <cworth@cworth.org>
Tue, 20 Feb 2007 17:44:35 +0000 (09:44 -0800)
committerCarl Worth <cworth@cworth.org>
Tue, 20 Feb 2007 17:44:35 +0000 (09:44 -0800)
Previously, for tiles > 9 we were just using the next larger
character values in ACII above '9'. Oops! Now, we're properly
using snprintf to format the number as an integer within the
string.

kub.c

diff --git a/kub.c b/kub.c
index 0a5bc59a852a2ae7744936d17abd3c2ed1449a9b..15fc6498eb575762ee997cce9ed35a5f5e828425 100644 (file)
--- a/kub.c
+++ b/kub.c
@@ -61,9 +61,12 @@ static void card_print(card_t card)
 
 static void card_draw(game_t *game, card_t *card, cairo_t *cr, int x, int y)
 {
-    char number_string[2];
-    number_string[0] = card->number + '0';
-    number_string[1] = '\0';
+    char number_string[3];
+    int len;
+
+    len = snprintf (number_string, 3, "%d", card->number);
+    if (len < 0 || len >= 3)
+       FATAL_ERROR ("snprintf failed");
 
     cairo_save(cr);
     cairo_translate(cr, x, y);