Fix admin test arena (#35444)

* Fix admin test arena

* Add to GridsLoadableTest

* QueueDel map, remove nullable

---------

Co-authored-by: ElectroJr <leonsfriedrich@gmail.com>
This commit is contained in:
metalgearsloth
2025-02-24 17:05:59 +11:00
committed by GitHub
parent 05de5bd3eb
commit 5385683b7e
2 changed files with 15 additions and 9 deletions

View File

@@ -1,6 +1,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using Content.Server.Administration.Systems;
using Content.Server.GameTicking; using Content.Server.GameTicking;
using Content.Server.Maps; using Content.Server.Maps;
using Content.Server.Shuttles.Components; using Content.Server.Shuttles.Components;
@@ -38,7 +39,8 @@ namespace Content.IntegrationTests.Tests
private static readonly string[] Grids = private static readonly string[] Grids =
{ {
"/Maps/centcomm.yml" "/Maps/centcomm.yml",
AdminTestArenaSystem.ArenaMapPath
}; };
private static readonly string[] DoNotMapWhitelist = private static readonly string[] DoNotMapWhitelist =

View File

@@ -12,6 +12,7 @@ public sealed class AdminTestArenaSystem : EntitySystem
{ {
[Dependency] private readonly MapLoaderSystem _loader = default!; [Dependency] private readonly MapLoaderSystem _loader = default!;
[Dependency] private readonly MetaDataSystem _metaDataSystem = default!; [Dependency] private readonly MetaDataSystem _metaDataSystem = default!;
[Dependency] private readonly SharedMapSystem _maps = default!;
public const string ArenaMapPath = "/Maps/Test/admin_test_arena.yml"; public const string ArenaMapPath = "/Maps/Test/admin_test_arena.yml";
@@ -33,17 +34,20 @@ public sealed class AdminTestArenaSystem : EntitySystem
} }
var path = new ResPath(ArenaMapPath); var path = new ResPath(ArenaMapPath);
if (!_loader.TryLoadMap(path, out var map, out var grids)) var mapUid = _maps.CreateMap(out var mapId);
if (!_loader.TryLoadGrid(mapId, path, out var grid))
{
QueueDel(mapUid);
throw new Exception($"Failed to load admin arena"); throw new Exception($"Failed to load admin arena");
}
ArenaMap[admin.UserId] = map.Value.Owner; ArenaMap[admin.UserId] = mapUid;
_metaDataSystem.SetEntityName(map.Value.Owner, $"ATAM-{admin.Name}"); _metaDataSystem.SetEntityName(mapUid, $"ATAM-{admin.Name}");
var grid = grids.FirstOrNull(); ArenaGrid[admin.UserId] = grid.Value.Owner;
ArenaGrid[admin.UserId] = grid?.Owner; _metaDataSystem.SetEntityName(grid.Value.Owner, $"ATAG-{admin.Name}");
if (grid != null)
_metaDataSystem.SetEntityName(grid.Value.Owner, $"ATAG-{admin.Name}");
return (map.Value.Owner, grid?.Owner); return (mapUid, grid.Value.Owner);
} }
} }