Fix issue causing map parsing to not include all base.json properties

This commit is contained in:
Chomp 2023-07-07 21:00:59 +01:00
parent 033c4f03da
commit a458605221
3 changed files with 31 additions and 16 deletions

View File

@ -1,10 +1,4 @@
using System; namespace DumpCleaner
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DumpCleaner
{ {
public static class DumpFiles public static class DumpFiles
{ {
@ -14,6 +8,7 @@ namespace DumpCleaner
new DumpData{InputName = "resp.client.handbook.templates", OutputName = "handbook", OutputFolder = "templates"}, new DumpData{InputName = "resp.client.handbook.templates", OutputName = "handbook", OutputFolder = "templates"},
new DumpData{InputName = "resp.client.customization", OutputName = "customization", OutputFolder = "templates"}, new DumpData{InputName = "resp.client.customization", OutputName = "customization", OutputFolder = "templates"},
new DumpData{InputName = "resp.client.account.customization", OutputName = "character", OutputFolder = "templates"}, new DumpData{InputName = "resp.client.account.customization", OutputName = "character", OutputFolder = "templates"},
new DumpData{InputName = "resp.client.locale.ru", OutputName = "ru", OutputFolder = "locales\\global"}, new DumpData{InputName = "resp.client.locale.ru", OutputName = "ru", OutputFolder = "locales\\global"},
new DumpData{InputName = "resp.client.locale.en", OutputName = "en", OutputFolder = "locales\\global"}, new DumpData{InputName = "resp.client.locale.en", OutputName = "en", OutputFolder = "locales\\global"},
new DumpData{InputName = "resp.client.locale.jp", OutputName = "jp", OutputFolder = "locales\\global"}, new DumpData{InputName = "resp.client.locale.jp", OutputName = "jp", OutputFolder = "locales\\global"},

View File

@ -2,10 +2,22 @@
using QuestValidator.Common; using QuestValidator.Common;
using QuestValidator.Common.Helpers; using QuestValidator.Common.Helpers;
using System.Text.Json; using System.Text.Json;
using System.Text.Json.Nodes;
public class LocationData
{
public LocationData(Location location, Dump rawLocation)
{
Location = location;
RawLocation = rawLocation;
}
public Location Location { get; set; }
public Dump RawLocation { get; set; }
}
public class LocationParser public class LocationParser
{ {
private readonly Dictionary<string, Location> locations = new(); private readonly Dictionary<string, LocationData> locations = new Dictionary<string, LocationData>();
private readonly string outputPath; private readonly string outputPath;
public LocationParser(string outputPath) public LocationParser(string outputPath)
@ -13,7 +25,7 @@ public class LocationParser
this.outputPath = outputPath; this.outputPath = outputPath;
} }
internal void AddLocalLootDump(Dump dumpFile) internal void AddLocalLootDump(Dump dumpFile, string rawJson)
{ {
var locationData = JsonSerializer.Deserialize<Location>(dumpFile.data.ToString()); var locationData = JsonSerializer.Deserialize<Location>(dumpFile.data.ToString());
var locationName = locationData.Id; var locationName = locationData.Id;
@ -27,7 +39,15 @@ public class LocationParser
// remove loot as not needed for base.json // remove loot as not needed for base.json
locationData.Loot?.Clear(); locationData.Loot?.Clear();
locations.Add(locationName, locationData); // remove loot from raw file
JsonNode? parsedJson = JsonNode.Parse(rawJson);
var data = parsedJson["data"];
data["Loot"] = new JsonArray();
var lootFreeJson = parsedJson.ToString();
locations.Add(locationName, new LocationData(locationData, JsonSerializer.Deserialize<Dump>(lootFreeJson)));
} }
internal void CreateLocationFile() internal void CreateLocationFile()
@ -35,13 +55,13 @@ public class LocationParser
foreach (var location in locations) foreach (var location in locations)
{ {
if (string.Equals(location.Value.Id, "lighthouse2", StringComparison.CurrentCultureIgnoreCase)) if (string.Equals(location.Value.Location.Id, "lighthouse2", StringComparison.CurrentCultureIgnoreCase))
{ {
continue; continue;
} }
JsonWriter.WriteJson(location.Value, $"{outputPath}/{location.Value.Id.ToLower()}", Directory.GetCurrentDirectory(), "base"); JsonWriter.WriteJson(location.Value.RawLocation.data, $"{outputPath}/{location.Value.Location.Id.ToLower()}", Directory.GetCurrentDirectory(), "base");
LoggingHelpers.LogToConsole($"Found map file: {location.Value.Id} wrote file to output folder"); LoggingHelpers.LogToConsole($"Found map file: {location.Value.Location.Id} wrote file to output folder");
} }
} }
} }

View File

@ -32,7 +32,7 @@ foreach (var path in InputFileHelper.GetInputFilePaths())
// Special case, Do special tasks with it // Special case, Do special tasks with it
if (names.SpecialCase) if (names.SpecialCase)
{ {
HandleSpecialCase(names, dumpFile); HandleSpecialCase(names, dumpFile, rawJson);
} }
else else
{ {
@ -44,11 +44,11 @@ foreach (var path in InputFileHelper.GetInputFilePaths())
locationParser.CreateLocationFile(); locationParser.CreateLocationFile();
void HandleSpecialCase(DumpData names, Dump dumpFile) void HandleSpecialCase(DumpData names, Dump dumpFile, string rawJson)
{ {
if (names.InputName == "resp.client.location.getLocalloot") if (names.InputName == "resp.client.location.getLocalloot")
{ {
locationParser.AddLocalLootDump(dumpFile); locationParser.AddLocalLootDump(dumpFile, rawJson);
} }
if (names.InputName == "resp.client.trading.api.traderSettings") if (names.InputName == "resp.client.trading.api.traderSettings")