Skip to content

Commit 8382c2f

Browse files
committed
fix duplicate key exception introduced in Update 14
This seems to be a mistake, as far as I'm concerned, spawner ID's should be unique.
1 parent 3853ca0 commit 8382c2f

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

SOTFEdit/ViewModel/NpcsPageViewModel.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,15 @@ private void LoadNpcs(Savegame? savegame)
9191
return;
9292
}
9393

94+
var groupBy = vailWorldSim["Spawners"]?.ToObject<List<Spawner>>()?
95+
.GroupBy(s => s.UniqueId)
96+
.Where(g => g.ToList().Count > 1)
97+
.ToDictionary(g => g.Key, g => g.ToList());
98+
99+
94100
var spawnersBySpawnerUniqueId = vailWorldSim["Spawners"]?.ToObject<List<Spawner>>()?
95-
.ToDictionary(s => s.UniqueId) ?? new Dictionary<int, Spawner>();
101+
.GroupBy(s => s.UniqueId)
102+
.ToDictionary(s => s.Key, s => s.First()) ?? new Dictionary<int, Spawner>();
96103
var influenceMemoryByUniqueId = vailWorldSim["InfluenceMemory"]?.ToObject<List<InfluenceMemory>>()?
97104
.GroupBy(s => s.UniqueId)
98105
.ToDictionary(s => s.Key, s => s.ToList()) ?? new Dictionary<int, List<InfluenceMemory>>();

0 commit comments

Comments
 (0)