General robustness patch from James Harvey:
[sgt/puzzles] / mines.c
diff --git a/mines.c b/mines.c
index 157c0ea..6cfb634 100644 (file)
--- a/mines.c
+++ b/mines.c
@@ -1990,6 +1990,7 @@ static char *validate_desc(game_params *params, char *desc)
     int x, y;
 
     if (*desc == 'r') {
+        desc++;
        if (!*desc || !isdigit((unsigned char)*desc))
            return "No initial mine count in game description";
        while (*desc && isdigit((unsigned char)*desc))
@@ -2352,7 +2353,7 @@ static void free_ui(game_ui *ui)
     sfree(ui);
 }
 
-char *encode_ui(game_ui *ui)
+static char *encode_ui(game_ui *ui)
 {
     char buf[80];
     /*
@@ -2362,7 +2363,7 @@ char *encode_ui(game_ui *ui)
     return dupstr(buf);
 }
 
-void decode_ui(game_ui *ui, char *encoding)
+static void decode_ui(game_ui *ui, char *encoding)
 {
     sscanf(encoding, "D%d", &ui->deaths);
 }
@@ -2606,19 +2607,19 @@ static game_state *execute_move(game_state *from, char *move)
 static void game_size(game_params *params, game_drawstate *ds,
                       int *x, int *y, int expand)
 {
-    int tsx, tsy, ts;
+    double tsx, tsy, ts;
     /*
      * Each window dimension equals the tile size times 3 more than
      * the grid dimension (the border is 3/2 the width of the
      * tiles).
      */
-    tsx = *x / (params->w + 3);
-    tsy = *y / (params->h + 3);
+    tsx = (double)*x / ((double)params->w + 3.0);
+    tsy = (double)*y / ((double)params->h + 3.0);
     ts = min(tsx, tsy);
     if (expand)
-        ds->tilesize = ts;
+        ds->tilesize = (int)(ts + 0.5);
     else
-        ds->tilesize = min(ts, PREFERRED_TILE_SIZE);
+        ds->tilesize = min((int)ts, PREFERRED_TILE_SIZE);
 
     *x = BORDER * 2 + TILE_SIZE * params->w;
     *y = BORDER * 2 + TILE_SIZE * params->h;