From: Holger Schemel Date: Mon, 19 Feb 2018 20:58:16 +0000 (+0100) Subject: fixed bug when checking out-of-bounds frames im graphics definitions X-Git-Tag: 4.0.1.2~3 X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=commitdiff_plain;h=f31bfea6c5b1febcda3d90a6f1ed872e39c14dde fixed bug when checking out-of-bounds frames im graphics definitions - this bug was caused by getFixedGraphicSource() always using 32x32 tile size even if element graphic was defined using smaller tile size like 16x16, resulting in correct definitions to be assumed as out of bounds - fixed by using getGraphicSourceXY() instead, which only uses width and height attributes (which are set to the correct tile size for elements) --- diff --git a/src/init.c b/src/init.c index 54f4277d..6980eb9a 100644 --- a/src/init.c +++ b/src/init.c @@ -1717,10 +1717,10 @@ static void InitGraphicInfo() for (i = 0; i < num_images; i++) { - Bitmap *src_bitmap; + Bitmap *src_bitmap = graphic_info[i].bitmap; int src_x, src_y; int width, height; - int first_frame, last_frame; + int last_frame; int src_bitmap_width, src_bitmap_height; /* now check if no animation frames are outside of the loaded image */ @@ -1738,9 +1738,7 @@ static void InitGraphicInfo() /* check if first animation frame is inside specified bitmap */ - first_frame = 0; - getFixedGraphicSource(i, first_frame, &src_bitmap, &src_x, &src_y); - + /* do not use getGraphicSourceXY() here to get position of first frame; */ /* this avoids calculating wrong start position for out-of-bounds frame */ src_x = graphic_info[i].src_x; src_y = graphic_info[i].src_y; @@ -1770,12 +1768,15 @@ static void InitGraphicInfo() Error(ERR_INFO_LINE, "-"); graphic_info[i] = graphic_info[fallback_graphic]; + + /* if first frame out of bounds, do not check last frame anymore */ + continue; } /* check if last animation frame is inside specified bitmap */ last_frame = graphic_info[i].anim_frames - 1; - getFixedGraphicSource(i, last_frame, &src_bitmap, &src_x, &src_y); + getGraphicSourceXY(i, last_frame, &src_x, &src_y, FALSE); if (src_x < 0 || src_y < 0 || src_x + width > src_bitmap_width ||