Skip to content

Commit 0542bf0

Browse files
committed
Update v3.0.7.4
2 parents b2b12ef + 650f0b1 commit 0542bf0

File tree

4 files changed

+82
-25
lines changed

4 files changed

+82
-25
lines changed

xivModdingFramework/Cache/XivDependencyRoot.cs

Lines changed: 38 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,23 @@ public XivDependencyRootInfo GetOtherSlot(string slot)
6868
};
6969
}
7070

71+
public bool IsHumanMaterialVersionException()
72+
{
73+
if (PrimaryType == XivItemType.human)
74+
{
75+
if(SecondaryType != null &&
76+
(SecondaryType == XivItemType.tail || SecondaryType == XivItemType.body))
77+
{
78+
if(PrimaryId == XivRace.Hrothgar_Female.GetRaceCodeInt()
79+
|| PrimaryId == XivRace.Hrothgar_Male.GetRaceCodeInt())
80+
{
81+
return true;
82+
}
83+
}
84+
}
85+
return false;
86+
}
87+
7188
/// <summary>
7289
/// Converts this dependency root into a raw string entry.
7390
/// </summary>
@@ -733,9 +750,28 @@ public async Task<List<string>> GetMaterialFiles(int materialVariant = -1, ModTr
733750

734751
index = await tx.GetIndexFile(df);
735752
modlist = await tx.GetModList();
736-
737753
var materials = new HashSet<string>();
738-
if (Info.PrimaryType == XivItemType.human && Info.SecondaryType == XivItemType.body)
754+
755+
if (Info.IsHumanMaterialVersionException())
756+
{
757+
// Special Hrothgar Cases.
758+
var primary = Info.PrimaryId.ToString("D4");
759+
var secondary = Info.SecondaryId.Value.ToString("D4");
760+
var path = $"chara/human/c{primary}/obj/body/b{secondary}/material/v0001/mt_c{primary}b{secondary}_a.mtrl";
761+
if(Info.SecondaryType == XivItemType.tail)
762+
{
763+
path = $"chara/human/c{primary}/obj/tail/t{secondary}/material/v0001/mt_c{primary}t{secondary}_a.mtrl";
764+
}
765+
766+
materials.Add(path);
767+
for (int i = 2; i <= 5; i++)
768+
{
769+
materials.Add(path.Replace("/v0001/", "/v000" + i + "/"));
770+
}
771+
772+
materialVariant = -1;
773+
}
774+
else if (Info.PrimaryType == XivItemType.human && Info.SecondaryType == XivItemType.body)
739775
{
740776
// Bleargh. So here's the exception of exception class. Because the "models" in human body are
741777
// are so sparse and all over the place, relying on them is impossible. Thankfully, body types only ever
@@ -745,27 +781,12 @@ public async Task<List<string>> GetMaterialFiles(int materialVariant = -1, ModTr
745781
var path = $"chara/human/c{primary}/obj/body/b{body}/material/v0001/mt_c{primary}b{body}_a.mtrl";
746782

747783
// Just validate it exists and call it a day.
748-
749784
var exists = index.FileExists(path);
750785
if (exists)
751786
{
752787
materials.Add(path);
753788
}
754789

755-
// XXX: I noticed female hrothgar also have patterns so I'm gonna put them here too
756-
if (Info.PrimaryId == XivRace.Hrothgar_Male.GetRaceCodeInt()
757-
|| Info.PrimaryId == XivRace.Hrothgar_Female.GetRaceCodeInt()
758-
)
759-
{
760-
// JK, Hrothgar actually have 5 material sets (that's how their fur pattern stuff is set)
761-
for (int i = 2; i <= 5; i++)
762-
{
763-
var mSet = i.ToString().PadLeft(4, '0');
764-
path = $"chara/human/c{primary}/obj/body/b{body}/material/v{mSet}/mt_c{primary}b{body}_a.mtrl";
765-
materials.Add(path);
766-
}
767-
}
768-
769790
materialVariant = -1;
770791
}
771792
else if (Info.PrimaryType == XivItemType.human && Info.SecondaryType != XivItemType.hair && Info.SecondaryId > 100)

xivModdingFramework/Helpers/PenumbraAPI.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,26 @@ private static async Task<bool> Request(string urlPath, object data = null)
7272
}
7373

7474

75+
public static string GetQuickLauncherGameDirectory()
76+
{
77+
var path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "XIVLauncher", "launcherConfigV3.json");
78+
if (!File.Exists(path))
79+
{
80+
return "";
81+
}
82+
83+
try
84+
{
85+
var obj = JObject.Parse(File.ReadAllText(path));
86+
var st = (string)obj["GamePath"];
87+
return st;
88+
}
89+
catch (Exception ex)
90+
{
91+
return "";
92+
}
93+
}
94+
7595
public static string GetPenumbraDirectory()
7696
{
7797
var path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "XIVLauncher", "pluginConfigs", "Penumbra.json");
@@ -91,6 +111,7 @@ public static string GetPenumbraDirectory()
91111
return "";
92112
}
93113
}
114+
94115
public static bool IsPenumbraInstalled()
95116
{
96117
var path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "XIVLauncher", "dalamudConfig.json");

