diff --git a/Source/msg.cpp b/Source/msg.cpp index f6b8b2fdede..8d5cb7fc3d9 100644 --- a/Source/msg.cpp +++ b/Source/msg.cpp @@ -1044,6 +1044,8 @@ bool IsPItemValid(const TCmdPItem &message, const Player &player) ValidateField(creationFlags, IsTownItemValid(creationFlags, player)); else if ((creationFlags & CF_USEFUL) == CF_UPER15) ValidateFields(creationFlags, dwBuff, IsUniqueMonsterItemValid(creationFlags, dwBuff)); + else if ((dwBuff & CF_HELLFIRE) != 0 && AllItemsList[idx].iMiscId == IMISC_BOOK) + return RecreateHellfireSpellBook(player, message.item); else ValidateFields(creationFlags, dwBuff, IsDungeonItemValid(creationFlags, dwBuff)); } diff --git a/Source/pack.cpp b/Source/pack.cpp index e9039b8fd9e..892e575d8c3 100644 --- a/Source/pack.cpp +++ b/Source/pack.cpp @@ -178,10 +178,10 @@ bool IsDungeonItemValid(uint16_t iCreateInfo, uint32_t dwBuff) return level <= (diabloMaxDungeonLevel * 2); } -bool RecreateHellfireSpellBook(const Player &player, const ItemNetPack &packedItem, Item &item) +bool RecreateHellfireSpellBook(const Player &player, const TItem &packedItem, Item *item) { Item spellBook {}; - RecreateItem(player, packedItem.item, spellBook); + RecreateItem(player, packedItem, spellBook); // Hellfire uses the spell book level when generating items via CreateSpellBook() int spellBookLevel = GetSpellBookLevel(spellBook._iSpell); @@ -191,12 +191,14 @@ bool RecreateHellfireSpellBook(const Player &player, const ItemNetPack &packedIt if (spellBookLevel >= 1 && (spellBook._iCreateInfo & CF_LEVEL) == spellBookLevel * 2) { // The ilvl matches the result for a spell book drop, so we confirm the item is legitimate - item = spellBook; + if (item != nullptr) + *item = spellBook; return true; } ValidateFields(spellBook._iCreateInfo, spellBook.dwBuff, IsDungeonItemValid(spellBook._iCreateInfo, spellBook.dwBuff)); - item = spellBook; + if (item != nullptr) + *item = spellBook; return true; } @@ -529,7 +531,7 @@ bool UnPackNetItem(const Player &player, const ItemNetPack &packedItem, Item &it else if ((creationFlags & CF_USEFUL) == CF_UPER15) ValidateFields(creationFlags, dwBuff, IsUniqueMonsterItemValid(creationFlags, dwBuff)); else if ((dwBuff & CF_HELLFIRE) != 0 && AllItemsList[idx].iMiscId == IMISC_BOOK) - return RecreateHellfireSpellBook(player, packedItem, item); + return RecreateHellfireSpellBook(player, packedItem.item, &item); else ValidateFields(creationFlags, dwBuff, IsDungeonItemValid(creationFlags, dwBuff)); diff --git a/Source/pack.h b/Source/pack.h index 5ff70a1c5e5..5ed545c6435 100644 --- a/Source/pack.h +++ b/Source/pack.h @@ -146,6 +146,7 @@ bool IsCreationFlagComboValid(uint16_t iCreateInfo); bool IsTownItemValid(uint16_t iCreateInfo, const Player &player); bool IsUniqueMonsterItemValid(uint16_t iCreateInfo, uint32_t dwBuff); bool IsDungeonItemValid(uint16_t iCreateInfo, uint32_t dwBuff); +bool RecreateHellfireSpellBook(const Player &player, const TItem &packedItem, Item *item = nullptr); void PackPlayer(PlayerPack &pPack, const Player &player); void UnPackPlayer(const PlayerPack &pPack, Player &player); void PackNetPlayer(PlayerNetPack &packed, const Player &player);