Skip to content

Commit

Permalink
Rework fix to address comments by BevapDin.
Browse files Browse the repository at this point in the history
  • Loading branch information
bdragon28 committed Mar 9, 2014
1 parent 60b6725 commit ca9436b
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/inventory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1062,10 +1062,10 @@ std::list<item> inventory::use_amount(itype_id it, int quantity, bool use_contai
{
sort();
std::list<item> ret;
for (invstack::iterator iter = items.begin(); iter != items.end() && quantity > 0; ++iter) {
for (invstack::iterator iter = items.begin(); iter != items.end() && quantity > 0; /* noop */) {
for (std::list<item>::iterator stack_iter = iter->begin();
stack_iter != iter->end() && quantity > 0;
++stack_iter) {
/* noop */) {
// First, check contents
bool used_item_contents = false;
for (int k = 0; k < stack_iter->contents.size() && quantity > 0; k++) {
Expand All @@ -1082,26 +1082,24 @@ std::list<item> inventory::use_amount(itype_id it, int quantity, bool use_contai
stack_iter = iter->erase(stack_iter);
if (iter->empty()) {
iter = items.erase(iter);
--iter;
break;
} else {
--stack_iter;
continue;
}
} else if (stack_iter->type->id == it && quantity > 0 && stack_iter->contents.size() == 0) {
ret.push_back(*stack_iter);
quantity--;
stack_iter = iter->erase(stack_iter);
if (iter->empty()) {
iter = items.erase(iter);
if (iter != items.begin()) {
--iter;
}
break;
} else if (stack_iter != iter->begin()) {
--stack_iter;
} else {
continue;
}
}
++stack_iter;
}
++iter;
}
return ret;
}
Expand Down

0 comments on commit ca9436b

Please sign in to comment.