From: IProduceWidgets <107586145+IProduceWidgets@users.noreply.github.com> Date: Fri, 6 Dec 2024 04:52:02 +0000 (-0500) Subject: fix a station event weighting bug (#33584) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=3e0b93d071450a2e1a54d12fa7c97c721a5921e4;p=space-station-14.git fix a station event weighting bug (#33584) * fractional weights dont work in StationEvents * force-int * sure why not, we can keep floats I guess. --- diff --git a/Content.Server/StationEvents/EventManagerSystem.cs b/Content.Server/StationEvents/EventManagerSystem.cs index bc6b183400..86c98a8e30 100644 --- a/Content.Server/StationEvents/EventManagerSystem.cs +++ b/Content.Server/StationEvents/EventManagerSystem.cs @@ -148,20 +148,20 @@ public sealed class EventManagerSystem : EntitySystem return null; } - var sumOfWeights = 0; + var sumOfWeights = 0.0f; foreach (var stationEvent in availableEvents.Values) { - sumOfWeights += (int) stationEvent.Weight; + sumOfWeights += stationEvent.Weight; } - sumOfWeights = _random.Next(sumOfWeights); + sumOfWeights = _random.NextFloat(sumOfWeights); foreach (var (proto, stationEvent) in availableEvents) { - sumOfWeights -= (int) stationEvent.Weight; + sumOfWeights -= stationEvent.Weight; - if (sumOfWeights <= 0) + if (sumOfWeights <= 0.0f) { return proto.ID; }