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, - draw_field, draw_player and restore player function fixed,
problems with position on the field is greater as the problems with position on the field is greater as the
fieldsize. (SDL BadValue) fieldsize. (SDL BadValue)

@ -86,7 +86,7 @@ fi
dnl Set PACKAGE DATA & DOC DIR dnl Set PACKAGE DATA & DOC DIR
packagedatadir=share/${PACKAGE} packagedatadir=share/${PACKAGE}
packagedocdir=doc/${PACKAGE} packagedocdir=share/doc/${PACKAGE}
dnl Set PACKAGE DIRS in config.h. dnl Set PACKAGE DIRS in config.h.
packagepixmapsdir=${packagedatadir}/pixmaps 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 */ /* gfx.c */
#include <SDL.h> #include <SDL.h>
@ -595,12 +595,33 @@ gfx_shutdown ()
void void
gfx_AddUpdateRect (int x, int y, int w, int h) 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) if (UpdateRects_nr >= MAX_UPDATERECTS)
return; return;
UpdateRects[UpdateRects_nr].x = x;
UpdateRects[UpdateRects_nr].y = y; if (x < 0)
UpdateRects[UpdateRects_nr].w = w; UpdateRects[UpdateRects_nr].x = 0;
UpdateRects[UpdateRects_nr].h = h; 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++; UpdateRects_nr++;
}; };

Loading…
Cancel
Save