Skip to content

Commit 6ba431c

Browse files
committed
- Enable force-scanning for all possible furniture roots.
1 parent f8c592a commit 6ba431c

File tree

1 file changed

+70
-29
lines changed

1 file changed

+70
-29
lines changed

xivModdingFramework/Cache/XivDependencyGraph.cs

Lines changed: 70 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,22 @@ public string GetRacialModelName(XivRace race)
278278
{
279279
return GetRacialModelName(Int32.Parse(XivRaces.GetRaceCode(race)));
280280
}
281+
282+
/// <summary>
283+
/// Calculates and returns the SGD file name for this root.
284+
/// </summary>
285+
/// <returns></returns>
286+
public string GetSgdName()
287+
{
288+
if (PrimaryType != XivItemType.indoor && PrimaryType != XivItemType.outdoor)
289+
{
290+
throw new NotSupportedException("Cannot get SGB File for Non-Furniture item type.");
291+
}
292+
293+
var assetFile = $"{Slot}_b0_m{PrimaryId.ToString().PadLeft(4, '0')}.sgb";
294+
return assetFile;
295+
}
296+
281297
public string GetRacialModelName(int raceRaw)
282298
{
283299
if (SecondaryType != null)
@@ -1592,29 +1608,48 @@ await Task.Run(() => {
15921608

15931609
if (secondary == XivItemType.none)
15941610
{
1595-
var folder = root.GetRootFolder() + "model";
1596-
var folderHash = HashGenerator.GetHash(folder);
1597-
var slots = XivItemTypes.GetAvailableSlots(root.PrimaryType);
1611+
if (primary == XivItemType.indoor || primary == XivItemType.outdoor)
1612+
{
1613+
// For furniture, they're valid as long as they have an SGD file we can find.
1614+
root.Slot = primary == XivItemType.indoor ? "fun" : "gar";
1615+
1616+
var folder = root.GetRootFolder() + "asset";
1617+
var file = root.GetSgdName();
15981618

1599-
// For these, just let the EDP module verify if there are any races availble for the item?
1600-
foreach (var slot in slots)
1619+
var folderHash = HashGenerator.GetHash(folder);
1620+
var fileHash = HashGenerator.GetHash(file);
1621+
var key = fileHash.ToString() + folderHash.ToString();
1622+
if (combinedHashes.ContainsKey(key))
1623+
{
1624+
result.Add((XivDependencyRootInfo)root.Clone());
1625+
}
1626+
}
1627+
else
16011628
{
1602-
root.Slot = slot;
1629+
var folder = root.GetRootFolder() + "model";
1630+
var folderHash = HashGenerator.GetHash(folder);
1631+
var slots = XivItemTypes.GetAvailableSlots(root.PrimaryType);
16031632

1604-
// Check every possible race code, not just playables?
1605-
//for (int s = 0; s < 10000; p++)
1606-
foreach(var race in races)
1633+
// For these, just let the EDP module verify if there are any races availble for the item?
1634+
foreach (var slot in slots)
16071635
{
1608-
//var modelName = root.GetRacialModelName(s);
1609-
var modelName = root.GetRacialModelName(race);
1610-
var fileHash = HashGenerator.GetHash(modelName);
1611-
var key = fileHash.ToString() + folderHash.ToString();
1612-
if (combinedHashes.ContainsKey(key))
1613-
{
1614-
result.Add((XivDependencyRootInfo)root.Clone());
1636+
root.Slot = slot;
16151637

1616-
// We don't care how many models there are, just that there *are* any models.
1617-
break;
1638+
// Check every possible race code, not just playables?
1639+
//for (int s = 0; s < 10000; p++)
1640+
foreach (var race in races)
1641+
{
1642+
//var modelName = root.GetRacialModelName(s);
1643+
var modelName = root.GetRacialModelName(race);
1644+
var fileHash = HashGenerator.GetHash(modelName);
1645+
var key = fileHash.ToString() + folderHash.ToString();
1646+
if (combinedHashes.ContainsKey(key))
1647+
{
1648+
result.Add((XivDependencyRootInfo)root.Clone());
1649+
1650+
// We don't care how many models there are, just that there *are* any models.
1651+
break;
1652+
}
16181653
}
16191654
}
16201655
}
@@ -1634,13 +1669,6 @@ await Task.Run(() => {
16341669
slots = XivItemTypes.GetAvailableSlots(XivItemType.equipment);
16351670
}
16361671

1637-
// For these, just let the EDP module verify if there are any races availble for the item?
1638-
1639-
if (root.PrimaryId == 201 && root.SecondaryId == 56 && root.PrimaryType == XivItemType.weapon)
1640-
{
1641-
var z = "d";
1642-
}
1643-
16441672
if (slots.Count == 0)
16451673
{
16461674
slots.Add("");
@@ -1695,6 +1723,13 @@ public static async Task CacheAllRealRoots()
16951723
mergedDict.Add(kv.Key, new XivDependencyRootInfo());
16961724
}
16971725

1726+
var bgcHashes = await index.GetFileDictionary(XivDataFile._01_Bgcommon);
1727+
1728+
var bgcHashDict = new Dictionary<string, XivDependencyRootInfo>();
1729+
foreach (var kv in bgcHashes)
1730+
{
1731+
bgcHashDict.Add(kv.Key, new XivDependencyRootInfo());
1732+
}
16981733

16991734
var types = new Dictionary<XivItemType, List<XivItemType>>();
17001735
foreach (var type in DependencySupportedTypes)
@@ -1711,6 +1746,8 @@ public static async Task CacheAllRealRoots()
17111746
types[XivItemType.demihuman].Add(XivItemType.equipment);
17121747
types[XivItemType.equipment].Add(XivItemType.none);
17131748
types[XivItemType.accessory].Add(XivItemType.none);
1749+
types[XivItemType.indoor].Add(XivItemType.none);
1750+
types[XivItemType.outdoor].Add(XivItemType.none);
17141751

17151752

17161753

@@ -1720,10 +1757,14 @@ public static async Task CacheAllRealRoots()
17201757
var primary = kv.Key;
17211758
foreach (var secondary in kv.Value)
17221759
{
1723-
// Apparently despite all documentation, Dictionary.HasKey() is not actually
1724-
// thread safe? Or at least, we'll hit random failures to find dictionary keys if
1725-
// we don't clone the dictionary here. Unsure why.
1726-
tasks.Add(TestAllRoots(mergedDict, primary, secondary));
1760+
if (primary == XivItemType.indoor || primary == XivItemType.outdoor)
1761+
{
1762+
tasks.Add(TestAllRoots(bgcHashDict, primary, secondary));
1763+
}
1764+
else
1765+
{
1766+
tasks.Add(TestAllRoots(mergedDict, primary, secondary));
1767+
}
17271768
}
17281769
}
17291770
try

0 commit comments

Comments
 (0)