Adopt C99 bool in the game backend API.

encode_params, validate_params and new_desc now take a bool parameter;
fetch_preset, can_format_as_text_now and timing_state all return bool;
and the data fields is_timed, wants_statusbar and can_* are all bool.
All of those were previously typed as int, but semantically boolean.

This commit changes the API declarations in puzzles.h, updates all the
games to match (including the unfinisheds), and updates the developer
docs as well.
This commit is contained in:
Simon Tatham
2018-11-13 21:34:42 +00:00
parent 0f77798ae2
commit a76d269cf2
46 changed files with 319 additions and 319 deletions

12
net.c
View File

@ -178,7 +178,7 @@ static const struct game_params net_presets[] = {
#endif
};
static int game_fetch_preset(int i, char **name, game_params **params)
static bool game_fetch_preset(int i, char **name, game_params **params)
{
game_params *ret;
char str[80];
@ -239,7 +239,7 @@ static void decode_params(game_params *ret, char const *string)
}
}
static char *encode_params(const game_params *params, int full)
static char *encode_params(const game_params *params, bool full)
{
char ret[400];
int len;
@ -306,7 +306,7 @@ static game_params *custom_params(const config_item *cfg)
return ret;
}
static const char *validate_params(const game_params *params, int full)
static const char *validate_params(const game_params *params, bool full)
{
if (params->width <= 0 || params->height <= 0)
return "Width and height must both be greater than zero";
@ -1130,7 +1130,7 @@ static int *compute_loops_inner(int w, int h, int wrapping,
const unsigned char *barriers);
static char *new_game_desc(const game_params *params, random_state *rs,
char **aux, int interactive)
char **aux, bool interactive)
{
tree234 *possibilities, *barriertree;
int w, h, x, y, cx, cy, nbarriers;
@ -1844,7 +1844,7 @@ static char *solve_game(const game_state *state, const game_state *currstate,
return ret;
}
static int game_can_format_as_text_now(const game_params *params)
static bool game_can_format_as_text_now(const game_params *params)
{
return TRUE;
}
@ -3089,7 +3089,7 @@ 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)
static bool game_timing_state(const game_state *state, game_ui *ui)
{
return TRUE;
}