From: Leon Friedrich <60421075+ElectroJr@users.noreply.github.com> Date: Sun, 22 Oct 2023 05:55:10 +0000 (+1100) Subject: Maybe fix hand test failures (#21157) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=fbf4333a03a701df698671b131c73ec485d46c2c;p=space-station-14.git Maybe fix hand test failures (#21157) --- diff --git a/Content.Client/Hands/Systems/HandsSystem.cs b/Content.Client/Hands/Systems/HandsSystem.cs index f44bc1ec97..ed40589f7f 100644 --- a/Content.Client/Hands/Systems/HandsSystem.cs +++ b/Content.Client/Hands/Systems/HandsSystem.cs @@ -95,7 +95,8 @@ namespace Content.Client.Hands.Systems } } - component.SortedHands = new(state.HandNames); + component.SortedHands.Clear(); + component.SortedHands.AddRange(state.HandNames); var sorted = addedHands.OrderBy(hand => component.SortedHands.IndexOf(hand.Name)); foreach (var hand in sorted) diff --git a/Content.Shared/Hands/Components/HandsComponent.cs b/Content.Shared/Hands/Components/HandsComponent.cs index c1664289ce..0bece1d141 100644 --- a/Content.Shared/Hands/Components/HandsComponent.cs +++ b/Content.Shared/Hands/Components/HandsComponent.cs @@ -97,8 +97,9 @@ public sealed class HandsComponentState : ComponentState public HandsComponentState(HandsComponent handComp) { + // cloning lists because of test networking. Hands = new(handComp.Hands.Values); - HandNames = handComp.SortedHands; + HandNames = new(handComp.SortedHands); ActiveHand = handComp.ActiveHand?.Name; } } diff --git a/Content.Shared/Hands/EntitySystems/SharedHandsSystem.cs b/Content.Shared/Hands/EntitySystems/SharedHandsSystem.cs index e1de636969..6b786fdfaa 100644 --- a/Content.Shared/Hands/EntitySystems/SharedHandsSystem.cs +++ b/Content.Shared/Hands/EntitySystems/SharedHandsSystem.cs @@ -69,9 +69,9 @@ public abstract partial class SharedHandsSystem if (!handsComp.Hands.Remove(handName, out var hand)) return; + handsComp.SortedHands.Remove(hand.Name); TryDrop(uid, hand, null, false, true, handsComp); hand.Container?.Shutdown(); - handsComp.SortedHands.Remove(hand.Name); if (handsComp.ActiveHand == hand) TrySetActiveHand(uid, handsComp.SortedHands.FirstOrDefault(), handsComp);