]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Revert #26994 and #27077 (#27090)
authorVasilis <vasilis@pikachu.systems>
Thu, 18 Apr 2024 15:06:56 +0000 (17:06 +0200)
committerGitHub <noreply@github.com>
Thu, 18 Apr 2024 15:06:56 +0000 (17:06 +0200)
18 files changed:
Content.IntegrationTests/Pair/TestMapData.cs
Content.IntegrationTests/Pair/TestPair.Helpers.cs
Content.IntegrationTests/Tests/Administration/Logs/AddTests.cs
Content.IntegrationTests/Tests/DeviceNetwork/DeviceNetworkTest.cs
Content.IntegrationTests/Tests/EntityTest.cs
Content.IntegrationTests/Tests/Fluids/PuddleTest.cs
Content.IntegrationTests/Tests/Interaction/InteractionTest.Helpers.cs
Content.IntegrationTests/Tests/Interaction/InteractionTest.cs
Content.IntegrationTests/Tests/Interaction/MovementTest.cs
Content.IntegrationTests/Tests/PrototypeSaveTest.cs
Content.IntegrationTests/Tests/Shuttle/DockTest.cs
Content.IntegrationTests/Tests/Tiles/TileConstructionTests.cs
Content.Server/GameTicking/Rules/PiratesRuleSystem.cs
Content.Server/Mapping/MappingCommand.cs
Content.Server/Salvage/SalvageSystem.Expeditions.cs
Content.Server/Salvage/SalvageSystem.cs
Content.Server/Salvage/SpawnSalvageMissionJob.cs
RobustToolbox

index 343641e16137aea778e9c2017a34369ed4066386..bdf12080388cef2e0cabc2ebced781eca7a4cbd2 100644 (file)
@@ -10,8 +10,9 @@ namespace Content.IntegrationTests.Pair;
 public sealed class TestMapData
 {
     public EntityUid MapUid { get; set; }
-    public Entity<MapGridComponent> Grid;
-    public MapId MapId;
+    public EntityUid GridUid { get; set; }
+    public MapId MapId { get; set; }
+    public MapGridComponent MapGrid { get; set; } = default!;
     public EntityCoordinates GridCoords { get; set; }
     public MapCoordinates MapCoords { get; set; }
     public TileRef Tile { get; set; }
@@ -20,4 +21,4 @@ public sealed class TestMapData
     public EntityUid CMapUid { get; set; }
     public EntityUid CGridUid { get; set; }
     public EntityCoordinates CGridCoords { get; set; }
-}
+}
\ No newline at end of file
index 0ea6d3e2dcc0798d58ab1d44a5ee11d25891aeea..554807b2d25051682e28ff374677251cb919e397 100644 (file)
@@ -1,6 +1,5 @@
 #nullable enable
 using System.Collections.Generic;
-using System.Diagnostics.CodeAnalysis;
 using System.Linq;
 using Robust.Shared.GameObjects;
 using Robust.Shared.Map;
@@ -15,37 +14,36 @@ public sealed partial class TestPair
     /// <summary>
     /// Creates a map, a grid, and a tile, and gives back references to them.
     /// </summary>
