diff --git a/CHANGELOG.md b/CHANGELOG.md index 569fa91c16..d0bdd30f6b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ Bug #4204: Dead slaughterfish doesn't float to water surface after loading saved game Bug #4382: Sound output device does not change when it should Bug #4610: Casting a Bound Weapon spell cancels the casting animation by equipping the weapon prematurely + Bug #4754: Stack of ammunition cannot be equipped partially Bug #4816: GetWeaponDrawn returns 1 before weapon is attached Bug #5057: Weapon swing sound plays at same pitch whether it hits or misses Bug #5129: Stuttering animation on Centurion Archer @@ -26,6 +27,7 @@ Bug #6716: mwscript comparison operator handling is too restrictive Bug #6807: Ultimate Galleon is not working properly Bug #6893: Lua: Inconsistent behavior with actors affected by Disable and SetDelete commands + Bug #6894: Added item combines with equipped stack instead of creating a new unequipped stack Bug #6939: OpenMW-CS: ID columns are too short Bug #6949: Sun Damage effect doesn't work in quasi exteriors Bug #6964: Nerasa Dralor Won't Follow diff --git a/apps/openmw/mwgui/inventorywindow.cpp b/apps/openmw/mwgui/inventorywindow.cpp index d96db97353..1ab37ace0e 100644 --- a/apps/openmw/mwgui/inventorywindow.cpp +++ b/apps/openmw/mwgui/inventorywindow.cpp @@ -579,7 +579,28 @@ namespace MWGui mDragAndDrop->mItem, mDragAndDrop->mDraggedCount, mTradeModel); } - useItem(ptr); + // Handles partial equipping + const std::pair, bool> slots = ptr.getClass().getEquipmentSlots(ptr); + if (!slots.first.empty() && slots.second) + { + int equippedStackableCount = 0; + MWWorld::InventoryStore& invStore = mPtr.getClass().getInventoryStore(mPtr); + MWWorld::ConstContainerStoreIterator slotIt = invStore.getSlot(slots.first.front()); + + // Get the count before useItem() + if (slotIt != invStore.end() && slotIt->getCellRef().getRefId() == ptr.getCellRef().getRefId()) + equippedStackableCount = slotIt->getRefData().getCount(); + + useItem(ptr); + int unequipCount = ptr.getRefData().getCount() - mDragAndDrop->mDraggedCount - equippedStackableCount; + if (unequipCount > 0) + { + invStore.unequipItemQuantity(ptr, unequipCount); + updateItemView(); + } + } + else + useItem(ptr); // If item is ingredient or potion don't stop drag and drop to simplify action of taking more than one 1 // item diff --git a/apps/openmw/mwworld/containerstore.cpp b/apps/openmw/mwworld/containerstore.cpp index 30287b4d4e..838a44b48b 100644 --- a/apps/openmw/mwworld/containerstore.cpp +++ b/apps/openmw/mwworld/containerstore.cpp @@ -1,4 +1,5 @@ #include "containerstore.hpp" +#include "inventorystore.hpp" #include #include @@ -396,6 +397,11 @@ MWWorld::ContainerStoreIterator MWWorld::ContainerStore::addImp(const Ptr& ptr, // determine whether to stack or not for (MWWorld::ContainerStoreIterator iter(begin(type)); iter != end(); ++iter) { + // Don't stack with equipped items + if (!mActor.isEmpty() && mActor.getClass().hasInventoryStore(mActor)) + if (mActor.getClass().getInventoryStore(mActor).isEquipped(*iter)) + continue; + if (stacks(*iter, ptr)) { // stack