Core/Items: Implemented packets setting up inventory cleanup parameters
Port From (https://github.com/TrinityCore/TrinityCore/commit/cc9241784491198581a19f3f5502a42d048ea063)
This commit is contained in:
@@ -1388,4 +1388,17 @@ namespace Framework.Constants
|
||||
HeartLevelTooLow = 11, // Arg: RequiredLevel
|
||||
NotEquipped = 12
|
||||
}
|
||||
|
||||
[Flags]
|
||||
public enum BagSlotFlags
|
||||
{
|
||||
None = 0x00,
|
||||
DisableAutoSort = 0x01,
|
||||
PriorityEquipment = 0x02,
|
||||
PriorityConsumables = 0x04,
|
||||
PriorityTradeGoods = 0x08,
|
||||
PriorityJunk = 0x10,
|
||||
PriorityQuestItems = 0x20,
|
||||
ExcludeJunkSell = 0x40,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,7 +72,8 @@ namespace Framework.Database
|
||||
PrepareStatement(CharStatements.DEL_BATTLEGROUND_RANDOM, "DELETE FROM character_battleground_random WHERE guid = ?");
|
||||
PrepareStatement(CharStatements.INS_BATTLEGROUND_RANDOM, "INSERT INTO character_battleground_random (guid) VALUES (?)");
|
||||
|
||||
PrepareStatement(CharStatements.SEL_CHARACTER, "SELECT c.guid, account, name, race, class, gender, level, xp, money, inventorySlots, bankSlots, restState, playerFlags, playerFlagsEx, " +
|
||||
PrepareStatement(CharStatements.SEL_CHARACTER, "SELECT c.guid, account, name, race, class, gender, level, xp, money, inventorySlots, inventoryBagFlags, bagSlotFlags1, bagSlotFlags2, bagSlotFlags3, bagSlotFlags4, bagSlotFlags5, " +
|
||||
"bankSlots, bankBagFlags, bankBagSlotFlags1, bankBagSlotFlags2, bankBagSlotFlags3, bankBagSlotFlags4, bankBagSlotFlags5, bankBagSlotFlags6, bankBagSlotFlags7, restState, playerFlags, playerFlagsEx, " +
|
||||
"position_x, position_y, position_z, map, orientation, taximask, createTime, createMode, cinematic, totaltime, leveltime, rest_bonus, logout_time, is_logout_resting, resettalents_cost, " +
|
||||
"resettalents_time, primarySpecialization, trans_x, trans_y, trans_z, trans_o, transguid, extra_flags, summonedPetNumber, at_login, zone, online, death_expire_time, taxi_path, dungeonDifficulty, " +
|
||||
"totalKills, todayKills, yesterdayKills, chosenTitle, watchedFaction, drunk, " +
|
||||
@@ -448,13 +449,15 @@ namespace Framework.Database
|
||||
PrepareStatement(CharStatements.DEL_LFG_DATA, "DELETE FROM lfg_data WHERE guid = ?");
|
||||
|
||||
// Player saving
|
||||
PrepareStatement(CharStatements.INS_CHARACTER, "INSERT INTO characters (guid, account, name, race, class, gender, level, xp, money, inventorySlots, bankSlots, restState, playerFlags, playerFlagsEx, " +
|
||||
PrepareStatement(CharStatements.INS_CHARACTER, "INSERT INTO characters (guid, account, name, race, class, gender, level, xp, money, inventorySlots, inventoryBagFlags, bagSlotFlags1, bagSlotFlags2, bagSlotFlags3, bagSlotFlags4, bagSlotFlags5, " +
|
||||
"bankSlots, bankBagFlags, bankBagSlotFlags1, bankBagSlotFlags2, bankBagSlotFlags3, bankBagSlotFlags4, bankBagSlotFlags5, bankBagSlotFlags6, bankBagSlotFlags7, restState, playerFlags, playerFlagsEx, " +
|
||||
"map, instance_id, dungeonDifficulty, raidDifficulty, legacyRaidDifficulty, position_x, position_y, position_z, orientation, trans_x, trans_y, trans_z, trans_o, transguid, " +
|
||||
"taximask, createTime, createMode, cinematic, totaltime, leveltime, rest_bonus, logout_time, is_logout_resting, resettalents_cost, resettalents_time, primarySpecialization, " +
|
||||
"extra_flags, summonedPetNumber, at_login, death_expire_time, taxi_path, totalKills, todayKills, yesterdayKills, chosenTitle, watchedFaction, drunk, health, power1, power2, power3, " +
|
||||
"power4, power5, power6, power7, power8, power9, power10, latency, activeTalentGroup, lootSpecId, exploredZones, equipmentCache, knownTitles, actionBars, lastLoginBuild) VALUES " +
|
||||
"(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
|
||||
PrepareStatement(CharStatements.UPD_CHARACTER, "UPDATE characters SET name=?,race=?,class=?,gender=?,level=?,xp=?,money=?,inventorySlots=?,bankSlots=?,restState=?,playerFlags=?,playerFlagsEx=?," +
|
||||
"(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
|
||||
PrepareStatement(CharStatements.UPD_CHARACTER, "UPDATE characters SET name=?,race=?,class=?,gender=?,level=?,xp=?,money=?,inventorySlots=?,inventoryBagFlags=?,bagSlotFlags1=?,bagSlotFlags2=?,bagSlotFlags3=?,bagSlotFlags4=?,bagSlotFlags5=?," +
|
||||
"bankSlots=?,bankBagFlags=?,bankBagSlotFlags1=?,bankBagSlotFlags2=?,bankBagSlotFlags3=?,bankBagSlotFlags4=?,bankBagSlotFlags5=?,bankBagSlotFlags6=?,bankBagSlotFlags7=?,restState=?,playerFlags=?,playerFlagsEx=?," +
|
||||
"map=?,instance_id=?,dungeonDifficulty=?,raidDifficulty=?,legacyRaidDifficulty=?,position_x=?,position_y=?,position_z=?,orientation=?,trans_x=?,trans_y=?,trans_z=?,trans_o=?,transguid=?,taximask=?,cinematic=?,totaltime=?,leveltime=?,rest_bonus=?," +
|
||||
"logout_time=?,is_logout_resting=?,resettalents_cost=?,resettalents_time=?,numRespecs=?,primarySpecialization=?,extra_flags=?,summonedPetNumber=?,at_login=?,zone=?,death_expire_time=?,taxi_path=?," +
|
||||
"totalKills=?,todayKills=?,yesterdayKills=?,chosenTitle=?," +
|
||||
|
||||
@@ -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