From: ElectroJr Date: Sun, 16 Feb 2025 12:16:22 +0000 (+1300) Subject: Merge branch 'master' of https://github.com/space-wizards/space-station-14 into pr... X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=afc41947a7609b88461b68037727bf3b1292cc9a;p=space-station-14.git Merge branch 'master' of https://github.com/space-wizards/space-station-14 into pr/34711 --- afc41947a7609b88461b68037727bf3b1292cc9a diff --cc Content.IntegrationTests/Tests/PostMapInitTest.cs index 7fc6560694,94214c609a..dcb2e222a4 --- a/Content.IntegrationTests/Tests/PostMapInitTest.cs +++ b/Content.IntegrationTests/Tests/PostMapInitTest.cs @@@ -36,17 -38,9 +38,14 @@@ namespace Content.IntegrationTests.Test private static readonly string[] Grids = { - "/Maps/centcomm.yml", - "/Maps/Shuttles/cargo.yml", - "/Maps/Shuttles/emergency.yml", - "/Maps/Shuttles/infiltrator.yml", + "/Maps/centcomm.yml" }; + private static readonly string[] DoNotMapWhitelist = + { + "/Maps/centcomm.yml", + }; + private static readonly string[] GameMaps = { "Dev", @@@ -127,7 -159,8 +164,9 @@@ var server = pair.Server; var resourceManager = server.ResolveDependency(); + var protoManager = server.ResolveDependency(); + var loader = server.System(); + var mapFolder = new ResPath("/Maps"); var maps = resourceManager .ContentFindFiles(mapFolder) @@@ -156,27 -190,41 +196,58 @@@ var root = yamlStream.Documents[0].RootNode; var meta = root["meta"]; - var postMapInit = meta["postmapinit"].AsBool(); + var version = meta["format"].AsInt(); + if (version >= 7) + { + v7Maps.Add(map); + continue; + } + + var postMapInit = meta["postmapinit"].AsBool(); Assert.That(postMapInit, Is.False, $"Map {map.Filename} was saved postmapinit"); + + // testing that maps have nothing with the DoNotMap entity category + // I do it here because it's basically copy-paste code for the most part + var yamlEntities = root["entities"]; + if (!protoManager.TryIndex("DoNotMap", out var dnmCategory)) + return; + foreach (var yamlEntity in (YamlSequenceNode)yamlEntities) + { + var protoId = yamlEntity["proto"].AsString(); + protoManager.TryIndex(protoId, out var proto, false); + if (proto is null || proto.EditorSuffix is null) + continue; + if (proto.Categories.Contains(dnmCategory) && !DoNotMapWhitelist.Contains(map.ToString())) + { + Assert.Fail($"\nMap {map} has the DO NOT MAP category in prototype {proto.Name}"); + } + } } + + var deps = server.ResolveDependency().DependencyCollection; + foreach (var map in v7Maps) + { + Assert.That(IsPreInit(map, loader, deps)); + } + + // Check that the test actually does manage to catch post-init maps and isn't just blindly passing everything. + // To that end, create a new post-init map and try verify it. + var mapSys = server.System(); + MapId id = default; + await server.WaitPost(() => mapSys.CreateMap(out id, runMapInit: false)); + await server.WaitPost(() => server.EntMan.Spawn(null, new MapCoordinates(0, 0, id))); + + // First check that a pre-init version passes + var path = new ResPath($"{nameof(NoSavedPostMapInitTest)}.yml"); + Assert.That(loader.TrySaveMap(id, path)); + Assert.That(IsPreInit(path, loader, deps)); + + // and the post-init version fails. + await server.WaitPost(() => mapSys.InitializeMap(id)); + Assert.That(loader.TrySaveMap(id, path)); + Assert.That(IsPreInit(path, loader, deps), Is.False); + await pair.CleanReturnAsync(); }