Core: Updated to 11.2.0
Port From (https://github.com/TrinityCore/TrinityCore/commit/5cf0c6c8bb2c4e58a2d66ba5f304af34d18a4782)
This commit is contained in:
@@ -90,7 +90,6 @@ namespace Game
|
||||
features.BpayStoreAvailable = false;
|
||||
features.BpayStoreDisabledByParentalControls = false;
|
||||
features.CharUndeleteEnabled = WorldConfig.GetBoolValue(WorldCfg.FeatureSystemCharacterUndeleteEnabled);
|
||||
features.BpayStoreEnabled = WorldConfig.GetBoolValue(WorldCfg.FeatureSystemBpayStoreEnabled);
|
||||
features.MaxCharactersOnThisRealm = WorldConfig.GetIntValue(WorldCfg.CharactersPerRealm);
|
||||
features.MinimumExpansionLevel = (int)Expansion.Classic;
|
||||
features.MaximumExpansionLevel = WorldConfig.GetIntValue(WorldCfg.Expansion);
|
||||
|
||||
@@ -7,6 +7,7 @@ using Game.Entities;
|
||||
using Game.Networking;
|
||||
using Game.Networking.Packets;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Game
|
||||
{
|
||||
@@ -127,65 +128,121 @@ namespace Game
|
||||
}
|
||||
}
|
||||
|
||||
[WorldPacketHandler(ClientOpcodes.BuyBankSlot, Processing = PacketProcessing.Inplace)]
|
||||
void HandleBuyBankSlot(BuyBankSlot packet)
|
||||
[WorldPacketHandler(ClientOpcodes.BuyAccountBankTab)]
|
||||
void HandleBuyBankTab(BuyBankTab buyBankTab)
|
||||
{
|
||||
if (!CanUseBank(packet.Guid))
|
||||
if (!CanUseBank(buyBankTab.Banker))
|
||||
{
|
||||
Log.outDebug(LogFilter.Network, "WORLD: HandleBuyBankSlot - {0} not found or you can't interact with him.", packet.Guid.ToString());
|
||||
Log.outDebug(LogFilter.Network, $"WorldSession::HandleBuyBankTab {_player.GetGUID()} - Banker {buyBankTab.Banker} not found or can't interact with him.");
|
||||
return;
|
||||
}
|
||||
|
||||
uint slot = GetPlayer().GetBankBagSlotCount();
|
||||
if (buyBankTab.BankType != BankType.Character)
|
||||
{
|
||||
Log.outDebug(LogFilter.Network, $"WorldSession::HandleBuyBankTab {_player.GetGUID()} - Bank type {buyBankTab.BankType} is not supported.");
|
||||
return;
|
||||
}
|
||||
|
||||
uint itemId = 0;
|
||||
byte slot = 0;
|
||||
byte inventorySlot = 0;
|
||||
|
||||
switch (buyBankTab.BankType)
|
||||
{
|
||||
case BankType.Character:
|
||||
itemId = 242709;
|
||||
slot = _player.GetCharacterBankTabCount();
|
||||
inventorySlot = InventorySlots.BankBagStart;
|
||||
break;
|
||||
case BankType.Account:
|
||||
itemId = 208392;
|
||||
slot = _player.GetAccountBankTabCount();
|
||||
inventorySlot = (byte)AccountBankBagSlots.Start;
|
||||
break;
|
||||
default:
|
||||
Log.outDebug(LogFilter.Network, $"WorldSession::HandleBuyBankTab {_player.GetGUID()} - Bank type {buyBankTab.BankType} is not supported.");
|
||||
return;
|
||||
}
|
||||
// next slot
|
||||
++slot;
|
||||
|
||||
BankBagSlotPricesRecord slotEntry = CliDB.BankBagSlotPricesStorage.LookupByKey(slot);
|
||||
if (slotEntry == null)
|
||||
var bankTab = CliDB.BankTabStorage.FirstOrDefault(record => record.Value.BankType == (byte)buyBankTab.BankType && record.Value.OrderIndex == slot).Value;
|
||||
if (bankTab == null)
|
||||
return;
|
||||
|
||||
uint price = slotEntry.Cost;
|
||||
if (!GetPlayer().HasEnoughMoney(price))
|
||||
return;
|
||||
|
||||
GetPlayer().SetBankBagSlotCount((byte)slot);
|
||||
GetPlayer().ModifyMoney(-price);
|
||||
GetPlayer().UpdateCriteria(CriteriaType.BankSlotsPurchased);
|
||||
}
|
||||
|
||||
[WorldPacketHandler(ClientOpcodes.BuyReagentBank)]
|
||||
void HandleBuyReagentBank(ReagentBank reagentBank)
|
||||
{
|
||||
if (!CanUseBank(reagentBank.Banker))
|
||||
{
|
||||
Log.outDebug(LogFilter.Network, $"WORLD: HandleBuyReagentBankOpcode - {reagentBank.Banker} not found or you can't interact with him.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (_player.IsReagentBankUnlocked())
|
||||
{
|
||||
Log.outDebug(LogFilter.Network, $"WORLD: HandleBuyReagentBankOpcode - Player ({_player.GetGUID()}, name: {_player.GetName()}) tried to unlock reagent bank a 2nd time.");
|
||||
return;
|
||||
}
|
||||
|
||||
long price = 100 * MoneyConstants.Gold;
|
||||
|
||||
ulong price = bankTab.Cost;
|
||||
if (!_player.HasEnoughMoney(price))
|
||||
return;
|
||||
|
||||
InventoryResult msg = _player.CanEquipNewItem(inventorySlot, out ushort inventoryPos, itemId, false);
|
||||
if (msg != InventoryResult.Ok)
|
||||
{
|
||||
Log.outDebug(LogFilter.Network, $"WORLD: HandleBuyReagentBankOpcode - Player ({_player.GetGUID()}, name: {_player.GetName()}) without enough gold.");
|
||||
_player.SendEquipError(msg, null, null, itemId);
|
||||
return;
|
||||
}
|
||||
|
||||
_player.ModifyMoney(-price);
|
||||
_player.UnlockReagentBank();
|
||||
Item bag = _player.EquipNewItem(inventoryPos, itemId, ItemContext.None, true);
|
||||
if (bag == null)
|
||||
return;
|
||||
|
||||
switch (buyBankTab.BankType)
|
||||
{
|
||||
case BankType.Character:
|
||||
_player.SetCharacterBankTabCount(slot);
|
||||
break;
|
||||
case BankType.Account:
|
||||
_player.SetAccountBankTabCount(slot);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
_player.ModifyMoney(-(long)price);
|
||||
|
||||
_player.UpdateCriteria(CriteriaType.BankTabPurchased, (ulong)buyBankTab.BankType);
|
||||
}
|
||||
|
||||
[WorldPacketHandler(ClientOpcodes.DepositReagentBank)]
|
||||
void HandleReagentBankDeposit(ReagentBank reagentBank)
|
||||
[WorldPacketHandler(ClientOpcodes.UpdateAccountBankTabSettings)]
|
||||
void HandleUpdateBankTabSettings(UpdateBankTabSettings updateBankTabSettings)
|
||||
{
|
||||
if (!CanUseBank(reagentBank.Banker))
|
||||
if (!CanUseBank(updateBankTabSettings.Banker))
|
||||
{
|
||||
Log.outDebug(LogFilter.Network, $"WORLD: HandleReagentBankDepositOpcode - {reagentBank.Banker} not found or you can't interact with him.");
|
||||
Log.outDebug(LogFilter.Network, $"WorldSession::HandleUpdateBankTabSettings {_player.GetGUID()} - Banker {updateBankTabSettings.Banker} not found or can't interact with him.");
|
||||
return;
|
||||
}
|
||||
|
||||
switch (updateBankTabSettings.BankType)
|
||||
{
|
||||
case BankType.Character:
|
||||
if (updateBankTabSettings.Tab >= _player.m_activePlayerData.CharacterBankTabSettings.Size())
|
||||
{
|
||||
Log.outDebug(LogFilter.Network, $"WorldSession::HandleUpdateBankTabSettings {_player.GetGUID()} doesn't have bank tab {updateBankTabSettings.Tab} in bank type {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())
|
||||
{
|
||||
Log.outDebug(LogFilter.Network, $"WorldSession::HandleUpdateBankTabSettings {_player.GetGUID()} doesn't have bank tab {updateBankTabSettings.Tab} in bank type {updateBankTabSettings.BankType}.");
|
||||
return;
|
||||
}
|
||||
_player.SetAccountBankTabSettings(updateBankTabSettings.Tab, updateBankTabSettings.Settings.Name,
|
||||
updateBankTabSettings.Settings.Icon, updateBankTabSettings.Settings.Description, updateBankTabSettings.Settings.DepositFlags);
|
||||
break;
|
||||
default:
|
||||
Log.outDebug(LogFilter.Network, $"WorldSession::HandleUpdateBankTabSettings {_player.GetGUID()} - Bank type {updateBankTabSettings.BankType} is not supported.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
[WorldPacketHandler(ClientOpcodes.AutoDepositCharacterBank)]
|
||||
void HandleAutoDepositCharacterBank(AutoDepositCharacterBank autoDepositCharacterBank)
|
||||
{
|
||||
if (!CanUseBank(autoDepositCharacterBank.Banker))
|
||||
{
|
||||
Log.outDebug(LogFilter.Network, $"WORLD: HandleAutoDepositCharacterBank - {autoDepositCharacterBank.Banker} not found or you can't interact with him.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -204,13 +261,13 @@ namespace Game
|
||||
if (msg != InventoryResult.Ok)
|
||||
{
|
||||
if (msg != InventoryResult.ReagentBankFull || !anyDeposited)
|
||||
_player.SendEquipError(msg, item);
|
||||
_player.SendEquipError(msg, item, null);
|
||||
break;
|
||||
}
|
||||
|
||||
if (dest.Count == 1 && dest[0].pos == item.GetPos())
|
||||
{
|
||||
_player.SendEquipError(InventoryResult.CantSwap, item);
|
||||
_player.SendEquipError(InventoryResult.CantSwap, item, null);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -219,90 +276,7 @@ namespace Game
|
||||
_player.BankItem(dest, item, true);
|
||||
anyDeposited = true;
|
||||
}
|
||||
}
|
||||
|
||||
[WorldPacketHandler(ClientOpcodes.AutobankReagent)]
|
||||
void HandleAutoBankReagent(AutoBankReagent autoBankReagent)
|
||||
{
|
||||
if (!CanUseBank())
|
||||
{
|
||||
Log.outDebug(LogFilter.Network, $"WORLD: HandleAutoBankReagentOpcode - {_player.PlayerTalkClass.GetInteractionData().SourceGuid} not found or you can't interact with him.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_player.IsReagentBankUnlocked())
|
||||
{
|
||||
_player.SendEquipError(InventoryResult.ReagentBankLocked);
|
||||
return;
|
||||
}
|
||||
|
||||
Item item = _player.GetItemByPos(autoBankReagent.PackSlot, autoBankReagent.Slot);
|
||||
if (item == null)
|
||||
return;
|
||||
|
||||
List<ItemPosCount> dest = new();
|
||||
InventoryResult msg = _player.CanBankItem(ItemConst.NullBag, ItemConst.NullSlot, dest, item, false, true, true);
|
||||
if (msg != InventoryResult.Ok)
|
||||
{
|
||||
_player.SendEquipError(msg, item);
|
||||
return;
|
||||
}
|
||||
|
||||
if (dest.Count == 1 && dest[0].pos == item.GetPos())
|
||||
{
|
||||
_player.SendEquipError(InventoryResult.CantSwap, item);
|
||||
return;
|
||||
}
|
||||
|
||||
_player.RemoveItem(autoBankReagent.PackSlot, autoBankReagent.Slot, true);
|
||||
_player.BankItem(dest, item, true);
|
||||
}
|
||||
|
||||
[WorldPacketHandler(ClientOpcodes.AutostoreBankReagent)]
|
||||
void HandleAutoStoreBankReagent(AutoStoreBankReagent autoStoreBankReagent)
|
||||
{
|
||||
if (!CanUseBank())
|
||||
{
|
||||
Log.outDebug(LogFilter.Network, $"WORLD: HandleAutoBankReagentOpcode - {_player.PlayerTalkClass.GetInteractionData().SourceGuid} not found or you can't interact with him.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_player.IsReagentBankUnlocked())
|
||||
{
|
||||
_player.SendEquipError(InventoryResult.ReagentBankLocked);
|
||||
return;
|
||||
}
|
||||
|
||||
Item pItem = _player.GetItemByPos(autoStoreBankReagent.Slot, autoStoreBankReagent.PackSlot);
|
||||
if (pItem == null)
|
||||
return;
|
||||
|
||||
if (Player.IsReagentBankPos(autoStoreBankReagent.Slot, autoStoreBankReagent.PackSlot))
|
||||
{
|
||||
List<ItemPosCount> dest = new();
|
||||
InventoryResult msg = _player.CanStoreItem(ItemConst.NullBag, ItemConst.NullSlot, dest, pItem, false);
|
||||
if (msg != InventoryResult.Ok)
|
||||
{
|
||||
_player.SendEquipError(msg, pItem);
|
||||
return;
|
||||
}
|
||||
|
||||
_player.RemoveItem(autoStoreBankReagent.Slot, autoStoreBankReagent.PackSlot, true);
|
||||
_player.StoreItem(dest, pItem, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
List<ItemPosCount> dest = new();
|
||||
InventoryResult msg = _player.CanBankItem(ItemConst.NullBag, ItemConst.NullSlot, dest, pItem, false, true, true);
|
||||
if (msg != InventoryResult.Ok)
|
||||
{
|
||||
_player.SendEquipError(msg, pItem);
|
||||
return;
|
||||
}
|
||||
|
||||
_player.RemoveItem(autoStoreBankReagent.Slot, autoStoreBankReagent.PackSlot, true);
|
||||
_player.BankItem(dest, pItem, true);
|
||||
}
|
||||
}
|
||||
|
||||
public void SendShowBank(ObjectGuid guid, PlayerInteractionType interactionType)
|
||||
|
||||
@@ -1144,7 +1144,6 @@ namespace Game
|
||||
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
|
||||
|
||||
EuropaTicketConfig europaTicketSystemStatus = new();
|
||||
europaTicketSystemStatus.ThrottleState.MaxTries = 10;
|
||||
@@ -1163,7 +1162,6 @@ namespace Game
|
||||
features.EuropaTicketSystemStatus = europaTicketSystemStatus;
|
||||
|
||||
features.CharUndeleteEnabled = WorldConfig.GetBoolValue(WorldCfg.FeatureSystemCharacterUndeleteEnabled);
|
||||
features.BpayStoreEnabled = WorldConfig.GetBoolValue(WorldCfg.FeatureSystemBpayStoreEnabled);
|
||||
features.WarModeEnabled = WorldConfig.GetBoolValue(WorldCfg.FeatureSystemWarModeEnabled);
|
||||
features.IsChatMuted = !CanSpeak();
|
||||
|
||||
@@ -2796,10 +2794,6 @@ namespace Game
|
||||
stmt.AddValue(0, lowGuid);
|
||||
SetQuery(PlayerLoginQueryLoad.AzeriteEmpowered, stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CharStatements.SEL_CHAR_VOID_STORAGE);
|
||||
stmt.AddValue(0, lowGuid);
|
||||
SetQuery(PlayerLoginQueryLoad.VoidStorage, stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CharStatements.SEL_MAIL);
|
||||
stmt.AddValue(0, lowGuid);
|
||||
SetQuery(PlayerLoginQueryLoad.Mails, stmt);
|
||||
@@ -2966,6 +2960,10 @@ namespace Game
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CharStatements.SEL_PLAYER_DATA_FLAGS_CHARACTER);
|
||||
stmt.AddValue(0, lowGuid);
|
||||
SetQuery(PlayerLoginQueryLoad.DataFlags, stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CharStatements.SEL_CHARACTER_BANK_TAB_SETTINGS);
|
||||
stmt.AddValue(0, lowGuid);
|
||||
SetQuery(PlayerLoginQueryLoad.BankTabSettings, stmt);
|
||||
}
|
||||
|
||||
public ObjectGuid GetGuid() { return m_guid; }
|
||||
@@ -3060,7 +3058,6 @@ namespace Game
|
||||
InstanceLockTimes,
|
||||
SeasonalQuestStatus,
|
||||
MonthlyQuestStatus,
|
||||
VoidStorage,
|
||||
Currency,
|
||||
CufProfiles,
|
||||
CorpseLocation,
|
||||
@@ -3074,6 +3071,7 @@ namespace Game
|
||||
TraitConfigs,
|
||||
DataElements,
|
||||
DataFlags,
|
||||
BankTabSettings,
|
||||
Max
|
||||
}
|
||||
|
||||
|
||||
@@ -1097,14 +1097,6 @@ namespace Game
|
||||
SendPacket(new BagCleanupFinished());
|
||||
}
|
||||
|
||||
[WorldPacketHandler(ClientOpcodes.SortReagentBankBags, Processing = PacketProcessing.Inplace)]
|
||||
void HandleSortReagentBankBags(SortReagentBankBags sortReagentBankBags)
|
||||
{
|
||||
// TODO: Implement sorting
|
||||
// Placeholder to prevent completely locking out bags clientside
|
||||
SendPacket(new BagCleanupFinished());
|
||||
}
|
||||
|
||||
[WorldPacketHandler(ClientOpcodes.RemoveNewItem, Processing = PacketProcessing.Inplace)]
|
||||
void HandleRemoveNewItem(RemoveNewItem removeNewItem)
|
||||
{
|
||||
@@ -1134,18 +1126,6 @@ namespace Game
|
||||
_player.RemoveBagSlotFlag(changeBagSlotFlag.BagIndex, changeBagSlotFlag.FlagToChange);
|
||||
}
|
||||
|
||||
[WorldPacketHandler(ClientOpcodes.ChangeBankBagSlotFlag, Processing = PacketProcessing.Inplace)]
|
||||
void HandleChangeBankBagSlotFlag(ChangeBankBagSlotFlag changeBankBagSlotFlag)
|
||||
{
|
||||
if (changeBankBagSlotFlag.BagIndex >= _player.m_activePlayerData.BankBagSlotFlags.GetSize())
|
||||
return;
|
||||
|
||||
if (changeBankBagSlotFlag.On)
|
||||
_player.SetBankBagSlotFlag(changeBankBagSlotFlag.BagIndex, changeBankBagSlotFlag.FlagToChange);
|
||||
else
|
||||
_player.RemoveBankBagSlotFlag(changeBankBagSlotFlag.BagIndex, changeBankBagSlotFlag.FlagToChange);
|
||||
}
|
||||
|
||||
[WorldPacketHandler(ClientOpcodes.SetBackpackAutosortDisabled, Processing = PacketProcessing.Inplace)]
|
||||
void HandleSetBackpackAutosortDisabled(SetBackpackAutosortDisabled setBackpackAutosortDisabled)
|
||||
{
|
||||
|
||||
@@ -301,7 +301,16 @@ namespace Game
|
||||
SendTradeStatus(info);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Player.IsAccountBankPos(item.GetSlot(), item.GetBagSlot()))
|
||||
{
|
||||
info.Status = TradeStatus.Failed;
|
||||
info.BagResult = InventoryResult.CantTradeAccountItem;
|
||||
SendTradeStatus(info);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
item = his_trade.GetItem((TradeSlots)i);
|
||||
if (item != null)
|
||||
{
|
||||
@@ -312,6 +321,14 @@ namespace Game
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (Player.IsAccountBankPos(item.GetSlot(), item.GetBagSlot()))
|
||||
{
|
||||
info.Status = TradeStatus.Failed;
|
||||
info.BagResult = InventoryResult.CantTradeAccountItem;
|
||||
SendTradeStatus(info);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (his_trade.IsAccepted())
|
||||
|
||||
@@ -1,230 +0,0 @@
|
||||
// Copyright (c) CypherCore <http://github.com/CypherCore> All rights reserved.
|
||||
// Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE file in the project root for full license information.
|
||||
|
||||
using Framework.Constants;
|
||||
using Game.Entities;
|
||||
using Game.Networking;
|
||||
using Game.Networking.Packets;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Game
|
||||
{
|
||||
public partial class WorldSession
|
||||
{
|
||||
public void SendVoidStorageTransferResult(VoidTransferError result)
|
||||
{
|
||||
SendPacket(new VoidTransferResult(result));
|
||||
}
|
||||
|
||||
[WorldPacketHandler(ClientOpcodes.UnlockVoidStorage, Processing = PacketProcessing.Inplace)]
|
||||
void HandleVoidStorageUnlock(UnlockVoidStorage unlockVoidStorage)
|
||||
{
|
||||
Creature unit = GetPlayer().GetNPCIfCanInteractWith(unlockVoidStorage.Npc, NPCFlags.VaultKeeper, NPCFlags2.None);
|
||||
if (unit == null)
|
||||
{
|
||||
Log.outDebug(LogFilter.Network, "WORLD: HandleVoidStorageUnlock - {0} not found or player can't interact with it.", unlockVoidStorage.Npc.ToString());
|
||||
return;
|
||||
}
|
||||
|
||||
if (GetPlayer().IsVoidStorageUnlocked())
|
||||
{
|
||||
Log.outDebug(LogFilter.Network, "WORLD: HandleVoidStorageUnlock - Player({0}, name: {1}) tried to unlock void storage a 2nd time.", GetPlayer().GetGUID().ToString(), GetPlayer().GetName());
|
||||
return;
|
||||
}
|
||||
|
||||
GetPlayer().ModifyMoney(-SharedConst.VoidStorageUnlockCost);
|
||||
GetPlayer().UnlockVoidStorage();
|
||||
}
|
||||
|
||||
[WorldPacketHandler(ClientOpcodes.QueryVoidStorage, Processing = PacketProcessing.Inplace)]
|
||||
void HandleVoidStorageQuery(QueryVoidStorage queryVoidStorage)
|
||||
{
|
||||
Player player = GetPlayer();
|
||||
|
||||
Creature unit = player.GetNPCIfCanInteractWith(queryVoidStorage.Npc, NPCFlags.Transmogrifier | NPCFlags.VaultKeeper, NPCFlags2.None);
|
||||
if (unit == null)
|
||||
{
|
||||
Log.outDebug(LogFilter.Network, "WORLD: HandleVoidStorageQuery - {0} not found or player can't interact with it.", queryVoidStorage.Npc.ToString());
|
||||
SendPacket(new VoidStorageFailed());
|
||||
return;
|
||||
}
|
||||
|
||||
if (!GetPlayer().IsVoidStorageUnlocked())
|
||||
{
|
||||
Log.outDebug(LogFilter.Network, "WORLD: HandleVoidStorageQuery - {0} name: {1} queried void storage without unlocking it.", player.GetGUID().ToString(), player.GetName());
|
||||
SendPacket(new VoidStorageFailed());
|
||||
return;
|
||||
}
|
||||
|
||||
VoidStorageContents voidStorageContents = new();
|
||||
for (byte i = 0; i < SharedConst.VoidStorageMaxSlot; ++i)
|
||||
{
|
||||
VoidStorageItem item = player.GetVoidStorageItem(i);
|
||||
if (item == null)
|
||||
continue;
|
||||
|
||||
VoidItem voidItem = new();
|
||||
voidItem.Guid = ObjectGuid.Create(HighGuid.Item, item.ItemId);
|
||||
voidItem.Creator = item.CreatorGuid;
|
||||
voidItem.Slot = i;
|
||||
voidItem.Item = new ItemInstance(item);
|
||||
|
||||
voidStorageContents.Items.Add(voidItem);
|
||||
}
|
||||
|
||||
SendPacket(voidStorageContents);
|
||||
}
|
||||
|
||||
[WorldPacketHandler(ClientOpcodes.VoidStorageTransfer)]
|
||||
void HandleVoidStorageTransfer(VoidStorageTransfer voidStorageTransfer)
|
||||
{
|
||||
Player player = GetPlayer();
|
||||
|
||||
Creature unit = player.GetNPCIfCanInteractWith(voidStorageTransfer.Npc, NPCFlags.VaultKeeper, NPCFlags2.None);
|
||||
if (unit == null)
|
||||
{
|
||||
Log.outDebug(LogFilter.Network, "WORLD: HandleVoidStorageTransfer - {0} not found or player can't interact with it.", voidStorageTransfer.Npc.ToString());
|
||||
return;
|
||||
}
|
||||
|
||||
if (!player.IsVoidStorageUnlocked())
|
||||
{
|
||||
Log.outDebug(LogFilter.Network, "WORLD: HandleVoidStorageTransfer - Player ({0}, name: {1}) queried void storage without unlocking it.", player.GetGUID().ToString(), player.GetName());
|
||||
return;
|
||||
}
|
||||
|
||||
if (voidStorageTransfer.Deposits.Length > player.GetNumOfVoidStorageFreeSlots())
|
||||
{
|
||||
SendVoidStorageTransferResult(VoidTransferError.Full);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!voidStorageTransfer.Withdrawals.Empty() && voidStorageTransfer.Withdrawals.Length > _player.GetFreeInventorySlotCount(ItemSearchLocation.Inventory))
|
||||
{
|
||||
SendVoidStorageTransferResult(VoidTransferError.InventoryFull);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!player.HasEnoughMoney((voidStorageTransfer.Deposits.Length * SharedConst.VoidStorageStoreItemCost)))
|
||||
{
|
||||
SendVoidStorageTransferResult(VoidTransferError.NotEnoughMoney);
|
||||
return;
|
||||
}
|
||||
|
||||
VoidStorageTransferChanges voidStorageTransferChanges = new();
|
||||
|
||||
byte depositCount = 0;
|
||||
for (int i = 0; i < voidStorageTransfer.Deposits.Length; ++i)
|
||||
{
|
||||
Item item = player.GetItemByGuid(voidStorageTransfer.Deposits[i]);
|
||||
if (item == null)
|
||||
{
|
||||
Log.outDebug(LogFilter.Network, "WORLD: HandleVoidStorageTransfer - {0} {1} wants to deposit an invalid item ({2}).", player.GetGUID().ToString(), player.GetName(), voidStorageTransfer.Deposits[i].ToString());
|
||||
continue;
|
||||
}
|
||||
|
||||
VoidStorageItem itemVS = new(Global.ObjectMgr.GenerateVoidStorageItemId(), item.GetEntry(), item.GetCreator(),
|
||||
item.GetItemRandomBonusListId(), item.GetModifier(ItemModifier.TimewalkerLevel), item.GetModifier(ItemModifier.ArtifactKnowledgeLevel),
|
||||
item.GetContext(), item.GetBonusListIDs());
|
||||
|
||||
VoidItem voidItem;
|
||||
voidItem.Guid = ObjectGuid.Create(HighGuid.Item, itemVS.ItemId);
|
||||
voidItem.Creator = item.GetCreator();
|
||||
voidItem.Item = new ItemInstance(itemVS);
|
||||
voidItem.Slot = _player.AddVoidStorageItem(itemVS);
|
||||
|
||||
voidStorageTransferChanges.AddedItems.Add(voidItem);
|
||||
|
||||
player.DestroyItem(item.GetBagSlot(), item.GetSlot(), true);
|
||||
++depositCount;
|
||||
}
|
||||
|
||||
long cost = depositCount * SharedConst.VoidStorageStoreItemCost;
|
||||
|
||||
player.ModifyMoney(-cost);
|
||||
|
||||
for (int i = 0; i < voidStorageTransfer.Withdrawals.Length; ++i)
|
||||
{
|
||||
byte slot;
|
||||
VoidStorageItem itemVS = player.GetVoidStorageItem(voidStorageTransfer.Withdrawals[i].GetCounter(), out slot);
|
||||
if (itemVS == null)
|
||||
{
|
||||
Log.outDebug(LogFilter.Network, "WORLD: HandleVoidStorageTransfer - {0} {1} tried to withdraw an invalid item ({2})", player.GetGUID().ToString(), player.GetName(), voidStorageTransfer.Withdrawals[i].ToString());
|
||||
continue;
|
||||
}
|
||||
|
||||
List<ItemPosCount> dest = new();
|
||||
InventoryResult msg = player.CanStoreNewItem(ItemConst.NullBag, ItemConst.NullSlot, dest, itemVS.ItemEntry, 1);
|
||||
if (msg != InventoryResult.Ok)
|
||||
{
|
||||
SendVoidStorageTransferResult(VoidTransferError.InventoryFull);
|
||||
Log.outDebug(LogFilter.Network, "WORLD: HandleVoidStorageTransfer - {0} {1} couldn't withdraw {2} because inventory was full.", player.GetGUID().ToString(), player.GetName(), voidStorageTransfer.Withdrawals[i].ToString());
|
||||
return;
|
||||
}
|
||||
|
||||
Item item = player.StoreNewItem(dest, itemVS.ItemEntry, true, itemVS.RandomBonusListId, null, itemVS.Context, itemVS.BonusListIDs);
|
||||
if (item != null)
|
||||
{
|
||||
item.SetCreator(itemVS.CreatorGuid);
|
||||
item.SetBinding(true);
|
||||
GetCollectionMgr().AddItemAppearance(item);
|
||||
}
|
||||
|
||||
voidStorageTransferChanges.RemovedItems.Add(ObjectGuid.Create(HighGuid.Item, itemVS.ItemId));
|
||||
|
||||
player.DeleteVoidStorageItem(slot);
|
||||
}
|
||||
|
||||
SendPacket(voidStorageTransferChanges);
|
||||
SendVoidStorageTransferResult(VoidTransferError.Ok);
|
||||
}
|
||||
|
||||
[WorldPacketHandler(ClientOpcodes.SwapVoidItem, Processing = PacketProcessing.Inplace)]
|
||||
void HandleVoidSwapItem(SwapVoidItem swapVoidItem)
|
||||
{
|
||||
Player player = GetPlayer();
|
||||
|
||||
Creature unit = player.GetNPCIfCanInteractWith(swapVoidItem.Npc, NPCFlags.VaultKeeper, NPCFlags2.None);
|
||||
if (unit == null)
|
||||
{
|
||||
Log.outDebug(LogFilter.Network, "WORLD: HandleVoidSwapItem - {0} not found or player can't interact with it.", swapVoidItem.Npc.ToString());
|
||||
return;
|
||||
}
|
||||
|
||||
if (!player.IsVoidStorageUnlocked())
|
||||
{
|
||||
Log.outDebug(LogFilter.Network, "WORLD: HandleVoidSwapItem - Player ({0}, name: {1}) queried void storage without unlocking it.", player.GetGUID().ToString(), player.GetName());
|
||||
return;
|
||||
}
|
||||
|
||||
byte oldSlot;
|
||||
if (player.GetVoidStorageItem(swapVoidItem.VoidItemGuid.GetCounter(), out oldSlot) == null)
|
||||
{
|
||||
Log.outDebug(LogFilter.Network, "WORLD: HandleVoidSwapItem - Player (GUID: {0}, name: {1}) requested swapping an invalid item (slot: {2}, itemid: {3}).", player.GetGUID().ToString(), player.GetName(), swapVoidItem.DstSlot, swapVoidItem.VoidItemGuid.ToString());
|
||||
return;
|
||||
}
|
||||
|
||||
bool usedDestSlot = player.GetVoidStorageItem((byte)swapVoidItem.DstSlot) != null;
|
||||
ObjectGuid itemIdDest = ObjectGuid.Empty;
|
||||
if (usedDestSlot)
|
||||
itemIdDest = ObjectGuid.Create(HighGuid.Item, player.GetVoidStorageItem((byte)swapVoidItem.DstSlot).ItemId);
|
||||
|
||||
if (!player.SwapVoidStorageItem(oldSlot, (byte)swapVoidItem.DstSlot))
|
||||
{
|
||||
SendVoidStorageTransferResult(VoidTransferError.InternalError1);
|
||||
return;
|
||||
}
|
||||
|
||||
VoidItemSwapResponse voidItemSwapResponse = new();
|
||||
voidItemSwapResponse.VoidItemA = swapVoidItem.VoidItemGuid;
|
||||
voidItemSwapResponse.VoidItemSlotA = swapVoidItem.DstSlot;
|
||||
if (usedDestSlot)
|
||||
{
|
||||
voidItemSwapResponse.VoidItemB = itemIdDest;
|
||||
voidItemSwapResponse.VoidItemSlotB = oldSlot;
|
||||
}
|
||||
|
||||
SendPacket(voidItemSwapResponse);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user