X-Git-Url: https://git.draconx.ca/gitweb/liblbx.git/blobdiff_plain/fc46251027e2c65bff081cc04939ff13015501aa..ba19b133bf87936dc606dd994f56f433a278b768:/src/image.c?ds=sidebyside diff --git a/src/image.c b/src/image.c index 764f2be..e0ee129 100644 --- a/src/image.c +++ b/src/image.c @@ -1,7 +1,7 @@ /* * 2ooM: The Master of Orion II Reverse Engineering Project * Library for working with LBX image files. - * Copyright © 2006-2011, 2013 Nick Bowler + * Copyright © 2006-2011, 2013-2014 Nick Bowler * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -43,7 +43,7 @@ struct lbx_image_priv { struct lbx_image pub; unsigned short wtf, flags; - unsigned char wtf2, leadin; + unsigned char wtf2; unsigned short palstart, palcount; const struct lbx_file_ops *fops; @@ -77,13 +77,19 @@ static struct lbx_image_priv *lbx_img_init(unsigned char hdr[static HDR_LEN]) .wtf = unpack_16_le(hdr+4), .pub.frames = hdr[6], .wtf2 = hdr[7], - .leadin = hdr[8], + .pub.leadin = hdr[8], .pub.chunk = hdr[9], .flags = unpack_16_le(hdr+10), .currentframe = -1, }; + if (img->flags & FLAG_OVERWRITE) + img->pub.chunk = 1; + + if (img->flags & FLAG_LOOPING) + img->pub.leadin = 0; + return img; } @@ -115,7 +121,7 @@ struct lbx_image *lbx_img_open(void *f, const struct lbx_file_ops *fops, */ _lbx_assert(img->wtf == 0); /* version? */ _lbx_assert(img->wtf2 == 0); /* very likely is simply reserved. */ - _lbx_assert(img->pub.frames > img->leadin); + _lbx_assert(img->pub.frames > img->pub.leadin); _lbx_assert(!(img->flags & ~FLAG_ALL)); /* Read all offsets. Should be merged with identical code in lbx.c */ @@ -490,8 +496,8 @@ void lbx_img_getinfo(struct lbx_image *pub, struct lbx_imginfo *info) if (img->flags & FLAG_LOOPING) { info->loopstart = 0; info->looping = 1; - } else if (img->leadin != pub->frames - 1) { - info->loopstart = img->leadin; + } else if (img->pub.leadin != pub->frames - 1) { + info->loopstart = img->pub.leadin; info->looping = 1; } }