Skip to content

Commit caf5f0e

Browse files
committed
Update v3.0.5.6
2 parents 0ea2ed0 + 0c86623 commit caf5f0e

File tree

9 files changed

+131
-28
lines changed

9 files changed

+131
-28
lines changed

xivModdingFramework/Cache/XivDependencyRoot.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,10 @@ public string GetMaterialPath(XivRace race = XivRace.All_Races, string suffix =
283283
} else if (string.IsNullOrWhiteSpace(fakeSlot) && string.IsNullOrWhiteSpace(Slot))
284284
{
285285
// The base material we're starting from has no slot suffix.
286-
materialName = materialName.Replace("_" + Slot, "");
286+
if (!string.IsNullOrWhiteSpace(Slot))
287+
{
288+
materialName = materialName.Replace("_" + Slot, "");
289+
}
287290
}
288291

289292
if(!string.IsNullOrWhiteSpace(suffix))

xivModdingFramework/Helpers/IOUtil.cs

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -402,13 +402,16 @@ public static void DeleteTempDirectory(string dir)
402402
{
403403
return;
404404
}
405+
var time = DateTime.Now;
405406
if (dir.StartsWith(Path.GetTempPath()))
406407
{
407408
RecursiveDeleteDirectory(dir);
408409
} else if (dir.StartsWith(XivCache.FrameworkSettings.TempDirectory))
409410
{
410411
RecursiveDeleteDirectory(dir);
411412
}
413+
var duration = DateTime.Now - time;
414+
Trace.WriteLine("Deletion Time: " + duration);
412415
}
413416
public static void RecursiveDeleteDirectory(string dir)
414417
{
@@ -919,24 +922,5 @@ await Task.Run(async () =>
919922
}
920923
}
921924

922-
public static string GetPenumbraDirectory()
923-
{
924-
var path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "XIVLauncher", "pluginConfigs", "Penumbra.json");
925-
if (!File.Exists(path))
926-
{
927-
return "";
928-
}
929-
930-
try
931-
{
932-
var obj = JObject.Parse(File.ReadAllText(path));
933-
var st = (string) obj["ModDirectory"];
934-
return st;
935-
}
936-
catch(Exception ex)
937-
{
938-
return "";
939-
}
940-
}
941925
}
942926
}

xivModdingFramework/Helpers/PenumbraAPI.cs

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
using Newtonsoft.Json;
2+
using Newtonsoft.Json.Linq;
23
using System;
34
using System.Collections.Generic;
45
using System.Diagnostics;
6+
using System.IO;
7+
using System.Linq;
58
using System.Net.Http;
69
using System.Text;
710
using System.Threading.Tasks;
@@ -69,5 +72,63 @@ private static async Task<bool> Request(string urlPath, object data = null)
6972
}
7073

7174

75+
public static string GetPenumbraDirectory()
76+
{
77+
var path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "XIVLauncher", "pluginConfigs", "Penumbra.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["ModDirectory"];
87+
return st;
88+
}
89+
catch (Exception ex)
90+
{
91+
return "";
92+
}
93+
}
94+
public static bool IsPenumbraInstalled()
95+
{
96+
var path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "XIVLauncher", "dalamudConfig.json");
97+
if (!File.Exists(path))
98+
{
99+
return false;
100+
}
101+
102+
try
103+
{
104+
var obj = JObject.Parse(File.ReadAllText(path));
105+
var profile = (JObject)obj["DefaultProfile"];
106+
var plugins = (JObject)profile["Plugins"];
107+
var pValues = (JArray)plugins["$values"];
108+
109+
var penumbra = pValues.FirstOrDefault(x => (string)x["InternalName"] == "Penumbra");
110+
111+
if(penumbra != null)
112+
{
113+
// Normally we'd stop here. But while Penumbra is in testing we need to check that part.
114+
var optIns = (JObject)obj["PluginTestingOptIns"];
115+
var oValues = (JArray)optIns["$values"];
116+
var pTesting = oValues.FirstOrDefault(x => (string)x["InternalName"] == "Penumbra");
117+
if ((string)pTesting["Branch"] == "testing-live")
118+
{
119+
return true;
120+
}
121+
122+
return false;
123+
} else
124+
{
125+
return false;
126+
}
127+
}
128+
catch (Exception ex)
129+
{
130+
return false;
131+
}
132+
}
72133
}
73134
}

