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:
parent
4df394f9fe
commit
5111c5485c
|
|
@ -66,7 +66,7 @@ WAD_LoadInfo(wad_t *wad)
|
||||||
len = fread(&miptex, 1, sizeof(miptex), wad->file);
|
len = fread(&miptex, 1, sizeof(miptex), wad->file);
|
||||||
if (len != sizeof(miptex))
|
if (len != sizeof(miptex))
|
||||||
return false;
|
return false;
|
||||||
disksize = miptex.width * miptex.height / 64 * 85;
|
disksize = sizeof(miptex) + (miptex.width * miptex.height / 64 * 85);
|
||||||
if (disksize < wad->lumps[i].disksize)
|
if (disksize < wad->lumps[i].disksize)
|
||||||
wad->lumps[i].disksize = disksize;
|
wad->lumps[i].disksize = disksize;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue