From 3e0b93d071450a2e1a54d12fa7c97c721a5921e4 Mon Sep 17 00:00:00 2001 From: IProduceWidgets <107586145+IProduceWidgets@users.noreply.github.com> Date: Thu, 5 Dec 2024 23:52:02 -0500 Subject: [PATCH] fix a station event weighting bug (#33584) * fractional weights dont work in StationEvents * force-int * sure why not, we can keep floats I guess. --- Content.Server/StationEvents/EventManagerSystem.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Content.Server/StationEvents/EventManagerSystem.cs b/Content.Server/StationEvents/EventManagerSystem.cs index bc6b1834002dd4..86c98a8e30dfc8 100644 --- a/Content.Server/StationEvents/EventManagerSystem.cs +++ b/Content.Server/StationEvents/EventManagerSystem.cs @@ -148,20 +148,20 @@ public bool TryBuildLimitedEvents(EntityTableSelector limitedEventsTable, out Di 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; }