Browse Source

Apply Hellfire spellbook validation to PItem packet handling

pull/6961/head
staphen 2 years ago committed by Anders Jenbo
parent
commit
ab601eeb11
  1. 2
      Source/msg.cpp
  2. 12
      Source/pack.cpp
  3. 1
      Source/pack.h

2
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));
}

12
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));

1
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);

Loading…
Cancel
Save