Fix unhandled edge case in TradeItemModel with items that are able to stack, but are not currently stacked (e.g. after repairing a damaged item)

Fixes #1368
deque
scrawl 11 years ago
parent 16ac6e7aac
commit de7fcf0beb

@ -100,7 +100,7 @@ namespace MWGui
for (size_t i=0; i<mSourceModel->getItemCount(); ++i)
{
const ItemStack& item = mSourceModel->getItem(i);
if (item == itemToSearch)
if (item.mBase == itemToSearch.mBase)
return i;
}
return -1;
@ -112,7 +112,7 @@ namespace MWGui
for (size_t i=0; i<getItemCount(); ++i)
{
const ItemStack& item = getItem(i);
if (item == itemToSearch)
if (item.mBase == itemToSearch.mBase)
return i;
}
return -1;

@ -35,7 +35,7 @@ namespace MWGui
bool found = false;
for (; it != out.end(); ++it)
{
if (it->stacks(item))
if (it->mBase == item.mBase)
{
it->mCount += item.mCount;
found = true;
@ -52,7 +52,7 @@ namespace MWGui
bool found = false;
for (; it != out.end(); ++it)
{
if (it->stacks(item))
if (it->mBase == item.mBase)
{
if (it->mCount < count)
throw std::runtime_error("Not enough borrowed items to return");
@ -114,7 +114,7 @@ namespace MWGui
size_t i=0;
for (; i<sourceModel->getItemCount(); ++i)
{
if (it->stacks(sourceModel->getItem(i)))
if (it->mBase == sourceModel->getItem(i).mBase)
break;
}
if (i == sourceModel->getItemCount())
@ -182,7 +182,7 @@ namespace MWGui
std::vector<ItemStack>::iterator it = mBorrowedFromUs.begin();
for (; it != mBorrowedFromUs.end(); ++it)
{
if (it->stacks(item))
if (it->mBase == item.mBase)
{
if (item.mCount < it->mCount)
throw std::runtime_error("Lent more items than present");

Loading…
Cancel
Save