Fix parallel tests unreliably failing due to statics in Atmospherics (#1914)

* Fix atmospherics statics unreliably failing parallel tests

* Cache getting atmosphere system
This commit is contained in:
DrSmugleaf
2020-08-25 16:14:26 +02:00
committed by GitHub
parent f436429a81
commit 4f8fbe2749
11 changed files with 107 additions and 73 deletions

View File

@@ -4,8 +4,10 @@ using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using Content.Server.Atmos.Reactions;
using Content.Server.GameObjects.EntitySystems;
using Content.Server.Interfaces;
using Content.Shared.Atmos;
using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Interfaces.Serialization;
using Robust.Shared.IoC;
using Robust.Shared.Prototypes;
@@ -20,12 +22,17 @@ namespace Content.Server.Atmos
[Serializable]
public class GasMixture : IExposeData, IEquatable<GasMixture>, ICloneable
{
private readonly AtmosphereSystem _atmosphereSystem;
[ViewVariables]
private float[] _moles = new float[Atmospherics.TotalNumberOfGases];
[ViewVariables]
private float[] _molesArchived = new float[Atmospherics.TotalNumberOfGases];
[ViewVariables]
private float _temperature = Atmospherics.TCMB;
public IReadOnlyList<float> Gases => _moles;
[ViewVariables]
@@ -51,7 +58,7 @@ namespace Content.Server.Atmos
for (var i = 0; i < Atmospherics.TotalNumberOfGases; i++)
{
capacity += Atmospherics.GetGas(i).SpecificHeat * _moles[i];
capacity += _atmosphereSystem.GetGas(i).SpecificHeat * _moles[i];
}
return MathF.Max(capacity, Atmospherics.MinimumHeatCapacity);
@@ -68,7 +75,7 @@ namespace Content.Server.Atmos
for (var i = 0; i < Atmospherics.TotalNumberOfGases; i++)
{
capacity += Atmospherics.GetGas(i).SpecificHeat * _molesArchived[i];
capacity += _atmosphereSystem.GetGas(i).SpecificHeat * _molesArchived[i];
}
return MathF.Max(capacity, Atmospherics.MinimumHeatCapacity);
@@ -124,6 +131,7 @@ namespace Content.Server.Atmos
public GasMixture()
{
_atmosphereSystem = EntitySystem.Get<AtmosphereSystem>();
}
public GasMixture(float volume)
@@ -131,6 +139,7 @@ namespace Content.Server.Atmos
if (volume < 0)
volume = 0;
Volume = volume;
_atmosphereSystem = EntitySystem.Get<AtmosphereSystem>();
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -274,7 +283,7 @@ namespace Content.Server.Atmos
if (!(MathF.Abs(delta) >= Atmospherics.GasMinMoles)) continue;
if (absTemperatureDelta > Atmospherics.MinimumTemperatureDeltaToConsider)
{
var gasHeatCapacity = delta * Atmospherics.GetGas(i).SpecificHeat;
var gasHeatCapacity = delta * _atmosphereSystem.GetGas(i).SpecificHeat;
if (delta > 0)
{
heatCapacityToSharer += gasHeatCapacity;