From 141755b4735ed8b5dff8479e34839d5d972b52a2 Mon Sep 17 00:00:00 2001 From: Ragora Date: Wed, 10 Sep 2014 21:34:17 -0400 Subject: [PATCH 1/3] Appears to have resolved the issue with unequipping conjured items and all possible error conditions deriving from being able to unequip them --- apps/openmw/mwgui/container.cpp | 8 ++++++++ apps/openmw/mwgui/inventorywindow.cpp | 17 ++++++++--------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/apps/openmw/mwgui/container.cpp b/apps/openmw/mwgui/container.cpp index 73ca8779f1..19fe4b94cb 100644 --- a/apps/openmw/mwgui/container.cpp +++ b/apps/openmw/mwgui/container.cpp @@ -113,6 +113,14 @@ namespace MWGui std::string sound = mItem.mBase.getClass().getDownSoundId(mItem.mBase); MWBase::Environment::get().getSoundManager()->playSound (sound, 1.0, 1.0); + // We can't drop a conjured item to the ground; the target container should always be the source container though if it's somehow not on your + // person and you're trying to take it, this would display the wrong message. (Dropping rather than taking). + if (mItem.mBase.getCellRef().getRefId().size() > 6 && mItem.mBase.getCellRef().getRefId().substr(0,6) == "bound_" && targetModel != mSourceModel) + { + MWBase::Environment::get().getWindowManager()->messageBox("#{sBarterDialog12}"); + return; + } + // If item is dropped where it was taken from, we don't need to do anything - // otherwise, do the transfer if (targetModel != mSourceModel) diff --git a/apps/openmw/mwgui/inventorywindow.cpp b/apps/openmw/mwgui/inventorywindow.cpp index 441d8c28f0..4f1ef7de8c 100644 --- a/apps/openmw/mwgui/inventorywindow.cpp +++ b/apps/openmw/mwgui/inventorywindow.cpp @@ -183,21 +183,20 @@ namespace MWGui MWWorld::Ptr object = item.mBase; int count = item.mCount; - // Bound items may not be moved - if (item.mBase.getCellRef().getRefId().size() > 6 - && item.mBase.getCellRef().getRefId().substr(0,6) == "bound_") - { - MWBase::Environment::get().getSoundManager()->playSound (sound, 1.0, 1.0); - MWBase::Environment::get().getWindowManager()->messageBox("#{sBarterDialog12}"); - return; - } - bool shift = MyGUI::InputManager::getInstance().isShiftPressed(); if (MyGUI::InputManager::getInstance().isControlPressed()) count = 1; if (mTrading) { + // Can't give bound items to a merchant + if (item.mBase.getCellRef().getRefId().size() > 6 && item.mBase.getCellRef().getRefId().substr(0,6) == "bound_") + { + MWBase::Environment::get().getSoundManager()->playSound (sound, 1.0, 1.0); + MWBase::Environment::get().getWindowManager()->messageBox("#{sBarterDialog9}"); + return; + } + // check if merchant accepts item int services = MWBase::Environment::get().getWindowManager()->getTradeWindow()->getMerchantServices(); if (!object.getClass().canSell(object, services)) From 69dbd6b30f6567fa780bdeebc472b2d6ffc9079b Mon Sep 17 00:00:00 2001 From: Ragora Date: Wed, 10 Sep 2014 23:38:38 -0400 Subject: [PATCH 2/3] Added checks for different bound item situations --- apps/openmw/mwgui/companionwindow.cpp | 11 +++++++++-- apps/openmw/mwgui/container.cpp | 14 ++++++++++---- apps/openmw/mwgui/inventoryitemmodel.cpp | 4 ++++ apps/openmw/mwgui/inventorywindow.cpp | 2 +- 4 files changed, 24 insertions(+), 7 deletions(-) diff --git a/apps/openmw/mwgui/companionwindow.cpp b/apps/openmw/mwgui/companionwindow.cpp index 6ac8c9d187..13daeefc50 100644 --- a/apps/openmw/mwgui/companionwindow.cpp +++ b/apps/openmw/mwgui/companionwindow.cpp @@ -41,6 +41,15 @@ CompanionWindow::CompanionWindow(DragAndDrop *dragAndDrop, MessageBoxManager* ma void CompanionWindow::onItemSelected(int index) { + const ItemStack& item = mSortModel->getItem(index); + + // We can't take conjured items from a companion NPC + if (item.mBase.getCellRef().getRefId().size() > 6 && item.mBase.getCellRef().getRefId().substr(0,6) == "bound_") + { + MWBase::Environment::get().getWindowManager()->messageBox("#{sBarterDialog12}"); + return; + } + if (mDragAndDrop->mIsOnDragAndDrop) { mDragAndDrop->drop(mModel, mItemView); @@ -48,8 +57,6 @@ void CompanionWindow::onItemSelected(int index) return; } - const ItemStack& item = mSortModel->getItem(index); - MWWorld::Ptr object = item.mBase; int count = item.mCount; bool shift = MyGUI::InputManager::getInstance().isShiftPressed(); diff --git a/apps/openmw/mwgui/container.cpp b/apps/openmw/mwgui/container.cpp index 19fe4b94cb..633e536d70 100644 --- a/apps/openmw/mwgui/container.cpp +++ b/apps/openmw/mwgui/container.cpp @@ -113,8 +113,7 @@ namespace MWGui std::string sound = mItem.mBase.getClass().getDownSoundId(mItem.mBase); MWBase::Environment::get().getSoundManager()->playSound (sound, 1.0, 1.0); - // We can't drop a conjured item to the ground; the target container should always be the source container though if it's somehow not on your - // person and you're trying to take it, this would display the wrong message. (Dropping rather than taking). + // We can't drop a conjured item to the ground; the target container should always be the source container if (mItem.mBase.getCellRef().getRefId().size() > 6 && mItem.mBase.getCellRef().getRefId().substr(0,6) == "bound_" && targetModel != mSourceModel) { MWBase::Environment::get().getWindowManager()->messageBox("#{sBarterDialog12}"); @@ -175,6 +174,15 @@ namespace MWGui void ContainerWindow::onItemSelected(int index) { + const ItemStack& item = mSortModel->getItem(index); + + // We can't take a conjured item from a container (some NPC we're pickpocketing, a box, etc) + if (item.mBase.getCellRef().getRefId().size() > 6 && item.mBase.getCellRef().getRefId().substr(0,6) == "bound_") + { + MWBase::Environment::get().getWindowManager()->messageBox("#{sContentsMessage1}"); + return; + } + if (mDragAndDrop->mIsOnDragAndDrop) { if (!dynamic_cast(mModel)) @@ -182,8 +190,6 @@ namespace MWGui return; } - const ItemStack& item = mSortModel->getItem(index); - MWWorld::Ptr object = item.mBase; int count = item.mCount; bool shift = MyGUI::InputManager::getInstance().isShiftPressed(); diff --git a/apps/openmw/mwgui/inventoryitemmodel.cpp b/apps/openmw/mwgui/inventoryitemmodel.cpp index ad1a4e9537..8273b92a6c 100644 --- a/apps/openmw/mwgui/inventoryitemmodel.cpp +++ b/apps/openmw/mwgui/inventoryitemmodel.cpp @@ -61,6 +61,10 @@ void InventoryItemModel::removeItem (const ItemStack& item, size_t count) MWWorld::Ptr InventoryItemModel::moveItem(const ItemStack &item, size_t count, ItemModel *otherModel) { + // Can't move conjured items: This is a general fix that also takes care of issues with taking conjured items via the 'Take All' button. + if (item.mBase.getCellRef().getRefId().size() > 6 && item.mBase.getCellRef().getRefId().substr(0,6) == "bound_") + return MWWorld::Ptr(); + bool setNewOwner = false; // Are you dead? Then you wont need that anymore diff --git a/apps/openmw/mwgui/inventorywindow.cpp b/apps/openmw/mwgui/inventorywindow.cpp index 4f1ef7de8c..2ec30d5bd3 100644 --- a/apps/openmw/mwgui/inventorywindow.cpp +++ b/apps/openmw/mwgui/inventorywindow.cpp @@ -189,7 +189,7 @@ namespace MWGui if (mTrading) { - // Can't give bound items to a merchant + // Can't give cojured items to a merchant if (item.mBase.getCellRef().getRefId().size() > 6 && item.mBase.getCellRef().getRefId().substr(0,6) == "bound_") { MWBase::Environment::get().getSoundManager()->playSound (sound, 1.0, 1.0); From 74e1db3ac8f4a10cabfa4375f747a93245e4a08f Mon Sep 17 00:00:00 2001 From: Ragora Date: Thu, 11 Sep 2014 01:00:39 -0400 Subject: [PATCH 3/3] Minor Correction to existing conjured item logic --- apps/openmw/mwgui/companionwindow.cpp | 14 +++++++------- apps/openmw/mwgui/container.cpp | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/apps/openmw/mwgui/companionwindow.cpp b/apps/openmw/mwgui/companionwindow.cpp index 13daeefc50..4ea2a44c70 100644 --- a/apps/openmw/mwgui/companionwindow.cpp +++ b/apps/openmw/mwgui/companionwindow.cpp @@ -41,6 +41,13 @@ CompanionWindow::CompanionWindow(DragAndDrop *dragAndDrop, MessageBoxManager* ma void CompanionWindow::onItemSelected(int index) { + if (mDragAndDrop->mIsOnDragAndDrop) + { + mDragAndDrop->drop(mModel, mItemView); + updateEncumbranceBar(); + return; + } + const ItemStack& item = mSortModel->getItem(index); // We can't take conjured items from a companion NPC @@ -50,13 +57,6 @@ void CompanionWindow::onItemSelected(int index) return; } - if (mDragAndDrop->mIsOnDragAndDrop) - { - mDragAndDrop->drop(mModel, mItemView); - updateEncumbranceBar(); - return; - } - MWWorld::Ptr object = item.mBase; int count = item.mCount; bool shift = MyGUI::InputManager::getInstance().isShiftPressed(); diff --git a/apps/openmw/mwgui/container.cpp b/apps/openmw/mwgui/container.cpp index 633e536d70..bc04eafebd 100644 --- a/apps/openmw/mwgui/container.cpp +++ b/apps/openmw/mwgui/container.cpp @@ -174,6 +174,13 @@ namespace MWGui void ContainerWindow::onItemSelected(int index) { + if (mDragAndDrop->mIsOnDragAndDrop) + { + if (!dynamic_cast(mModel)) + dropItem(); + return; + } + const ItemStack& item = mSortModel->getItem(index); // We can't take a conjured item from a container (some NPC we're pickpocketing, a box, etc) @@ -183,13 +190,6 @@ namespace MWGui return; } - if (mDragAndDrop->mIsOnDragAndDrop) - { - if (!dynamic_cast(mModel)) - dropItem(); - return; - } - MWWorld::Ptr object = item.mBase; int count = item.mCount; bool shift = MyGUI::InputManager::getInstance().isShiftPressed();