Skip to content

Commit 42370cb

Browse files
committed
Update 2.3.0.1
2 parents ebf94d0 + fd4e936 commit 42370cb

File tree

2 files changed

+40
-6
lines changed

2 files changed

+40
-6
lines changed

xivModdingFramework/Cache/XivDependencyGraph.cs

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -503,9 +503,28 @@ public async Task<List<string>> GetModelFiles()
503503
var housingAssets = await _housing.GetFurnitureModelParts(Info.PrimaryId, Info.PrimaryType);
504504
return housingAssets.Select(x => x.Value).ToList();
505505
} else {
506+
507+
506508
// The rest of the types just have a single, calculateable model path.
507509
var folder = Info.GetRootFolder();
508-
var modelPath = folder + "model/" + Info.GetSimpleModelName();
510+
var modelFolder = folder + "model";
511+
var modelPath = modelFolder + "/" + Info.GetSimpleModelName();
512+
513+
514+
if (Info.PrimaryType == XivItemType.human && Info.SecondaryId / 100 >= 1)
515+
{
516+
// For human types, if their model is missing, the version 00xx is used instead.
517+
var index = new Index(XivCache.GameInfo.GameDirectory);
518+
if(!(await index.FileExists(modelPath)))
519+
{
520+
var replacementNumber = (Info.SecondaryId % 100);
521+
var alteredRoot = new XivDependencyRoot(Info.PrimaryType, Info.PrimaryId, Info.SecondaryType, replacementNumber, Info.Slot);
522+
523+
return await alteredRoot.GetModelFiles();
524+
}
525+
526+
}
527+
509528
return new List<string>() { modelPath };
510529
}
511530

@@ -547,16 +566,31 @@ public async Task<List<string>> GetMaterialFiles(int materialVariant = -1)
547566
if (models != null && models.Count > 0)
548567
{
549568
var dataFile = IOUtil.GetDataFileFromPath(models[0]);
569+
550570
var _mdl = new Mdl(XivCache.GameInfo.GameDirectory, dataFile);
551571

572+
Regex secondaryRex = null;
573+
string secondaryTypePrefix = null;
574+
if (Info.PrimaryType == XivItemType.human) {
575+
secondaryTypePrefix = XivItemTypes.GetSystemPrefix((XivItemType)Info.SecondaryType);
576+
secondaryRex = new Regex("(" + secondaryTypePrefix +"[0-9]{4})");
577+
}
578+
552579
foreach (var model in models)
553580
{
554581
var mdlMats = await XivCache.GetChildFiles(model);
555-
if (materialVariant < 0)
582+
if (materialVariant <= 0)
556583
{
557584
foreach (var mat in mdlMats)
558585
{
559-
materials.Add(mat);
586+
var m = mat;
587+
588+
// Human types have their material ID automatically changed over.
589+
if (Info.PrimaryType == XivItemType.human)
590+
{
591+
m = secondaryRex.Replace(m, secondaryTypePrefix + Info.SecondaryId.ToString().PadLeft(4, '0'));
592+
}
593+
materials.Add(m);
560594
}
561595
}
562596
else
@@ -899,7 +933,7 @@ public async Task<List<IItemModel>> GetAllItems(int imcSubset = -1)
899933
}
900934

901935
/// For these types we also want to read their IMC file to fill in any missing NPC only versions.
902-
if (Info.PrimaryType == XivItemType.equipment || Info.PrimaryType == XivItemType.accessory || Info.PrimaryType == XivItemType.weapon)
936+
if (Imc.UsesImc(this))
903937
{
904938
var imc = new Imc(XivCache.GameInfo.GameDirectory);
905939
var imcPaths = await GetImcEntryPaths();

xivModdingFramework/Materials/FileTypes/Mtrl.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,9 +1072,9 @@ public static async Task<int> GetMaterialSetId(IItem item)
10721072
var root = item.GetRootInfo();
10731073
if (root == null) return -1;
10741074

1075-
if (root.SecondaryType == XivItemType.hair ||
1075+
if (root.PrimaryType == XivItemType.human && (root.SecondaryType == XivItemType.hair ||
10761076
root.SecondaryType == XivItemType.body ||
1077-
root.SecondaryType == XivItemType.tail)
1077+
root.SecondaryType == XivItemType.tail))
10781078
{
10791079
return 1;
10801080
}

0 commit comments

Comments
 (0)