Update dump tool to use loot dump jsons instead of location json, they have more properties
This commit is contained in:
parent
78494e2472
commit
89eebf604d
@ -42,6 +42,8 @@ namespace DumpCleaner
|
|||||||
|
|
||||||
new DumpData{InputName = "resp.client.locations", OutputName = "locations", OutputFolder = "locations", SpecialCase = true},
|
new DumpData{InputName = "resp.client.locations", OutputName = "locations", OutputFolder = "locations", SpecialCase = true},
|
||||||
|
|
||||||
|
new DumpData{InputName = "resp.client.location.getLocalloot", OutputName = "locations", OutputFolder = "locations", SpecialCase = true},
|
||||||
|
|
||||||
new DumpData{InputName = "resp.client.trading.api.traderSettings", OutputName = "traders", OutputFolder = "traders", SpecialCase = true},
|
new DumpData{InputName = "resp.client.trading.api.traderSettings", OutputName = "traders", OutputFolder = "traders", SpecialCase = true},
|
||||||
|
|
||||||
new DumpData{InputName= "usec.resp.client.trading.customization", OutputName= "usecsuits", OutputFolder = "traders/5ac3b934156ae10c4430e83c"},
|
new DumpData{InputName= "usec.resp.client.trading.customization", OutputName= "usecsuits", OutputFolder = "traders/5ac3b934156ae10c4430e83c"},
|
||||||
|
47
DumpCleaner/LocationParser.cs
Normal file
47
DumpCleaner/LocationParser.cs
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
using DumpCleaner;
|
||||||
|
using QuestValidator.Common;
|
||||||
|
using QuestValidator.Common.Helpers;
|
||||||
|
using System.Text.Json;
|
||||||
|
|
||||||
|
public class LocationParser
|
||||||
|
{
|
||||||
|
private readonly Dictionary<string, Location> locations = new();
|
||||||
|
private readonly string outputPath;
|
||||||
|
|
||||||
|
public LocationParser(string outputPath)
|
||||||
|
{
|
||||||
|
this.outputPath = outputPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void AddLocalLootDump(Dump dumpFile)
|
||||||
|
{
|
||||||
|
var locationData = JsonSerializer.Deserialize<Location>(dumpFile.data.ToString());
|
||||||
|
var locationName = locationData.Id;
|
||||||
|
|
||||||
|
// already parsed, skip
|
||||||
|
if (locations.ContainsKey(locationName))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// remove loot as not needed for base.json
|
||||||
|
locationData.Loot?.Clear();
|
||||||
|
|
||||||
|
locations.Add(locationName, locationData);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void CreateLocationFile()
|
||||||
|
{
|
||||||
|
foreach (var location in locations)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (string.Equals(location.Value.Id, "lighthouse2", StringComparison.CurrentCultureIgnoreCase))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
JsonWriter.WriteJson(location.Value, $"{outputPath}/{location.Value.Id.ToLower()}", Directory.GetCurrentDirectory(), "base");
|
||||||
|
LoggingHelpers.LogToConsole($"Found map file: {location.Value.Id} wrote file to output folder");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -7,11 +7,12 @@ using System.Text.Json;
|
|||||||
|
|
||||||
var inputPath = DiskHelpers.CreateWorkingFolders();
|
var inputPath = DiskHelpers.CreateWorkingFolders();
|
||||||
InputFileHelper.SetInputFiles(inputPath);
|
InputFileHelper.SetInputFiles(inputPath);
|
||||||
|
var locationParser = new LocationParser("locations");
|
||||||
|
|
||||||
foreach (var path in InputFileHelper.GetInputFilePaths())
|
foreach (var path in InputFileHelper.GetInputFilePaths())
|
||||||
{
|
{
|
||||||
var filename = Path.GetFileNameWithoutExtension(path);
|
var filename = Path.GetFileNameWithoutExtension(path);
|
||||||
var names = DumpFiles.filenames.FirstOrDefault(x => filename.StartsWith(x.InputName));
|
var names = DumpFiles.filenames.Find(x => filename.StartsWith(x.InputName));
|
||||||
|
|
||||||
if (names == null)
|
if (names == null)
|
||||||
{
|
{
|
||||||
@ -19,8 +20,8 @@ foreach (var path in InputFileHelper.GetInputFilePaths())
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
var questDataJson = File.ReadAllText(path);
|
var rawJson = File.ReadAllText(path);
|
||||||
var dumpFile = JsonSerializer.Deserialize<Dump>(questDataJson);
|
var dumpFile = JsonSerializer.Deserialize<Dump>(rawJson);
|
||||||
|
|
||||||
if (dumpFile.data == null)
|
if (dumpFile.data == null)
|
||||||
{
|
{
|
||||||
@ -40,11 +41,14 @@ foreach (var path in InputFileHelper.GetInputFilePaths())
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
locationParser.CreateLocationFile();
|
||||||
|
|
||||||
|
|
||||||
void HandleSpecialCase(DumpData names, Dump dumpFile)
|
void HandleSpecialCase(DumpData names, Dump dumpFile)
|
||||||
{
|
{
|
||||||
if (names.InputName == "resp.client.locations")
|
if (names.InputName == "resp.client.location.getLocalloot")
|
||||||
{
|
{
|
||||||
HandleLocationsFile(names, dumpFile);
|
locationParser.AddLocalLootDump(dumpFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (names.InputName == "resp.client.trading.api.traderSettings")
|
if (names.InputName == "resp.client.trading.api.traderSettings")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user