Skip to content

Commit a7accd1

Browse files
committed
Beta v2.3.4.0b
2 parents 91740b3 + 9b977aa commit a7accd1

File tree

12 files changed

+576
-52
lines changed

12 files changed

+576
-52
lines changed

xivModdingFramework/Cache/XivDependencyGraph.cs

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -635,38 +635,41 @@ public async Task<List<string>> GetMaterialFiles(int materialVariant = -1, Index
635635
}
636636
}
637637

638-
if (materialVariant <= 0)
638+
if (mdlMats != null)
639639
{
640-
foreach (var mat in mdlMats)
640+
if (materialVariant <= 0)
641641
{
642-
var m = mat;
643-
644-
// Human types have their material ID automatically changed over.
645-
if (Info.PrimaryType == XivItemType.human && Info.SecondaryType != XivItemType.hair)
642+
foreach (var mat in mdlMats)
646643
{
647-
m = secondaryRex.Replace(m, secondaryTypePrefix + Info.SecondaryId.ToString().PadLeft(4, '0'));
644+
var m = mat;
645+
646+
// Human types have their material ID automatically changed over.
647+
if (Info.PrimaryType == XivItemType.human && Info.SecondaryType != XivItemType.hair)
648+
{
649+
m = secondaryRex.Replace(m, secondaryTypePrefix + Info.SecondaryId.ToString().PadLeft(4, '0'));
650+
}
651+
materials.Add(m);
648652
}
649-
materials.Add(m);
650653
}
651-
}
652-
else
653-
{
654-
var replacement = "v" + materialVariant.ToString().PadLeft(4, '0');
655-
foreach (var mat in mdlMats)
654+
else
656655
{
657-
// Replace any material set references with the new one.
658-
// The hash set will scrub us down to just a single copy.
659-
// This is faster than re-scanning the MDL file.
660-
// And a little more thorough than simply skipping over non-matching refs.
661-
// Since some materials may not have variant references.
662-
var m = _materialSetRegex.Replace(mat, replacement);
663-
664-
// Human types have their material ID automatically fixed to match.
665-
if (Info.PrimaryType == XivItemType.human && Info.SecondaryType != XivItemType.hair)
656+
var replacement = "v" + materialVariant.ToString().PadLeft(4, '0');
657+
foreach (var mat in mdlMats)
666658
{
667-
m = secondaryRex.Replace(m, secondaryTypePrefix + Info.SecondaryId.ToString().PadLeft(4, '0'));
659+
// Replace any material set references with the new one.
660+
// The hash set will scrub us down to just a single copy.
661+
// This is faster than re-scanning the MDL file.
662+
// And a little more thorough than simply skipping over non-matching refs.
663+
// Since some materials may not have variant references.
664+
var m = _materialSetRegex.Replace(mat, replacement);
665+
666+
// Human types have their material ID automatically fixed to match.
667+
if (Info.PrimaryType == XivItemType.human && Info.SecondaryType != XivItemType.hair)
668+
{
669+
m = secondaryRex.Replace(m, secondaryTypePrefix + Info.SecondaryId.ToString().PadLeft(4, '0'));
670+
}
671+
materials.Add(m);
668672
}
669-
materials.Add(m);
670673
}
671674
}
672675
}

xivModdingFramework/Helpers/IOUtil.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ public static async Task<byte[]> Decompressor(byte[] compressedBytes, int uncomp
7474
while ((bytesRead = await ds.ReadAsync(decompressedBytes, offset, uncompressedSize - offset)) > 0)
7575
{
7676
offset += bytesRead; // offset in buffer for results of next reading
77+
if (bytesRead == uncompressedSize) break;
7778
}
7879
}
7980
}

xivModdingFramework/Materials/DataContainers/XivMtrl.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public class XivMtrl
6262
/// </remarks>
6363
public ushort ColorSetDataSize { get {
6464
var size = ColorSetData.Count * 2;
65-
size += ColorSetExtraData == null ? 0 : ColorSetExtraData.Length;
65+
size += ColorSetDyeData == null ? 0 : ColorSetDyeData.Length;
6666
return (ushort) size;
6767
} }
6868

