Skip to content

Commit

Permalink
Fix not being able to equip two-handed items in a certain case
Browse files Browse the repository at this point in the history
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.

Co-authored-by: Tully <[email protected]>
  • Loading branch information
ephphatha and Tully-B authored Sep 7, 2024
1 parent 77020db commit 5e0b48d
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions Source/inv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -774,24 +774,32 @@ 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
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.
// Moving a two-hand item from inventory to InvBody requires emptying both hands.
if (player.InvBody[INVLOC_HAND_RIGHT].isEmpty()) {
// If the right hand is empty then we can simply try equipping this item in the left hand,
// we'll let the common code take care of unequipping anything held there.
invloc = INVLOC_HAND_LEFT;
} else if (player.InvBody[INVLOC_HAND_LEFT].isEmpty()) {
// We have an item in the right hand but nothing in the left, so let the common code
// take care of unequipping whatever is held in the right hand. The auto-equip code
// picks the most appropriate location for the item type (which in this case will be
// the left hand), invloc isn't used there.
invloc = INVLOC_HAND_RIGHT;
} else {
// Both hands are holding items, we must unequip the right hand item and check that there's
// space for the left before trying to auto-equip
if (!AutoPlaceItemInInventory(player, player.InvBody[INVLOC_HAND_RIGHT], true)) {
// No space to move right hand item to inventory, abort.
break;
}
holdItem = player.InvBody[INVLOC_HAND_LEFT];
if (!AutoPlaceItemInInventory(player, holdItem, false)) {
if (!AutoPlaceItemInInventory(player, player.InvBody[INVLOC_HAND_LEFT], 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;
} else {
invloc = INVLOC_HAND_LEFT;
}
break;
default:
Expand Down

0 comments on commit 5e0b48d

Please sign in to comment.