diff --git a/DumpCleaner/DumpFiles.cs b/DumpCleaner/DumpFiles.cs index 12fe7d5..252d7c6 100644 --- a/DumpCleaner/DumpFiles.cs +++ b/DumpCleaner/DumpFiles.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace DumpCleaner +namespace DumpCleaner { 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.customization", OutputName = "customization", 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.en", OutputName = "en", OutputFolder = "locales\\global"}, new DumpData{InputName = "resp.client.locale.jp", OutputName = "jp", OutputFolder = "locales\\global"}, diff --git a/DumpCleaner/LocationParser.cs b/DumpCleaner/LocationParser.cs index 6363d21..03d5a91 100644 --- a/DumpCleaner/LocationParser.cs +++ b/DumpCleaner/LocationParser.cs @@ -2,10 +2,22 @@ using QuestValidator.Common; using QuestValidator.Common.Helpers; 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 { - private readonly Dictionary locations = new(); + private readonly Dictionary locations = new Dictionary(); private readonly string outputPath; public LocationParser(string outputPath) @@ -13,7 +25,7 @@ public class LocationParser this.outputPath = outputPath; } - internal void AddLocalLootDump(Dump dumpFile) + internal void AddLocalLootDump(Dump dumpFile, string rawJson) { var locationData = JsonSerializer.Deserialize(dumpFile.data.ToString()); var locationName = locationData.Id; @@ -27,7 +39,15 @@ public class LocationParser // remove loot as not needed for base.json 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(lootFreeJson))); } internal void CreateLocationFile() @@ -35,13 +55,13 @@ public class LocationParser 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; } - 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"); + JsonWriter.WriteJson(location.Value.RawLocation.data, $"{outputPath}/{location.Value.Location.Id.ToLower()}", Directory.GetCurrentDirectory(), "base"); + LoggingHelpers.LogToConsole($"Found map file: {location.Value.Location.Id} wrote file to output folder"); } } } \ No newline at end of file diff --git a/DumpCleaner/Program.cs b/DumpCleaner/Program.cs index 6c87ad7..6c96dcc 100644 --- a/DumpCleaner/Program.cs +++ b/DumpCleaner/Program.cs @@ -32,7 +32,7 @@ foreach (var path in InputFileHelper.GetInputFilePaths()) // Special case, Do special tasks with it if (names.SpecialCase) { - HandleSpecialCase(names, dumpFile); + HandleSpecialCase(names, dumpFile, rawJson); } else { @@ -44,11 +44,11 @@ foreach (var path in InputFileHelper.GetInputFilePaths()) locationParser.CreateLocationFile(); -void HandleSpecialCase(DumpData names, Dump dumpFile) +void HandleSpecialCase(DumpData names, Dump dumpFile, string rawJson) { if (names.InputName == "resp.client.location.getLocalloot") { - locationParser.AddLocalLootDump(dumpFile); + locationParser.AddLocalLootDump(dumpFile, rawJson); } if (names.InputName == "resp.client.trading.api.traderSettings")