From: Nick Bowler Date: Sun, 30 Dec 2007 09:29:48 +0000 (-0500) Subject: Fix processing of the 2nd type of drawing command in images. X-Git-Url: https://git.draconx.ca/gitweb/liblbx.git/commitdiff_plain/210202b952fe47685635f812d85779f7a8ce5354?ds=sidebyside Fix processing of the 2nd type of drawing command in images. The unknown word in the bunch turns out to be an x-adjustment value. This makes *all* frames of the main menu animation decodable. --- diff --git a/src/image.c b/src/image.c index 9b9b1dd..336cd98 100644 --- a/src/image.c +++ b/src/image.c @@ -110,8 +110,7 @@ static int _lbx_drawrow(int first, struct lbx_image *img) xval = letohs(xval); img->foff += sizeof xval; /* Ensure that the row fits in the image. */ - if (img->height - img->currenty <= yval - || xval >= img->width || count > img->width - xval) { + if (img->height - img->currenty <= yval || xval >= img->width) { lbx_errno = LBX_EFORMAT; return -1; } @@ -119,17 +118,22 @@ static int _lbx_drawrow(int first, struct lbx_image *img) img->currenty += yval; img->currentx = xval; } else { - if (fread(&yval, sizeof yval, 1, img->f) != 1) goto readerr; - yval = letohs(yval); img->foff += sizeof yval; - - /* FIXME Still have to figure out what to do here. */ - - count = type; + if (fread(&xval, sizeof xval, 1, img->f) != 1) goto readerr; + xval = letohs(xval); img->foff += sizeof xval; - if (count > img->width - img->currentx) { + if (img->width - img->currentx <= xval) { lbx_errno = LBX_EFORMAT; return -1; } + img->currentx += xval; + + count = type; + + } + + if (count > img->width - img->currentx) { + lbx_errno = LBX_EFORMAT; + return -1; } pos = &img->framedata[img->currenty][img->currentx];