Add mines and mineobfusc to the ignore property.
[sgt/puzzles] / net.c
diff --git a/net.c b/net.c
index 0df502f..33af6c6 100644 (file)
--- a/net.c
+++ b/net.c
@@ -12,8 +12,6 @@
 #include "puzzles.h"
 #include "tree234.h"
 
-#define PI 3.141592653589793238462643383279502884197169399
-
 #define MATMUL(xr,yr,m,x,y) do { \
     float rx, ry, xx = (x), yy = (y), *mat = (m); \
     rx = mat[0] * xx + mat[2] * yy; \
@@ -122,7 +120,7 @@ static int xyd_cmp(const void *av, const void *bv) {
     if (a->direction > b->direction)
        return +1;
     return 0;
-};
+}
 
 static int xyd_cmp_nc(void *av, void *bv) { return xyd_cmp(av, bv); }
 
@@ -151,32 +149,29 @@ static game_params *default_params(void)
     return ret;
 }
 
+static const struct game_params net_presets[] = {
+    {5, 5, FALSE, TRUE, 0.0},
+    {7, 7, FALSE, TRUE, 0.0},
+    {9, 9, FALSE, TRUE, 0.0},
+    {11, 11, FALSE, TRUE, 0.0},
+    {13, 11, FALSE, TRUE, 0.0},
+    {5, 5, TRUE, TRUE, 0.0},
+    {7, 7, TRUE, TRUE, 0.0},
+    {9, 9, TRUE, TRUE, 0.0},
+    {11, 11, TRUE, TRUE, 0.0},
+    {13, 11, TRUE, TRUE, 0.0},
+};
+
 static int game_fetch_preset(int i, char **name, game_params **params)
 {
     game_params *ret;
     char str[80];
-    static const struct { int x, y, wrap; } values[] = {
-        {5, 5, FALSE},
-        {7, 7, FALSE},
-        {9, 9, FALSE},
-        {11, 11, FALSE},
-        {13, 11, FALSE},
-        {5, 5, TRUE},
-        {7, 7, TRUE},
-        {9, 9, TRUE},
-        {11, 11, TRUE},
-        {13, 11, TRUE},
-    };
-
-    if (i < 0 || i >= lenof(values))
+
+    if (i < 0 || i >= lenof(net_presets))
         return FALSE;
 
     ret = snew(game_params);
-    ret->width = values[i].x;
-    ret->height = values[i].y;
-    ret->wrapping = values[i].wrap;
-    ret->unique = TRUE;
-    ret->barrier_probability = 0.0;
+    *ret = net_presets[i];
 
     sprintf(str, "%dx%d%s", ret->width, ret->height,
             ret->wrapping ? " wrapping" : "");
@@ -304,12 +299,8 @@ static game_params *custom_params(config_item *cfg)
 
 static char *validate_params(game_params *params)
 {
-    if (params->width <= 0 && params->height <= 0)
+    if (params->width <= 0 || params->height <= 0)
        return "Width and height must both be greater than zero";
-    if (params->width <= 0)
-       return "Width must be greater than zero";
-    if (params->height <= 0)
-       return "Height must be greater than zero";
     if (params->width <= 1 && params->height <= 1)
        return "At least one of width and height must be greater than one";
     if (params->barrier_probability < 0)
@@ -970,6 +961,7 @@ static void perturb(int w, int h, unsigned char *tiles, int wrapping,
 
        break;
     }
+    sfree(perim2);
 
     if (i == nperim)
        return;                        /* nothing we can do! */
@@ -1146,7 +1138,7 @@ static void perturb(int w, int h, unsigned char *tiles, int wrapping,
 }
 
 static char *new_game_desc(game_params *params, random_state *rs,
-                          game_aux_info **aux)
+                          game_aux_info **aux, int interactive)
 {
     tree234 *possibilities, *barriertree;
     int w, h, x, y, cx, cy, nbarriers;
@@ -1558,7 +1550,7 @@ static char *validate_desc(game_params *params, char *desc)
  * Construct an initial game state, given a description and parameters.
  */
 
-static game_state *new_game(game_params *params, char *desc)
+static game_state *new_game(midend_data *me, game_params *params, char *desc)
 {
     game_state *state;
     int w, h, x, y;
@@ -1798,8 +1790,7 @@ static void free_ui(game_ui *ui)
  * Process a move.
  */
 static game_state *make_move(game_state *state, game_ui *ui,
-                            int x, int y, int button)
-{
+                             game_drawstate *ds, int x, int y, int button) {
     game_state *ret, *nullret;
     int tx, ty, orig;
     int shift = button & MOD_SHFT, ctrl = button & MOD_CTRL;
@@ -1947,7 +1938,10 @@ static game_state *make_move(game_state *state, game_ui *ui,
         ret->last_rotate_dir = 0; /* suppress animation */
         ret->last_rotate_x = ret->last_rotate_y = 0;
 
-    } else assert(0);
+    } else {
+       ret = NULL;  /* placate optimisers which don't understand assert(0) */
+       assert(0);
+    }
 
     /*
      * Check whether the game has been completed.
@@ -2568,6 +2562,11 @@ static int game_wants_statusbar(void)
     return TRUE;
 }
 
+static int game_timing_state(game_state *state)
+{
+    return TRUE;
+}
+
 #ifdef COMBINED
 #define thegame net
 #endif
@@ -2601,4 +2600,6 @@ const struct game thegame = {
     game_anim_length,
     game_flash_length,
     game_wants_statusbar,
+    FALSE, game_timing_state,
+    0,                                /* mouse_priorities */
 };