From 92b3f82c5b28a05c777cddb2c05c23353f4919cd Mon Sep 17 00:00:00 2001 From: Atvaark Date: Fri, 11 Sep 2015 18:57:21 +0200 Subject: [PATCH] Fixed ftexs and chunk count for 4096x4096 textures --- FtexTool/Ftex/FtexFile.cs | 2 +- FtexTool/FtexDdsConverter.cs | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/FtexTool/Ftex/FtexFile.cs b/FtexTool/Ftex/FtexFile.cs index a0d908f..70ba470 100644 --- a/FtexTool/Ftex/FtexFile.cs +++ b/FtexTool/Ftex/FtexFile.cs @@ -172,7 +172,7 @@ public void UpdateOffsets() { FtexFileMipMapInfo ftexMipMapInfo = MipMapInfos.ElementAt(mipMapIndex); ftexMipMapInfo.CompressedFileSize = ftexsFileMipMap.CompressedDataSize; - ftexMipMapInfo.ChunkCount = Convert.ToByte(ftexsFileMipMap.Chunks.Count()); + ftexMipMapInfo.ChunkCount = Convert.ToInt16(ftexsFileMipMap.Chunks.Count()); ftexMipMapInfo.Offset = ftexsFileMipMap.Offset; ++mipMapIndex; } diff --git a/FtexTool/FtexDdsConverter.cs b/FtexTool/FtexDdsConverter.cs index 6ec01b1..8dd30da 100644 --- a/FtexTool/FtexDdsConverter.cs +++ b/FtexTool/FtexDdsConverter.cs @@ -120,7 +120,7 @@ private static List GetFtexsFiles(List mipMapInfo private static List GetFtexsChunks(FtexFileMipMapInfo mipMapInfo, byte[] mipMapData) { List ftexsFileChunks = new List(); - const int maxChunkSize = short.MaxValue; + const int maxChunkSize = short.MaxValue/2 + 1; int requiredChunks = (int) Math.Ceiling((double) mipMapData.Length/maxChunkSize); int mipMapDataOffset = 0; for (int i = 0; i < requiredChunks; i++) @@ -180,7 +180,9 @@ private static byte GetFtexsFileNumber(int fileSize) return 3; if (fileSize <= 1398128) return 4; - return 5; + if (fileSize <= 11180000) + return 5; + return 6; } private static List GetMipMapData(DdsFile file)