Capped oscillator frequency to 240 Hz to prevent players from causing performance issues by setting it to an excessively high value

This commit is contained in:
Joonas Rikkonen
2017-10-05 21:19:23 +03:00
parent 57667b3169
commit f8dfba91b8

View File

@@ -31,7 +31,12 @@ namespace Barotrauma.Items.Components
public float Frequency
{
get { return frequency; }
set { frequency = Math.Max(0.0f, value); }
set
{
//capped to 240 Hz (= 4 signals per frame) to prevent players
//from wrecking the performance by setting the value too high
frequency = MathHelper.Clamp(value, 0.0f, 240.0f);
}
}
public OscillatorComponent(Item item, XElement element) :