Skip to content

Commit 94b86a1

Browse files
committed
Allow creation of new IMC files.
1 parent 6bc573d commit 94b86a1

File tree

1 file changed

+30
-11
lines changed
  • xivModdingFramework/Variants/FileTypes

1 file changed

+30
-11
lines changed

xivModdingFramework/Variants/FileTypes/Imc.cs

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,36 @@ public async Task<List<XivImc>> GetEntries(List<string> pathsWithOffsets, bool f
235235
internal async Task SaveEntries(string path, string slot, List<XivImc> entries)
236236
{
237237
var dat = new Dat(_gameDirectory);
238-
//var imcByteData = await dat.GetType2Data(path, false);
239-
var info = await GetFullImcInfo(path);
238+
var index = new Index(_gameDirectory);
239+
240+
var exists = await index.FileExists(path);
241+
FullImcInfo info;
242+
if(exists)
243+
{
244+
info = await GetFullImcInfo(path);
245+
} else
246+
{
247+
var ri = XivDependencyGraph.ExtractRootInfo(path);
248+
if (ri.SecondaryType == null)
249+
{
250+
info = new FullImcInfo()
251+
{
252+
DefaultSubset = new List<XivImc>() { new XivImc(), new XivImc(), new XivImc(), new XivImc(), new XivImc() },
253+
SubsetList = new List<List<XivImc>>(),
254+
TypeIdentifier = ImcType.Set
255+
};
256+
} else
257+
{
258+
info = new FullImcInfo()
259+
{
260+
DefaultSubset = new List<XivImc>() { new XivImc() },
261+
SubsetList = new List<List<XivImc>>(),
262+
TypeIdentifier = ImcType.NonSet
263+
};
264+
}
265+
}
266+
267+
240268
for(int i = 0; i < entries.Count; i++)
241269
{
242270
XivImc e;
@@ -452,15 +480,6 @@ public async Task SaveFullImcInfo(FullImcInfo info, string path, string itemName
452480
var index = new Index(_gameDirectory);
453481
var dat = new Dat(_gameDirectory);
454482

455-
456-
var imcOffset = await index.GetDataOffset(path);
457-
458-
// No writing new IMC files.
459-
if (imcOffset == 0)
460-
{
461-
throw new InvalidDataException($"Could not find offset for {path}");
462-
}
463-
464483
var data = new List<byte>();
465484

466485
// 4 Header bytes.

0 commit comments

Comments
 (0)