Skip to content

Commit 6a075b8

Browse files
committed
Update 2.3.1.9
2 parents bd9a4bf + 5348a00 commit 6a075b8

File tree

13 files changed

+644
-15
lines changed

13 files changed

+644
-15
lines changed

xivModdingFramework/Cache/XivDependencyGraph.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1816,6 +1816,13 @@ await Task.Run(() => {
18161816
var mdlFileHash = HashGenerator.GetHash(mdlFile);
18171817

18181818
var mtrlFile = "mt_" + nRoot.GetBaseFileName(true) + "_a.mtrl";
1819+
if(secondary == XivItemType.tail)
1820+
{
1821+
// Tail materials don't actually use their slot name, even though their model does,
1822+
// for whatever reason.
1823+
mtrlFile = "mt_" + nRoot.GetBaseFileName(false) + "_a.mtrl";
1824+
}
1825+
18191826
var mtrlFileHash = HashGenerator.GetHash(mtrlFile);
18201827

18211828
var hasModel = Hashes.ContainsKey(mfolderHash) && Hashes[mfolderHash].Contains(mdlFileHash);
@@ -1904,7 +1911,6 @@ public static async Task CacheAllRealRoots()
19041911
types[XivItemType.accessory].Add(XivItemType.none);
19051912
types[XivItemType.outdoor].Add(XivItemType.none);
19061913

1907-
19081914
var tasks = new List<Task<List<XivDependencyRootInfo>>>();
19091915
foreach (var kv in types)
19101916
{

xivModdingFramework/Items/Categories/Gear.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,7 @@ await Task.Run(() => Parallel.For(1, 200, (i) =>
745745
{XivStrings.Body_Hands_Legs, "top"},
746746
{XivStrings.Body_Legs_Feet, "top"},
747747
{XivStrings.Body_Hands_Legs_Feet, "top"},
748-
{XivStrings.Legs_Feet, "top"},
748+
{XivStrings.Legs_Feet, "dwn"},
749749
{XivStrings.All, "top"},
750750
{XivStrings.Face, "fac"},
751751
{XivStrings.Iris, "iri"},

xivModdingFramework/Models/FileTypes/Eqp.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -876,10 +876,10 @@ private async Task<ushort> GetRawEquipmentDeformationParameters(int equipmentId,
876876
return 0;
877877
}
878878

879-
var parameters = new byte[EquipmentParameterEntrySize];
879+
var parameters = new byte[EquipmentDeformerParameterEntrySize];
880880

881881

882-
for (var idx = 0; idx < EquipmentParameterEntrySize; idx++)
882+
for (var idx = 0; idx < EquipmentDeformerParameterEntrySize; idx++)
883883
{
884884
parameters[idx] = data[offset + idx];
885885
}
@@ -997,7 +997,7 @@ private byte[] ExpandEqdpBlock(byte[] eqdpData, int setId)
997997
}
998998
}
999999

1000-
ushort nextOffset = (ushort)(lastOffset > 0 ? (lastOffset + blockSize) : 0);
1000+
ushort nextOffset = (ushort)(lastOffset >= 0 ? (lastOffset + blockSize) : 0);
10011001
IOUtil.ReplaceBytesAt(eqdpData, BitConverter.GetBytes(nextOffset), headerEntryOffset);
10021002

10031003
// 6 Byte basic header, then block table.

xivModdingFramework/Models/FileTypes/Mdl.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2100,7 +2100,6 @@ await Task.Run(async () =>
21002100
// Time to pull in the Model Modifier for any extra steps before we pass
21012101
// it to the raw MDL creation function.
21022102

2103-
loggingFunction(false, "Merging in existing Attribute & Material Data...");
21042103

21052104
XivMdl ogMdl = null;
21062105

@@ -2116,6 +2115,8 @@ await Task.Run(async () =>
21162115
ogMdl = currentMdl;
21172116
}
21182117

2118+
loggingFunction(false, "Merging in existing Attribute & Material Data...");
2119+
21192120
// Apply our Model Modifier options to the model.
21202121
options.Apply(ttModel, currentMdl, ogMdl, loggingFunction);
21212122

@@ -4568,7 +4569,7 @@ public async Task<string> GetMdlPath(IItemModel itemModel, XivRace xivRace, stri
45684569
{XivStrings.Head_Body, "top"},
45694570
{XivStrings.Body_Hands, "top"},
45704571
{XivStrings.Body_Hands_Legs, "top"},
4571-
{XivStrings.Body_Legs_Feet, "top"},
4572+
{XivStrings.Body_Legs_Feet, "dwn"},
45724573
{XivStrings.Body_Hands_Legs_Feet, "top"},
45734574
{XivStrings.Legs_Feet, "top"},
45744575
{XivStrings.All, "top"},

xivModdingFramework/Models/FileTypes/Sklb.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ private static async Task<string> GetExtraSkelbPath(XivDependencyRootInfo root,
298298
}
299299

300300
// Hair and face types have a race defined at root level.
301-
if ((type == Est.EstType.Face || type == Est.EstType.Hair) && race != XivRace.All_Races)
301+
if ((type == Est.EstType.Face || type == Est.EstType.Hair) && race == XivRace.All_Races)
302302
{
303303
var ret = new Dictionary<XivRace, ExtraSkeletonEntry>();
304304
race = XivRaces.GetXivRace(root.PrimaryId);

xivModdingFramework/Models/Helpers/ModelModifiers.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,10 @@ public static void MergeShapeData(TTModel ttModel, XivMdl ogMdl, Action<bool, st
686686
// Because we're using the index offset that's relative to the original model's mesh group index list.
687687
var indexId = d.BaseIndex;
688688

689-
ttPart.Replacements.Add(indexId, vertexId);
689+
if (!ttPart.Replacements.ContainsKey(indexId))
690+
{
691+
ttPart.Replacements.Add(indexId, vertexId);
692+
}
690693
}
691694
newGroup.ShapeParts.Add(ttPart);
692695
}

xivModdingFramework/Mods/FileTypes/ItemMetadata.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Collections.Generic;
33
using System.IO;
44
using System.Linq;
5+
using System.Net.NetworkInformation;
56
using System.Runtime.CompilerServices;
67
using System.Security.Cryptography;
78
using System.Text;
@@ -88,6 +89,31 @@ public ItemMetadata(XivDependencyRoot root)
8889
Root = root;
8990
}
9091

92+
/// <summary>
93+
/// Validates this metadata file to ensure it is being written to the correct location.
94+
/// </summary>
95+
public void Validate(string path)
96+
{
97+
const string prefix = "INVALID METADATA ERROR: ";
98+
if (Root == null)
99+
{
100+
throw new InvalidDataException(prefix + "Internal Root is NULL.");
101+
}
102+
103+
if(Root.Info.GetRootFile() != path)
104+
{
105+
throw new InvalidDataException(prefix + "Internal file path not match destination file path.");
106+
}
107+
108+
foreach(var entry in EstEntries)
109+
{
110+
if(entry.Value.SetId != Root.Info.PrimaryId && entry.Value.SetId != Root.Info.SecondaryId)
111+
{
112+
throw new InvalidDataException(prefix + "Extra Skeleton Table entries do not match internal set number.");
113+
}
114+
}
115+
}
116+
91117
/// <summary>
92118
/// Gets the metadata file for an IItem entry
93119
/// </summary>

xivModdingFramework/Mods/Modding.cs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,8 @@ public async Task<bool> ToggleModUnsafe(bool enable, Mod mod, bool includeIntern
379379
var data = await dat.GetType2Data(mod.fullPath, false);
380380
var meta = await ItemMetadata.Deserialize(data);
381381

382+
meta.Validate(mod.fullPath);
383+
382384
// And write that metadata to the actual constituent files.
383385
await ItemMetadata.ApplyMetadata(meta);
384386
}
@@ -436,9 +438,9 @@ public async Task ToggleAllMods(bool enable, IProgress<(int current, int total,
436438
progress?.Report((++modNum, modList.Mods.Count, string.Empty));
437439
}
438440

439-
if (includeInternal)
441+
if (includeInternal && !enable)
440442
{
441-
// Disable these last, just to avoid any potential strangeness.
443+
// Disable these last.
442444
var internalEntries = modList.Mods.Where(x => x.IsInternal());
443445
foreach (var modEntry in internalEntries)
444446
{
@@ -449,6 +451,17 @@ public async Task ToggleAllMods(bool enable, IProgress<(int current, int total,
449451

450452
SaveModList(modList);
451453

454+
if (includeInternal && !enable)
455+
{
456+
// Now go ahead and delete the internal files, to prevent them
457+
// being accidentally re-enabled (They should be re-built by the metadata file imports)
458+
var internalEntries = modList.Mods.Where(x => x.IsInternal());
459+
foreach (var modEntry in internalEntries)
460+
{
461+
await DeleteMod(modEntry.fullPath, true);
462+
}
463+
}
464+
452465

453466
// Do these as a batch query at the end.
454467
progress?.Report((++modNum, modList.Mods.Count, "Adding modified files to Cache Queue..."));

xivModdingFramework/Mods/RootCloner.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,23 @@ public static async Task CloneRoot(XivDependencyRoot Source, XivDependencyRoot D
353353
{
354354
ProgressReporter.Report("Copying metdata...");
355355
}
356+
357+
// Poke through the variants and adjust any that point to null Material Sets to instead use a valid one.
358+
var valid = newMetadata.ImcEntries.FirstOrDefault(x => x.MaterialSet != 0).MaterialSet;
359+
if(valid <= 0)
360+
{
361+
valid = originalMetadata.ImcEntries.FirstOrDefault(x => x.MaterialSet != 0).MaterialSet;
362+
}
363+
364+
for(int i = 0; i < newMetadata.ImcEntries.Count; i++)
365+
{
366+
var entry = newMetadata.ImcEntries[i];
367+
if (entry.MaterialSet == 0)
368+
{
369+
entry.MaterialSet = valid;
370+
}
371+
}
372+
356373
// Save the new Metadata file.
357374
await ItemMetadata.SaveMetadata(newMetadata, ApplicationSource);
358375

0 commit comments

Comments
 (0)