Skip to content

Commit a5be1a2

Browse files
committed
Update v2.1.0.1
2 parents f770bc7 + 1a23e23 commit a5be1a2

File tree

5 files changed

+80
-38
lines changed

5 files changed

+80
-38
lines changed

xivModdingFramework/Items/Categories/Gear.cs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -736,6 +736,46 @@ public async Task<List<IItemModel>> GetSameModelList(IItemModel item)
736736
&& it.ModelInfo.SecondaryID == item.ModelInfo.SecondaryID
737737
&& it.SecondaryCategory == item.SecondaryCategory).Select(it => it as IItemModel).ToList()
738738
);
739+
740+
// We don't really care which sub-model gets returned here, we just need a path to pull the data file off of.
741+
var imc = new Imc(_gameDirectory, item.DataFile);
742+
743+
// Language doesn't actually matter for the tests we're doing here.
744+
var info = await imc.GetFullImcInfo(item);
745+
var slot = item.GetItemSlotAbbreviation();
746+
var imcEntries = info.GetAllEntries(slot);
747+
748+
// Need to verify all of our IMC sets are properly represented in the item list.
749+
for (int i = 0; i < imcEntries.Count; i++)
750+
{
751+
// Already in it. All set.
752+
if (sameModelItems.Any(x => x.ModelInfo.ImcSubsetID == i)) continue;
753+
754+
// Need to create a new item for it.
755+
var npcItem = new XivGear()
756+
{
757+
Name = "NPC Equipment e" + item.ModelInfo.PrimaryID + " " + slot + " IMC Variant " + i,
758+
ModelInfo = new XivGearModelInfo(),
759+
PrimaryCategory = item.PrimaryCategory,
760+
SecondaryCategory = item.SecondaryCategory,
761+
TertiaryCategory = item.TertiaryCategory,
762+
DataFile = item.DataFile,
763+
};
764+
npcItem.ModelInfo.PrimaryID = item.ModelInfo.PrimaryID;
765+
npcItem.ModelInfo.SecondaryID = item.ModelInfo.SecondaryID;
766+
npcItem.ModelInfo.ImcSubsetID = i;
767+
try
768+
{
769+
((XivGearModelInfo)npcItem.ModelInfo).IsWeapon = ((XivGearModelInfo)item.ModelInfo).IsWeapon;
770+
}
771+
catch
772+
{
773+
// No-op. Should never actually get here, but safety check on the cast.
774+
}
775+
776+
sameModelItems.Add(npcItem);
777+
}
778+
739779
}
740780
else
741781
{

xivModdingFramework/Models/FileTypes/Dae.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,6 +1019,8 @@ public TTModel ReadColladaFile(DirectoryInfo daeLocation, Action<bool, string> l
10191019
throw ex;
10201020
}
10211021

1022+
ModelModifiers.MakeImportReady(ttModel);
1023+
10221024
return ttModel;
10231025
}
10241026

xivModdingFramework/Models/FileTypes/Mdl.cs

Lines changed: 11 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -372,42 +372,6 @@ private async Task ExportMaterialsForModel(TTModel model, string outputFilePath,
372372
}
373373
}
374374

375-
/// <summary>
376-
/// Retrieves all items that share the same model.
377-
/// </summary>
378-
/// <param name="item"></param>
379-
/// <param name="language"></param>
380-
/// <returns></returns>
381-
public async Task<List<IItemModel>> GetSameModelList(IItemModel item, XivLanguage language = XivLanguage.English)
382-
{
383-
var sameModelItems = new List<IItemModel>();
384-
var gear = new Gear(_gameDirectory, language);
385-
var character = new Character(_gameDirectory, language);
386-
var companions = new Companions(_gameDirectory, language);
387-
var ui = new UI(_gameDirectory, language);
388-
var housing = new Housing(_gameDirectory, language);
389-
390-
if (item.PrimaryCategory.Equals(XivStrings.Gear))
391-
{
392-
393-
// Scan the gear list for anything using the same model ID and slot.
394-
sameModelItems.AddRange(
395-
(await gear.GetGearList())
396-
.Where(it =>
397-
it.ModelInfo.PrimaryID == item.ModelInfo.PrimaryID
398-
&& it.SecondaryCategory == item.SecondaryCategory).Select(it => it as IItemModel).ToList()
399-
);
400-
}
401-
else if (item.PrimaryCategory.Equals(XivStrings.Character))
402-
{
403-
404-
// Character models are assumed to have no shared models,
405-
// So return a copy of the original item.
406-
sameModelItems.Add((IItemModel)item.Clone());
407-
}
408-
return sameModelItems;
409-
}
410-
411375

