From: simon Date: Wed, 28 Apr 2004 17:37:13 +0000 (+0000) Subject: Fix zillions of MSVC compiler warnings. Sigh. X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/puzzles/commitdiff_plain/03f856c427096797f0f7a6c93ca7f3ad72f7193e Fix zillions of MSVC compiler warnings. Sigh. git-svn-id: svn://svn.tartarus.org/sgt/puzzles@4165 cda61777-01e9-0310-a592-d414129be87e --- diff --git a/cube.c b/cube.c index 543e13b..934d475 100644 --- a/cube.c +++ b/cube.c @@ -27,82 +27,86 @@ struct solid { static const struct solid tetrahedron = { 4, { - 0.0, -0.57735026919, -0.20412414523, - -0.5, 0.28867513459, -0.20412414523, - 0.0, -0.0, 0.6123724357, - 0.5, 0.28867513459, -0.20412414523, + 0.0F, -0.57735026919F, -0.20412414523F, + -0.5F, 0.28867513459F, -0.20412414523F, + 0.0F, -0.0F, 0.6123724357F, + 0.5F, 0.28867513459F, -0.20412414523F, }, 3, 4, { 0,2,1, 3,1,2, 2,0,3, 1,3,0 }, { - -0.816496580928, -0.471404520791, 0.333333333334, - 0.0, 0.942809041583, 0.333333333333, - 0.816496580928, -0.471404520791, 0.333333333334, - 0.0, 0.0, -1.0, + -0.816496580928F, -0.471404520791F, 0.333333333334F, + 0.0F, 0.942809041583F, 0.333333333333F, + 0.816496580928F, -0.471404520791F, 0.333333333334F, + 0.0F, 0.0F, -1.0F, }, - 0.0, 0.3 + 0.0F, 0.3F }; static const struct solid cube = { 8, { - -0.5,-0.5,-0.5, -0.5,-0.5,+0.5, -0.5,+0.5,-0.5, -0.5,+0.5,+0.5, - +0.5,-0.5,-0.5, +0.5,-0.5,+0.5, +0.5,+0.5,-0.5, +0.5,+0.5,+0.5, + -0.5F,-0.5F,-0.5F, -0.5F,-0.5F,+0.5F, + -0.5F,+0.5F,-0.5F, -0.5F,+0.5F,+0.5F, + +0.5F,-0.5F,-0.5F, +0.5F,-0.5F,+0.5F, + +0.5F,+0.5F,-0.5F, +0.5F,+0.5F,+0.5F, }, 4, 6, { 0,1,3,2, 1,5,7,3, 5,4,6,7, 4,0,2,6, 0,4,5,1, 3,7,6,2 }, { - -1,0,0, 0,0,+1, +1,0,0, 0,0,-1, 0,-1,0, 0,+1,0 + -1.0F,0.0F,0.0F, 0.0F,0.0F,+1.0F, + +1.0F,0.0F,0.0F, 0.0F,0.0F,-1.0F, + 0.0F,-1.0F,0.0F, 0.0F,+1.0F,0.0F }, - 0.3, 0.5 + 0.3F, 0.5F }; static const struct solid octahedron = { 6, { - -0.5, -0.28867513459472505, 0.4082482904638664, - 0.5, 0.28867513459472505, -0.4082482904638664, - -0.5, 0.28867513459472505, -0.4082482904638664, - 0.5, -0.28867513459472505, 0.4082482904638664, - 0.0, -0.57735026918945009, -0.4082482904638664, - 0.0, 0.57735026918945009, 0.4082482904638664, + -0.5F, -0.28867513459472505F, 0.4082482904638664F, + 0.5F, 0.28867513459472505F, -0.4082482904638664F, + -0.5F, 0.28867513459472505F, -0.4082482904638664F, + 0.5F, -0.28867513459472505F, 0.4082482904638664F, + 0.0F, -0.57735026918945009F, -0.4082482904638664F, + 0.0F, 0.57735026918945009F, 0.4082482904638664F, }, 3, 8, { 4,0,2, 0,5,2, 0,4,3, 5,0,3, 1,4,2, 5,1,2, 4,1,3, 1,5,3 }, { - -0.816496580928, -0.471404520791, -0.333333333334, - -0.816496580928, 0.471404520791, 0.333333333334, - 0.0, -0.942809041583, 0.333333333333, - 0.0, 0.0, 1.0, - 0.0, 0.0, -1.0, - 0.0, 0.942809041583, -0.333333333333, - 0.816496580928, -0.471404520791, -0.333333333334, - 0.816496580928, 0.471404520791, 0.333333333334, + -0.816496580928F, -0.471404520791F, -0.333333333334F, + -0.816496580928F, 0.471404520791F, 0.333333333334F, + 0.0F, -0.942809041583F, 0.333333333333F, + 0.0F, 0.0F, 1.0F, + 0.0F, 0.0F, -1.0F, + 0.0F, 0.942809041583F, -0.333333333333F, + 0.816496580928F, -0.471404520791F, -0.333333333334F, + 0.816496580928F, 0.471404520791F, 0.333333333334F, }, - 0.0, 0.5 + 0.0F, 0.5F }; static const struct solid icosahedron = { 12, { - 0.0, 0.57735026919, 0.75576131408, - 0.0, -0.93417235896, 0.17841104489, - 0.0, 0.93417235896, -0.17841104489, - 0.0, -0.57735026919, -0.75576131408, - -0.5, -0.28867513459, 0.75576131408, - -0.5, 0.28867513459, -0.75576131408, - 0.5, -0.28867513459, 0.75576131408, - 0.5, 0.28867513459, -0.75576131408, - -0.80901699437, 0.46708617948, 0.17841104489, - 0.80901699437, 0.46708617948, 0.17841104489, - -0.80901699437, -0.46708617948, -0.17841104489, - 0.80901699437, -0.46708617948, -0.17841104489, + 0.0F, 0.57735026919F, 0.75576131408F, + 0.0F, -0.93417235896F, 0.17841104489F, + 0.0F, 0.93417235896F, -0.17841104489F, + 0.0F, -0.57735026919F, -0.75576131408F, + -0.5F, -0.28867513459F, 0.75576131408F, + -0.5F, 0.28867513459F, -0.75576131408F, + 0.5F, -0.28867513459F, 0.75576131408F, + 0.5F, 0.28867513459F, -0.75576131408F, + -0.80901699437F, 0.46708617948F, 0.17841104489F, + 0.80901699437F, 0.46708617948F, 0.17841104489F, + -0.80901699437F, -0.46708617948F, -0.17841104489F, + 0.80901699437F, -0.46708617948F, -0.17841104489F, }, 3, 20, { @@ -112,28 +116,28 @@ static const struct solid icosahedron = { 1,11,6, 8,2,5, 2,9,7, 3,10,5, 11,3,7, }, { - -0.356822089773, 0.87267799625, 0.333333333333, - 0.356822089773, 0.87267799625, 0.333333333333, - -0.356822089773, -0.87267799625, -0.333333333333, - 0.356822089773, -0.87267799625, -0.333333333333, - -0.0, 0.0, 1.0, - 0.0, -0.666666666667, 0.745355992501, - 0.0, 0.666666666667, -0.745355992501, - 0.0, 0.0, -1.0, - -0.934172358963, -0.12732200375, 0.333333333333, - -0.934172358963, 0.12732200375, -0.333333333333, - 0.934172358963, -0.12732200375, 0.333333333333, - 0.934172358963, 0.12732200375, -0.333333333333, - -0.57735026919, 0.333333333334, 0.745355992501, - 0.57735026919, 0.333333333334, 0.745355992501, - -0.57735026919, -0.745355992501, 0.333333333334, - 0.57735026919, -0.745355992501, 0.333333333334, - -0.57735026919, 0.745355992501, -0.333333333334, - 0.57735026919, 0.745355992501, -0.333333333334, - -0.57735026919, -0.333333333334, -0.745355992501, - 0.57735026919, -0.333333333334, -0.745355992501, + -0.356822089773F, 0.87267799625F, 0.333333333333F, + 0.356822089773F, 0.87267799625F, 0.333333333333F, + -0.356822089773F, -0.87267799625F, -0.333333333333F, + 0.356822089773F, -0.87267799625F, -0.333333333333F, + -0.0F, 0.0F, 1.0F, + 0.0F, -0.666666666667F, 0.745355992501F, + 0.0F, 0.666666666667F, -0.745355992501F, + 0.0F, 0.0F, -1.0F, + -0.934172358963F, -0.12732200375F, 0.333333333333F, + -0.934172358963F, 0.12732200375F, -0.333333333333F, + 0.934172358963F, -0.12732200375F, 0.333333333333F, + 0.934172358963F, 0.12732200375F, -0.333333333333F, + -0.57735026919F, 0.333333333334F, 0.745355992501F, + 0.57735026919F, 0.333333333334F, 0.745355992501F, + -0.57735026919F, -0.745355992501F, 0.333333333334F, + 0.57735026919F, -0.745355992501F, 0.333333333334F, + -0.57735026919F, 0.745355992501F, -0.333333333334F, + 0.57735026919F, 0.745355992501F, -0.333333333334F, + -0.57735026919F, -0.333333333334F, -0.745355992501F, + 0.57735026919F, -0.333333333334F, -0.745355992501F, }, - 0.0, 0.8 + 0.0F, 0.8F }; enum { @@ -152,8 +156,8 @@ enum { enum { LEFT, RIGHT, UP, DOWN, UP_LEFT, UP_RIGHT, DOWN_LEFT, DOWN_RIGHT }; -#define GRID_SCALE 48 -#define ROLLTIME 0.1 +#define GRID_SCALE 48.0F +#define ROLLTIME 0.1F #define SQ(x) ( (x) * (x) ) @@ -282,16 +286,16 @@ static void enum_grid_squares(game_params *params, for (y = 0; y < params->d2; y++) { struct grid_square sq; - sq.x = x; - sq.y = y; - sq.points[0] = x - 0.5; - sq.points[1] = y - 0.5; - sq.points[2] = x - 0.5; - sq.points[3] = y + 0.5; - sq.points[4] = x + 0.5; - sq.points[5] = y + 0.5; - sq.points[6] = x + 0.5; - sq.points[7] = y - 0.5; + sq.x = (float)x; + sq.y = (float)y; + sq.points[0] = x - 0.5F; + sq.points[1] = y - 0.5F; + sq.points[2] = x - 0.5F; + sq.points[3] = y + 0.5F; + sq.points[4] = x + 0.5F; + sq.points[5] = y + 0.5F; + sq.points[6] = x + 0.5F; + sq.points[7] = y - 0.5F; sq.npoints = 4; sq.directions[LEFT] = 0x03; /* 0,1 */ @@ -315,7 +319,7 @@ static void enum_grid_squares(game_params *params, } } else { int row, rowlen, other, i, firstix = -1; - float theight = sqrt(3) / 2.0; + float theight = (float)(sqrt(3) / 2.0); for (row = 0; row < params->d1 + params->d2; row++) { if (row < params->d1) { @@ -335,15 +339,15 @@ static void enum_grid_squares(game_params *params, float x, y; ix = (2 * i - (rowlen-1)); - x = ix * 0.5; + x = ix * 0.5F; y = theight * row; sq.x = x; sq.y = y + theight / 3; - sq.points[0] = x - 0.5; + sq.points[0] = x - 0.5F; sq.points[1] = y; sq.points[2] = x; sq.points[3] = y + theight; - sq.points[4] = x + 0.5; + sq.points[4] = x + 0.5F; sq.points[5] = y; sq.npoints = 3; @@ -380,15 +384,15 @@ static void enum_grid_squares(game_params *params, float x, y; ix = (2 * i - (rowlen+other-1)); - x = ix * 0.5; + x = ix * 0.5F; y = theight * row; sq.x = x; sq.y = y + 2*theight / 3; - sq.points[0] = x + 0.5; + sq.points[0] = x + 0.5F; sq.points[1] = y + theight; sq.points[2] = x; sq.points[3] = y; - sq.points[4] = x - 0.5; + sq.points[4] = x - 0.5F; sq.points[5] = y + theight; sq.npoints = 3; @@ -507,7 +511,7 @@ char *new_game_seed(game_params *params) for (j = 0; j < facesperclass; j++) { unsigned long divisor = RAND_MAX / data.nsquares[i]; unsigned long max = divisor * data.nsquares[i]; - int n; + unsigned long n; do { n = rand(); @@ -523,7 +527,7 @@ char *new_game_seed(game_params *params) * better data structure for this, but for such small * numbers it hardly seems worth the effort. */ - while (n < data.nsquares[i]-1) { + while ((int)n < data.nsquares[i]-1) { data.gridptrs[i][n] = data.gridptrs[i][n+1]; n++; } @@ -564,7 +568,7 @@ char *new_game_seed(game_params *params) { unsigned long divisor = RAND_MAX / m; unsigned long max = divisor * m; - int n; + unsigned long n; do { n = rand(); @@ -704,8 +708,8 @@ static struct solid *transform_poly(const struct solid *solid, int flip, vmatrix[1] = -vy; vmatrix[4] = vx; vmatrix[7] = 0; vmatrix[2] = 0; vmatrix[5] = 0; vmatrix[8] = 1; - ax = cos(angle); - ay = sin(angle); + ax = (float)cos(angle); + ay = (float)sin(angle); amatrix[0] = 1; amatrix[3] = 0; amatrix[6] = 0; amatrix[1] = 0; amatrix[4] = ax; amatrix[7] = ay; @@ -972,7 +976,7 @@ game_state *make_move(game_state *from, int x, int y, int button) for (i = 0; i < 3; i++) dp += (from->solid->normals[f[0]*3+i] * from->solid->normals[f[1]*3+i]); - angle = acos(dp); + angle = (float)acos(dp); } /* @@ -1149,10 +1153,10 @@ static struct bbox find_bbox(game_params *params) * These should be hugely more than the real bounding box will * be. */ - bb.l = 2 * (params->d1 + params->d2); - bb.r = -2 * (params->d1 + params->d2); - bb.u = 2 * (params->d1 + params->d2); - bb.d = -2 * (params->d1 + params->d2); + bb.l = 2.0F * (params->d1 + params->d2); + bb.r = -2.0F * (params->d1 + params->d2); + bb.u = 2.0F * (params->d1 + params->d2); + bb.d = -2.0F * (params->d1 + params->d2); enum_grid_squares(params, find_bbox_callback, &bb); return bb; @@ -1161,8 +1165,8 @@ static struct bbox find_bbox(game_params *params) void game_size(game_params *params, int *x, int *y) { struct bbox bb = find_bbox(params); - *x = (bb.r - bb.l + 2*solids[params->solid]->border) * GRID_SCALE; - *y = (bb.d - bb.u + 2*solids[params->solid]->border) * GRID_SCALE; + *x = (int)((bb.r - bb.l + 2*solids[params->solid]->border) * GRID_SCALE); + *y = (int)((bb.d - bb.u + 2*solids[params->solid]->border) * GRID_SCALE); } float *game_colours(frontend *fe, game_state *state, int *ncolours) @@ -1188,8 +1192,8 @@ game_drawstate *game_new_drawstate(game_state *state) struct game_drawstate *ds = snew(struct game_drawstate); struct bbox bb = find_bbox(&state->params); - ds->ox = -(bb.l - state->solid->border) * GRID_SCALE; - ds->oy = -(bb.u - state->solid->border) * GRID_SCALE; + ds->ox = (int)(-(bb.l - state->solid->border) * GRID_SCALE); + ds->oy = (int)(-(bb.u - state->solid->border) * GRID_SCALE); return ds; } @@ -1211,8 +1215,8 @@ void game_redraw(frontend *fe, game_drawstate *ds, game_state *oldstate, game_state *newstate; int square; - draw_rect(fe, 0, 0, (bb.r-bb.l+2) * GRID_SCALE, - (bb.d-bb.u+2) * GRID_SCALE, COL_BACKGROUND); + draw_rect(fe, 0, 0, (int)((bb.r-bb.l+2.0F) * GRID_SCALE), + (int)((bb.d-bb.u+2.0F) * GRID_SCALE), COL_BACKGROUND); if (oldstate && oldstate->movecount > state->movecount) { game_state *t; @@ -1247,10 +1251,10 @@ void game_redraw(frontend *fe, game_drawstate *ds, game_state *oldstate, int coords[8]; for (j = 0; j < state->squares[i].npoints; j++) { - coords[2*j] = state->squares[i].points[2*j] - * GRID_SCALE + ds->ox; - coords[2*j+1] = state->squares[i].points[2*j+1] - * GRID_SCALE + ds->oy; + coords[2*j] = ((int)(state->squares[i].points[2*j] * GRID_SCALE) + + ds->ox); + coords[2*j+1] = ((int)(state->squares[i].points[2*j+1]*GRID_SCALE) + + ds->oy); } draw_polygon(fe, coords, state->squares[i].npoints, TRUE, @@ -1307,8 +1311,8 @@ void game_redraw(frontend *fe, game_drawstate *ds, game_state *oldstate, } for (j = 0; j < poly->order; j++) { - coords[j*2] = points[j*2] * GRID_SCALE + ds->ox; - coords[j*2+1] = points[j*2+1] * GRID_SCALE + ds->oy; + coords[j*2] = (int)(points[j*2] * GRID_SCALE) + ds->ox; + coords[j*2+1] = (int)(points[j*2+1] * GRID_SCALE) + ds->oy; } /* @@ -1341,8 +1345,8 @@ void game_redraw(frontend *fe, game_drawstate *ds, game_state *oldstate, } sfree(poly); - draw_update(fe, 0, 0, (bb.r-bb.l+2) * GRID_SCALE, - (bb.d-bb.u+2) * GRID_SCALE); + draw_update(fe, 0, 0, (int)((bb.r-bb.l+2.0F) * GRID_SCALE), + (int)((bb.d-bb.u+2.0F) * GRID_SCALE)); } float game_anim_length(game_state *oldstate, game_state *newstate) diff --git a/net.c b/net.c index a295804..cb324e8 100644 --- a/net.c +++ b/net.c @@ -53,8 +53,8 @@ #define TILE_BORDER 1 #define WINDOW_OFFSET 16 -#define ROTATE_TIME 0.1 -#define FLASH_FRAME 0.05 +#define ROTATE_TIME 0.1F +#define FLASH_FRAME 0.05F enum { COL_BACKGROUND, @@ -458,7 +458,7 @@ game_state *new_game(game_params *params, char *seed) * the original 10 plus 10 more, rather than getting 20 new * ones and the chance of remembering your first 10.) */ - nbarriers = params->barrier_probability * count234(barriers); + nbarriers = (int)(params->barrier_probability * count234(barriers)); assert(nbarriers >= 0 && nbarriers <= count234(barriers)); while (nbarriers > 0) { @@ -785,44 +785,44 @@ float *game_colours(frontend *fe, game_state *state, int *ncolours) /* * Wires are black. */ - ret[COL_WIRE * 3 + 0] = 0.0; - ret[COL_WIRE * 3 + 1] = 0.0; - ret[COL_WIRE * 3 + 2] = 0.0; + ret[COL_WIRE * 3 + 0] = 0.0F; + ret[COL_WIRE * 3 + 1] = 0.0F; + ret[COL_WIRE * 3 + 2] = 0.0F; /* * Powered wires and powered endpoints are cyan. */ - ret[COL_POWERED * 3 + 0] = 0.0; - ret[COL_POWERED * 3 + 1] = 1.0; - ret[COL_POWERED * 3 + 2] = 1.0; + ret[COL_POWERED * 3 + 0] = 0.0F; + ret[COL_POWERED * 3 + 1] = 1.0F; + ret[COL_POWERED * 3 + 2] = 1.0F; /* * Barriers are red. */ - ret[COL_BARRIER * 3 + 0] = 1.0; - ret[COL_BARRIER * 3 + 1] = 0.0; - ret[COL_BARRIER * 3 + 2] = 0.0; + ret[COL_BARRIER * 3 + 0] = 1.0F; + ret[COL_BARRIER * 3 + 1] = 0.0F; + ret[COL_BARRIER * 3 + 2] = 0.0F; /* * Unpowered endpoints are blue. */ - ret[COL_ENDPOINT * 3 + 0] = 0.0; - ret[COL_ENDPOINT * 3 + 1] = 0.0; - ret[COL_ENDPOINT * 3 + 2] = 1.0; + ret[COL_ENDPOINT * 3 + 0] = 0.0F; + ret[COL_ENDPOINT * 3 + 1] = 0.0F; + ret[COL_ENDPOINT * 3 + 2] = 1.0F; /* * Tile borders are a darker grey than the background. */ - ret[COL_BORDER * 3 + 0] = 0.5 * ret[COL_BACKGROUND * 3 + 0]; - ret[COL_BORDER * 3 + 1] = 0.5 * ret[COL_BACKGROUND * 3 + 1]; - ret[COL_BORDER * 3 + 2] = 0.5 * ret[COL_BACKGROUND * 3 + 2]; + ret[COL_BORDER * 3 + 0] = 0.5F * ret[COL_BACKGROUND * 3 + 0]; + ret[COL_BORDER * 3 + 1] = 0.5F * ret[COL_BACKGROUND * 3 + 1]; + ret[COL_BORDER * 3 + 2] = 0.5F * ret[COL_BACKGROUND * 3 + 2]; /* * Locked tiles are a grey in between those two. */ - ret[COL_LOCKED * 3 + 0] = 0.75 * ret[COL_BACKGROUND * 3 + 0]; - ret[COL_LOCKED * 3 + 1] = 0.75 * ret[COL_BACKGROUND * 3 + 1]; - ret[COL_LOCKED * 3 + 2] = 0.75 * ret[COL_BACKGROUND * 3 + 2]; + ret[COL_LOCKED * 3 + 0] = 0.75F * ret[COL_BACKGROUND * 3 + 0]; + ret[COL_LOCKED * 3 + 1] = 0.75F * ret[COL_BACKGROUND * 3 + 1]; + ret[COL_LOCKED * 3 + 2] = 0.75F * ret[COL_BACKGROUND * 3 + 2]; return ret; } @@ -933,31 +933,33 @@ static void draw_tile(frontend *fe, game_state *state, int x, int y, int tile, /* * Set up the rotation matrix. */ - matrix[0] = cos(angle * PI / 180.0); - matrix[1] = -sin(angle * PI / 180.0); - matrix[2] = sin(angle * PI / 180.0); - matrix[3] = cos(angle * PI / 180.0); + matrix[0] = (float)cos(angle * PI / 180.0); + matrix[1] = (float)-sin(angle * PI / 180.0); + matrix[2] = (float)sin(angle * PI / 180.0); + matrix[3] = (float)cos(angle * PI / 180.0); /* * Draw the wires. */ - cx = cy = TILE_BORDER + (TILE_SIZE-TILE_BORDER) / 2.0 - 0.5; + cx = cy = TILE_BORDER + (TILE_SIZE-TILE_BORDER) / 2.0F - 0.5F; col = (tile & ACTIVE ? COL_POWERED : COL_WIRE); for (dir = 1; dir < 0x10; dir <<= 1) { if (tile & dir) { - ex = (TILE_SIZE - TILE_BORDER - 1.0) / 2.0 * X(dir); - ey = (TILE_SIZE - TILE_BORDER - 1.0) / 2.0 * Y(dir); + ex = (TILE_SIZE - TILE_BORDER - 1.0F) / 2.0F * X(dir); + ey = (TILE_SIZE - TILE_BORDER - 1.0F) / 2.0F * Y(dir); MATMUL(tx, ty, matrix, ex, ey); - draw_thick_line(fe, bx+cx, by+cy, bx+(cx+tx), by+(cy+ty), + draw_thick_line(fe, bx+(int)cx, by+(int)cy, + bx+(int)(cx+tx), by+(int)(cy+ty), COL_WIRE); } } for (dir = 1; dir < 0x10; dir <<= 1) { if (tile & dir) { - ex = (TILE_SIZE - TILE_BORDER - 1.0) / 2.0 * X(dir); - ey = (TILE_SIZE - TILE_BORDER - 1.0) / 2.0 * Y(dir); + ex = (TILE_SIZE - TILE_BORDER - 1.0F) / 2.0F * X(dir); + ey = (TILE_SIZE - TILE_BORDER - 1.0F) / 2.0F * Y(dir); MATMUL(tx, ty, matrix, ex, ey); - draw_line(fe, bx+cx, by+cy, bx+(cx+tx), by+(cy+ty), col); + draw_line(fe, bx+(int)cx, by+(int)cy, + bx+(int)(cx+tx), by+(int)(cy+ty), col); } } @@ -982,11 +984,11 @@ static void draw_tile(frontend *fe, game_state *state, int x, int y, int tile, points[6] = -1; points[7] = +1; for (i = 0; i < 8; i += 2) { - ex = (TILE_SIZE * 0.24) * points[i]; - ey = (TILE_SIZE * 0.24) * points[i+1]; + ex = (TILE_SIZE * 0.24F) * points[i]; + ey = (TILE_SIZE * 0.24F) * points[i+1]; MATMUL(tx, ty, matrix, ex, ey); - points[i] = bx+cx+tx; - points[i+1] = by+cy+ty; + points[i] = bx+(int)(cx+tx); + points[i+1] = by+(int)(cy+ty); } draw_polygon(fe, points, 4, TRUE, col); @@ -1012,8 +1014,8 @@ static void draw_tile(frontend *fe, game_state *state, int x, int y, int tile, if (!(tile(state, ox, oy) & F(dir))) continue; - px = bx + (dx>0 ? TILE_SIZE + TILE_BORDER - 1 : dx<0 ? 0 : cx); - py = by + (dy>0 ? TILE_SIZE + TILE_BORDER - 1 : dy<0 ? 0 : cy); + px = bx + (int)(dx>0 ? TILE_SIZE + TILE_BORDER - 1 : dx<0 ? 0 : cx); + py = by + (int)(dy>0 ? TILE_SIZE + TILE_BORDER - 1 : dy<0 ? 0 : cy); lx = dx * (TILE_BORDER-1); ly = dy * (TILE_BORDER-1); vx = (dy ? 1 : 0); @@ -1131,9 +1133,9 @@ void game_redraw(frontend *fe, game_drawstate *ds, game_state *oldstate, if (tx >= 0) { if (tile(state, tx, ty) == ROT(tile(oldstate, tx, ty), state->last_rotate_dir)) - angle = state->last_rotate_dir * 90.0 * (t / ROTATE_TIME); + angle = state->last_rotate_dir * 90.0F * (t / ROTATE_TIME); else - angle = state->last_rotate_dir * -90.0 * (t / ROTATE_TIME); + angle = state->last_rotate_dir * -90.0F * (t / ROTATE_TIME); state = oldstate; } } else if (t > ROTATE_TIME) { @@ -1141,7 +1143,7 @@ void game_redraw(frontend *fe, game_drawstate *ds, game_state *oldstate, * We're animating a completion flash. Find which frame * we're at. */ - frame = (t - ROTATE_TIME) / FLASH_FRAME; + frame = (int)((t - ROTATE_TIME) / FLASH_FRAME); } /* @@ -1175,7 +1177,7 @@ void game_redraw(frontend *fe, game_drawstate *ds, game_state *oldstate, index(state, ds->visible, x, y) == 0xFF || (x == tx && y == ty)) { draw_tile(fe, state, x, y, c, - (x == tx && y == ty ? angle : 0.0)); + (x == tx && y == ty ? angle : 0.0F)); if (x == tx && y == ty) index(state, ds->visible, x, y) = 0xFF; else @@ -1188,7 +1190,7 @@ void game_redraw(frontend *fe, game_drawstate *ds, game_state *oldstate, float game_anim_length(game_state *oldstate, game_state *newstate) { - float ret = 0.0; + float ret = 0.0F; int x, y; /* diff --git a/random.c b/random.c index dad2c0e..e0a179e 100644 --- a/random.c +++ b/random.c @@ -177,22 +177,22 @@ static void SHA_Final(SHA_State * s, unsigned char *output) c[0] = 0x80; SHA_Bytes(s, &c, pad); - c[0] = (lenhi >> 24) & 0xFF; - c[1] = (lenhi >> 16) & 0xFF; - c[2] = (lenhi >> 8) & 0xFF; - c[3] = (lenhi >> 0) & 0xFF; - c[4] = (lenlo >> 24) & 0xFF; - c[5] = (lenlo >> 16) & 0xFF; - c[6] = (lenlo >> 8) & 0xFF; - c[7] = (lenlo >> 0) & 0xFF; + c[0] = (unsigned char)((lenhi >> 24) & 0xFF); + c[1] = (unsigned char)((lenhi >> 16) & 0xFF); + c[2] = (unsigned char)((lenhi >> 8) & 0xFF); + c[3] = (unsigned char)((lenhi >> 0) & 0xFF); + c[4] = (unsigned char)((lenlo >> 24) & 0xFF); + c[5] = (unsigned char)((lenlo >> 16) & 0xFF); + c[6] = (unsigned char)((lenlo >> 8) & 0xFF); + c[7] = (unsigned char)((lenlo >> 0) & 0xFF); SHA_Bytes(s, &c, 8); for (i = 0; i < 5; i++) { - output[i * 4] = (s->h[i] >> 24) & 0xFF; - output[i * 4 + 1] = (s->h[i] >> 16) & 0xFF; - output[i * 4 + 2] = (s->h[i] >> 8) & 0xFF; - output[i * 4 + 3] = (s->h[i]) & 0xFF; + output[i * 4] = (unsigned char)((s->h[i] >> 24) & 0xFF); + output[i * 4 + 1] = (unsigned char)((s->h[i] >> 16) & 0xFF); + output[i * 4 + 2] = (unsigned char)((s->h[i] >> 8) & 0xFF); + output[i * 4 + 3] = (unsigned char)((s->h[i]) & 0xFF); } }