Core/Items: Implemented packets setting up inventory cleanup parameters
Port From (https://github.com/TrinityCore/TrinityCore/commit/cc9241784491198581a19f3f5502a42d048ea063)
This commit is contained in:
@@ -2828,7 +2828,17 @@ namespace Game.Entities
|
||||
uint xp = result.Read<uint>(fieldIndex++);
|
||||
ulong money = result.Read<ulong>(fieldIndex++);
|
||||
byte inventorySlots = result.Read<byte>(fieldIndex++);
|
||||
BagSlotFlags inventoryBagFlags = (BagSlotFlags)result.Read<uint>(fieldIndex++);
|
||||
BagSlotFlags[] bagSlotFlags = new BagSlotFlags[5];
|
||||
for (var i = 0; i < bagSlotFlags.Length; ++i)
|
||||
bagSlotFlags[i] = (BagSlotFlags)result.Read<uint>(fieldIndex++);
|
||||
|
||||
byte bankSlots = result.Read<byte>(fieldIndex++);
|
||||
BagSlotFlags[] bankBagSlotFlags = new BagSlotFlags[7];
|
||||
BagSlotFlags bankBagFlags = (BagSlotFlags)result.Read<uint>(fieldIndex++);
|
||||
for (var i = 0; i < bankBagSlotFlags.Length; ++i)
|
||||
bankBagSlotFlags[i] = (BagSlotFlags)result.Read<uint>(fieldIndex++);
|
||||
|
||||
PlayerRestState restState = (PlayerRestState)result.Read<byte>(fieldIndex++);
|
||||
PlayerFlags playerFlags = (PlayerFlags)result.Read<uint>(fieldIndex++);
|
||||
PlayerFlagsEx playerFlagsEx = (PlayerFlagsEx)result.Read<uint>(fieldIndex++);
|
||||
@@ -2991,7 +3001,16 @@ namespace Game.Entities
|
||||
|
||||
SetCustomizations(customizations, false);
|
||||
SetInventorySlotCount(inventorySlots);
|
||||
SetBackpackAutoSortDisabled(inventoryBagFlags.HasFlag(BagSlotFlags.DisableAutoSort));
|
||||
SetBackpackSellJunkDisabled(inventoryBagFlags.HasFlag(BagSlotFlags.ExcludeJunkSell));
|
||||
for (int bagIndex = 0; bagIndex < bagSlotFlags.Length; ++bagIndex)
|
||||
ReplaceAllBagSlotFlags(bagIndex, bagSlotFlags[bagIndex]);
|
||||
|
||||
SetBankBagSlotCount(bankSlots);
|
||||
SetBankAutoSortDisabled(bankBagFlags.HasFlag(BagSlotFlags.DisableAutoSort));
|
||||
for (int bagIndex = 0; bagIndex < bankBagSlotFlags.Length; ++bagIndex)
|
||||
ReplaceAllBankBagSlotFlags(bagIndex, bankBagSlotFlags[bagIndex]);
|
||||
|
||||
SetNativeGender(gender);
|
||||
SetUpdateFieldValue(m_values.ModifyValue(m_playerData).ModifyValue(m_playerData.Inebriation), drunk);
|
||||
ReplaceAllPlayerFlags(playerFlags);
|
||||
@@ -3677,7 +3696,24 @@ namespace Game.Entities
|
||||
stmt.AddValue(index++, GetXP());
|
||||
stmt.AddValue(index++, GetMoney());
|
||||
stmt.AddValue(index++, GetInventorySlotCount());
|
||||
|
||||
BagSlotFlags inventoryFlags = BagSlotFlags.None;
|
||||
if (m_activePlayerData.BackpackAutoSortDisabled)
|
||||
inventoryFlags |= BagSlotFlags.DisableAutoSort;
|
||||
if (m_activePlayerData.BackpackSellJunkDisabled)
|
||||
inventoryFlags |= BagSlotFlags.ExcludeJunkSell;
|
||||
stmt.AddValue(index++, (uint)inventoryFlags);
|
||||
foreach (uint bagSlotFlag in m_activePlayerData.BagSlotFlags)
|
||||
stmt.AddValue(index++, bagSlotFlag);
|
||||
stmt.AddValue(index++, GetBankBagSlotCount());
|
||||
|
||||
inventoryFlags = BagSlotFlags.None;
|
||||
if (m_activePlayerData.BankAutoSortDisabled)
|
||||
inventoryFlags |= BagSlotFlags.DisableAutoSort;
|
||||
stmt.AddValue(index++, (uint)inventoryFlags);
|
||||
foreach (uint bankBagSlotFlag in m_activePlayerData.BankBagSlotFlags)
|
||||
stmt.AddValue(index++, bankBagSlotFlag);
|
||||
|
||||
stmt.AddValue(index++, m_activePlayerData.RestInfo[(int)RestTypes.XP].StateID);
|
||||
stmt.AddValue(index++, m_playerData.PlayerFlags);
|
||||
stmt.AddValue(index++, m_playerData.PlayerFlagsEx);
|
||||
@@ -3791,7 +3827,24 @@ namespace Game.Entities
|
||||
stmt.AddValue(index++, GetXP());
|
||||
stmt.AddValue(index++, GetMoney());
|
||||
stmt.AddValue(index++, GetInventorySlotCount());
|
||||
|
||||
BagSlotFlags inventoryFlags = BagSlotFlags.None;
|
||||
if (m_activePlayerData.BackpackAutoSortDisabled)
|
||||
inventoryFlags |= BagSlotFlags.DisableAutoSort;
|
||||
if (m_activePlayerData.BackpackSellJunkDisabled)
|
||||
inventoryFlags |= BagSlotFlags.ExcludeJunkSell;
|
||||
stmt.AddValue(index++, (uint)inventoryFlags);
|
||||
foreach (uint bagSlotFlag in m_activePlayerData.BagSlotFlags)
|
||||
stmt.AddValue(index++, bagSlotFlag);
|
||||
stmt.AddValue(index++, GetBankBagSlotCount());
|
||||
|
||||
inventoryFlags = BagSlotFlags.None;
|
||||
if (m_activePlayerData.BankAutoSortDisabled)
|
||||
inventoryFlags |= BagSlotFlags.DisableAutoSort;
|
||||
stmt.AddValue(index++, (uint)inventoryFlags);
|
||||
foreach (uint bankBagSlotFlag in m_activePlayerData.BankBagSlotFlags)
|
||||
stmt.AddValue(index++, bankBagSlotFlag);
|
||||
|
||||
stmt.AddValue(index++, m_activePlayerData.RestInfo[(int)RestTypes.XP].StateID);
|
||||
stmt.AddValue(index++, m_playerData.PlayerFlags);
|
||||
stmt.AddValue(index++, m_playerData.PlayerFlagsEx);
|
||||
|
||||
@@ -6069,6 +6069,21 @@ namespace Game.Entities
|
||||
public byte GetBankBagSlotCount() { return m_activePlayerData.NumBankSlots; }
|
||||
public void SetBankBagSlotCount(byte count) { SetUpdateFieldValue(m_values.ModifyValue(m_activePlayerData).ModifyValue(m_activePlayerData.NumBankSlots), count); }
|
||||
|
||||
public bool IsBackpackAutoSortDisabled() { return m_activePlayerData.BackpackAutoSortDisabled; }
|
||||
public void SetBackpackAutoSortDisabled(bool disabled) { SetUpdateFieldValue(m_values.ModifyValue(m_activePlayerData).ModifyValue(m_activePlayerData.BackpackAutoSortDisabled), disabled); }
|
||||
public bool IsBackpackSellJunkDisabled() { return m_activePlayerData.BackpackSellJunkDisabled; }
|
||||
public void SetBackpackSellJunkDisabled(bool disabled) { SetUpdateFieldValue(m_values.ModifyValue(m_activePlayerData).ModifyValue(m_activePlayerData.BackpackSellJunkDisabled), disabled); }
|
||||
public bool IsBankAutoSortDisabled() { return m_activePlayerData.BankAutoSortDisabled; }
|
||||
public void SetBankAutoSortDisabled(bool disabled) { SetUpdateFieldValue(m_values.ModifyValue(m_activePlayerData).ModifyValue(m_activePlayerData.BankAutoSortDisabled), disabled); }
|
||||
public BagSlotFlags GetBagSlotFlags(int bagIndex) { return (BagSlotFlags)m_activePlayerData.BagSlotFlags[bagIndex]; }
|
||||
public void SetBagSlotFlag(int bagIndex, BagSlotFlags flags) { SetUpdateFieldFlagValue(ref m_values.ModifyValue(m_activePlayerData).ModifyValue(m_activePlayerData.BagSlotFlags, bagIndex), (uint)flags); }
|
||||
public void RemoveBagSlotFlag(int bagIndex, BagSlotFlags flags) { RemoveUpdateFieldFlagValue(ref m_values.ModifyValue(m_activePlayerData).ModifyValue(m_activePlayerData.BagSlotFlags, bagIndex), (uint)flags); }
|
||||
public void ReplaceAllBagSlotFlags(int bagIndex, BagSlotFlags flags) { SetUpdateFieldValue(ref m_values.ModifyValue(m_activePlayerData).ModifyValue(m_activePlayerData.BagSlotFlags, bagIndex), (uint)flags); }
|
||||
public BagSlotFlags GetBankBagSlotFlags(int bagIndex) { return (BagSlotFlags)m_activePlayerData.BankBagSlotFlags[bagIndex]; }
|
||||
public void SetBankBagSlotFlag(int bagIndex, BagSlotFlags flags) { SetUpdateFieldFlagValue(ref m_values.ModifyValue(m_activePlayerData).ModifyValue(m_activePlayerData.BankBagSlotFlags, bagIndex), (uint)flags); }
|
||||
public void RemoveBankBagSlotFlag(int bagIndex, BagSlotFlags flags) { RemoveUpdateFieldFlagValue(ref m_values.ModifyValue(m_activePlayerData).ModifyValue(m_activePlayerData.BankBagSlotFlags, bagIndex), (uint)flags); }
|
||||
public void ReplaceAllBankBagSlotFlags(int bagIndex, BagSlotFlags flags) { SetUpdateFieldValue(ref m_values.ModifyValue(m_activePlayerData).ModifyValue(m_activePlayerData.BankBagSlotFlags, bagIndex), (uint)flags); }
|
||||
|
||||
//Loot
|
||||
public ObjectGuid GetLootGUID() { return m_playerData.LootTargetGUID; }
|
||||
public void SetLootGUID(ObjectGuid guid) { SetUpdateFieldValue(m_values.ModifyValue(m_playerData).ModifyValue(m_playerData.LootTargetGUID), guid); }
|
||||
|
||||
@@ -609,7 +609,7 @@ namespace Game
|
||||
|
||||
public void SendEnchantmentLog(ObjectGuid owner, ObjectGuid caster, ObjectGuid itemGuid, uint itemId, uint enchantId, uint enchantSlot)
|
||||
{
|
||||
EnchantmentLog packet = new();
|
||||
EnchantmentLog packet = new();
|
||||
packet.Owner = owner;
|
||||
packet.Caster = caster;
|
||||
packet.ItemGUID = itemGuid;
|
||||
@@ -822,7 +822,7 @@ namespace Game
|
||||
|
||||
if (i != firstPrismatic)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Gem must match socket color
|
||||
if (ItemConst.SocketColorToGemTypeMask[(int)itemTarget.GetSocketColor(i)] != gemProperties[i].Type)
|
||||
@@ -1099,5 +1099,47 @@ namespace Game
|
||||
item.SetState(ItemUpdateState.Changed, _player);
|
||||
}
|
||||
}
|
||||
|
||||
[WorldPacketHandler(ClientOpcodes.ChangeBagSlotFlag, Processing = PacketProcessing.Inplace)]
|
||||
void HandleChangeBagSlotFlag(ChangeBagSlotFlag changeBagSlotFlag)
|
||||
{
|
||||
if (changeBagSlotFlag.BagIndex >= _player.m_activePlayerData.BagSlotFlags.GetSize())
|
||||
return;
|
||||
|
||||
if (changeBagSlotFlag.On)
|
||||
_player.SetBagSlotFlag(changeBagSlotFlag.BagIndex, changeBagSlotFlag.FlagToChange);
|
||||
else
|
||||
_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)
|
||||
{
|
||||
_player.SetBackpackAutoSortDisabled(setBackpackAutosortDisabled.Disable);
|
||||
}
|
||||
|
||||
[WorldPacketHandler(ClientOpcodes.SetBackpackSellJunkDisabled, Processing = PacketProcessing.Inplace)]
|
||||
void HandleSetBackpackSellJunkDisabled(SetBackpackSellJunkDisabled setBackpackSellJunkDisabled)
|
||||
{
|
||||
_player.SetBackpackSellJunkDisabled(setBackpackSellJunkDisabled.Disable);
|
||||
}
|
||||
|
||||
[WorldPacketHandler(ClientOpcodes.SetBankAutosortDisabled, Processing = PacketProcessing.Inplace)]
|
||||
void HandleSetBankAutosortDisabled(SetBankAutosortDisabled setBankAutosortDisabled)
|
||||
{
|
||||
_player.SetBankAutoSortDisabled(setBankAutosortDisabled.Disable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,11 +2,10 @@
|
||||
// Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE file in the project root for full license information.
|
||||
|
||||
using Framework.Constants;
|
||||
using Framework.Dynamic;
|
||||
using Game.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System;
|
||||
|
||||
namespace Game.Networking.Packets
|
||||
{
|
||||
@@ -682,6 +681,76 @@ namespace Game.Networking.Packets
|
||||
public override void Write() { }
|
||||
}
|
||||
|
||||
class ChangeBagSlotFlag : ClientPacket
|
||||
{
|
||||
public int BagIndex;
|
||||
public BagSlotFlags FlagToChange;
|
||||
public bool On;
|
||||
|
||||
public ChangeBagSlotFlag(WorldPacket packet) : base(packet) { }
|
||||
|
||||
public override void Read()
|
||||
{
|
||||
BagIndex = _worldPacket.ReadInt32();
|
||||
FlagToChange = (BagSlotFlags)_worldPacket.ReadUInt32();
|
||||
On = _worldPacket.HasBit();
|
||||
}
|
||||
}
|
||||
|
||||
class ChangeBankBagSlotFlag : ClientPacket
|
||||
{
|
||||
public int BagIndex;
|
||||
public BagSlotFlags FlagToChange;
|
||||
public bool On;
|
||||
|
||||
public ChangeBankBagSlotFlag(WorldPacket packet) : base(packet) { }
|
||||
|
||||
public override void Read()
|
||||
{
|
||||
BagIndex = _worldPacket.ReadInt32();
|
||||
FlagToChange = (BagSlotFlags)_worldPacket.ReadUInt32();
|
||||
On = _worldPacket.HasBit();
|
||||
}
|
||||
}
|
||||
|
||||
class SetBackpackAutosortDisabled : ClientPacket
|
||||
{
|
||||
public bool Disable;
|
||||
|
||||
public SetBackpackAutosortDisabled(WorldPacket packet) : base(packet) { }
|
||||
|
||||
public override void Read()
|
||||
{
|
||||
Disable = _worldPacket.HasBit();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class SetBackpackSellJunkDisabled : ClientPacket
|
||||
{
|
||||
public bool Disable;
|
||||
|
||||
public SetBackpackSellJunkDisabled(WorldPacket packet) : base(packet) { }
|
||||
|
||||
public override void Read()
|
||||
{
|
||||
Disable = _worldPacket.HasBit();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class SetBankAutosortDisabled : ClientPacket
|
||||
{
|
||||
public bool Disable;
|
||||
|
||||
public SetBankAutosortDisabled(WorldPacket packet) : base(packet) { }
|
||||
|
||||
public override void Read()
|
||||
{
|
||||
Disable = _worldPacket.HasBit();
|
||||
}
|
||||
}
|
||||
|
||||
//Structs
|
||||
public class ItemBonuses
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user