]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix instances of predicted randomness (#39661)
authorScarKy0 <106310278+ScarKy0@users.noreply.github.com>
Fri, 15 Aug 2025 13:48:23 +0000 (15:48 +0200)
committerGitHub <noreply@github.com>
Fri, 15 Aug 2025 13:48:23 +0000 (15:48 +0200)
init

Content.Shared/Flash/SharedFlashSystem.cs
Content.Shared/Throwing/CatchableSystem.cs

index dd6c9c91c10e478a18d2b3fdbca89512db5c7cdd..7f69e860420d317e61a554595556703f52f2b091 100644 (file)
@@ -21,6 +21,7 @@ using Robust.Shared.Random;
 using Robust.Shared.Timing;
 using System.Linq;
 using Content.Shared.Movement.Systems;
+using Content.Shared.Random.Helpers;
 
 namespace Content.Shared.Flash;
 
@@ -204,7 +205,8 @@ public abstract class SharedFlashSystem : EntitySystem
         foreach (var entity in _entSet)
         {
             // TODO: Use RandomPredicted https://github.com/space-wizards/RobustToolbox/pull/5849
-            var rand = new System.Random((int)_timing.CurTick.Value + GetNetEntity(entity).Id);
+            var seed = SharedRandomExtensions.HashCodeCombine(new() { (int)_timing.CurTick.Value, GetNetEntity(entity).Id });
+            var rand = new System.Random(seed);
             if (!rand.Prob(probability))
                 continue;
 
index 8f2fd355bab8ae1c50b18d4e980974ca41b78d78..586397f58b1659fd50d460701641e3571e370046 100644 (file)
@@ -3,6 +3,7 @@ using Content.Shared.Hands.Components;
 using Content.Shared.Hands.EntitySystems;
 using Content.Shared.IdentityManagement;
 using Content.Shared.Popups;
+using Content.Shared.Random.Helpers;
 using Content.Shared.Whitelist;
 using Robust.Shared.Audio.Systems;
 using Robust.Shared.Network;
@@ -55,7 +56,7 @@ public sealed partial class CatchableSystem : EntitySystem
             return;
 
         // TODO: Replace with RandomPredicted once the engine PR is merged
-        var seed = HashCode.Combine((int)_timing.CurTick.Value, GetNetEntity(ent).Id);
+        var seed = SharedRandomExtensions.HashCodeCombine(new() { (int)_timing.CurTick.Value, GetNetEntity(ent).Id });
         var rand = new System.Random(seed);
         if (!rand.Prob(ent.Comp.CatchChance))
             return;