diff --git a/BlueprintPurge/BlueprintPurge.cs b/BlueprintPurge/BlueprintPurge.cs index 6e5880c..a13d86f 100644 --- a/BlueprintPurge/BlueprintPurge.cs +++ b/BlueprintPurge/BlueprintPurge.cs @@ -117,8 +117,8 @@ private void ButtonSearch_Click(object sender, EventArgs e) { if (Guid.TryParse(bp, out var guid)) blueprints.Add(guid); - else if (rxAlphaNumerical.IsMatch(bp)) - types.Add(", " + bp); + else //if (rxAlphaNumerical.IsMatch(bp)) + types.Add(/*", " + */bp); } if (blueprints.Count == 0 && types.Count == 0) @@ -194,7 +194,7 @@ private void Search(ZipEntry entry) } // if it's an type, check if it's blacklisted - else if (isType && this.types.Any(a => quote.EndsWith(a))) + else if (isType && this.types.Any(a => quote.Contains(a))) { // get id, if it has any if (lastId.TryGetValue(stack.Count, out var id)) @@ -297,7 +297,7 @@ private void Cleanup() break; } - // include tailing comma + // include tailing comma; check if last entry in list if (!purge.IsList) { for (int j = purge.End + 1; j < purge.Data.Length; j++) @@ -305,8 +305,10 @@ private void Cleanup() char c = (char)purge.Data[j]; if (char.IsWhiteSpace(c)) continue; - if (c == ',') + else if (c == ',') purge.End = j; + else if (c == ']' || c == '}') + purge.IsLastInList = true; break; } } @@ -382,6 +384,20 @@ private void ButtonPurge_Click(object sender, EventArgs e) // simply clear all chars for (int i = purge.Start; i <= purge.End; i++) purge.Data[i] = (byte)' '; + + // remove preceding comma + if (purge.IsLastInList) + { + for (int i = purge.Start; i > 0; i--) + { + char c = (char)purge.Data[i]; + if (char.IsWhiteSpace(c)) + continue; + else if (c == ',') + purge.Data[i] = (byte)' '; + break; + } + } } } @@ -390,7 +406,7 @@ private void ButtonPurge_Click(object sender, EventArgs e) { foreach (var (file, data) in edited) { - CheckSyntax(data); + CheckSyntax(file, data); zip.UpdateEntry(file, data); } @@ -406,17 +422,21 @@ private void ButtonPurge_Click(object sender, EventArgs e) Clear(); } - private bool CheckSyntax(byte[] data) + private bool CheckSyntax(string file, byte[] data) { + string sdata = null; try { - JsonValue.Parse(Encoding.Default.GetString(data)); + sdata = Encoding.Default.GetString(data); + JsonValue.Parse(sdata); return true; } catch (Exception e) { Debug.WriteLine(e.ToString()); - throw new Exception("Syntax error in output file", e); + Debug.WriteLine("in file: " + file); + Debug.WriteLine(sdata); + throw new Exception("Syntax error in output file " + file, e); } } diff --git a/BlueprintPurge/PurgeRange.cs b/BlueprintPurge/PurgeRange.cs index e974aee..1aac2eb 100644 --- a/BlueprintPurge/PurgeRange.cs +++ b/BlueprintPurge/PurgeRange.cs @@ -19,6 +19,8 @@ public class PurgeRange public bool IsList { get; set; } public string Ref { get; set; } public string Peek { get; set; } + public byte[] Data; + public bool IsLastInList; } } diff --git a/BlueprintPurge/README.md b/BlueprintPurge/README.md index dd15c93..630c9d8 100644 --- a/BlueprintPurge/README.md +++ b/BlueprintPurge/README.md @@ -1,4 +1,4 @@ -# BlueprintPurge +# BlueprintPurge Tool for Pathfinder: Wrath of the Righteous Index diff --git a/BlueprintPurge/changelog.md b/BlueprintPurge/changelog.md index a80e9be..50f9a36 100644 --- a/BlueprintPurge/changelog.md +++ b/BlueprintPurge/changelog.md @@ -1,5 +1,9 @@ # Changelog +## [0.5.0] +- removed string restriction on $type +- fixed preceding comma, when purging last entry in a list + ## [0.4.0] - added ability to filter $type; simply put it in the blueprint textbox