diff options
Diffstat (limited to 'src/server/game/Handlers/LootHandler.cpp')
-rw-r--r-- | src/server/game/Handlers/LootHandler.cpp | 135 |
1 files changed, 68 insertions, 67 deletions
diff --git a/src/server/game/Handlers/LootHandler.cpp b/src/server/game/Handlers/LootHandler.cpp index 68911435766..c17cb02bbca 100644 --- a/src/server/game/Handlers/LootHandler.cpp +++ b/src/server/game/Handlers/LootHandler.cpp @@ -449,103 +449,104 @@ void WorldSession::DoLootReleaseAll() DoLootRelease(lootPair.second); } -void WorldSession::HandleLootMasterGiveOpcode(WorldPacket& recvData) +void WorldSession::HandleLootMasterGiveOpcode(WorldPackets::Loot::MasterLootItem& masterLootItem) { - uint8 slotid; - ObjectGuid lootguid, target_playerguid; - - recvData >> lootguid >> slotid >> target_playerguid; + AELootResult aeResult; if (!_player->GetGroup() || _player->GetGroup()->GetMasterLooterGuid() != _player->GetGUID() || _player->GetGroup()->GetLootMethod() != MASTER_LOOT) { - _player->SendLootError(lootguid, ObjectGuid::Empty, LOOT_ERROR_DIDNT_KILL); + _player->SendLootError(ObjectGuid::Empty, ObjectGuid::Empty, LOOT_ERROR_DIDNT_KILL); return; } // player on other map - Player* target = ObjectAccessor::GetPlayer(*_player, target_playerguid); + Player* target = ObjectAccessor::GetPlayer(*_player, masterLootItem.Target); if (!target) { - _player->SendLootError(lootguid, ObjectGuid::Empty, LOOT_ERROR_PLAYER_NOT_FOUND); + _player->SendLootError(ObjectGuid::Empty, ObjectGuid::Empty, LOOT_ERROR_PLAYER_NOT_FOUND); return; } TC_LOG_DEBUG("network", "WorldSession::HandleLootMasterGiveOpcode (CMSG_LOOT_MASTER_GIVE, 0x02A3) Target = [%s].", target->GetName().c_str()); - if (_player->GetLootGUID() != lootguid) + for (WorldPackets::Loot::LootRequest const& req : masterLootItem.Loot) { - _player->SendLootError(lootguid, ObjectGuid::Empty, LOOT_ERROR_DIDNT_KILL); - return; - } + Loot* loot = nullptr; + ObjectGuid lootguid = _player->GetLootWorldObjectGUID(req.Object); - if (!_player->IsInRaidWith(target) || !_player->IsInMap(target)) - { - _player->SendLootError(lootguid, ObjectGuid::Empty, LOOT_ERROR_MASTER_OTHER); - TC_LOG_INFO("entities.player.cheat", "MasterLootItem: Player %s tried to give an item to ineligible player %s !", GetPlayer()->GetName().c_str(), target->GetName().c_str()); - return; - } + if (!_player->IsInRaidWith(target) || !_player->IsInMap(target)) + { + _player->SendLootError(req.Object, ObjectGuid::Empty, LOOT_ERROR_MASTER_OTHER); + TC_LOG_INFO("entities.player.cheat", "MasterLootItem: Player %s tried to give an item to ineligible player %s !", GetPlayer()->GetName().c_str(), target->GetName().c_str()); + return; + } - Loot* loot = NULL; + if (GetPlayer()->GetLootGUID().IsCreatureOrVehicle()) + { + Creature* creature = GetPlayer()->GetMap()->GetCreature(lootguid); + if (!creature) + return; - if (GetPlayer()->GetLootGUID().IsCreatureOrVehicle()) - { - Creature* creature = GetPlayer()->GetMap()->GetCreature(lootguid); - if (!creature) + loot = &creature->loot; + } + else if (GetPlayer()->GetLootGUID().IsGameObject()) + { + GameObject* pGO = GetPlayer()->GetMap()->GetGameObject(lootguid); + if (!pGO) + return; + + loot = &pGO->loot; + } + + if (!loot) return; - loot = &creature->loot; - } - else if (GetPlayer()->GetLootGUID().IsGameObject()) - { - GameObject* pGO = GetPlayer()->GetMap()->GetGameObject(lootguid); - if (!pGO) + uint8 slotid = req.LootListID - 1; + if (slotid >= loot->items.size() + loot->quest_items.size()) + { + TC_LOG_DEBUG("loot", "MasterLootItem: Player %s might be using a hack! (slot %d, size %lu)", + GetPlayer()->GetName().c_str(), slotid, (unsigned long)loot->items.size()); return; + } - loot = &pGO->loot; - } + LootItem& item = slotid >= loot->items.size() ? loot->quest_items[slotid - loot->items.size()] : loot->items[slotid]; - if (!loot) - return; + ItemPosCountVec dest; + InventoryResult msg = target->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, item.itemid, item.count); + if (item.follow_loot_rules && !item.AllowedForPlayer(target)) + msg = EQUIP_ERR_CANT_EQUIP_EVER; + if (msg != EQUIP_ERR_OK) + { + if (msg == EQUIP_ERR_ITEM_MAX_COUNT) + _player->SendLootError(req.Object, ObjectGuid::Empty, LOOT_ERROR_MASTER_UNIQUE_ITEM); + else if (msg == EQUIP_ERR_INV_FULL) + _player->SendLootError(req.Object, ObjectGuid::Empty, LOOT_ERROR_MASTER_INV_FULL); + else + _player->SendLootError(req.Object, ObjectGuid::Empty, LOOT_ERROR_MASTER_OTHER); - if (slotid >= loot->items.size() + loot->quest_items.size()) - { - TC_LOG_DEBUG("loot", "MasterLootItem: Player %s might be using a hack! (slot %d, size %lu)", - GetPlayer()->GetName().c_str(), slotid, (unsigned long)loot->items.size()); - return; - } + target->SendEquipError(msg, NULL, NULL, item.itemid); + return; + } - LootItem& item = slotid >= loot->items.size() ? loot->quest_items[slotid - loot->items.size()] : loot->items[slotid]; + // now move item from loot to target inventory + Item* newitem = target->StoreNewItem(dest, item.itemid, true, item.randomBonusListId, item.GetAllowedLooters(), item.context, item.BonusListIDs); + aeResult.Add(newitem, item.count, loot->loot_type); - ItemPosCountVec dest; - InventoryResult msg = target->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, item.itemid, item.count); - if (item.follow_loot_rules && !item.AllowedForPlayer(target)) - msg = EQUIP_ERR_CANT_EQUIP_EVER; - if (msg != EQUIP_ERR_OK) - { - if (msg == EQUIP_ERR_ITEM_MAX_COUNT) - _player->SendLootError(lootguid, ObjectGuid::Empty, LOOT_ERROR_MASTER_UNIQUE_ITEM); - else if (msg == EQUIP_ERR_INV_FULL) - _player->SendLootError(lootguid, ObjectGuid::Empty, LOOT_ERROR_MASTER_INV_FULL); - else - _player->SendLootError(lootguid, ObjectGuid::Empty, LOOT_ERROR_MASTER_OTHER); + // mark as looted + item.count = 0; + item.is_looted = true; - target->SendEquipError(msg, NULL, NULL, item.itemid); - return; + loot->NotifyItemRemoved(slotid); + --loot->unlootedCount; } - // now move item from loot to target inventory - Item* newitem = target->StoreNewItem(dest, item.itemid, true, item.randomBonusListId, item.GetAllowedLooters(), item.context, item.BonusListIDs); - target->SendNewItem(newitem, uint32(item.count), false, false, true); - target->UpdateCriteria(CRITERIA_TYPE_LOOT_ITEM, item.itemid, item.count); - target->UpdateCriteria(CRITERIA_TYPE_LOOT_TYPE, item.itemid, item.count, loot->loot_type); - target->UpdateCriteria(CRITERIA_TYPE_LOOT_EPIC_ITEM, item.itemid, item.count); - - // mark as looted - item.count = 0; - item.is_looted = true; - - loot->NotifyItemRemoved(slotid); - --loot->unlootedCount; + for (AELootResult::ResultValue const& resultValue : aeResult) + { + target->SendNewItem(resultValue.item, resultValue.count, false, false, true); + target->UpdateCriteria(CRITERIA_TYPE_LOOT_ITEM, resultValue.item->GetEntry(), resultValue.count); + target->UpdateCriteria(CRITERIA_TYPE_LOOT_TYPE, resultValue.item->GetEntry(), resultValue.count, resultValue.lootType); + target->UpdateCriteria(CRITERIA_TYPE_LOOT_EPIC_ITEM, resultValue.item->GetEntry(), resultValue.count); + } } void WorldSession::HandleSetLootSpecialization(WorldPackets::Loot::SetLootSpecialization& packet) |