diff options
| author | Intel <chemicstry@gmail.com> | 2014-12-30 02:23:37 +0200 |
|---|---|---|
| committer | Intel <chemicstry@gmail.com> | 2015-01-15 22:37:10 +0200 |
| commit | dc9ce43c4506431bf13a303b4508cf9504b4fb58 (patch) | |
| tree | 90b2bf6e2e19223a49c07edcb86cc884765bc925 /src/server/game/Handlers/LootHandler.cpp | |
| parent | 8e95ca9c578d6f8eb1076c88abd5ae4d05c0e9ce (diff) | |
Core/Loot: Implemented SMSG_LOOT_RESPONSE, SMSG_LOOT_REMOVED, CMSG_AUTOSTORE_LOOT_ITEM
AoE looting is work in progress.
Diffstat (limited to 'src/server/game/Handlers/LootHandler.cpp')
| -rw-r--r-- | src/server/game/Handlers/LootHandler.cpp | 95 |
1 files changed, 49 insertions, 46 deletions
diff --git a/src/server/game/Handlers/LootHandler.cpp b/src/server/game/Handlers/LootHandler.cpp index 91353104be4..35096da66b1 100644 --- a/src/server/game/Handlers/LootHandler.cpp +++ b/src/server/game/Handlers/LootHandler.cpp @@ -33,71 +33,74 @@ #include "LootPackets.h" #include "WorldSession.h" -void WorldSession::HandleAutostoreLootItemOpcode(WorldPacket& recvData) +void WorldSession::HandleAutostoreLootItemOpcode(WorldPackets::Loot::AutoStoreLootItem& packet) { TC_LOG_DEBUG("network", "WORLD: CMSG_AUTOSTORE_LOOT_ITEM"); Player* player = GetPlayer(); ObjectGuid lguid = player->GetLootGUID(); - Loot* loot = NULL; - uint8 lootSlot = 0; - - recvData >> lootSlot; - if (lguid.IsGameObject()) + /// @todo Implement looting by LootObject guid + for (WorldPackets::Loot::LootRequest const& req : packet.Loot) { - GameObject* go = player->GetMap()->GetGameObject(lguid); + Loot* loot = NULL; - // not check distance for GO in case owned GO (fishing bobber case, for example) or Fishing hole GO - if (!go || ((go->GetOwnerGUID() != _player->GetGUID() && go->GetGoType() != GAMEOBJECT_TYPE_FISHINGHOLE) && !go->IsWithinDistInMap(_player, INTERACTION_DISTANCE))) + if (lguid.IsGameObject()) { - player->SendLootRelease(lguid); - return; - } + GameObject* go = player->GetMap()->GetGameObject(lguid); - loot = &go->loot; - } - else if (lguid.IsItem()) - { - Item* pItem = player->GetItemByGuid(lguid); + // not check distance for GO in case owned GO (fishing bobber case, for example) or Fishing hole GO + if (!go || ((go->GetOwnerGUID() != _player->GetGUID() && go->GetGoType() != GAMEOBJECT_TYPE_FISHINGHOLE) && !go->IsWithinDistInMap(_player, INTERACTION_DISTANCE))) + { + player->SendLootRelease(lguid); + continue; + } - if (!pItem) - { - player->SendLootRelease(lguid); - return; + loot = &go->loot; } - - loot = &pItem->loot; - } - else if (lguid.IsCorpse()) - { - Corpse* bones = ObjectAccessor::GetCorpse(*player, lguid); - if (!bones) + else if (lguid.IsItem()) { - player->SendLootRelease(lguid); - return; - } + Item* pItem = player->GetItemByGuid(lguid); - loot = &bones->loot; - } - else - { - Creature* creature = GetPlayer()->GetMap()->GetCreature(lguid); + if (!pItem) + { + player->SendLootRelease(lguid); + continue; + } - bool lootAllowed = creature && creature->IsAlive() == (player->getClass() == CLASS_ROGUE && creature->loot.loot_type == LOOT_PICKPOCKETING); - if (!lootAllowed || !creature->IsWithinDistInMap(_player, INTERACTION_DISTANCE)) + loot = &pItem->loot; + } + else if (lguid.IsCorpse()) { - player->SendLootError(lguid, lootAllowed ? LOOT_ERROR_TOO_FAR : LOOT_ERROR_DIDNT_KILL); - return; + Corpse* bones = ObjectAccessor::GetCorpse(*player, lguid); + if (!bones) + { + player->SendLootRelease(lguid); + continue; + } + + loot = &bones->loot; } + else + { + Creature* creature = GetPlayer()->GetMap()->GetCreature(lguid); - loot = &creature->loot; - } + bool lootAllowed = creature && creature->IsAlive() == (player->getClass() == CLASS_ROGUE && creature->loot.loot_type == LOOT_PICKPOCKETING); + if (!lootAllowed || !creature->IsWithinDistInMap(_player, INTERACTION_DISTANCE)) + { + player->SendLootError(lguid, lootAllowed ? LOOT_ERROR_TOO_FAR : LOOT_ERROR_DIDNT_KILL); + continue; + } - player->StoreLootItem(lootSlot, loot); + loot = &creature->loot; + } - // If player is removing the last LootItem, delete the empty container. - if (loot->isLooted() && lguid.IsItem()) - player->GetSession()->DoLootRelease(lguid); + // Since 6.x client sends loot starting from 1 hence the -1 + player->StoreLootItem(req.LootListID-1, loot); + + // If player is removing the last LootItem, delete the empty container. + if (loot->isLooted() && lguid.IsItem()) + player->GetSession()->DoLootRelease(lguid); + } } void WorldSession::HandleLootMoneyOpcode(WorldPacket& /*recvData*/) |
