]> git.draconx.ca Git - liblbx.git/commitdiff
Fix processing of the 2nd type of drawing command in images.
authorNick Bowler <draconx@gmail.com>
Sun, 30 Dec 2007 09:29:48 +0000 (04:29 -0500)
committerNick Bowler <draconx@gmail.com>
Mon, 31 Dec 2007 01:42:46 +0000 (20:42 -0500)
The unknown word in the bunch turns out to be an x-adjustment value.
This makes *all* frames of the main menu animation decodable.

src/image.c

index 9b9b1dde323e6b0c5de1aa978b3ed97616ab4669..336cd98ebd4951cfb049d24c10db6f3eeaf55864 100644 (file)
@@ -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];