]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
fix a station event weighting bug (#33584)
authorIProduceWidgets <107586145+IProduceWidgets@users.noreply.github.com>
Fri, 6 Dec 2024 04:52:02 +0000 (23:52 -0500)
committerGitHub <noreply@github.com>
Fri, 6 Dec 2024 04:52:02 +0000 (22:52 -0600)
* fractional weights dont work in StationEvents

* force-int

* sure why not, we can keep floats I guess.

Content.Server/StationEvents/EventManagerSystem.cs

index bc6b1834002dd44031316615d1c54aed68e5c40d..86c98a8e30dfc82bca01f73f3681ab334f848543 100644 (file)
@@ -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;
             }