mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-21 08:01:30 -07:00
Patch from James H providing lots more paranoid casting. Also one
actual behaviour change: Untangle now permits dragging with the right mouse button, which has exactly the same effect as it does with the left. (Harmless on desktop platforms, but helpful when "right-click" is achieved by press-and-hold; now the drag takes place even if you hesitate first.) [originally from svn r8177]
This commit is contained in:
9
cube.c
9
cube.c
@ -1115,8 +1115,8 @@ static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
|
|||||||
int cx, cy;
|
int cx, cy;
|
||||||
double angle;
|
double angle;
|
||||||
|
|
||||||
cx = state->squares[state->current].x * GRID_SCALE + ds->ox;
|
cx = (int)(state->squares[state->current].x * GRID_SCALE) + ds->ox;
|
||||||
cy = state->squares[state->current].y * GRID_SCALE + ds->oy;
|
cy = (int)(state->squares[state->current].y * GRID_SCALE) + ds->oy;
|
||||||
|
|
||||||
if (x == cx && y == cy)
|
if (x == cx && y == cy)
|
||||||
return NULL; /* clicked in exact centre! */
|
return NULL; /* clicked in exact centre! */
|
||||||
@ -1476,7 +1476,7 @@ static void game_set_size(drawing *dr, game_drawstate *ds,
|
|||||||
{
|
{
|
||||||
struct bbox bb = find_bbox(params);
|
struct bbox bb = find_bbox(params);
|
||||||
|
|
||||||
ds->gridscale = tilesize;
|
ds->gridscale = (float)tilesize;
|
||||||
ds->ox = (int)(-(bb.l - solids[params->solid]->border) * ds->gridscale);
|
ds->ox = (int)(-(bb.l - solids[params->solid]->border) * ds->gridscale);
|
||||||
ds->oy = (int)(-(bb.u - solids[params->solid]->border) * ds->gridscale);
|
ds->oy = (int)(-(bb.u - solids[params->solid]->border) * ds->gridscale);
|
||||||
}
|
}
|
||||||
@ -1503,7 +1503,8 @@ static game_drawstate *game_new_drawstate(drawing *dr, game_state *state)
|
|||||||
{
|
{
|
||||||
struct game_drawstate *ds = snew(struct game_drawstate);
|
struct game_drawstate *ds = snew(struct game_drawstate);
|
||||||
|
|
||||||
ds->ox = ds->oy = ds->gridscale = 0.0F;/* not decided yet */
|
ds->ox = ds->oy = 0;
|
||||||
|
ds->gridscale = 0.0F; /* not decided yet */
|
||||||
|
|
||||||
return ds;
|
return ds;
|
||||||
}
|
}
|
||||||
|
@ -281,5 +281,5 @@ void print_line_width(drawing *dr, int width)
|
|||||||
* _square root_ of the main puzzle scale. Double the puzzle
|
* _square root_ of the main puzzle scale. Double the puzzle
|
||||||
* size, and the line width multiplies by 1.4.
|
* size, and the line width multiplies by 1.4.
|
||||||
*/
|
*/
|
||||||
dr->api->line_width(dr->handle, sqrt(dr->scale) * width);
|
dr->api->line_width(dr->handle, (float)sqrt(dr->scale) * width);
|
||||||
}
|
}
|
||||||
|
10
flip.c
10
flip.c
@ -1099,12 +1099,12 @@ static void draw_tile(drawing *dr, game_drawstate *ds,
|
|||||||
|
|
||||||
coords[0] = bx + TILE_SIZE;
|
coords[0] = bx + TILE_SIZE;
|
||||||
coords[1] = by;
|
coords[1] = by;
|
||||||
coords[2] = bx + TILE_SIZE * animtime;
|
coords[2] = bx + (int)((float)TILE_SIZE * animtime);
|
||||||
coords[3] = by + TILE_SIZE * animtime;
|
coords[3] = by + (int)((float)TILE_SIZE * animtime);
|
||||||
coords[4] = bx;
|
coords[4] = bx;
|
||||||
coords[5] = by + TILE_SIZE;
|
coords[5] = by + TILE_SIZE;
|
||||||
coords[6] = bx + TILE_SIZE - TILE_SIZE * animtime;
|
coords[6] = bx + TILE_SIZE - (int)((float)TILE_SIZE * animtime);
|
||||||
coords[7] = by + TILE_SIZE - TILE_SIZE * animtime;
|
coords[7] = by + TILE_SIZE - (int)((float)TILE_SIZE * animtime);
|
||||||
|
|
||||||
colour = (tile & 1 ? COL_WRONG : COL_RIGHT);
|
colour = (tile & 1 ? COL_WRONG : COL_RIGHT);
|
||||||
if (animtime < 0.5)
|
if (animtime < 0.5)
|
||||||
@ -1185,7 +1185,7 @@ static void game_redraw(drawing *dr, game_drawstate *ds, game_state *oldstate,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (flashtime)
|
if (flashtime)
|
||||||
flashframe = flashtime / FLASH_FRAME;
|
flashframe = (int)(flashtime / FLASH_FRAME);
|
||||||
else
|
else
|
||||||
flashframe = -1;
|
flashframe = -1;
|
||||||
|
|
||||||
|
6
guess.c
6
guess.c
@ -992,9 +992,9 @@ static float *game_colours(frontend *fe, int *ncolours)
|
|||||||
|
|
||||||
/* We also want to be able to tell the difference between BACKGROUND
|
/* We also want to be able to tell the difference between BACKGROUND
|
||||||
* and EMPTY, for similar distinguishing-hint reasons. */
|
* and EMPTY, for similar distinguishing-hint reasons. */
|
||||||
ret[COL_EMPTY * 3 + 0] = ret[COL_BACKGROUND * 3 + 0] * 2.0 / 3.0;
|
ret[COL_EMPTY * 3 + 0] = ret[COL_BACKGROUND * 3 + 0] * 2.0F / 3.0F;
|
||||||
ret[COL_EMPTY * 3 + 1] = ret[COL_BACKGROUND * 3 + 1] * 2.0 / 3.0;
|
ret[COL_EMPTY * 3 + 1] = ret[COL_BACKGROUND * 3 + 1] * 2.0F / 3.0F;
|
||||||
ret[COL_EMPTY * 3 + 2] = ret[COL_BACKGROUND * 3 + 2] * 2.0 / 3.0;
|
ret[COL_EMPTY * 3 + 2] = ret[COL_BACKGROUND * 3 + 2] * 2.0F / 3.0F;
|
||||||
|
|
||||||
*ncolours = NCOLOURS;
|
*ncolours = NCOLOURS;
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -2171,8 +2171,8 @@ static void game_print_size(game_params *params, float *x, float *y)
|
|||||||
* I'll use 6mm squares by default.
|
* I'll use 6mm squares by default.
|
||||||
*/
|
*/
|
||||||
game_compute_size(params, 600, &pw, &ph);
|
game_compute_size(params, 600, &pw, &ph);
|
||||||
*x = pw / 100.0;
|
*x = pw / 100.0F;
|
||||||
*y = ph / 100.0;
|
*y = ph / 100.0F;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void game_print(drawing *dr, game_state *state, int tilesize)
|
static void game_print(drawing *dr, game_state *state, int tilesize)
|
||||||
|
14
midend.c
14
midend.c
@ -335,9 +335,9 @@ void midend_new_game(midend *me)
|
|||||||
char newseed[16];
|
char newseed[16];
|
||||||
int i;
|
int i;
|
||||||
newseed[15] = '\0';
|
newseed[15] = '\0';
|
||||||
newseed[0] = '1' + random_upto(me->random, 9);
|
newseed[0] = '1' + (char)random_upto(me->random, 9);
|
||||||
for (i = 1; i < 15; i++)
|
for (i = 1; i < 15; i++)
|
||||||
newseed[i] = '0' + random_upto(me->random, 10);
|
newseed[i] = '0' + (char)random_upto(me->random, 10);
|
||||||
sfree(me->seedstr);
|
sfree(me->seedstr);
|
||||||
me->seedstr = dupstr(newseed);
|
me->seedstr = dupstr(newseed);
|
||||||
|
|
||||||
@ -832,9 +832,9 @@ float *midend_colours(midend *me, int *ncolours)
|
|||||||
buf[k] = '\0';
|
buf[k] = '\0';
|
||||||
if ((e = getenv(buf)) != NULL &&
|
if ((e = getenv(buf)) != NULL &&
|
||||||
sscanf(e, "%2x%2x%2x", &r, &g, &b) == 3) {
|
sscanf(e, "%2x%2x%2x", &r, &g, &b) == 3) {
|
||||||
ret[i*3 + 0] = r / 255.0;
|
ret[i*3 + 0] = r / 255.0F;
|
||||||
ret[i*3 + 1] = g / 255.0;
|
ret[i*3 + 1] = g / 255.0F;
|
||||||
ret[i*3 + 2] = b / 255.0;
|
ret[i*3 + 2] = b / 255.0F;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1304,7 +1304,7 @@ char *midend_rewrite_statusbar(midend *me, char *text)
|
|||||||
char timebuf[100], *ret;
|
char timebuf[100], *ret;
|
||||||
int min, sec;
|
int min, sec;
|
||||||
|
|
||||||
sec = me->elapsed;
|
sec = (int)me->elapsed;
|
||||||
min = sec / 60;
|
min = sec / 60;
|
||||||
sec %= 60;
|
sec %= 60;
|
||||||
sprintf(timebuf, "[%d:%02d] ", min, sec);
|
sprintf(timebuf, "[%d:%02d] ", min, sec);
|
||||||
@ -1608,7 +1608,7 @@ char *midend_deserialise(midend *me,
|
|||||||
uistr = val;
|
uistr = val;
|
||||||
val = NULL;
|
val = NULL;
|
||||||
} else if (!strcmp(key, "TIME")) {
|
} else if (!strcmp(key, "TIME")) {
|
||||||
elapsed = atof(val);
|
elapsed = (float)atof(val);
|
||||||
} else if (!strcmp(key, "NSTATES")) {
|
} else if (!strcmp(key, "NSTATES")) {
|
||||||
nstates = atoi(val);
|
nstates = atoi(val);
|
||||||
if (nstates <= 0) {
|
if (nstates <= 0) {
|
||||||
|
6
net.c
6
net.c
@ -232,7 +232,7 @@ static void decode_params(game_params *ret, char const *string)
|
|||||||
ret->wrapping = TRUE;
|
ret->wrapping = TRUE;
|
||||||
} else if (*p == 'b') {
|
} else if (*p == 'b') {
|
||||||
p++;
|
p++;
|
||||||
ret->barrier_probability = atof(p);
|
ret->barrier_probability = (float)atof(p);
|
||||||
while (*p && (*p == '.' || isdigit((unsigned char)*p))) p++;
|
while (*p && (*p == '.' || isdigit((unsigned char)*p))) p++;
|
||||||
} else if (*p == 'a') {
|
} else if (*p == 'a') {
|
||||||
p++;
|
p++;
|
||||||
@ -2863,8 +2863,8 @@ static void game_print_size(game_params *params, float *x, float *y)
|
|||||||
* I'll use 8mm squares by default.
|
* I'll use 8mm squares by default.
|
||||||
*/
|
*/
|
||||||
game_compute_size(params, 800, &pw, &ph);
|
game_compute_size(params, 800, &pw, &ph);
|
||||||
*x = pw / 100.0;
|
*x = pw / 100.0F;
|
||||||
*y = ph / 100.0;
|
*y = ph / 100.0F;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void draw_diagram(drawing *dr, game_drawstate *ds, int x, int y,
|
static void draw_diagram(drawing *dr, game_drawstate *ds, int x, int y,
|
||||||
|
@ -1126,7 +1126,7 @@ static char *sel_movedesc(game_ui *ui, game_state *state)
|
|||||||
if (ui->tiles[i] & TILE_SELECTED) {
|
if (ui->tiles[i] & TILE_SELECTED) {
|
||||||
sprintf(buf, "%s%d", sep, i);
|
sprintf(buf, "%s%d", sep, i);
|
||||||
sep = ",";
|
sep = ",";
|
||||||
if (retlen + strlen(buf) >= retsize) {
|
if (retlen + (int)strlen(buf) >= retsize) {
|
||||||
retsize = retlen + strlen(buf) + 256;
|
retsize = retlen + strlen(buf) + 256;
|
||||||
ret = sresize(ret, retsize, char);
|
ret = sresize(ret, retsize, char);
|
||||||
}
|
}
|
||||||
@ -1419,9 +1419,9 @@ static float *game_colours(frontend *fe, int *ncolours)
|
|||||||
ret[COL_HIGHLIGHT * 3 + 1] = 1.0F;
|
ret[COL_HIGHLIGHT * 3 + 1] = 1.0F;
|
||||||
ret[COL_HIGHLIGHT * 3 + 2] = 1.0F;
|
ret[COL_HIGHLIGHT * 3 + 2] = 1.0F;
|
||||||
|
|
||||||
ret[COL_LOWLIGHT * 3 + 0] = ret[COL_BACKGROUND * 3 + 0] * 2.0 / 3.0;
|
ret[COL_LOWLIGHT * 3 + 0] = ret[COL_BACKGROUND * 3 + 0] * 2.0F / 3.0F;
|
||||||
ret[COL_LOWLIGHT * 3 + 1] = ret[COL_BACKGROUND * 3 + 1] * 2.0 / 3.0;
|
ret[COL_LOWLIGHT * 3 + 1] = ret[COL_BACKGROUND * 3 + 1] * 2.0F / 3.0F;
|
||||||
ret[COL_LOWLIGHT * 3 + 2] = ret[COL_BACKGROUND * 3 + 2] * 2.0 / 3.0;
|
ret[COL_LOWLIGHT * 3 + 2] = ret[COL_BACKGROUND * 3 + 2] * 2.0F / 3.0F;
|
||||||
|
|
||||||
*ncolours = NCOLOURS;
|
*ncolours = NCOLOURS;
|
||||||
return ret;
|
return ret;
|
||||||
|
14
untangle.c
14
untangle.c
@ -1000,8 +1000,8 @@ static char *solve_game(game_state *state, game_state *currstate,
|
|||||||
pts[i].d = 2;
|
pts[i].d = 2;
|
||||||
ox *= pts[i].d;
|
ox *= pts[i].d;
|
||||||
oy *= pts[i].d;
|
oy *= pts[i].d;
|
||||||
pts[i].x = ox + 0.5;
|
pts[i].x = (long)(ox + 0.5F);
|
||||||
pts[i].y = oy + 0.5;
|
pts[i].y = (long)(oy + 0.5F);
|
||||||
|
|
||||||
extra = sprintf(buf, ";P%d:%ld,%ld/%ld", i,
|
extra = sprintf(buf, ";P%d:%ld,%ld/%ld", i,
|
||||||
pts[i].x, pts[i].y, pts[i].d);
|
pts[i].x, pts[i].y, pts[i].d);
|
||||||
@ -1077,7 +1077,7 @@ static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
|
|||||||
{
|
{
|
||||||
int n = state->params.n;
|
int n = state->params.n;
|
||||||
|
|
||||||
if (button == LEFT_BUTTON) {
|
if (IS_MOUSE_DOWN(button)) {
|
||||||
int i, best;
|
int i, best;
|
||||||
long bestd;
|
long bestd;
|
||||||
|
|
||||||
@ -1111,12 +1111,12 @@ static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (button == LEFT_DRAG && ui->dragpoint >= 0) {
|
} else if (IS_MOUSE_DRAG(button) && ui->dragpoint >= 0) {
|
||||||
ui->newpoint.x = x;
|
ui->newpoint.x = x;
|
||||||
ui->newpoint.y = y;
|
ui->newpoint.y = y;
|
||||||
ui->newpoint.d = ds->tilesize;
|
ui->newpoint.d = ds->tilesize;
|
||||||
return "";
|
return "";
|
||||||
} else if (button == LEFT_RELEASE && ui->dragpoint >= 0) {
|
} else if (IS_MOUSE_RELEASE(button) && ui->dragpoint >= 0) {
|
||||||
int p = ui->dragpoint;
|
int p = ui->dragpoint;
|
||||||
char buf[80];
|
char buf[80];
|
||||||
|
|
||||||
@ -1268,8 +1268,8 @@ static point mix(point a, point b, float distance)
|
|||||||
point ret;
|
point ret;
|
||||||
|
|
||||||
ret.d = a.d * b.d;
|
ret.d = a.d * b.d;
|
||||||
ret.x = a.x * b.d + distance * (b.x * a.d - a.x * b.d);
|
ret.x = (long)(a.x * b.d + distance * (b.x * a.d - a.x * b.d));
|
||||||
ret.y = a.y * b.d + distance * (b.y * a.d - a.y * b.d);
|
ret.y = (long)(a.y * b.d + distance * (b.y * a.d - a.y * b.d));
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user