8562d32f36
various updates
107 lines
3.4 KiB
C#
107 lines
3.4 KiB
C#
using AssortGenerator.Common.Helpers;
|
|
using DumpCleaner;
|
|
using QuestValidator.Common;
|
|
using QuestValidator.Common.Helpers;
|
|
using QuestValidator.Helpers;
|
|
using System.Text.Json;
|
|
|
|
var inputPath = DiskHelpers.CreateWorkingFolders();
|
|
InputFileHelper.SetInputFiles(inputPath);
|
|
var locationParser = new LocationParser("locations");
|
|
|
|
foreach (var path in InputFileHelper.GetInputFilePaths())
|
|
{
|
|
var filename = Path.GetFileNameWithoutExtension(path);
|
|
var names = DumpFiles.filenames.Find(x => filename.StartsWith(x.InputName));
|
|
|
|
if (names == null)
|
|
{
|
|
LoggingHelpers.LogToConsole($"No mapping found for file: {filename} Skipping", ConsoleColor.Yellow);
|
|
continue;
|
|
}
|
|
|
|
var rawJson = File.ReadAllText(path);
|
|
var dumpFile = JsonSerializer.Deserialize<Dump>(rawJson);
|
|
|
|
if (dumpFile.data == null)
|
|
{
|
|
LoggingHelpers.LogWarning($"file: {filename} had no data in it, skipping");
|
|
continue;
|
|
}
|
|
|
|
// Special case, Do special tasks with it
|
|
if (names.SpecialCase)
|
|
{
|
|
HandleSpecialCase(names, dumpFile, rawJson);
|
|
}
|
|
else
|
|
{
|
|
JsonWriter.WriteJson(dumpFile.data, names.OutputFolder, Directory.GetCurrentDirectory(), names.OutputName);
|
|
LoggingHelpers.LogToConsole($"Found file: {filename} wrote file to output folder");
|
|
}
|
|
}
|
|
|
|
locationParser.CreateLocationFile();
|
|
|
|
|
|
void HandleSpecialCase(DumpData names, Dump dumpFile, string rawJson)
|
|
{
|
|
if (names.InputName == "resp.client.location.getLocalloot")
|
|
{
|
|
locationParser.AddLocalLootDump(dumpFile, rawJson);
|
|
|
|
return;
|
|
}
|
|
|
|
if (names.InputName == "resp.client.trading.api.traderSettings")
|
|
{
|
|
HandleTraderSettingsFile(names, dumpFile);
|
|
|
|
return;
|
|
}
|
|
|
|
if (names.InputName == "resp.client.achievement.list")
|
|
{
|
|
HandleAchievementFile(names, dumpFile);
|
|
}
|
|
}
|
|
|
|
void HandleLocationsFile(DumpData names, Dump dumpFile)
|
|
{
|
|
var locationsRoot = JsonSerializer.Deserialize<Dictionary<string, object>>(dumpFile.data.ToString());
|
|
var locations = JsonSerializer.Deserialize<Dictionary<string, object>>(locationsRoot.First().Value.ToString());
|
|
|
|
foreach (var location in locations)
|
|
{
|
|
var locationData = JsonSerializer.Deserialize<Location>(location.Value.ToString());
|
|
|
|
var mapName = locationData.Id.ToLower();
|
|
if (mapName == "lighthouse2")
|
|
{
|
|
continue;
|
|
}
|
|
|
|
if (new string[] { "bigmap", "interchange", "lighthouse", "rezervbase", "shoreline", "woods", "tarkovstreets" }.Contains(mapName))
|
|
{
|
|
// TODO: add back airdrop chance
|
|
}
|
|
|
|
JsonWriter.WriteJson(location.Value.ToString(), $"{names.OutputFolder}/{locationData.Id.ToLower()}", Directory.GetCurrentDirectory(), "base");
|
|
LoggingHelpers.LogToConsole($"Found map file: {locationData.Id} wrote file to output folder");
|
|
}
|
|
}
|
|
|
|
void HandleTraderSettingsFile(DumpData names, Dump dumpFile)
|
|
{
|
|
var traders = JsonSerializer.Deserialize<List<object>>(dumpFile.data.ToString());
|
|
|
|
foreach (var trader in traders)
|
|
{
|
|
var traderData = JsonSerializer.Deserialize<Trader>(trader.ToString());
|
|
traderData.sell_category = TraderSellCategories.GetCategoriesByTraderId(traderData._id);
|
|
|
|
JsonWriter.WriteJson(traderData, $"{names.OutputFolder}/{traderData._id}", Directory.GetCurrentDirectory(), "base");
|
|
LoggingHelpers.LogToConsole($"Found trader file: {traderData._id} wrote file to output folder");
|
|
}
|
|
}
|