Skip to content

Commit

Permalink
Restore packed item state when regenerating an item using heroitem data
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenCWills committed Sep 4, 2023
1 parent 49c5aea commit 9b9cab5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
8 changes: 8 additions & 0 deletions Source/loadsave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -969,6 +969,14 @@ 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);
RemoveInvalidItem(unpackedItem);
if (unpackedItem.isEmpty())
continue;
}
if (!IsShopPriceValid(unpackedItem)) {
unpackedItem.clear();
Expand Down
6 changes: 0 additions & 6 deletions Source/pack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -407,13 +407,7 @@ void UnPackItem(const ItemPack &packedItem, const Player &player, Item &item, bo
item._iDurability = ClampDurability(item, packedItem.bDur);
item._iMaxCharges = std::clamp<int>(packedItem.bMCh, 0, item._iMaxCharges);
item._iCharges = std::clamp<int>(packedItem.bCh, 0, item._iMaxCharges);

RemoveInvalidItem(item);

if (isHellfire)
item.dwBuff |= CF_HELLFIRE;
else
item.dwBuff &= ~CF_HELLFIRE;
}
}

Expand Down

0 comments on commit 9b9cab5

Please sign in to comment.