gfx_AddUpdateRect clipping of the updatebox

origin
stpohle 23 years ago
parent acd9fb8047
commit 4c6a7b0efa

@ -1,3 +1,5 @@
- screen clipping of gfx_AddUpdateRect
- draw_field, draw_player and restore player function fixed,
problems with position on the field is greater as the
fieldsize. (SDL BadValue)

@ -86,7 +86,7 @@ fi
dnl Set PACKAGE DATA & DOC DIR
packagedatadir=share/${PACKAGE}
packagedocdir=doc/${PACKAGE}
packagedocdir=share/doc/${PACKAGE}
dnl Set PACKAGE DIRS in config.h.
packagepixmapsdir=${packagedatadir}/pixmaps

@ -1,4 +1,4 @@
/* $Id: gfx.c,v 1.21 2003/06/16 21:03:16 stpohle Exp $ */
/* $Id: gfx.c,v 1.22 2003/06/20 22:59:21 stpohle Exp $ */
/* gfx.c */
#include <SDL.h>
@ -595,12 +595,33 @@ gfx_shutdown ()
void
gfx_AddUpdateRect (int x, int y, int w, int h)
{
/* clipping of the box */
if (x >= gfx.res.x || y >= gfx.res.y || y+h <= 0 || x+w <= 0)
return;
if (UpdateRects_nr >= MAX_UPDATERECTS)
return;
UpdateRects[UpdateRects_nr].x = x;
UpdateRects[UpdateRects_nr].y = y;
UpdateRects[UpdateRects_nr].w = w;
UpdateRects[UpdateRects_nr].h = h;
if (x < 0)
UpdateRects[UpdateRects_nr].x = 0;
else
UpdateRects[UpdateRects_nr].x = x;
if (y < 0)
UpdateRects[UpdateRects_nr].y = 0;
else
UpdateRects[UpdateRects_nr].y = y;
if (w+x >= gfx.res.x)
UpdateRects[UpdateRects_nr].w = gfx.res.x - x;
else
UpdateRects[UpdateRects_nr].w = w;
if (h+y >= gfx.res.y)
UpdateRects[UpdateRects_nr].h = gfx.res.y - y;
else
UpdateRects[UpdateRects_nr].h = h;
UpdateRects_nr++;
};

Loading…
Cancel
Save