Browse Source

Avoid durability overflow when packing items. (#6342)

pull/6273/head^2
Anders Jenbo 3 years ago committed by GitHub
parent
commit
97ee615a8a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      Source/pack.cpp

8
Source/pack.cpp

@ -91,8 +91,12 @@ void PackItem(ItemPack &packedItem, const Item &item, bool isHellfire)
packedItem.iSeed = SDL_SwapLE32(item._iSeed);
packedItem.iCreateInfo = SDL_SwapLE16(item._iCreateInfo);
packedItem.bId = (item._iMagical << 1) | (item._iIdentified ? 1 : 0);
packedItem.bDur = item._iDurability;
packedItem.bMDur = item._iMaxDur;
if (item._iMaxDur > 255)
packedItem.bMDur = 254;
else
packedItem.bMDur = item._iMaxDur;
packedItem.bDur = std::min<int32_t>(item._iDurability, packedItem.bMDur);
packedItem.bCh = item._iCharges;
packedItem.bMCh = item._iMaxCharges;
if (item.IDidx == IDI_GOLD)

Loading…
Cancel
Save