mirror of
https://github.com/sp-tarkov/loot-dump-processor.git
synced 2025-02-13 03:10:46 -05:00
Refactored static loot processor to process maps in parallel
This commit is contained in:
parent
7eb932f603
commit
0af0c9f9c3
@ -193,7 +193,7 @@ public class MultithreadSteppedDumpProcessor(
|
||||
LoggerFactory.GetInstance().Log("Processing ammo distribution", LogLevel.Info);
|
||||
|
||||
var staticAmmo = new ConcurrentDictionary<string, IReadOnlyDictionary<string, List<AmmoDistribution>>>();
|
||||
Parallel.ForEach(dumpProcessData.ContainerCounts.Keys, (mapId) =>
|
||||
Parallel.ForEach(dumpProcessData.ContainerCounts.Keys, mapId =>
|
||||
{
|
||||
var preProcessedStaticLoots = dumpProcessData.ContainerCounts[mapId];
|
||||
var ammoDistribution = _ammoProcessor.CreateAmmoDistribution(mapId, preProcessedStaticLoots);
|
||||
@ -207,10 +207,19 @@ public class MultithreadSteppedDumpProcessor(
|
||||
|
||||
if (LoggerFactory.GetInstance().CanBeLogged(LogLevel.Info))
|
||||
LoggerFactory.GetInstance().Log("Processing static loot distribution", LogLevel.Info);
|
||||
|
||||
var staticLoot = new ConcurrentDictionary<string, IReadOnlyDictionary<string, StaticItemDistribution>>();
|
||||
Parallel.ForEach(dumpProcessData.ContainerCounts.Keys, mapId =>
|
||||
{
|
||||
var preProcessedStaticLoots = dumpProcessData.ContainerCounts[mapId];
|
||||
var staticLootDistribution =
|
||||
_staticLootProcessor.CreateStaticLootDistribution(mapId, preProcessedStaticLoots);
|
||||
staticLoot[mapId] = staticLootDistribution;
|
||||
});
|
||||
// Static loot distribution
|
||||
output.Add(
|
||||
OutputFileType.StaticLoot,
|
||||
_staticLootProcessor.CreateStaticLootDistribution(dumpProcessData.ContainerCounts, staticContainers)
|
||||
staticLoot
|
||||
);
|
||||
|
||||
if (LoggerFactory.GetInstance().CanBeLogged(LogLevel.Info))
|
||||
|
@ -1,6 +1,5 @@
|
||||
using LootDumpProcessor.Model;
|
||||
using LootDumpProcessor.Model.Output;
|
||||
using LootDumpProcessor.Model.Output.StaticContainer;
|
||||
using LootDumpProcessor.Model.Processing;
|
||||
|
||||
namespace LootDumpProcessor.Process.Processor.v2.StaticLootProcessor;
|
||||
@ -9,7 +8,7 @@ public interface IStaticLootProcessor
|
||||
{
|
||||
IReadOnlyList<PreProcessedStaticLoot> PreProcessStaticLoot(IReadOnlyList<Template> staticLoot);
|
||||
|
||||
IReadOnlyDictionary<string, IReadOnlyDictionary<string, StaticItemDistribution>> CreateStaticLootDistribution(
|
||||
IReadOnlyDictionary<string, List<PreProcessedStaticLoot>> containerCounts,
|
||||
IReadOnlyDictionary<string, MapStaticLoot> staticContainers);
|
||||
IReadOnlyDictionary<string, StaticItemDistribution> CreateStaticLootDistribution(
|
||||
string mapName,
|
||||
IReadOnlyList<PreProcessedStaticLoot> containers);
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
using LootDumpProcessor.Model;
|
||||
using LootDumpProcessor.Model.Output;
|
||||
using LootDumpProcessor.Model.Output.StaticContainer;
|
||||
using LootDumpProcessor.Model.Processing;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
@ -43,15 +42,9 @@ public class StaticLootProcessor(ILogger<StaticLootProcessor> logger) : IStaticL
|
||||
return nonWeaponContainers;
|
||||
}
|
||||
|
||||
public IReadOnlyDictionary<string, IReadOnlyDictionary<string, StaticItemDistribution>>
|
||||
CreateStaticLootDistribution(
|
||||
IReadOnlyDictionary<string, List<PreProcessedStaticLoot>> containerCounts,
|
||||
IReadOnlyDictionary<string, MapStaticLoot> staticContainers)
|
||||
{
|
||||
var allMapsStaticLootDistribution =
|
||||
new Dictionary<string, IReadOnlyDictionary<string, StaticItemDistribution>>();
|
||||
|
||||
foreach (var (mapName, containers) in containerCounts)
|
||||
public IReadOnlyDictionary<string, StaticItemDistribution> CreateStaticLootDistribution(
|
||||
string mapName,
|
||||
IReadOnlyList<PreProcessedStaticLoot> containers)
|
||||
{
|
||||
var staticLootDistribution = new Dictionary<string, StaticItemDistribution>();
|
||||
var uniqueContainerTypes = containers.Select(container => container.Type).Distinct();
|
||||
@ -76,15 +69,12 @@ public class StaticLootProcessor(ILogger<StaticLootProcessor> logger) : IStaticL
|
||||
};
|
||||
|
||||
_logger.LogDebug(
|
||||
"Processed static loot distribution for ContainerType {ContainerType} in Map {MapName}.",
|
||||
"Processed static loot distribution for ContainerType `{ContainerType}` in Map `{MapName}`.",
|
||||
containerType, mapName);
|
||||
}
|
||||
|
||||
allMapsStaticLootDistribution[mapName] = staticLootDistribution;
|
||||
_logger.LogInformation("Created static loot distribution for Map {MapName}.", mapName);
|
||||
}
|
||||
|
||||
return allMapsStaticLootDistribution;
|
||||
_logger.LogInformation("Created static loot distribution for Map `{MapName}`.", mapName);
|
||||
return staticLootDistribution;
|
||||
}
|
||||
|
||||
private static IReadOnlyList<int> GetItemCountsInContainers(IReadOnlyList<PreProcessedStaticLoot> selectedContainers)
|
||||
@ -112,6 +102,6 @@ public class StaticLootProcessor(ILogger<StaticLootProcessor> logger) : IStaticL
|
||||
{
|
||||
Tpl = kv.Key,
|
||||
RelativeProbability = kv.Value
|
||||
}).ToArray();
|
||||
}).ToList();
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user