From 20dadf45ec92aecd244ae9e77d87c4531c6d1493 Mon Sep 17 00:00:00 2001 From: Tayrtahn Date: Thu, 18 Jan 2024 16:39:13 -0500 Subject: [PATCH] Fix solution corruption when grinding a stack of items (#24242) Fix corruption when grinding a stack of items --- .../Kitchen/EntitySystems/ReagentGrinderSystem.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Content.Server/Kitchen/EntitySystems/ReagentGrinderSystem.cs b/Content.Server/Kitchen/EntitySystems/ReagentGrinderSystem.cs index acb6116e9a..e309c3bd37 100644 --- a/Content.Server/Kitchen/EntitySystems/ReagentGrinderSystem.cs +++ b/Content.Server/Kitchen/EntitySystems/ReagentGrinderSystem.cs @@ -103,7 +103,12 @@ namespace Content.Server.Kitchen.EntitySystems if (fitsCount <= 0) continue; - solution.ScaleSolution(fitsCount); + // Make a copy of the solution to scale + // Otherwise we'll actually change the volume of the remaining stack too + var scaledSolution = new Solution(solution); + scaledSolution.ScaleSolution(fitsCount); + solution = scaledSolution; + _stackSystem.SetCount(item, stack.Count - fitsCount); // Setting to 0 will QueueDel } else