aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Handlers
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2025-08-13 00:31:39 +0200
committerShauren <shauren.trinity@gmail.com>2025-08-13 00:31:39 +0200
commit5cf0c6c8bb2c4e58a2d66ba5f304af34d18a4782 (patch)
tree0616f3e83f511aae0e10916f0c22161017e09c24 /src/server/game/Handlers
parent82f19c898815e3bc5bb6288b0191ee897594f9b5 (diff)
Core: Updated to 11.2.0
Diffstat (limited to 'src/server/game/Handlers')
-rw-r--r--src/server/game/Handlers/BankHandler.cpp210
-rw-r--r--src/server/game/Handlers/CharacterHandler.cpp9
-rw-r--r--src/server/game/Handlers/ItemHandler.cpp18
-rw-r--r--src/server/game/Handlers/TradeHandler.cpp16
-rw-r--r--src/server/game/Handlers/VoidStorageHandler.cpp236
5 files changed, 115 insertions, 374 deletions
diff --git a/src/server/game/Handlers/BankHandler.cpp b/src/server/game/Handlers/BankHandler.cpp
index 91a65dfb58b..db3a34e0403 100644
--- a/src/server/game/Handlers/BankHandler.cpp
+++ b/src/server/game/Handlers/BankHandler.cpp
@@ -31,7 +31,7 @@ void WorldSession::HandleAutoBankItemOpcode(WorldPackets::Bank::AutoBankItem& pa
if (!CanUseBank())
{
- TC_LOG_ERROR("network", "WORLD: HandleAutoBankItemOpcode - Unit ({}) not found or you can't interact with him.", _player->PlayerTalkClass->GetInteractionData().SourceGuid.ToString());
+ TC_LOG_ERROR("network", "WORLD: HandleAutoBankItemOpcode - Unit ({}) not found or you can't interact with him.", _player->PlayerTalkClass->GetInteractionData().SourceGuid);
return;
}
@@ -106,7 +106,7 @@ void WorldSession::HandleAutoStoreBankItemOpcode(WorldPackets::Bank::AutoStoreBa
if (!CanUseBank())
{
- TC_LOG_ERROR("network", "WORLD: HandleAutoStoreBankItemOpcode - Unit ({}) not found or you can't interact with him.", _player->PlayerTalkClass->GetInteractionData().SourceGuid.ToString());
+ TC_LOG_ERROR("network", "WORLD: HandleAutoStoreBankItemOpcode - Unit ({}) not found or you can't interact with him.", _player->PlayerTalkClass->GetInteractionData().SourceGuid);
return;
}
@@ -144,67 +144,129 @@ void WorldSession::HandleAutoStoreBankItemOpcode(WorldPackets::Bank::AutoStoreBa
}
}
-void WorldSession::HandleBuyBankSlotOpcode(WorldPackets::Bank::BuyBankSlot& packet)
+void WorldSession::HandleBuyBankTab(WorldPackets::Bank::BuyBankTab const& buyBankTab)
{
- if (!CanUseBank(packet.Guid))
+ if (!CanUseBank(buyBankTab.Banker))
{
- TC_LOG_ERROR("network", "WORLD: HandleBuyBankSlotOpcode - {} not found or you can't interact with him.", packet.Guid.ToString());
+ TC_LOG_ERROR("network", "WorldSession::HandleBuyBankTab {} - Banker {} not found or can't interact with him.",
+ _player->GetGUID(), buyBankTab.Banker);
return;
}
- uint32 slot = _player->GetBankBagSlotCount();
+ if (buyBankTab.BankType != BankType::Character)
+ {
+ TC_LOG_DEBUG("network", "WorldSession::HandleBuyBankTab {} - Bank type {} is not supported.",
+ _player->GetGUID(), buyBankTab.BankType);
+ return;
+ }
+
+ uint32 itemId = 0;
+ uint8 slot = 0;
+ uint8 inventorySlot = 0;
+
+ switch (buyBankTab.BankType)
+ {
+ case BankType::Character:
+ itemId = ITEM_CHARACTER_BANK_TAB_BAG;
+ slot = _player->GetCharacterBankTabCount();
+ inventorySlot = BANK_SLOT_BAG_START;
+ break;
+ case BankType::Account:
+ itemId = ITEM_ACCOUNT_BANK_TAB_BAG;
+ slot = _player->GetAccountBankTabCount();
+ inventorySlot = ACCOUNT_BANK_SLOT_BAG_START;
+ break;
+ default:
+ TC_LOG_DEBUG("network", "WorldSession::HandleBuyBankTab {} - Bank type {} is not supported.",
+ _player->GetGUID(), buyBankTab.BankType);
+ return;
+ }
// next slot
++slot;
- TC_LOG_INFO("network", "PLAYER: Buy bank bag slot, slot number = {}", slot);
+ auto bankTab = std::ranges::find(sBankTabStore, std::pair(buyBankTab.BankType, int8(slot)),
+ [](BankTabEntry const* bankTab) { return std::pair(BankType(bankTab->BankType), bankTab->OrderIndex); });
- BankBagSlotPricesEntry const* slotEntry = sBankBagSlotPricesStore.LookupEntry(slot);
- if (!slotEntry)
+ if (bankTab == sBankTabStore.end())
return;
- uint32 price = slotEntry->Cost;
-
- if (!_player->HasEnoughMoney(uint64(price)))
+ uint64 price = bankTab->Cost;
+ if (!_player->HasEnoughMoney(price))
return;
- _player->SetBankBagSlotCount(slot);
- _player->ModifyMoney(-int64(price));
-
- _player->UpdateCriteria(CriteriaType::BankSlotsPurchased);
-}
-
-void WorldSession::HandleBuyReagentBankOpcode(WorldPackets::Bank::ReagentBank& reagentBank)
-{
- if (!CanUseBank(reagentBank.Banker))
+ uint16 inventoryPos = 0;
+ InventoryResult msg = _player->CanEquipNewItem(inventorySlot, inventoryPos, itemId, false);
+ if (msg != EQUIP_ERR_OK)
{
- TC_LOG_DEBUG("network", "WORLD: HandleBuyReagentBankOpcode - {} not found or you can't interact with him.", reagentBank.Banker.ToString());
+ _player->SendEquipError(msg, nullptr, nullptr, itemId);
return;
}
- if (_player->IsReagentBankUnlocked())
- {
- TC_LOG_DEBUG("network", "WORLD: HandleBuyReagentBankOpcode - Player ({}, name: {}) tried to unlock reagent bank a 2nd time.", _player->GetGUID().ToString(), _player->GetName());
+ Item* bag = _player->EquipNewItem(inventoryPos, itemId, ItemContext::NONE, true);
+ if (!bag)
return;
+
+ switch (buyBankTab.BankType)
+ {
+ case BankType::Character:
+ _player->SetCharacterBankTabCount(slot);
+ break;
+ case BankType::Account:
+ _player->SetAccountBankTabCount(slot);
+ break;
+ default:
+ break;
}
- constexpr int64 price = 100 * GOLD;
+ _player->ModifyMoney(-int64(price));
- if (!_player->HasEnoughMoney(price))
+ _player->UpdateCriteria(CriteriaType::BankTabPurchased, uint64(buyBankTab.BankType));
+}
+
+void WorldSession::HandleUpdateBankTabSettings(WorldPackets::Bank::UpdateBankTabSettings const& updateBankTabSettings)
+{
+ if (!CanUseBank(updateBankTabSettings.Banker))
{
- TC_LOG_DEBUG("network", "WORLD: HandleBuyReagentBankOpcode - Player ({}, name: {}) without enough gold.", _player->GetGUID().ToString(), _player->GetName());
+ TC_LOG_ERROR("network", "WorldSession::HandleUpdateBankTabSettings {} - Banker {} not found or can't interact with him.",
+ _player->GetGUID(), updateBankTabSettings.Banker);
return;
}
- _player->ModifyMoney(-price);
- _player->UnlockReagentBank();
+ switch (updateBankTabSettings.BankType)
+ {
+ case BankType::Character:
+ if (updateBankTabSettings.Tab >= _player->m_activePlayerData->CharacterBankTabSettings.size())
+ {
+ TC_LOG_DEBUG("network", "WorldSession::HandleUpdateBankTabSettings {} doesn't have bank tab {} in bank type {}.",
+ _player->GetGUID(), updateBankTabSettings.Tab, updateBankTabSettings.BankType);
+ return;
+ }
+ _player->SetCharacterBankTabSettings(updateBankTabSettings.Tab, updateBankTabSettings.Settings.Name,
+ updateBankTabSettings.Settings.Icon, updateBankTabSettings.Settings.Description, updateBankTabSettings.Settings.DepositFlags);
+ break;
+ case BankType::Account:
+ if (updateBankTabSettings.Tab >= _player->m_activePlayerData->AccountBankTabSettings.size())
+ {
+ TC_LOG_DEBUG("network", "WorldSession::HandleUpdateBankTabSettings {} doesn't have bank tab {} in bank type {}.",
+ _player->GetGUID(), updateBankTabSettings.Tab, updateBankTabSettings.BankType);
+ return;
+ }
+ _player->SetAccountBankTabSettings(updateBankTabSettings.Tab, updateBankTabSettings.Settings.Name,
+ updateBankTabSettings.Settings.Icon, updateBankTabSettings.Settings.Description, updateBankTabSettings.Settings.DepositFlags);
+ break;
+ default:
+ TC_LOG_DEBUG("network", "WorldSession::HandleUpdateBankTabSettings {} - Bank type {} is not supported.",
+ _player->GetGUID(), updateBankTabSettings.BankType);
+ break;
+ }
}
-void WorldSession::HandleReagentBankDepositOpcode(WorldPackets::Bank::ReagentBank& reagentBank)
+void WorldSession::HandleAutoDepositCharacterBank(WorldPackets::Bank::AutoDepositCharacterBank const& autoDepositCharacterBank)
{
- if (!CanUseBank(reagentBank.Banker))
+ if (!CanUseBank(autoDepositCharacterBank.Banker))
{
- TC_LOG_DEBUG("network", "WORLD: HandleReagentBankDepositOpcode - {} not found or you can't interact with him.", reagentBank.Banker.ToString());
+ TC_LOG_DEBUG("network", "WORLD: HandleReagentBankDepositOpcode - {} not found or you can't interact with him.", autoDepositCharacterBank.Banker);
return;
}
@@ -240,88 +302,6 @@ void WorldSession::HandleReagentBankDepositOpcode(WorldPackets::Bank::ReagentBan
}
}
-void WorldSession::HandleAutoBankReagentOpcode(WorldPackets::Bank::AutoBankReagent& autoBankReagent)
-{
- if (!CanUseBank())
- {
- TC_LOG_DEBUG("network", "WORLD: HandleAutoBankReagentOpcode - {} not found or you can't interact with him.", _player->PlayerTalkClass->GetInteractionData().SourceGuid.ToString());
- return;
- }
-
- if (!_player->IsReagentBankUnlocked())
- {
- _player->SendEquipError(EQUIP_ERR_REAGENT_BANK_LOCKED);
- return;
- }
-
- Item* item = _player->GetItemByPos(autoBankReagent.PackSlot, autoBankReagent.Slot);
- if (!item)
- return;
-
- ItemPosCountVec dest;
- InventoryResult msg = _player->CanBankItem(NULL_BAG, NULL_SLOT, dest, item, false, true, true);
- if (msg != EQUIP_ERR_OK)
- {
- _player->SendEquipError(msg, item, nullptr);
- return;
- }
-
- if (dest.size() == 1 && dest[0].pos == item->GetPos())
- {
- _player->SendEquipError(EQUIP_ERR_CANT_SWAP, item, nullptr);
- return;
- }
-
- _player->RemoveItem(autoBankReagent.PackSlot, autoBankReagent.Slot, true);
- _player->BankItem(dest, item, true);
-}
-
-void WorldSession::HandleAutoStoreBankReagentOpcode(WorldPackets::Bank::AutoStoreBankReagent& autoStoreBankReagent)
-{
- if (!CanUseBank())
- {
- TC_LOG_DEBUG("network", "WORLD: HandleAutoBankReagentOpcode - {} not found or you can't interact with him.", _player->PlayerTalkClass->GetInteractionData().SourceGuid.ToString());
- return;
- }
-
- if (!_player->IsReagentBankUnlocked())
- {
- _player->SendEquipError(EQUIP_ERR_REAGENT_BANK_LOCKED);
- return;
- }
-
- Item* pItem = _player->GetItemByPos(autoStoreBankReagent.Slot, autoStoreBankReagent.PackSlot);
- if (!pItem)
- return;
-
- if (_player->IsReagentBankPos(autoStoreBankReagent.Slot, autoStoreBankReagent.PackSlot))
- {
- ItemPosCountVec dest;
- InventoryResult msg = _player->CanStoreItem(NULL_BAG, NULL_SLOT, dest, pItem, false);
- if (msg != EQUIP_ERR_OK)
- {
- _player->SendEquipError(msg, pItem, nullptr);
- return;
- }
-
- _player->RemoveItem(autoStoreBankReagent.Slot, autoStoreBankReagent.PackSlot, true);
- _player->StoreItem(dest, pItem, true);
- }
- else
- {
- ItemPosCountVec dest;
- InventoryResult msg = _player->CanBankItem(NULL_BAG, NULL_SLOT, dest, pItem, false, true, true);
- if (msg != EQUIP_ERR_OK)
- {
- _player->SendEquipError(msg, pItem, nullptr);
- return;
- }
-
- _player->RemoveItem(autoStoreBankReagent.Slot, autoStoreBankReagent.PackSlot, true);
- _player->BankItem(dest, pItem, true);
- }
-}
-
void WorldSession::SendShowBank(ObjectGuid guid, PlayerInteractionType interactionType)
{
_player->PlayerTalkClass->GetInteractionData().StartInteraction(guid, interactionType);
diff --git a/src/server/game/Handlers/CharacterHandler.cpp b/src/server/game/Handlers/CharacterHandler.cpp
index 116390128d2..f0f60870bf1 100644
--- a/src/server/game/Handlers/CharacterHandler.cpp
+++ b/src/server/game/Handlers/CharacterHandler.cpp
@@ -182,10 +182,6 @@ bool LoginQueryHolder::Initialize()
stmt->setUInt64(0, lowGuid);
res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOAD_AZERITE_EMPOWERED, stmt);
- stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_VOID_STORAGE);
- stmt->setUInt64(0, lowGuid);
- res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOAD_VOID_STORAGE, stmt);
-
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_MAIL);
stmt->setUInt64(0, lowGuid);
res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOAD_MAILS, stmt);
@@ -353,6 +349,10 @@ bool LoginQueryHolder::Initialize()
stmt->setUInt64(0, lowGuid);
res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOAD_DATA_FLAGS, stmt);
+ stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARACTER_BANK_TAB_SETTINGS);
+ stmt->setUInt64(0, lowGuid);
+ res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOAD_BANK_TAB_SETTINGS, stmt);
+
return res;
}
@@ -1504,7 +1504,6 @@ void WorldSession::SendFeatureSystemStatus()
features.CfgRealmRecID = 0;
features.CommercePricePollTimeSeconds = 300;
features.VoiceEnabled = false;
- features.BrowserEnabled = false; // Has to be false, otherwise client will crash if "Customer Support" is opened
// Enable guilds only.
// This is required to restore old guild channel behavior for GMs.
diff --git a/src/server/game/Handlers/ItemHandler.cpp b/src/server/game/Handlers/ItemHandler.cpp
index e63ed58e7e4..a8602605c7d 100644
--- a/src/server/game/Handlers/ItemHandler.cpp
+++ b/src/server/game/Handlers/ItemHandler.cpp
@@ -1251,13 +1251,6 @@ void WorldSession::HandleSortBankBags(WorldPackets::Item::SortBankBags& /*sortBa
SendPacket(WorldPackets::Item::BagCleanupFinished().Write());
}
-void WorldSession::HandleSortReagentBankBags(WorldPackets::Item::SortReagentBankBags& /*sortReagentBankBags*/)
-{
- // TODO: Implement sorting
- // Placeholder to prevent completely locking out bags clientside
- SendPacket(WorldPackets::Item::BagCleanupFinished().Write());
-}
-
void WorldSession::HandleRemoveNewItem(WorldPackets::Item::RemoveNewItem& removeNewItem)
{
Item* item = _player->GetItemByGuid(removeNewItem.ItemGuid);
@@ -1285,17 +1278,6 @@ void WorldSession::HandleChangeBagSlotFlag(WorldPackets::Item::ChangeBagSlotFlag
_player->RemoveBagSlotFlag(changeBagSlotFlag.BagIndex, changeBagSlotFlag.FlagToChange);
}
-void WorldSession::HandleChangeBankBagSlotFlag(WorldPackets::Item::ChangeBankBagSlotFlag const& changeBankBagSlotFlag)
-{
- if (changeBankBagSlotFlag.BagIndex >= _player->m_activePlayerData->BankBagSlotFlags.size())
- return;
-
- if (changeBankBagSlotFlag.On)
- _player->SetBankBagSlotFlag(changeBankBagSlotFlag.BagIndex, changeBankBagSlotFlag.FlagToChange);
- else
- _player->RemoveBankBagSlotFlag(changeBankBagSlotFlag.BagIndex, changeBankBagSlotFlag.FlagToChange);
-}
-
void WorldSession::HandleSetBackpackAutosortDisabled(WorldPackets::Item::SetBackpackAutosortDisabled const& setBackpackAutosortDisabled)
{
_player->SetBackpackAutoSortDisabled(setBackpackAutosortDisabled.Disable);
diff --git a/src/server/game/Handlers/TradeHandler.cpp b/src/server/game/Handlers/TradeHandler.cpp
index 4012ccff590..37fda27000e 100644
--- a/src/server/game/Handlers/TradeHandler.cpp
+++ b/src/server/game/Handlers/TradeHandler.cpp
@@ -322,6 +322,14 @@ void WorldSession::HandleAcceptTradeOpcode(WorldPackets::Trade::AcceptTrade& acc
SendTradeStatus(info);
return;
}
+
+ if (Player::IsAccountBankPos(item->GetSlot(), item->GetBagSlot()))
+ {
+ info.Status = TRADE_STATUS_FAILED;
+ info.BagResult = EQUIP_ERR_CANT_TRADE_ACCOUNT_ITEM;
+ SendTradeStatus(info);
+ return;
+ }
}
if (Item* item = his_trade->GetItem(TradeSlots(i)))
@@ -338,6 +346,14 @@ void WorldSession::HandleAcceptTradeOpcode(WorldPackets::Trade::AcceptTrade& acc
// his_trade->SetAccepted(false, true);
// return;
//}
+
+ if (Player::IsAccountBankPos(item->GetSlot(), item->GetBagSlot()))
+ {
+ info.Status = TRADE_STATUS_FAILED;
+ info.BagResult = EQUIP_ERR_CANT_TRADE_ACCOUNT_ITEM;
+ SendTradeStatus(info);
+ return;
+ }
}
}
diff --git a/src/server/game/Handlers/VoidStorageHandler.cpp b/src/server/game/Handlers/VoidStorageHandler.cpp
deleted file mode 100644
index 2ab4ee8fb8f..00000000000
--- a/src/server/game/Handlers/VoidStorageHandler.cpp
+++ /dev/null
@@ -1,236 +0,0 @@
-/*
- * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "WorldSession.h"
-#include "Bag.h"
-#include "CollectionMgr.h"
-#include "Common.h"
-#include "Log.h"
-#include "ObjectAccessor.h"
-#include "ObjectMgr.h"
-#include "Player.h"
-#include "VoidStoragePackets.h"
-
-void WorldSession::SendVoidStorageTransferResult(VoidTransferError result)
-{
- SendPacket(WorldPackets::VoidStorage::VoidTransferResult(result).Write());
-}
-
-void WorldSession::HandleVoidStorageUnlock(WorldPackets::VoidStorage::UnlockVoidStorage& unlockVoidStorage)
-{
- Creature* unit = _player->GetNPCIfCanInteractWith(unlockVoidStorage.Npc, UNIT_NPC_FLAG_VAULTKEEPER, UNIT_NPC_FLAG_2_NONE);
- if (!unit)
- {
- TC_LOG_DEBUG("network", "WORLD: HandleVoidStorageUnlock - {} not found or player can't interact with it.", unlockVoidStorage.Npc.ToString());
- return;
- }
-
- if (_player->IsVoidStorageUnlocked())
- {
- TC_LOG_DEBUG("network", "WORLD: HandleVoidStorageUnlock - Player ({}, name: {}) tried to unlock void storage a 2nd time.", _player->GetGUID().ToString(), _player->GetName());
- return;
- }
-
- _player->ModifyMoney(-int64(VOID_STORAGE_UNLOCK_COST));
- _player->UnlockVoidStorage();
-}
-
-void WorldSession::HandleVoidStorageQuery(WorldPackets::VoidStorage::QueryVoidStorage& queryVoidStorage)
-{
- Creature* unit = _player->GetNPCIfCanInteractWith(queryVoidStorage.Npc, UNIT_NPC_FLAG_TRANSMOGRIFIER | UNIT_NPC_FLAG_VAULTKEEPER, UNIT_NPC_FLAG_2_NONE);
- if (!unit)
- {
- TC_LOG_DEBUG("network", "WORLD: HandleVoidStorageQuery - {} not found or player can't interact with it.", queryVoidStorage.Npc.ToString());
- SendPacket(WorldPackets::VoidStorage::VoidStorageFailed().Write());
- return;
- }
-
- if (!_player->IsVoidStorageUnlocked())
- {
- TC_LOG_DEBUG("network", "WORLD: HandleVoidStorageQuery - Player ({}, name: {}) queried void storage without unlocking it.", _player->GetGUID().ToString(), _player->GetName());
- SendPacket(WorldPackets::VoidStorage::VoidStorageFailed().Write());
- return;
- }
-
- WorldPackets::VoidStorage::VoidStorageContents voidStorageContents;
- voidStorageContents.Items.reserve(VOID_STORAGE_MAX_SLOT);
-
- for (uint8 i = 0; i < VOID_STORAGE_MAX_SLOT; ++i)
- {
- VoidStorageItem* item = _player->GetVoidStorageItem(i);
- if (!item)
- continue;
-
- WorldPackets::VoidStorage::VoidItem voidItem;
- voidItem.Guid = ObjectGuid::Create<HighGuid::Item>(item->ItemId);
- voidItem.Creator = item->CreatorGuid;
- voidItem.Slot = i;
- voidItem.Item.Initialize(item);
-
- voidStorageContents.Items.push_back(voidItem);
- }
-
- SendPacket(voidStorageContents.Write());
-}
-
-void WorldSession::HandleVoidStorageTransfer(WorldPackets::VoidStorage::VoidStorageTransfer& voidStorageTransfer)
-{
- Creature* unit = _player->GetNPCIfCanInteractWith(voidStorageTransfer.Npc, UNIT_NPC_FLAG_VAULTKEEPER, UNIT_NPC_FLAG_2_NONE);
- if (!unit)
- {
- TC_LOG_DEBUG("network", "WORLD: HandleVoidStorageTransfer - {} not found or player can't interact with it.", voidStorageTransfer.Npc.ToString());
- return;
- }
-
- if (!_player->IsVoidStorageUnlocked())
- {
- TC_LOG_DEBUG("network", "WORLD: HandleVoidStorageTransfer - Player ({}, name: {}) queried void storage without unlocking it.", _player->GetGUID().ToString(), _player->GetName());
- return;
- }
-
- if (voidStorageTransfer.Deposits.size() > _player->GetNumOfVoidStorageFreeSlots())
- {
- SendVoidStorageTransferResult(VOID_TRANSFER_ERROR_FULL);
- return;
- }
-
- if (!voidStorageTransfer.Withdrawals.empty() && voidStorageTransfer.Withdrawals.size() > _player->GetFreeInventorySlotCount(ItemSearchLocation::Inventory))
- {
- SendVoidStorageTransferResult(VOID_TRANSFER_ERROR_INVENTORY_FULL);
- return;
- }
-
- if (!_player->HasEnoughMoney(uint64(voidStorageTransfer.Deposits.size() * VOID_STORAGE_STORE_ITEM_COST)))
- {
- SendVoidStorageTransferResult(VOID_TRANSFER_ERROR_NOT_ENOUGH_MONEY);
- return;
- }
-
- WorldPackets::VoidStorage::VoidStorageTransferChanges voidStorageTransferChanges;
- voidStorageTransferChanges.AddedItems.reserve(VOID_STORAGE_MAX_DEPOSIT);
- voidStorageTransferChanges.RemovedItems.reserve(VOID_STORAGE_MAX_DEPOSIT);
-
- uint8 depositCount = 0;
- for (uint32 i = 0; i < voidStorageTransfer.Deposits.size(); ++i)
- {
- Item* item = _player->GetItemByGuid(voidStorageTransfer.Deposits[i]);
- if (!item)
- {
- TC_LOG_DEBUG("network", "WORLD: HandleVoidStorageTransfer - {} {} wants to deposit an invalid item ({}).", _player->GetGUID().ToString(), _player->GetName(), voidStorageTransfer.Deposits[i].ToString());
- continue;
- }
-
- VoidStorageItem itemVS(sObjectMgr->GenerateVoidStorageItemId(), item->GetEntry(), item->GetCreator(),
- item->GetItemRandomBonusListId(), item->GetModifier(ITEM_MODIFIER_TIMEWALKER_LEVEL), item->GetModifier(ITEM_MODIFIER_ARTIFACT_KNOWLEDGE_LEVEL),
- item->GetContext(), item->GetBonusListIDs());
-
- WorldPackets::VoidStorage::VoidItem voidItem;
- voidItem.Guid = ObjectGuid::Create<HighGuid::Item>(itemVS.ItemId);
- voidItem.Creator = item->GetCreator();
- voidItem.Item.Initialize(&itemVS);
- voidItem.Slot = _player->AddVoidStorageItem(std::move(itemVS));
-
- voidStorageTransferChanges.AddedItems.push_back(voidItem);
-
- _player->DestroyItem(item->GetBagSlot(), item->GetSlot(), true);
- ++depositCount;
- }
-
- int64 cost = depositCount * VOID_STORAGE_STORE_ITEM_COST;
-
- _player->ModifyMoney(-cost);
-
- for (uint32 i = 0; i < voidStorageTransfer.Withdrawals.size(); ++i)
- {
- uint8 slot = 0;
- VoidStorageItem* itemVS = _player->GetVoidStorageItem(voidStorageTransfer.Withdrawals[i].GetCounter(), slot);
- if (!itemVS)
- {
- TC_LOG_DEBUG("network", "WORLD: HandleVoidStorageTransfer - {} {} tried to withdraw an invalid item (id: {})", _player->GetGUID().ToString(), _player->GetName(), voidStorageTransfer.Withdrawals[i].ToString());
- continue;
- }
-
- ItemPosCountVec dest;
- InventoryResult msg = _player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, itemVS->ItemEntry, 1);
- if (msg != EQUIP_ERR_OK)
- {
- SendVoidStorageTransferResult(VOID_TRANSFER_ERROR_INVENTORY_FULL);
- TC_LOG_DEBUG("network", "WORLD: HandleVoidStorageTransfer - {} {} couldn't withdraw item id {} because inventory was full.", _player->GetGUID().ToString(), _player->GetName(), voidStorageTransfer.Withdrawals[i].ToString());
- return;
- }
-
- if (Item* item = _player->StoreNewItem(dest, itemVS->ItemEntry, true, itemVS->RandomBonusListId, GuidSet(), itemVS->Context, &itemVS->BonusListIDs))
- {
- item->SetCreator(itemVS->CreatorGuid);
- item->SetBinding(true);
- GetCollectionMgr()->AddItemAppearance(item);
- }
-
- voidStorageTransferChanges.RemovedItems.push_back(ObjectGuid::Create<HighGuid::Item>(itemVS->ItemId));
-
- _player->DeleteVoidStorageItem(slot);
- }
-
- SendPacket(voidStorageTransferChanges.Write());
-
- SendVoidStorageTransferResult(VOID_TRANSFER_ERROR_NO_ERROR);
-}
-
-void WorldSession::HandleVoidSwapItem(WorldPackets::VoidStorage::SwapVoidItem& swapVoidItem)
-{
- Creature* unit = _player->GetNPCIfCanInteractWith(swapVoidItem.Npc, UNIT_NPC_FLAG_VAULTKEEPER, UNIT_NPC_FLAG_2_NONE);
- if (!unit)
- {
- TC_LOG_DEBUG("network", "WORLD: HandleVoidSwapItem - {} not found or player can't interact with it.", swapVoidItem.Npc.ToString());
- return;
- }
-
- if (!_player->IsVoidStorageUnlocked())
- {
- TC_LOG_DEBUG("network", "WORLD: HandleVoidSwapItem - Player ({}, name: {}) queried void storage without unlocking it.", _player->GetGUID().ToString(), _player->GetName());
- return;
- }
-
- uint8 oldSlot;
- if (!_player->GetVoidStorageItem(swapVoidItem.VoidItemGuid.GetCounter(), oldSlot))
- {
- TC_LOG_DEBUG("network", "WORLD: HandleVoidSwapItem - {} {} requested swapping an invalid item (slot: {}, itemid: {}).", _player->GetGUID().ToString(), _player->GetName(), swapVoidItem.DstSlot, swapVoidItem.VoidItemGuid.ToString());
- return;
- }
-
- bool usedDestSlot = _player->GetVoidStorageItem(swapVoidItem.DstSlot) != nullptr;
- ObjectGuid itemIdDest;
- if (usedDestSlot)
- itemIdDest = ObjectGuid::Create<HighGuid::Item>(_player->GetVoidStorageItem(swapVoidItem.DstSlot)->ItemId);
-
- if (!_player->SwapVoidStorageItem(oldSlot, swapVoidItem.DstSlot))
- {
- SendVoidStorageTransferResult(VOID_TRANSFER_ERROR_INTERNAL_ERROR_1);
- return;
- }
-
- WorldPackets::VoidStorage::VoidItemSwapResponse voidItemSwapResponse;
- voidItemSwapResponse.VoidItemA = swapVoidItem.VoidItemGuid;
- voidItemSwapResponse.VoidItemSlotA = swapVoidItem.DstSlot;
- if (usedDestSlot)
- {
- voidItemSwapResponse.VoidItemB = itemIdDest;
- voidItemSwapResponse.VoidItemSlotB = oldSlot;
- }
-
- SendPacket(voidItemSwapResponse.Write());
-}