diff --git a/Source/itemdat.h b/Source/itemdat.h index 46c9fe757..a37c70ac9 100644 --- a/Source/itemdat.h +++ b/Source/itemdat.h @@ -13,7 +13,7 @@ namespace devilution { /** @todo add missing values and apply */ -enum _item_indexes : int16_t { +enum _item_indexes : int16_t { // TODO defines all indexes in AllItemsList IDI_GOLD, IDI_WARRIOR, IDI_WARRSHLD, @@ -64,6 +64,9 @@ enum _item_indexes : int16_t { IDI_FULLNOTE, IDI_BROWNSUIT, IDI_GREYSUIT, + IDI_SORCERER_DIABLO = 166, + + IDI_LAST = IDI_SORCERER_DIABLO, IDI_NONE = -1, }; diff --git a/Source/items.cpp b/Source/items.cpp index eda467297..ce76cd3eb 100644 --- a/Source/items.cpp +++ b/Source/items.cpp @@ -2516,6 +2516,9 @@ void NextItemRecord(int i) bool IsItemAvailable(int i) { + if (i < 0 || i > IDI_LAST) + return false; + if (gbIsSpawn) { if (i >= 62 && i <= 71) return false; // Medium and heavy armors diff --git a/Source/loadsave.cpp b/Source/loadsave.cpp index 07e0fc2be..9d1f9b16f 100644 --- a/Source/loadsave.cpp +++ b/Source/loadsave.cpp @@ -1461,7 +1461,7 @@ _item_indexes RemapItemIdxFromDiablo(_item_indexes i) { constexpr auto GetItemIdValue = [](int i) -> int { if (i == IDI_SORCERER) { - return 166; + return IDI_SORCERER_DIABLO; } if (i >= 156) { i += 5; // Hellfire exclusive items @@ -1482,7 +1482,7 @@ _item_indexes RemapItemIdxFromDiablo(_item_indexes i) _item_indexes RemapItemIdxToDiablo(_item_indexes i) { constexpr auto GetItemIdValue = [](int i) -> int { - if (i == 166) { + if (i == IDI_SORCERER_DIABLO) { return IDI_SORCERER; } if ((i >= 83 && i <= 86) || i == 92 || i >= 161) { diff --git a/Source/pack.cpp b/Source/pack.cpp index 694a746db..73c11a0e9 100644 --- a/Source/pack.cpp +++ b/Source/pack.cpp @@ -140,10 +140,6 @@ void UnPackItem(const ItemPack *is, Item *id, bool isHellfire) { auto &item = Items[MAXITEMS]; auto idx = static_cast<_item_indexes>(SDL_SwapLE16(is->idx)); - if (idx == IDI_NONE) { - id->_itype = ItemType::None; - return; - } if (gbIsSpawn) { idx = RemapItemIdxFromSpawn(idx);