shithub: puzzles

Download patch

ref: f2f39af2d3ca27ee9aa2e284896efa07f5df5f02
parent: 2409a9913e1b3972ff4ef3b4ab377ace9b5d4ef7
author: Simon Tatham <anakin@pobox.com>
date: Mon Apr 26 13:59:22 EDT 2021

Mosaic: use signed char for clue values.

Negative numbers are used as a sentinel for an absent clue, so we have
to use a type that's guaranteed to have some negative numbers. char is
unsigned on some platforms. So now Mosaic runs apparently correctly on
Raspbian, for example.

--- a/mosaic.c
+++ b/mosaic.c
@@ -98,12 +98,12 @@
 };
 
 struct board_cell {
-    char clue;
+    signed char clue;
     bool shown;
 };
 
 struct solution_cell {
-    char cell;
+    signed char cell;
     bool solved;
     bool needed;
 };
@@ -1426,7 +1426,7 @@
     sfree(ds);
 }
 
-static void draw_cell(drawing *dr, int cell, int ts, char clue_val,
+static void draw_cell(drawing *dr, int cell, int ts, signed char clue_val,
                       int x, int y)
 {
     int startX = ((x * ts) + ts / 2) - 1, startY = ((y * ts) + ts / 2) - 1;
@@ -1468,7 +1468,8 @@
                         float flashtime)
 {
     int x, y;
-    char status[80], clue_val;
+    char status[80];
+    signed char clue_val;
     bool flashing = (flashtime > 0 && (flashtime <= FLASH_TIME / 3 ||
                                        flashtime > 2*FLASH_TIME / 3));