From 979e67e612884b7e2d6cc3257642d8e4e56193da Mon Sep 17 00:00:00 2001 From: Jens Granseuer Date: Mon, 20 Jan 2014 20:41:04 +0100 Subject: [PATCH] Skip stacked items when sanitizing charges Fixes some stacked items resetting to stack size 1 on load. --- gemrb/core/Interface.cpp | 46 ++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/gemrb/core/Interface.cpp b/gemrb/core/Interface.cpp index cb7fa96e0e..621d2a9220 100644 --- a/gemrb/core/Interface.cpp +++ b/gemrb/core/Interface.cpp @@ -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); } }