diff --git a/Content.IntegrationTests/ContentIntegrationTest.cs b/Content.IntegrationTests/ContentIntegrationTest.cs index 765d3ade75..738544be80 100644 --- a/Content.IntegrationTests/ContentIntegrationTest.cs +++ b/Content.IntegrationTests/ContentIntegrationTest.cs @@ -1,31 +1,56 @@ using System; +using System.Linq; using System.Threading.Tasks; +using Content.Client.Entry; using Content.Client.IoC; using Content.Client.Parallax.Managers; using Content.Server.GameTicking; using Content.Server.IoC; using Content.Shared.CCVar; -using Moq; using NUnit.Framework; using Robust.Client; using Robust.Server; -using Robust.Server.Maps; -using Robust.Shared; +using Robust.Server.Player; using Robust.Shared.ContentPack; using Robust.Shared.GameObjects; using Robust.Shared.IoC; using Robust.Shared.Log; using Robust.Shared.Map; using Robust.Shared.Network; -using Robust.Shared.Timing; +using Robust.Shared.Prototypes; using Robust.UnitTesting; -using EntryPoint = Content.Client.Entry.EntryPoint; namespace Content.IntegrationTests { [Parallelizable(ParallelScope.All)] public abstract class ContentIntegrationTest : RobustIntegrationTest { + private static readonly (string cvar, string value, bool)[] ServerTestCvars = { + // Avoid funny race conditions with the database. + (CCVars.DatabaseSynchronous.Name, "true", false), + + // Disable holidays as some of them might mess with the map at round start. + (CCVars.HolidaysEnabled.Name, "false", false), + + // Avoid loading a large map by default for integration tests if none has been specified. + (CCVars.GameMap.Name, "Maps/Test/empty.yml", true) + }; + + private static void SetServerTestCvars(IntegrationOptions options) + { + foreach (var (cvar, value, tryAdd) in ServerTestCvars) + { + if (tryAdd) + { + options.CVarOverrides.TryAdd(cvar, value); + } + else + { + options.CVarOverrides[cvar] = value; + } + } + } + protected sealed override ClientIntegrationInstance StartClient(ClientIntegrationOptions options = null) { options ??= new ClientContentIntegrationOption() @@ -33,6 +58,8 @@ namespace Content.IntegrationTests FailureLogLevel = LogLevel.Warning }; + options.Pool = ShouldPool(options, false); + // Load content resources, but not config and user data. options.Options = new GameControllerOptions() { @@ -71,11 +98,14 @@ namespace Content.IntegrationTests protected override ServerIntegrationInstance StartServer(ServerIntegrationOptions options = null) { - options ??= new ServerContentIntegrationOption() + options ??= new ServerContentIntegrationOption { - FailureLogLevel = LogLevel.Warning + FailureLogLevel = LogLevel.Warning, }; + SetServerTestCvars(options); + options.Pool = ShouldPool(options, true); + // Load content resources, but not config and user data. options.Options = new ServerOptions() { @@ -108,16 +138,6 @@ namespace Content.IntegrationTests IoCManager.Resolve().GetSawmill("loc").Level = LogLevel.Error; }; - // Avoid funny race conditions with the database. - options.CVarOverrides[CCVars.DatabaseSynchronous.Name] = "true"; - - // Disable holidays as some of them might mess with the map at round start. - options.CVarOverrides[CCVars.HolidaysEnabled.Name] = "false"; - - // Avoid loading a large map by default for integration tests if none has been specified. - if(!options.CVarOverrides.ContainsKey(CCVars.GameMap.Name)) - options.CVarOverrides[CCVars.GameMap.Name] = "Maps/Test/empty.yml"; - return base.StartServer(options); } @@ -150,7 +170,6 @@ namespace Content.IntegrationTests return (client, server); } - protected async Task<(ClientIntegrationInstance client, ServerIntegrationInstance server)> StartConnectedServerDummyTickerClientPair(ClientIntegrationOptions clientOptions = null, ServerIntegrationOptions serverOptions = null) @@ -163,30 +182,129 @@ namespace Content.IntegrationTests return (client, server); } - protected async Task InitializeMap(ServerIntegrationInstance server, string mapPath) + private bool ShouldPool(IntegrationOptions options, bool server) { - await server.WaitIdleAsync(); - - var mapManager = server.ResolveDependency(); - var pauseManager = server.ResolveDependency(); - var mapLoader = server.ResolveDependency(); - - IMapGrid grid = null; - - server.Post(() => + if (options.Pool == false) { - var mapId = mapManager.CreateMap(); + return false; + } - pauseManager.AddUninitializedMap(mapId); + if (server) + { + if (options.CVarOverrides.Count != 3) + { + return false; + } - grid = mapLoader.LoadBlueprint(mapId, mapPath); + foreach (var (cvar, value, _) in ServerTestCvars) + { + if (!options.CVarOverrides.TryGetValue(cvar, out var actualValue) || + actualValue != value) + { + return false; + } + } + } - pauseManager.DoMapInitialize(mapId); + if (options.CVarOverrides.TryGetValue(CCVars.GameDummyTicker.Name, out var dummy) && + dummy == "true") + { + return false; + } + + if (options.CVarOverrides.TryGetValue(CCVars.GameLobbyEnabled.Name, out var lobby) && + lobby == "true") + { + return false; + } + + if (options is ClientContentIntegrationOption {ContentBeforeIoC: { }} + or ServerContentIntegrationOption {ContentBeforeIoC: { }}) + { + return false; + } + + return options.InitIoC == null && + options.BeforeStart == null && + options.ContentAssemblies == null; + } + + protected override async Task OnClientReturn(ClientIntegrationInstance client) + { + await base.OnClientReturn(client); + + await client.WaitIdleAsync(); + + var net = client.ResolveDependency(); + var prototypes = client.ResolveDependency(); + + await client.WaitPost(() => + { + net.ClientDisconnect("Test pooling disconnect"); + + if (client.PreviousOptions?.ExtraPrototypes is { } oldExtra) + { + prototypes.RemoveString(oldExtra); + } + + if (client.Options?.ExtraPrototypes is { } extra) + { + prototypes.LoadString(extra, true); + prototypes.Resync(); + } }); + await WaitUntil(client, () => !net.IsConnected); + } + + protected override async Task OnServerReturn(ServerIntegrationInstance server) + { + await base.OnServerReturn(server); + await server.WaitIdleAsync(); - return grid; + if (server.Options != null) + { + SetServerTestCvars(server.Options); + } + + var systems = server.ResolveDependency(); + var prototypes = server.ResolveDependency(); + var net = server.ResolveDependency(); + var players = server.ResolveDependency(); + + var gameTicker = systems.GetEntitySystem(); + + await server.WaitPost(() => + { + foreach (var channel in net.Channels) + { + net.DisconnectChannel(channel, "Test pooling disconnect"); + } + }); + + await WaitUntil(server, () => players.PlayerCount == 0); + + await server.WaitPost(() => + { + gameTicker.RestartRound(); + + if (server.PreviousOptions?.ExtraPrototypes is { } oldExtra) + { + prototypes.RemoveString(oldExtra); + } + + if (server.Options?.ExtraPrototypes is { } extra) + { + prototypes.LoadString(extra, true); + prototypes.Resync(); + } + }); + + if (!gameTicker.DummyTicker) + { + await WaitUntil(server, () => gameTicker.RunLevel == GameRunLevel.InRound); + } } protected async Task WaitUntil(IntegrationInstance instance, Func func, int maxTicks = 600, @@ -211,6 +329,12 @@ namespace Content.IntegrationTests ticksAwaited += ticksToRun; } + if (!passed) + { + Assert.Fail($"Condition did not pass after {maxTicks} ticks.\n" + + $"Tests ran ({instance.TestsRan.Count}):\n" + + $"{string.Join('\n', instance.TestsRan)}"); + } Assert.That(passed); } @@ -239,6 +363,30 @@ namespace Content.IntegrationTests } } + protected MapId GetMainMapId(IMapManager manager) + { + // TODO a heuristic that is not this bad + return manager.GetAllMapIds().Last(); + } + + protected IMapGrid GetMainGrid(IMapManager manager) + { + // TODO a heuristic that is not this bad + return manager.GetAllGrids().First(); + } + + protected TileRef GetMainTile(IMapGrid grid) + { + // TODO a heuristic that is not this bad + return grid.GetAllTiles().First(); + } + + protected EntityCoordinates GetMainEntityCoordinates(IMapManager manager) + { + var gridId = GetMainGrid(manager).GridEntityId; + return new EntityCoordinates(gridId, -0.5f, -0.5f); + } + protected sealed class ClientContentIntegrationOption : ClientIntegrationOptions { public ClientContentIntegrationOption() diff --git a/Content.IntegrationTests/ContentIntegrationTestSetup.cs b/Content.IntegrationTests/ContentIntegrationTestSetup.cs new file mode 100644 index 0000000000..eea68fa0b7 --- /dev/null +++ b/Content.IntegrationTests/ContentIntegrationTestSetup.cs @@ -0,0 +1,15 @@ +using NUnit.Framework; + +[SetUpFixture] +// ReSharper disable once CheckNamespace +public class ContentIntegrationTestSetup +{ + [OneTimeTearDown] + public void TearDown() + { + var robustSetup = new RobustIntegrationTestSetup(); + + robustSetup.Shutdown(); + robustSetup.PrintTestPoolingInfo(); + } +} diff --git a/Content.IntegrationTests/Tests/AI/BehaviorSetsTest.cs b/Content.IntegrationTests/Tests/AI/BehaviorSetsTest.cs index 849eae250d..f0db8cc07b 100644 --- a/Content.IntegrationTests/Tests/AI/BehaviorSetsTest.cs +++ b/Content.IntegrationTests/Tests/AI/BehaviorSetsTest.cs @@ -7,7 +7,6 @@ using Content.Server.AI.Utility.AiLogic; using NUnit.Framework; using Robust.Shared.Prototypes; using Robust.Shared.Reflection; -using YamlDotNet.RepresentationModel; namespace Content.IntegrationTests.Tests.AI { @@ -18,8 +17,7 @@ namespace Content.IntegrationTests.Tests.AI [Test] public async Task TestBehaviorSets() { - var options = new ServerIntegrationOptions(); - var server = StartServerDummyTicker(options); + var server = StartServer(); await server.WaitIdleAsync(); var protoManager = server.ResolveDependency(); diff --git a/Content.IntegrationTests/Tests/Access/AccessReaderTest.cs b/Content.IntegrationTests/Tests/Access/AccessReaderTest.cs index d64f2a934d..5587ed14d8 100644 --- a/Content.IntegrationTests/Tests/Access/AccessReaderTest.cs +++ b/Content.IntegrationTests/Tests/Access/AccessReaderTest.cs @@ -15,7 +15,7 @@ namespace Content.Tests.Server.GameObjects.Components.Access [Test] public async Task TestTags() { - var server = StartServerDummyTicker(); + var server = StartServer(); await server.WaitAssertion(() => { var system = EntitySystem.Get(); diff --git a/Content.IntegrationTests/Tests/Atmos/ConstantsTest.cs b/Content.IntegrationTests/Tests/Atmos/ConstantsTest.cs index a2cacb4fd2..c02ca700c1 100644 --- a/Content.IntegrationTests/Tests/Atmos/ConstantsTest.cs +++ b/Content.IntegrationTests/Tests/Atmos/ConstantsTest.cs @@ -15,7 +15,7 @@ namespace Content.IntegrationTests.Tests.Atmos [Test] public async Task TotalGasesTest() { - var server = StartServerDummyTicker(); + var server = StartServer(); await server.WaitIdleAsync(); diff --git a/Content.IntegrationTests/Tests/Atmos/GasMixtureTest.cs b/Content.IntegrationTests/Tests/Atmos/GasMixtureTest.cs index b3fb1751c9..e3aa4617e9 100644 --- a/Content.IntegrationTests/Tests/Atmos/GasMixtureTest.cs +++ b/Content.IntegrationTests/Tests/Atmos/GasMixtureTest.cs @@ -14,7 +14,7 @@ namespace Content.IntegrationTests.Tests.Atmos [Test] public async Task TestMerge() { - var server = StartServerDummyTicker(); + var server = StartServer(); await server.WaitIdleAsync(); @@ -60,7 +60,7 @@ namespace Content.IntegrationTests.Tests.Atmos [TestCase(Atmospherics.BreathPercentage)] public async Task RemoveRatio(float ratio) { - var server = StartServerDummyTicker(); + var server = StartServer(); server.Assert(() => { diff --git a/Content.IntegrationTests/Tests/Body/LegTest.cs b/Content.IntegrationTests/Tests/Body/LegTest.cs index 2153606b5b..e06b2a314d 100644 --- a/Content.IntegrationTests/Tests/Body/LegTest.cs +++ b/Content.IntegrationTests/Tests/Body/LegTest.cs @@ -34,7 +34,7 @@ namespace Content.IntegrationTests.Tests.Body public async Task RemoveLegsFallTest() { var options = new ServerContentIntegrationOption{ExtraPrototypes = Prototypes}; - var server = StartServerDummyTicker(options); + var server = StartServer(options); AppearanceComponent appearance = null; diff --git a/Content.IntegrationTests/Tests/Body/LungTest.cs b/Content.IntegrationTests/Tests/Body/LungTest.cs index b529a2abe1..90aab55410 100644 --- a/Content.IntegrationTests/Tests/Body/LungTest.cs +++ b/Content.IntegrationTests/Tests/Body/LungTest.cs @@ -52,7 +52,7 @@ namespace Content.IntegrationTests.Tests.Body public async Task AirConsistencyTest() { var options = new ServerContentIntegrationOption{ExtraPrototypes = Prototypes}; - var server = StartServerDummyTicker(options); + var server = StartServer(options); server.Assert(() => { @@ -139,7 +139,7 @@ namespace Content.IntegrationTests.Tests.Body public async Task NoSuffocationTest() { var options = new ServerContentIntegrationOption{ExtraPrototypes = Prototypes}; - var server = StartServerDummyTicker(options); + var server = StartServer(options); await server.WaitIdleAsync(); diff --git a/Content.IntegrationTests/Tests/Body/MechanismBehaviorEventsTest.cs b/Content.IntegrationTests/Tests/Body/MechanismBehaviorEventsTest.cs index 8536e940f2..9b175edcd5 100644 --- a/Content.IntegrationTests/Tests/Body/MechanismBehaviorEventsTest.cs +++ b/Content.IntegrationTests/Tests/Body/MechanismBehaviorEventsTest.cs @@ -117,7 +117,7 @@ namespace Content.IntegrationTests.Tests.Body public async Task EventsTest() { var options = new ServerContentIntegrationOption {ExtraPrototypes = Prototypes}; - var server = StartServerDummyTicker(options); + var server = StartServer(options); await server.WaitAssertion(() => { diff --git a/Content.IntegrationTests/Tests/Buckle/BuckleTest.cs b/Content.IntegrationTests/Tests/Buckle/BuckleTest.cs index f28578a252..3a101ac2eb 100644 --- a/Content.IntegrationTests/Tests/Buckle/BuckleTest.cs +++ b/Content.IntegrationTests/Tests/Buckle/BuckleTest.cs @@ -8,8 +8,6 @@ using Content.Shared.Body.Components; using Content.Shared.Body.Part; using Content.Shared.Buckle.Components; using Content.Shared.Coordinates; -using Content.Shared.Interaction.Events; -using Content.Shared.Movement; using Content.Shared.Standing; using NUnit.Framework; using Robust.Server.Player; @@ -73,8 +71,7 @@ namespace Content.IntegrationTests.Tests.Buckle var actionBlocker = EntitySystem.Get(); var standingState = EntitySystem.Get(); - var gridId = new GridId(1); - var grid = mapManager.GetGrid(gridId); + var grid = GetMainGrid(mapManager); var coordinates = grid.GridEntityId.ToCoordinates(); human = entityManager.SpawnEntity(BuckleDummyId, coordinates); @@ -235,8 +232,7 @@ namespace Content.IntegrationTests.Tests.Buckle var mapManager = IoCManager.Resolve(); var entityManager = IoCManager.Resolve(); - var gridId = new GridId(1); - var grid = mapManager.GetGrid(gridId); + var grid = GetMainGrid(mapManager); var coordinates = grid.GridEntityId.ToCoordinates(); human = entityManager.SpawnEntity(BuckleDummyId, coordinates); @@ -321,8 +317,7 @@ namespace Content.IntegrationTests.Tests.Buckle var mapManager = IoCManager.Resolve(); var entityManager = IoCManager.Resolve(); - var gridId = new GridId(1); - var grid = mapManager.GetGrid(gridId); + var grid = GetMainGrid(mapManager); var coordinates = grid.GridEntityId.ToCoordinates(); human = entityManager.SpawnEntity(BuckleDummyId, coordinates); diff --git a/Content.IntegrationTests/Tests/Chemistry/TryAllReactionsTest.cs b/Content.IntegrationTests/Tests/Chemistry/TryAllReactionsTest.cs index c976ba08cd..684d857272 100644 --- a/Content.IntegrationTests/Tests/Chemistry/TryAllReactionsTest.cs +++ b/Content.IntegrationTests/Tests/Chemistry/TryAllReactionsTest.cs @@ -19,13 +19,14 @@ namespace Content.IntegrationTests.Tests.Chemistry [Test] public async Task TryAllTest() { - var server = StartServerDummyTicker(); + var server = StartServer(); await server.WaitIdleAsync(); - var mapManager = server.ResolveDependency(); var entityManager = server.ResolveDependency(); var prototypeManager = server.ResolveDependency(); + var mapManager = server.ResolveDependency(); + var coordinates = GetMainEntityCoordinates(mapManager); foreach (var reactionPrototype in prototypeManager.EnumeratePrototypes()) { @@ -37,9 +38,7 @@ namespace Content.IntegrationTests.Tests.Chemistry server.Assert(() => { - mapManager.CreateNewMapEntity(MapId.Nullspace); - - beaker = entityManager.SpawnEntity("BluespaceBeaker", MapCoordinates.Nullspace); + beaker = entityManager.SpawnEntity("BluespaceBeaker", coordinates); Assert.That(EntitySystem.Get() .TryGetSolution(beaker.Uid, "beaker", out component)); foreach (var (id, reactant) in reactionPrototype.Reactants) diff --git a/Content.IntegrationTests/Tests/Commands/RejuvenateTest.cs b/Content.IntegrationTests/Tests/Commands/RejuvenateTest.cs index 6860b0b36d..25df0048f9 100644 --- a/Content.IntegrationTests/Tests/Commands/RejuvenateTest.cs +++ b/Content.IntegrationTests/Tests/Commands/RejuvenateTest.cs @@ -34,7 +34,7 @@ namespace Content.IntegrationTests.Tests.Commands public async Task RejuvenateDeadTest() { var options = new ServerIntegrationOptions{ExtraPrototypes = Prototypes}; - var server = StartServerDummyTicker(options); + var server = StartServer(options); await server.WaitAssertion(() => { diff --git a/Content.IntegrationTests/Tests/Construction/ConstructionActionValid.cs b/Content.IntegrationTests/Tests/Construction/ConstructionActionValid.cs index 5fbf5c3d17..9d3b66156b 100644 --- a/Content.IntegrationTests/Tests/Construction/ConstructionActionValid.cs +++ b/Content.IntegrationTests/Tests/Construction/ConstructionActionValid.cs @@ -49,7 +49,7 @@ namespace Content.IntegrationTests.Tests.Construction [Test] public async Task ConstructionGraphSpawnPrototypeValid() { - var server = StartServerDummyTicker(); + var server = StartServer(); await server.WaitIdleAsync(); @@ -89,7 +89,7 @@ namespace Content.IntegrationTests.Tests.Construction [Test] public async Task ConstructionGraphNodeEntityPrototypeValid() { - var server = StartServerDummyTicker(); + var server = StartServer(); await server.WaitIdleAsync(); @@ -115,7 +115,7 @@ namespace Content.IntegrationTests.Tests.Construction [Test] public async Task ConstructionGraphEdgeValid() { - var server = StartServerDummyTicker(); + var server = StartServer(); await server.WaitIdleAsync(); diff --git a/Content.IntegrationTests/Tests/Construction/ConstructionPrototypeTest.cs b/Content.IntegrationTests/Tests/Construction/ConstructionPrototypeTest.cs index 9eea03ee70..23dd76a14e 100644 --- a/Content.IntegrationTests/Tests/Construction/ConstructionPrototypeTest.cs +++ b/Content.IntegrationTests/Tests/Construction/ConstructionPrototypeTest.cs @@ -1,4 +1,3 @@ -using System.Collections.Generic; using System.Threading.Tasks; using Content.Shared.Construction.Prototypes; using NUnit.Framework; @@ -12,7 +11,7 @@ namespace Content.IntegrationTests.Tests.Construction [Test] public async Task TestStartIsValid() { - var server = StartServerDummyTicker(); + var server = StartServer(); await server.WaitIdleAsync(); @@ -30,7 +29,7 @@ namespace Content.IntegrationTests.Tests.Construction [Test] public async Task TestTargetIsValid() { - var server = StartServerDummyTicker(); + var server = StartServer(); await server.WaitIdleAsync(); @@ -48,7 +47,7 @@ namespace Content.IntegrationTests.Tests.Construction [Test] public async Task TestStartReachesTarget() { - var server = StartServerDummyTicker(); + var server = StartServer(); await server.WaitIdleAsync(); diff --git a/Content.IntegrationTests/Tests/DeleteInventoryTest.cs b/Content.IntegrationTests/Tests/DeleteInventoryTest.cs index 189d3a6a80..c29d4bebbf 100644 --- a/Content.IntegrationTests/Tests/DeleteInventoryTest.cs +++ b/Content.IntegrationTests/Tests/DeleteInventoryTest.cs @@ -17,7 +17,7 @@ namespace Content.IntegrationTests.Tests [Test] public async Task Test() { - var server = StartServerDummyTicker(); + var server = StartServer(); server.Assert(() => { diff --git a/Content.IntegrationTests/Tests/Destructible/DestructibleDamageGroupTest.cs b/Content.IntegrationTests/Tests/Destructible/DestructibleDamageGroupTest.cs index 280d313d13..3b5addc1a1 100644 --- a/Content.IntegrationTests/Tests/Destructible/DestructibleDamageGroupTest.cs +++ b/Content.IntegrationTests/Tests/Destructible/DestructibleDamageGroupTest.cs @@ -5,7 +5,6 @@ using Content.Shared.Damage.Prototypes; using Content.Shared.FixedPoint; using NUnit.Framework; using Robust.Shared.GameObjects; -using Robust.Shared.IoC; using Robust.Shared.Map; using Robust.Shared.Prototypes; using static Content.IntegrationTests.Tests.Destructible.DestructibleTestPrototypes; @@ -20,7 +19,7 @@ namespace Content.IntegrationTests.Tests.Destructible [Test] public async Task AndTest() { - var server = StartServerDummyTicker(new ServerContentIntegrationOption + var server = StartServer(new ServerContentIntegrationOption { ExtraPrototypes = Prototypes }); @@ -39,13 +38,15 @@ namespace Content.IntegrationTests.Tests.Destructible await server.WaitPost(() => { - var mapId = new MapId(1); - var coordinates = new MapCoordinates(0, 0, mapId); - sMapManager.CreateMap(mapId); + var gridId = GetMainGrid(sMapManager).GridEntityId; + var coordinates = new EntityCoordinates(gridId, 0, 0); sDestructibleEntity = sEntityManager.SpawnEntity(DestructibleDamageGroupEntityId, coordinates); sDamageableComponent = sDestructibleEntity.GetComponent(); + sTestThresholdListenerSystem = sEntitySystemManager.GetEntitySystem(); + sTestThresholdListenerSystem.ThresholdsReached.Clear(); + sDamageableSystem = sEntitySystemManager.GetEntitySystem(); }); diff --git a/Content.IntegrationTests/Tests/Destructible/DestructibleDamageTypeTest.cs b/Content.IntegrationTests/Tests/Destructible/DestructibleDamageTypeTest.cs index 92f299791c..313e6ad549 100644 --- a/Content.IntegrationTests/Tests/Destructible/DestructibleDamageTypeTest.cs +++ b/Content.IntegrationTests/Tests/Destructible/DestructibleDamageTypeTest.cs @@ -19,7 +19,7 @@ namespace Content.IntegrationTests.Tests.Destructible [Test] public async Task Test() { - var server = StartServerDummyTicker(new ServerContentIntegrationOption + var server = StartServer(new ServerContentIntegrationOption { ExtraPrototypes = Prototypes }); @@ -37,9 +37,8 @@ namespace Content.IntegrationTests.Tests.Destructible await server.WaitPost(() => { - var mapId = new MapId(1); - var coordinates = new MapCoordinates(0, 0, mapId); - sMapManager.CreateMap(mapId); + var gridId = GetMainGrid(sMapManager).GridEntityId; + var coordinates = new EntityCoordinates(gridId, 0, 0); sDestructibleEntity = sEntityManager.SpawnEntity(DestructibleDamageTypeEntityId, coordinates); sDamageableComponent = sDestructibleEntity.GetComponent(); diff --git a/Content.IntegrationTests/Tests/Destructible/DestructibleDestructionTest.cs b/Content.IntegrationTests/Tests/Destructible/DestructibleDestructionTest.cs index 29ba6a1f12..27c40f87b0 100644 --- a/Content.IntegrationTests/Tests/Destructible/DestructibleDestructionTest.cs +++ b/Content.IntegrationTests/Tests/Destructible/DestructibleDestructionTest.cs @@ -18,7 +18,7 @@ namespace Content.IntegrationTests.Tests.Destructible [Test] public async Task Test() { - var server = StartServerDummyTicker(new ServerContentIntegrationOption + var server = StartServer(new ServerContentIntegrationOption { ExtraPrototypes = Prototypes }); @@ -36,9 +36,8 @@ namespace Content.IntegrationTests.Tests.Destructible await server.WaitPost(() => { - var mapId = new MapId(1); - var coordinates = new MapCoordinates(0, 0, mapId); - sMapManager.CreateMap(mapId); + var gridId = GetMainGrid(sMapManager).GridEntityId; + var coordinates = new EntityCoordinates(gridId, 0, 0); sDestructibleEntity = sEntityManager.SpawnEntity(DestructibleDestructionEntityId, coordinates); sDamageableComponent = sDestructibleEntity.GetComponent(); diff --git a/Content.IntegrationTests/Tests/Destructible/DestructibleThresholdActivationTest.cs b/Content.IntegrationTests/Tests/Destructible/DestructibleThresholdActivationTest.cs index 795c965759..90fb064fd5 100644 --- a/Content.IntegrationTests/Tests/Destructible/DestructibleThresholdActivationTest.cs +++ b/Content.IntegrationTests/Tests/Destructible/DestructibleThresholdActivationTest.cs @@ -9,7 +9,6 @@ using Content.Shared.Damage.Prototypes; using Content.Shared.FixedPoint; using NUnit.Framework; using Robust.Shared.GameObjects; -using Robust.Shared.IoC; using Robust.Shared.Map; using Robust.Shared.Prototypes; using static Content.IntegrationTests.Tests.Destructible.DestructibleTestPrototypes; @@ -24,7 +23,7 @@ namespace Content.IntegrationTests.Tests.Destructible [Test] public async Task Test() { - var server = StartServerDummyTicker(new ServerContentIntegrationOption + var server = StartServer(new ServerContentIntegrationOption { ExtraPrototypes = Prototypes }); @@ -44,14 +43,16 @@ namespace Content.IntegrationTests.Tests.Destructible await server.WaitPost(() => { - var mapId = new MapId(1); - var coordinates = new MapCoordinates(0, 0, mapId); - sMapManager.CreateMap(mapId); + var gridId = GetMainGrid(sMapManager).GridEntityId; + var coordinates = new EntityCoordinates(gridId, 0, 0); sDestructibleEntity = sEntityManager.SpawnEntity(DestructibleEntityId, coordinates); sDamageableComponent = sDestructibleEntity.GetComponent(); sDestructibleComponent = sDestructibleEntity.GetComponent(); + sTestThresholdListenerSystem = sEntitySystemManager.GetEntitySystem(); + sTestThresholdListenerSystem.ThresholdsReached.Clear(); + sDamageableSystem = sEntitySystemManager.GetEntitySystem(); }); diff --git a/Content.IntegrationTests/Tests/Destructible/TestDestructibleListenerSystem.cs b/Content.IntegrationTests/Tests/Destructible/TestDestructibleListenerSystem.cs index 657b27c412..1d9de70709 100644 --- a/Content.IntegrationTests/Tests/Destructible/TestDestructibleListenerSystem.cs +++ b/Content.IntegrationTests/Tests/Destructible/TestDestructibleListenerSystem.cs @@ -1,6 +1,7 @@ -using Content.Server.Destructible; -using Robust.Shared.GameObjects; using System.Collections.Generic; +using Content.Server.Destructible; +using Content.Shared.GameTicking; +using Robust.Shared.GameObjects; namespace Content.IntegrationTests.Tests.Destructible { @@ -10,10 +11,13 @@ namespace Content.IntegrationTests.Tests.Destructible /// public class TestDestructibleListenerSystem : EntitySystem { + public readonly List ThresholdsReached = new(); + public override void Initialize() { base.Initialize(); SubscribeLocalEvent(AddThresholdsToList); + SubscribeLocalEvent(OnRoundRestart); } public void AddThresholdsToList(EntityUid _, DestructibleComponent comp, DamageThresholdReached args) @@ -21,6 +25,9 @@ namespace Content.IntegrationTests.Tests.Destructible ThresholdsReached.Add(args); } - public List ThresholdsReached = new(); + private void OnRoundRestart(RoundRestartCleanupEvent ev) + { + ThresholdsReached.Clear(); + } } } diff --git a/Content.IntegrationTests/Tests/DeviceNetwork/DeviceNetworkTest.cs b/Content.IntegrationTests/Tests/DeviceNetwork/DeviceNetworkTest.cs index ceac721e96..a873978f82 100644 --- a/Content.IntegrationTests/Tests/DeviceNetwork/DeviceNetworkTest.cs +++ b/Content.IntegrationTests/Tests/DeviceNetwork/DeviceNetworkTest.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Content.Server.DeviceNetwork; using Content.Server.DeviceNetwork.Components; using Content.Server.DeviceNetwork.Systems; @@ -5,7 +6,6 @@ using NUnit.Framework; using Robust.Shared.GameObjects; using Robust.Shared.IoC; using Robust.Shared.Map; -using System.Threading.Tasks; namespace Content.IntegrationTests.Tests.DeviceNetwork { @@ -54,7 +54,7 @@ namespace Content.IntegrationTests.Tests.DeviceNetwork } }; - var server = StartServerDummyTicker(options); + var server = StartServer(options); await server.WaitIdleAsync(); @@ -116,7 +116,7 @@ namespace Content.IntegrationTests.Tests.DeviceNetwork } }; - var server = StartServerDummyTicker(options); + var server = StartServer(options); await server.WaitIdleAsync(); @@ -198,7 +198,7 @@ namespace Content.IntegrationTests.Tests.DeviceNetwork } }; - var server = StartServerDummyTicker(options); + var server = StartServer(options); await server.WaitIdleAsync(); diff --git a/Content.IntegrationTests/Tests/Disposal/DisposalUnitTest.cs b/Content.IntegrationTests/Tests/Disposal/DisposalUnitTest.cs index e055fda883..1e30f6a77f 100644 --- a/Content.IntegrationTests/Tests/Disposal/DisposalUnitTest.cs +++ b/Content.IntegrationTests/Tests/Disposal/DisposalUnitTest.cs @@ -4,13 +4,11 @@ using Content.Server.Disposal.Tube.Components; using Content.Server.Disposal.Unit.Components; using Content.Server.Disposal.Unit.EntitySystems; using Content.Server.Power.Components; -using Content.Shared.Coordinates; using Content.Shared.Disposal; using NUnit.Framework; using Robust.Shared.GameObjects; using Robust.Shared.Map; using Robust.Shared.Reflection; -using Robust.Shared.Timing; namespace Content.IntegrationTests.Tests.Disposal { @@ -122,7 +120,7 @@ namespace Content.IntegrationTests.Tests.Disposal public async Task Test() { var options = new ServerIntegrationOptions { ExtraPrototypes = Prototypes }; - var server = StartServerDummyTicker(options); + var server = StartServer(options); await server.WaitIdleAsync(); IEntity human = default!; @@ -130,48 +128,19 @@ namespace Content.IntegrationTests.Tests.Disposal IEntity disposalUnit = default!; IEntity disposalTrunk = default!; DisposalUnitComponent unit = default!; - EntityCoordinates coordinates = default!; var mapManager = server.ResolveDependency(); var entityManager = server.ResolveDependency(); - var pauseManager = server.ResolveDependency(); - var tileDefinitionManager = server.ResolveDependency(); - - // Build up test environment - server.Post(() => - { - // Create a one tile grid to anchor our disposal unit to. - var mapId = mapManager.CreateMap(); - - pauseManager.AddUninitializedMap(mapId); - - var gridId = new GridId(1); - - if (!mapManager.TryGetGrid(gridId, out var grid)) - { - grid = mapManager.CreateGrid(mapId, gridId); - } - - var tileDefinition = tileDefinitionManager["underplating"]; - var tile = new Tile(tileDefinition.TileId); - coordinates = grid.ToCoordinates(); - - grid.SetTile(coordinates, tile); - - pauseManager.DoMapInitialize(mapId); - }); await server.WaitAssertion(() => { // Spawn the entities + var coordinates = GetMainEntityCoordinates(mapManager); human = entityManager.SpawnEntity("HumanDummy", coordinates); wrench = entityManager.SpawnEntity("WrenchDummy", coordinates); disposalUnit = entityManager.SpawnEntity("DisposalUnitDummy", coordinates); disposalTrunk = entityManager.SpawnEntity("DisposalTrunkDummy", disposalUnit.Transform.MapPosition); - // Check that we have a grid, so that we can anchor our unit - Assert.That(mapManager.TryFindGridAt(disposalUnit.Transform.MapPosition, out var _)); - // Test for components existing Assert.True(disposalUnit.TryGetComponent(out unit!)); Assert.True(disposalTrunk.HasComponent()); diff --git a/Content.IntegrationTests/Tests/DoAfter/DoAfterServerTest.cs b/Content.IntegrationTests/Tests/DoAfter/DoAfterServerTest.cs index 570178cf44..b0c0d021af 100644 --- a/Content.IntegrationTests/Tests/DoAfter/DoAfterServerTest.cs +++ b/Content.IntegrationTests/Tests/DoAfter/DoAfterServerTest.cs @@ -1,7 +1,6 @@ using System.Threading; using System.Threading.Tasks; using Content.Server.DoAfter; -using Content.Server.GameObjects.Components; using NUnit.Framework; using Robust.Shared.GameObjects; using Robust.Shared.IoC; @@ -27,7 +26,7 @@ namespace Content.IntegrationTests.Tests.DoAfter { Task task = null; var options = new ServerIntegrationOptions{ExtraPrototypes = Prototypes}; - var server = StartServerDummyTicker(options); + var server = StartServer(options); // That it finishes successfully server.Post(() => @@ -51,7 +50,7 @@ namespace Content.IntegrationTests.Tests.DoAfter { Task task = null; var options = new ServerIntegrationOptions{ExtraPrototypes = Prototypes}; - var server = StartServerDummyTicker(options); + var server = StartServer(options); server.Post(() => { diff --git a/Content.IntegrationTests/Tests/Doors/AirlockTest.cs b/Content.IntegrationTests/Tests/Doors/AirlockTest.cs index 4bbd571e78..d3a9c185e1 100644 --- a/Content.IntegrationTests/Tests/Doors/AirlockTest.cs +++ b/Content.IntegrationTests/Tests/Doors/AirlockTest.cs @@ -46,7 +46,7 @@ namespace Content.IntegrationTests.Tests.Doors public async Task OpenCloseDestroyTest() { var options = new ServerIntegrationOptions {ExtraPrototypes = Prototypes}; - var server = StartServerDummyTicker(options); + var server = StartServer(options); await server.WaitIdleAsync(); diff --git a/Content.IntegrationTests/Tests/EntityTest.cs b/Content.IntegrationTests/Tests/EntityTest.cs index e57d82e105..19df1b29f6 100644 --- a/Content.IntegrationTests/Tests/EntityTest.cs +++ b/Content.IntegrationTests/Tests/EntityTest.cs @@ -2,8 +2,6 @@ using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -using Content.Server.Power.Components; -using Content.Server.PowerCell.Components; using Content.Shared.CCVar; using Content.Shared.Coordinates; using NUnit.Framework; @@ -27,7 +25,7 @@ namespace Content.IntegrationTests.Tests CVarOverrides = {{CCVars.AIMaxUpdates.Name, int.MaxValue.ToString()}} }; - var server = StartServerDummyTicker(options); + var server = StartServer(options); await server.WaitIdleAsync(); var mapManager = server.ResolveDependency(); @@ -118,7 +116,7 @@ namespace Content.IntegrationTests.Tests - type: entity id: AllComponentsOneToOneDeleteTestEntity"; - var server = StartServerDummyTicker(new ServerContentIntegrationOption + var server = StartServer(new ServerContentIntegrationOption { ExtraPrototypes = testEntity, FailureLogLevel = LogLevel.Error @@ -221,10 +219,11 @@ namespace Content.IntegrationTests.Tests - type: entity id: AllComponentsOneEntityDeleteTestEntity"; - var server = StartServerDummyTicker(new ServerContentIntegrationOption + var server = StartServer(new ServerContentIntegrationOption { ExtraPrototypes = testEntity, - FailureLogLevel = LogLevel.Error + FailureLogLevel = LogLevel.Error, + Pool = false }); await server.WaitIdleAsync(); diff --git a/Content.IntegrationTests/Tests/Fluids/PuddleTest.cs b/Content.IntegrationTests/Tests/Fluids/PuddleTest.cs index 5fe124b8a3..e314734242 100644 --- a/Content.IntegrationTests/Tests/Fluids/PuddleTest.cs +++ b/Content.IntegrationTests/Tests/Fluids/PuddleTest.cs @@ -2,7 +2,6 @@ using System; using System.Threading.Tasks; using Content.Server.Fluids.Components; using Content.Shared.Chemistry.Components; -using Content.Shared.Chemistry.Reagent; using Content.Shared.Coordinates; using Content.Shared.FixedPoint; using NUnit.Framework; @@ -19,46 +18,20 @@ namespace Content.IntegrationTests.Tests.Fluids [Test] public async Task TilePuddleTest() { - var server = StartServerDummyTicker(); + var server = StartServer(); await server.WaitIdleAsync(); var mapManager = server.ResolveDependency(); - var pauseManager = server.ResolveDependency(); - var tileDefinitionManager = server.ResolveDependency(); - - EntityCoordinates coordinates = default; - - // Build up test environment - server.Post(() => - { - // Create a one tile grid to spill onto - var mapId = mapManager.CreateMap(); - - pauseManager.AddUninitializedMap(mapId); - - var gridId = new GridId(1); - - if (!mapManager.TryGetGrid(gridId, out var grid)) - { - grid = mapManager.CreateGrid(mapId, gridId); - } - - var tileDefinition = tileDefinitionManager["underplating"]; - var tile = new Tile(tileDefinition.TileId); - coordinates = grid.ToCoordinates(); - - grid.SetTile(coordinates, tile); - - pauseManager.DoMapInitialize(mapId); - }); - - await server.WaitIdleAsync(); server.Assert(() => { var solution = new Solution("water", FixedPoint2.New(20)); + var grid = GetMainGrid(mapManager); + var (x, y) = GetMainTile(grid).GridIndices; + var coordinates = new EntityCoordinates(grid.GridEntityId, x, y); var puddle = solution.SpillAt(coordinates, "PuddleSmear"); + Assert.NotNull(puddle); }); @@ -68,25 +41,22 @@ namespace Content.IntegrationTests.Tests.Fluids [Test] public async Task SpaceNoPuddleTest() { - var server = StartServerDummyTicker(); + var server = StartServer(); await server.WaitIdleAsync(); + var mapManager = server.ResolveDependency(); - var pauseManager = server.ResolveDependency(); + IMapGrid grid = null; - // Build up test environment + // Remove all tiles server.Post(() => { - var mapId = mapManager.CreateMap(); + grid = GetMainGrid(mapManager); - pauseManager.AddUninitializedMap(mapId); - - var gridId = new GridId(1); - - if (!mapManager.TryGetGrid(gridId, out grid)) + foreach (var tile in grid.GetAllTiles()) { - grid = mapManager.CreateGrid(mapId, gridId); + grid.SetTile(tile.GridIndices, Tile.Empty); } }); diff --git a/Content.IntegrationTests/Tests/GameObjects/Components/ActionBlocking/HandCuffTest.cs b/Content.IntegrationTests/Tests/GameObjects/Components/ActionBlocking/HandCuffTest.cs index fbde337fa9..4257ccb361 100644 --- a/Content.IntegrationTests/Tests/GameObjects/Components/ActionBlocking/HandCuffTest.cs +++ b/Content.IntegrationTests/Tests/GameObjects/Components/ActionBlocking/HandCuffTest.cs @@ -41,7 +41,7 @@ namespace Content.IntegrationTests.Tests.GameObjects.Components.ActionBlocking public async Task Test() { var options = new ServerIntegrationOptions{ExtraPrototypes = Prototypes}; - var server = StartServerDummyTicker(options); + var server = StartServer(options); IEntity human; IEntity otherHuman; diff --git a/Content.IntegrationTests/Tests/GameObjects/Components/Mobs/ActionsComponentTests.cs b/Content.IntegrationTests/Tests/GameObjects/Components/Mobs/ActionsComponentTests.cs index ba93f5d835..6c74485d7a 100644 --- a/Content.IntegrationTests/Tests/GameObjects/Components/Mobs/ActionsComponentTests.cs +++ b/Content.IntegrationTests/Tests/GameObjects/Components/Mobs/ActionsComponentTests.cs @@ -3,7 +3,6 @@ using System.Linq; using System.Threading.Tasks; using Content.Client.Actions; using Content.Client.Actions.UI; -using Content.Client.UserInterface; using Content.Server.Actions; using Content.Server.Hands.Components; using Content.Server.Items; @@ -13,11 +12,11 @@ using Content.Shared.Actions.Prototypes; using Content.Shared.Cooldown; using NUnit.Framework; using Robust.Client.UserInterface; +using Robust.Server.Player; using Robust.Shared.GameObjects; using Robust.Shared.Map; using Robust.Shared.Timing; using Robust.Shared.Utility; -using IPlayerManager = Robust.Server.Player.IPlayerManager; namespace Content.IntegrationTests.Tests.GameObjects.Components.Mobs { @@ -244,7 +243,7 @@ namespace Content.IntegrationTests.Tests.GameObjects.Components.Mobs // spawn and give them an item that has actions serverFlashlight = serverEntManager.SpawnEntity("TestFlashlight", - new EntityCoordinates(new EntityUid(1), (0, 0))); + new EntityCoordinates(serverPlayerEnt.Uid, (0, 0))); Assert.That(serverFlashlight.TryGetComponent(out var itemActions)); // we expect this only to have a toggle light action initially var actionConfigs = itemActions.ActionConfigs.ToList(); diff --git a/Content.IntegrationTests/Tests/GameObjects/Components/Movement/ClimbUnitTest.cs b/Content.IntegrationTests/Tests/GameObjects/Components/Movement/ClimbUnitTest.cs index c51a9815bd..8d13ee7c47 100644 --- a/Content.IntegrationTests/Tests/GameObjects/Components/Movement/ClimbUnitTest.cs +++ b/Content.IntegrationTests/Tests/GameObjects/Components/Movement/ClimbUnitTest.cs @@ -2,7 +2,6 @@ using System.Threading.Tasks; using Content.Server.Climbing.Components; -using Content.Shared.Physics; using NUnit.Framework; using Robust.Shared.GameObjects; using Robust.Shared.IoC; @@ -36,7 +35,7 @@ namespace Content.IntegrationTests.Tests.GameObjects.Components.Movement public async Task Test() { var options = new ServerIntegrationOptions{ExtraPrototypes = Prototypes}; - var server = StartServerDummyTicker(options); + var server = StartServer(options); IEntity human; IEntity table; diff --git a/Content.IntegrationTests/Tests/Gravity/WeightlessStatusTests.cs b/Content.IntegrationTests/Tests/Gravity/WeightlessStatusTests.cs index c2b7092faf..dc27712f31 100644 --- a/Content.IntegrationTests/Tests/Gravity/WeightlessStatusTests.cs +++ b/Content.IntegrationTests/Tests/Gravity/WeightlessStatusTests.cs @@ -4,7 +4,6 @@ using Content.Server.Gravity.EntitySystems; using Content.Shared.Acts; using Content.Shared.Alert; using Content.Shared.Coordinates; -using Content.Shared.Gravity; using NUnit.Framework; using Robust.Shared.GameObjects; using Robust.Shared.Map; @@ -49,14 +48,7 @@ namespace Content.IntegrationTests.Tests.Gravity await server.WaitAssertion(() => { - var mapId = new MapId(1); - var gridId = new GridId(1); - - if (!mapManager.TryGetGrid(gridId, out var grid)) - { - grid = mapManager.CreateGrid(mapId, gridId); - } - + var grid = GetMainGrid(mapManager); var coordinates = grid.ToCoordinates(); human = entityManager.SpawnEntity("HumanDummy", coordinates); diff --git a/Content.IntegrationTests/Tests/GravityGridTest.cs b/Content.IntegrationTests/Tests/GravityGridTest.cs index 1b0156992f..d1e2a9c9c2 100644 --- a/Content.IntegrationTests/Tests/GravityGridTest.cs +++ b/Content.IntegrationTests/Tests/GravityGridTest.cs @@ -31,7 +31,7 @@ namespace Content.IntegrationTests.Tests public async Task Test() { var options = new ServerIntegrationOptions{ExtraPrototypes = Prototypes}; - var server = StartServerDummyTicker(options); + var server = StartServer(options); IEntity generator = null; @@ -43,9 +43,9 @@ namespace Content.IntegrationTests.Tests { var mapMan = IoCManager.Resolve(); - mapMan.CreateMap(new MapId(1)); - grid1 = mapMan.CreateGrid(new MapId(1)); - grid2 = mapMan.CreateGrid(new MapId(1)); + var mapId = GetMainMapId(mapMan); + grid1 = mapMan.CreateGrid(mapId); + grid2 = mapMan.CreateGrid(mapId); var entityMan = IoCManager.Resolve(); diff --git a/Content.IntegrationTests/Tests/GridTileLookupTest.cs b/Content.IntegrationTests/Tests/GridTileLookupTest.cs index d67d570a3d..da9c90f947 100644 --- a/Content.IntegrationTests/Tests/GridTileLookupTest.cs +++ b/Content.IntegrationTests/Tests/GridTileLookupTest.cs @@ -22,7 +22,7 @@ namespace Content.IntegrationTests.Tests public async Task Test() { var options = new ServerIntegrationOptions{ExtraPrototypes = Prototypes}; - var server = StartServerDummyTicker(options); + var server = StartServer(options); await server.WaitIdleAsync(); var entityManager = server.ResolveDependency(); diff --git a/Content.IntegrationTests/Tests/HumanInventoryUniformSlotsTest.cs b/Content.IntegrationTests/Tests/HumanInventoryUniformSlotsTest.cs index 89e016578d..ce62679255 100644 --- a/Content.IntegrationTests/Tests/HumanInventoryUniformSlotsTest.cs +++ b/Content.IntegrationTests/Tests/HumanInventoryUniformSlotsTest.cs @@ -59,7 +59,7 @@ namespace Content.IntegrationTests.Tests public async Task Test() { var options = new ServerIntegrationOptions{ExtraPrototypes = Prototypes}; - var server = StartServerDummyTicker(options); + var server = StartServer(options); IEntity human = null; IEntity uniform = null; diff --git a/Content.IntegrationTests/Tests/Interaction/Click/InteractionSystemTests.cs b/Content.IntegrationTests/Tests/Interaction/Click/InteractionSystemTests.cs index 473119e481..120610e126 100644 --- a/Content.IntegrationTests/Tests/Interaction/Click/InteractionSystemTests.cs +++ b/Content.IntegrationTests/Tests/Interaction/Click/InteractionSystemTests.cs @@ -1,3 +1,10 @@ +using System.Threading.Tasks; +using Content.Server.Hands.Components; +using Content.Server.Interaction; +using Content.Server.Items; +using Content.Shared.Hands.Components; +using Content.Shared.Interaction; +using Content.Shared.Weapons.Melee; using NUnit.Framework; using Robust.Shared.Containers; using Robust.Shared.GameObjects; @@ -5,13 +12,6 @@ using Robust.Shared.IoC; using Robust.Shared.Map; using Robust.Shared.Maths; using Robust.Shared.Reflection; -using System.Threading.Tasks; -using Content.Server.Hands.Components; -using Content.Server.Interaction; -using Content.Server.Items; -using Content.Shared.Interaction; -using Content.Shared.Weapons.Melee; -using Content.Shared.Hands.Components; namespace Content.IntegrationTests.Tests.Interaction.Click { @@ -38,7 +38,7 @@ namespace Content.IntegrationTests.Tests.Interaction.Click [Test] public async Task InteractionTest() { - var server = StartServerDummyTicker(new ServerContentIntegrationOption + var server = StartServer(new ServerContentIntegrationOption { ContentBeforeIoC = () => { @@ -107,7 +107,7 @@ namespace Content.IntegrationTests.Tests.Interaction.Click [Test] public async Task InteractionObstructionTest() { - var server = StartServerDummyTicker(new ServerContentIntegrationOption + var server = StartServer(new ServerContentIntegrationOption { ContentBeforeIoC = () => { @@ -179,7 +179,7 @@ namespace Content.IntegrationTests.Tests.Interaction.Click [Test] public async Task InteractionInRangeTest() { - var server = StartServerDummyTicker(new ServerContentIntegrationOption + var server = StartServer(new ServerContentIntegrationOption { ContentBeforeIoC = () => { @@ -249,7 +249,7 @@ namespace Content.IntegrationTests.Tests.Interaction.Click [Test] public async Task InteractionOutOfRangeTest() { - var server = StartServerDummyTicker(new ServerContentIntegrationOption + var server = StartServer(new ServerContentIntegrationOption { ContentBeforeIoC = () => { @@ -318,7 +318,7 @@ namespace Content.IntegrationTests.Tests.Interaction.Click [Test] public async Task InsideContainerInteractionBlockTest() { - var server = StartServerDummyTicker(new ServerContentIntegrationOption + var server = StartServer(new ServerContentIntegrationOption { ContentBeforeIoC = () => { diff --git a/Content.IntegrationTests/Tests/Interaction/InRangeUnobstructed.cs b/Content.IntegrationTests/Tests/Interaction/InRangeUnobstructed.cs index ae8881629b..1f773108f2 100644 --- a/Content.IntegrationTests/Tests/Interaction/InRangeUnobstructed.cs +++ b/Content.IntegrationTests/Tests/Interaction/InRangeUnobstructed.cs @@ -29,7 +29,7 @@ namespace Content.IntegrationTests.Tests.Interaction [Test] public async Task EntityEntityTest() { - var server = StartServerDummyTicker(); + var server = StartServer(); await server.WaitIdleAsync(); diff --git a/Content.IntegrationTests/Tests/InventoryHelpersTest.cs b/Content.IntegrationTests/Tests/InventoryHelpersTest.cs index b29302e55c..46de2637e8 100644 --- a/Content.IntegrationTests/Tests/InventoryHelpersTest.cs +++ b/Content.IntegrationTests/Tests/InventoryHelpersTest.cs @@ -4,8 +4,6 @@ using Content.Server.Inventory; using Content.Server.Inventory.Components; using Content.Server.Items; using Content.Server.Stunnable; -using Content.Server.Stunnable.Components; -using Content.Shared.Stunnable; using NUnit.Framework; using Robust.Shared.GameObjects; using Robust.Shared.IoC; @@ -50,7 +48,7 @@ namespace Content.IntegrationTests.Tests public async Task SpawnItemInSlotTest() { var options = new ServerIntegrationOptions {ExtraPrototypes = Prototypes}; - var server = StartServerDummyTicker(options); + var server = StartServer(options); IEntity human = null; InventoryComponent inventory = null; diff --git a/Content.IntegrationTests/Tests/Kitchen/KitchenTest.cs b/Content.IntegrationTests/Tests/Kitchen/KitchenTest.cs index 9716d9255d..c8d6409aab 100644 --- a/Content.IntegrationTests/Tests/Kitchen/KitchenTest.cs +++ b/Content.IntegrationTests/Tests/Kitchen/KitchenTest.cs @@ -1,9 +1,7 @@ using System.Threading.Tasks; -using Content.Shared.Chemistry; using Content.Shared.Chemistry.Reagent; using Content.Shared.Kitchen; using NUnit.Framework; -using Robust.Shared.GameObjects; using Robust.Shared.Prototypes; namespace Content.IntegrationTests.Tests.Kitchen @@ -14,7 +12,7 @@ namespace Content.IntegrationTests.Tests.Kitchen [Test] public async Task TestRecipesValid() { - var server = StartServerDummyTicker(); + var server = StartServer(); await server.WaitIdleAsync(); var protoManager = server.ResolveDependency(); diff --git a/Content.IntegrationTests/Tests/Lobby/CharacterCreationTest.cs b/Content.IntegrationTests/Tests/Lobby/CharacterCreationTest.cs index 461a1fc30b..3453885d5a 100644 --- a/Content.IntegrationTests/Tests/Lobby/CharacterCreationTest.cs +++ b/Content.IntegrationTests/Tests/Lobby/CharacterCreationTest.cs @@ -1,12 +1,8 @@ using System.Threading.Tasks; -using Content.Client; using Content.Client.Lobby; using Content.Client.Preferences; -using Content.Client.State; using Content.Server.GameTicking; -using Content.Server.Preferences; using Content.Server.Preferences.Managers; -using Content.Shared; using Content.Shared.CCVar; using Content.Shared.Preferences; using NUnit.Framework; @@ -25,7 +21,16 @@ namespace Content.IntegrationTests.Tests.Lobby [Test] public async Task CreateDeleteCreateTest() { - var (client, server) = await StartConnectedServerClientPair(); + var serverOptions = new ServerContentIntegrationOption + { + CVarOverrides = + { + [CCVars.GameDummyTicker.Name] = "false", + [CCVars.GameLobbyEnabled.Name] = "true" + } + }; + + var (client, server) = await StartConnectedServerClientPair(serverOptions: serverOptions); var clientNetManager = client.ResolveDependency(); var clientStateManager = client.ResolveDependency(); @@ -50,7 +55,7 @@ namespace Content.IntegrationTests.Tests.Lobby // Need to run them in sync to receive the messages. await RunTicksSync(client, server, 1); - await WaitUntil(client, () => clientStateManager.CurrentState is LobbyState, maxTicks: 60); + await WaitUntil(client, () => clientStateManager.CurrentState is LobbyState, 600); Assert.NotNull(clientNetManager.ServerChannel); diff --git a/Content.IntegrationTests/Tests/Networking/ConnectTest.cs b/Content.IntegrationTests/Tests/Networking/ConnectTest.cs index a2e1ce57d6..f6c6770d84 100644 --- a/Content.IntegrationTests/Tests/Networking/ConnectTest.cs +++ b/Content.IntegrationTests/Tests/Networking/ConnectTest.cs @@ -16,7 +16,7 @@ namespace Content.IntegrationTests.Tests.Networking public async Task TestConnect() { var client = StartClient(); - var server = StartServer(); + var server = StartServer(new ServerContentIntegrationOption {Pool = false}); await Task.WhenAll(client.WaitIdleAsync(), server.WaitIdleAsync()); diff --git a/Content.IntegrationTests/Tests/Pathfinding/PathfindingChunkTest.cs b/Content.IntegrationTests/Tests/Pathfinding/PathfindingChunkTest.cs index 7030afbd98..187d37f2c9 100644 --- a/Content.IntegrationTests/Tests/Pathfinding/PathfindingChunkTest.cs +++ b/Content.IntegrationTests/Tests/Pathfinding/PathfindingChunkTest.cs @@ -16,7 +16,7 @@ namespace Content.IntegrationTests.Tests.Pathfinding [Test] public async Task Test() { - var server = StartServerDummyTicker(); + var server = StartServer(); server.Assert(() => { @@ -24,17 +24,15 @@ namespace Content.IntegrationTests.Tests.Pathfinding var mapMan = IoCManager.Resolve(); // Setup - var mapId = mapMan.CreateMap(new MapId(1)); - var gridId = new GridId(2); - mapMan.CreateGrid(mapId, gridId); - var chunkTile = mapMan.GetGrid(gridId).GetTileRef(new Vector2i(0, 0)); + var grid = GetMainGrid(mapMan); + var chunkTile = grid.GetTileRef(new Vector2i(0, 0)); var chunk = pathfindingSystem.GetChunk(chunkTile); Assert.That(chunk.Nodes.Length == PathfindingChunk.ChunkSize * PathfindingChunk.ChunkSize); // Neighbors var chunkNeighbors = chunk.GetNeighbors().ToList(); Assert.That(chunkNeighbors.Count == 0); - var neighborChunkTile = mapMan.GetGrid(gridId).GetTileRef(new Vector2i(PathfindingChunk.ChunkSize, PathfindingChunk.ChunkSize)); + var neighborChunkTile = grid.GetTileRef(new Vector2i(PathfindingChunk.ChunkSize, PathfindingChunk.ChunkSize)); var neighborChunk = pathfindingSystem.GetChunk(neighborChunkTile); chunkNeighbors = chunk.GetNeighbors().ToList(); Assert.That(chunkNeighbors.Count == 1); diff --git a/Content.IntegrationTests/Tests/PostMapInitTest.cs b/Content.IntegrationTests/Tests/PostMapInitTest.cs index 88e4e79046..ea1044f84e 100644 --- a/Content.IntegrationTests/Tests/PostMapInitTest.cs +++ b/Content.IntegrationTests/Tests/PostMapInitTest.cs @@ -17,7 +17,7 @@ namespace Content.IntegrationTests.Tests [Test] public async Task NoSavedPostMapInitTest() { - var server = StartServerDummyTicker(); + var server = StartServer(); await server.WaitIdleAsync(); diff --git a/Content.IntegrationTests/Tests/Power/PowerTest.cs b/Content.IntegrationTests/Tests/Power/PowerTest.cs index 44fef5b504..759f61f425 100644 --- a/Content.IntegrationTests/Tests/Power/PowerTest.cs +++ b/Content.IntegrationTests/Tests/Power/PowerTest.cs @@ -168,7 +168,7 @@ namespace Content.IntegrationTests.Tests.Power public async Task Setup() { var options = new ServerIntegrationOptions {ExtraPrototypes = Prototypes}; - _server = StartServerDummyTicker(options); + _server = StartServer(options); await _server.WaitIdleAsync(); _mapManager = _server.ResolveDependency(); diff --git a/Content.IntegrationTests/Tests/SaveLoadMapTest.cs b/Content.IntegrationTests/Tests/SaveLoadMapTest.cs index 61cb861f87..10825af9fa 100644 --- a/Content.IntegrationTests/Tests/SaveLoadMapTest.cs +++ b/Content.IntegrationTests/Tests/SaveLoadMapTest.cs @@ -3,7 +3,6 @@ using NUnit.Framework; using Robust.Server.Maps; using Robust.Shared.ContentPack; using Robust.Shared.GameObjects; -using Robust.Shared.IoC; using Robust.Shared.Log; using Robust.Shared.Map; using Robust.Shared.Maths; @@ -34,7 +33,8 @@ namespace Content.IntegrationTests.Tests var dir = new ResourcePath(mapPath).Directory; resManager.UserData.CreateDir(dir); - var mapId = mapManager.CreateMap(new MapId(5)); + var nextMapId = mapManager.NextMapId(); + var mapId = mapManager.CreateMap(nextMapId); { var mapGrid = mapManager.CreateGrid(mapId); @@ -51,7 +51,7 @@ namespace Content.IntegrationTests.Tests mapLoader.SaveMap(mapId, mapPath); - mapManager.DeleteMap(new MapId(5)); + mapManager.DeleteMap(nextMapId); }); await server.WaitIdleAsync(); diff --git a/Content.IntegrationTests/Tests/SaveLoadSaveTest.cs b/Content.IntegrationTests/Tests/SaveLoadSaveTest.cs index e77981375b..b2c5a6f791 100644 --- a/Content.IntegrationTests/Tests/SaveLoadSaveTest.cs +++ b/Content.IntegrationTests/Tests/SaveLoadSaveTest.cs @@ -19,7 +19,7 @@ namespace Content.IntegrationTests.Tests [Test] public async Task SaveLoadSave() { - var server = StartServer(); + var server = StartServer(new ServerContentIntegrationOption {Pool = false}); await server.WaitIdleAsync(); var mapLoader = server.ResolveDependency(); var mapManager = server.ResolveDependency(); @@ -86,7 +86,7 @@ namespace Content.IntegrationTests.Tests IMapGrid grid = default; - // Load stationstation.yml as uninitialized map, and save it to ensure it's up to date. + // Load saltern.yml as uninitialized map, and save it to ensure it's up to date. server.Post(() => { var mapId = mapManager.CreateMap(); diff --git a/Content.IntegrationTests/Tests/Solutions/ReagentDispenserTest.cs b/Content.IntegrationTests/Tests/Solutions/ReagentDispenserTest.cs index 34094ac24b..f54d4f5799 100644 --- a/Content.IntegrationTests/Tests/Solutions/ReagentDispenserTest.cs +++ b/Content.IntegrationTests/Tests/Solutions/ReagentDispenserTest.cs @@ -1,6 +1,5 @@ #nullable enable using System.Threading.Tasks; -using Content.Shared.Chemistry; using Content.Shared.Chemistry.Dispenser; using Content.Shared.Chemistry.Reagent; using NUnit.Framework; @@ -14,7 +13,7 @@ namespace Content.IntegrationTests.Tests.Solutions [Test] public async Task TestReagentDispenserInventory() { - var server = StartServerDummyTicker(); + var server = StartServer(); await server.WaitIdleAsync(); var protoManager = server.ResolveDependency(); diff --git a/Content.IntegrationTests/Tests/StartTest.cs b/Content.IntegrationTests/Tests/StartTest.cs index bedb94136c..5bcb611224 100644 --- a/Content.IntegrationTests/Tests/StartTest.cs +++ b/Content.IntegrationTests/Tests/StartTest.cs @@ -13,7 +13,10 @@ namespace Content.IntegrationTests.Tests [Test] public async Task TestServerStart() { - var server = StartServer(); + var server = StartServer(new ServerContentIntegrationOption + { + Pool = false + }); server.RunTicks(5); await server.WaitIdleAsync(); Assert.That(server.IsAlive); @@ -30,7 +33,10 @@ namespace Content.IntegrationTests.Tests [Test] public async Task TestClientStart() { - var client = StartClient(); + var client = StartClient(new ClientContentIntegrationOption + { + Pool = false + }); await client.WaitIdleAsync(); Assert.That(client.IsAlive); client.RunTicks(5); diff --git a/Content.IntegrationTests/Tests/StationEvents/StationEventsSystemTest.cs b/Content.IntegrationTests/Tests/StationEvents/StationEventsSystemTest.cs index 099e5fb6b1..f67a467b0d 100644 --- a/Content.IntegrationTests/Tests/StationEvents/StationEventsSystemTest.cs +++ b/Content.IntegrationTests/Tests/StationEvents/StationEventsSystemTest.cs @@ -14,7 +14,7 @@ namespace Content.IntegrationTests.Tests.StationEvents [Test] public async Task Test() { - var server = StartServerDummyTicker(); + var server = StartServer(); server.Assert(() => { diff --git a/Content.IntegrationTests/Tests/StorageFillTest.cs b/Content.IntegrationTests/Tests/StorageFillTest.cs index 43377f1f2c..aec54366b5 100644 --- a/Content.IntegrationTests/Tests/StorageFillTest.cs +++ b/Content.IntegrationTests/Tests/StorageFillTest.cs @@ -3,8 +3,6 @@ using System.Threading.Tasks; using Content.Server.Storage.Components; using NUnit.Framework; using Robust.Shared.Prototypes; -using Robust.Shared.Utility; -using YamlDotNet.RepresentationModel; namespace Content.IntegrationTests.Tests { @@ -14,7 +12,7 @@ namespace Content.IntegrationTests.Tests [Test] public async Task TestStorageFillPrototypes() { - var server = StartServerDummyTicker(); + var server = StartServer(); await server.WaitIdleAsync(); var protoManager = server.ResolveDependency(); diff --git a/Content.IntegrationTests/Tests/Tag/TagTest.cs b/Content.IntegrationTests/Tests/Tag/TagTest.cs index de158f4036..1fe45f374d 100644 --- a/Content.IntegrationTests/Tests/Tag/TagTest.cs +++ b/Content.IntegrationTests/Tests/Tag/TagTest.cs @@ -45,7 +45,7 @@ namespace Content.IntegrationTests.Tests.Tag public async Task TagComponentTest() { var options = new ServerContentIntegrationOption {ExtraPrototypes = Prototypes}; - var server = StartServerDummyTicker(options); + var server = StartServer(options); await server.WaitIdleAsync(); diff --git a/Content.IntegrationTests/Tests/Utility/EntitySystemExtensionsTest.cs b/Content.IntegrationTests/Tests/Utility/EntitySystemExtensionsTest.cs index b810b42e5d..d41a72fbb0 100644 --- a/Content.IntegrationTests/Tests/Utility/EntitySystemExtensionsTest.cs +++ b/Content.IntegrationTests/Tests/Utility/EntitySystemExtensionsTest.cs @@ -5,9 +5,7 @@ using Content.Shared.Spawning; using NUnit.Framework; using Robust.Shared.GameObjects; using Robust.Shared.Map; -using Robust.Shared.Maths; using Robust.Shared.Physics; -using Robust.Shared.Physics.Broadphase; namespace Content.IntegrationTests.Tests.Utility { @@ -45,18 +43,17 @@ namespace Content.IntegrationTests.Tests.Utility await server.WaitAssertion(() => { - var mapId = new MapId(1); - var grid = sMapManager.GetGrid(new GridId(1)); - grid.SetTile(new Vector2i(0, 0), new Tile(1)); + var grid = GetMainGrid(sMapManager); var gridEnt = sEntityManager.GetEntity(grid.GridEntityId); var gridPos = gridEnt.Transform.WorldPosition; - var entityCoordinates = new EntityCoordinates(grid.GridEntityId, 0, 0); + var entityCoordinates = GetMainEntityCoordinates(sMapManager); // Nothing blocking it, only entity is the grid Assert.NotNull(sEntityManager.SpawnIfUnobstructed(null, entityCoordinates, CollisionGroup.Impassable)); Assert.True(sEntityManager.TrySpawnIfUnobstructed(null, entityCoordinates, CollisionGroup.Impassable, out var entity)); Assert.NotNull(entity); + var mapId = GetMainMapId(sMapManager); var mapCoordinates = new MapCoordinates(gridPos.X, gridPos.Y, mapId); // Nothing blocking it, only entity is the grid diff --git a/Content.IntegrationTests/Tests/Utility/EntityWhitelistTest.cs b/Content.IntegrationTests/Tests/Utility/EntityWhitelistTest.cs index 583cbdc939..b77b41cd70 100644 --- a/Content.IntegrationTests/Tests/Utility/EntityWhitelistTest.cs +++ b/Content.IntegrationTests/Tests/Utility/EntityWhitelistTest.cs @@ -3,7 +3,6 @@ using System.Threading.Tasks; using Content.Shared.Containers.ItemSlots; using Content.Shared.Whitelist; using NUnit.Framework; -using NUnit.Framework.Internal; using Robust.Shared.GameObjects; using Robust.Shared.Map; @@ -70,7 +69,7 @@ namespace Content.IntegrationTests.Tests.Utility await server.WaitAssertion(() => { - var mapId = new MapId(1); + var mapId = GetMainMapId(mapManager); var mapCoordinates = new MapCoordinates(0, 0, mapId); var validComponent = entityManager.SpawnEntity("ValidComponentDummy", mapCoordinates); diff --git a/Content.IntegrationTests/Tests/VendingMachineTest.cs b/Content.IntegrationTests/Tests/VendingMachineTest.cs index 6bb5511937..877c024a7c 100644 --- a/Content.IntegrationTests/Tests/VendingMachineTest.cs +++ b/Content.IntegrationTests/Tests/VendingMachineTest.cs @@ -13,8 +13,8 @@ namespace Content.IntegrationTests.Tests [Test] public async Task Test() { - var server = StartServerDummyTicker(); - + var server = StartServer(); + server.Assert(() => { var prototypeManager = IoCManager.Resolve(); diff --git a/Content.Server/AI/Pathfinding/ServerPathfindingDebugSystem.cs b/Content.Server/AI/Pathfinding/ServerPathfindingDebugSystem.cs index 2845bc011a..875a683994 100644 --- a/Content.Server/AI/Pathfinding/ServerPathfindingDebugSystem.cs +++ b/Content.Server/AI/Pathfinding/ServerPathfindingDebugSystem.cs @@ -45,14 +45,14 @@ namespace Content.Server.AI.Pathfinding var tileOneWorld = tileOneGrid.ToMapPos(EntityManager); var tileTwoGrid = mapManager.GetGrid(to.GridIndex).GridTileToLocal(to.GridIndices); var tileTwoWorld = tileTwoGrid.ToMapPos(EntityManager); - cameFrom.Add(tileOneWorld, tileTwoWorld); + cameFrom[tileOneWorld] = tileTwoWorld; } var gScores = new Dictionary(); foreach (var (tile, score) in routeDebug.GScores) { var tileGrid = mapManager.GetGrid(tile.GridIndex).GridTileToLocal(tile.GridIndices); - gScores.Add(tileGrid.ToMapPos(EntityManager), score); + gScores[tileGrid.ToMapPos(EntityManager)] = score; } var systemMessage = new SharedAiDebug.AStarRouteMessage( diff --git a/Content.Server/Solar/Components/SolarPanelComponent.cs b/Content.Server/Solar/Components/SolarPanelComponent.cs index 108e591db1..c2f631fbca 100644 --- a/Content.Server/Solar/Components/SolarPanelComponent.cs +++ b/Content.Server/Solar/Components/SolarPanelComponent.cs @@ -70,15 +70,6 @@ namespace Content.Server.Solar.Components } } - protected override void Initialize() - { - base.Initialize(); - - Owner.EnsureComponentWarn(); - - UpdateSupply(); - } - public void OnBreak(BreakageEventArgs args) { if (!Owner.TryGetComponent(out var sprite)) diff --git a/Content.Server/Solar/EntitySystems/PowerSolarSystem.cs b/Content.Server/Solar/EntitySystems/PowerSolarSystem.cs index 7d1ee222ef..f6d385383e 100644 --- a/Content.Server/Solar/EntitySystems/PowerSolarSystem.cs +++ b/Content.Server/Solar/EntitySystems/PowerSolarSystem.cs @@ -1,5 +1,6 @@ using System; using System.Linq; +using Content.Server.Power.Components; using Content.Server.Solar.Components; using Content.Shared.Physics; using JetBrains.Annotations; @@ -7,7 +8,6 @@ using Robust.Shared.GameObjects; using Robust.Shared.IoC; using Robust.Shared.Maths; using Robust.Shared.Physics; -using Robust.Shared.Physics.Broadphase; using Robust.Shared.Random; using Robust.Shared.Timing; @@ -71,11 +71,18 @@ namespace Content.Server.Solar.EntitySystems public override void Initialize() { + SubscribeLocalEvent(OnMapInit); + // Initialize the sun to something random TowardsSun = MathHelper.TwoPi * _robustRandom.NextDouble(); SunAngularVelocity = Angle.FromDegrees(0.1 + ((_robustRandom.NextDouble() - 0.5) * 0.05)); } + private void OnMapInit(EntityUid uid, SolarPanelComponent component, MapInitEvent args) + { + UpdateSupply(uid, component); + } + public override void Update(float frameTime) { TowardsSun += SunAngularVelocity * frameTime; @@ -145,5 +152,18 @@ namespace Content.Server.Solar.EntitySystems // Total coverage calculated; apply it to the panel. panel.Coverage = coverage; } + + private void UpdateSupply( + EntityUid uid, + SolarPanelComponent? solar = null, + PowerSupplierComponent? supplier = null) + { + if (!Resolve(uid, ref solar, ref supplier)) + { + return; + } + + supplier.MaxSupply = (int) (solar.MaxSupply * solar.Coverage); + } } }