From da5e72d43ef062748f8a1b09337bab055d17d9e5 Mon Sep 17 00:00:00 2001
From: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
Date: Fri, 24 Oct 2025 09:25:42 +0200
Subject: [PATCH] Fix wielding two-handed items with only one hand (#40966)
* fix
* review
---
.../Hands/EntitySystems/SharedHandsSystem.cs | 16 +++++++++++++++-
.../Wieldable/SharedWieldableSystem.cs | 2 +-
2 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/Content.Shared/Hands/EntitySystems/SharedHandsSystem.cs b/Content.Shared/Hands/EntitySystems/SharedHandsSystem.cs
index 8431e27658..2060ee892f 100644
--- a/Content.Shared/Hands/EntitySystems/SharedHandsSystem.cs
+++ b/Content.Shared/Hands/EntitySystems/SharedHandsSystem.cs
@@ -419,6 +419,9 @@ public abstract partial class SharedHandsSystem
return GetHeldItem(ent, handId) == null;
}
+ ///
+ /// Counts the number of hands on this entity.
+ ///
public int GetHandCount(Entity ent)
{
if (!Resolve(ent, ref ent.Comp, false))
@@ -427,6 +430,9 @@ public abstract partial class SharedHandsSystem
return ent.Comp.Hands.Count;
}
+ ///
+ /// Counts the number of hands that are empty.
+ ///
public int CountFreeHands(Entity ent)
{
if (!Resolve(ent, ref ent.Comp, false))
@@ -442,11 +448,19 @@ public abstract partial class SharedHandsSystem
return free;
}
- public int CountFreeableHands(Entity hands)
+ ///
+ /// Counts the number of hands that are empty or can be emptied by dropping an item.
+ /// Unremoveable items will cause a hand to not be freeable.
+ ///
+ /// The hand this entity is in will be ignored when counting.
+ public int CountFreeableHands(Entity hands, EntityUid? except = null)
{
var freeable = 0;
foreach (var name in hands.Comp.Hands.Keys)
{
+ if (except != null && GetHeldItem(hands.AsNullable(), name) == except)
+ continue;
+
if (HandIsEmpty(hands.AsNullable(), name) || CanDropHeld(hands, name))
freeable++;
}
diff --git a/Content.Shared/Wieldable/SharedWieldableSystem.cs b/Content.Shared/Wieldable/SharedWieldableSystem.cs
index 3b9b8dd8e7..49db4ff86c 100644
--- a/Content.Shared/Wieldable/SharedWieldableSystem.cs
+++ b/Content.Shared/Wieldable/SharedWieldableSystem.cs
@@ -259,7 +259,7 @@ public abstract class SharedWieldableSystem : EntitySystem
return false;
}
- if (_hands.CountFreeableHands((user, hands)) < component.FreeHandsRequired)
+ if (_hands.CountFreeableHands((user, hands), except: uid) < component.FreeHandsRequired)
{
if (!quiet)
{