diff options
| author | Simon Tatham <anakin@pobox.com> | 2018-11-13 21:44:02 +0000 |
|---|---|---|
| committer | Simon Tatham <anakin@pobox.com> | 2018-11-13 21:48:24 +0000 |
| commit | a550ea0a47374705a37f36b0f05ffe9e4c8161fb (patch) | |
| tree | a4664ac4d90cdeb581ddd2bf41ccda7b0d45855c /range.c | |
| parent | 064da876828ea3079d5d7be5849b693f4d55364b (diff) | |
| download | puzzles-a550ea0a47374705a37f36b0f05ffe9e4c8161fb.zip puzzles-a550ea0a47374705a37f36b0f05ffe9e4c8161fb.tar.gz puzzles-a550ea0a47374705a37f36b0f05ffe9e4c8161fb.tar.bz2 puzzles-a550ea0a47374705a37f36b0f05ffe9e4c8161fb.tar.xz | |
Replace TRUE/FALSE with C99 true/false throughout.
This commit removes the old #defines of TRUE and FALSE from puzzles.h,
and does a mechanical search-and-replace throughout the code to
replace them with the C99 standard lowercase spellings.
Diffstat (limited to 'range.c')
| -rw-r--r-- | range.c | 64 |
1 files changed, 32 insertions, 32 deletions
@@ -127,7 +127,7 @@ static bool game_fetch_preset(int i, char **name, game_params **params) { game_params *ret; - if (i < 0 || i >= lenof(range_presets)) return FALSE; + if (i < 0 || i >= lenof(range_presets)) return false; ret = default_params(); *ret = range_presets[i]; /* struct copy */ @@ -135,7 +135,7 @@ static bool game_fetch_preset(int i, char **name, game_params **params) *name = nfmtstr(40, "%d x %d", range_presets[i].w, range_presets[i].h); - return TRUE; + return true; } static void free_params(game_params *params) @@ -388,7 +388,7 @@ static int runlength(puzzle_size r, puzzle_size c, { int const w = state->params.w, h = state->params.h; int sz = 0; - while (TRUE) { + while (true) { int cell = idx(r, c, w); if (out_of_bounds(r, c, w, h)) break; if (state->grid[cell] > 0) { @@ -706,7 +706,7 @@ static char *new_game_desc(const game_params *params, random_state *rs, for (i = 0; i < n; ++i) shuffle_1toN[i] = i; - while (TRUE) { + while (true) { shuffle(shuffle_1toN, n, sizeof (int), rs); newdesc_choose_black_squares(&state, shuffle_1toN); @@ -1139,8 +1139,8 @@ static game_state *new_game(midend *me, const game_params *params, } } assert(i == n); - state->has_cheated = FALSE; - state->was_solved = FALSE; + state->has_cheated = false; + state->was_solved = false; return state; } @@ -1151,7 +1151,7 @@ static game_state *new_game(midend *me, const game_params *params, static bool game_can_format_as_text_now(const game_params *params) { - return TRUE; + return true; } static char *game_text_format(const game_state *state) @@ -1228,7 +1228,7 @@ static game_ui *new_ui(const game_state *state) { struct game_ui *ui = snew(game_ui); ui->r = ui->c = 0; - ui->cursor_show = FALSE; + ui->cursor_show = false; return ui; } @@ -1282,7 +1282,7 @@ static char *interpret_move(const game_state *state, game_ui *ui, if (out_of_bounds(r, c, w, h)) return NULL; ui->r = r; ui->c = c; - ui->cursor_show = FALSE; + ui->cursor_show = false; } if (button == LEFT_BUTTON || button == RIGHT_BUTTON) { @@ -1363,7 +1363,7 @@ static char *interpret_move(const game_state *state, game_ui *ui, ui->r += dr[i]; ui->c += dc[i]; } - } else ui->cursor_show = TRUE; + } else ui->cursor_show = true; return UI_UPDATE; } @@ -1430,7 +1430,7 @@ static int find_errors(const game_state *state, int *report) if (out_of_bounds(rr, cc, w, h)) continue; if (state->grid[idx(rr, cc, w)] != BLACK) continue; if (!report) goto found_error; - report[i] = TRUE; + report[i] = true; break; } } @@ -1445,14 +1445,14 @@ static int find_errors(const game_state *state, int *report) } if (!report) { if (runs != state->grid[i]) goto found_error; - } else if (runs < state->grid[i]) report[i] = TRUE; + } else if (runs < state->grid[i]) report[i] = true; else { for (runs = 1, j = 0; j < 4; ++j) { int const rr = r + dr[j], cc = c + dc[j]; runs += runlength(rr, cc, dr[j], dc[j], state, ~(MASK(BLACK) | MASK(EMPTY))); } - if (runs > state->grid[i]) report[i] = TRUE; + if (runs > state->grid[i]) report[i] = true; } } @@ -1503,16 +1503,16 @@ static int find_errors(const game_state *state, int *report) for (i = 0; i < n; ++i) if (state->grid[i] != BLACK && dsf_canonify(dsf, i) != canonical) - report[i] = TRUE; + report[i] = true; } sfree(dsf); free_game(dup); - return FALSE; /* if report != NULL, this is ignored */ + return false; /* if report != NULL, this is ignored */ found_error: free_game(dup); - return TRUE; + return true; } static game_state *execute_move(const game_state *state, const char *move) @@ -1527,7 +1527,7 @@ static game_state *execute_move(const game_state *state, const char *move) if (*move == 'S') { ++move; - ret->has_cheated = ret->was_solved = TRUE; + ret->has_cheated = ret->was_solved = true; } for (; *move; move += nchars) { @@ -1543,7 +1543,7 @@ static game_state *execute_move(const game_state *state, const char *move) ret->grid[idx(r, c, ret->params.w)] = value; } - if (ret->was_solved == FALSE) + if (ret->was_solved == false) ret->was_solved = !find_errors(ret, NULL); return ret; @@ -1643,11 +1643,11 @@ static game_drawstate *game_new_drawstate(drawing *dr, const game_state *state) int i; ds->tilesize = 0; - ds->started = FALSE; + ds->started = false; ds->grid = snewn(n, drawcell); for (i = 0; i < n; ++i) - ds->grid[i] = makecell(w + h, FALSE, FALSE, FALSE); + ds->grid[i] = makecell(w + h, false, false, false); return ds; } @@ -1684,22 +1684,22 @@ static void game_redraw(drawing *dr, game_drawstate *ds, int r, c, i; int *errors = snewn(n, int); - memset(errors, FALSE, n * sizeof (int)); + memset(errors, false, n * sizeof (int)); find_errors(state, errors); assert (oldstate == NULL); /* only happens if animating moves */ if (!ds->started) { - ds->started = TRUE; + ds->started = true; draw_rect(dr, 0, 0, wpx, hpx, COL_BACKGROUND); draw_update(dr, 0, 0, wpx, hpx); } for (i = r = 0; r < h; ++r) { for (c = 0; c < w; ++c, ++i) { - drawcell cell = makecell(state->grid[i], errors[i], FALSE, flash); + drawcell cell = makecell(state->grid[i], errors[i], false, flash); if (r == ui->r && c == ui->c && ui->cursor_show) - cell.cursor = TRUE; + cell.cursor = true; if (!cell_eq(cell, ds->grid[i])) { draw_cell(dr, ds, r, c, cell); ds->grid[i] = cell; @@ -1748,7 +1748,7 @@ static void draw_cell(drawing *draw, game_drawstate *ds, int r, int c, static bool game_timing_state(const game_state *state, game_ui *ui) { puts("warning: game_timing_state was called (this shouldn't happen)"); - return FALSE; /* the (non-existing) timer should not be running */ + return false; /* the (non-existing) timer should not be running */ } /* ---------------------------------------------------------------------- @@ -1780,7 +1780,7 @@ static void game_print(drawing *dr, const game_state *state, int tilesize) for (i = r = 0; r < h; ++r) for (c = 0; c < w; ++c, ++i) draw_cell(dr, ds, r, c, - makecell(state->grid[i], FALSE, FALSE, FALSE)); + makecell(state->grid[i], false, false, false)); print_line_width(dr, 3 * tilesize / 40); draw_rect_outline(dr, BORDER, BORDER, w*TILESIZE, h*TILESIZE, COL_GRID); @@ -1800,15 +1800,15 @@ struct game const thegame = { encode_params, free_params, dup_params, - TRUE, game_configure, custom_params, + true, game_configure, custom_params, validate_params, new_game_desc, validate_desc, new_game, dup_game, free_game, - TRUE, solve_game, - TRUE, game_can_format_as_text_now, game_text_format, + true, solve_game, + true, game_can_format_as_text_now, game_text_format, new_ui, free_ui, encode_ui, @@ -1825,8 +1825,8 @@ struct game const thegame = { game_anim_length, game_flash_length, game_status, - TRUE, FALSE, game_print_size, game_print, - FALSE, /* wants_statusbar */ - FALSE, game_timing_state, + true, false, game_print_size, game_print, + false, /* wants_statusbar */ + false, game_timing_state, 0, /* flags */ }; |