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",
var server = pair.Server;
var resourceManager = server.ResolveDependency<IResourceManager>();
+ var protoManager = server.ResolveDependency<IPrototypeManager>();
+ var loader = server.System<MapLoaderSystem>();
+
var mapFolder = new ResPath("/Maps");
var maps = resourceManager
.ContentFindFiles(mapFolder)
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<EntityCategoryPrototype>("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<IEntitySystemManager>().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<SharedMapSystem>();
+ 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();
}