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

View File

@ -127,7 +127,7 @@ const static struct game_params group_presets[] = {
{ 12, DIFF_NORMAL, TRUE },
};
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 buf[80];
@ -189,7 +189,7 @@ static void decode_params(game_params *params, 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[80];
@ -240,7 +240,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->w < 3 || params->w > 26)
return "Grid size must be between 3 and 26";
@ -593,7 +593,7 @@ static const struct groups groups[] = {
/* ----- data generated by group.gap ends ----- */
static char *new_game_desc(const game_params *params, random_state *rs,
char **aux, int interactive)
char **aux, bool interactive)
{
int w = params->w, a = w*w;
digit *grid, *soln, *soln2;
@ -940,7 +940,7 @@ static char *solve_game(const game_state *state, const game_state *currstate,
return out;
}
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;
}
@ -1973,7 +1973,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)
{
if (state->completed)
return FALSE;