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:
136
mines.c
136
mines.c
@ -97,19 +97,19 @@ static game_params *default_params(void)
|
||||
|
||||
ret->w = ret->h = 9;
|
||||
ret->n = 10;
|
||||
ret->unique = TRUE;
|
||||
ret->unique = true;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static const struct game_params mines_presets[] = {
|
||||
{9, 9, 10, TRUE},
|
||||
{9, 9, 35, TRUE},
|
||||
{16, 16, 40, TRUE},
|
||||
{16, 16, 99, TRUE},
|
||||
{9, 9, 10, true},
|
||||
{9, 9, 35, true},
|
||||
{16, 16, 40, true},
|
||||
{16, 16, 99, true},
|
||||
#ifndef SMALL_SCREEN
|
||||
{30, 16, 99, TRUE},
|
||||
{30, 16, 170, TRUE},
|
||||
{30, 16, 99, true},
|
||||
{30, 16, 170, true},
|
||||
#endif
|
||||
};
|
||||
|
||||
@ -119,7 +119,7 @@ static bool game_fetch_preset(int i, char **name, game_params **params)
|
||||
char str[80];
|
||||
|
||||
if (i < 0 || i >= lenof(mines_presets))
|
||||
return FALSE;
|
||||
return false;
|
||||
|
||||
ret = snew(game_params);
|
||||
*ret = mines_presets[i];
|
||||
@ -128,7 +128,7 @@ static bool game_fetch_preset(int i, char **name, game_params **params)
|
||||
|
||||
*name = dupstr(str);
|
||||
*params = ret;
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void free_params(game_params *params)
|
||||
@ -167,7 +167,7 @@ static void decode_params(game_params *params, char const *string)
|
||||
while (*p) {
|
||||
if (*p == 'a') {
|
||||
p++;
|
||||
params->unique = FALSE;
|
||||
params->unique = false;
|
||||
} else
|
||||
p++; /* skip any other gunk */
|
||||
}
|
||||
@ -401,7 +401,7 @@ static void ss_add_todo(struct setstore *ss, struct set *s)
|
||||
ss->todo_head = s;
|
||||
ss->todo_tail = s;
|
||||
s->next = NULL;
|
||||
s->todo = TRUE;
|
||||
s->todo = true;
|
||||
}
|
||||
|
||||
static void ss_add(struct setstore *ss, int x, int y, int mask, int mines)
|
||||
@ -427,7 +427,7 @@ static void ss_add(struct setstore *ss, int x, int y, int mask, int mines)
|
||||
s->y = y;
|
||||
s->mask = mask;
|
||||
s->mines = mines;
|
||||
s->todo = FALSE;
|
||||
s->todo = false;
|
||||
if (add234(ss->sets, s) != s) {
|
||||
/*
|
||||
* This set already existed! Free it and return.
|
||||
@ -463,7 +463,7 @@ static void ss_remove(struct setstore *ss, struct set *s)
|
||||
else if (s == ss->todo_tail)
|
||||
ss->todo_tail = prev;
|
||||
|
||||
s->todo = FALSE;
|
||||
s->todo = false;
|
||||
|
||||
/*
|
||||
* Remove s from the tree.
|
||||
@ -507,7 +507,7 @@ static struct set **ss_overlap(struct setstore *ss, int x, int y, int mask)
|
||||
* really overlap, and add it to the list if
|
||||
* so.
|
||||
*/
|
||||
if (setmunge(x, y, mask, s->x, s->y, s->mask, FALSE)) {
|
||||
if (setmunge(x, y, mask, s->x, s->y, s->mask, false)) {
|
||||
/*
|
||||
* There's an overlap.
|
||||
*/
|
||||
@ -542,7 +542,7 @@ static struct set *ss_todo(struct setstore *ss)
|
||||
else
|
||||
ss->todo_tail = NULL;
|
||||
ret->next = ret->prev = NULL;
|
||||
ret->todo = FALSE;
|
||||
ret->todo = false;
|
||||
return ret;
|
||||
} else {
|
||||
return NULL;
|
||||
@ -671,7 +671,7 @@ static int minesolve(int w, int h, int n, signed char *grid,
|
||||
* Main deductive loop.
|
||||
*/
|
||||
while (1) {
|
||||
int done_something = FALSE;
|
||||
int done_something = false;
|
||||
struct set *s;
|
||||
|
||||
/*
|
||||
@ -740,7 +740,7 @@ static int minesolve(int w, int h, int n, signed char *grid,
|
||||
* Compute the mask for this set minus the
|
||||
* newly known square.
|
||||
*/
|
||||
newmask = setmunge(s->x, s->y, s->mask, x, y, 1, TRUE);
|
||||
newmask = setmunge(s->x, s->y, s->mask, x, y, 1, true);
|
||||
|
||||
/*
|
||||
* Compute the new mine count.
|
||||
@ -768,7 +768,7 @@ static int minesolve(int w, int h, int n, signed char *grid,
|
||||
* Marking a fresh square as known certainly counts as
|
||||
* doing something.
|
||||
*/
|
||||
done_something = TRUE;
|
||||
done_something = true;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -825,9 +825,9 @@ static int minesolve(int w, int h, int n, signed char *grid,
|
||||
* s2-s.
|
||||
*/
|
||||
swing = setmunge(s->x, s->y, s->mask, s2->x, s2->y, s2->mask,
|
||||
TRUE);
|
||||
true);
|
||||
s2wing = setmunge(s2->x, s2->y, s2->mask, s->x, s->y, s->mask,
|
||||
TRUE);
|
||||
true);
|
||||
swc = bitcount16(swing);
|
||||
s2wc = bitcount16(s2wing);
|
||||
|
||||
@ -874,7 +874,7 @@ static int minesolve(int w, int h, int n, signed char *grid,
|
||||
* _something_, even if it's only reducing the size of
|
||||
* our to-do list.
|
||||
*/
|
||||
done_something = TRUE;
|
||||
done_something = true;
|
||||
} else if (n >= 0) {
|
||||
/*
|
||||
* We have nothing left on our todo list, which means
|
||||
@ -1015,7 +1015,7 @@ static int minesolve(int w, int h, int n, signed char *grid,
|
||||
while (1) {
|
||||
|
||||
if (cursor < nsets) {
|
||||
int ok = TRUE;
|
||||
int ok = true;
|
||||
|
||||
/* See if any existing set overlaps this one. */
|
||||
for (i = 0; i < cursor; i++)
|
||||
@ -1024,8 +1024,8 @@ static int minesolve(int w, int h, int n, signed char *grid,
|
||||
sets[cursor]->y,
|
||||
sets[cursor]->mask,
|
||||
sets[i]->x, sets[i]->y, sets[i]->mask,
|
||||
FALSE)) {
|
||||
ok = FALSE;
|
||||
false)) {
|
||||
ok = false;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1065,15 +1065,15 @@ static int minesolve(int w, int h, int n, signed char *grid,
|
||||
*/
|
||||
for (i = 0; i < w*h; i++)
|
||||
if (grid[i] == -2) {
|
||||
int outside = TRUE;
|
||||
int outside = true;
|
||||
y = i / w;
|
||||
x = i % w;
|
||||
for (j = 0; j < nsets; j++)
|
||||
if (setused[j] &&
|
||||
setmunge(sets[j]->x, sets[j]->y,
|
||||
sets[j]->mask, x, y, 1,
|
||||
FALSE)) {
|
||||
outside = FALSE;
|
||||
false)) {
|
||||
outside = false;
|
||||
break;
|
||||
}
|
||||
if (outside)
|
||||
@ -1082,7 +1082,7 @@ static int minesolve(int w, int h, int n, signed char *grid,
|
||||
x, y, 1, minesleft != 0);
|
||||
}
|
||||
|
||||
done_something = TRUE;
|
||||
done_something = true;
|
||||
break; /* return to main deductive loop */
|
||||
}
|
||||
|
||||
@ -1728,7 +1728,7 @@ static char *minegen(int w, int h, int n, int x, int y, int unique,
|
||||
int ntries = 0;
|
||||
|
||||
do {
|
||||
success = FALSE;
|
||||
success = false;
|
||||
ntries++;
|
||||
|
||||
memset(ret, 0, w*h);
|
||||
@ -1814,17 +1814,17 @@ static char *minegen(int w, int h, int n, int x, int y, int unique,
|
||||
solveret =
|
||||
minesolve(w, h, n, solvegrid, mineopen, mineperturb, ctx, rs);
|
||||
if (solveret < 0 || (prevret >= 0 && solveret >= prevret)) {
|
||||
success = FALSE;
|
||||
success = false;
|
||||
break;
|
||||
} else if (solveret == 0) {
|
||||
success = TRUE;
|
||||
success = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
sfree(solvegrid);
|
||||
} else {
|
||||
success = TRUE;
|
||||
success = true;
|
||||
}
|
||||
|
||||
} while (!success);
|
||||
@ -1849,7 +1849,7 @@ static char *describe_layout(char *grid, int area, int x, int y,
|
||||
bmp[i / 8] |= 0x80 >> (i % 8);
|
||||
}
|
||||
if (obfuscate)
|
||||
obfuscate_bitmap(bmp, area, FALSE);
|
||||
obfuscate_bitmap(bmp, area, false);
|
||||
|
||||
/*
|
||||
* Now encode the resulting bitmap in hex. We can work to
|
||||
@ -1879,7 +1879,7 @@ static char *new_mine_layout(int w, int h, int n, int x, int y, int unique,
|
||||
char *grid;
|
||||
|
||||
#ifdef TEST_OBFUSCATION
|
||||
static int tested_obfuscation = FALSE;
|
||||
static int tested_obfuscation = false;
|
||||
if (!tested_obfuscation) {
|
||||
/*
|
||||
* A few simple test vectors for the obfuscator.
|
||||
@ -1895,10 +1895,10 @@ static char *new_mine_layout(int w, int h, int n, int x, int y, int unique,
|
||||
*/
|
||||
{
|
||||
unsigned char bmp1[] = "\x12\x34\x56\x70";
|
||||
obfuscate_bitmap(bmp1, 28, FALSE);
|
||||
obfuscate_bitmap(bmp1, 28, false);
|
||||
printf("test 1 encode: %s\n",
|
||||
memcmp(bmp1, "\x07\xfa\x65\x00", 4) ? "failed" : "passed");
|
||||
obfuscate_bitmap(bmp1, 28, TRUE);
|
||||
obfuscate_bitmap(bmp1, 28, true);
|
||||
printf("test 1 decode: %s\n",
|
||||
memcmp(bmp1, "\x12\x34\x56\x70", 4) ? "failed" : "passed");
|
||||
}
|
||||
@ -1912,7 +1912,7 @@ static char *new_mine_layout(int w, int h, int n, int x, int y, int unique,
|
||||
unsigned char bmp2a[50];
|
||||
memset(bmp2, 0, 50);
|
||||
memset(bmp2a, 0, 50);
|
||||
obfuscate_bitmap(bmp2, 50 * 8, FALSE);
|
||||
obfuscate_bitmap(bmp2, 50 * 8, false);
|
||||
/*
|
||||
* SHA of twenty-five zero bytes plus "0" is
|
||||
* b202c07b990c01f6ff2d544707f60e506019b671. SHA of
|
||||
@ -1934,7 +1934,7 @@ static char *new_mine_layout(int w, int h, int n, int x, int y, int unique,
|
||||
"\xb5\xa2\x10\xb0\xaf\x91\x3d\xb8\x5d\x37\xca\x27"
|
||||
"\xf5\x2a\x9f\x78\xbb\xa3\xa8\x00\x30\xdb\x3d\x01"
|
||||
"\xd8\xdf\x78", 50) ? "failed" : "passed");
|
||||
obfuscate_bitmap(bmp2, 50 * 8, TRUE);
|
||||
obfuscate_bitmap(bmp2, 50 * 8, true);
|
||||
printf("test 2 decode: %s\n",
|
||||
memcmp(bmp2, bmp2a, 50) ? "failed" : "passed");
|
||||
}
|
||||
@ -1944,7 +1944,7 @@ static char *new_mine_layout(int w, int h, int n, int x, int y, int unique,
|
||||
grid = minegen(w, h, n, x, y, unique, rs);
|
||||
|
||||
if (game_desc)
|
||||
*game_desc = describe_layout(grid, w * h, x, y, TRUE);
|
||||
*game_desc = describe_layout(grid, w * h, x, y, true);
|
||||
|
||||
return grid;
|
||||
}
|
||||
@ -2079,7 +2079,7 @@ static int open_square(game_state *state, int x, int y)
|
||||
* mine that killed them, but not the rest (in case they
|
||||
* want to Undo and carry on playing).
|
||||
*/
|
||||
state->dead = TRUE;
|
||||
state->dead = true;
|
||||
state->grid[y*w+x] = 65;
|
||||
return -1;
|
||||
}
|
||||
@ -2099,7 +2099,7 @@ static int open_square(game_state *state, int x, int y)
|
||||
* using repeated N^2 scans of the grid.
|
||||
*/
|
||||
while (1) {
|
||||
int done_something = FALSE;
|
||||
int done_something = false;
|
||||
|
||||
for (yy = 0; yy < h; yy++)
|
||||
for (xx = 0; xx < w; xx++)
|
||||
@ -2128,7 +2128,7 @@ static int open_square(game_state *state, int x, int y)
|
||||
state->grid[(yy+dy)*w+(xx+dx)] = -10;
|
||||
}
|
||||
|
||||
done_something = TRUE;
|
||||
done_something = true;
|
||||
}
|
||||
|
||||
if (!done_something)
|
||||
@ -2155,7 +2155,7 @@ static int open_square(game_state *state, int x, int y)
|
||||
if (state->grid[yy*w+xx] < 0)
|
||||
state->grid[yy*w+xx] = -1;
|
||||
}
|
||||
state->won = TRUE;
|
||||
state->won = true;
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -2171,8 +2171,8 @@ static game_state *new_game(midend *me, const game_params *params,
|
||||
state->w = params->w;
|
||||
state->h = params->h;
|
||||
state->n = params->n;
|
||||
state->dead = state->won = FALSE;
|
||||
state->used_solve = FALSE;
|
||||
state->dead = state->won = false;
|
||||
state->used_solve = false;
|
||||
|
||||
wh = state->w * state->h;
|
||||
|
||||
@ -2190,9 +2190,9 @@ static game_state *new_game(midend *me, const game_params *params,
|
||||
desc++; /* skip over mine count */
|
||||
if (*desc) desc++; /* eat comma */
|
||||
if (*desc == 'a')
|
||||
state->layout->unique = FALSE;
|
||||
state->layout->unique = false;
|
||||
else
|
||||
state->layout->unique = TRUE;
|
||||
state->layout->unique = true;
|
||||
desc++;
|
||||
if (*desc) desc++; /* eat comma */
|
||||
|
||||
@ -2219,7 +2219,7 @@ static game_state *new_game(midend *me, const game_params *params,
|
||||
}
|
||||
|
||||
if (*desc == 'm') {
|
||||
masked = TRUE;
|
||||
masked = true;
|
||||
desc++;
|
||||
} else {
|
||||
if (*desc == 'u')
|
||||
@ -2228,7 +2228,7 @@ static game_state *new_game(midend *me, const game_params *params,
|
||||
* We permit game IDs to be entered by hand without the
|
||||
* masking transformation.
|
||||
*/
|
||||
masked = FALSE;
|
||||
masked = false;
|
||||
}
|
||||
|
||||
bmp = snewn((wh + 7) / 8, unsigned char);
|
||||
@ -2251,7 +2251,7 @@ static game_state *new_game(midend *me, const game_params *params,
|
||||
}
|
||||
|
||||
if (masked)
|
||||
obfuscate_bitmap(bmp, wh, TRUE);
|
||||
obfuscate_bitmap(bmp, wh, true);
|
||||
|
||||
memset(state->layout->mines, 0, wh);
|
||||
for (i = 0; i < wh; i++) {
|
||||
@ -2310,7 +2310,7 @@ static char *solve_game(const game_state *state, const game_state *currstate,
|
||||
|
||||
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)
|
||||
@ -2355,8 +2355,8 @@ static game_ui *new_ui(const game_state *state)
|
||||
ui->hx = ui->hy = -1;
|
||||
ui->hradius = ui->validradius = 0;
|
||||
ui->deaths = 0;
|
||||
ui->completed = FALSE;
|
||||
ui->flash_is_death = FALSE; /* *shrug* */
|
||||
ui->completed = false;
|
||||
ui->flash_is_death = false; /* *shrug* */
|
||||
ui->cur_x = ui->cur_y = ui->cur_visible = 0;
|
||||
return ui;
|
||||
}
|
||||
@ -2384,14 +2384,14 @@ static void decode_ui(game_ui *ui, const char *encoding)
|
||||
int p= 0;
|
||||
sscanf(encoding, "D%d%n", &ui->deaths, &p);
|
||||
if (encoding[p] == 'C')
|
||||
ui->completed = TRUE;
|
||||
ui->completed = true;
|
||||
}
|
||||
|
||||
static void game_changed_state(game_ui *ui, const game_state *oldstate,
|
||||
const game_state *newstate)
|
||||
{
|
||||
if (newstate->won)
|
||||
ui->completed = TRUE;
|
||||
ui->completed = true;
|
||||
}
|
||||
|
||||
struct game_drawstate {
|
||||
@ -2643,7 +2643,7 @@ static game_state *execute_move(const game_state *from, const char *move)
|
||||
}
|
||||
}
|
||||
}
|
||||
ret->used_solve = TRUE;
|
||||
ret->used_solve = true;
|
||||
|
||||
return ret;
|
||||
} else {
|
||||
@ -2797,7 +2797,7 @@ static game_drawstate *game_new_drawstate(drawing *dr, const game_state *state)
|
||||
|
||||
ds->w = state->w;
|
||||
ds->h = state->h;
|
||||
ds->started = FALSE;
|
||||
ds->started = false;
|
||||
ds->tilesize = 0; /* not decided yet */
|
||||
ds->grid = snewn(ds->w * ds->h, signed char);
|
||||
ds->bg = -1;
|
||||
@ -2996,7 +2996,7 @@ static void game_redraw(drawing *dr, game_drawstate *ds,
|
||||
coords[0] = COORD(0) - OUTER_HIGHLIGHT_WIDTH;
|
||||
draw_polygon(dr, coords, 5, COL_LOWLIGHT, COL_LOWLIGHT);
|
||||
|
||||
ds->started = TRUE;
|
||||
ds->started = true;
|
||||
}
|
||||
|
||||
if (ui->cur_visible) cx = ui->cur_x;
|
||||
@ -3130,11 +3130,11 @@ static float game_flash_length(const game_state *oldstate,
|
||||
|
||||
if (dir > 0 && !oldstate->dead && !oldstate->won) {
|
||||
if (newstate->dead) {
|
||||
ui->flash_is_death = TRUE;
|
||||
ui->flash_is_death = true;
|
||||
return 3 * FLASH_FRAME;
|
||||
}
|
||||
if (newstate->won) {
|
||||
ui->flash_is_death = FALSE;
|
||||
ui->flash_is_death = false;
|
||||
return 2 * FLASH_FRAME;
|
||||
}
|
||||
}
|
||||
@ -3154,8 +3154,8 @@ static int game_status(const game_state *state)
|
||||
static bool game_timing_state(const game_state *state, game_ui *ui)
|
||||
{
|
||||
if (state->dead || state->won || ui->completed || !state->layout->mines)
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void game_print_size(const game_params *params, float *x, float *y)
|
||||
@ -3178,15 +3178,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,
|
||||
@ -3203,9 +3203,9 @@ const struct game thegame = {
|
||||
game_anim_length,
|
||||
game_flash_length,
|
||||
game_status,
|
||||
FALSE, FALSE, game_print_size, game_print,
|
||||
TRUE, /* wants_statusbar */
|
||||
TRUE, game_timing_state,
|
||||
false, false, game_print_size, game_print,
|
||||
true, /* wants_statusbar */
|
||||
true, game_timing_state,
|
||||
BUTTON_BEATS(LEFT_BUTTON, RIGHT_BUTTON) | REQUIRE_RBUTTON,
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user