aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2015-04-13 20:35:57 +0200
committerShauren <shauren.trinity@gmail.com>2015-04-13 20:35:57 +0200
commitf20c6530b8ef496259c8e6a6401b11c50efd5940 (patch)
treee938aa851202da4855f33c81d70c6100d570140d
parent78f23891a2465dc2491e8c7710a20eb1ed4fa5c0 (diff)
Core/PacketIO: Updated and enabled void storage packets
-rw-r--r--src/server/game/AuctionHouse/AuctionHouseMgr.cpp2
-rw-r--r--src/server/game/Entities/Player/Player.cpp2
-rw-r--r--src/server/game/Handlers/TradeHandler.cpp2
-rw-r--r--src/server/game/Handlers/VoidStorageHandler.cpp522
-rw-r--r--src/server/game/Loot/LootMgr.cpp12
-rw-r--r--src/server/game/Server/Packets/AuctionHousePackets.cpp4
-rw-r--r--src/server/game/Server/Packets/InspectPackets.cpp2
-rw-r--r--src/server/game/Server/Packets/ItemPackets.cpp12
-rw-r--r--src/server/game/Server/Packets/ItemPackets.h7
-rw-r--r--src/server/game/Server/Packets/MailPackets.cpp2
-rw-r--r--src/server/game/Server/Packets/VoidStoragePackets.cpp110
-rw-r--r--src/server/game/Server/Packets/VoidStoragePackets.h138
-rw-r--r--src/server/game/Server/Protocol/Opcodes.cpp21
-rw-r--r--src/server/game/Server/WorldSession.h16
14 files changed, 389 insertions, 463 deletions
diff --git a/src/server/game/AuctionHouse/AuctionHouseMgr.cpp b/src/server/game/AuctionHouse/AuctionHouseMgr.cpp
index 5065bd23ffb..06fa47cd09d 100644
--- a/src/server/game/AuctionHouse/AuctionHouseMgr.cpp
+++ b/src/server/game/AuctionHouse/AuctionHouseMgr.cpp
@@ -628,7 +628,7 @@ void AuctionEntry::BuildAuctionInfo(std::vector<WorldPackets::AuctionHouse::Auct
WorldPackets::AuctionHouse::AuctionItem auctionItem;
auctionItem.AuctionItemID = Id;
- auctionItem.Item.Initalize(item);
+ auctionItem.Item.Initialize(item);
auctionItem.BuyoutPrice = buyout;
auctionItem.CensorBidInfo = false;
auctionItem.CensorServerSideInfo = listAuctionItems;
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index 5560c78c4ab..2ef3380a5eb 100644
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -13618,7 +13618,7 @@ void Player::SendNewItem(Item* item, uint32 quantity, bool pushed, bool created,
packet.Slot = item->GetBagSlot();
packet.SlotInBag = item->GetCount() == quantity ? item->GetSlot() : -1;
- packet.Item.Initalize(item);
+ packet.Item.Initialize(item);
//packet.ReadUInt32("WodUnk");
packet.Quantity = quantity;
diff --git a/src/server/game/Handlers/TradeHandler.cpp b/src/server/game/Handlers/TradeHandler.cpp
index 517d02f852a..c5258e63e40 100644
--- a/src/server/game/Handlers/TradeHandler.cpp
+++ b/src/server/game/Handlers/TradeHandler.cpp
@@ -70,7 +70,7 @@ void WorldSession::SendUpdateTrade(bool trader_data /*= true*/)
if (!item->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_WRAPPED))
{
WorldPackets::Trade::TradeUpdated::UnwrappedTradeItem* unwrappedItem = &tradeItem.Unwrapped.Value;
- unwrappedItem->Item.Initalize(item);
+ unwrappedItem->Item.Initialize(item);
unwrappedItem->EnchantID = item->GetEnchantmentId(PERM_ENCHANTMENT_SLOT);
unwrappedItem->OnUseEnchantmentID = item->GetEnchantmentId(USE_ENCHANTMENT_SLOT);
unwrappedItem->Creator = item->GetGuidValue(ITEM_FIELD_CREATOR);
diff --git a/src/server/game/Handlers/VoidStorageHandler.cpp b/src/server/game/Handlers/VoidStorageHandler.cpp
index 1e4ba33c910..dcca2f81711 100644
--- a/src/server/game/Handlers/VoidStorageHandler.cpp
+++ b/src/server/game/Handlers/VoidStorageHandler.cpp
@@ -24,301 +24,128 @@
#include "Log.h"
#include "Opcodes.h"
#include "Player.h"
-#include <list>
-#include <vector>
-#include <utility>
+#include "VoidStoragePackets.h"
void WorldSession::SendVoidStorageTransferResult(VoidTransferError result)
{
- WorldPacket data(SMSG_VOID_TRANSFER_RESULT, 4);
- data << uint32(result);
- SendPacket(&data);
+ SendPacket(WorldPackets::VoidStorage::VoidTransferResult(result).Write());
}
-void WorldSession::HandleVoidStorageUnlock(WorldPacket& recvData)
+void WorldSession::HandleVoidStorageUnlock(WorldPackets::VoidStorage::UnlockVoidStorage& unlockVoidStorage)
{
- TC_LOG_DEBUG("network", "WORLD: Received CMSG_VOID_STORAGE_UNLOCK");
- Player* player = GetPlayer();
-
- ObjectGuid npcGuid;
- npcGuid[4] = recvData.ReadBit();
- npcGuid[5] = recvData.ReadBit();
- npcGuid[3] = recvData.ReadBit();
- npcGuid[0] = recvData.ReadBit();
- npcGuid[2] = recvData.ReadBit();
- npcGuid[1] = recvData.ReadBit();
- npcGuid[7] = recvData.ReadBit();
- npcGuid[6] = recvData.ReadBit();
-
- recvData.ReadByteSeq(npcGuid[7]);
- recvData.ReadByteSeq(npcGuid[1]);
- recvData.ReadByteSeq(npcGuid[2]);
- recvData.ReadByteSeq(npcGuid[3]);
- recvData.ReadByteSeq(npcGuid[5]);
- recvData.ReadByteSeq(npcGuid[0]);
- recvData.ReadByteSeq(npcGuid[6]);
- recvData.ReadByteSeq(npcGuid[4]);
-
- Creature* unit = player->GetNPCIfCanInteractWith(npcGuid, UNIT_NPC_FLAG_VAULTKEEPER);
+ Creature* unit = _player->GetNPCIfCanInteractWith(unlockVoidStorage.Npc, UNIT_NPC_FLAG_VAULTKEEPER);
if (!unit)
{
- TC_LOG_DEBUG("network", "WORLD: HandleVoidStorageUnlock - %s not found or player can't interact with it.", npcGuid.ToString().c_str());
+ TC_LOG_DEBUG("network", "WORLD: HandleVoidStorageUnlock - %s not found or player can't interact with it.", unlockVoidStorage.Npc.ToString().c_str());
return;
}
- if (player->IsVoidStorageUnlocked())
+ if (_player->IsVoidStorageUnlocked())
{
- TC_LOG_DEBUG("network", "WORLD: HandleVoidStorageUnlock - Player (%s, name: %s) tried to unlock void storage a 2nd time.", player->GetGUID().ToString().c_str(), player->GetName().c_str());
+ TC_LOG_DEBUG("network", "WORLD: HandleVoidStorageUnlock - Player (%s, name: %s) tried to unlock void storage a 2nd time.", _player->GetGUID().ToString().c_str(), _player->GetName().c_str());
return;
}
- player->ModifyMoney(-int64(VOID_STORAGE_UNLOCK));
- player->UnlockVoidStorage();
+ _player->ModifyMoney(-int64(VOID_STORAGE_UNLOCK_COST));
+ _player->UnlockVoidStorage();
}
-void WorldSession::HandleVoidStorageQuery(WorldPacket& recvData)
+void WorldSession::HandleVoidStorageQuery(WorldPackets::VoidStorage::QueryVoidStorage& queryVoidStorage)
{
- TC_LOG_DEBUG("network", "WORLD: Received CMSG_VOID_STORAGE_QUERY");
- Player* player = GetPlayer();
-
- ObjectGuid npcGuid;
- npcGuid[4] = recvData.ReadBit();
- npcGuid[0] = recvData.ReadBit();
- npcGuid[5] = recvData.ReadBit();
- npcGuid[7] = recvData.ReadBit();
- npcGuid[6] = recvData.ReadBit();
- npcGuid[3] = recvData.ReadBit();
- npcGuid[1] = recvData.ReadBit();
- npcGuid[2] = recvData.ReadBit();
-
- recvData.ReadByteSeq(npcGuid[5]);
- recvData.ReadByteSeq(npcGuid[6]);
- recvData.ReadByteSeq(npcGuid[3]);
- recvData.ReadByteSeq(npcGuid[7]);
- recvData.ReadByteSeq(npcGuid[1]);
- recvData.ReadByteSeq(npcGuid[0]);
- recvData.ReadByteSeq(npcGuid[4]);
- recvData.ReadByteSeq(npcGuid[2]);
-
- Creature* unit = player->GetNPCIfCanInteractWith(npcGuid, UNIT_NPC_FLAG_VAULTKEEPER);
+ Creature* unit = _player->GetNPCIfCanInteractWith(queryVoidStorage.Npc, UNIT_NPC_FLAG_VAULTKEEPER);
if (!unit)
{
- TC_LOG_DEBUG("network", "WORLD: HandleVoidStorageQuery - %s not found or player can't interact with it.", npcGuid.ToString().c_str());
+ TC_LOG_DEBUG("network", "WORLD: HandleVoidStorageQuery - %s not found or player can't interact with it.", queryVoidStorage.Npc.ToString().c_str());
+ SendPacket(WorldPackets::VoidStorage::VoidStorageFailed().Write());
return;
}
- if (!player->IsVoidStorageUnlocked())
+ if (!_player->IsVoidStorageUnlocked())
{
- TC_LOG_DEBUG("network", "WORLD: HandleVoidStorageQuery - Player (%s, name: %s) queried void storage without unlocking it.", player->GetGUID().ToString().c_str(), player->GetName().c_str());
+ TC_LOG_DEBUG("network", "WORLD: HandleVoidStorageQuery - Player (%s, name: %s) queried void storage without unlocking it.", _player->GetGUID().ToString().c_str(), _player->GetName().c_str());
+ SendPacket(WorldPackets::VoidStorage::VoidStorageFailed().Write());
return;
}
uint8 count = 0;
for (uint8 i = 0; i < VOID_STORAGE_MAX_SLOT; ++i)
- if (player->GetVoidStorageItem(i))
+ if (_player->GetVoidStorageItem(i))
++count;
- WorldPacket data(SMSG_VOID_STORAGE_CONTENTS, 2 * count + (14 + 4 + 4 + 4 + 4) * count);
-
- data.WriteBits(count, 8);
-
- ByteBuffer itemData((14 + 4 + 4 + 4 + 4) * count);
+ 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);
+ VoidStorageItem* item = _player->GetVoidStorageItem(i);
if (!item)
continue;
- ObjectGuid itemId = ObjectGuid::Create<HighGuid::Item>(item->ItemId);
- ObjectGuid creatorGuid = item->CreatorGuid;
-
- data.WriteBit(creatorGuid[3]);
- data.WriteBit(itemId[5]);
- data.WriteBit(creatorGuid[6]);
- data.WriteBit(creatorGuid[1]);
- data.WriteBit(itemId[1]);
- data.WriteBit(itemId[3]);
- data.WriteBit(itemId[6]);
- data.WriteBit(creatorGuid[5]);
- data.WriteBit(creatorGuid[2]);
- data.WriteBit(itemId[2]);
- data.WriteBit(creatorGuid[4]);
- data.WriteBit(itemId[0]);
- data.WriteBit(itemId[4]);
- data.WriteBit(itemId[7]);
- data.WriteBit(creatorGuid[0]);
- data.WriteBit(creatorGuid[7]);
-
- itemData.WriteByteSeq(creatorGuid[3]);
-
- itemData << uint32(item->ItemSuffixFactor);
-
- itemData.WriteByteSeq(creatorGuid[4]);
-
- itemData << uint32(i);
-
- itemData.WriteByteSeq(itemId[0]);
- itemData.WriteByteSeq(itemId[6]);
- itemData.WriteByteSeq(creatorGuid[0]);
- itemData.WriteByteSeq(creatorGuid[1]);
-
- itemData << uint32(item->ItemRandomPropertyId);
-
- itemData.WriteByteSeq(itemId[4]);
- itemData.WriteByteSeq(itemId[5]);
- itemData.WriteByteSeq(itemId[2]);
- itemData.WriteByteSeq(creatorGuid[2]);
- itemData.WriteByteSeq(creatorGuid[6]);
- itemData.WriteByteSeq(itemId[1]);
- itemData.WriteByteSeq(itemId[3]);
- itemData.WriteByteSeq(creatorGuid[5]);
- itemData.WriteByteSeq(creatorGuid[7]);
-
- itemData << uint32(item->ItemEntry);
-
- itemData.WriteByteSeq(itemId[7]);
- }
+ WorldPackets::VoidStorage::VoidItem voidItem;
+ voidItem.Guid = ObjectGuid::Create<HighGuid::Item>(item->ItemId);
+ voidItem.Creator = item->CreatorGuid;
+ voidItem.Slot = i;
+ voidItem.Item.Initialize(item);
- data.FlushBits();
- data.append(itemData);
+ voidStorageContents.Items.push_back(voidItem);
+ }
- SendPacket(&data);
+ SendPacket(voidStorageContents.Write());
}
-void WorldSession::HandleVoidStorageTransfer(WorldPacket& recvData)
+void WorldSession::HandleVoidStorageTransfer(WorldPackets::VoidStorage::VoidStorageTransfer& voidStorageTransfer)
{
- TC_LOG_DEBUG("network", "WORLD: Received CMSG_VOID_STORAGE_TRANSFER");
- Player* player = GetPlayer();
-
- // Read everything
-
- ObjectGuid npcGuid;
- npcGuid[1] = recvData.ReadBit();
-
- uint32 countDeposit = recvData.ReadBits(26);
-
- if (countDeposit > 9)
+ if (voidStorageTransfer.DepositsCount > VOID_STORAGE_MAX_DEPOSIT)
{
- TC_LOG_DEBUG("network", "WORLD: HandleVoidStorageTransfer - Player (%s, name: %s) wants to deposit more than 9 items (%u).", player->GetGUID().ToString().c_str(), player->GetName().c_str(), countDeposit);
+ TC_LOG_DEBUG("network", "WORLD: HandleVoidStorageTransfer - Player (%s, name: %s) wants to deposit more than 9 items (%u).", _player->GetGUID().ToString().c_str(), _player->GetName().c_str(), voidStorageTransfer.DepositsCount);
return;
}
- std::vector<ObjectGuid> itemGuids(countDeposit);
- for (uint32 i = 0; i < countDeposit; ++i)
+ if (voidStorageTransfer.WithdrawalsCount > VOID_STORAGE_MAX_WITHDRAW)
{
- itemGuids[i][4] = recvData.ReadBit();
- itemGuids[i][6] = recvData.ReadBit();
- itemGuids[i][7] = recvData.ReadBit();
- itemGuids[i][0] = recvData.ReadBit();
- itemGuids[i][1] = recvData.ReadBit();
- itemGuids[i][5] = recvData.ReadBit();
- itemGuids[i][3] = recvData.ReadBit();
- itemGuids[i][2] = recvData.ReadBit();
- }
-
- npcGuid[2] = recvData.ReadBit();
- npcGuid[0] = recvData.ReadBit();
- npcGuid[3] = recvData.ReadBit();
- npcGuid[5] = recvData.ReadBit();
- npcGuid[6] = recvData.ReadBit();
- npcGuid[4] = recvData.ReadBit();
-
- uint32 countWithdraw = recvData.ReadBits(26);
-
- if (countWithdraw > 9)
- {
- TC_LOG_DEBUG("network", "WORLD: HandleVoidStorageTransfer - Player (%s, name: %s) wants to withdraw more than 9 items (%u).", player->GetGUID().ToString().c_str(), player->GetName().c_str(), countWithdraw);
+ TC_LOG_DEBUG("network", "WORLD: HandleVoidStorageTransfer - Player (%s, name: %s) wants to withdraw more than 9 items (%u).", _player->GetGUID().ToString().c_str(), _player->GetName().c_str(), voidStorageTransfer.WithdrawalsCount);
return;
}
- std::vector<ObjectGuid> itemIds(countWithdraw);
- for (uint32 i = 0; i < countWithdraw; ++i)
- {
- itemIds[i][4] = recvData.ReadBit();
- itemIds[i][7] = recvData.ReadBit();
- itemIds[i][1] = recvData.ReadBit();
- itemIds[i][0] = recvData.ReadBit();
- itemIds[i][2] = recvData.ReadBit();
- itemIds[i][3] = recvData.ReadBit();
- itemIds[i][5] = recvData.ReadBit();
- itemIds[i][6] = recvData.ReadBit();
- }
-
- npcGuid[7] = recvData.ReadBit();
-
- for (uint32 i = 0; i < countDeposit; ++i)
- {
- recvData.ReadByteSeq(itemGuids[i][6]);
- recvData.ReadByteSeq(itemGuids[i][1]);
- recvData.ReadByteSeq(itemGuids[i][0]);
- recvData.ReadByteSeq(itemGuids[i][2]);
- recvData.ReadByteSeq(itemGuids[i][4]);
- recvData.ReadByteSeq(itemGuids[i][5]);
- recvData.ReadByteSeq(itemGuids[i][3]);
- recvData.ReadByteSeq(itemGuids[i][7]);
- }
-
- recvData.ReadByteSeq(npcGuid[5]);
- recvData.ReadByteSeq(npcGuid[6]);
-
- for (uint32 i = 0; i < countWithdraw; ++i)
- {
- recvData.ReadByteSeq(itemIds[i][3]);
- recvData.ReadByteSeq(itemIds[i][0]);
- recvData.ReadByteSeq(itemIds[i][1]);
- recvData.ReadByteSeq(itemIds[i][6]);
- recvData.ReadByteSeq(itemIds[i][2]);
- recvData.ReadByteSeq(itemIds[i][7]);
- recvData.ReadByteSeq(itemIds[i][5]);
- recvData.ReadByteSeq(itemIds[i][4]);
- }
-
- recvData.ReadByteSeq(npcGuid[1]);
- recvData.ReadByteSeq(npcGuid[4]);
- recvData.ReadByteSeq(npcGuid[7]);
- recvData.ReadByteSeq(npcGuid[3]);
- recvData.ReadByteSeq(npcGuid[2]);
- recvData.ReadByteSeq(npcGuid[0]);
-
- Creature* unit = player->GetNPCIfCanInteractWith(npcGuid, UNIT_NPC_FLAG_VAULTKEEPER);
+ Creature* unit = _player->GetNPCIfCanInteractWith(voidStorageTransfer.Npc, UNIT_NPC_FLAG_VAULTKEEPER);
if (!unit)
{
- TC_LOG_DEBUG("network", "WORLD: HandleVoidStorageTransfer - %s not found or player can't interact with it.", npcGuid.ToString().c_str());
+ TC_LOG_DEBUG("network", "WORLD: HandleVoidStorageTransfer - %s not found or player can't interact with it.", voidStorageTransfer.Npc.ToString().c_str());
return;
}
- if (!player->IsVoidStorageUnlocked())
+ if (!_player->IsVoidStorageUnlocked())
{
- TC_LOG_DEBUG("network", "WORLD: HandleVoidStorageTransfer - Player (%s, name: %s) queried void storage without unlocking it.", player->GetGUID().ToString().c_str(), player->GetName().c_str());
+ TC_LOG_DEBUG("network", "WORLD: HandleVoidStorageTransfer - Player (%s, name: %s) queried void storage without unlocking it.", _player->GetGUID().ToString().c_str(), _player->GetName().c_str());
return;
}
- if (itemGuids.size() > player->GetNumOfVoidStorageFreeSlots())
+ if (voidStorageTransfer.DepositsCount > _player->GetNumOfVoidStorageFreeSlots())
{
SendVoidStorageTransferResult(VOID_TRANSFER_ERROR_FULL);
return;
}
uint32 freeBagSlots = 0;
- if (itemIds.size() != 0)
+ if (voidStorageTransfer.WithdrawalsCount)
{
// make this a Player function
for (uint8 i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; i++)
- if (Bag* bag = player->GetBagByPos(i))
+ if (Bag* bag = _player->GetBagByPos(i))
freeBagSlots += bag->GetFreeSlots();
+
for (uint8 i = INVENTORY_SLOT_ITEM_START; i < INVENTORY_SLOT_ITEM_END; i++)
- if (!player->GetItemByPos(INVENTORY_SLOT_BAG_0, i))
+ if (!_player->GetItemByPos(INVENTORY_SLOT_BAG_0, i))
++freeBagSlots;
}
- if (itemIds.size() > freeBagSlots)
+ if (voidStorageTransfer.WithdrawalsCount > freeBagSlots)
{
SendVoidStorageTransferResult(VOID_TRANSFER_ERROR_INVENTORY_FULL);
return;
}
- if (!player->HasEnoughMoney(uint64(itemGuids.size() * VOID_STORAGE_STORE_ITEM)))
+ if (!_player->HasEnoughMoney(uint64(voidStorageTransfer.DepositsCount * VOID_STORAGE_STORE_ITEM_COST)))
{
SendVoidStorageTransferResult(VOID_TRANSFER_ERROR_NOT_ENOUGH_MONEY);
return;
@@ -326,294 +153,125 @@ void WorldSession::HandleVoidStorageTransfer(WorldPacket& recvData)
std::pair<VoidStorageItem, uint8> depositItems[VOID_STORAGE_MAX_DEPOSIT];
uint8 depositCount = 0;
- for (std::vector<ObjectGuid>::iterator itr = itemGuids.begin(); itr != itemGuids.end(); ++itr)
+ for (uint32 i = 0; i < voidStorageTransfer.DepositsCount; ++i)
{
- Item* item = player->GetItemByGuid(*itr);
+ Item* item = _player->GetItemByGuid(voidStorageTransfer.Deposits[i]);
if (!item)
{
- TC_LOG_DEBUG("network", "WORLD: HandleVoidStorageTransfer - %s %s wants to deposit an invalid item (%s).", player->GetGUID().ToString().c_str(), player->GetName().c_str(), itr->ToString().c_str());
+ TC_LOG_DEBUG("network", "WORLD: HandleVoidStorageTransfer - %s %s wants to deposit an invalid item (%s).", _player->GetGUID().ToString().c_str(), _player->GetName().c_str(), item->GetGUID().ToString().c_str());
continue;
}
+ // TODO: Save these fields to database - for now disallow storing these items to prevent data loss
+ if (item->GetUInt32Value(ITEM_FIELD_MODIFIERS_MASK) || !item->GetDynamicValues(ITEM_DYNAMIC_FIELD_BONUSLIST_IDS).empty())
+ continue;
+
VoidStorageItem itemVS(sObjectMgr->GenerateVoidStorageItemId(), item->GetEntry(), item->GetGuidValue(ITEM_FIELD_CREATOR), item->GetItemRandomPropertyId(), item->GetItemSuffixFactor());
- uint8 slot = player->AddVoidStorageItem(itemVS);
+ uint8 slot = _player->AddVoidStorageItem(itemVS);
depositItems[depositCount++] = std::make_pair(itemVS, slot);
- player->DestroyItem(item->GetBagSlot(), item->GetSlot(), true);
+ _player->DestroyItem(item->GetBagSlot(), item->GetSlot(), true);
}
- int64 cost = depositCount * VOID_STORAGE_STORE_ITEM;
+ int64 cost = depositCount * VOID_STORAGE_STORE_ITEM_COST;
- player->ModifyMoney(-cost);
+ _player->ModifyMoney(-cost);
VoidStorageItem withdrawItems[VOID_STORAGE_MAX_WITHDRAW];
uint8 withdrawCount = 0;
- for (std::vector<ObjectGuid>::iterator itr = itemIds.begin(); itr != itemIds.end(); ++itr)
+ for (uint32 i = 0; i < voidStorageTransfer.WithdrawalsCount; ++i)
{
- uint8 slot;
- VoidStorageItem* itemVS = player->GetVoidStorageItem(itr->GetCounter(), slot);
+ uint8 slot = 0;
+ VoidStorageItem* itemVS = _player->GetVoidStorageItem(voidStorageTransfer.Withdrawals[i].GetCounter(), slot);
if (!itemVS)
{
- TC_LOG_DEBUG("network", "WORLD: HandleVoidStorageTransfer - %s %s tried to withdraw an invalid item (id: %s)", player->GetGUID().ToString().c_str(), player->GetName().c_str(), itr->ToString().c_str());
+ TC_LOG_DEBUG("network", "WORLD: HandleVoidStorageTransfer - %s %s tried to withdraw an invalid item (id: %s)", _player->GetGUID().ToString().c_str(), _player->GetName().c_str(), voidStorageTransfer.Withdrawals[i].ToString().c_str());
continue;
}
ItemPosCountVec dest;
- InventoryResult msg = player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, itemVS->ItemEntry, 1);
+ 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 - %s %s couldn't withdraw item id %s because inventory was full.", player->GetGUID().ToString().c_str(), player->GetName().c_str(), itr->ToString().c_str());
+ TC_LOG_DEBUG("network", "WORLD: HandleVoidStorageTransfer - %s %s couldn't withdraw item id %s because inventory was full.", _player->GetGUID().ToString().c_str(), _player->GetName().c_str(), voidStorageTransfer.Withdrawals[i].ToString().c_str());
return;
}
- Item* item = player->StoreNewItem(dest, itemVS->ItemEntry, true, itemVS->ItemRandomPropertyId);
+ Item* item = _player->StoreNewItem(dest, itemVS->ItemEntry, true, itemVS->ItemRandomPropertyId);
+ item->SetUInt32Value(ITEM_FIELD_PROPERTY_SEED, itemVS->ItemSuffixFactor);
item->SetGuidValue(ITEM_FIELD_CREATOR, itemVS->CreatorGuid);
item->SetBinding(true);
- player->SendNewItem(item, 1, false, false, false);
+ _player->SendNewItem(item, 1, false, false, false);
withdrawItems[withdrawCount++] = *itemVS;
- player->DeleteVoidStorageItem(slot);
+ _player->DeleteVoidStorageItem(slot);
}
- WorldPacket data(SMSG_VOID_STORAGE_TRANSFER_CHANGES, ((5 + 5 + (7 + 7) * depositCount +
- 7 * withdrawCount) / 8) + 7 * withdrawCount + (7 + 7 + 4 * 4) * depositCount);
-
- data.WriteBits(depositCount, 5);
- data.WriteBits(withdrawCount, 5);
+ WorldPackets::VoidStorage::VoidStorageTransferChanges voidStorageTransferChanges;
+ voidStorageTransferChanges.AddedItems.resize(depositCount);
+ voidStorageTransferChanges.RemovedItems.resize(withdrawCount);
for (uint8 i = 0; i < depositCount; ++i)
{
- ObjectGuid itemId = ObjectGuid::Create<HighGuid::Item>(depositItems[i].first.ItemId);
- ObjectGuid creatorGuid = depositItems[i].first.CreatorGuid;
- data.WriteBit(creatorGuid[7]);
- data.WriteBit(itemId[7]);
- data.WriteBit(itemId[4]);
- data.WriteBit(creatorGuid[6]);
- data.WriteBit(creatorGuid[5]);
- data.WriteBit(itemId[3]);
- data.WriteBit(itemId[5]);
- data.WriteBit(creatorGuid[4]);
- data.WriteBit(creatorGuid[2]);
- data.WriteBit(creatorGuid[0]);
- data.WriteBit(creatorGuid[3]);
- data.WriteBit(creatorGuid[1]);
- data.WriteBit(itemId[2]);
- data.WriteBit(itemId[0]);
- data.WriteBit(itemId[1]);
- data.WriteBit(itemId[6]);
+ voidStorageTransferChanges.AddedItems[i].Guid = ObjectGuid::Create<HighGuid::Item>(depositItems[i].first.ItemId);
+ voidStorageTransferChanges.AddedItems[i].Creator = depositItems[i].first.CreatorGuid;
+ voidStorageTransferChanges.AddedItems[i].Slot = depositItems[i].second;
+ voidStorageTransferChanges.AddedItems[i].Item.Initialize(&depositItems[i].first);
}
for (uint8 i = 0; i < withdrawCount; ++i)
- {
- ObjectGuid itemId = ObjectGuid::Create<HighGuid::Item>(withdrawItems[i].ItemId);
- data.WriteBit(itemId[1]);
- data.WriteBit(itemId[7]);
- data.WriteBit(itemId[3]);
- data.WriteBit(itemId[5]);
- data.WriteBit(itemId[6]);
- data.WriteBit(itemId[2]);
- data.WriteBit(itemId[4]);
- data.WriteBit(itemId[0]);
- }
+ voidStorageTransferChanges.RemovedItems[i] = ObjectGuid::Create<HighGuid::Item>(withdrawItems[i].ItemId);
- data.FlushBits();
-
- for (uint8 i = 0; i < withdrawCount; ++i)
- {
- ObjectGuid itemId = ObjectGuid::Create<HighGuid::Item>(withdrawItems[i].ItemId);
- data.WriteByteSeq(itemId[3]);
- data.WriteByteSeq(itemId[1]);
- data.WriteByteSeq(itemId[0]);
- data.WriteByteSeq(itemId[2]);
- data.WriteByteSeq(itemId[7]);
- data.WriteByteSeq(itemId[5]);
- data.WriteByteSeq(itemId[6]);
- data.WriteByteSeq(itemId[4]);
- }
-
- for (uint8 i = 0; i < depositCount; ++i)
- {
- ObjectGuid itemId = ObjectGuid::Create<HighGuid::Item>(depositItems[i].first.ItemId);
- ObjectGuid creatorGuid = depositItems[i].first.CreatorGuid;
-
- data << uint32(depositItems[i].first.ItemSuffixFactor);
-
- data.WriteByteSeq(itemId[6]);
- data.WriteByteSeq(itemId[4]);
- data.WriteByteSeq(creatorGuid[4]);
- data.WriteByteSeq(itemId[2]);
- data.WriteByteSeq(creatorGuid[1]);
- data.WriteByteSeq(creatorGuid[3]);
- data.WriteByteSeq(itemId[3]);
- data.WriteByteSeq(creatorGuid[0]);
- data.WriteByteSeq(itemId[0]);
- data.WriteByteSeq(creatorGuid[6]);
- data.WriteByteSeq(itemId[5]);
- data.WriteByteSeq(creatorGuid[5]);
- data.WriteByteSeq(creatorGuid[7]);
-
- data << uint32(depositItems[i].first.ItemEntry);
-
- data.WriteByteSeq(itemId[1]);
-
- data << uint32(depositItems[i].second); // slot
-
- data.WriteByteSeq(creatorGuid[2]);
- data.WriteByteSeq(itemId[7]);
-
- data << uint32(depositItems[i].first.ItemRandomPropertyId);
- }
-
- SendPacket(&data);
+ SendPacket(voidStorageTransferChanges.Write());
SendVoidStorageTransferResult(VOID_TRANSFER_ERROR_NO_ERROR);
}
-void WorldSession::HandleVoidSwapItem(WorldPacket& recvData)
+void WorldSession::HandleVoidSwapItem(WorldPackets::VoidStorage::SwapVoidItem& swapVoidItem)
{
- TC_LOG_DEBUG("network", "WORLD: Received CMSG_VOID_SWAP_ITEM");
-
- Player* player = GetPlayer();
- uint32 newSlot;
- ObjectGuid npcGuid;
- ObjectGuid itemId;
-
- recvData >> newSlot;
-
- npcGuid[2] = recvData.ReadBit();
- npcGuid[4] = recvData.ReadBit();
- npcGuid[0] = recvData.ReadBit();
- itemId[2] = recvData.ReadBit();
- itemId[6] = recvData.ReadBit();
- itemId[5] = recvData.ReadBit();
- npcGuid[1] = recvData.ReadBit();
- npcGuid[7] = recvData.ReadBit();
- itemId[3] = recvData.ReadBit();
- itemId[7] = recvData.ReadBit();
- itemId[0] = recvData.ReadBit();
- npcGuid[6] = recvData.ReadBit();
- npcGuid[5] = recvData.ReadBit();
- npcGuid[3] = recvData.ReadBit();
- itemId[1] = recvData.ReadBit();
- itemId[4] = recvData.ReadBit();
-
- recvData.ReadByteSeq(npcGuid[1]);
- recvData.ReadByteSeq(itemId[3]);
- recvData.ReadByteSeq(itemId[2]);
- recvData.ReadByteSeq(itemId[4]);
- recvData.ReadByteSeq(npcGuid[3]);
- recvData.ReadByteSeq(npcGuid[0]);
- recvData.ReadByteSeq(itemId[6]);
- recvData.ReadByteSeq(itemId[1]);
- recvData.ReadByteSeq(npcGuid[5]);
- recvData.ReadByteSeq(itemId[5]);
- recvData.ReadByteSeq(npcGuid[6]);
- recvData.ReadByteSeq(itemId[0]);
- recvData.ReadByteSeq(npcGuid[2]);
- recvData.ReadByteSeq(npcGuid[7]);
- recvData.ReadByteSeq(npcGuid[4]);
- recvData.ReadByteSeq(itemId[7]);
-
- Creature* unit = player->GetNPCIfCanInteractWith(npcGuid, UNIT_NPC_FLAG_VAULTKEEPER);
+ Creature* unit = _player->GetNPCIfCanInteractWith(swapVoidItem.Npc, UNIT_NPC_FLAG_VAULTKEEPER);
if (!unit)
{
- TC_LOG_DEBUG("network", "WORLD: HandleVoidSwapItem - %s not found or player can't interact with it.", npcGuid.ToString().c_str());
+ TC_LOG_DEBUG("network", "WORLD: HandleVoidSwapItem - %s not found or player can't interact with it.", swapVoidItem.Npc.ToString().c_str());
return;
}
- if (!player->IsVoidStorageUnlocked())
+ if (!_player->IsVoidStorageUnlocked())
{
- TC_LOG_DEBUG("network", "WORLD: HandleVoidSwapItem - Player (%s, name: %s) queried void storage without unlocking it.", player->GetGUID().ToString().c_str(), player->GetName().c_str());
+ TC_LOG_DEBUG("network", "WORLD: HandleVoidSwapItem - Player (%s, name: %s) queried void storage without unlocking it.", _player->GetGUID().ToString().c_str(), _player->GetName().c_str());
return;
}
uint8 oldSlot;
- if (!player->GetVoidStorageItem(itemId.GetCounter(), oldSlot))
+ if (!_player->GetVoidStorageItem(swapVoidItem.VoidItemGuid.GetCounter(), oldSlot))
{
- TC_LOG_DEBUG("network", "WORLD: HandleVoidSwapItem - %s %s requested swapping an invalid item (slot: %u, itemid: %s).", player->GetGUID().ToString().c_str(), player->GetName().c_str(), newSlot, itemId.ToString().c_str());
+ TC_LOG_DEBUG("network", "WORLD: HandleVoidSwapItem - %s %s requested swapping an invalid item (slot: %u, itemid: %s).", _player->GetGUID().ToString().c_str(), _player->GetName().c_str(), swapVoidItem.DstSlot, swapVoidItem.VoidItemGuid.ToString().c_str());
return;
}
- bool usedSrcSlot = player->GetVoidStorageItem(oldSlot) != NULL; // should be always true
- bool usedDestSlot = player->GetVoidStorageItem(newSlot) != NULL;
+ bool usedDestSlot = _player->GetVoidStorageItem(swapVoidItem.DstSlot) != NULL;
ObjectGuid itemIdDest;
if (usedDestSlot)
- itemIdDest = ObjectGuid::Create<HighGuid::Item>(player->GetVoidStorageItem(newSlot)->ItemId);
+ itemIdDest = ObjectGuid::Create<HighGuid::Item>(_player->GetVoidStorageItem(swapVoidItem.DstSlot)->ItemId);
- if (!player->SwapVoidStorageItem(oldSlot, newSlot))
+ if (!_player->SwapVoidStorageItem(oldSlot, swapVoidItem.DstSlot))
{
SendVoidStorageTransferResult(VOID_TRANSFER_ERROR_INTERNAL_ERROR_1);
return;
}
- WorldPacket data(SMSG_VOID_ITEM_SWAP_RESPONSE, 1 + (usedSrcSlot + usedDestSlot) * (1 + 7 + 4));
-
- data.WriteBit(!usedDestSlot);
- data.WriteBit(!usedSrcSlot);
-
- if (usedSrcSlot)
- {
- data.WriteBit(itemId[5]);
- data.WriteBit(itemId[2]);
- data.WriteBit(itemId[1]);
- data.WriteBit(itemId[4]);
- data.WriteBit(itemId[0]);
- data.WriteBit(itemId[6]);
- data.WriteBit(itemId[7]);
- data.WriteBit(itemId[3]);
- }
-
- data.WriteBit(!usedDestSlot); // unk
-
- if (usedDestSlot)
- {
- data.WriteBit(itemIdDest[7]);
- data.WriteBit(itemIdDest[3]);
- data.WriteBit(itemIdDest[4]);
- data.WriteBit(itemIdDest[0]);
- data.WriteBit(itemIdDest[5]);
- data.WriteBit(itemIdDest[1]);
- data.WriteBit(itemIdDest[2]);
- data.WriteBit(itemIdDest[6]);
- }
-
- data.WriteBit(!usedSrcSlot); // unk
-
- data.FlushBits();
-
+ WorldPackets::VoidStorage::VoidItemSwapResponse voidItemSwapResponse;
+ voidItemSwapResponse.VoidItemA = swapVoidItem.VoidItemGuid;
+ voidItemSwapResponse.VoidItemSlotA = swapVoidItem.DstSlot;
if (usedDestSlot)
{
- data.WriteByteSeq(itemIdDest[4]);
- data.WriteByteSeq(itemIdDest[6]);
- data.WriteByteSeq(itemIdDest[5]);
- data.WriteByteSeq(itemIdDest[2]);
- data.WriteByteSeq(itemIdDest[3]);
- data.WriteByteSeq(itemIdDest[1]);
- data.WriteByteSeq(itemIdDest[7]);
- data.WriteByteSeq(itemIdDest[0]);
- }
-
- if (usedSrcSlot)
- {
- data.WriteByteSeq(itemId[6]);
- data.WriteByteSeq(itemId[3]);
- data.WriteByteSeq(itemId[5]);
- data.WriteByteSeq(itemId[0]);
- data.WriteByteSeq(itemId[1]);
- data.WriteByteSeq(itemId[2]);
- data.WriteByteSeq(itemId[4]);
- data.WriteByteSeq(itemId[7]);
+ voidItemSwapResponse.VoidItemB = itemIdDest;
+ voidItemSwapResponse.VoidItemSlotB = oldSlot;
}
- if (usedDestSlot)
- data << uint32(oldSlot);
-
- if (usedSrcSlot)
- data << uint32(newSlot);
-
- SendPacket(&data);
+ SendPacket(voidItemSwapResponse.Write());
}
diff --git a/src/server/game/Loot/LootMgr.cpp b/src/server/game/Loot/LootMgr.cpp
index ce99d6ed971..efb3810d00c 100644
--- a/src/server/game/Loot/LootMgr.cpp
+++ b/src/server/game/Loot/LootMgr.cpp
@@ -921,7 +921,7 @@ void Loot::BuildLootResponse(WorldPackets::Loot::LootResponse& packet, Player* v
lootItem.LootListID = packet.Items.size()+1;
lootItem.LootItemType = slot_type;
lootItem.Quantity = items[i].count;
- lootItem.Loot.Initalize(items[i]);
+ lootItem.Loot.Initialize(items[i]);
packet.Items.push_back(lootItem);
}
}
@@ -941,7 +941,7 @@ void Loot::BuildLootResponse(WorldPackets::Loot::LootResponse& packet, Player* v
lootItem.LootListID = packet.Items.size()+1;
lootItem.LootItemType = LOOT_SLOT_TYPE_ALLOW_LOOT;
lootItem.Quantity = items[i].count;
- lootItem.Loot.Initalize(items[i]);
+ lootItem.Loot.Initialize(items[i]);
packet.Items.push_back(lootItem);
}
}
@@ -958,7 +958,7 @@ void Loot::BuildLootResponse(WorldPackets::Loot::LootResponse& packet, Player* v
lootItem.LootListID = packet.Items.size()+1;
lootItem.LootItemType = LOOT_SLOT_TYPE_ALLOW_LOOT;
lootItem.Quantity = items[i].count;
- lootItem.Loot.Initalize(items[i]);
+ lootItem.Loot.Initialize(items[i]);
packet.Items.push_back(lootItem);
}
}
@@ -981,7 +981,7 @@ void Loot::BuildLootResponse(WorldPackets::Loot::LootResponse& packet, Player* v
WorldPackets::Loot::LootItemData lootItem;
lootItem.LootListID = packet.Items.size()+1;
lootItem.Quantity = item.count;
- lootItem.Loot.Initalize(item);
+ lootItem.Loot.Initialize(item);
if (item.follow_loot_rules)
{
@@ -1027,7 +1027,7 @@ void Loot::BuildLootResponse(WorldPackets::Loot::LootResponse& packet, Player* v
lootItem.LootListID = packet.Items.size()+1;
lootItem.LootItemType = LOOT_SLOT_TYPE_ALLOW_LOOT;
lootItem.Quantity = item.count;
- lootItem.Loot.Initalize(item);
+ lootItem.Loot.Initialize(item);
packet.Items.push_back(lootItem);
}
}
@@ -1046,7 +1046,7 @@ void Loot::BuildLootResponse(WorldPackets::Loot::LootResponse& packet, Player* v
WorldPackets::Loot::LootItemData lootItem;
lootItem.LootListID = packet.Items.size()+1;
lootItem.Quantity = item.count;
- lootItem.Loot.Initalize(item);
+ lootItem.Loot.Initialize(item);
if (item.follow_loot_rules)
{
diff --git a/src/server/game/Server/Packets/AuctionHousePackets.cpp b/src/server/game/Server/Packets/AuctionHousePackets.cpp
index 49a8d358a55..65652688823 100644
--- a/src/server/game/Server/Packets/AuctionHousePackets.cpp
+++ b/src/server/game/Server/Packets/AuctionHousePackets.cpp
@@ -82,14 +82,14 @@ ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::AuctionHouse::AuctionBidd
void WorldPackets::AuctionHouse::AuctionOwnerNotification::Initialize(::AuctionEntry const* auction, ::Item const* item)
{
AuctionItemID = auction->Id;
- Item.Initalize(item);
+ Item.Initialize(item);
BidAmount = auction->bid;
}
void WorldPackets::AuctionHouse::AuctionBidderNotification::Initialize(::AuctionEntry const* auction, ::Item const* item)
{
AuctionItemID = auction->Id;
- Item.Initalize(item);
+ Item.Initialize(item);
Bidder = ObjectGuid::Create<HighGuid::Player>(auction->bidder);
}
diff --git a/src/server/game/Server/Packets/InspectPackets.cpp b/src/server/game/Server/Packets/InspectPackets.cpp
index bdfdc4da06b..9d98d30bd74 100644
--- a/src/server/game/Server/Packets/InspectPackets.cpp
+++ b/src/server/game/Server/Packets/InspectPackets.cpp
@@ -60,7 +60,7 @@ WorldPackets::Inspect::InspectItemData::InspectItemData(::Item const* item, uint
{
CreatorGUID = item->GetGuidValue(ITEM_FIELD_CREATOR);
- Item.Initalize(item);
+ Item.Initialize(item);
Index = index;
Usable = true; /// @todo
diff --git a/src/server/game/Server/Packets/ItemPackets.cpp b/src/server/game/Server/Packets/ItemPackets.cpp
index f3346887ab9..958a6c9c33a 100644
--- a/src/server/game/Server/Packets/ItemPackets.cpp
+++ b/src/server/game/Server/Packets/ItemPackets.cpp
@@ -16,6 +16,7 @@
*/
#include "ItemPackets.h"
+#include "Player.h"
void WorldPackets::Item::BuyBackItem::Read()
{
@@ -165,7 +166,7 @@ ByteBuffer& WorldPackets::Item::operator>>(ByteBuffer& data, InvUpdate& invUpdat
return data;
}
-void WorldPackets::Item::ItemInstance::Initalize(::Item const* item)
+void WorldPackets::Item::ItemInstance::Initialize(::Item const* item)
{
ItemID = item->GetEntry();
RandomPropertiesSeed = item->GetItemSuffixFactor();
@@ -188,7 +189,7 @@ void WorldPackets::Item::ItemInstance::Initalize(::Item const* item)
}
}
-void WorldPackets::Item::ItemInstance::Initalize(::LootItem const& lootItem)
+void WorldPackets::Item::ItemInstance::Initialize(::LootItem const& lootItem)
{
ItemID = lootItem.itemid;
RandomPropertiesSeed = lootItem.randomSuffix;
@@ -203,6 +204,13 @@ void WorldPackets::Item::ItemInstance::Initalize(::LootItem const& lootItem)
/// no Modifications
}
+void WorldPackets::Item::ItemInstance::Initialize(::VoidStorageItem const* voidItem)
+{
+ ItemID = voidItem->ItemEntry;
+ RandomPropertiesID = voidItem->ItemRandomPropertyId;
+ RandomPropertiesSeed = voidItem->ItemSuffixFactor;
+}
+
WorldPacket const* WorldPackets::Item::InventoryChangeFailure::Write()
{
_worldPacket << int8(BagResult);
diff --git a/src/server/game/Server/Packets/ItemPackets.h b/src/server/game/Server/Packets/ItemPackets.h
index 9b171317dd9..f9c700b0cb4 100644
--- a/src/server/game/Server/Packets/ItemPackets.h
+++ b/src/server/game/Server/Packets/ItemPackets.h
@@ -22,6 +22,8 @@
#include "Item.h"
#include "PacketUtilities.h"
+struct VoidStorageItem;
+
namespace WorldPackets
{
namespace Item
@@ -34,8 +36,9 @@ namespace WorldPackets
struct ItemInstance
{
- void Initalize(::Item const* item);
- void Initalize(::LootItem const& lootItem);
+ void Initialize(::Item const* item);
+ void Initialize(::LootItem const& lootItem);
+ void Initialize(::VoidStorageItem const* voidItem);
uint32 ItemID = 0;
uint32 RandomPropertiesSeed = 0;
diff --git a/src/server/game/Server/Packets/MailPackets.cpp b/src/server/game/Server/Packets/MailPackets.cpp
index 4e3c59a27e6..b1de05aac25 100644
--- a/src/server/game/Server/Packets/MailPackets.cpp
+++ b/src/server/game/Server/Packets/MailPackets.cpp
@@ -24,7 +24,7 @@ WorldPackets::Mail::MailAttachedItem::MailAttachedItem(::Item const* item, uint8
{
Position = pos;
AttachID = item->GetGUID().GetCounter();
- Item.Initalize(item);
+ Item.Initialize(item);
Count = item->GetCount();
Charges = item->GetSpellCharges();
MaxDurability = item->GetUInt32Value(ITEM_FIELD_MAXDURABILITY);
diff --git a/src/server/game/Server/Packets/VoidStoragePackets.cpp b/src/server/game/Server/Packets/VoidStoragePackets.cpp
new file mode 100644
index 00000000000..a635d57666d
--- /dev/null
+++ b/src/server/game/Server/Packets/VoidStoragePackets.cpp
@@ -0,0 +1,110 @@
+/*
+ * Copyright (C) 2008-2015 TrinityCore <http://www.trinitycore.org/>
+ *
+ * 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 "VoidStoragePackets.h"
+#include "SharedDefines.h"
+
+WorldPacket const* WorldPackets::VoidStorage::VoidTransferResult::Write()
+{
+ _worldPacket << int32(Result);
+ return &_worldPacket;
+}
+
+void WorldPackets::VoidStorage::UnlockVoidStorage::Read()
+{
+ _worldPacket >> Npc;
+}
+
+void WorldPackets::VoidStorage::QueryVoidStorage::Read()
+{
+ _worldPacket >> Npc;
+}
+
+WorldPacket const* WorldPackets::VoidStorage::VoidStorageFailed::Write()
+{
+ _worldPacket << uint8(Reason);
+ return &_worldPacket;
+}
+
+ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::VoidStorage::VoidItem const& voidItem)
+{
+ data << voidItem.Guid;
+ data << voidItem.Creator;
+ data << uint32(voidItem.Slot);
+ data << voidItem.Item;
+ return data;
+}
+
+WorldPacket const* WorldPackets::VoidStorage::VoidStorageContents::Write()
+{
+ _worldPacket.reserve(1 + Items.size() * sizeof(VoidItem));
+
+ _worldPacket.WriteBits(Items.size(), 8);
+ _worldPacket.FlushBits();
+
+ for (VoidItem const& voidItem : Items)
+ _worldPacket << voidItem;
+
+ return &_worldPacket;
+}
+
+void WorldPackets::VoidStorage::VoidStorageTransfer::Read()
+{
+ _worldPacket >> Npc;
+ _worldPacket >> DepositsCount;
+ _worldPacket >> WithdrawalsCount;
+
+ if (WithdrawalsCount > VOID_STORAGE_MAX_WITHDRAW || DepositsCount > VOID_STORAGE_MAX_DEPOSIT)
+ return;
+
+ for (uint32 i = 0; i < DepositsCount; ++i)
+ _worldPacket >> Deposits[i];
+
+ for (uint32 i = 0; i < WithdrawalsCount; ++i)
+ _worldPacket >> Withdrawals[i];
+}
+
+WorldPacket const* WorldPackets::VoidStorage::VoidStorageTransferChanges::Write()
+{
+ _worldPacket.reserve(1 + AddedItems.size() * sizeof(VoidItem) + RemovedItems.size() * 16);
+
+ _worldPacket.WriteBits(AddedItems.size(), 4);
+ _worldPacket.WriteBits(RemovedItems.size(), 4);
+ _worldPacket.FlushBits();
+
+ for (VoidItem const& addedItem : AddedItems)
+ _worldPacket << addedItem;
+
+ for (ObjectGuid const& removedItem : RemovedItems)
+ _worldPacket << removedItem;
+
+ return &_worldPacket;
+}
+
+void WorldPackets::VoidStorage::SwapVoidItem::Read()
+{
+ _worldPacket >> Npc;
+ _worldPacket >> VoidItemGuid;
+ _worldPacket >> DstSlot;
+}
+
+WorldPacket const* WorldPackets::VoidStorage::VoidItemSwapResponse::Write()
+{
+ _worldPacket << VoidItemA << uint32(VoidItemSlotA);
+ _worldPacket << VoidItemB << uint32(VoidItemSlotB);
+ return &_worldPacket;
+}
diff --git a/src/server/game/Server/Packets/VoidStoragePackets.h b/src/server/game/Server/Packets/VoidStoragePackets.h
new file mode 100644
index 00000000000..9790b328e72
--- /dev/null
+++ b/src/server/game/Server/Packets/VoidStoragePackets.h
@@ -0,0 +1,138 @@
+/*
+ * Copyright (C) 2008-2015 TrinityCore <http://www.trinitycore.org/>
+ *
+ * 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/>.
+ */
+
+#ifndef VoidStoragePackets_h__
+#define VoidStoragePackets_h__
+
+#include "Packet.h"
+#include "ItemPackets.h"
+
+namespace WorldPackets
+{
+ namespace VoidStorage
+ {
+ class VoidTransferResult final : public ServerPacket
+ {
+ public:
+ VoidTransferResult(int32 result) : ServerPacket(SMSG_VOID_TRANSFER_RESULT, 4), Result(result) { }
+
+ WorldPacket const* Write() override;
+
+ int32 Result;
+ };
+
+ class UnlockVoidStorage final : public ClientPacket
+ {
+ public:
+ UnlockVoidStorage(WorldPacket&& packet) : ClientPacket(CMSG_UNLOCK_VOID_STORAGE, std::move(packet)) { }
+
+ void Read() override;
+
+ ObjectGuid Npc;
+ };
+
+ class QueryVoidStorage final : public ClientPacket
+ {
+ public:
+ QueryVoidStorage(WorldPacket&& packet) : ClientPacket(CMSG_QUERY_VOID_STORAGE, std::move(packet)) { }
+
+ void Read() override;
+
+ ObjectGuid Npc;
+ };
+
+ class VoidStorageFailed final : public ServerPacket
+ {
+ public:
+ VoidStorageFailed() : ServerPacket(SMSG_VOID_STORAGE_FAILED, 1) { }
+
+ WorldPacket const* Write() override;
+
+ uint8 Reason = 0;
+ };
+
+ struct VoidItem
+ {
+ ObjectGuid Guid;
+ ObjectGuid Creator;
+ uint32 Slot = 0;
+ WorldPackets::Item::ItemInstance Item;
+ };
+
+ class VoidStorageContents final : public ServerPacket
+ {
+ public:
+ VoidStorageContents() : ServerPacket(SMSG_VOID_STORAGE_CONTENTS, 0) { }
+
+ WorldPacket const* Write() override;
+
+ std::vector<VoidItem> Items;
+ };
+
+ class VoidStorageTransfer final : public ClientPacket
+ {
+ public:
+ VoidStorageTransfer(WorldPacket&& packet) : ClientPacket(CMSG_VOID_STORAGE_TRANSFER, std::move(packet)) { }
+
+ void Read() override;
+
+ std::array<ObjectGuid, VOID_STORAGE_MAX_WITHDRAW> Withdrawals;
+ uint32 WithdrawalsCount = 0;
+ std::array<ObjectGuid, VOID_STORAGE_MAX_DEPOSIT> Deposits;
+ uint32 DepositsCount = 0;
+ ObjectGuid Npc;
+ };
+
+ class VoidStorageTransferChanges final : public ServerPacket
+ {
+ public:
+ VoidStorageTransferChanges() : ServerPacket(SMSG_VOID_STORAGE_TRANSFER_CHANGES, 0) { }
+
+ WorldPacket const* Write() override;
+
+ std::vector<ObjectGuid> RemovedItems;
+ std::vector<VoidItem> AddedItems;
+ };
+
+ class SwapVoidItem final : public ClientPacket
+ {
+ public:
+ SwapVoidItem(WorldPacket&& packet) : ClientPacket(CMSG_SWAP_VOID_ITEM, std::move(packet)) { }
+
+ void Read() override;
+
+ ObjectGuid Npc;
+ ObjectGuid VoidItemGuid;
+ uint32 DstSlot = 0;
+ };
+
+ class VoidItemSwapResponse final : public ServerPacket
+ {
+ public:
+ VoidItemSwapResponse() : ServerPacket(SMSG_VOID_ITEM_SWAP_RESPONSE, 16 + 16 + 4 + 4) { }
+
+ WorldPacket const* Write() override;
+
+ ObjectGuid VoidItemA;
+ ObjectGuid VoidItemB;
+ uint32 VoidItemSlotA = 0;
+ uint32 VoidItemSlotB = 0;
+ };
+ }
+}
+
+#endif // VoidStoragePackets_h__
diff --git a/src/server/game/Server/Protocol/Opcodes.cpp b/src/server/game/Server/Protocol/Opcodes.cpp
index ffb2de1f64a..d1f68da912c 100644
--- a/src/server/game/Server/Protocol/Opcodes.cpp
+++ b/src/server/game/Server/Protocol/Opcodes.cpp
@@ -51,6 +51,7 @@
#include "Packets/TradePackets.h"
#include "Packets/TicketPackets.h"
#include "Packets/VehiclePackets.h"
+#include "Packets/VoidStoragePackets.h"
#include "Packets/WhoPackets.h"
template<class PacketClass, void(WorldSession::*HandlerFunction)(PacketClass&)>
@@ -579,7 +580,7 @@ void OpcodeTable::Initialize()
DEFINE_HANDLER(CMSG_MOVE_WATER_WALK_ACK, STATUS_LOGGEDIN, PROCESS_THREADSAFE, WorldPackets::Movement::MovementAckMessage, &WorldSession::HandleMovementAckMessage);
DEFINE_OPCODE_HANDLER_OLD(CMSG_NEUTRAL_PLAYER_SELECT_FACTION, STATUS_UNHANDLED, PROCESS_INPLACE, &WorldSession::Handle_NULL );
DEFINE_OPCODE_HANDLER_OLD(CMSG_NEXT_CINEMATIC_CAMERA, STATUS_UNHANDLED, PROCESS_THREADUNSAFE, &WorldSession::HandleNextCinematicCamera );
- DEFINE_HANDLER(CMSG_OBJECT_UPDATE_FAILED, STATUS_LOGGEDIN, PROCESS_INPLACE, WorldPackets::Misc::ObjectUpdateFailed, &WorldSession::HandleObjectUpdateFailedOpcode);
+ DEFINE_HANDLER(CMSG_OBJECT_UPDATE_FAILED, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, WorldPackets::Misc::ObjectUpdateFailed, &WorldSession::HandleObjectUpdateFailedOpcode);
DEFINE_HANDLER(CMSG_OBJECT_UPDATE_RESCUED, STATUS_LOGGEDIN, PROCESS_INPLACE, WorldPackets::Misc::ObjectUpdateRescued, &WorldSession::HandleObjectUpdateRescuedOpcode);
DEFINE_HANDLER(CMSG_OFFER_PETITION, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, WorldPackets::Petition::OfferPetition, &WorldSession::HandleOfferPetition);
DEFINE_OPCODE_HANDLER_OLD(CMSG_OPENING_CINEMATIC, STATUS_UNHANDLED, PROCESS_THREADUNSAFE, &WorldSession::HandleOpeningCinematic );
@@ -637,7 +638,7 @@ void OpcodeTable::Initialize()
DEFINE_OPCODE_HANDLER_OLD(CMSG_QUERY_REALM_NAME, STATUS_UNHANDLED, PROCESS_INPLACE, &WorldSession::Handle_NULL );
DEFINE_OPCODE_HANDLER_OLD(CMSG_QUERY_SCENARIO_POI, STATUS_UNHANDLED, PROCESS_INPLACE, &WorldSession::Handle_NULL );
DEFINE_HANDLER(CMSG_QUERY_TIME, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, WorldPackets::Query::QueryTime, &WorldSession::HandleQueryTimeOpcode);
- DEFINE_OPCODE_HANDLER_OLD(CMSG_QUERY_VOID_STORAGE, STATUS_UNHANDLED, PROCESS_INPLACE, &WorldSession::HandleVoidStorageQuery );
+ DEFINE_HANDLER(CMSG_QUERY_VOID_STORAGE, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, WorldPackets::VoidStorage::QueryVoidStorage, &WorldSession::HandleVoidStorageQuery);
DEFINE_OPCODE_HANDLER_OLD(CMSG_QUEST_CONFIRM_ACCEPT, STATUS_UNHANDLED, PROCESS_THREADUNSAFE, &WorldSession::HandleQuestConfirmAccept );
DEFINE_HANDLER(CMSG_QUEST_GIVER_ACCEPT_QUEST, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, WorldPackets::Quest::QuestGiverAcceptQuest, &WorldSession::HandleQuestgiverAcceptQuestOpcode);
DEFINE_HANDLER(CMSG_QUEST_GIVER_CHOOSE_REWARD, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, WorldPackets::Quest::QuestGiverChooseReward, &WorldSession::HandleQuestgiverChooseRewardOpcode);
@@ -773,7 +774,7 @@ void OpcodeTable::Initialize()
DEFINE_HANDLER(CMSG_SWAP_INV_ITEM, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, WorldPackets::Item::SwapInvItem, &WorldSession::HandleSwapInvItemOpcode);
DEFINE_HANDLER(CMSG_SWAP_ITEM, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, WorldPackets::Item::SwapItem, &WorldSession::HandleSwapItem);
DEFINE_OPCODE_HANDLER_OLD(CMSG_SWAP_SUB_GROUPS, STATUS_UNHANDLED, PROCESS_INPLACE, &WorldSession::HandleGroupSwapSubGroupOpcode );
- DEFINE_OPCODE_HANDLER_OLD(CMSG_SWAP_VOID_ITEM, STATUS_UNHANDLED, PROCESS_INPLACE, &WorldSession::HandleVoidSwapItem );
+ DEFINE_HANDLER(CMSG_SWAP_VOID_ITEM, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, WorldPackets::VoidStorage::SwapVoidItem, &WorldSession::HandleVoidSwapItem);
DEFINE_HANDLER(CMSG_TABARD_VENDOR_ACTIVATE, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, WorldPackets::NPC::Hello, &WorldSession::HandleTabardVendorActivateOpcode);
DEFINE_HANDLER(CMSG_TALK_TO_GOSSIP, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, WorldPackets::NPC::Hello, &WorldSession::HandleGossipHelloOpcode);
DEFINE_OPCODE_HANDLER_OLD(CMSG_TAXI_NODE_STATUS_QUERY, STATUS_UNHANDLED, PROCESS_THREADSAFE, &WorldSession::HandleTaxiNodeStatusQueryOpcode );
@@ -802,7 +803,7 @@ void OpcodeTable::Initialize()
DEFINE_HANDLER(CMSG_UNDELETE_CHARACTER, STATUS_AUTHED, PROCESS_THREADUNSAFE, WorldPackets::Character::UndeleteCharacter, &WorldSession::HandleCharUndeleteOpcode);
DEFINE_OPCODE_HANDLER_OLD(CMSG_UNLEARN_SKILL, STATUS_UNHANDLED, PROCESS_THREADUNSAFE, &WorldSession::HandleUnlearnSkillOpcode );
DEFINE_OPCODE_HANDLER_OLD(CMSG_UNLEARN_SPECIALIZATION, STATUS_UNHANDLED, PROCESS_INPLACE, &WorldSession::Handle_NULL );
- DEFINE_OPCODE_HANDLER_OLD(CMSG_UNLOCK_VOID_STORAGE, STATUS_UNHANDLED, PROCESS_INPLACE, &WorldSession::HandleVoidStorageUnlock );
+ DEFINE_HANDLER(CMSG_UNLOCK_VOID_STORAGE, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, WorldPackets::VoidStorage::UnlockVoidStorage, &WorldSession::HandleVoidStorageUnlock);
DEFINE_HANDLER(CMSG_UPDATE_ACCOUNT_DATA, STATUS_AUTHED, PROCESS_THREADUNSAFE, WorldPackets::ClientConfig::UserClientUpdateAccountData, &WorldSession::HandleUpdateAccountData);
DEFINE_OPCODE_HANDLER_OLD(CMSG_UPDATE_CLIENT_SETTINGS, STATUS_UNHANDLED, PROCESS_INPLACE, &WorldSession::Handle_NULL );
DEFINE_OPCODE_HANDLER_OLD(CMSG_UPDATE_MISSILE_TRAJECTORY, STATUS_UNHANDLED, PROCESS_THREADUNSAFE, &WorldSession::HandleUpdateMissileTrajectory );
@@ -820,7 +821,7 @@ void OpcodeTable::Initialize()
DEFINE_OPCODE_HANDLER_OLD(CMSG_VOICE_ADD_IGNORE, STATUS_UNHANDLED, PROCESS_INPLACE, &WorldSession::Handle_NULL );
DEFINE_OPCODE_HANDLER_OLD(CMSG_VOICE_DEL_IGNORE, STATUS_UNHANDLED, PROCESS_INPLACE, &WorldSession::Handle_NULL );
DEFINE_OPCODE_HANDLER_OLD(CMSG_VOICE_SESSION_ENABLE, STATUS_UNHANDLED, PROCESS_THREADUNSAFE, &WorldSession::HandleVoiceSessionEnableOpcode );
- DEFINE_OPCODE_HANDLER_OLD(CMSG_VOID_STORAGE_TRANSFER, STATUS_UNHANDLED, PROCESS_INPLACE, &WorldSession::HandleVoidStorageTransfer );
+ DEFINE_HANDLER(CMSG_VOID_STORAGE_TRANSFER, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, WorldPackets::VoidStorage::VoidStorageTransfer, &WorldSession::HandleVoidStorageTransfer);
DEFINE_OPCODE_HANDLER_OLD(CMSG_WARDEN_DATA, STATUS_UNHANDLED, PROCESS_THREADUNSAFE, &WorldSession::HandleWardenDataOpcode );
DEFINE_HANDLER(CMSG_WHO, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, WorldPackets::Who::WhoRequestPkt, &WorldSession::HandleWhoOpcode);
DEFINE_HANDLER(CMSG_WHO_IS, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, WorldPackets::Who::WhoIsRequest, &WorldSession::HandleWhoIsOpcode);
@@ -1725,11 +1726,11 @@ void OpcodeTable::Initialize()
DEFINE_SERVER_OPCODE_HANDLER(SMSG_VOICE_PARENTAL_CONTROLS, STATUS_UNHANDLED, CONNECTION_TYPE_REALM);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_VOICE_SESSION_LEAVE, STATUS_UNHANDLED, CONNECTION_TYPE_REALM);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_VOICE_SESSION_ROSTER_UPDATE, STATUS_UNHANDLED, CONNECTION_TYPE_REALM);
- DEFINE_SERVER_OPCODE_HANDLER(SMSG_VOID_ITEM_SWAP_RESPONSE, STATUS_UNHANDLED, CONNECTION_TYPE_REALM);
- DEFINE_SERVER_OPCODE_HANDLER(SMSG_VOID_STORAGE_CONTENTS, STATUS_UNHANDLED, CONNECTION_TYPE_REALM);
- DEFINE_SERVER_OPCODE_HANDLER(SMSG_VOID_STORAGE_FAILED, STATUS_UNHANDLED, CONNECTION_TYPE_REALM);
- DEFINE_SERVER_OPCODE_HANDLER(SMSG_VOID_STORAGE_TRANSFER_CHANGES, STATUS_UNHANDLED, CONNECTION_TYPE_REALM);
- DEFINE_SERVER_OPCODE_HANDLER(SMSG_VOID_TRANSFER_RESULT, STATUS_UNHANDLED, CONNECTION_TYPE_REALM);
+ DEFINE_SERVER_OPCODE_HANDLER(SMSG_VOID_ITEM_SWAP_RESPONSE, STATUS_NEVER, CONNECTION_TYPE_INSTANCE);
+ DEFINE_SERVER_OPCODE_HANDLER(SMSG_VOID_STORAGE_CONTENTS, STATUS_NEVER, CONNECTION_TYPE_INSTANCE);
+ DEFINE_SERVER_OPCODE_HANDLER(SMSG_VOID_STORAGE_FAILED, STATUS_NEVER, CONNECTION_TYPE_INSTANCE);
+ DEFINE_SERVER_OPCODE_HANDLER(SMSG_VOID_STORAGE_TRANSFER_CHANGES, STATUS_NEVER, CONNECTION_TYPE_INSTANCE);
+ DEFINE_SERVER_OPCODE_HANDLER(SMSG_VOID_TRANSFER_RESULT, STATUS_NEVER, CONNECTION_TYPE_INSTANCE);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_WAIT_QUEUE_FINISH, STATUS_UNHANDLED, CONNECTION_TYPE_REALM);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_WAIT_QUEUE_UPDATE, STATUS_UNHANDLED, CONNECTION_TYPE_REALM);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_WARDEN_DATA, STATUS_UNHANDLED, CONNECTION_TYPE_REALM);
diff --git a/src/server/game/Server/WorldSession.h b/src/server/game/Server/WorldSession.h
index 837f0b42021..ce525420710 100644
--- a/src/server/game/Server/WorldSession.h
+++ b/src/server/game/Server/WorldSession.h
@@ -472,6 +472,14 @@ namespace WorldPackets
class MoveSetVehicleRecIdAck;
}
+ namespace VoidStorage
+ {
+ class UnlockVoidStorage;
+ class QueryVoidStorage;
+ class VoidStorageTransfer;
+ class SwapVoidItem;
+ }
+
namespace Who
{
class WhoIsRequest;
@@ -1390,10 +1398,10 @@ class WorldSession
void HandleSetSavedInstanceExtend(WorldPacket& recvData);
// Void Storage
- void HandleVoidStorageUnlock(WorldPacket& recvData);
- void HandleVoidStorageQuery(WorldPacket& recvData);
- void HandleVoidStorageTransfer(WorldPacket& recvData);
- void HandleVoidSwapItem(WorldPacket& recvData);
+ void HandleVoidStorageUnlock(WorldPackets::VoidStorage::UnlockVoidStorage& unlockVoidStorage);
+ void HandleVoidStorageQuery(WorldPackets::VoidStorage::QueryVoidStorage& queryVoidStorage);
+ void HandleVoidStorageTransfer(WorldPackets::VoidStorage::VoidStorageTransfer& voidStorageTransfer);
+ void HandleVoidSwapItem(WorldPackets::VoidStorage::SwapVoidItem& swapVoidItem);
void SendVoidStorageTransferResult(VoidTransferError result);
// Transmogrification