ref: 0b93de904a98f119b1a95d3a53029f1ed4bfb9b3
parent: 383c15794a517a4e6dc0b7364edac1f7056cee82
author: Simon Tatham <anakin@pobox.com>
date: Fri Apr 12 13:11:49 EDT 2013
Add 'const' to the game_params arguments in validate_desc and new_desc. Oddities in the 'make test' output brought to my attention that a few puzzles have been modifying their input game_params for various reasons; they shouldn't do that, because that's the game_params held permanently by the midend and it will affect subsequent game generations if they modify it. So now those arguments are const, and all the games which previously modified their game_params now take a copy and modify that instead. [originally from svn r9830]
--- a/blackbox.c
+++ b/blackbox.c
@@ -210,7 +210,7 @@
* Then we obfuscate it.
*/
-static char *new_game_desc(game_params *params, random_state *rs,
+static char *new_game_desc(const game_params *params, random_state *rs,
char **aux, int interactive)
{
int nballs = params->minballs, i;
@@ -251,7 +251,7 @@
return ret;
}
-static char *validate_desc(game_params *params, char *desc)
+static char *validate_desc(const game_params *params, char *desc)
{
int nballs, dlen = strlen(desc), i;
unsigned char *bmp;
--- a/bridges.c
+++ b/bridges.c
@@ -1735,7 +1735,7 @@
/* --- New game functions --- */
-static game_state *new_state(game_params *params)
+static game_state *new_state(const game_params *params)
{
game_state *ret = snew(game_state);
int wh = params->w * params->h, i;
@@ -1845,7 +1845,7 @@
#define ORDER(a,b) do { if (a < b) { int tmp=a; int a=b; int b=tmp; } } while(0)
-static char *new_game_desc(game_params *params, random_state *rs,
+static char *new_game_desc(const game_params *params, random_state *rs,
char **aux, int interactive)
{
game_state *tobuild = NULL;
@@ -2015,7 +2015,7 @@
return ret;
}
-static char *validate_desc(game_params *params, char *desc)
+static char *validate_desc(const game_params *params, char *desc)
{
int i, wh = params->w * params->h;
--- a/cube.c
+++ b/cube.c
@@ -315,7 +315,8 @@
}
typedef void (*egc_callback)(void *, struct grid_square *);
-static void enum_grid_squares(game_params *params, egc_callback callback, void *ctx)
+static void enum_grid_squares(const game_params *params, egc_callback callback,
+ void *ctx)
{
const struct solid *solid = solids[params->solid];
@@ -597,7 +598,7 @@
data->squareindex++;
}
-static char *new_game_desc(game_params *params, random_state *rs,
+static char *new_game_desc(const game_params *params, random_state *rs,
char **aux, int interactive)
{
struct grid_data data;
@@ -845,7 +846,7 @@
return ret;
}
-static char *validate_desc(game_params *params, char *desc)
+static char *validate_desc(const game_params *params, char *desc)
{
int area = grid_area(params->d1, params->d2, solids[params->solid]->order);
int i, j;
--- a/devel.but
+++ b/devel.but
@@ -655,7 +655,7 @@
\S{backend-new-desc} \cw{new_desc()}
-\c char *(*new_desc)(game_params *params, random_state *rs,
+\c char *(*new_desc)(const game_params *params, random_state *rs,
\c char **aux, int interactive);
This function is where all the really hard work gets done. This is
@@ -696,7 +696,7 @@
\S{backend-validate-desc} \cw{validate_desc()}
-\c char *(*validate_desc)(game_params *params, char *desc);
+\c char *(*validate_desc)(const game_params *params, char *desc);
This function is given a game description, and its job is to
validate that it describes a puzzle which makes sense.
--- a/dominosa.c
+++ b/dominosa.c
@@ -545,7 +545,7 @@
* End of solver code.
*/
-static char *new_game_desc(game_params *params, random_state *rs,
+static char *new_game_desc(const game_params *params, random_state *rs,
char **aux, int interactive)
{
int n = params->n, w = n+2, h = n+1, wh = w*h;
@@ -746,7 +746,7 @@
return ret;
}
-static char *validate_desc(game_params *params, char *desc)
+static char *validate_desc(const game_params *params, char *desc)
{
int n = params->n, w = n+2, h = n+1, wh = w*h;
int *occurrences;
--- a/fifteen.c
+++ b/fifteen.c
@@ -155,7 +155,7 @@
return ret;
}
-static char *new_game_desc(game_params *params, random_state *rs,
+static char *new_game_desc(const game_params *params, random_state *rs,
char **aux, int interactive)
{
int gap, n, i, x;
@@ -271,7 +271,7 @@
return ret;
}
-static char *validate_desc(game_params *params, char *desc)
+static char *validate_desc(const game_params *params, char *desc)
{
char *p, *err;
int i, area;
--- a/filling.c
+++ b/filling.c
@@ -867,7 +867,7 @@
sfree(board_cp);
}
-static char *new_game_desc(game_params *params, random_state *rs,
+static char *new_game_desc(const game_params *params, random_state *rs,
char **aux, int interactive)
{
const int w = params->w;
@@ -906,7 +906,7 @@
return game_description;
}
-static char *validate_desc(game_params *params, char *desc)
+static char *validate_desc(const game_params *params, char *desc)
{
int i;
const int sz = params->w * params->h;
--- a/flip.c
+++ b/flip.c
@@ -347,7 +347,7 @@
addsq(t, w, h, cx, cy, x, y+1, matrix);
}
-static char *new_game_desc(game_params *params, random_state *rs,
+static char *new_game_desc(const game_params *params, random_state *rs,
char **aux, int interactive)
{
int w = params->w, h = params->h, wh = w * h;
@@ -596,7 +596,7 @@
return ret;
}
-static char *validate_desc(game_params *params, char *desc)
+static char *validate_desc(const game_params *params, char *desc)
{
int w = params->w, h = params->h, wh = w * h;
int mlen = (wh*wh+3)/4, glen = (wh+3)/4;
--- a/galaxies.c
+++ b/galaxies.c
@@ -1233,7 +1233,7 @@
static int check_complete(game_state *state, int *dsf, int *colours);
static int solver_state(game_state *state, int maxdiff);
-static char *new_game_desc(game_params *params, random_state *rs,
+static char *new_game_desc(const game_params *params, random_state *rs,
char **aux, int interactive)
{
game_state *state = blank_game(params->w, params->h), *copy;
@@ -1480,7 +1480,7 @@
return (ret == -1) ? 1 : 0;
}
-static game_state *load_game(game_params *params, char *desc,
+static game_state *load_game(const game_params *params, char *desc,
char **why_r)
{
game_state *state = blank_game(params->w, params->h);
@@ -1528,7 +1528,7 @@
return NULL;
}
-static char *validate_desc(game_params *params, char *desc)
+static char *validate_desc(const game_params *params, char *desc)
{
char *why = NULL;
game_state *dummy = load_game(params, desc, &why);
--- a/guess.c
+++ b/guess.c
@@ -264,7 +264,7 @@
sfree(pegs);
}
-static char *new_game_desc(game_params *params, random_state *rs,
+static char *new_game_desc(const game_params *params, random_state *rs,
char **aux, int interactive)
{
unsigned char *bmp = snewn(params->npegs, unsigned char);
@@ -287,7 +287,7 @@
return ret;
}
-static char *validate_desc(game_params *params, char *desc)
+static char *validate_desc(const game_params *params, char *desc)
{
unsigned char *bmp;
int i;
--- a/inertia.c
+++ b/inertia.c
@@ -583,13 +583,13 @@
return grid;
}
-static char *new_game_desc(game_params *params, random_state *rs,
+static char *new_game_desc(const game_params *params, random_state *rs,
char **aux, int interactive)
{
return gengrid(params->w, params->h, rs);
}
-static char *validate_desc(game_params *params, char *desc)
+static char *validate_desc(const game_params *params, char *desc)
{
int w = params->w, h = params->h, wh = w*h;
int starts = 0, gems = 0, i;
--- a/keen.c
+++ b/keen.c
@@ -740,7 +740,7 @@
return NULL;
}
-static char *new_game_desc(game_params *params, random_state *rs,
+static char *new_game_desc(const game_params *params, random_state *rs,
char **aux, int interactive)
{
int w = params->w, a = w*w;
@@ -1145,7 +1145,7 @@
* Gameplay.
*/
-static char *validate_desc(game_params *params, char *desc)
+static char *validate_desc(const game_params *params, char *desc)
{
int w = params->w, a = w*w;
int *dsf;
--- a/lightup.c
+++ b/lightup.c
@@ -367,7 +367,7 @@
/* --- Game state construction/freeing helper functions --- */
-static game_state *new_state(game_params *params)
+static game_state *new_state(const game_params *params)
{
game_state *ret = snew(game_state);
@@ -568,7 +568,8 @@
state->nlights = 0;
}
-static void set_blacks(game_state *state, game_params *params, random_state *rs)
+static void set_blacks(game_state *state, const game_params *params,
+ random_state *rs)
{
int x, y, degree = 0, rotate = 0, nblack;
int rh, rw, i;
@@ -1516,9 +1517,11 @@
#define MAX_GRIDGEN_TRIES 20
-static char *new_game_desc(game_params *params, random_state *rs,
+static char *new_game_desc(const game_params *params_in, random_state *rs,
char **aux, int interactive)
{
+ game_params params_copy = *params_in; /* structure copy */
+ game_params *params = ¶ms_copy;
game_state *news = new_state(params), *copys;
int i, j, run, x, y, wh = params->w*params->h, num;
char *ret, *p;
@@ -1625,7 +1628,7 @@
return ret;
}
-static char *validate_desc(game_params *params, char *desc)
+static char *validate_desc(const game_params *params, char *desc)
{
int i;
for (i = 0; i < params->w*params->h; i++) {
--- a/loopy.c
+++ b/loopy.c
@@ -231,7 +231,7 @@
char *clue_satisfied;
};
-static char *validate_desc(game_params *params, char *desc);
+static char *validate_desc(const game_params *params, char *desc);
static int dot_order(const game_state* state, int i, char line_type);
static int face_order(const game_state* state, int i, char line_type);
static solver_state *solve_game_rec(const solver_state *sstate);
@@ -277,7 +277,7 @@
/* Generates a (dynamically allocated) new grid, according to the
* type and size requested in params. Does nothing if the grid is already
* generated. */
-static grid *loopy_generate_grid(game_params *params, char *grid_desc)
+static grid *loopy_generate_grid(const game_params *params, char *grid_desc)
{
return grid_new(grid_types[params->type], params->w, params->h, grid_desc);
}
@@ -713,7 +713,7 @@
/* We require that the params pass the test in validate_params and that the
* description fills the entire game area */
-static char *validate_desc(game_params *params, char *desc)
+static char *validate_desc(const game_params *params, char *desc)
{
int count = 0;
grid *g;
@@ -1364,7 +1364,7 @@
}
-static char *new_game_desc(game_params *params, random_state *rs,
+static char *new_game_desc(const game_params *params, random_state *rs,
char **aux, int interactive)
{
/* solution and description both use run-length encoding in obvious ways */
--- a/magnets.c
+++ b/magnets.c
@@ -422,7 +422,8 @@
return NULL;
}
-static game_state *new_game_int(game_params *params, char *desc, const char **prob)
+static game_state *new_game_int(const game_params *params, char *desc,
+ const char **prob)
{
game_state *state = new_state(params->w, params->h);
int x, y, idx, *count;
@@ -529,7 +530,7 @@
return state;
}
-static char *validate_desc(game_params *params, char *desc)
+static char *validate_desc(const game_params *params, char *desc)
{
const char *prob;
game_state *st = new_game_int(params, desc, &prob);
@@ -1603,7 +1604,7 @@
aux[new->wh] = '\0';
}
-static int check_difficulty(game_params *params, game_state *new,
+static int check_difficulty(const game_params *params, game_state *new,
random_state *rs)
{
int *scratch, *grid_correct, slen, i;
@@ -1675,7 +1676,7 @@
return 0;
}
-static char *new_game_desc(game_params *params, random_state *rs,
+static char *new_game_desc(const game_params *params, random_state *rs,
char **aux_r, int interactive)
{
game_state *new = new_state(params->w, params->h);
--- a/map.c
+++ b/map.c
@@ -1393,7 +1393,7 @@
* Game generation main function.
*/
-static char *new_game_desc(game_params *params, random_state *rs,
+static char *new_game_desc(const game_params *params, random_state *rs,
char **aux, int interactive)
{
struct solver_scratch *sc = NULL;
@@ -1704,7 +1704,7 @@
return ret;
}
-static char *parse_edge_list(game_params *params, char **desc, int *map)
+static char *parse_edge_list(const game_params *params, char **desc, int *map)
{
int w = params->w, h = params->h, wh = w*h, n = params->n;
int i, k, pos, state;
@@ -1780,7 +1780,7 @@
return NULL;
}
-static char *validate_desc(game_params *params, char *desc)
+static char *validate_desc(const game_params *params, char *desc)
{
int w = params->w, h = params->h, wh = w*h, n = params->n;
int area;
--- a/mines.c
+++ b/mines.c
@@ -1955,7 +1955,7 @@
return grid;
}
-static char *new_game_desc(game_params *params, random_state *rs,
+static char *new_game_desc(const game_params *params, random_state *rs,
char **aux, int interactive)
{
/*
@@ -1994,7 +1994,7 @@
}
}
-static char *validate_desc(game_params *params, char *desc)
+static char *validate_desc(const game_params *params, char *desc)
{
int wh = params->w * params->h;
int x, y;
--- a/net.c
+++ b/net.c
@@ -1126,7 +1126,7 @@
sfree(perimeter);
}
-static char *new_game_desc(game_params *params, random_state *rs,
+static char *new_game_desc(const game_params *params, random_state *rs,
char **aux, int interactive)
{
tree234 *possibilities, *barriertree;
@@ -1545,7 +1545,7 @@
return desc;
}
-static char *validate_desc(game_params *params, char *desc)
+static char *validate_desc(const game_params *params, char *desc)
{
int w = params->width, h = params->height;
int i;
--- a/netslide.c
+++ b/netslide.c
@@ -324,7 +324,7 @@
* Randomly select a new game description.
*/
-static char *new_game_desc(game_params *params, random_state *rs,
+static char *new_game_desc(const game_params *params, random_state *rs,
char **aux, int interactive)
{
tree234 *possibilities, *barriertree;
@@ -696,7 +696,7 @@
return desc;
}
-static char *validate_desc(game_params *params, char *desc)
+static char *validate_desc(const game_params *params, char *desc)
{
int w = params->width, h = params->height;
int i;
--- a/nullgame.c
+++ b/nullgame.c
@@ -83,13 +83,13 @@
return NULL;
}
-static char *new_game_desc(game_params *params, random_state *rs,
+static char *new_game_desc(const game_params *params, random_state *rs,
char **aux, int interactive)
{
return dupstr("FIXME");
}
-static char *validate_desc(game_params *params, char *desc)
+static char *validate_desc(const game_params *params, char *desc)
{
return NULL;
}
--- a/pattern.c
+++ b/pattern.c
@@ -662,7 +662,7 @@
return grid;
}
-static char *new_game_desc(game_params *params, random_state *rs,
+static char *new_game_desc(const game_params *params, random_state *rs,
char **aux, int interactive)
{
unsigned char *grid;
@@ -749,7 +749,7 @@
return desc;
}
-static char *validate_desc(game_params *params, char *desc)
+static char *validate_desc(const game_params *params, char *desc)
{
int i, n, rowspace;
char *p;
--- a/pearl.c
+++ b/pearl.c
@@ -1158,7 +1158,7 @@
#endif
}
-static int new_clues(game_params *params, random_state *rs,
+static int new_clues(const game_params *params, random_state *rs,
char *clues, char *grid)
{
int w = params->w, h = params->h, diff = params->difficulty;
@@ -1356,7 +1356,7 @@
return ngen;
}
-static char *new_game_desc(game_params *params, random_state *rs,
+static char *new_game_desc(const game_params *params, random_state *rs,
char **aux, int interactive)
{
char *grid, *clues;
@@ -1393,7 +1393,7 @@
return desc;
}
-static char *validate_desc(game_params *params, char *desc)
+static char *validate_desc(const game_params *params, char *desc)
{
int i, sizesofar;
const int totalsize = params->w * params->h;
--- a/pegs.c
+++ b/pegs.c
@@ -503,7 +503,7 @@
* it as part of the puzzle.
*/
-static char *new_game_desc(game_params *params, random_state *rs,
+static char *new_game_desc(const game_params *params, random_state *rs,
char **aux, int interactive)
{
int w = params->w, h = params->h;
@@ -660,7 +660,7 @@
return ret;
}
-static char *validate_desc(game_params *params, char *desc)
+static char *validate_desc(const game_params *params, char *desc)
{
int len = params->w * params->h;
--- a/puzzles.h
+++ b/puzzles.h
@@ -487,9 +487,9 @@
config_item *(*configure)(game_params *params);
game_params *(*custom_params)(config_item *cfg);
char *(*validate_params)(game_params *params, int full);
- char *(*new_desc)(game_params *params, random_state *rs,
+ char *(*new_desc)(const game_params *params, random_state *rs,
char **aux, int interactive);
- char *(*validate_desc)(game_params *params, char *desc);
+ char *(*validate_desc)(const game_params *params, char *desc);
game_state *(*new_game)(midend *me, game_params *params, char *desc);
game_state *(*dup_game)(game_state *state);
void (*free_game)(game_state *state);
--- a/range.c
+++ b/range.c
@@ -672,7 +672,7 @@
static int newdesc_strip_clues(game_state *state, int *shuffle_1toN);
static char *newdesc_encode_game_description(int n, puzzle_size *grid);
-static char *new_game_desc(game_params *params, random_state *rs,
+static char *new_game_desc(const game_params *params, random_state *rs,
char **aux, int interactive)
{
int const w = params->w, h = params->h, n = w * h;
@@ -1060,7 +1060,7 @@
return desc;
}
-static char *validate_desc(game_params *params, char *desc)
+static char *validate_desc(const game_params *params, char *desc)
{
int const n = params->w * params->h;
int squares = 0;
--- a/rect.c
+++ b/rect.c
@@ -1146,9 +1146,11 @@
}
#endif
-static char *new_game_desc(game_params *params, random_state *rs,
+static char *new_game_desc(const game_params *params_in, random_state *rs,
char **aux, int interactive)
{
+ game_params params_copy = *params_in; /* structure copy */
+ game_params *params = ¶ms_copy;
int *grid, *numbers = NULL;
int x, y, y2, y2last, yx, run, i, nsquares;
char *desc, *p;
@@ -1776,7 +1778,7 @@
return desc;
}
-static char *validate_desc(game_params *params, char *desc)
+static char *validate_desc(const game_params *params, char *desc)
{
int area = params->w * params->h;
int squares = 0;
--- a/samegame.c
+++ b/samegame.c
@@ -917,7 +917,7 @@
}
}
-static char *new_game_desc(game_params *params, random_state *rs,
+static char *new_game_desc(const game_params *params, random_state *rs,
char **aux, int interactive)
{
char *ret;
@@ -948,7 +948,7 @@
return ret;
}
-static char *validate_desc(game_params *params, char *desc)
+static char *validate_desc(const game_params *params, char *desc)
{
int area = params->w * params->h, i;
char *p = desc;
--- a/signpost.c
+++ b/signpost.c
@@ -499,7 +499,7 @@
sfree(state);
}
-static void unpick_desc(game_params *params, char *desc,
+static void unpick_desc(const game_params *params, char *desc,
game_state **sout, char **mout)
{
game_state *state = blank_game(params->w, params->h);
@@ -793,7 +793,7 @@
return ret;
}
-static char *new_game_desc(game_params *params, random_state *rs,
+static char *new_game_desc(const game_params *params, random_state *rs,
char **aux, int interactive)
{
game_state *state = blank_game(params->w, params->h);
@@ -840,7 +840,7 @@
return ret;
}
-static char *validate_desc(game_params *params, char *desc)
+static char *validate_desc(const game_params *params, char *desc)
{
char *ret = NULL;
--- a/singles.c
+++ b/singles.c
@@ -333,7 +333,7 @@
return -1;
}
-static void unpick_desc(game_params *params, char *desc,
+static void unpick_desc(const game_params *params, char *desc,
game_state **sout, char **mout)
{
game_state *state = blank_game(params->w, params->h);
@@ -1207,7 +1207,7 @@
the solver gets a headstart working out where they are.
*/
-static int new_game_is_good(game_params *params,
+static int new_game_is_good(const game_params *params,
game_state *state, game_state *tosolve)
{
int sret, sret_easy = 0;
@@ -1289,7 +1289,7 @@
return j;
}
-static char *new_game_desc(game_params *params, random_state *rs,
+static char *new_game_desc(const game_params *params, random_state *rs,
char **aux, int interactive)
{
game_state *state = blank_game(params->w, params->h);
@@ -1401,7 +1401,7 @@
return ret;
}
-static char *validate_desc(game_params *params, char *desc)
+static char *validate_desc(const game_params *params, char *desc)
{
char *ret = NULL;
--- a/sixteen.c
+++ b/sixteen.c
@@ -193,7 +193,7 @@
return ret;
}
-static char *new_game_desc(game_params *params, random_state *rs,
+static char *new_game_desc(const game_params *params, random_state *rs,
char **aux, int interactive)
{
int stop, n, i, x;
@@ -398,7 +398,7 @@
}
-static char *validate_desc(game_params *params, char *desc)
+static char *validate_desc(const game_params *params, char *desc)
{
char *p, *err;
int i, area;
--- a/slant.c
+++ b/slant.c
@@ -1063,7 +1063,7 @@
sfree(connected);
}
-static char *new_game_desc(game_params *params, random_state *rs,
+static char *new_game_desc(const game_params *params, random_state *rs,
char **aux, int interactive)
{
int w = params->w, h = params->h, W = w+1, H = h+1;
@@ -1216,7 +1216,7 @@
return desc;
}
-static char *validate_desc(game_params *params, char *desc)
+static char *validate_desc(const game_params *params, char *desc)
{
int w = params->w, h = params->h, W = w+1, H = h+1;
int area = W*H;
--- a/solo.c
+++ b/solo.c
@@ -3063,7 +3063,8 @@
return TRUE;
}
-static int symmetries(game_params *params, int x, int y, int *output, int s)
+static int symmetries(const game_params *params, int x, int y,
+ int *output, int s)
{
int c = params->c, r = params->r, cr = c*r;
int i = 0;
@@ -3305,7 +3306,7 @@
return grid_encode_space(area);
}
-static char *encode_puzzle_desc(game_params *params, digit *grid,
+static char *encode_puzzle_desc(const game_params *params, digit *grid,
struct block_structure *blocks,
digit *kgrid,
struct block_structure *kblocks)
@@ -3548,7 +3549,7 @@
return b;
}
-static char *new_game_desc(game_params *params, random_state *rs,
+static char *new_game_desc(const game_params *params, random_state *rs,
char **aux, int interactive)
{
int c = params->c, r = params->r, cr = c*r;
@@ -3989,7 +3990,7 @@
return NULL;
}
-static char *validate_desc(game_params *params, char *desc)
+static char *validate_desc(const game_params *params, char *desc)
{
int cr = params->c * params->r, area = cr*cr;
char *err;
--- a/tents.c
+++ b/tents.c
@@ -900,9 +900,11 @@
return 1;
}
-static char *new_game_desc(game_params *params, random_state *rs,
+static char *new_game_desc(const game_params *params_in, random_state *rs,
char **aux, int interactive)
{
+ game_params params_copy = *params_in; /* structure copy */
+ game_params *params = ¶ms_copy;
int w = params->w, h = params->h;
int ntrees = w * h / 5;
char *grid = snewn(w*h, char);
@@ -1188,7 +1190,7 @@
return ret;
}
-static char *validate_desc(game_params *params, char *desc)
+static char *validate_desc(const game_params *params, char *desc)
{
int w = params->w, h = params->h;
int area, i;
--- a/towers.c
+++ b/towers.c
@@ -608,7 +608,7 @@
* Grid generation.
*/
-static char *new_game_desc(game_params *params, random_state *rs,
+static char *new_game_desc(const game_params *params, random_state *rs,
char **aux, int interactive)
{
int w = params->w, a = w*w;
@@ -803,7 +803,7 @@
* Gameplay.
*/
-static char *validate_desc(game_params *params, char *desc)
+static char *validate_desc(const game_params *params, char *desc)
{
int w = params->w, a = w*w;
const char *p = desc;
--- a/twiddle.c
+++ b/twiddle.c
@@ -306,7 +306,7 @@
return ok;
}
-static char *new_game_desc(game_params *params, random_state *rs,
+static char *new_game_desc(const game_params *params, random_state *rs,
char **aux, int interactive)
{
int *grid;
@@ -430,7 +430,7 @@
return ret;
}
-static char *validate_desc(game_params *params, char *desc)
+static char *validate_desc(const game_params *params, char *desc)
{
char *p;
int w = params->w, h = params->h, wh = w*h;
--- a/undead.c
+++ b/undead.c
@@ -237,7 +237,7 @@
int cheated;
};
-static game_state *new_state(game_params *params) {
+static game_state *new_state(const game_params *params) {
int i;
game_state *state = snew(game_state);
state->common = snew(struct game_common);
@@ -956,7 +956,7 @@
return pa->num_monsters - pb->num_monsters;
}
-static char *new_game_desc(game_params *params, random_state *rs,
+static char *new_game_desc(const game_params *params, random_state *rs,
char **aux, int interactive) {
int i,count,c,w,h,r,p,g;
game_state *new;
@@ -1419,7 +1419,7 @@
return state;
}
-static char *validate_desc(game_params *params, char *desc) {
+static char *validate_desc(const game_params *params, char *desc) {
int i;
int w = params->w, h = params->h;
int wh = w*h;
--- a/unequal.c
+++ b/unequal.c
@@ -1094,9 +1094,11 @@
}
}
-static char *new_game_desc(game_params *params, random_state *rs,
+static char *new_game_desc(const game_params *params_in, random_state *rs,
char **aux, int interactive)
{
+ game_params params_copy = *params_in; /* structure copy */
+ game_params *params = ¶ms_copy;
digit *sq = NULL;
int i, x, y, retlen, k, nsol;
int o2 = params->order * params->order, ntries = 1;
@@ -1188,7 +1190,7 @@
return ret;
}
-static game_state *load_game(game_params *params, char *desc,
+static game_state *load_game(const game_params *params, char *desc,
char **why_r)
{
game_state *state = blank_game(params->order, params->adjacent);
@@ -1284,7 +1286,7 @@
return state;
}
-static char *validate_desc(game_params *params, char *desc)
+static char *validate_desc(const game_params *params, char *desc)
{
char *why = NULL;
game_state *dummy = load_game(params, desc, &why);
--- a/unfinished/group.c
+++ b/unfinished/group.c
@@ -361,7 +361,7 @@
#define SOLVER(upper,title,func,lower) func,
static usersolver_t const group_solvers[] = { DIFFLIST(SOLVER) };
-static int solver(game_params *params, digit *grid, int maxdiff)
+static int solver(const game_params *params, digit *grid, int maxdiff)
{
int w = params->w;
int ret;
@@ -595,7 +595,7 @@
/* ----- data generated by group.gap ends ----- */
-static char *new_game_desc(game_params *params, random_state *rs,
+static char *new_game_desc(const game_params *params, random_state *rs,
char **aux, int interactive)
{
int w = params->w, a = w*w;
@@ -810,7 +810,7 @@
return NULL;
}
-static char *validate_desc(game_params *params, char *desc)
+static char *validate_desc(const game_params *params, char *desc)
{
int w = params->w, a = w*w;
const char *p = desc;
--- a/unfinished/separate.c
+++ b/unfinished/separate.c
@@ -626,7 +626,7 @@
* End of solver/generator code.
*/
-static char *new_game_desc(game_params *params, random_state *rs,
+static char *new_game_desc(const game_params *params, random_state *rs,
char **aux, int interactive)
{
int w = params->w, h = params->h, wh = w*h, k = params->k;
@@ -646,7 +646,7 @@
return desc;
}
-static char *validate_desc(game_params *params, char *desc)
+static char *validate_desc(const game_params *params, char *desc)
{
return NULL;
}
--- a/unfinished/slide.c
+++ b/unfinished/slide.c
@@ -837,7 +837,7 @@
* End of solver/generator code.
*/
-static char *new_game_desc(game_params *params, random_state *rs,
+static char *new_game_desc(const game_params *params, random_state *rs,
char **aux, int interactive)
{
int w = params->w, h = params->h, wh = w*h;
@@ -891,7 +891,7 @@
return ret;
}
-static char *validate_desc(game_params *params, char *desc)
+static char *validate_desc(const game_params *params, char *desc)
{
int w = params->w, h = params->h, wh = w*h;
int *active, *link;
--- a/unfinished/sokoban.c
+++ b/unfinished/sokoban.c
@@ -731,7 +731,7 @@
grid[py*w+px] = PLAYER;
}
-static char *new_game_desc(game_params *params, random_state *rs,
+static char *new_game_desc(const game_params *params, random_state *rs,
char **aux, int interactive)
{
int w = params->w, h = params->h;
@@ -806,7 +806,7 @@
return desc;
}
-static char *validate_desc(game_params *params, char *desc)
+static char *validate_desc(const game_params *params, char *desc)
{
int w = params->w, h = params->h;
int area = 0;
--- a/unruly.c
+++ b/unruly.c
@@ -269,7 +269,7 @@
return NULL;
}
-static char *validate_desc(game_params *params, char *desc)
+static char *validate_desc(const game_params *params, char *desc)
{
int w2 = params->w2, h2 = params->h2;
int s = w2 * h2;
@@ -1077,7 +1077,7 @@
return TRUE;
}
-static char *new_game_desc(game_params *params, random_state *rs,
+static char *new_game_desc(const game_params *params, random_state *rs,
char **aux, int interactive)
{
#ifdef STANDALONE_SOLVER
--- a/untangle.c
+++ b/untangle.c
@@ -491,7 +491,7 @@
}
}
-static char *new_game_desc(game_params *params, random_state *rs,
+static char *new_game_desc(const game_params *params, random_state *rs,
char **aux, int interactive)
{
int n = params->n, i;
@@ -734,7 +734,7 @@
return ret;
}
-static char *validate_desc(game_params *params, char *desc)
+static char *validate_desc(const game_params *params, char *desc)
{
int a, b;