]> git.draconx.ca Git - upkg.git/commitdiff
engine: Fix off-by-one in PCX run-length encoder.
authorNick Bowler <nbowler@draconx.ca>
Fri, 11 May 2012 23:39:36 +0000 (19:39 -0400)
committerNick Bowler <nbowler@draconx.ca>
Fri, 11 May 2012 23:43:15 +0000 (19:43 -0400)
Runs of 64 bytes are invalid, but the encoder would emit them anyway
(which get subsequently interpreted as a run of 0).  This obviously
causes some textures to export incorrectly.

We can now export all of UTtech2.utx!

src/engine/pcx.c

index b01e9b8acca728c6560301ea9840f00145e4320e..f0d0ba525bbc02cfce53296bcbb7cecb98865f12 100644 (file)
@@ -68,7 +68,7 @@ int pcx_write_scanline(const struct pcx_head *head, const unsigned char *src,
        for (size_t i = 0; i < len;) {
                unsigned run = 0;
 
-               while (i+run < len && src[i] == src[i+run] && run <= 0x3f)
+               while (i+run < len && src[i] == src[i+run] && run < 0x3f)
                        run++;
 
                if (run > 1 || src[i] > 0xbf)