From 0d8d50de921adc9d821ec89ceb7801505a3eb7de Mon Sep 17 00:00:00 2001 From: ElectroJr Date: Sat, 18 Jan 2025 16:29:21 +1300 Subject: [PATCH] Fix elk and add new test --- .../Tests/PostMapInitTest.cs | 54 +++++++++++++++++-- .../Maps/Shuttles/emergency_elkridge.yml | 14 +---- 2 files changed, 51 insertions(+), 17 deletions(-) diff --git a/Content.IntegrationTests/Tests/PostMapInitTest.cs b/Content.IntegrationTests/Tests/PostMapInitTest.cs index b47416ec82..fac5569970 100644 --- a/Content.IntegrationTests/Tests/PostMapInitTest.cs +++ b/Content.IntegrationTests/Tests/PostMapInitTest.cs @@ -38,10 +38,7 @@ namespace Content.IntegrationTests.Tests 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[] GameMaps = @@ -105,6 +102,55 @@ namespace Content.IntegrationTests.Tests await pair.CleanReturnAsync(); } + /// + /// Asserts that shuttles are loadable and have been saved as grids and not maps. + /// + [Test] + public async Task ShuttlesLoadableTest() + { + await using var pair = await PoolManager.GetServerClient(); + var server = pair.Server; + + var entManager = server.ResolveDependency(); + var resMan = server.ResolveDependency(); + var mapLoader = entManager.System(); + var mapSystem = entManager.System(); + var cfg = server.ResolveDependency(); + Assert.That(cfg.GetCVar(CCVars.GridFill), Is.False); + + var shuttleFolder = new ResPath("/Maps/Shuttles"); + var shuttles = resMan + .ContentFindFiles(shuttleFolder) + .Where(filePath => + filePath.Extension == "yml" && !filePath.Filename.StartsWith(".", StringComparison.Ordinal)) + .ToArray(); + + await server.WaitPost(() => + { + Assert.Multiple(() => + { + foreach (var path in shuttles) + { + mapSystem.CreateMap(out var mapId); + try + { + Assert.That(mapLoader.TryLoadGrid(mapId, path, out _), + $"Failed to load shuttle {path}, was it saved as a map instead of a grid?"); + } + catch (Exception ex) + { + throw new Exception($"Failed to load shuttle {path}, was it saved as a map instead of a grid?", + ex); + } + mapSystem.DeleteMap(mapId); + } + }); + }); + await server.WaitRunTicks(1); + + await pair.CleanReturnAsync(); + } + [Test] public async Task NoSavedPostMapInitTest() { diff --git a/Resources/Maps/Shuttles/emergency_elkridge.yml b/Resources/Maps/Shuttles/emergency_elkridge.yml index efeba6844b..4dafdee84a 100644 --- a/Resources/Maps/Shuttles/emergency_elkridge.yml +++ b/Resources/Maps/Shuttles/emergency_elkridge.yml @@ -18,7 +18,7 @@ entities: name: NT Evac Log - type: Transform pos: -0.42093527,-0.86894274 - parent: 637 + parent: invalid - type: MapGrid chunks: 0,0: @@ -804,18 +804,6 @@ entities: chunkSize: 4 - type: GasTileOverlay - type: RadiationGridResistance - - uid: 637 - components: - - type: MetaData - name: Map Entity - - type: Transform - - type: Map - mapPaused: True - - type: PhysicsMap - - type: GridTree - - type: MovedGrids - - type: Broadphase - - type: OccluderTree - proto: AirAlarm entities: - uid: 577 -- 2.51.2