From b48b230d92c3995343963fc6f22cc9e7dd6962cb Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 15 Aug 2023 16:36:29 +0100 Subject: [PATCH] Fixed missing server items from old quests --- Config/config.json | 6 +++--- LootDumpProcessorContext.cs | 3 +-- Process/TarkovItems.cs | 34 +++++++++++++++++++++++++--------- 3 files changed, 29 insertions(+), 14 deletions(-) diff --git a/Config/config.json b/Config/config.json index b5bda8b..ff7c802 100644 --- a/Config/config.json +++ b/Config/config.json @@ -9,7 +9,7 @@ }, "dataStorageConfig": { "dataStorageType": "Memory", - "fileDataStorageTempLocation": "D:\\Spt Stuff\\Lootgenerator\\Dumps\\cache" + "fileDataStorageTempLocation": "E:\\spt\\dumps\\cache" }, "loggerConfig": { "logLevel": "Info", @@ -20,11 +20,11 @@ "preProcessors": [ "SevenZip" ], - "preProcessorTempFolder": "D:\\Spt Stuff\\Lootgenerator\\TEMP", + "preProcessorTempFolder": "E:\\spt\\dumps\\temp", "cleanupTempFolderAfterProcess": true }, "intakeReaderConfig": { - "maxDumpsPerMap": 1500, + "maxDumpsPerMap": 5000, "readerType": "Json", "ignoredDumpLocations": [ "Hideout" diff --git a/LootDumpProcessorContext.cs b/LootDumpProcessorContext.cs index 47cb433..01e5538 100644 --- a/LootDumpProcessorContext.cs +++ b/LootDumpProcessorContext.cs @@ -116,8 +116,7 @@ public class LootDumpProcessorContext if (_tarkovItems == null) { _tarkovItems = new TarkovItems( - $"{GetConfig().ServerLocation}/project/assets/database/templates/items.json", - $"{GetConfig().ServerLocation}/project/assets/database/templates/handbook.json" + $"{GetConfig().ServerLocation}/project/assets/database/templates/items.json" ); } } diff --git a/Process/TarkovItems.cs b/Process/TarkovItems.cs index a818fb1..98af492 100644 --- a/Process/TarkovItems.cs +++ b/Process/TarkovItems.cs @@ -1,4 +1,5 @@ -using LootDumpProcessor.Model.Tarkov; +using LootDumpProcessor.Logger; +using LootDumpProcessor.Model.Tarkov; using LootDumpProcessor.Serializers.Json; namespace LootDumpProcessor.Process; @@ -8,17 +9,20 @@ public class TarkovItems private static readonly IJsonSerializer _jsonSerializer = JsonSerializerFactory.GetInstance(); private Dictionary _items; - private HandbookRoot _handbook; - - public TarkovItems(string items, string handbook) + + public TarkovItems(string items) { _items = _jsonSerializer.Deserialize>(File.ReadAllText(items)); - _handbook = _jsonSerializer.Deserialize(File.ReadAllText(handbook)); } public virtual bool IsBaseClass(string tpl, string baseclass_id) { - var item_template = _items[tpl]; + if (!_items.TryGetValue(tpl, out var item_template)) + { + LoggerFactory.GetInstance().Log($"[IsBaseClass] Item template '{tpl}' with base class id '{baseclass_id}' was not found on the server items!", LogLevel.Error); + return false; + } + if (string.IsNullOrEmpty(item_template.Parent)) return false; @@ -27,19 +31,31 @@ public class TarkovItems public virtual bool IsQuestItem(string tpl) { - var item_template = _items[tpl]; + if (!_items.TryGetValue(tpl, out var item_template)) + { + LoggerFactory.GetInstance().Log($"[IsQuestItem] Item template '{tpl}' was not found on the server items!", LogLevel.Error); + return false; + } return item_template.Props.QuestItem; } public virtual string? MaxDurability(string tpl) { - var item_template = _items[tpl]; + if (!_items.TryGetValue(tpl, out var item_template)) + { + LoggerFactory.GetInstance().Log($"[MaxDurability] Item template '{tpl}' was not found on the server items!", LogLevel.Error); + return null; + } return item_template.Props.MaxDurability?.ToString() ?? ""; } public virtual string? AmmoCaliber(string tpl) { - var item_template = _items[tpl]; + if (!_items.TryGetValue(tpl, out var item_template)) + { + LoggerFactory.GetInstance().Log($"[AmmoCaliber] Item template '{tpl}' was not found on the server items!", LogLevel.Error); + return null; + } return item_template.Props.Caliber; } } \ No newline at end of file