Gas moles may never be below the minimum amount of moles again.
A few atmos tweaks and fixes. Should(?) fix the NaN issue that can't be replicated.
This commit is contained in:
@@ -120,8 +120,8 @@ namespace Content.Server.Atmos
|
|||||||
public GasMixture(AtmosphereSystem? atmosphereSystem)
|
public GasMixture(AtmosphereSystem? atmosphereSystem)
|
||||||
{
|
{
|
||||||
_atmosphereSystem = atmosphereSystem ?? EntitySystem.Get<AtmosphereSystem>();
|
_atmosphereSystem = atmosphereSystem ?? EntitySystem.Get<AtmosphereSystem>();
|
||||||
_moles = new float[MathHelper.NextMultipleOf(Atmospherics.TotalNumberOfGases, 4)];
|
_moles = new float[Atmospherics.AdjustedNumberOfGases];
|
||||||
_molesArchived = new float[_moles.Length];
|
_molesArchived = new float[Atmospherics.AdjustedNumberOfGases];
|
||||||
}
|
}
|
||||||
|
|
||||||
public GasMixture(float volume, AtmosphereSystem? atmosphereSystem = null): this(atmosphereSystem)
|
public GasMixture(float volume, AtmosphereSystem? atmosphereSystem = null): this(atmosphereSystem)
|
||||||
@@ -222,6 +222,15 @@ namespace Content.Server.Atmos
|
|||||||
if (!Immutable)
|
if (!Immutable)
|
||||||
NumericsHelpers.Sub(_moles, removed._moles);
|
NumericsHelpers.Sub(_moles, removed._moles);
|
||||||
|
|
||||||
|
for (var i = 0; i < _moles.Length; i++)
|
||||||
|
{
|
||||||
|
if (_moles[i] < Atmospherics.GasMinMoles)
|
||||||
|
_moles[i] = 0;
|
||||||
|
|
||||||
|
if (removed._moles[i] < Atmospherics.GasMinMoles)
|
||||||
|
removed._moles[i] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
return removed;
|
return removed;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -508,19 +517,17 @@ namespace Content.Server.Atmos
|
|||||||
|
|
||||||
public void ExposeData(ObjectSerializer serializer)
|
public void ExposeData(ObjectSerializer serializer)
|
||||||
{
|
{
|
||||||
var length = MathHelper.NextMultipleOf(Atmospherics.TotalNumberOfGases, 4);
|
|
||||||
|
|
||||||
serializer.DataField(this, x => Immutable, "immutable", false);
|
serializer.DataField(this, x => Immutable, "immutable", false);
|
||||||
serializer.DataField(this, x => Volume, "volume", 0f);
|
serializer.DataField(this, x => Volume, "volume", 0f);
|
||||||
serializer.DataField(this, x => LastShare, "lastShare", 0f);
|
serializer.DataField(this, x => LastShare, "lastShare", 0f);
|
||||||
serializer.DataField(this, x => TemperatureArchived, "temperatureArchived", 0f);
|
serializer.DataField(this, x => TemperatureArchived, "temperatureArchived", 0f);
|
||||||
serializer.DataField(ref _moles, "moles", new float[length]);
|
serializer.DataField(ref _moles, "moles", new float[Atmospherics.AdjustedNumberOfGases]);
|
||||||
serializer.DataField(ref _molesArchived, "molesArchived", new float[length]);
|
serializer.DataField(ref _molesArchived, "molesArchived", new float[Atmospherics.AdjustedNumberOfGases]);
|
||||||
serializer.DataField(ref _temperature, "temperature", Atmospherics.TCMB);
|
serializer.DataField(ref _temperature, "temperature", Atmospherics.TCMB);
|
||||||
|
|
||||||
// The arrays MUST have a specific length.
|
// The arrays MUST have a specific length.
|
||||||
Array.Resize(ref _moles, length);
|
Array.Resize(ref _moles, Atmospherics.AdjustedNumberOfGases);
|
||||||
Array.Resize(ref _molesArchived, length);
|
Array.Resize(ref _molesArchived, Atmospherics.AdjustedNumberOfGases);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Equals(object? obj)
|
public override bool Equals(object? obj)
|
||||||
|
|||||||
@@ -1,10 +1,17 @@
|
|||||||
namespace Content.Shared.Atmos
|
using Robust.Shared.Maths;
|
||||||
|
|
||||||
|
namespace Content.Shared.Atmos
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Class to store atmos constants.
|
/// Class to store atmos constants.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class Atmospherics
|
public static class Atmospherics
|
||||||
{
|
{
|
||||||
|
static Atmospherics()
|
||||||
|
{
|
||||||
|
AdjustedNumberOfGases = MathHelper.NextMultipleOf(TotalNumberOfGases, 4);
|
||||||
|
}
|
||||||
|
|
||||||
#region ATMOS
|
#region ATMOS
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The universal gas constant, in kPa*L/(K*mol)
|
/// The universal gas constant, in kPa*L/(K*mol)
|
||||||
@@ -144,7 +151,13 @@
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Total number of gases. Increase this if you want to add more!
|
/// Total number of gases. Increase this if you want to add more!
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const byte TotalNumberOfGases = 6;
|
public const int TotalNumberOfGases = 6;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This is the actual length of the gases arrays in mixtures.
|
||||||
|
/// Set to the closest multiple of 4 relative to <see cref="TotalNumberOfGases"/> for SIMD reasons.
|
||||||
|
/// </summary>
|
||||||
|
public static readonly int AdjustedNumberOfGases;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Amount of heat released per mole of burnt hydrogen or tritium (hydrogen isotope)
|
/// Amount of heat released per mole of burnt hydrogen or tritium (hydrogen isotope)
|
||||||
|
|||||||
Reference in New Issue
Block a user