]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix admin test arena (#35444)
authormetalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Mon, 24 Feb 2025 06:05:59 +0000 (17:05 +1100)
committerGitHub <noreply@github.com>
Mon, 24 Feb 2025 06:05:59 +0000 (17:05 +1100)
* Fix admin test arena

* Add to GridsLoadableTest

* QueueDel map, remove nullable

---------

Co-authored-by: ElectroJr <leonsfriedrich@gmail.com>
Content.IntegrationTests/Tests/PostMapInitTest.cs
Content.Server/Administration/Systems/AdminTestArenaSystem.cs

index 65eac0a6985ab90aef57739ada3338b46f59e310..177161d5870444b93a46c27a7b3569bf3d1ab574 100644 (file)
@@ -1,6 +1,7 @@
 using System.Collections.Generic;
 using System.IO;
 using System.Linq;
+using Content.Server.Administration.Systems;
 using Content.Server.GameTicking;
 using Content.Server.Maps;
 using Content.Server.Shuttles.Components;
@@ -38,7 +39,8 @@ namespace Content.IntegrationTests.Tests
 
         private static readonly string[] Grids =
         {
-            "/Maps/centcomm.yml"
+            "/Maps/centcomm.yml",
+            AdminTestArenaSystem.ArenaMapPath
         };
 
         private static readonly string[] DoNotMapWhitelist =
index 12bf0eba6484de510fccdf3f66b72171d8df94c9..f45af60f6d2561fc4a718cc8bccda2478dcd01af 100644 (file)
@@ -12,6 +12,7 @@ public sealed class AdminTestArenaSystem : EntitySystem
 {
     [Dependency] private readonly MapLoaderSystem _loader = default!;
     [Dependency] private readonly MetaDataSystem _metaDataSystem = default!;
+    [Dependency] private readonly SharedMapSystem _maps = default!;
 
     public const string ArenaMapPath = "/Maps/Test/admin_test_arena.yml";
 
@@ -33,17 +34,20 @@ public sealed class AdminTestArenaSystem : EntitySystem
         }
 
         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");
+        }
 
-        ArenaMap[admin.UserId] = map.Value.Owner;
-        _metaDataSystem.SetEntityName(map.Value.Owner, $"ATAM-{admin.Name}");
+        ArenaMap[admin.UserId] = mapUid;
+        _metaDataSystem.SetEntityName(mapUid, $"ATAM-{admin.Name}");
 
-        var grid = grids.FirstOrNull();
-        ArenaGrid[admin.UserId] = grid?.Owner;
-        if (grid != null)
-            _metaDataSystem.SetEntityName(grid.Value.Owner, $"ATAG-{admin.Name}");
+        ArenaGrid[admin.UserId] = grid.Value.Owner;
+        _metaDataSystem.SetEntityName(grid.Value.Owner, $"ATAG-{admin.Name}");
 
-        return (map.Value.Owner, grid?.Owner);
+        return (mapUid, grid.Value.Owner);
     }
 }