qbsp: account for miptex struct in wad3 lump disksize

Here's another little tyrutils patch: in qbsp, I believe the
calculation of the "disksize" field of the miptex lumps when using
WAD3 textures is missing the size of the dmiptex_t struct (40 bytes),
causing the resulting bsp file to be slightly truncated.

I noticed this because one of Tronyn's levels (jam2_tronyn.bsp) was
crashing Quakespasm for me; it turned out the engine was trying to
read 40 bytes past the end of the file when loading the last texture
in the bsp. I got him to send over his map source, wads, and compiler;
he was using tyrutils 0.15 and wad3 format textures, and I confirmed
that this patch fixes the engine crash.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
This commit is contained in:
Eric Wasylishen 2014-10-30 12:54:36 +10:30 committed by Kevin Shanahan
parent 4df394f9fe
commit 5111c5485c
1 changed files with 1 additions and 1 deletions

View File

@ -66,7 +66,7 @@ WAD_LoadInfo(wad_t *wad)
len = fread(&miptex, 1, sizeof(miptex), wad->file);
if (len != sizeof(miptex))
return false;
disksize = miptex.width * miptex.height / 64 * 85;
disksize = sizeof(miptex) + (miptex.width * miptex.height / 64 * 85);
if (disksize < wad->lumps[i].disksize)
wad->lumps[i].disksize = disksize;
}