From f8dfba91b84cf5f3b16b38cb2bf734e114f3beb9 Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Thu, 5 Oct 2017 21:19:23 +0300 Subject: [PATCH] Capped oscillator frequency to 240 Hz to prevent players from causing performance issues by setting it to an excessively high value --- .../Source/Items/Components/Signal/OscillatorComponent.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/Signal/OscillatorComponent.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/Signal/OscillatorComponent.cs index 80602bad8..f9d28c261 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/Signal/OscillatorComponent.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/Signal/OscillatorComponent.cs @@ -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) :