Fixed missing server items from old quests

This commit is contained in:
Alex 2023-08-15 16:36:29 +01:00
parent c69dea3130
commit b48b230d92
3 changed files with 29 additions and 14 deletions

View File

@ -9,7 +9,7 @@
}, },
"dataStorageConfig": { "dataStorageConfig": {
"dataStorageType": "Memory", "dataStorageType": "Memory",
"fileDataStorageTempLocation": "D:\\Spt Stuff\\Lootgenerator\\Dumps\\cache" "fileDataStorageTempLocation": "E:\\spt\\dumps\\cache"
}, },
"loggerConfig": { "loggerConfig": {
"logLevel": "Info", "logLevel": "Info",
@ -20,11 +20,11 @@
"preProcessors": [ "preProcessors": [
"SevenZip" "SevenZip"
], ],
"preProcessorTempFolder": "D:\\Spt Stuff\\Lootgenerator\\TEMP", "preProcessorTempFolder": "E:\\spt\\dumps\\temp",
"cleanupTempFolderAfterProcess": true "cleanupTempFolderAfterProcess": true
}, },
"intakeReaderConfig": { "intakeReaderConfig": {
"maxDumpsPerMap": 1500, "maxDumpsPerMap": 5000,
"readerType": "Json", "readerType": "Json",
"ignoredDumpLocations": [ "ignoredDumpLocations": [
"Hideout" "Hideout"

View File

@ -116,8 +116,7 @@ public class LootDumpProcessorContext
if (_tarkovItems == null) if (_tarkovItems == null)
{ {
_tarkovItems = new TarkovItems( _tarkovItems = new TarkovItems(
$"{GetConfig().ServerLocation}/project/assets/database/templates/items.json", $"{GetConfig().ServerLocation}/project/assets/database/templates/items.json"
$"{GetConfig().ServerLocation}/project/assets/database/templates/handbook.json"
); );
} }
} }

View File

@ -1,4 +1,5 @@
using LootDumpProcessor.Model.Tarkov; using LootDumpProcessor.Logger;
using LootDumpProcessor.Model.Tarkov;
using LootDumpProcessor.Serializers.Json; using LootDumpProcessor.Serializers.Json;
namespace LootDumpProcessor.Process; namespace LootDumpProcessor.Process;
@ -8,17 +9,20 @@ public class TarkovItems
private static readonly IJsonSerializer _jsonSerializer = JsonSerializerFactory.GetInstance(); private static readonly IJsonSerializer _jsonSerializer = JsonSerializerFactory.GetInstance();
private Dictionary<string, TemplateFileItem> _items; private Dictionary<string, TemplateFileItem> _items;
private HandbookRoot _handbook;
public TarkovItems(string items)
public TarkovItems(string items, string handbook)
{ {
_items = _jsonSerializer.Deserialize<Dictionary<string, TemplateFileItem>>(File.ReadAllText(items)); _items = _jsonSerializer.Deserialize<Dictionary<string, TemplateFileItem>>(File.ReadAllText(items));
_handbook = _jsonSerializer.Deserialize<HandbookRoot>(File.ReadAllText(handbook));
} }
public virtual bool IsBaseClass(string tpl, string baseclass_id) 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)) if (string.IsNullOrEmpty(item_template.Parent))
return false; return false;
@ -27,19 +31,31 @@ public class TarkovItems
public virtual bool IsQuestItem(string tpl) 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; return item_template.Props.QuestItem;
} }
public virtual string? MaxDurability(string tpl) 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() ?? ""; return item_template.Props.MaxDurability?.ToString() ?? "";
} }
public virtual string? AmmoCaliber(string tpl) 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; return item_template.Props.Caliber;
} }
} }