-    [MemberNotNull(nameof(TestMap))]
-    public async Task<TestMapData> CreateTestMap(bool initialized = true, string tile = "Plating")
+    public async Task<TestMapData> CreateTestMap()
     {
-        var mapData = new TestMapData();
-        TestMap = mapData;
         await Server.WaitIdleAsync();
         var tileDefinitionManager = Server.ResolveDependency<ITileDefinitionManager>();
 
+        var mapData = new TestMapData();
         TestMap = mapData;
         await Server.WaitPost(() =>
         {
-            mapData.MapUid = Server.System<SharedMapSystem>().CreateMap(out mapData.MapId, runMapInit: initialized);
-            mapData.Grid = Server.MapMan.CreateGridEntity(mapData.MapId);
-            mapData.GridCoords = new EntityCoordinates(mapData.Grid, 0, 0);
-            var plating = tileDefinitionManager[tile];
+            mapData.MapId = Server.MapMan.CreateMap();
+            mapData.MapUid = Server.MapMan.GetMapEntityId(mapData.MapId);
+            var mapGrid = Server.MapMan.CreateGridEntity(mapData.MapId);
+            mapData.MapGrid = mapGrid;
+            mapData.GridUid = mapGrid.Owner; // Fixing this requires an engine PR.
+            mapData.GridCoords = new EntityCoordinates(mapData.GridUid, 0, 0);
+            var plating = tileDefinitionManager["Plating"];
             var platingTile = new Tile(plating.TileId);
-            mapData.Grid.Comp.SetTile(mapData.GridCoords, platingTile);
+            mapData.MapGrid.SetTile(mapData.GridCoords, platingTile);
             mapData.MapCoords = new MapCoordinates(0, 0, mapData.MapId);
-            mapData.Tile = mapData.Grid.Comp.GetAllTiles().First();
+            mapData.Tile = mapData.MapGrid.GetAllTiles().First();
         });
 
-        TestMap = mapData;
         if (!Settings.Connected)
             return mapData;
 
         await RunTicksSync(10);
         mapData.CMapUid = ToClientUid(mapData.MapUid);
-        mapData.CGridUid = ToClientUid(mapData.Grid);
+        mapData.CGridUid = ToClientUid(mapData.GridUid);
         mapData.CGridCoords = new EntityCoordinates(mapData.CGridUid, 0, 0);
 
-        TestMap = mapData;
         return mapData;
     }
 
index 772af337a1aadbe30111ff8e8bdecf14311667cb..98c7363a6c4977522f8d11cc4f1fe0e3efe26f26 100644 (file)
@@ -32,8 +32,8 @@ public sealed class AddTests
 
         var guid = Guid.NewGuid();
 
