Browse Source

Restore packed item state when regenerating an item using heroitem data

pull/6679/head
staphen 3 years ago committed by Anders Jenbo
parent
commit
02790d8265
  1. 5
      Source/loadsave.cpp
  2. 6
      Source/pack.cpp

5
Source/loadsave.cpp

@ -968,6 +968,11 @@ void LoadMatchingItems(LoadHelper &file, const Player &player, const int n, Item
if ((heroItem.dwBuff & CF_HELLFIRE) != (unpackedItem.dwBuff & CF_HELLFIRE)) {
unpackedItem = {};
RecreateItem(player, unpackedItem, heroItem.IDidx, heroItem._iCreateInfo, heroItem._iSeed, heroItem._ivalue, (heroItem.dwBuff & CF_HELLFIRE) != 0);
unpackedItem._iIdentified = heroItem._iIdentified;
unpackedItem._iMaxDur = heroItem._iMaxDur;
unpackedItem._iDurability = ClampDurability(unpackedItem, heroItem._iDurability);
unpackedItem._iMaxCharges = std::clamp<int>(heroItem._iMaxCharges, 0, unpackedItem._iMaxCharges);
unpackedItem._iCharges = std::clamp<int>(heroItem._iCharges, 0, unpackedItem._iMaxCharges);
}
if (!IsShopPriceValid(unpackedItem)) {
unpackedItem.clear();

6
Source/pack.cpp

@ -435,13 +435,7 @@ void UnPackItem(const ItemPack &packedItem, const Player &player, Item &item, bo
item._iDurability = ClampDurability(item, packedItem.bDur);
item._iMaxCharges = clamp<int>(packedItem.bMCh, 0, item._iMaxCharges);
item._iCharges = clamp<int>(packedItem.bCh, 0, item._iMaxCharges);
RemoveInvalidItem(item);
if (isHellfire)
item.dwBuff |= CF_HELLFIRE;
else
item.dwBuff &= ~CF_HELLFIRE;
}
}

Loading…
Cancel
Save