TexTools / xivModdingFramework

GNU General Public License v3.0
9 stars 16 forks source link

.tex handling when mipmap size is a multiple of 16000 causes loss of data #51

Closed Soreepeong closed 4 months ago

Soreepeong commented 1 year ago

In the following code, shouldn't

uncompLength = dealing with last part ? mipLength % 16000 : 16000

have been

uncompLength = dealing with last part && mipLength % 16000 != 0 ? mipLength % 16000 : 16000

instead? Otherwise, the last part of each mipmap would end up being omitted.

https://github.com/TexTools/xivModdingFramework/blob/12efd03145dd8f03f132699e8ef2cd757dc1fed6/xivModdingFramework/Textures/FileTypes/DDS.cs#L526-L554

This mod has consecutive sqblocks where (size=16b, unk=0, compressed=0 decompressed=16000), and while I'm not sure if the above is the cause (can't think of a reason why would these empty blocks be placed consecutive), thought that it might worth sharing this issue.

image

Soreepeong commented 1 year ago

On consecutive invalid empty blocks, it might be the case of the game storing .tex files truncated if it ends with bunch of trailing zeroes, resulting in truncated .tex file, which makes ReadBytes return zero length array, in which case maybe it can just stop there?

Lunaretic commented 4 months ago

Resolved in Dawntrail builds as part of other refactoring.