Patch from Chris Boyle to fix Signpost's labelling when you have more
authorsimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Sun, 18 Sep 2011 07:43:18 +0000 (07:43 +0000)
committersimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Sun, 18 Sep 2011 07:43:18 +0000 (07:43 +0000)
than 26 separate linked chains of unnumbered squares: we now wrap from
'z' to an Excel-like 'aa', 'ab', ..., instead of falling off z into
punctuation and control characters.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@9304 cda61777-01e9-0310-a592-d414129be87e

signpost.c

index 3f2a645..6b16ff7 100644 (file)
@@ -1930,19 +1930,30 @@ static void tile_redraw(drawing *dr, game_drawstate *ds, int tx, int ty,
     if (!empty) {
         int set = (num <= 0) ? 0 : num / (ds->n+1);
 
+        char *p = buf;
         if (set == 0 || num <= 0) {
             sprintf(buf, "%d", num);
         } else {
             int n = num % (ds->n+1);
+            p += sizeof(buf) - 1;
 
-            if (n == 0)
-                sprintf(buf, "%c", (int)(set+'a'-1));
-            else
-                sprintf(buf, "%c+%d", (int)(set+'a'-1), n);
+            if (n != 0) {
+                sprintf(buf, "+%d", n);  /* Just to get the length... */
+                p -= strlen(buf);
+                sprintf(p, "+%d", n);
+            } else {
+                *p = '\0';
+            }
+            do {
+                set--;
+                p--;
+                *p = (char)((set % 26)+'a');
+                set /= 26;
+            } while (set);
         }
-        textsz = min(2*asz, (TILE_SIZE - 2 * cb) / (int)strlen(buf));
+        textsz = min(2*asz, (TILE_SIZE - 2 * cb) / (int)strlen(p));
         draw_text(dr, tx + cb, ty + TILE_SIZE/4, FONT_VARIABLE, textsz,
-                  ALIGN_VCENTRE | ALIGN_HLEFT, textcol, buf);
+                  ALIGN_VCENTRE | ALIGN_HLEFT, textcol, p);
     }
 
     if (print_ink < 0) {