chiark
/
gitweb
/
~ian
/
sgt-puzzles.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix borders on the HTML menu bar.
[sgt-puzzles.git]
/
netslide.c
diff --git
a/netslide.c
b/netslide.c
index 99eb6e13620f87cb5aeb347daabe8693bc3d0224..c56e1abd6a822f88560a3bb1d817a7ef31e3d887 100644
(file)
--- a/
netslide.c
+++ b/
netslide.c
@@
-197,7
+197,7
@@
static void free_params(game_params *params)
sfree(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 */
{
game_params *ret = snew(game_params);
*ret = *params; /* structure copy */
@@
-232,7
+232,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;
{
char ret[400];
int len;
@@
-252,7
+252,7
@@
static char *encode_params(game_params *params, int full)
return dupstr(ret);
}
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];
{
config_item *ret;
char buf[80];
@@
-296,7
+296,7
@@
static config_item *game_configure(game_params *params)
return ret;
}
return ret;
}
-static game_params *custom_params(config_item *cfg)
+static game_params *custom_params(con
st con
fig_item *cfg)
{
game_params *ret = snew(game_params);
{
game_params *ret = snew(game_params);
@@
-309,7
+309,7
@@
static game_params *custom_params(config_item *cfg)
return ret;
}
return ret;
}
-static char *validate_params(game_params *params, int full)
+static char *validate_params(
const
game_params *params, int full)
{
if (params->width <= 1 || params->height <= 1)
return "Width and height must both be greater than one";
{
if (params->width <= 1 || params->height <= 1)
return "Width and height must both be greater than one";
@@
-324,7
+324,7
@@
static char *validate_params(game_params *params, int full)
* Randomly select a new game description.
*/
* 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;
char **aux, int interactive)
{
tree234 *possibilities, *barriertree;
@@
-696,7
+696,7
@@
static char *new_game_desc(game_params *params, random_state *rs,
return desc;
}
return desc;
}
-static char *validate_desc(
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;
{
int w = params->width, h = params->height;
int i;
@@
-726,7
+726,8
@@
static char *validate_desc(game_params *params, char *desc)
* Construct an initial game state, given a description and parameters.
*/
* 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;
{
game_state *state;
int w, h, x, y;
@@
-852,7
+853,7
@@
static game_state *new_game(midend *me, game_params *params, char *desc)
return state;
}
return state;
}
-static game_state *dup_game(game_state *state)
+static game_state *dup_game(
const
game_state *state)
{
game_state *ret;
{
game_state *ret;
@@
-884,8
+885,8
@@
static void free_game(game_state *state)
sfree(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)
{
if (!aux) {
*error = "Solution not known for this puzzle";
{
if (!aux) {
*error = "Solution not known for this puzzle";
@@
-895,12
+896,12
@@
static char *solve_game(game_state *state, game_state *currstate,
return dupstr(aux);
}
return dupstr(aux);
}
-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;
}
{
return TRUE;
}
-static char *game_text_format(game_state *state)
+static char *game_text_format(
const
game_state *state)
{
return NULL;
}
{
return NULL;
}
@@
-919,7
+920,7
@@
static char *game_text_format(game_state *state)
* squares in the moving_row and moving_col are always inactive - this
* is so that "current" doesn't appear to jump across moving lines.
*/
* squares in the moving_row and moving_col are always inactive - this
* is so that "current" doesn't appear to jump across moving lines.
*/
-static unsigned char *compute_active(game_state *state,
+static unsigned char *compute_active(
const
game_state *state,
int moving_row, int moving_col)
{
unsigned char *active;
int moving_row, int moving_col)
{
unsigned char *active;
@@
-976,7
+977,7
@@
struct game_ui {
int cur_visible;
};
int cur_visible;
};
-static game_ui *new_ui(game_state *state)
+static game_ui *new_ui(
const
game_state *state)
{
game_ui *ui = snew(game_ui);
ui->cur_x = 0;
{
game_ui *ui = snew(game_ui);
ui->cur_x = 0;
@@
-991,12
+992,12
@@
static void free_ui(game_ui *ui)
sfree(ui);
}
sfree(ui);
}
-static char *encode_ui(game_ui *ui)
+static char *encode_ui(
const
game_ui *ui)
{
return NULL;
}
{
return NULL;
}
-static void decode_ui(game_ui *ui, char *encoding)
+static void decode_ui(game_ui *ui, c
onst c
har *encoding)
{
}
{
}
@@
-1042,8
+1043,8
@@
static void slide_col(game_state *state, int dir, int col)
slide_col_int(state->width, state->height, state->tiles, dir, col);
}
slide_col_int(state->width, state->height, state->tiles, dir, col);
}
-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)
{
}
{
}
@@
-1055,11
+1056,12
@@
struct game_drawstate {
int cur_x, cur_y;
};
int cur_x, cur_y;
};
-static char *interpret_move(game_state *state, game_ui *ui,
- 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)
{
int cx, cy;
{
int cx, cy;
- int
n,
dx, dy;
+ int dx, dy;
char buf[80];
button &= ~MOD_MASK;
char buf[80];
button &= ~MOD_MASK;
@@
-1101,7
+1103,6
@@
static char *interpret_move(game_state *state, game_ui *ui,
if (cx == -1) dx = +1;
else if (cx == state->width) dx = -1;
else return NULL;
if (cx == -1) dx = +1;
else if (cx == state->width) dx = -1;
else return NULL;
- n = state->width;
dy = 0;
}
else if (cx >= 0 && cx < state->width && cx != state->cx)
dy = 0;
}
else if (cx >= 0 && cx < state->width && cx != state->cx)
@@
-1109,7
+1110,6
@@
static char *interpret_move(game_state *state, game_ui *ui,
if (cy == -1) dy = +1;
else if (cy == state->height) dy = -1;
else return NULL;
if (cy == -1) dy = +1;
else if (cy == state->height) dy = -1;
else return NULL;
- n = state->height;
dx = 0;
}
else
dx = 0;
}
else
@@
-1129,7
+1129,7
@@
static char *interpret_move(game_state *state, game_ui *ui,
return dupstr(buf);
}
return dupstr(buf);
}
-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 c, d, col;
{
game_state *ret;
int c, d, col;
@@
-1204,7
+1204,7
@@
static game_state *execute_move(game_state *from, char *move)
* Routines for drawing the game position on the screen.
*/
* 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);
{
game_drawstate *ds = snew(game_drawstate);
@@
-1225,8
+1225,8
@@
static void game_free_drawstate(drawing *dr, game_drawstate *ds)
sfree(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)
{
/* Ick: fake up `ds->tilesize' for macro expansion purposes */
struct { int tilesize; } ads, *ds = &ads;
{
/* Ick: fake up `ds->tilesize' for macro expansion purposes */
struct { int tilesize; } ads, *ds = &ads;
@@
-1237,7
+1237,7
@@
static void game_compute_size(game_params *params, int tilesize,
}
static void game_set_size(drawing *dr, game_drawstate *ds,
}
static void game_set_size(drawing *dr, game_drawstate *ds,
- game_params *params, int tilesize)
+
const
game_params *params, int tilesize)
{
ds->tilesize = tilesize;
}
{
ds->tilesize = tilesize;
}
@@
-1307,8
+1307,8
@@
static float *game_colours(frontend *fe, int *ncolours)
return ret;
}
return ret;
}
-static void draw_
thick
_line(drawing *dr, int x1, int y1, int x2, int y2,
- int colour)
+static void draw_
filled
_line(drawing *dr, int x1, int y1, int x2, int y2,
+ int colour)
{
draw_line(dr, x1-1, y1, x2-1, y2, COL_WIRE);
draw_line(dr, x1+1, y1, x2+1, y2, COL_WIRE);
{
draw_line(dr, x1-1, y1, x2-1, y2, COL_WIRE);
draw_line(dr, x1+1, y1, x2+1, y2, COL_WIRE);
@@
-1376,7
+1376,7
@@
static void draw_barrier(drawing *dr, game_drawstate *ds,
}
}
}
}
-static void draw_tile(drawing *dr, game_drawstate *ds, game_state *state,
+static void draw_tile(drawing *dr, game_drawstate *ds,
const
game_state *state,
int x, int y, int tile, float xshift, float yshift)
{
int bx = BORDER + WINDOW_OFFSET + TILE_SIZE * x + (int)(xshift * TILE_SIZE);
int x, int y, int tile, float xshift, float yshift)
{
int bx = BORDER + WINDOW_OFFSET + TILE_SIZE * x + (int)(xshift * TILE_SIZE);
@@
-1420,9
+1420,9
@@
static void draw_tile(drawing *dr, game_drawstate *ds, game_state *state,
if (tile & dir) {
ex = (TILE_SIZE - TILE_BORDER - 1.0F) / 2.0F * X(dir);
ey = (TILE_SIZE - TILE_BORDER - 1.0F) / 2.0F * Y(dir);
if (tile & dir) {
ex = (TILE_SIZE - TILE_BORDER - 1.0F) / 2.0F * X(dir);
ey = (TILE_SIZE - TILE_BORDER - 1.0F) / 2.0F * Y(dir);
- draw_
thick
_line(dr, bx+(int)cx, by+(int)cy,
- bx+(int)(cx+ex), by+(int)(cy+ey),
- COL_WIRE);
+ draw_
filled
_line(dr, bx+(int)cx, by+(int)cy,
+
bx+(int)(cx+ex), by+(int)(cy+ey),
+ COL_WIRE);
}
}
for (dir = 1; dir < 0x10; dir <<= 1) {
}
}
for (dir = 1; dir < 0x10; dir <<= 1) {
@@
-1515,7
+1515,7
@@
static void draw_tile(drawing *dr, game_drawstate *ds, game_state *state,
}
static void draw_tile_barriers(drawing *dr, game_drawstate *ds,
}
static void draw_tile_barriers(drawing *dr, game_drawstate *ds,
- game_state *state, int x, int y)
+
const
game_state *state, int x, int y)
{
int phase;
int dir;
{
int phase;
int dir;
@@
-1582,10
+1582,12
@@
static void draw_arrow_for_cursor(drawing *dr, game_drawstate *ds,
TILE_SIZE, TILE_SIZE);
}
TILE_SIZE, TILE_SIZE);
}
-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;
+ int x, y, frame;
unsigned char *active;
float xshift = 0.0;
float yshift = 0.0;
unsigned char *active;
float xshift = 0.0;
float yshift = 0.0;
@@
-1671,13
+1673,12
@@
static void game_redraw(drawing *dr, game_drawstate *ds, game_state *oldstate,
* backwards.
*/
if (oldstate && oldstate->move_count > state->move_count) {
* backwards.
*/
if (oldstate && oldstate->move_count > state->move_count) {
- game_state * tmpstate = state;
+
const
game_state * tmpstate = state;
state = oldstate;
oldstate = tmpstate;
t = ANIM_TIME - t;
}
state = oldstate;
oldstate = tmpstate;
t = ANIM_TIME - t;
}
- tx = ty = -1;
if (oldstate && (t < ANIM_TIME)) {
/*
* We're animating a slide, of row/column number
if (oldstate && (t < ANIM_TIME)) {
/*
* We're animating a slide, of row/column number
@@
-1798,14
+1799,14
@@
static void game_redraw(drawing *dr, game_drawstate *ds, game_state *oldstate,
sfree(active);
}
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)
{
return ANIM_TIME;
}
{
return ANIM_TIME;
}
-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
{
/*
* If the game has just been completed, we display a completion
@@
-1829,16
+1830,21
@@
static float game_flash_length(game_state *oldstate,
return 0.0F;
}
return 0.0F;
}
-static int game_timing_state(game_state *state, game_ui *ui)
+static int game_status(const game_state *state)
+{
+ return state->completed ? +1 : 0;
+}
+
+static int game_timing_state(const game_state *state, game_ui *ui)
{
return FALSE;
}
{
return FALSE;
}
-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)
{
}
{
}
-static void game_print(drawing *dr, game_state *state, int tilesize)
+static void game_print(drawing *dr,
const
game_state *state, int tilesize)
{
}
{
}
@@
-1849,7
+1855,7
@@
static void game_print(drawing *dr, game_state *state, int tilesize)
const struct game thegame = {
"Netslide", "games.netslide", "netslide",
default_params,
const struct game thegame = {
"Netslide", "games.netslide", "netslide",
default_params,
- game_fetch_preset,
+ game_fetch_preset,
NULL,
decode_params,
encode_params,
free_params,
decode_params,
encode_params,
free_params,
@@
-1877,6
+1883,7
@@
const struct game thegame = {
game_redraw,
game_anim_length,
game_flash_length,
game_redraw,
game_anim_length,
game_flash_length,
+ game_status,
FALSE, FALSE, game_print_size, game_print,
TRUE, /* wants_statusbar */
FALSE, game_timing_state,
FALSE, FALSE, game_print_size, game_print,
TRUE, /* wants_statusbar */
FALSE, game_timing_state,