|
|
@ -262,7 +262,7 @@ namespace MWMechanics
|
|
|
|
MWBase::Environment::get().getWorld()->getPlayer().setDrawState(MWMechanics::DrawState_Weapon);
|
|
|
|
MWBase::Environment::get().getWorld()->getPlayer().setDrawState(MWMechanics::DrawState_Weapon);
|
|
|
|
|
|
|
|
|
|
|
|
if (prevItem != store.end())
|
|
|
|
if (prevItem != store.end())
|
|
|
|
mPreviousItems[itemId] = *prevItem;
|
|
|
|
mPreviousItems[itemId] = (*prevItem).getCellRef().getRefId();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Actors::removeBoundItem (const std::string& itemId, const MWWorld::Ptr& actor)
|
|
|
|
void Actors::removeBoundItem (const std::string& itemId, const MWWorld::Ptr& actor)
|
|
|
@ -279,26 +279,34 @@ namespace MWMechanics
|
|
|
|
if (actor != MWMechanics::getPlayer())
|
|
|
|
if (actor != MWMechanics::getPlayer())
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
MWWorld::Ptr prevItem = mPreviousItems[itemId];
|
|
|
|
std::string prevItemId = mPreviousItems[itemId];
|
|
|
|
|
|
|
|
|
|
|
|
mPreviousItems.erase(itemId);
|
|
|
|
mPreviousItems.erase(itemId);
|
|
|
|
|
|
|
|
|
|
|
|
if (prevItem.isEmpty())
|
|
|
|
if (prevItemId.empty())
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
// check if the item is still in the player's inventory
|
|
|
|
// Find the item by id
|
|
|
|
MWWorld::ContainerStoreIterator it = store.begin();
|
|
|
|
MWWorld::Ptr item;
|
|
|
|
for (; it != store.end(); ++it)
|
|
|
|
for (MWWorld::ContainerStoreIterator iter = store.begin(); iter != store.end(); ++iter)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (*it == prevItem)
|
|
|
|
if (Misc::StringUtils::ciEqual(iter->getCellRef().getRefId(), prevItemId))
|
|
|
|
break;
|
|
|
|
{
|
|
|
|
|
|
|
|
if (item.isEmpty() ||
|
|
|
|
|
|
|
|
// Prefer the stack with the lowest remaining uses
|
|
|
|
|
|
|
|
!item.getClass().hasItemHealth(*iter) ||
|
|
|
|
|
|
|
|
iter->getClass().getItemHealth(*iter) < item.getClass().getItemHealth(item))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
item = *iter;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// we should equip previous item only if expired bound item was equipped.
|
|
|
|
// we should equip previous item only if expired bound item was equipped.
|
|
|
|
if (it == store.end() || !wasEquipped)
|
|
|
|
if (item.isEmpty() || !wasEquipped)
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
MWWorld::ActionEquip action(prevItem);
|
|
|
|
MWWorld::ActionEquip action(item);
|
|
|
|
action.execute(actor);
|
|
|
|
action.execute(actor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|