From 915d8152542f45bd197965147fff65807393e7f7 Mon Sep 17 00:00:00 2001 From: Perry Fraser Date: Mon, 11 Aug 2025 18:44:10 -0400 Subject: [PATCH] feat: make ReagentId hash by value (#39494) --- Content.Shared/Chemistry/Reagent/ReagentId.cs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) 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) -- 2.51.2