Log explosive depressurization. (#5474)

This commit is contained in:
Vera Aguilera Puerto
2021-11-23 12:22:18 +01:00
committed by GitHub
parent 8c6125752b
commit af86378995
3 changed files with 17 additions and 4 deletions

View File

@@ -2,6 +2,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using Content.Server.Atmos.Components; using Content.Server.Atmos.Components;
using Content.Server.Doors.Components; using Content.Server.Doors.Components;
using Content.Shared.Administration.Logs;
using Content.Shared.Atmos; using Content.Shared.Atmos;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.IoC; using Robust.Shared.IoC;
@@ -16,6 +17,11 @@ namespace Content.Server.Atmos.EntitySystems
{ {
[Dependency] private readonly IRobustRandom _robustRandom = default!; [Dependency] private readonly IRobustRandom _robustRandom = default!;
/// <summary>
/// Threshold for logging explosive depressurization.
/// </summary>
private const float DepressurizationLogThreshold = Atmospherics.MolesCellStandard * 10;
private readonly TileAtmosphereComparer _monstermosComparer = new(); private readonly TileAtmosphereComparer _monstermosComparer = new();
private readonly TileAtmosphere?[] _equalizeTiles = new TileAtmosphere[Atmospherics.MonstermosHardTileLimit]; private readonly TileAtmosphere?[] _equalizeTiles = new TileAtmosphere[Atmospherics.MonstermosHardTileLimit];
@@ -360,7 +366,7 @@ namespace Content.Server.Atmos.EntitySystems
const int limit = Atmospherics.MonstermosHardTileLimit; const int limit = Atmospherics.MonstermosHardTileLimit;
var totalGasesRemoved = 0f; var totalMolesRemoved = 0f;
var queueCycle = ++gridAtmosphere.EqualizationQueueCycleControl; var queueCycle = ++gridAtmosphere.EqualizationQueueCycleControl;
var tileCount = 0; var tileCount = 0;
@@ -447,7 +453,7 @@ namespace Content.Server.Atmos.EntitySystems
var otherTile2 = otherTile.AdjacentTiles[otherTile.MonstermosInfo.CurrentTransferDirection.ToIndex()]; var otherTile2 = otherTile.AdjacentTiles[otherTile.MonstermosInfo.CurrentTransferDirection.ToIndex()];
if (otherTile2?.Air == null) continue; if (otherTile2?.Air == null) continue;
var sum = otherTile2.Air.TotalMoles; var sum = otherTile2.Air.TotalMoles;
totalGasesRemoved += sum; totalMolesRemoved += sum;
otherTile.MonstermosInfo.CurrentTransferAmount += sum; otherTile.MonstermosInfo.CurrentTransferAmount += sum;
otherTile2.MonstermosInfo.CurrentTransferAmount += otherTile.MonstermosInfo.CurrentTransferAmount; otherTile2.MonstermosInfo.CurrentTransferAmount += otherTile.MonstermosInfo.CurrentTransferAmount;
otherTile.PressureDifference = otherTile.MonstermosInfo.CurrentTransferAmount; otherTile.PressureDifference = otherTile.MonstermosInfo.CurrentTransferAmount;
@@ -471,10 +477,14 @@ namespace Content.Server.Atmos.EntitySystems
var gridPhysics = EntityManager.GetComponent<PhysicsComponent>(mapGrid.GridEntityId); var gridPhysics = EntityManager.GetComponent<PhysicsComponent>(mapGrid.GridEntityId);
// TODO ATMOS: Come up with better values for these. // TODO ATMOS: Come up with better values for these.
gridPhysics.ApplyLinearImpulse(direction * totalGasesRemoved * gridPhysics.Mass); gridPhysics.ApplyLinearImpulse(direction * totalMolesRemoved * gridPhysics.Mass);
gridPhysics.ApplyAngularImpulse(Vector2.Cross(tile.GridIndices - gridPhysics.LocalCenter, direction) * totalGasesRemoved); gridPhysics.ApplyAngularImpulse(Vector2.Cross(tile.GridIndices - gridPhysics.LocalCenter, direction) * totalMolesRemoved);
} }
if(totalMolesRemoved > DepressurizationLogThreshold)
_adminLog.Add(LogType.ExplosiveDepressurization, LogImpact.High,
$"Explosive depressurization removed {totalMolesRemoved} moles from {tileCount} tiles starting from position {tile.GridIndices:position} on grid ID {tile.GridIndex:grid}");
Array.Clear(_depressurizeTiles, 0, Atmospherics.MonstermosHardTileLimit); Array.Clear(_depressurizeTiles, 0, Atmospherics.MonstermosHardTileLimit);
Array.Clear(_depressurizeSpaceTiles, 0, Atmospherics.MonstermosHardTileLimit); Array.Clear(_depressurizeSpaceTiles, 0, Atmospherics.MonstermosHardTileLimit);
Array.Clear(_depressurizeProgressionOrder, 0, Atmospherics.MonstermosHardTileLimit * 2); Array.Clear(_depressurizeProgressionOrder, 0, Atmospherics.MonstermosHardTileLimit * 2);

View File

@@ -1,3 +1,4 @@
using Content.Server.Administration.Logs;
using Content.Server.Atmos.Components; using Content.Server.Atmos.Components;
using Content.Server.NodeContainer.EntitySystems; using Content.Server.NodeContainer.EntitySystems;
using Content.Server.Temperature.Components; using Content.Server.Temperature.Components;
@@ -18,6 +19,7 @@ namespace Content.Server.Atmos.EntitySystems
public partial class AtmosphereSystem : SharedAtmosphereSystem public partial class AtmosphereSystem : SharedAtmosphereSystem
{ {
[Dependency] private readonly IMapManager _mapManager = default!; [Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly AdminLogSystem _adminLog = default!;
private const float ExposedUpdateDelay = 1f; private const float ExposedUpdateDelay = 1f;
private float _exposedTimer = 0f; private float _exposedTimer = 0f;

View File

@@ -15,6 +15,7 @@ public enum LogType
Verb = 19, Verb = 19,
ShuttleCalled = 8, ShuttleCalled = 8,
ShuttleRecalled = 9, ShuttleRecalled = 9,
ExplosiveDepressurization = 10,
ChemicalReaction = 17, ChemicalReaction = 17,
ReagentEffect = 18, ReagentEffect = 18,
} }