Skip to content

Commit d24a362

Browse files
committed
- Resolved an issue wherein material variants could be resolved incorrectly within transactional states with unexpanded metadata.
1 parent 230fc6f commit d24a362

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

xivModdingFramework/Models/FileTypes/Mdl.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
using xivModdingFramework.Cache;
5959
using xivModdingFramework.SqPack.DataContainers;
6060
using xivModdingFramework.Mods.DataContainers;
61+
using xivModdingFramework.Mods.FileTypes;
6162

6263
namespace xivModdingFramework.Models.FileTypes
6364
{
@@ -1699,8 +1700,10 @@ public async Task<List<string>> GetReferencedMaterialPaths(string mdlPath, int m
16991700
var dataFile = IOUtil.GetDataFileFromPath(mdlPath);
17001701
var _mtrl = new Mtrl(XivCache.GameInfo.GameDirectory);
17011702
var _imc = new Imc(_gameDirectory);
1703+
var useCached = true;
17021704
if (index == null)
17031705
{
1706+
useCached = false;
17041707
var _index = new Index(_gameDirectory);
17051708
var _modding = new Modding(_gameDirectory);
17061709
index = await _index.GetIndexFile(dataFile, false, true);
@@ -1711,6 +1714,7 @@ public async Task<List<string>> GetReferencedMaterialPaths(string mdlPath, int m
17111714

17121715
// Read the raw Material names from the file.
17131716
var materialNames = await GetReferencedMaterialNames(mdlPath, getOriginal, index, modlist);
1717+
var root = await XivCache.GetFirstRoot(mdlPath);
17141718
if(materialNames.Count == 0)
17151719
{
17161720
return materials;
@@ -1722,7 +1726,17 @@ public async Task<List<string>> GetReferencedMaterialPaths(string mdlPath, int m
17221726
// If we had a specific variant to get, just use that.
17231727
materialVariants.Add(materialVariant);
17241728

1725-
} else {
1729+
}
1730+
else if(useCached && root != null)
1731+
{
1732+
var metadata = await ItemMetadata.GetFromCachedIndex(root, index);
1733+
foreach (var entry in metadata.ImcEntries)
1734+
{
1735+
materialVariants.Add(entry.MaterialSet);
1736+
}
1737+
}
1738+
else
1739+
{
17261740

17271741
// Otherwise, we have to resolve all possible variants.
17281742
var imcPath = ItemType.GetIMCPathFromChildPath(mdlPath);

xivModdingFramework/Mods/FileTypes/TTMP.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -708,12 +708,15 @@ await Task.Run(async () =>
708708
if (fileKv.Key != fileKv.Value)
709709
{
710710
filesToReset.Add(fileKv.Key);
711-
712711
}
713712

714-
var mod = modList.Mods.First(x => x.fullPath == fileKv.Value);
715-
mod.modPack = modPack;
716713
filePaths.Remove(fileKv.Key);
714+
715+
var mod = modList.Mods.FirstOrDefault(x => x.fullPath == fileKv.Value);
716+
if (mod != null)
717+
{
718+
mod.modPack = modPack;
719+
}
717720
}
718721
}
719722

0 commit comments

Comments
 (0)