-        await pair.CreateTestMap();
-        var coordinates = pair.TestMap.GridCoords;
+        var testMap = await pair.CreateTestMap();
+        var coordinates = testMap.GridCoords;
         await server.WaitPost(() =>
         {
             var entity = sEntities.SpawnEntity(null, coordinates);
index b37f7cfa46875515000b01becc23fb2557de5387..26ea726211b935cfd2a2255499f96e05d32ecaa7 100644 (file)
@@ -212,7 +212,7 @@ namespace Content.IntegrationTests.Tests.DeviceNetwork
             DeviceNetworkComponent networkComponent1 = null;
             DeviceNetworkComponent networkComponent2 = null;
             WiredNetworkComponent wiredNetworkComponent = null;
-            var grid = testMap.Grid.Comp;
+            var grid = testMap.MapGrid;
 
             var testValue = "test";
             var payload = new NetworkPayload
index d3b1fb47221df831d60153792bd52a024d9c5bb4..152eb725221b5096fb931285847240427f829e86 100644 (file)
@@ -354,18 +354,41 @@ namespace Content.IntegrationTests.Tests
 
             await using var pair = await PoolManager.GetServerClient();
             var server = pair.Server;
+
+            var mapManager = server.ResolveDependency<IMapManager>();
             var entityManager = server.ResolveDependency<IEntityManager>();
             var componentFactory = server.ResolveDependency<IComponentFactory>();
+            var tileDefinitionManager = server.ResolveDependency<ITileDefinitionManager>();
+            var mapSystem = entityManager.System<SharedMapSystem>();
             var logmill = server.ResolveDependency<ILogManager>().GetSawmill("EntityTest");
 
-            await pair.CreateTestMap();
+            Entity<MapGridComponent> grid = default!;
+
+            await server.WaitPost(() =>
+            {
+                // Create a one tile grid to stave off the grid 0 monsters
+                var mapId = mapManager.CreateMap();
+
+                mapManager.AddUninitializedMap(mapId);
+
+                grid = mapManager.CreateGridEntity(mapId);
+
+                var tileDefinition = tileDefinitionManager["Plating"];
+                var tile = new Tile(tileDefinition.TileId);
+                var coordinates = new EntityCoordinates(grid.Owner, Vector2.Zero);
+
+                mapSystem.SetTile(grid.Owner, grid.Comp!, coordinates, tile);
+
+                mapManager.DoMapInitialize(mapId);
+            });
+
             await server.WaitRunTicks(5);
-            var testLocation = pair.TestMap.GridCoords;
 
             await server.WaitAssertion(() =>
             {
                 Assert.Multiple(() =>
                 {
+                    var testLocation = new EntityCoordinates(grid.Owner, Vector2.Zero);
 
                     foreach (var type in componentFactory.AllRegisteredTypes)
                     {
index a9069892dffdb68a8f816787e1f2bfa70f26b7de..611af6738095b9d9c21c106bc8c7e4cd54503df4 100644 (file)
@@ -46,14 +46,17 @@ namespace Content.IntegrationTests.Tests.Fluids
             var server = pair.Server;
 
             var testMap = await pair.CreateTestMap();
-            var grid = testMap.Grid.Comp;
 
             var entitySystemManager = server.ResolveDependency<IEntitySystemManager>();
             var spillSystem = entitySystemManager.GetEntitySystem<PuddleSystem>();
 
+            MapGridComponent grid = null;
+
             // Remove all tiles
             await server.WaitPost(() =>
             {
+                grid = testMap.MapGrid;
+
                 foreach (var tile in grid.GetAllTiles())
                 {
                     grid.SetTile(tile.GridIndices, Tile.Empty);
index 480fd9cde6fa3c8292a2dccc37346eaf61f11ab5..88448e7b80023bf6fa7d2fa78783e932122724bf 100644 (file)
@@ -989,7 +989,7 @@ public abstract partial class InteractionTest
     /// </summary>
     protected async Task AddGravity(EntityUid? uid = null)
     {
-        var target = uid ?? MapData.Grid;
+        var target = uid ?? MapData.GridUid;
         await Server.WaitPost(() =>
         {
             var gravity = SEntMan.EnsureComponent<GravityComponent>(target);
index a4ed31e9983d0281df40922e268da78ce424e94f..bed27ba6efe0ffa770f7df9fd7b969778945af67 100644 (file)
@@ -184,7 +184,7 @@ public abstract partial class InteractionTest
         await Pair.CreateTestMap();
         PlayerCoords = SEntMan.GetNetCoordinates(MapData.GridCoords.Offset(new Vector2(0.5f, 0.5f)).WithEntityId(MapData.MapUid, Transform, SEntMan));
         TargetCoords = SEntMan.GetNetCoordinates(MapData.GridCoords.Offset(new Vector2(1.5f, 0.5f)).WithEntityId(MapData.MapUid, Transform, SEntMan));
-        await SetTile(Plating, grid: MapData.Grid.Comp);
+        await SetTile(Plating, grid: MapData.MapGrid);
 
         // Get player data
         var sPlayerMan = Server.ResolveDependency<Robust.Server.Player.IPlayerManager>();
index dc5aec92cfc71107470d545a50b83ffe0291b49d..553b031c2b7112bca21cb2e707eda5df21ba6651 100644 (file)
@@ -31,7 +31,7 @@ public abstract class MovementTest : InteractionTest
 
         for (var i = -Tiles; i <= Tiles; i++)
         {
-            await SetTile(Plating, SEntMan.GetNetCoordinates(pCoords.Offset(new Vector2(i, 0))), MapData.Grid.Comp);
+            await SetTile(Plating, SEntMan.GetNetCoordinates(pCoords.Offset(new Vector2(i, 0))), MapData.MapGrid);
         }
         AssertGridCount(1);
 
index 9e26fa5eaa280d792268ee4909a71639e5a18b24..e4a9c1a840dfc1f1648c28a69274f21dc5268a32 100644 (file)
@@ -38,15 +38,31 @@ public sealed class PrototypeSaveTest
         var mapManager = server.ResolveDependency<IMapManager>();
         var entityMan = server.ResolveDependency<IEntityManager>();
         var prototypeMan = server.ResolveDependency<IPrototypeManager>();
+        var tileDefinitionManager = server.ResolveDependency<ITileDefinitionManager>();
         var seriMan = server.ResolveDependency<ISerializationManager>();
         var compFact = server.ResolveDependency<IComponentFactory>();
 
         var prototypes = new List<EntityPrototype>();
+        MapGridComponent grid = default!;
         EntityUid uid;
+        MapId mapId = default;
 
-        await pair.CreateTestMap(false, "FloorSteel"); // Wires n such disable ambiance while under the floor
-        var mapId = pair.TestMap.MapId;
-        var grid = pair.TestMap.Grid;
+        //Build up test environment
+        await server.WaitPost(() =>
+        {
+            // Create a one tile grid to stave off the grid 0 monsters
+            mapId = mapManager.CreateMap();
+
+            mapManager.AddUninitializedMap(mapId);
+
+            grid = mapManager.CreateGrid(mapId);
+
+            var tileDefinition = tileDefinitionManager["FloorSteel"]; // Wires n such disable ambiance while under the floor
+            var tile = new Tile(tileDefinition.TileId);
+            var coordinates = grid.Owner.ToCoordinates();
+
+            grid.SetTile(coordinates, tile);
+        });
 
         await server.WaitRunTicks(5);
 
index a1aa462a6973e38d10e8dd0572858f5877bdd399..b6fc273570a151b51ca1990e8720e1488ab28420 100644 (file)
@@ -39,7 +39,7 @@ public sealed class DockTest : ContentUnitTest
 
         await server.WaitAssertion(() =>
         {
-            entManager.DeleteEntity(map.Grid);
+            entManager.DeleteEntity(map.GridUid);
             var grid1 = mapManager.CreateGridEntity(mapId);
             var grid2 = mapManager.CreateGridEntity(mapId);
             var grid1Ent = grid1.Owner;
@@ -104,7 +104,7 @@ public sealed class DockTest : ContentUnitTest
         // Spawn shuttle and affirm no valid docks.
         await server.WaitAssertion(() =>
         {
-            entManager.DeleteEntity(map.Grid);
+            entManager.DeleteEntity(map.GridUid);
             Assert.That(entManager.System<MapLoaderSystem>().TryLoad(otherMap.MapId, "/Maps/Shuttles/emergency.yml", out var rootUids));
             shuttle = rootUids[0];
 
index 083e817d69754ea8f755ba5d4f2265bd5f3b179f..0a2af88887a8f85b522d93f81fd3ae2a56e9a6bc 100644 (file)
@@ -37,7 +37,7 @@ public sealed class TileConstructionTests : InteractionTest
         // Remove grid
         await SetTile(null);
         await SetTile(null, PlayerCoords);
-        Assert.That(MapData.Grid.Comp.Deleted);
+        Assert.That(MapData.MapGrid.Deleted);
         AssertGridCount(0);
 
         // Place Lattice
@@ -70,7 +70,7 @@ public sealed class TileConstructionTests : InteractionTest
         // Remove grid
         await SetTile(null);
         await SetTile(null, PlayerCoords);
-        Assert.That(MapData.Grid.Comp.Deleted);
+        Assert.That(MapData.MapGrid.Deleted);
         AssertGridCount(0);
 
         // Space -> Lattice
index 0a749d2e01c7bc191a12f97c274b5440bd31a0e4..818d3c6e94ce7f18e0bd6e39fb97905362eb5008 100644 (file)
@@ -24,7 +24,6 @@ using Robust.Shared.Audio.Systems;
 using Robust.Shared.Configuration;
 using Robust.Shared.Enums;
 using Robust.Shared.Map;
-using Robust.Shared.Map.Components;
 using Robust.Shared.Player;
 using Robust.Shared.Prototypes;
 using Robust.Shared.Random;
@@ -181,7 +180,7 @@ public sealed class PiratesRuleSystem : GameRuleSystem<PiratesRuleComponent>
 
             var aabbs = EntityQuery<StationDataComponent>().SelectMany(x =>
                     x.Grids.Select(x =>
-                        xformQuery.GetComponent(x).WorldMatrix.TransformBox(Comp<MapGridComponent>(x).LocalAABB)))
+                        xformQuery.GetComponent(x).WorldMatrix.TransformBox(_mapManager.GetGridComp(x).LocalAABB)))
                 .ToArray();
 
             var aabb = aabbs[0];
index 08f3dcccf9fb2d44651ee75d970fe7b3329a6f45..08ba0de83346d4746cb459b4d7fdf62d75c04768 100644 (file)
@@ -1,14 +1,17 @@
+// ReSharper disable once RedundantUsingDirective
+// Used to warn the player in big red letters in debug mode
+
 using System.Linq;
 using Content.Server.Administration;
 using Content.Server.GameTicking;
 using Content.Shared.Administration;
 using Content.Shared.CCVar;
-using Robust.Server.GameObjects;
-using Robust.Server.Maps;
+using Robust.Server.Player;
 using Robust.Shared.Configuration;
 using Robust.Shared.Console;
 using Robust.Shared.ContentPack;
 using Robust.Shared.Map;
+using Robust.Shared.Utility;
 
 namespace Content.Server.Mapping
 {
@@ -16,8 +19,6 @@ namespace Content.Server.Mapping
     sealed class MappingCommand : IConsoleCommand
     {
         [Dependency] private readonly IEntityManager _entities = default!;
-        [Dependency] private readonly IMapManager _map = default!;
-        [Dependency] private readonly IConfigurationManager _cfg = default!;
 
         public string Command => "mapping";
         public string Description => Loc.GetString("cmd-mapping-desc");
@@ -56,13 +57,13 @@ namespace Content.Server.Mapping
             shell.WriteError(Loc.GetString("cmd-mapping-warning"));
 #endif
 
+            var mapManager = IoCManager.Resolve<IMapManager>();
             MapId mapId;
-            string? toLoad = null;
-            var mapSys = _entities.System<SharedMapSystem>();
 
             // Get the map ID to use
             if (args.Length is 1 or 2)
             {
+
                 if (!int.TryParse(args[0], out var intMapId))
                 {
                     shell.WriteError(Loc.GetString("cmd-mapping-failure-integer", ("arg", args[0])));
@@ -78,33 +79,35 @@ namespace Content.Server.Mapping
                     return;
                 }
 
-                if (_map.MapExists(mapId))
+                if (mapManager.MapExists(mapId))
                 {
                     shell.WriteError(Loc.GetString("cmd-mapping-exists", ("mapId", mapId)));
                     return;
                 }
 
-                // either load a map or create a new one.
-                if (args.Length <= 1)
-                {
-                    mapSys.CreateMap(mapId, runMapInit: false);
-                }
-                else
-                {
-                    var loadOptions = new MapLoadOptions {StoreMapUids = true};
-                    _entities.System<MapLoaderSystem>().TryLoad(mapId, args[1], out _, loadOptions);
-                }
+            }
+            else
+            {
+                mapId = mapManager.NextMapId();
+            }
 
-                // was the map actually created or did it fail somehow?
-                if (!_map.MapExists(mapId))
-                {
-                    shell.WriteError(Loc.GetString("cmd-mapping-error"));
-                    return;
-                }
+            string? toLoad = null;
+            // either load a map or create a new one.
+            if (args.Length <= 1)
+            {
+                shell.ExecuteCommand($"addmap {mapId} false");
             }
             else
             {
-                mapSys.CreateMap(out mapId, runMapInit: false);
+                toLoad = CommandParsing.Escape(args[1]);
+                shell.ExecuteCommand($"loadmap {mapId} \"{toLoad}\" 0 0 0 true");
+            }
+
+            // was the map actually created?
+            if (!mapManager.MapExists(mapId))
+            {
+                shell.WriteError(Loc.GetString("cmd-mapping-error"));
+                return;
             }
 
             // map successfully created. run misc helpful mapping commands
@@ -114,15 +117,17 @@ namespace Content.Server.Mapping
                 shell.ExecuteCommand("aghost");
             }
 
+            var cfg = IoCManager.Resolve<IConfigurationManager>();
+
             // don't interrupt mapping with events or auto-shuttle
             shell.ExecuteCommand("sudo cvar events.enabled false");
             shell.ExecuteCommand("sudo cvar shuttle.auto_call_time 0");
 
-            if (_cfg.GetCVar(CCVars.AutosaveEnabled))
+            if (cfg.GetCVar(CCVars.AutosaveEnabled))
                 shell.ExecuteCommand($"toggleautosave {mapId} {toLoad ?? "NEWMAP"}");
             shell.ExecuteCommand($"tp 0 0 {mapId}");
             shell.RemoteExecuteCommand("mappingclientsidesetup");
-            _map.SetMapPaused(mapId, true);
+            mapManager.SetMapPaused(mapId, true);
 
             if (args.Length == 2)
                 shell.WriteLine(Loc.GetString("cmd-mapping-success-load",("mapId",mapId),("path", args[1])));
index 4d5d569dabd45f8dd55c11794966a3c36bf9d994..839730ec8733d584beee9ef08345dcbd5e0504d3 100644 (file)
@@ -164,7 +164,6 @@ public sealed partial class SalvageSystem
             _dungeon,
             _metaData,
             _transform,
-            _mapSystem,
             station,
             coordinatesDisk,
             missionParams,
index eb5719c892f837ecef3f091a177342a5f4788d76..9af4736345ed8ac5ff1f8926411f55e177b14dfd 100644 (file)
@@ -40,6 +40,7 @@ namespace Content.Server.Salvage
     {
         [Dependency] private readonly IChatManager _chat = default!;
         [Dependency] private readonly IConfigurationManager _configurationManager = default!;
+        [Dependency] private readonly IEntityManager _entManager = default!;
         [Dependency] private readonly IGameTiming _timing = default!;
         [Dependency] private readonly ILogManager _logManager = default!;
         [Dependency] private readonly IMapManager _mapManager = default!;
@@ -55,7 +56,6 @@ namespace Content.Server.Salvage
         [Dependency] private readonly RadioSystem _radioSystem = default!;
         [Dependency] private readonly SharedAudioSystem _audio = default!;
         [Dependency] private readonly SharedTransformSystem _transform = default!;
-        [Dependency] private readonly SharedMapSystem _mapSystem = default!;
         [Dependency] private readonly ShuttleSystem _shuttle = default!;
         [Dependency] private readonly ShuttleConsoleSystem _shuttleConsoles = default!;
         [Dependency] private readonly StationSystem _station = default!;
index 47123e978454baa8fdd39db8424871e683a0de38..180c8d145cf131c329a386db390c8f640f186478 100644 (file)
@@ -50,7 +50,6 @@ public sealed class SpawnSalvageMissionJob : Job<bool>
     private readonly DungeonSystem _dungeon;
     private readonly MetaDataSystem _metaData;
     private readonly SharedTransformSystem _xforms;
-    private readonly SharedMapSystem _map;
 
     public readonly EntityUid Station;
     public readonly EntityUid? CoordinatesDisk;
@@ -70,7 +69,6 @@ public sealed class SpawnSalvageMissionJob : Job<bool>
         DungeonSystem dungeon,
         MetaDataSystem metaData,
         SharedTransformSystem xform,
-        SharedMapSystem map,
         EntityUid station,
         EntityUid? coordinatesDisk,
         SalvageMissionParams missionParams,
@@ -85,7 +83,6 @@ public sealed class SpawnSalvageMissionJob : Job<bool>
         _dungeon = dungeon;
         _metaData = metaData;
         _xforms = xform;
-        _map = map;
         Station = station;
         CoordinatesDisk = coordinatesDisk;
         _missionParams = missionParams;
@@ -98,7 +95,9 @@ public sealed class SpawnSalvageMissionJob : Job<bool>
     protected override async Task<bool> Process()
     {
         _sawmill.Debug("salvage", $"Spawning salvage mission with seed {_missionParams.Seed}");
-        var mapUid = _map.CreateMap(out var mapId, runMapInit: false);
+        var mapId = _mapManager.CreateMap();
+        var mapUid = _mapManager.GetMapEntityId(mapId);
+        _mapManager.AddUninitializedMap(mapId);
         MetaDataComponent? metadata = null;
         var grid = _entManager.EnsureComponent<MapGridComponent>(mapUid);
         var random = new Random(_missionParams.Seed);
index f5a6e52c7fefa568296d52aab9b894e1a8bd9122..19010597553d15f5ca239497ac66eab876ecc720 160000 (submodule)
@@ -1 +1 @@
-Subproject commit f5a6e52c7fefa568296d52aab9b894e1a8bd9122
+Subproject commit 19010597553d15f5ca239497ac66eab876ecc720