diff options
| author | Simon Tatham <anakin@pobox.com> | 2008-09-13 18:29:20 +0000 |
|---|---|---|
| committer | Simon Tatham <anakin@pobox.com> | 2008-09-13 18:29:20 +0000 |
| commit | 1d661ec46b8d7216bc6f2e34a4d6b9cc9fdc6f96 (patch) | |
| tree | 7d148a3d1d265a36957636faa3b5e7aba92bd1f9 | |
| parent | 5ead207060a3e1f74ad6200fdf02934457394bc2 (diff) | |
| download | puzzles-1d661ec46b8d7216bc6f2e34a4d6b9cc9fdc6f96.zip puzzles-1d661ec46b8d7216bc6f2e34a4d6b9cc9fdc6f96.tar.gz puzzles-1d661ec46b8d7216bc6f2e34a4d6b9cc9fdc6f96.tar.bz2 puzzles-1d661ec46b8d7216bc6f2e34a4d6b9cc9fdc6f96.tar.xz | |
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]
| -rw-r--r-- | cube.c | 9 | ||||
| -rw-r--r-- | drawing.c | 2 | ||||
| -rw-r--r-- | flip.c | 10 | ||||
| -rw-r--r-- | guess.c | 6 | ||||
| -rw-r--r-- | lightup.c | 4 | ||||
| -rw-r--r-- | midend.c | 14 | ||||
| -rw-r--r-- | net.c | 6 | ||||
| -rw-r--r-- | samegame.c | 8 | ||||
| -rw-r--r-- | untangle.c | 14 |
9 files changed, 37 insertions, 36 deletions
@@ -1115,8 +1115,8 @@ static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds, int cx, cy; double angle; - cx = state->squares[state->current].x * GRID_SCALE + ds->ox; - cy = state->squares[state->current].y * GRID_SCALE + ds->oy; + cx = (int)(state->squares[state->current].x * GRID_SCALE) + ds->ox; + cy = (int)(state->squares[state->current].y * GRID_SCALE) + ds->oy; if (x == cx && y == cy) 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); - ds->gridscale = tilesize; + ds->gridscale = (float)tilesize; ds->ox = (int)(-(bb.l - 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); - 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; } @@ -281,5 +281,5 @@ void print_line_width(drawing *dr, int width) * _square root_ of the main puzzle scale. Double the puzzle * 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); } @@ -1099,12 +1099,12 @@ static void draw_tile(drawing *dr, game_drawstate *ds, coords[0] = bx + TILE_SIZE; coords[1] = by; - coords[2] = bx + TILE_SIZE * animtime; - coords[3] = by + TILE_SIZE * animtime; + coords[2] = bx + (int)((float)TILE_SIZE * animtime); + coords[3] = by + (int)((float)TILE_SIZE * animtime); coords[4] = bx; coords[5] = by + TILE_SIZE; - coords[6] = bx + TILE_SIZE - TILE_SIZE * animtime; - coords[7] = by + TILE_SIZE - TILE_SIZE * animtime; + coords[6] = bx + TILE_SIZE - (int)((float)TILE_SIZE * animtime); + coords[7] = by + TILE_SIZE - (int)((float)TILE_SIZE * animtime); colour = (tile & 1 ? COL_WRONG : COL_RIGHT); if (animtime < 0.5) @@ -1185,7 +1185,7 @@ static void game_redraw(drawing *dr, game_drawstate *ds, game_state *oldstate, } if (flashtime) - flashframe = flashtime / FLASH_FRAME; + flashframe = (int)(flashtime / FLASH_FRAME); else flashframe = -1; @@ -992,9 +992,9 @@ static float *game_colours(frontend *fe, int *ncolours) /* We also want to be able to tell the difference between BACKGROUND * 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 + 1] = ret[COL_BACKGROUND * 3 + 1] * 2.0 / 3.0; - ret[COL_EMPTY * 3 + 2] = ret[COL_BACKGROUND * 3 + 2] * 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.0F / 3.0F; + ret[COL_EMPTY * 3 + 2] = ret[COL_BACKGROUND * 3 + 2] * 2.0F / 3.0F; *ncolours = NCOLOURS; 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. */ game_compute_size(params, 600, &pw, &ph); - *x = pw / 100.0; - *y = ph / 100.0; + *x = pw / 100.0F; + *y = ph / 100.0F; } static void game_print(drawing *dr, game_state *state, int tilesize) @@ -335,9 +335,9 @@ void midend_new_game(midend *me) char newseed[16]; int i; 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++) - newseed[i] = '0' + random_upto(me->random, 10); + newseed[i] = '0' + (char)random_upto(me->random, 10); sfree(me->seedstr); me->seedstr = dupstr(newseed); @@ -832,9 +832,9 @@ float *midend_colours(midend *me, int *ncolours) buf[k] = '\0'; if ((e = getenv(buf)) != NULL && sscanf(e, "%2x%2x%2x", &r, &g, &b) == 3) { - ret[i*3 + 0] = r / 255.0; - ret[i*3 + 1] = g / 255.0; - ret[i*3 + 2] = b / 255.0; + ret[i*3 + 0] = r / 255.0F; + ret[i*3 + 1] = g / 255.0F; + ret[i*3 + 2] = b / 255.0F; } } } @@ -1304,7 +1304,7 @@ char *midend_rewrite_statusbar(midend *me, char *text) char timebuf[100], *ret; int min, sec; - sec = me->elapsed; + sec = (int)me->elapsed; min = sec / 60; sec %= 60; sprintf(timebuf, "[%d:%02d] ", min, sec); @@ -1608,7 +1608,7 @@ char *midend_deserialise(midend *me, uistr = val; val = NULL; } else if (!strcmp(key, "TIME")) { - elapsed = atof(val); + elapsed = (float)atof(val); } else if (!strcmp(key, "NSTATES")) { nstates = atoi(val); if (nstates <= 0) { @@ -232,7 +232,7 @@ static void decode_params(game_params *ret, char const *string) ret->wrapping = TRUE; } else if (*p == 'b') { p++; - ret->barrier_probability = atof(p); + ret->barrier_probability = (float)atof(p); while (*p && (*p == '.' || isdigit((unsigned char)*p))) p++; } else if (*p == 'a') { p++; @@ -2863,8 +2863,8 @@ static void game_print_size(game_params *params, float *x, float *y) * I'll use 8mm squares by default. */ game_compute_size(params, 800, &pw, &ph); - *x = pw / 100.0; - *y = ph / 100.0; + *x = pw / 100.0F; + *y = ph / 100.0F; } 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) { sprintf(buf, "%s%d", sep, i); sep = ","; - if (retlen + strlen(buf) >= retsize) { + if (retlen + (int)strlen(buf) >= retsize) { retsize = retlen + strlen(buf) + 256; 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 + 2] = 1.0F; - ret[COL_LOWLIGHT * 3 + 0] = ret[COL_BACKGROUND * 3 + 0] * 2.0 / 3.0; - ret[COL_LOWLIGHT * 3 + 1] = ret[COL_BACKGROUND * 3 + 1] * 2.0 / 3.0; - ret[COL_LOWLIGHT * 3 + 2] = ret[COL_BACKGROUND * 3 + 2] * 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.0F / 3.0F; + ret[COL_LOWLIGHT * 3 + 2] = ret[COL_BACKGROUND * 3 + 2] * 2.0F / 3.0F; *ncolours = NCOLOURS; return ret; @@ -1000,8 +1000,8 @@ static char *solve_game(game_state *state, game_state *currstate, pts[i].d = 2; ox *= pts[i].d; oy *= pts[i].d; - pts[i].x = ox + 0.5; - pts[i].y = oy + 0.5; + pts[i].x = (long)(ox + 0.5F); + pts[i].y = (long)(oy + 0.5F); extra = sprintf(buf, ";P%d:%ld,%ld/%ld", i, 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; - if (button == LEFT_BUTTON) { + if (IS_MOUSE_DOWN(button)) { int i, best; long bestd; @@ -1111,12 +1111,12 @@ static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds, return ""; } - } else if (button == LEFT_DRAG && ui->dragpoint >= 0) { + } else if (IS_MOUSE_DRAG(button) && ui->dragpoint >= 0) { ui->newpoint.x = x; ui->newpoint.y = y; ui->newpoint.d = ds->tilesize; return ""; - } else if (button == LEFT_RELEASE && ui->dragpoint >= 0) { + } else if (IS_MOUSE_RELEASE(button) && ui->dragpoint >= 0) { int p = ui->dragpoint; char buf[80]; @@ -1268,8 +1268,8 @@ static point mix(point a, point b, float distance) point ret; ret.d = a.d * b.d; - ret.x = 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.x = (long)(a.x * b.d + distance * (b.x * a.d - a.x * b.d)); + ret.y = (long)(a.y * b.d + distance * (b.y * a.d - a.y * b.d)); return ret; } |