xivModdingFramework/Items/Categories/Character.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public Task<List<XivCharacter>> GetUnCachedCharacterList(ModTransaction tx = nul
7979
var c2 = (XivCharacter)c.Clone();
8080
c2.ModelInfo.SecondaryID = id;
8181
c2.TertiaryCategory = c.Name;
82-
c2.Name = c2.SecondaryCategory + " " + id;
82+
c2.Name = race.GetDisplayName() + " " + c2.SecondaryCategory + " " + id;
8383
characterList.Add(c2);
8484
}
8585
}
@@ -97,7 +97,7 @@ public Task<List<XivCharacter>> GetUnCachedCharacterList(ModTransaction tx = nul
9797
var c2 = (XivCharacter)c.Clone();
9898
c2.ModelInfo.SecondaryID = id;
9999
c2.TertiaryCategory = c.Name;
100-
c2.Name = c2.SecondaryCategory + " " + id;
100+
c2.Name = race.GetDisplayName() + " " + c2.SecondaryCategory + " " + id;
101101
characterList.Add(c2);
102102
}
103103
}
@@ -116,7 +116,7 @@ public Task<List<XivCharacter>> GetUnCachedCharacterList(ModTransaction tx = nul
116116
var c2 = (XivCharacter)c.Clone();
117117
c2.ModelInfo.SecondaryID = id;
118118
c2.TertiaryCategory = c.Name;
119-
c2.Name = c2.SecondaryCategory + " " + id;
119+
c2.Name = race.GetDisplayName() + " " + c2.SecondaryCategory + " " + id;
120120
characterList.Add(c2);
121121
}
122122
}
@@ -135,7 +135,7 @@ public Task<List<XivCharacter>> GetUnCachedCharacterList(ModTransaction tx = nul
135135
var c2 = (XivCharacter)c.Clone();
136136
c2.ModelInfo.SecondaryID = id;
137137
c2.TertiaryCategory = c.Name;
138-
c2.Name = c2.SecondaryCategory + " " + id;
138+
c2.Name = race.GetDisplayName() + " " + c2.SecondaryCategory + " " + id;
139139
characterList.Add(c2);
140140
}
141141
}
@@ -154,7 +154,7 @@ public Task<List<XivCharacter>> GetUnCachedCharacterList(ModTransaction tx = nul
154154
var c2 = (XivCharacter)c.Clone();
155155
c2.ModelInfo.SecondaryID = id;
156156
c2.TertiaryCategory = c.Name;
157-
c2.Name = c2.SecondaryCategory + " " + id;
157+
c2.Name = race.GetDisplayName() + " " + c2.SecondaryCategory + " " + id;
158158
characterList.Add(c2);
159159
}
160160
}

xivModdingFramework/Mods/DataContainers/ModList.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ protected virtual void INTERNAL_AddOrUpdateMod(Mod mod)
8989
{
9090
throw new Exception("Cannot add NULL path mod.");
9191
}
92+
Dat.AssertOriginalOffsetIsSafe(mod.DataFile, mod.OriginalOffset8x);
9293

