Permalink
Browse files

Skip stacked items when sanitizing charges

Fixes some stacked items resetting to stack size 1 on load.
  • Loading branch information...
1 parent fbc49c3 commit 979e67e612884b7e2d6cc3257642d8e4e56193da @fizzet fizzet committed Jan 20, 2014
Showing with 23 additions and 23 deletions.
  1. +23 −23 gemrb/core/Interface.cpp
View
@@ -4844,25 +4844,32 @@ void Interface::SanitizeItem(CREItem *item) const
Item *itm = gamedata->GetItem(item->ItemResRef, true);
if (itm) {
- //set charge counters for non-rechargeable items if their charge is zero
- //set charge counters for items not using charges to one
- for (int i = 0; i < CHARGE_COUNTERS; i++) {
- ITMExtHeader *h = itm->GetExtHeader(i);
- if (h) {
- if (item->Usages[i] == 0) {
- if (!(h->RechargeFlags&IE_ITEM_RECHARGE)) {
- //HACK: the original (bg2) allows for 0 charged gems
- if (h->Charges) {
- item->Usages[i] = h->Charges;
- } else {
- item->Usages[i] = 1;
+
+ item->MaxStackAmount = itm->MaxStackAmount;
+ //if item is stacked mark it as so
+ if (itm->MaxStackAmount) {
+ item->Flags |= IE_INV_ITEM_STACKED;
+ } else {
+ //set charge counters for non-rechargeable items if their charge is zero
+ //set charge counters for items not using charges to one
+ for (int i = 0; i < CHARGE_COUNTERS; i++) {
+ ITMExtHeader *h = itm->GetExtHeader(i);
+ if (h) {
+ if (item->Usages[i] == 0) {
+ if (!(h->RechargeFlags&IE_ITEM_RECHARGE)) {
+ //HACK: the original (bg2) allows for 0 charged gems
+ if (h->Charges) {
+ item->Usages[i] = h->Charges;
+ } else {
+ item->Usages[i] = 1;
+ }
}
+ } else if (h->Charges == 0) {
+ item->Usages[i] = 1;
}
- } else if (h->Charges == 0) {
- item->Usages[i] = 1;
+ } else {
+ item->Usages[i] = 0;
}
- } else {
- item->Usages[i] = 0;
}
}
@@ -4893,13 +4900,6 @@ void Interface::SanitizeItem(CREItem *item) const
item->Flags |= IE_INV_ITEM_IDENTIFIED;
}
- //if item is stacked mark it as so
- if (itm->MaxStackAmount) {
- item->Flags |= IE_INV_ITEM_STACKED;
- }
-
- item->MaxStackAmount = itm->MaxStackAmount;
-
gamedata->FreeItem(itm, item->ItemResRef, false);
}
}

0 comments on commit 979e67e

Please sign in to comment.