412376
/// <summary>
413377
/// Retreives the high level TTModel representation of an underlying MDL file.
@@ -448,15 +412,16 @@ public async Task<XivMdl> GetRawMdlData(string mdlPath, bool getOriginal = false
448412
var index = new Index(_gameDirectory);
449413
var dat = new Dat(_gameDirectory);
450414
var modding = new Modding(_gameDirectory);
415+
var mod = await modding.TryGetModEntry(mdlPath);
416+
var modded = mod != null && mod.enabled;
451417
var getShapeData = true;
452418

453419

454420
var offset = await index.GetDataOffset(mdlPath);
455421

456422
if (getOriginal)
457423
{
458-
var mod = await modding.TryGetModEntry(mdlPath);
459-
if (mod != null && mod.enabled)
424+
if (modded)
460425
{
461426
offset = mod.data.originalOffset;
462427
}
@@ -684,6 +649,13 @@ public async Task<XivMdl> GetRawMdlData(string mdlPath, bool getOriginal = false
684649
lod.MeshCount = 1;
685650
}
686651

652+
// This is a simple check to identify old mods that may have broken shape data.
653+
// Old mods still have LoD 1+ data.
654+
if (modded && i > 0 && lod.MeshCount > 0)
655+
{
656+
getShapeData = false;
657+
}
658+
687659
//Adding to xivMdl
688660
xivMdl.LoDList.Add(lod);
689661
}
@@ -729,6 +701,7 @@ public async Task<XivMdl> GetRawMdlData(string mdlPath, bool getOriginal = false
729701
}
730702
}
731703

704+
732705
// Now that we have the LoD data, we can go back and read the Vertex Data Structures
733706
// First we save our current position
734707
var savePosition = br.BaseStream.Position;

xivModdingFramework/Models/ModelTextures/ModelTexture.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,23 @@ public static async Task<ModelTextureData> GetModelMaps(Tex tex, XivMtrl mtrl, C
166166
specularPixels = texMapData.Specular.Data;
167167
}
168168

169+
if(normalPixels == null && diffusePixels == null)
170+
{
171+
// This material doesn't actually have any readable data.
172+
173+
var empty = new ModelTextureData
174+
{
175+
Width = 0,
176+
Height = 0,
177+
Normal = new byte[0],
178+
Diffuse = new byte[0],
179+
Specular = new byte[0],
180+
Emissive = new byte[0],
181+
Alpha = new byte[0]
182+
};
183+
return empty;
184+
}
185+
169186
var dataLength = normalPixels != null ? normalPixels.Length : diffusePixels.Length;
170187

171188
await Task.Run(() =>

xivModdingFramework/Variants/FileTypes/Imc.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,16 @@ public int SubsetSize
392392
/// </summary>
393393
public List<XivImc> DefaultSubset { get; set; }
394394

395+
// Gets all (non-default) IMC entries for a given slot.
396+
public List<XivImc> GetAllEntries(string slot = "")
397+
{
398+
var ret = new List<XivImc>(SubsetList.Count);
399+
for(int i = 0; i < SubsetList.Count; i++)
400+
{
401+
ret.Add(GetEntry(i, slot));
402+
}
403+
return ret;
404+
}
395405

396406
/// <summary>
397407
/// Retrieve a given IMC info. Negative values retrieve the default set.

0 commit comments

Comments
 (0)