Skip to content

Commit

Permalink
Fix barotrauma pressure protection (space-wizards#26236)
Browse files Browse the repository at this point in the history
Oops

In space-wizards#26217 I re-organized the logic for the calculation. Part of that was moving the logic for GetFeltLowPressure and GetFeltHighPressure to be done before we actually check the hazard thresholds. What I didn't realize is that, with how our pressure protection is set up, these functions can return values so extreme they rebound into the other category.

For example, according to the math, when you're wearing a hardsuit in a low-pressure environment you have "felt" pressure of 1000 kPa. Yeah that's not right.

Now these functions clamp their result to OneAtmosphere, in the appropriate direction (101.3 kPa).

Fixes space-wizards#26234
  • Loading branch information
PJB3005 authored Mar 18, 2024
1 parent 75287db commit db81438
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Content.Server/Atmos/EntitySystems/BarotraumaSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ public float GetFeltLowPressure(EntityUid uid, BarotraumaComponent barotrauma, f
return Atmospherics.OneAtmosphere;
}

return (environmentPressure + barotrauma.LowPressureModifier) * (barotrauma.LowPressureMultiplier);
var modified = (environmentPressure + barotrauma.LowPressureModifier) * (barotrauma.LowPressureMultiplier);
return Math.Min(modified, Atmospherics.OneAtmosphere);
}

/// <summary>
Expand All @@ -162,7 +163,8 @@ public float GetFeltHighPressure(EntityUid uid, BarotraumaComponent barotrauma,
return Atmospherics.OneAtmosphere;
}

return (environmentPressure + barotrauma.HighPressureModifier) * (barotrauma.HighPressureMultiplier);
var modified = (environmentPressure + barotrauma.HighPressureModifier) * (barotrauma.HighPressureMultiplier);
return Math.Max(modified, Atmospherics.OneAtmosphere);
}

public bool TryGetPressureProtectionValues(
Expand Down

0 comments on commit db81438

Please sign in to comment.