|
1 |
| -// xivModdingFramework |
| 1 | +// xivModdingFramework |
2 | 2 | // Copyright © 2018 Rafael Gonzalez - All Rights Reserved
|
3 | 3 | //
|
4 | 4 | // This program is free software: you can redistribute it and/or modify
|
@@ -48,9 +48,9 @@ public class TTMP
|
48 | 48 | ".cmp", ".imc", ".eqdp", ".eqp", ".gmp", ".est"
|
49 | 49 | };
|
50 | 50 |
|
51 |
| - private readonly string _currentWizardTTMPVersion = "1.2w"; |
52 |
| - private readonly string _currentSimpleTTMPVersion = "1.2s"; |
53 |
| - private const string _minimumAssembly = "1.2.0.0"; |
| 51 | + private readonly string _currentWizardTTMPVersion = "1.3w"; |
| 52 | + private readonly string _currentSimpleTTMPVersion = "1.3s"; |
| 53 | + private const string _minimumAssembly = "1.3.0.0"; |
54 | 54 |
|
55 | 55 | private string _tempMPD, _tempMPL, _source;
|
56 | 56 | private readonly DirectoryInfo _modPackDirectory;
|
@@ -423,7 +423,7 @@ public Task<List<OriginalModPackJson>> GetOriginalModPackJsonData(DirectoryInfo
|
423 | 423 | /// </summary>
|
424 | 424 | /// <param name="modPackDirectory">The mod pack directory</param>
|
425 | 425 | /// <returns>The version of the mod pack as a string</returns>
|
426 |
| - public string GetVersion(DirectoryInfo modPackDirectory) |
| 426 | + public static string GetVersion(DirectoryInfo modPackDirectory) |
427 | 427 | {
|
428 | 428 | ModPackJson modPackJson = null;
|
429 | 429 |
|
@@ -529,6 +529,7 @@ await Task.Run(async () =>
|
529 | 529 |
|
530 | 530 | var _modding = new Modding(XivCache.GameInfo.GameDirectory);
|
531 | 531 | var modList = _modding.GetModList();
|
| 532 | + var needsTexFix = DoesTexNeedFixing(modPackDirectory); |
532 | 533 |
|
533 | 534 | // 0 - Extract the MPD file.
|
534 | 535 | using (var zf = ZipFile.Read(modPackDirectory.FullName))
|
@@ -572,6 +573,10 @@ await Task.Run(async () =>
|
572 | 573 | {
|
573 | 574 | binaryReader.BaseStream.Seek(modJson.ModOffset, SeekOrigin.Begin);
|
574 | 575 | var data = binaryReader.ReadBytes(modJson.ModSize);
|
| 576 | + |
| 577 | + if (modJson.FullPath.EndsWith(".tex") && needsTexFix) |
| 578 | + FixupTextoolsTex(data); |
| 579 | + |
575 | 580 | var df = IOUtil.GetDataFileFromPath(modJson.FullPath);
|
576 | 581 |
|
577 | 582 | var size = data.Length;
|
@@ -953,6 +958,46 @@ await Task.Run(async () =>
|
953 | 958 | return (count, errorCount, importErrors, seconds);
|
954 | 959 | }
|
955 | 960 |
|
| 961 | + /// <summary> |
| 962 | + /// Parse the version out of this modpack to determine whether or not we need |
| 963 | + /// to add 80 to the uncompressed size of the Tex files contained within. |
| 964 | + /// </summary> |
| 965 | + /// <param name="mpd">The path to the modpack.</param> |
| 966 | + /// <returns>True if we must modify tex header uncompressed sizes, false otherwise.</returns> |
| 967 | + private static bool DoesTexNeedFixing(DirectoryInfo mpd) { |
| 968 | + |
| 969 | + var ver = GetVersion(mpd); |
| 970 | + if (string.IsNullOrEmpty(ver)) |
| 971 | + return true; |
| 972 | + |
| 973 | + var newVer = ver; |
| 974 | + |
| 975 | + var lastChar = ver.Substring(ver.Length - 1)[0]; |
| 976 | + if (char.IsLetter(lastChar)) |
| 977 | + newVer = ver.Substring(0, ver.Length - 1); |
| 978 | + |
| 979 | + double.TryParse(newVer, out var verDouble); |
| 980 | + |
| 981 | + return verDouble < 1.3; |
| 982 | + } |
| 983 | + |
| 984 | + /// <summary> |
| 985 | + /// Fix xivModdingFramework TEX quirks. |
| 986 | + /// </summary> |
| 987 | + /// <param name="tex">The TEX data to be fixed up.</param> |
| 988 | + public static void FixupTextoolsTex(byte[] tex) { |
| 989 | + |
| 990 | + // Read the uncompressed size from the file |
| 991 | + var size = BitConverter.ToInt32(tex, 8); |
| 992 | + var newSize = size + 80; |
| 993 | + |
| 994 | + byte[] buffer = BitConverter.GetBytes(newSize); |
| 995 | + tex[8] = buffer[0]; |
| 996 | + tex[9] = buffer[1]; |
| 997 | + tex[10] = buffer[2]; |
| 998 | + tex[11] = buffer[3]; |
| 999 | + } |
| 1000 | + |
956 | 1001 | /// <summary>
|
957 | 1002 | /// Gets the data type from an item path
|
958 | 1003 | /// </summary>
|
|
0 commit comments