From 146136512c6abc0ddb61de8e2e9742336ac8b3cd Mon Sep 17 00:00:00 2001 From: Tully <166401925+Tully-B@users.noreply.github.com> Date: Wed, 10 Apr 2024 02:00:23 +0200 Subject: [PATCH] Fix not being able to equip two-handed items in a certain case (#5076) Fix a bug that caused two-handed items not to able to be equipped if there was an item in the right hand, but not in the left one and also there wasn't enough space to place the right item TWO times. This was unintended, obviously, the right item should only be checked for once. --- Source/inv.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/Source/inv.cpp b/Source/inv.cpp index f10da757402..36b8ef6db17 100644 --- a/Source/inv.cpp +++ b/Source/inv.cpp @@ -731,19 +731,21 @@ void CheckInvCut(Player &player, Point cursorPosition, bool automaticMove, bool } break; case ILOC_TWOHAND: - // Moving a two-hand item from inventory to InvBody requires emptying both hands + // Moving a two-hand item from inventory to InvBody requires emptying both hands. if (!player.InvBody[INVLOC_HAND_RIGHT].isEmpty()) { holdItem = player.InvBody[INVLOC_HAND_RIGHT]; if (!AutoPlaceItemInInventory(player, holdItem, true)) { - // No space to move right hand item to inventory, abort. + // No space to move right hand item to inventory, abort. break; } - holdItem = player.InvBody[INVLOC_HAND_LEFT]; - if (!AutoPlaceItemInInventory(player, holdItem, false)) { - // No space for left item. Move back right item to right hand and abort. - player.InvBody[INVLOC_HAND_RIGHT] = player.InvList[player._pNumInv - 1]; - player.RemoveInvItem(player._pNumInv - 1, false); - break; + if (!player.InvBody[INVLOC_HAND_LEFT].isEmpty()) { + holdItem = player.InvBody[INVLOC_HAND_LEFT]; + if (!AutoPlaceItemInInventory(player, holdItem, false)) { + // No space for left item. Move back right item to right hand and abort. + player.InvBody[INVLOC_HAND_RIGHT] = player.InvList[player._pNumInv - 1]; + player.RemoveInvItem(player._pNumInv - 1, false); + break; + } } RemoveEquipment(player, INVLOC_HAND_RIGHT, false); invloc = INVLOC_HAND_LEFT;