mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-20 23:51:29 -07:00
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.
This commit is contained in:
106
pearl.c
106
pearl.c
@ -150,7 +150,7 @@ static game_params *default_params(void)
|
||||
game_params *ret = snew(game_params);
|
||||
|
||||
*ret = pearl_presets[DEFAULT_PRESET];
|
||||
ret->nosolve = FALSE;
|
||||
ret->nosolve = false;
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -160,7 +160,7 @@ static bool game_fetch_preset(int i, char **name, game_params **params)
|
||||
game_params *ret;
|
||||
char buf[64];
|
||||
|
||||
if (i < 0 || i >= lenof(pearl_presets)) return FALSE;
|
||||
if (i < 0 || i >= lenof(pearl_presets)) return false;
|
||||
|
||||
ret = default_params();
|
||||
*ret = pearl_presets[i]; /* struct copy */
|
||||
@ -171,7 +171,7 @@ static bool game_fetch_preset(int i, char **name, game_params **params)
|
||||
pearl_diffnames[pearl_presets[i].difficulty]);
|
||||
*name = dupstr(buf);
|
||||
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void free_params(game_params *params)
|
||||
@ -206,9 +206,9 @@ static void decode_params(game_params *ret, char const *string)
|
||||
if (*string) string++;
|
||||
}
|
||||
|
||||
ret->nosolve = FALSE;
|
||||
ret->nosolve = false;
|
||||
if (*string == 'n') {
|
||||
ret->nosolve = TRUE;
|
||||
ret->nosolve = true;
|
||||
string++;
|
||||
}
|
||||
}
|
||||
@ -347,7 +347,7 @@ int pearl_solve(int w, int h, char *clues, char *result,
|
||||
* Now repeatedly try to find something we can do.
|
||||
*/
|
||||
while (1) {
|
||||
int done_something = FALSE;
|
||||
int done_something = false;
|
||||
|
||||
#ifdef SOLVER_DIAGNOSTICS
|
||||
for (y = 0; y < H; y++) {
|
||||
@ -383,7 +383,7 @@ int pearl_solve(int w, int h, char *clues, char *result,
|
||||
ex/2, ey/2, (ex+1)/2, (ey+1)/2,
|
||||
b, x, y);
|
||||
#endif
|
||||
done_something = TRUE;
|
||||
done_something = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -437,7 +437,7 @@ int pearl_solve(int w, int h, char *clues, char *result,
|
||||
|
||||
if (!(edgeor & d) && workspace[ey*W+ex] == 3) {
|
||||
workspace[ey*W+ex] = 2;
|
||||
done_something = TRUE;
|
||||
done_something = true;
|
||||
#ifdef SOLVER_DIAGNOSTICS
|
||||
printf("possible states of square (%d,%d) force edge"
|
||||
" (%d,%d)-(%d,%d) to be disconnected\n",
|
||||
@ -445,7 +445,7 @@ int pearl_solve(int w, int h, char *clues, char *result,
|
||||
#endif
|
||||
} else if ((edgeand & d) && workspace[ey*W+ex] == 3) {
|
||||
workspace[ey*W+ex] = 1;
|
||||
done_something = TRUE;
|
||||
done_something = true;
|
||||
#ifdef SOLVER_DIAGNOSTICS
|
||||
printf("possible states of square (%d,%d) force edge"
|
||||
" (%d,%d)-(%d,%d) to be connected\n",
|
||||
@ -483,7 +483,7 @@ int pearl_solve(int w, int h, char *clues, char *result,
|
||||
*/
|
||||
if (workspace[fy*W+fx] != (1<<type)) {
|
||||
workspace[fy*W+fx] = (1<<type);
|
||||
done_something = TRUE;
|
||||
done_something = true;
|
||||
#ifdef SOLVER_DIAGNOSTICS
|
||||
printf("corner clue at (%d,%d) forces square "
|
||||
"(%d,%d) into state %d\n", x, y,
|
||||
@ -501,7 +501,7 @@ int pearl_solve(int w, int h, char *clues, char *result,
|
||||
*/
|
||||
if (!(workspace[fy*W+fx] & (1<<type))) {
|
||||
workspace[ey*W+ex] = 2;
|
||||
done_something = TRUE;
|
||||
done_something = true;
|
||||
#ifdef SOLVER_DIAGNOSTICS
|
||||
printf("corner clue at (%d,%d), plus square "
|
||||
"(%d,%d) not being state %d, "
|
||||
@ -535,7 +535,7 @@ int pearl_solve(int w, int h, char *clues, char *result,
|
||||
!(workspace[gy*W+gx] & ((1<<( d |A(d))) |
|
||||
(1<<( d |C(d)))))) {
|
||||
workspace[(2*y+1)*W+(2*x+1)] &= ~(1<<type);
|
||||
done_something = TRUE;
|
||||
done_something = true;
|
||||
#ifdef SOLVER_DIAGNOSTICS
|
||||
printf("straight clue at (%d,%d) cannot corner at "
|
||||
"(%d,%d) or (%d,%d) so is not state %d\n",
|
||||
@ -561,7 +561,7 @@ int pearl_solve(int w, int h, char *clues, char *result,
|
||||
if (!(workspace[fy*W+fx] &~ (bLR|bUD)) &&
|
||||
(workspace[gy*W+gx] &~ (bLU|bLD|bRU|bRD))) {
|
||||
workspace[gy*W+gx] &= (bLU|bLD|bRU|bRD);
|
||||
done_something = TRUE;
|
||||
done_something = true;
|
||||
#ifdef SOLVER_DIAGNOSTICS
|
||||
printf("straight clue at (%d,%d) connecting to "
|
||||
"straight at (%d,%d) makes (%d,%d) a "
|
||||
@ -743,7 +743,7 @@ int pearl_solve(int w, int h, char *clues, char *result,
|
||||
* Yes! Mark this edge disconnected.
|
||||
*/
|
||||
workspace[y*W+x] = 2;
|
||||
done_something = TRUE;
|
||||
done_something = true;
|
||||
#ifdef SOLVER_DIAGNOSTICS
|
||||
printf("edge (%d,%d)-(%d,%d) would create"
|
||||
" a shortcut loop, hence must be"
|
||||
@ -804,7 +804,7 @@ int pearl_solve(int w, int h, char *clues, char *result,
|
||||
* state invalid.
|
||||
*/
|
||||
workspace[y*W+x] &= ~(1<<b);
|
||||
done_something = TRUE;
|
||||
done_something = true;
|
||||
#ifdef SOLVER_DIAGNOSTICS
|
||||
printf("square (%d,%d) would create a "
|
||||
"shortcut loop in state %d, "
|
||||
@ -1247,7 +1247,7 @@ static int new_clues(const game_params *params, random_state *rs,
|
||||
/*
|
||||
* See if we can solve the puzzle just like this.
|
||||
*/
|
||||
ret = pearl_solve(w, h, clues, grid, diff, FALSE);
|
||||
ret = pearl_solve(w, h, clues, grid, diff, false);
|
||||
assert(ret > 0); /* shouldn't be inconsistent! */
|
||||
if (ret != 1)
|
||||
continue; /* go round and try again */
|
||||
@ -1256,7 +1256,7 @@ static int new_clues(const game_params *params, random_state *rs,
|
||||
* Check this puzzle isn't too easy.
|
||||
*/
|
||||
if (diff > DIFF_EASY) {
|
||||
ret = pearl_solve(w, h, clues, grid, diff-1, FALSE);
|
||||
ret = pearl_solve(w, h, clues, grid, diff-1, false);
|
||||
assert(ret > 0);
|
||||
if (ret == 1)
|
||||
continue; /* too easy: try again */
|
||||
@ -1323,7 +1323,7 @@ static int new_clues(const game_params *params, random_state *rs,
|
||||
clue = clues[y*w+x];
|
||||
clues[y*w+x] = 0; /* try removing this clue */
|
||||
|
||||
ret = pearl_solve(w, h, clues, grid, diff, FALSE);
|
||||
ret = pearl_solve(w, h, clues, grid, diff, false);
|
||||
assert(ret > 0);
|
||||
if (ret != 1)
|
||||
clues[y*w+x] = clue; /* oops, put it back again */
|
||||
@ -1416,7 +1416,7 @@ static game_state *new_game(midend *me, const game_params *params,
|
||||
game_state *state = snew(game_state);
|
||||
int i, j, sz = params->w*params->h;
|
||||
|
||||
state->completed = state->used_solve = FALSE;
|
||||
state->completed = state->used_solve = false;
|
||||
state->shared = snew(struct shared_state);
|
||||
|
||||
state->shared->w = params->w;
|
||||
@ -1511,7 +1511,7 @@ static void dsf_update_completion(game_state *state, int ax, int ay, char dir,
|
||||
static void check_completion(game_state *state, int mark)
|
||||
{
|
||||
int w = state->shared->w, h = state->shared->h, x, y, i, d;
|
||||
int had_error = FALSE;
|
||||
int had_error = false;
|
||||
int *dsf, *component_state;
|
||||
int nsilly, nloop, npath, largest_comp, largest_size, total_pathsize;
|
||||
enum { COMP_NONE, COMP_LOOP, COMP_PATH, COMP_SILLY, COMP_EMPTY };
|
||||
@ -1522,7 +1522,7 @@ static void check_completion(game_state *state, int mark)
|
||||
}
|
||||
}
|
||||
|
||||
#define ERROR(x,y,e) do { had_error = TRUE; if (mark) state->errors[(y)*w+(x)] |= (e); } while(0)
|
||||
#define ERROR(x,y,e) do { had_error = true; if (mark) state->errors[(y)*w+(x)] |= (e); } while(0)
|
||||
|
||||
/*
|
||||
* Analyse the solution into loops, paths and stranger things.
|
||||
@ -1690,7 +1690,7 @@ static void check_completion(game_state *state, int mark)
|
||||
* But if not, then we're done!
|
||||
*/
|
||||
if (!had_error)
|
||||
state->completed = TRUE;
|
||||
state->completed = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1745,11 +1745,11 @@ static char *solve_game(const game_state *state, const game_state *currstate,
|
||||
* solution from there go back to original state. */
|
||||
ret = pearl_solve(currstate->shared->w, currstate->shared->h,
|
||||
currstate->shared->clues, solved->lines,
|
||||
DIFFCOUNT, FALSE);
|
||||
DIFFCOUNT, false);
|
||||
if (ret < 1)
|
||||
ret = pearl_solve(state->shared->w, state->shared->h,
|
||||
state->shared->clues, solved->lines,
|
||||
DIFFCOUNT, FALSE);
|
||||
DIFFCOUNT, false);
|
||||
|
||||
}
|
||||
|
||||
@ -1767,7 +1767,7 @@ done:
|
||||
|
||||
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)
|
||||
@ -1808,7 +1808,7 @@ struct game_ui {
|
||||
int clickx, clicky; /* pixel position of initial click */
|
||||
|
||||
int curx, cury; /* grid position of keyboard cursor */
|
||||
int cursor_active; /* TRUE iff cursor is shown */
|
||||
int cursor_active; /* true iff cursor is shown */
|
||||
};
|
||||
|
||||
static game_ui *new_ui(const game_state *state)
|
||||
@ -1818,7 +1818,7 @@ static game_ui *new_ui(const game_state *state)
|
||||
|
||||
ui->ndragcoords = -1;
|
||||
ui->dragcoords = snewn(sz, int);
|
||||
ui->cursor_active = FALSE;
|
||||
ui->cursor_active = false;
|
||||
ui->curx = ui->cury = 0;
|
||||
|
||||
return ui;
|
||||
@ -1963,7 +1963,7 @@ static void update_ui_drag(const game_state *state, game_ui *ui,
|
||||
*
|
||||
* Call it in a loop, like this:
|
||||
*
|
||||
* int clearing = TRUE;
|
||||
* int clearing = true;
|
||||
* for (i = 0; i < ui->ndragcoords - 1; i++) {
|
||||
* int sx, sy, dx, dy, dir, oldstate, newstate;
|
||||
* interpret_ui_drag(state, ui, &clearing, i, &sx, &sy, &dx, &dy,
|
||||
@ -2003,7 +2003,7 @@ static void interpret_ui_drag(const game_state *state, const game_ui *ui,
|
||||
* the drag are set rather than cleared.
|
||||
*/
|
||||
*newstate = *dir;
|
||||
*clearing = FALSE;
|
||||
*clearing = false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2037,14 +2037,14 @@ static char *interpret_move(const game_state *state, game_ui *ui,
|
||||
{
|
||||
int w = state->shared->w, h = state->shared->h /*, sz = state->shared->sz */;
|
||||
int gx = FROMCOORD(x), gy = FROMCOORD(y), i;
|
||||
int release = FALSE;
|
||||
int release = false;
|
||||
char tmpbuf[80];
|
||||
|
||||
int shift = button & MOD_SHFT, control = button & MOD_CTRL;
|
||||
button &= ~MOD_MASK;
|
||||
|
||||
if (IS_MOUSE_DOWN(button)) {
|
||||
ui->cursor_active = FALSE;
|
||||
ui->cursor_active = false;
|
||||
|
||||
if (!INGRID(state, gx, gy)) {
|
||||
ui->ndragcoords = -1;
|
||||
@ -2063,11 +2063,11 @@ static char *interpret_move(const game_state *state, game_ui *ui,
|
||||
return UI_UPDATE;
|
||||
}
|
||||
|
||||
if (IS_MOUSE_RELEASE(button)) release = TRUE;
|
||||
if (IS_MOUSE_RELEASE(button)) release = true;
|
||||
|
||||
if (IS_CURSOR_MOVE(button)) {
|
||||
if (!ui->cursor_active) {
|
||||
ui->cursor_active = TRUE;
|
||||
ui->cursor_active = true;
|
||||
} else if (control | shift) {
|
||||
char *move;
|
||||
if (ui->ndragcoords > 0) return NULL;
|
||||
@ -2075,10 +2075,10 @@ static char *interpret_move(const game_state *state, game_ui *ui,
|
||||
move = mark_in_direction(state, ui->curx, ui->cury,
|
||||
KEY_DIRECTION(button), control, tmpbuf);
|
||||
if (control && !shift && *move)
|
||||
move_cursor(button, &ui->curx, &ui->cury, w, h, FALSE);
|
||||
move_cursor(button, &ui->curx, &ui->cury, w, h, false);
|
||||
return move;
|
||||
} else {
|
||||
move_cursor(button, &ui->curx, &ui->cury, w, h, FALSE);
|
||||
move_cursor(button, &ui->curx, &ui->cury, w, h, false);
|
||||
if (ui->ndragcoords >= 0)
|
||||
update_ui_drag(state, ui, ui->curx, ui->cury);
|
||||
}
|
||||
@ -2087,7 +2087,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
|
||||
|
||||
if (IS_CURSOR_SELECT(button)) {
|
||||
if (!ui->cursor_active) {
|
||||
ui->cursor_active = TRUE;
|
||||
ui->cursor_active = true;
|
||||
return UI_UPDATE;
|
||||
} else if (button == CURSOR_SELECT) {
|
||||
if (ui->ndragcoords == -1) {
|
||||
@ -2096,7 +2096,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
|
||||
ui->clickx = CENTERED_COORD(ui->curx);
|
||||
ui->clicky = CENTERED_COORD(ui->cury);
|
||||
return UI_UPDATE;
|
||||
} else release = TRUE;
|
||||
} else release = true;
|
||||
} else if (button == CURSOR_SELECT2 && ui->ndragcoords >= 0) {
|
||||
ui->ndragcoords = -1;
|
||||
return UI_UPDATE;
|
||||
@ -2114,7 +2114,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
|
||||
int buflen = 0, bufsize = 256, tmplen;
|
||||
char *buf = NULL;
|
||||
const char *sep = "";
|
||||
int clearing = TRUE;
|
||||
int clearing = true;
|
||||
|
||||
for (i = 0; i < ui->ndragcoords - 1; i++) {
|
||||
int sx, sy, dx, dy, dir, oldstate, newstate;
|
||||
@ -2197,7 +2197,7 @@ static game_state *execute_move(const game_state *state, const char *move)
|
||||
while (*move) {
|
||||
c = *move;
|
||||
if (c == 'S') {
|
||||
ret->used_solve = TRUE;
|
||||
ret->used_solve = true;
|
||||
move++;
|
||||
} else if (c == 'L' || c == 'N' || c == 'R' || c == 'F' || c == 'M') {
|
||||
/* 'line' or 'noline' or 'replace' or 'flip' or 'mark' */
|
||||
@ -2232,7 +2232,7 @@ static game_state *execute_move(const game_state *state, const char *move)
|
||||
move += n;
|
||||
} else if (strcmp(move, "H") == 0) {
|
||||
pearl_solve(ret->shared->w, ret->shared->h,
|
||||
ret->shared->clues, ret->lines, DIFFCOUNT, TRUE);
|
||||
ret->shared->clues, ret->lines, DIFFCOUNT, true);
|
||||
for (n = 0; n < w*h; n++)
|
||||
ret->marks[n] &= ~ret->lines[n]; /* erase marks too */
|
||||
move++;
|
||||
@ -2245,7 +2245,7 @@ static game_state *execute_move(const game_state *state, const char *move)
|
||||
goto badmove;
|
||||
}
|
||||
|
||||
check_completion(ret, TRUE);
|
||||
check_completion(ret, true);
|
||||
|
||||
return ret;
|
||||
|
||||
@ -2317,7 +2317,7 @@ static game_drawstate *game_new_drawstate(drawing *dr, const game_state *state)
|
||||
int i;
|
||||
|
||||
ds->halfsz = 0;
|
||||
ds->started = FALSE;
|
||||
ds->started = false;
|
||||
|
||||
ds->w = state->shared->w;
|
||||
ds->h = state->shared->h;
|
||||
@ -2477,7 +2477,7 @@ static void game_redraw(drawing *dr, game_drawstate *ds,
|
||||
|
||||
draw_update(dr, 0, 0, w*TILE_SIZE + 2*BORDER, h*TILE_SIZE + 2*BORDER);
|
||||
|
||||
ds->started = TRUE;
|
||||
ds->started = true;
|
||||
force = 1;
|
||||
}
|
||||
|
||||
@ -2488,7 +2488,7 @@ static void game_redraw(drawing *dr, game_drawstate *ds,
|
||||
|
||||
memset(ds->draglines, 0, sz);
|
||||
if (ui->ndragcoords > 0) {
|
||||
int i, clearing = TRUE;
|
||||
int i, clearing = true;
|
||||
for (i = 0; i < ui->ndragcoords - 1; i++) {
|
||||
int sx, sy, dx, dy, dir, oldstate, newstate;
|
||||
interpret_ui_drag(state, ui, &clearing, i, &sx, &sy, &dx, &dy,
|
||||
@ -2546,7 +2546,7 @@ static int game_status(const game_state *state)
|
||||
|
||||
static bool game_timing_state(const game_state *state, game_ui *ui)
|
||||
{
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void game_print_size(const game_params *params, float *x, float *y)
|
||||
@ -2608,15 +2608,15 @@ const struct game 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,
|
||||
@ -2633,9 +2633,9 @@ const struct game 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 */
|
||||
};
|
||||
|
||||
@ -2669,7 +2669,7 @@ static void start_soak(game_params *p, random_state *rs, int nsecs)
|
||||
if (nsecs > 0) printf(" for %d seconds", nsecs);
|
||||
printf(".\n");
|
||||
|
||||
p->nosolve = TRUE;
|
||||
p->nosolve = true;
|
||||
|
||||
grid = snewn(p->w*p->h, char);
|
||||
clues = snewn(p->w*p->h, char);
|
||||
@ -2677,7 +2677,7 @@ static void start_soak(game_params *p, random_state *rs, int nsecs)
|
||||
while (1) {
|
||||
n += new_clues(p, rs, clues, grid); /* should be 1, with nosolve */
|
||||
|
||||
ret = pearl_solve(p->w, p->h, clues, grid, DIFF_TRICKY, FALSE);
|
||||
ret = pearl_solve(p->w, p->h, clues, grid, DIFF_TRICKY, false);
|
||||
if (ret <= 0) nimpossible++;
|
||||
if (ret == 1) nsolved++;
|
||||
|
||||
|
Reference in New Issue
Block a user