diff options
| author | Simon Tatham <anakin@pobox.com> | 2013-04-13 10:37:32 +0000 |
|---|---|---|
| committer | Simon Tatham <anakin@pobox.com> | 2013-04-13 10:37:32 +0000 |
| commit | 251b21c41813055d9c416378508b1ee038bc3dac (patch) | |
| tree | 3adb963c93a9ae014c8c7d6fd1bce5498d6bd062 /net.c | |
| parent | 339329449f4db72e4754f21c14295303ffe0ea5d (diff) | |
| download | puzzles-251b21c41813055d9c416378508b1ee038bc3dac.zip puzzles-251b21c41813055d9c416378508b1ee038bc3dac.tar.gz puzzles-251b21c41813055d9c416378508b1ee038bc3dac.tar.bz2 puzzles-251b21c41813055d9c416378508b1ee038bc3dac.tar.xz | |
Giant const patch of doom: add a 'const' to every parameter in every
puzzle backend function which ought to have it, and propagate those
consts through to per-puzzle subroutines as needed.
I've recently had to do that to a few specific parameters which were
being misused by particular puzzles (r9657, r9830), which suggests
that it's probably a good idea to do the whole lot pre-emptively
before the next such problem shows up.
[originally from svn r9832]
[r9657 == 3b250baa02a7332510685948bf17576c397b8ceb]
[r9830 == 0b93de904a98f119b1a95d3a53029f1ed4bfb9b3]
Diffstat (limited to 'net.c')
| -rw-r--r-- | net.c | 76 |
1 files changed, 40 insertions, 36 deletions
@@ -205,7 +205,7 @@ static void free_params(game_params *params) sfree(params); } -static game_params *dup_params(game_params *params) +static game_params *dup_params(const game_params *params) { game_params *ret = snew(game_params); *ret = *params; /* structure copy */ @@ -242,7 +242,7 @@ static void decode_params(game_params *ret, char const *string) } } -static char *encode_params(game_params *params, int full) +static char *encode_params(const game_params *params, int full) { char ret[400]; int len; @@ -260,7 +260,7 @@ static char *encode_params(game_params *params, int full) return dupstr(ret); } -static config_item *game_configure(game_params *params) +static config_item *game_configure(const game_params *params) { config_item *ret; char buf[80]; @@ -303,7 +303,7 @@ static config_item *game_configure(game_params *params) return ret; } -static game_params *custom_params(config_item *cfg) +static game_params *custom_params(const config_item *cfg) { game_params *ret = snew(game_params); @@ -316,7 +316,7 @@ static game_params *custom_params(config_item *cfg) return ret; } -static char *validate_params(game_params *params, int full) +static char *validate_params(const game_params *params, int full) { if (params->width <= 0 || params->height <= 0) return "Width and height must both be greater than zero"; @@ -1545,7 +1545,7 @@ static char *new_game_desc(const game_params *params, random_state *rs, return desc; } -static char *validate_desc(const game_params *params, char *desc) +static char *validate_desc(const game_params *params, const char *desc) { int w = params->width, h = params->height; int i; @@ -1575,7 +1575,8 @@ static char *validate_desc(const game_params *params, char *desc) * Construct an initial game state, given a description and parameters. */ -static game_state *new_game(midend *me, game_params *params, char *desc) +static game_state *new_game(midend *me, const game_params *params, + const char *desc) { game_state *state; int w, h, x, y; @@ -1661,7 +1662,7 @@ static game_state *new_game(midend *me, game_params *params, char *desc) return state; } -static game_state *dup_game(game_state *state) +static game_state *dup_game(const game_state *state) { game_state *ret; @@ -1689,8 +1690,8 @@ static void free_game(game_state *state) sfree(state); } -static char *solve_game(game_state *state, game_state *currstate, - char *aux, char **error) +static char *solve_game(const game_state *state, const game_state *currstate, + const char *aux, char **error) { unsigned char *tiles; char *ret; @@ -1784,12 +1785,12 @@ static char *solve_game(game_state *state, game_state *currstate, return ret; } -static int game_can_format_as_text_now(game_params *params) +static int game_can_format_as_text_now(const game_params *params) { return TRUE; } -static char *game_text_format(game_state *state) +static char *game_text_format(const game_state *state) { return NULL; } @@ -1805,7 +1806,7 @@ static char *game_text_format(game_state *state) * completed - just call this function and see whether every square * is marked active. */ -static unsigned char *compute_active(game_state *state, int cx, int cy) +static unsigned char *compute_active(const game_state *state, int cx, int cy) { unsigned char *active; tree234 *todo; @@ -1866,7 +1867,7 @@ struct game_ui { #endif }; -static game_ui *new_ui(game_state *state) +static game_ui *new_ui(const game_state *state) { void *seed; int seedsize; @@ -1888,7 +1889,7 @@ static void free_ui(game_ui *ui) sfree(ui); } -static char *encode_ui(game_ui *ui) +static char *encode_ui(const game_ui *ui) { char buf[120]; /* @@ -1899,14 +1900,14 @@ static char *encode_ui(game_ui *ui) return dupstr(buf); } -static void decode_ui(game_ui *ui, char *encoding) +static void decode_ui(game_ui *ui, const char *encoding) { sscanf(encoding, "O%d,%d;C%d,%d", &ui->org_x, &ui->org_y, &ui->cx, &ui->cy); } -static void game_changed_state(game_ui *ui, game_state *oldstate, - game_state *newstate) +static void game_changed_state(game_ui *ui, const game_state *oldstate, + const game_state *newstate) { } @@ -1921,8 +1922,9 @@ struct game_drawstate { /* ---------------------------------------------------------------------- * Process a move. */ -static char *interpret_move(game_state *state, game_ui *ui, - const game_drawstate *ds, int x, int y, int button) +static char *interpret_move(const game_state *state, game_ui *ui, + const game_drawstate *ds, + int x, int y, int button) { char *nullret; int tx = -1, ty = -1, dir = 0; @@ -2194,7 +2196,7 @@ static char *interpret_move(game_state *state, game_ui *ui, } } -static game_state *execute_move(game_state *from, char *move) +static game_state *execute_move(const game_state *from, const char *move) { game_state *ret; int tx = -1, ty = -1, n, noanim, orig; @@ -2285,7 +2287,7 @@ static game_state *execute_move(game_state *from, char *move) * Routines for drawing the game position on the screen. */ -static game_drawstate *game_new_drawstate(drawing *dr, game_state *state) +static game_drawstate *game_new_drawstate(drawing *dr, const game_state *state) { game_drawstate *ds = snew(game_drawstate); @@ -2306,15 +2308,15 @@ static void game_free_drawstate(drawing *dr, game_drawstate *ds) sfree(ds); } -static void game_compute_size(game_params *params, int tilesize, - int *x, int *y) +static void game_compute_size(const game_params *params, int tilesize, + int *x, int *y) { *x = WINDOW_OFFSET * 2 + tilesize * params->width + TILE_BORDER; *y = WINDOW_OFFSET * 2 + tilesize * params->height + TILE_BORDER; } static void game_set_size(drawing *dr, game_drawstate *ds, - game_params *params, int tilesize) + const game_params *params, int tilesize) { ds->tilesize = tilesize; } @@ -2447,7 +2449,7 @@ static void draw_barrier(drawing *dr, game_drawstate *ds, /* * draw_tile() is passed physical coordinates */ -static void draw_tile(drawing *dr, game_state *state, game_drawstate *ds, +static void draw_tile(drawing *dr, const game_state *state, game_drawstate *ds, int x, int y, int tile, int src, float angle, int cursor) { int bx = WINDOW_OFFSET + TILE_SIZE * x; @@ -2663,8 +2665,10 @@ static void draw_tile(drawing *dr, game_state *state, game_drawstate *ds, draw_update(dr, bx, by, TILE_SIZE+TILE_BORDER, TILE_SIZE+TILE_BORDER); } -static void game_redraw(drawing *dr, game_drawstate *ds, game_state *oldstate, - game_state *state, int dir, game_ui *ui, float t, float ft) +static void game_redraw(drawing *dr, game_drawstate *ds, + const game_state *oldstate, const game_state *state, + int dir, const game_ui *ui, + float t, float ft) { int x, y, tx, ty, frame, last_rotate_dir, moved_origin = FALSE; unsigned char *active; @@ -2828,8 +2832,8 @@ static void game_redraw(drawing *dr, game_drawstate *ds, game_state *oldstate, sfree(active); } -static float game_anim_length(game_state *oldstate, - game_state *newstate, int dir, game_ui *ui) +static float game_anim_length(const game_state *oldstate, + const game_state *newstate, int dir, game_ui *ui) { int last_rotate_dir; @@ -2844,8 +2848,8 @@ static float game_anim_length(game_state *oldstate, return 0.0F; } -static float game_flash_length(game_state *oldstate, - game_state *newstate, int dir, game_ui *ui) +static float game_flash_length(const game_state *oldstate, + const game_state *newstate, int dir, game_ui *ui) { /* * If the game has just been completed, we display a completion @@ -2864,17 +2868,17 @@ static float game_flash_length(game_state *oldstate, return 0.0F; } -static int game_status(game_state *state) +static int game_status(const game_state *state) { return state->completed ? +1 : 0; } -static int game_timing_state(game_state *state, game_ui *ui) +static int game_timing_state(const game_state *state, game_ui *ui) { return TRUE; } -static void game_print_size(game_params *params, float *x, float *y) +static void game_print_size(const game_params *params, float *x, float *y) { int pw, ph; @@ -2932,7 +2936,7 @@ static void draw_diagram(drawing *dr, game_drawstate *ds, int x, int y, } } -static void game_print(drawing *dr, game_state *state, int tilesize) +static void game_print(drawing *dr, const game_state *state, int tilesize) { int w = state->width, h = state->height; int ink = print_mono_colour(dr, 0); |