Fix elk and add new test

This commit is contained in:
ElectroJr
2025-01-18 16:29:21 +13:00
parent dc13744188
commit 0d8d50de92
2 changed files with 51 additions and 17 deletions

View File

@@ -38,10 +38,7 @@ namespace Content.IntegrationTests.Tests
private static readonly string[] Grids = private static readonly string[] Grids =
{ {
"/Maps/centcomm.yml", "/Maps/centcomm.yml"
"/Maps/Shuttles/cargo.yml",
"/Maps/Shuttles/emergency.yml",
"/Maps/Shuttles/infiltrator.yml",
}; };
private static readonly string[] GameMaps = private static readonly string[] GameMaps =
@@ -105,6 +102,55 @@ namespace Content.IntegrationTests.Tests
await pair.CleanReturnAsync(); await pair.CleanReturnAsync();
} }
/// <summary>
/// Asserts that shuttles are loadable and have been saved as grids and not maps.
/// </summary>
[Test]
public async Task ShuttlesLoadableTest()
{
await using var pair = await PoolManager.GetServerClient();
var server = pair.Server;
var entManager = server.ResolveDependency<IEntityManager>();
var resMan = server.ResolveDependency<IResourceManager>();
var mapLoader = entManager.System<MapLoaderSystem>();
var mapSystem = entManager.System<SharedMapSystem>();
var cfg = server.ResolveDependency<IConfigurationManager>();
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] [Test]
public async Task NoSavedPostMapInitTest() public async Task NoSavedPostMapInitTest()
{ {

View File

@@ -18,7 +18,7 @@ entities:
name: NT Evac Log name: NT Evac Log
- type: Transform - type: Transform
pos: -0.42093527,-0.86894274 pos: -0.42093527,-0.86894274
parent: 637 parent: invalid
- type: MapGrid - type: MapGrid
chunks: chunks:
0,0: 0,0:
@@ -804,18 +804,6 @@ entities:
chunkSize: 4 chunkSize: 4
- type: GasTileOverlay - type: GasTileOverlay
- type: RadiationGridResistance - 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 - proto: AirAlarm
entities: entities:
- uid: 577 - uid: 577