diff options
| author | Subv <subv2112@gmail.com> | 2014-06-07 20:27:23 -0500 |
|---|---|---|
| committer | Subv <subv2112@gmail.com> | 2014-06-07 20:27:23 -0500 |
| commit | f71abd173ebad2da329c04f5ea3b1d8704007303 (patch) | |
| tree | 993fad51c1ab97b1b83adc4f1e0640033c7ae56f /src/server/game/Handlers/ItemHandler.cpp | |
| parent | bbe51bbd130908603c0a5c0c5d14eae2f0495ede (diff) | |
| parent | e1e5f2a196240707f1671a02df6bd4966fed67f3 (diff) | |
Merge branch '4.3.4' of github.com:TrinityCore/TrinityCore into 4.3.4_phases
Diffstat (limited to 'src/server/game/Handlers/ItemHandler.cpp')
| -rw-r--r-- | src/server/game/Handlers/ItemHandler.cpp | 82 |
1 files changed, 76 insertions, 6 deletions
diff --git a/src/server/game/Handlers/ItemHandler.cpp b/src/server/game/Handlers/ItemHandler.cpp index b72d79539aa..741dec9bfec 100644 --- a/src/server/game/Handlers/ItemHandler.cpp +++ b/src/server/game/Handlers/ItemHandler.cpp @@ -87,6 +87,18 @@ void WorldSession::HandleSwapInvItemOpcode(WorldPacket& recvData) return; } + if (_player->IsBankPos(INVENTORY_SLOT_BAG_0, srcslot) && !CanUseBank()) + { + TC_LOG_DEBUG("network", "WORLD: HandleSwapInvItemOpcode - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(m_currentBankerGUID))); + return; + } + + if (_player->IsBankPos(INVENTORY_SLOT_BAG_0, dstslot) && !CanUseBank()) + { + TC_LOG_DEBUG("network", "WORLD: HandleSwapInvItemOpcode - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(m_currentBankerGUID))); + return; + } + uint16 src = ((INVENTORY_SLOT_BAG_0 << 8) | srcslot); uint16 dst = ((INVENTORY_SLOT_BAG_0 << 8) | dstslot); @@ -139,6 +151,18 @@ void WorldSession::HandleSwapItem(WorldPacket& recvData) return; } + if (_player->IsBankPos(srcbag, srcslot) && !CanUseBank()) + { + TC_LOG_DEBUG("network", "WORLD: HandleSwapItem - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(m_currentBankerGUID))); + return; + } + + if (_player->IsBankPos(dstbag, dstslot) && !CanUseBank()) + { + TC_LOG_DEBUG("network", "WORLD: HandleSwapItem - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(m_currentBankerGUID))); + return; + } + _player->SwapItem(src, dst); } @@ -780,15 +804,11 @@ void WorldSession::HandleBuyBankSlotOpcode(WorldPacket& recvPacket) uint64 guid; recvPacket >> guid; - // cheating protection - /* not critical if "cheated", and check skip allow by slots in bank windows open by .bank command. - Creature* creature = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_BANKER); - if (!creature) + if (!CanUseBank(guid)) { - TC_LOG_DEBUG("WORLD: HandleBuyBankSlotOpcode - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(guid))); + TC_LOG_DEBUG("network", "WORLD: HandleBuyBankSlotOpcode - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(guid))); return; } - */ uint32 slot = _player->GetBankBagSlotCount(); @@ -834,6 +854,12 @@ void WorldSession::HandleAutoBankItemOpcode(WorldPacket& recvPacket) recvPacket >> srcbag >> srcslot; TC_LOG_DEBUG("network", "STORAGE: receive srcbag = %u, srcslot = %u", srcbag, srcslot); + if (!CanUseBank()) + { + TC_LOG_DEBUG("network", "WORLD: HandleAutoBankItemOpcode - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(m_currentBankerGUID))); + return; + } + Item* pItem = _player->GetItemByPos(srcbag, srcslot); if (!pItem) return; @@ -865,6 +891,12 @@ void WorldSession::HandleAutoStoreBankItemOpcode(WorldPacket& recvPacket) recvPacket >> srcbag >> srcslot; TC_LOG_DEBUG("network", "STORAGE: receive srcbag = %u, srcslot = %u", srcbag, srcslot); + if (!CanUseBank()) + { + TC_LOG_DEBUG("network", "WORLD: HandleAutoStoreBankItemOpcode - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(m_currentBankerGUID))); + return; + } + Item* pItem = _player->GetItemByPos(srcbag, srcslot); if (!pItem) return; @@ -1463,6 +1495,12 @@ void WorldSession::HandleTransmogrifyItems(WorldPacket& recvData) } else { + if (itemTransmogrifier->GetEntry() != newEntries[i]) + { + TC_LOG_DEBUG("network", "WORLD: HandleTransmogrifyItems - Player (GUID: %u, name: %s) tried to transmogrify with an invalid entry (entry: %u) for item (lowguid: %u).", player->GetGUIDLow(), player->GetName().c_str(), newEntries[i], GUID_LOPART(itemGuids[i])); + return; + } + if (!Item::CanTransmogrifyItemWithItem(itemTransmogrified, itemTransmogrifier)) { TC_LOG_DEBUG("network", "WORLD: HandleTransmogrifyItems - Player (GUID: %u, name: %s) failed CanTransmogrifyItemWithItem (%u with %u).", player->GetGUIDLow(), player->GetName().c_str(), itemTransmogrified->GetEntry(), itemTransmogrifier->GetEntry()); @@ -1549,6 +1587,13 @@ void WorldSession::HandleReforgeItemOpcode(WorldPacket& recvData) if (!reforgeEntry) { + if (!item->GetEnchantmentId(REFORGE_ENCHANTMENT_SLOT)) + { + TC_LOG_ERROR("network", "WORLD: HandleReforgeItemOpcode - Player (Guid: %u Name: %s) tried to remove reforge from non-reforged item (Entry: %u)", player->GetGUIDLow(), player->GetName().c_str(), item->GetEntry()); + SendReforgeResult(false); + return; + } + // Reset the item if (item->IsEquipped()) player->ApplyReforgeEnchantment(item, false); @@ -1557,6 +1602,13 @@ void WorldSession::HandleReforgeItemOpcode(WorldPacket& recvData) return; } + if (item->GetEnchantmentId(REFORGE_ENCHANTMENT_SLOT)) + { + TC_LOG_ERROR("network", "WORLD: HandleReforgeItemOpcode - Player (Guid: %u Name: %s) tried to reforge an already reforged item (Entry: %u)", player->GetGUIDLow(), player->GetName().c_str(), item->GetEntry()); + SendReforgeResult(false); + return; + } + ItemReforgeEntry const* stats = sItemReforgeStore.LookupEntry(reforgeEntry); if (!stats) { @@ -1586,3 +1638,21 @@ void WorldSession::HandleReforgeItemOpcode(WorldPacket& recvData) if (item->IsEquipped()) player->ApplyReforgeEnchantment(item, true); } + +bool WorldSession::CanUseBank(uint64 bankerGUID) const +{ + // bankerGUID parameter is optional, set to 0 by default. + if (!bankerGUID) + bankerGUID = m_currentBankerGUID; + + bool isUsingBankCommand = (bankerGUID == GetPlayer()->GetGUID() && bankerGUID == m_currentBankerGUID); + + if (!isUsingBankCommand) + { + Creature* creature = GetPlayer()->GetNPCIfCanInteractWith(bankerGUID, UNIT_NPC_FLAG_BANKER); + if (!creature) + return false; + } + + return true; +} |
