diff options
| author | Shauren <shauren.trinity@gmail.com> | 2018-02-18 16:32:03 +0100 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2018-02-18 16:33:50 +0100 |
| commit | 75603fe1a00f9aac36bfad1378447bea973001c1 (patch) | |
| tree | cf8fea04151aa15c713704b6f324d0f61e304725 /src/server/game/Groups/Group.cpp | |
| parent | 4af15915bc8b780ef854c2e58d7ab5bb38f56758 (diff) | |
Core/DataStores: Updated db2 structures to 7.3.5.25996
Diffstat (limited to 'src/server/game/Groups/Group.cpp')
| -rw-r--r-- | src/server/game/Groups/Group.cpp | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/src/server/game/Groups/Group.cpp b/src/server/game/Groups/Group.cpp index 18b0bdbc901..9ecd0d8b68f 100644 --- a/src/server/game/Groups/Group.cpp +++ b/src/server/game/Groups/Group.cpp @@ -26,6 +26,7 @@ #include "GameObject.h" #include "GroupMgr.h" #include "InstanceSaveMgr.h" +#include "Item.h" #include "LFGMgr.h" #include "Log.h" #include "LootMgr.h" @@ -879,7 +880,11 @@ void Group::SendLootStartRollToPlayer(uint32 countDown, uint32 mapId, Player* p, startLootRoll.Method = GetLootMethod(); r.FillPacket(startLootRoll.Item); - p->GetSession()->SendPacket(startLootRoll.Write()); + if (ItemDisenchantLootEntry const* disenchant = r.GetItemDisenchantLoot(p)) + if (m_maxEnchantingLevel >= disenchant->RequiredDisenchantSkill) + startLootRoll.ValidRolls |= ROLL_FLAG_TYPE_DISENCHANT; + + p->SendDirectMessage(startLootRoll.Write()); } void Group::SendLootRoll(ObjectGuid playerGuid, int32 rollNumber, uint8 rollType, Roll const& roll) const @@ -1021,9 +1026,6 @@ void Group::GroupLoot(Loot* loot, WorldObject* lootedObject) { r->setLoot(loot); r->itemSlot = itemSlot; - if (item->DisenchantID && m_maxEnchantingLevel >= item->RequiredDisenchantSkill) - r->rollVoteMask |= ROLL_FLAG_TYPE_DISENCHANT; - if (item->GetFlags2() & ITEM_FLAG2_CAN_ONLY_ROLL_GREED) r->rollVoteMask &= ~ROLL_FLAG_TYPE_NEED; @@ -1344,14 +1346,16 @@ void Group::CountTheRoll(Rolls::iterator rollI) ItemTemplate const* pProto = sObjectMgr->GetItemTemplate(roll->itemid); player->UpdateCriteria(CRITERIA_TYPE_CAST_SPELL, 13262); // Disenchant + ItemDisenchantLootEntry const* disenchant = ASSERT_NOTNULL(roll->GetItemDisenchantLoot(player)); + ItemPosCountVec dest; InventoryResult msg = player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, roll->itemid, item->count); if (msg == EQUIP_ERR_OK) - player->AutoStoreLoot(pProto->DisenchantID, LootTemplates_Disenchant, true); + player->AutoStoreLoot(disenchant->ID, LootTemplates_Disenchant, true); else // If the player's inventory is full, send the disenchant result in a mail. { Loot loot; - loot.FillLoot(pProto->DisenchantID, LootTemplates_Disenchant, player, true); + loot.FillLoot(disenchant->ID, LootTemplates_Disenchant, player, true); uint32 max_slot = loot.GetMaxSlotInLootFor(player); for (uint32 i = 0; i < max_slot; ++i) @@ -1888,6 +1892,22 @@ void Roll::FillPacket(WorldPackets::Loot::LootItemData& lootItem) const } } +ItemDisenchantLootEntry const* Roll::GetItemDisenchantLoot(Player const* player) const +{ + if (LootItem const* lootItemInSlot = (*this)->GetItemInSlot(itemSlot)) + { + WorldPackets::Item::ItemInstance itemInstance; + itemInstance.Initialize(*lootItemInSlot); + + BonusData bonusData; + bonusData.Initialize(itemInstance); + + ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(itemid); + uint32 itemLevel = Item::GetItemLevel(itemTemplate, bonusData, player->getLevel(), 0, lootItemInSlot->upgradeId); + return Item::GetDisenchantLoot(itemTemplate, bonusData.Quality, itemLevel); + } +} + void Group::SetDungeonDifficultyID(Difficulty difficulty) { m_dungeonDifficulty = difficulty; |
