Make vid.width/height unsigned and clean up the mess.

This commit is contained in:
Bill Currie 2013-01-24 11:25:30 +09:00
parent 8153646eda
commit 40af4bb986
16 changed files with 36 additions and 34 deletions

View file

@ -138,7 +138,7 @@ typedef struct vid_render_funcs_s {
void (*SCR_DrawTurtle) (void);
void (*SCR_DrawPause) (void);
struct tex_s *(*SCR_CaptureBGR) (void);
struct tex_s *(*SCR_ScreenShot) (int width, int height);
struct tex_s *(*SCR_ScreenShot) (unsigned width, unsigned height);
void (*SCR_DrawStringToSnap) (const char *s, struct tex_s *tex,
int x, int y);

View file

@ -48,8 +48,8 @@ typedef struct {
unsigned int *colormap32; // 256 * VID_GRADES size
int fullbright; // index of first fullbright color
int rowbytes; // may be > width if displayed in a window
int width;
int height;
unsigned width;
unsigned height;
float aspect; // width / height -- < 1 is taller than wide
int numpages;
qboolean recalc_refdef; // if true, recalc vid-based stuff
@ -59,8 +59,8 @@ typedef struct {
int conrowbytes;
int conwidth;
int conheight;
int maxwarpwidth;
int maxwarpheight;
unsigned maxwarpwidth;
unsigned maxwarpheight;
byte *direct; // direct drawing to framebuffer, if not
// NULL
int (*surf_cache_size)(int width, int height);

View file

@ -42,7 +42,7 @@ void SCR_DrawTime (void);
void SCR_DrawTurtle (void);
void SCR_DrawPause (void);
struct tex_s *SCR_CaptureBGR (void);
struct tex_s *SCR_ScreenShot (int width, int height);
struct tex_s *SCR_ScreenShot (unsigned width, unsigned height);
void SCR_DrawStringToSnap (const char *s, struct tex_s *tex, int x, int y);

View file

@ -81,7 +81,7 @@ gl_SCR_CaptureBGR (void)
}
tex_t *
gl_SCR_ScreenShot (int width, int height)
gl_SCR_ScreenShot (unsigned width, unsigned height)
{
unsigned char *src, *dest, *snap;
float fracw, frach;

View file

@ -228,7 +228,7 @@ glsl_SCR_CaptureBGR (void)
}
tex_t *
glsl_SCR_ScreenShot (int width, int height)
glsl_SCR_ScreenShot (unsigned width, unsigned height)
{
return 0;
}

View file

@ -51,9 +51,9 @@ D_FillRect (vrect_t *rect, int color)
rheight += ry;
ry = 0;
}
if (rx + rwidth > vid.width)
if ((unsigned) (rx + rwidth) > vid.width)
rwidth = vid.width - rx;
if (ry + rheight > vid.height)
if ((unsigned) (ry + rheight) > vid.height)
rheight = vid.height - rx;
if (rwidth < 1 || rheight < 1)

View file

@ -100,7 +100,7 @@ D_ViewChanged (void)
r_refdef.vrectbottom - (d_pix_max << d_y_aspect_shift);
{
int i;
unsigned i;
for (i = 0; i < vid.height; i++) {
d_scantable[i] = i * rowpixels;

View file

@ -553,7 +553,7 @@ Draw_SubPic (int x, int y, qpic_t *pic, int srcx, int srcy, int width,
width += x;
x = 0;
}
if (x + width > vid.width)
if ((unsigned) (x + width) > vid.width)
width = vid.width - x;
if (width <= 0)
return;
@ -562,7 +562,7 @@ Draw_SubPic (int x, int y, qpic_t *pic, int srcx, int srcy, int width,
height += y;
y = 0;
}
if (y + height > vid.height)
if ((unsigned) (y + height) > vid.height)
height = vid.height - y;
if (height <= 0)
return;
@ -696,7 +696,7 @@ Draw_TileClear (int x, int y, int w, int h)
byte *psrc;
vrect_t vr;
CLIP (x, y, w, h, vid.width, vid.height);
CLIP (x, y, w, h, (int) vid.width, (int) vid.height);
r_rectdesc.rect.x = x;
r_rectdesc.rect.y = y;
@ -764,7 +764,7 @@ Draw_Fill (int x, int y, int w, int h, int c)
Sys_MaskPrintf (SYS_VID, "Bad Draw_Fill(%d, %d, %d, %d, %c)\n",
x, y, w, h, c);
}
CLIP (x, y, w, h, vid.width, vid.height);
CLIP (x, y, w, h, (int) vid.width, (int) vid.height);
dest = ((byte*)vid.buffer) + y * vid.rowbytes + x;
for (v = 0; v < h; v++, dest += vid.rowbytes)

View file

@ -85,7 +85,7 @@ SCR_CaptureBGR (void)
}
tex_t *
SCR_ScreenShot (int width, int height)
SCR_ScreenShot (unsigned width, unsigned height)
{
unsigned char *src, *dest;
float fracw, frach;

View file

@ -1084,7 +1084,7 @@ static void
renderlookup (byte **offs, byte* bufs)
{
byte *p = (byte*)vid.buffer;
int x, y;
unsigned x, y;
for (y = 0; y < vid.height; y++) {
for (x = 0; x < vid.width; x++, offs++)
p[x] = **offs;

View file

@ -63,9 +63,9 @@ sw32_D_FillRect (vrect_t *rect, int color)
rheight += ry;
ry = 0;
}
if (rx + rwidth > vid.width)
if ((unsigned) (rx + rwidth) > vid.width)
rwidth = vid.width - rx;
if (ry + rheight > vid.height)
if ((unsigned) (ry + rheight) > vid.height)
rheight = vid.height - rx;
if (rwidth < 1 || rheight < 1)
@ -101,9 +101,9 @@ sw32_D_FillRect (vrect_t *rect, int color)
rheight += ry;
ry = 0;
}
if (rx + rwidth > vid.width)
if ((unsigned) (rx + rwidth) > vid.width)
rwidth = vid.width - rx;
if (ry + rheight > vid.height)
if ((unsigned) (ry + rheight) > vid.height)
rheight = vid.height - rx;
if (rwidth < 1 || rheight < 1)
@ -140,9 +140,9 @@ sw32_D_FillRect (vrect_t *rect, int color)
rheight += ry;
ry = 0;
}
if (rx + rwidth > vid.width)
if ((unsigned) (rx + rwidth) > vid.width)
rwidth = vid.width - rx;
if (ry + rheight > vid.height)
if ((unsigned) (ry + rheight) > vid.height)
rheight = vid.height - rx;
if (rwidth < 1 || rheight < 1)

View file

@ -87,7 +87,7 @@ sw32_D_ViewChanged (void)
r_refdef.vrectbottom - (sw32_d_pix_max << sw32_d_y_aspect_shift);
{
int i;
unsigned i;
for (i = 0; i < vid.height; i++) {
sw32_d_scantable[i] = i * rowpixels;

View file

@ -669,7 +669,7 @@ sw32_Draw_SubPic (int x, int y, qpic_t *pic, int srcx, int srcy, int width,
width += x;
x = 0;
}
if (x + width > vid.width)
if ((unsigned) (x + width) > vid.width)
width = vid.width - x;
if (width <= 0)
return;
@ -678,7 +678,7 @@ sw32_Draw_SubPic (int x, int y, qpic_t *pic, int srcx, int srcy, int width,
height += y;
y = 0;
}
if (y + height > vid.height)
if ((unsigned) (y + height) > vid.height)
height = vid.height - y;
if (height <= 0)
return;
@ -1112,7 +1112,7 @@ sw32_Draw_TileClear (int x, int y, int w, int h)
byte *psrc;
vrect_t vr;
CLIP (x, y, w, h, vid.width, vid.height);
CLIP (x, y, w, h, (int) vid.width, (int) vid.height);
r_rectdesc.rect.x = x;
r_rectdesc.rect.y = y;
@ -1179,7 +1179,7 @@ sw32_Draw_Fill (int x, int y, int w, int h, int c)
Sys_MaskPrintf (SYS_VID, "Bad Draw_Fill(%d, %d, %d, %d, %c)\n",
x, y, w, h, c);
}
CLIP (x, y, w, h, vid.width, vid.height);
CLIP (x, y, w, h, (int) vid.width, (int) vid.height);
switch (sw32_r_pixbytes) {
case 1:
@ -1304,7 +1304,8 @@ sw32_Draw_BlendScreen (quat_t color)
break;
case 2:
{
int g1, g2, x, y;
int g1, g2;
unsigned x, y;
unsigned short rramp[32], gramp[64], bramp[32], *temp;
for (i = 0; i < 32; i++) {
r = i << 3;
@ -1331,7 +1332,7 @@ sw32_Draw_BlendScreen (quat_t color)
break;
case 4:
{
int x, y;
unsigned x, y;
byte ramp[256][4], *temp;
for (i = 0; i < 256; i++) {

View file

@ -88,7 +88,7 @@ sw32_SCR_CaptureBGR (void)
}
tex_t *
sw32_SCR_ScreenShot (int width, int height)
sw32_SCR_ScreenShot (unsigned width, unsigned height)
{
return 0;
}

View file

@ -339,7 +339,8 @@ check_mouse_event (Display *disp, XEvent *ev, XPointer arg)
XMotionEvent *me = &ev->xmotion;
if (ev->type != MotionNotify)
return False;
if (me->x != viddef.width / 2 || me->y != viddef.height / 2)
if ((unsigned) me->x != viddef.width / 2
|| (unsigned) me->y != viddef.height / 2)
return False;
return True;
}

View file

@ -700,8 +700,8 @@ event_motion (XEvent *event)
} else {
if (vid_fullscreen->int_val || input_grabbed) {
if (!event->xmotion.send_event) {
int dist_x = abs (viddef.width / 2 - event->xmotion.x);
int dist_y = abs (viddef.height / 2 - event->xmotion.y);
unsigned dist_x = abs (viddef.width / 2 - event->xmotion.x);
unsigned dist_y = abs (viddef.height / 2 - event->xmotion.y);
in_mouse_x += (event->xmotion.x - p_mouse_x);
in_mouse_y += (event->xmotion.y - p_mouse_y);
if (dist_x > viddef.width / 4 || dist_y > viddef.height / 4) {