From 350bb78f3dd6494186954d46abedd78e716b7ee8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=82ngelo=20Tadeucci?= Date: Wed, 11 Feb 2026 23:23:30 -0300 Subject: [PATCH] Add missing UGC maps without early exit Previously InitUgcMap returned early if any UgcMap rows existed, preventing new maps from being added later. This change builds a HashSet of existing (MapId, Number) pairs and skips inserts for those pairs, allowing the method to insert only missing map entries while avoiding duplicates. The DefaultHomeMapId check is preserved; AsEnumerable/ToHashSet is used to materialize the existing pairs for comparison. --- Maple2.Database/Storage/Game/GameStorage.Map.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Maple2.Database/Storage/Game/GameStorage.Map.cs b/Maple2.Database/Storage/Game/GameStorage.Map.cs index aaeed30de..41d60a8ef 100644 --- a/Maple2.Database/Storage/Game/GameStorage.Map.cs +++ b/Maple2.Database/Storage/Game/GameStorage.Map.cs @@ -293,10 +293,11 @@ public bool DeleteCube(PlotCube cube) { } public bool InitUgcMap(IEnumerable maps) { - // If there are entries, we assume it's already initialized. - if (Context.UgcMap.Any()) { - return true; - } + HashSet<(int MapId, int Number)> existing = Context.UgcMap + .Select(m => new { m.MapId, m.Number }) + .AsEnumerable() + .Select(m => (m.MapId, m.Number)) + .ToHashSet(); foreach (UgcMapMetadata map in maps) { if (map.Id == Constant.DefaultHomeMapId) { @@ -304,6 +305,10 @@ public bool InitUgcMap(IEnumerable maps) { } foreach (UgcMapGroup group in map.Plots.Values) { + if (existing.Contains((map.Id, group.Number))) { + continue; + } + Context.UgcMap.Add(new UgcMap { MapId = map.Id, Number = group.Number,