0
0
mirror of https://github.com/sp-tarkov/loot-dump-processor.git synced 2025-02-12 14:50:44 -05:00

Resolve missing static forced containers/weapons when using loot dumps from multiple versions (#7)

Instead of only using the static forced containers from the first dump, merge all static forced containers so we can utilize dumps from multiple versions

Co-authored-by: DrakiaXYZ <565558+TheDgtl@users.noreply.github.com>
Reviewed-on: SPT/LootDumpProcessor#7
Co-authored-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
Co-committed-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
This commit is contained in:
DrakiaXYZ 2024-11-05 09:10:40 +00:00 committed by chomp
parent 0719a7bfdd
commit 594a489eac

View File

@ -66,18 +66,31 @@ public class MultithreadSteppedDumpProcessor : IDumpProcessor
var mapId = dataDump.Data.LocationLoot.Id.ToLower();
// the if statement below takes care of processing "forced" or real static data for each map, only need
// to do this once per map, we dont care about doing it again
// Because we may use multiple version dumps for map data, merge the static loot between dumps
lock (staticContainersLock)
{
if (!staticContainers.ContainsKey(mapId))
if (!staticContainers.TryGetValue(mapId, out var mapStaticLoot))
{
if (LoggerFactory.GetInstance().CanBeLogged(LogLevel.Info))
LoggerFactory.GetInstance().Log($"Doing first time process for map {mapId} of real static data", LogLevel.Info);
var mapStaticContainers = StaticLootProcessor.CreateStaticWeaponsAndStaticForcedContainers(dataDump);
staticContainers[mapId] = new MapStaticLoot
{
StaticWeapons = new List<Template>(),
StaticForced = new List<StaticForced>()
};
}
else
{
// .Item1 = map name
// .Item2 = force/weapon static arrays
staticContainers[mapStaticContainers.Item1] = mapStaticContainers.Item2;
var mapStaticContainers = StaticLootProcessor.CreateStaticWeaponsAndStaticForcedContainers(dataDump);
var newStaticWeapons = mapStaticContainers.Item2.StaticWeapons.Where(x => !mapStaticLoot.StaticWeapons.Exists(y => y.Id == x.Id));
var newStaticForced = mapStaticContainers.Item2.StaticForced.Where(x => !mapStaticLoot.StaticForced.Exists(y => y.ContainerId == x.ContainerId));
mapStaticLoot.StaticWeapons.AddRange(newStaticWeapons);
mapStaticLoot.StaticForced.AddRange(newStaticForced);
}
}