From: Perry Fraser Date: Mon, 11 Aug 2025 22:44:10 +0000 (-0400) Subject: feat: make ReagentId hash by value (#39494) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=915d8152542f45bd197965147fff65807393e7f7;p=space-station-14.git feat: make ReagentId hash by value (#39494) --- diff --git a/Content.Shared/Chemistry/Reagent/ReagentId.cs b/Content.Shared/Chemistry/Reagent/ReagentId.cs index 798dd28db4..88c0abff2a 100644 --- a/Content.Shared/Chemistry/Reagent/ReagentId.cs +++ b/Content.Shared/Chemistry/Reagent/ReagentId.cs @@ -75,7 +75,21 @@ public partial struct ReagentId : IEquatable public override int GetHashCode() { - return HashCode.Combine(Prototype, Data); + // We need to make sure we take the hash code of Data by value in order + // for hashed key lookups to work properly + var hash = 17; + unchecked + { + if (Data?.Count != 0) + { + foreach (var data in Data ?? []) + { + hash = hash * 23 + data.GetHashCode(); + } + } + } + + return HashCode.Combine(Prototype, hash); } public string ToString(FixedPoint2 quantity)