xivModdingFramework/Models/DataContainers/TTModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2963,7 +2963,7 @@ public static void CheckCommonUserErrors(TTModel model, Action<bool, string> log
29632963
loggingFunction(true, "Mesh: " + mIdx + " Part: " + pIdx + " has a fully black Vertex Color channel. This can have unexpected results on in-game rendering. Was this intended?");
29642964
}
29652965

2966-
if (fullWhiteColor && m.Material.Contains("_iri_"))
2966+
if (fullWhiteColor && m.Material != null && m.Material.Contains("_iri_"))
29672967
{
29682968
loggingFunction(true, "Mesh: " + mIdx + " Part: " + pIdx + " has a fully white Vertex Color channel on an Iris material. This will break Heterochromia and cause discoloration. Was this intended?");
29692969
}

xivModdingFramework/Models/FileTypes/Mdl.cs

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -940,6 +940,7 @@ public static XivMdl GetXivMdl(byte[] mdlData, string mdlPath = "")
940940
xivMdl.BoneBoundingBoxes.Add(new List<Vector4>() { minPoint, maxPoint });
941941
}
942942

943+
var preBound = br.BaseStream.Position;
943944
xivMdl.BonelessPartBoundingBoxes = new List<List<Vector4>>();
944945
for (var i = 0; i < xivMdl.ModelData.FurniturePartBoundingBoxCount; i++)
945946
{
@@ -955,15 +956,29 @@ public static XivMdl GetXivMdl(byte[] mdlData, string mdlPath = "")
955956
// Attempts to catch weird broken mod mdls.
956957
// This has been known to occur with both certain penumbra MDLs, and very old
957958
// TexTools MDLs.
958-
if (xivMdl.LoDList[0].VertexDataOffset < br.BaseStream.Position
959-
|| (xivMdl.LoDList[0].VertexDataOffset % 8 != br.BaseStream.Position % 8))
959+
if (xivMdl.BonelessPartBoundingBoxes.Count != 0)
960960
{
961+
if(xivMdl.LoDList[0].VertexDataOffset == preBound)
962+
{
963+
foreach(var bl in xivMdl.BonelessPartBoundingBoxes)
964+
{
965+
bl[0] = new Vector4(0, 0, 0, 1);
966+
bl[1] = new Vector4(0, 0, 0, 1);
967+
}
968+
br.BaseStream.Seek(preBound, SeekOrigin.Begin);
969+
}
970+
}
971+
else {
972+
if (xivMdl.LoDList[0].VertexDataOffset < br.BaseStream.Position
973+
|| (xivMdl.LoDList[0].VertexDataOffset % 8 != br.BaseStream.Position % 8))
974+
{
961975

962-
var delta = (int) (xivMdl.LoDList[0].VertexDataOffset - br.BaseStream.Position);
963-
xivMdl.LoDList[0].VertexDataOffset -= delta;
964-
xivMdl.LoDList[0].IndexDataOffset -= delta;
965-
//var rem = br.ReadBytes(delta);
966-
var z = "z";
976+
var delta = (int)(xivMdl.LoDList[0].VertexDataOffset - br.BaseStream.Position);
977+
xivMdl.LoDList[0].VertexDataOffset -= delta;
978+
xivMdl.LoDList[0].IndexDataOffset -= delta;
979+
//var rem = br.ReadBytes(delta);
980+
var z = "z";
981+
}
967982
}
968983

969984

0 commit comments

Comments
 (0)