Skip to content

Commit 72c945a

Browse files
committed
[0.5.0]
- removed string restriction on $type - fixed preceding comma, when purging last entry in a list
1 parent 4167229 commit 72c945a

File tree

4 files changed

+36
-10
lines changed

4 files changed

+36
-10
lines changed

BlueprintPurge/BlueprintPurge.cs

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ private void ButtonSearch_Click(object sender, EventArgs e)
117117
{
118118
if (Guid.TryParse(bp, out var guid))
119119
blueprints.Add(guid);
120-
else if (rxAlphaNumerical.IsMatch(bp))
121-
types.Add(", " + bp);
120+
else //if (rxAlphaNumerical.IsMatch(bp))
121+
types.Add(/*", " + */bp);
122122
}
123123

124124
if (blueprints.Count == 0 && types.Count == 0)
@@ -194,7 +194,7 @@ private void Search(ZipEntry entry)
194194
}
195195

196196
// if it's an type, check if it's blacklisted
197-
else if (isType && this.types.Any(a => quote.EndsWith(a)))
197+
else if (isType && this.types.Any(a => quote.Contains(a)))
198198
{
199199
// get id, if it has any
200200
if (lastId.TryGetValue(stack.Count, out var id))
@@ -297,16 +297,18 @@ private void Cleanup()
297297
break;
298298
}
299299

300-
// include tailing comma
300+
// include tailing comma; check if last entry in list
301301
if (!purge.IsList)
302302
{
303303
for (int j = purge.End + 1; j < purge.Data.Length; j++)
304304
{
305305
char c = (char)purge.Data[j];
306306
if (char.IsWhiteSpace(c))
307307
continue;
308-
if (c == ',')
308+
else if (c == ',')
309309
purge.End = j;
310+
else if (c == ']' || c == '}')
311+
purge.IsLastInList = true;
310312
break;
311313
}
312314
}
@@ -382,6 +384,20 @@ private void ButtonPurge_Click(object sender, EventArgs e)
382384
// simply clear all chars
383385
for (int i = purge.Start; i <= purge.End; i++)
384386
purge.Data[i] = (byte)' ';
387+
388+
// remove preceding comma
389+
if (purge.IsLastInList)
390+
{
391+
for (int i = purge.Start; i > 0; i--)
392+
{
393+
char c = (char)purge.Data[i];
394+
if (char.IsWhiteSpace(c))
395+
continue;
396+
else if (c == ',')
397+
purge.Data[i] = (byte)' ';
398+
break;
399+
}
400+
}
385401
}
386402
}
387403

@@ -390,7 +406,7 @@ private void ButtonPurge_Click(object sender, EventArgs e)
390406
{
391407
foreach (var (file, data) in edited)
392408
{
393-
CheckSyntax(data);
409+
CheckSyntax(file, data);
394410
zip.UpdateEntry(file, data);
395411
}
396412

@@ -406,17 +422,21 @@ private void ButtonPurge_Click(object sender, EventArgs e)
406422
Clear();
407423
}
408424

409-
private bool CheckSyntax(byte[] data)
425+
private bool CheckSyntax(string file, byte[] data)
410426
{
427+
string sdata = null;
411428
try
412429
{
413-
JsonValue.Parse(Encoding.Default.GetString(data));
430+
sdata = Encoding.Default.GetString(data);
431+
JsonValue.Parse(sdata);
414432
return true;
415433
}
416434
catch (Exception e)
417435
{
418436
Debug.WriteLine(e.ToString());
419-
throw new Exception("Syntax error in output file", e);
437+
Debug.WriteLine("in file: " + file);
438+
Debug.WriteLine(sdata);
439+
throw new Exception("Syntax error in output file " + file, e);
420440
}
421441
}
422442

BlueprintPurge/PurgeRange.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ public class PurgeRange
1919
public bool IsList { get; set; }
2020
public string Ref { get; set; }
2121
public string Peek { get; set; }
22+
2223
public byte[] Data;
24+
public bool IsLastInList;
2325
}
2426
}

BlueprintPurge/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# BlueprintPurge
1+
# BlueprintPurge
22
Tool for Pathfinder: Wrath of the Righteous
33

44
Index

BlueprintPurge/changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## [0.5.0]
4+
- removed string restriction on $type
5+
- fixed preceding comma, when purging last entry in a list
6+
37
## [0.4.0]
48
- added ability to filter $type; simply put it in the blueprint textbox
59

0 commit comments

Comments
 (0)