9394
if (_Mods.ContainsKey(mod.FilePath))
9495
{

xivModdingFramework/Mods/FileTypes/TTMP.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -770,6 +770,7 @@ await Task.Run(async () =>
770770
mod.ModPack = modJson.ModPackEntry == null ? "" : modJson.ModPackEntry.Value.Name;
771771
mod.SourceApplication = settings.SourceApplication;
772772

773+
Dat.AssertOriginalOffsetIsSafe(mod.DataFile, mod.OriginalOffset8x);
773774
modList.AddOrUpdateMod(mod);
774775

775776
// Add the modpack if we haven't already.

xivModdingFramework/Mods/WizardData.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -980,6 +980,8 @@ public class WizardMetaEntry
980980
public string Version = "1.0";
981981
public string Image = "";
982982

983+
public List<string> Tags = new List<string>();
984+
983985
public static WizardMetaEntry FromPMP(PMPJson pmp, string unzipPath)
984986
{
985987
var meta = pmp.Meta;
@@ -989,6 +991,7 @@ public static WizardMetaEntry FromPMP(PMPJson pmp, string unzipPath)
989991
page.Author = meta.Author;
990992
page.Description = meta.Description;
991993
page.Name = meta.Name;
994+
page.Tags = meta.Tags;
992995

993996

994997
if (!string.IsNullOrWhiteSpace(meta.Image))
@@ -1451,6 +1454,7 @@ public async Task WritePmp(string targetPath, bool zip = true, bool saveExtraFil
14511454
pmp.Meta.Tags = new List<string>();
14521455
pmp.Meta.FileVersion = PMP._WriteFileVersion;
14531456
pmp.Meta.Image = WizardHelpers.WriteImage(MetaPage.Image, tempFolder, "_MetaImage");
1457+
pmp.Meta.Tags = MetaPage.Tags;
14541458

14551459
var optionCount = DataPages.Sum(p => p.Groups.Sum(x => x.Options.Count));
14561460

xivModdingFramework/SqPack/DataContainers/IndexFile.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -517,10 +517,10 @@ public virtual uint GetRawDataOffset(string filePath)
517517
{
518518
// Check Index1
519519
var offset = GetRawDataOffsetIndex1(filePath);
520-
if(offset == 0)
520+
var offset2 = GetRawDataOffsetIndex2(filePath);
521+
if (offset != offset2)
521522
{
522-
// Check Index2.
523-
offset = GetRawDataOffsetIndex2(filePath);
523+
return 0;
524524
}
525525
return offset;
526526
}

xivModdingFramework/SqPack/FileTypes/Dat.cs

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,52 @@ private static bool IsOldTTDat(BinaryReader br)
275275
return true;
276276
}
277277

278+
public static void AssertOriginalOffsetIsSafe(XivDataFile df, long offset8x)
279+
{
280+
if(OriginalDats == null)
281+
{
282+
CacheOriginalDatList();
283+
}
284+
285+
if (!OriginalDats.ContainsKey(df))
286+
{
287+
throw new InvalidDataException("Original offset pointed to a Data File which did not exist.");
288+
}
289+
290+
if(offset8x == 0)
291+
{
292+
return;
293+
}
294+
295+
var parts = IOUtil.Offset8xToParts(offset8x);
296+
if (!OriginalDats[df].Contains(parts.DatNum))
297+
{
298+
throw new InvalidDataException("Original offset points to a Modded DAT file, cannot complete unsafe mod file write.");
299+
}
300+
301+
}
302+
303+
private static Dictionary<XivDataFile, List<int>> OriginalDats;
304+
internal static void CacheOriginalDatList()
305+
{
306+
OriginalDats = new Dictionary<XivDataFile, List<int>>();
307+
foreach (XivDataFile f in Enum.GetValues(typeof(XivDataFile)))
308+
{
309+
var datList = new List<int>();
310+
for (var i = 0; i < 8; i++)
311+
{
312+
var datFilePath = Dat.GetDatPath(f, i);
313+
if (File.Exists(datFilePath))
314+
{
315+
if (IsOriginalDat(f, i))
316+
{
317+
datList.Add(i);
318+
}
319+
}
320+
}
321+
OriginalDats.Add(f, datList);
322+
}
323+
}
278324

279325

280326
/// <summary>
@@ -1265,6 +1311,7 @@ public static async Task<long> WriteModFile(byte[] fileData, string internalFile
12651311

12661312
// Write to the Data store and update the index with the temporary offset.
12671313
var offset8x = await tx.UNSAFE_WriteData(df, fileData, compressed);
1314+
12681315
var originalOffset = await tx.Get8xDataOffset(internalFilePath, true);
12691316
await tx.Set8xDataOffset(internalFilePath, offset8x);
12701317

@@ -1313,6 +1360,8 @@ public static async Task<long> WriteModFile(byte[] fileData, string internalFile
13131360
mod.SourceApplication = sourceApplication;
13141361
}
13151362

1363+
Dat.AssertOriginalOffsetIsSafe(IOUtil.GetDataFileFromPath(internalFilePath), mod.OriginalOffset8x);
1364+
13161365
modList.AddOrUpdateMod(mod);
13171366

13181367
// Always expand metadata.

0 commit comments

Comments
 (0)