Browse Source

allow auto-equipping two-handed weapons with both hands occupied

specifically where the larger item is in the right hand, this would fail previously in certain circumstances.
pull/7498/head
Andrew James 1 year ago committed by Anders Jenbo
parent
commit
5758e561fd
  1. 25
      Source/inv.cpp

25
Source/inv.cpp

@ -837,20 +837,25 @@ void CheckInvCut(Player &player, Point cursorPosition, bool automaticMove, bool
// 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])) {
// No space to move right hand item to inventory, abort.
break;
// Both hands are holding items, we must unequip one of the items and check that there's
// space for the other before trying to auto-equip
inv_body_loc mainHand = INVLOC_HAND_LEFT;
inv_body_loc offHand = INVLOC_HAND_RIGHT;
if (!AutoPlaceItemInInventory(player, player.InvBody[offHand])) {
// No space to move right hand item to inventory, can we move the left instead?
std::swap(mainHand, offHand);
if (!AutoPlaceItemInInventory(player, player.InvBody[offHand])) {
break;
}
}
if (!CouldFitItemInInventory(player, player.InvBody[INVLOC_HAND_LEFT], iv)) {
// No space for left item. Move back right item to right hand and abort.
player.InvBody[INVLOC_HAND_RIGHT] = player.InvList[player._pNumInv - 1];
if (!CouldFitItemInInventory(player, player.InvBody[mainHand], iv)) {
// No space for the main hand item. Move the other item back to the off hand and abort.
player.InvBody[offHand] = player.InvList[player._pNumInv - 1];
player.RemoveInvItem(player._pNumInv - 1, false);
break;
}
RemoveEquipment(player, INVLOC_HAND_RIGHT, false);
invloc = INVLOC_HAND_LEFT;
RemoveEquipment(player, offHand, false);
invloc = mainHand;
}
break;
default:

Loading…
Cancel
Save