Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions Maple2.Database/Storage/Game/GameStorage.Map.cs
Original file line number Diff line number Diff line change
Expand Up @@ -293,17 +293,22 @@ public bool DeleteCube(PlotCube cube) {
}

public bool InitUgcMap(IEnumerable<UgcMapMetadata> 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) {
continue;
}

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,
Expand Down
Loading