From b2c505df6a81da1a7062d01bf9df3fe1548d8c2e Mon Sep 17 00:00:00 2001 From: ScarKy0 <106310278+ScarKy0@users.noreply.github.com> Date: Fri, 15 Aug 2025 15:48:23 +0200 Subject: [PATCH] Fix instances of predicted randomness (#39661) init --- Content.Shared/Flash/SharedFlashSystem.cs | 4 +++- Content.Shared/Throwing/CatchableSystem.cs | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Content.Shared/Flash/SharedFlashSystem.cs b/Content.Shared/Flash/SharedFlashSystem.cs index dd6c9c91c1..7f69e86042 100644 --- a/Content.Shared/Flash/SharedFlashSystem.cs +++ b/Content.Shared/Flash/SharedFlashSystem.cs @@ -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; diff --git a/Content.Shared/Throwing/CatchableSystem.cs b/Content.Shared/Throwing/CatchableSystem.cs index 8f2fd355ba..586397f58b 100644 --- a/Content.Shared/Throwing/CatchableSystem.cs +++ b/Content.Shared/Throwing/CatchableSystem.cs @@ -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;