diff --git a/Source/items.cpp b/Source/items.cpp index 649998c80..1627f8b74 100644 --- a/Source/items.cpp +++ b/Source/items.cpp @@ -127,8 +127,13 @@ enum class PlayerArmorGraphic : uint8_t { // clang-format on }; ItemStruct curruitem; + +/** Holds item get records, tracking items being recently looted. This is in an effort to prevent items being picked up more than once. */ ItemGetRecordStruct itemrecord[MAXITEMS]; + bool itemhold[3][3]; + +/** Specifies the number of active item get records. */ int gnNumGetRecords; int OilLevels[] = { 1, 10, 1, 10, 4, 1, 5, 17, 1, 10 }; @@ -2628,6 +2633,9 @@ void InitItems() } ShowUniqueItemInfoBox = false; + + // BUGFIX: item get records not reset when resetting items (fixed). + initItemGetRecords(); } void CalcPlrItemVals(int playerId, bool loadgfx) @@ -4964,4 +4972,13 @@ void ItemStruct::SetNewAnimation(bool showAnimation) } } +/** + * @brief Resets item get records. + */ +void initItemGetRecords() +{ + memset(itemrecord, 0, sizeof(itemrecord)); + gnNumGetRecords = 0; +} + } // namespace devilution diff --git a/Source/items.h b/Source/items.h index 03b1ce392..a29838e0e 100644 --- a/Source/items.h +++ b/Source/items.h @@ -466,6 +466,7 @@ void CreateMagicWeapon(Point position, int imisc, int icurs, bool sendmsg, bool bool GetItemRecord(int nSeed, uint16_t wCI, int nIndex); void SetItemRecord(int nSeed, uint16_t wCI, int nIndex); void PutItemRecord(int nSeed, uint16_t wCI, int nIndex); +void initItemGetRecords(); #ifdef _DEBUG std::string DebugSpawnItem(std::string itemName, bool unique);