@@ -168,7 +168,7 @@ public ushort ColorSetDataSize { get {
168168
/// <summary>
169169
/// The byte array containing the extra ColorSet data
170170
/// </summary>
171-
public byte[] ColorSetExtraData { get; set; }
171+
public byte[] ColorSetDyeData { get; set; }
172172

173173
/// <summary>
174174
/// The size of the additional MTRL Data
@@ -534,17 +534,17 @@ public void SetShaderInfo(ShaderInfo info, bool forced = false)
534534
// ColorSetCount seems to always be 1, even when the data is empty.
535535
ColorSetCount = 1;
536536
ColorSetData = new List<Half>();
537-
ColorSetExtraData = null;
537+
ColorSetDyeData = null;
538538
} else
539539
{
540540
if(ColorSetCount == 0 || ColorSetData == null || ColorSetData.Count != 256)
541541
{
542542
// Get default Colorset Data.
543543
ColorSetData = Tex.GetColorsetDataFromDDS(Tex.GetDefaultTexturePath(XivTexType.ColorSet));
544544
}
545-
if(ColorSetExtraData == null || ColorSetExtraData.Length != 32)
545+
if(ColorSetDyeData == null || ColorSetDyeData.Length != 32)
546546
{
547-
ColorSetExtraData = Tex.GetColorsetExtraDataFromDDS(Tex.GetDefaultTexturePath(XivTexType.ColorSet));
547+
ColorSetDyeData = Tex.GetColorsetExtraDataFromDDS(Tex.GetDefaultTexturePath(XivTexType.ColorSet));
548548
}
549549
}
550550

xivModdingFramework/Materials/FileTypes/Mtrl.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ await Task.Run((Func<Task>)(async () =>
542542
xivMtrl.Unknown2 = br.ReadBytes(xivMtrl.UnknownDataSize);
543543

544544
xivMtrl.ColorSetData = new List<Half>();
545-
xivMtrl.ColorSetExtraData = null;
545+
xivMtrl.ColorSetDyeData = null;
546546
if (colorSetDataSize > 0)
547547
{
548548
// Color Data is always 512 (6 x 14 = 64 x 8bpp = 512)
@@ -556,7 +556,7 @@ await Task.Run((Func<Task>)(async () =>
556556
// If the color set is 544 in length, it has an extra 32 bytes at the end
557557
if (colorSetDataSize == 544)
558558
{
559-
xivMtrl.ColorSetExtraData = br.ReadBytes(32);
559+
xivMtrl.ColorSetDyeData = br.ReadBytes(32);
560560
}
561561
}
562562

@@ -681,7 +681,7 @@ public Task<XivTex> MtrlToXivTex(XivMtrl xivMtrl, TexTypePath ttp)
681681
/// <param name="race">The selected race for the item</param>
682682
public void SaveColorSetExtraData(IItem item, XivMtrl xivMtrl, DirectoryInfo saveDirectory, XivRace race)
683683
{
684-
var toWrite = xivMtrl.ColorSetExtraData != null ? xivMtrl.ColorSetExtraData : new byte[32];
684+
var toWrite = xivMtrl.ColorSetDyeData != null ? xivMtrl.ColorSetDyeData : new byte[32];
685685
var path = IOUtil.MakeItemSavePath(item, saveDirectory, race);
686686

687687
Directory.CreateDirectory(path);
@@ -868,7 +868,7 @@ public byte[] CreateMtrlFile(XivMtrl xivMtrl, IItem item)
868868

869869
if (xivMtrl.ColorSetDataSize == 544)
870870
{
871-
mtrlBytes.AddRange(xivMtrl.ColorSetExtraData);
871+
mtrlBytes.AddRange(xivMtrl.ColorSetDyeData);
872872
}
873873

874874

0 commit comments

Comments
 (0)