diff --git a/Content.Server/Maps/MapMigrationSystem.cs b/Content.Server/Maps/MapMigrationSystem.cs index 83c2abc5e38..1d5058f6eca 100644 --- a/Content.Server/Maps/MapMigrationSystem.cs +++ b/Content.Server/Maps/MapMigrationSystem.cs @@ -1,4 +1,4 @@ -using System.Diagnostics.CodeAnalysis; +using System.Diagnostics.CodeAnalysis; using System.IO; using System.Linq; using Robust.Server.GameObjects; @@ -21,7 +21,7 @@ public sealed class MapMigrationSystem : EntitySystem [Dependency] private readonly IPrototypeManager _protoMan = default!; [Dependency] private readonly IResourceManager _resMan = default!; - private const string MigrationFile = "/migration.yml"; + private static readonly string[] MigrationFiles = { "/migration.yml", "/_NF/migration.yml" }; // Frontier: use array of migration files public override void Initialize() { @@ -29,23 +29,50 @@ public override void Initialize() SubscribeLocalEvent(OnBeforeReadEvent); #if DEBUG - if (!TryReadFile(out var mappings)) + if (!TryReadFiles(out var mappings)) // Frontier: TryReadFile(newId), $"{newId} is not an entity prototype."); + foreach (var node in mapping.Values) + { + var newId = ((ValueDataNode)node).Value; + if (!string.IsNullOrEmpty(newId) && newId != "null") + DebugTools.Assert(_protoMan.HasIndex(newId), + $"{newId} is not an entity prototype."); + } } + // End Delta-V #endif } - private bool TryReadFile([NotNullWhen(true)] out MappingDataNode? mappings) + // Frontier: wrap single file reader + private bool TryReadFiles([NotNullWhen(true)] out List? mappings) { mappings = null; - var path = new ResPath(MigrationFile); + + if (MigrationFiles.Count() <= 0) + return false; + + foreach (var migrationFile in MigrationFiles) + { + if (!TryReadFile(migrationFile, out var mapping)) + continue; + + mappings = mappings ?? new List(); + mappings.Add(mapping); + } + + return mappings != null && mappings.Count > 0; + } + // End Frontier + + private bool TryReadFile(string migrationFile, [NotNullWhen(true)] out MappingDataNode? mappings) // Frontier: add migrationFile + { + mappings = null; + var path = new ResPath(migrationFile); // Frontier: MigrationFile